SimpleAreaParser.cpp

Go to the documentation of this file.
00001 /*
00002 SagaEngine library
00003 Copyright (c) 2002-2006 Skalden Studio AS
00004 
00005 This software is provided 'as-is', without any express or implied 
00006 warranty. In no event will the authors be held liable for any 
00007 damages arising from the use of this software.
00008 
00009 Permission is granted to distribute the library under the terms of the 
00010 Q Public License version 1.0. Be sure to read and understand the license
00011 before using the library. It should be included here, or you may read it
00012 at http://www.trolltech.com/products/qt/licenses/licensing/qpl
00013 
00014 The original version of this library can be located at:
00015 http://www.sagaengine.com/
00016 
00017 Rune Myrland
00018 rune@skalden.com
00019 */
00020 
00021 
00022 #include <se_core.hpp>
00023 #include "SimpleAreaParser.hpp"
00024 #include "../area/SimpleArea.hpp"
00025 #include "../area/SimpleAreaFactory.hpp"
00026 #include "sim/area/AreaManager.hpp"
00027 
00028 using namespace se_core;
00029 
00030 namespace se_basic {
00031 
00032 
00033     SimpleAreaParser
00034     ::SimpleAreaParser(ParseManager& parser)
00035         : Parser(parser, Parser::GAME, Parser::AREA, 1)  {
00036     }
00037 
00038 
00039     void SimpleAreaParser
00040     ::parse(InputStream& in) {
00041         String* name = new String();
00042         in.readString(*name);
00043         LogDetail(name->get());
00044 
00045         unsigned short w = in.readShort();
00046         unsigned short h = in.readShort();
00047 
00048         short doCreateInstance = false;
00049         int code;
00050         while((code = in.readInfoCode()) != 'Q') {
00051             switch(code) {
00052             case 'C': // create instance
00053                 doCreateInstance = true;
00054                 break;
00055             default:
00056                 LogFatal("Unknown code '" << (char)(code) << "' in file " << in.name());
00057                 break;
00058             }
00059         }
00060 
00061         SimpleAreaFactory* f = new SimpleAreaFactory(name, w, h);
00062         SimSchema::areaManager.addFactory(f);
00063         if(doCreateInstance)
00064             SimSchema::areaManager.createArea(name->get(), name->get());
00065     }
00066 
00067 }

Home Page | SagaEngine trunk (updated nightly) reference generated Sun Dec 2 20:06:02 2007 by Doxygen version 1.3.9.1.

SourceForge.net Logo