ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

knowledge.cpp

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the AUTHORS
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #include "engines/stark/resources/knowledge.h"
00024 
00025 #include "engines/stark/formats/xrc.h"
00026 
00027 #include "engines/stark/services/stateprovider.h"
00028 
00029 namespace Stark {
00030 namespace Resources {
00031 
00032 Knowledge::~Knowledge() {
00033 }
00034 
00035 Knowledge::Knowledge(Object *parent, byte subType, uint16 index, const Common::String &name) :
00036         Object(parent, subType, index, name),
00037         _booleanValue(false),
00038         _integerValue(0) {
00039     _type = TYPE;
00040 }
00041 
00042 void Knowledge::setBooleanValue(bool value) {
00043     _booleanValue = value;
00044 }
00045 
00046 bool Knowledge::getBooleanValue() {
00047     return _booleanValue;
00048 }
00049 
00050 void Knowledge::setIntegerValue(int32 value) {
00051     _integerValue = value;
00052 }
00053 
00054 int32 Knowledge::getIntegerValue() {
00055     return _integerValue;
00056 }
00057 
00058 void Knowledge::saveLoad(ResourceSerializer *serializer) {
00059     serializer->syncAsSint32LE(_integerValue);
00060     serializer->syncAsSint32LE(_booleanValue);
00061     serializer->syncAsResourceReference(_referenceValue);
00062 }
00063 
00064 void Knowledge::readData(Formats::XRCReadStream *stream) {
00065     Object::readData(stream);
00066 
00067     switch (_subType) {
00068     case kBoolean:
00069     case kBooleanWithChild:
00070         _booleanValue = stream->readBool();
00071         break;
00072     case kInteger:
00073     case kInteger2:
00074         _integerValue = stream->readSint32LE();
00075         break;
00076     case kReference:
00077         _referenceValue = stream->readResourceReference();
00078         break;
00079     default:
00080         error("Unknown knowledge subtype %d", _subType);
00081     }
00082 }
00083 
00084 void Knowledge::printData() {
00085     switch (_subType) {
00086     case kBoolean:
00087     case kBooleanWithChild:
00088         debug("value: %d", _booleanValue);
00089         break;
00090     case kInteger:
00091     case kInteger2:
00092         debug("value: %d", _integerValue);
00093         break;
00094     case kReference:
00095         debug("value: %s", _referenceValue.describe().c_str());
00096         break;
00097     default:
00098         error("Unknown knowledge subtype %d", _subType);
00099     }
00100 }
00101 
00102 } // End of namespace Resources
00103 } // End of namespace Stark


Generated on Sat Mar 16 2019 05:01:40 for ResidualVM by doxygen 1.7.1
curved edge   curved edge