RemorseGame.cpp

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2006 The Pentagram team
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU General Public License
00006 as published by the Free Software Foundation; either version 2
00007 of the License, or (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 */
00018 
00019 #include "pent_include.h"
00020 
00021 #include "RemorseGame.h"
00022 
00023 #include "SettingManager.h"
00024 #include "FileSystem.h"
00025 #include "IDataSource.h"
00026 #include "PaletteManager.h"
00027 #include "ObjectManager.h"
00028 #include "World.h"
00029 #include "XFormBlend.h"
00030 #include "GameData.h"
00031 #include "GUIApp.h"
00032 #include "RawArchive.h"
00033 #include "ItemFactory.h"
00034 #include "MainActor.h"
00035 
00036 RemorseGame::RemorseGame() : Game()
00037 {
00038         // Set some defaults for gameplay-related settings
00039         SettingManager* settingman = SettingManager::get_instance();
00040         settingman->setDefault("skipstart", false);
00041         settingman->setDefault("endgame", false);
00042         settingman->setDefault("footsteps", true);
00043         settingman->setDefault("cheat", true);
00044         settingman->setDefault("textdelay", 5);
00045 }
00046 
00047 RemorseGame::~RemorseGame()
00048 {
00049 
00050 }
00051 
00052 bool RemorseGame::loadFiles()
00053 {
00054         // Load palette
00055         pout << "Load Palette" << std::endl;
00056         IDataSource *pf = FileSystem::get_instance()->ReadFile("@game/static/gamepal.pal");
00057         if (!pf) {
00058                 perr << "Unable to load static/gamepal.pal." << std::endl;
00059                 return false;
00060         }
00061 
00062         IBufferDataSource xfds(U8XFormPal,1024);
00063         PaletteManager::get_instance()->load(PaletteManager::Pal_Game, *pf, xfds);
00064         delete pf;
00065 
00066         pout << "Load GameData" << std::endl;
00067         GameData::get_instance()->loadRemorseData();
00068 
00069         return true;
00070 }
00071 
00072 bool RemorseGame::startGame()
00073 {
00074         // NOTE: assumes the entire engine has been reset!
00075 
00076         pout << "Starting new Crusader: No Remorse game." << std::endl;
00077 
00078         ObjectManager* objman = ObjectManager::get_instance();
00079 
00080         // reserve a number of objids just in case we'll need them sometime
00081         for (uint16 i = 384; i < 512; ++i)
00082                 objman->reserveObjId(i);
00083 
00084         // FIXME: fix flags and such
00085         Actor* actor = ItemFactory::createActor(1,0,0,Item::FLG_IN_NPC_LIST,
00086                                                                                         1,1,Item::EXT_PERMANENT_NPC,false);
00087         if (!actor) {
00088                 perr << "Couldn't create MainActor. Exiting." << std::endl;
00089                 exit(-1);
00090         }
00091 
00092         ObjectManager::get_instance()->assignActorObjId(actor, 1);
00093 
00094         actor->setLocation(60700, 59420, 16); 
00095 
00096 
00097         World::get_instance()->switchMap(1);
00098 
00099         GUIApp::get_instance()->setAvatarInStasis(true);
00100 
00101         return true;
00102 }
00103 
00104 bool RemorseGame::startInitialUsecode()
00105 {
00106 //      Process* proc = new StartU8Process();
00107 //      Kernel::get_instance()->addProcess(proc);
00108 
00109         return true;
00110 }
00111 
00112 
00113 ProcId RemorseGame::playIntroMovie()
00114 {
00115         return 0;
00116 }
00117 
00118 ProcId RemorseGame::playEndgameMovie()
00119 {
00120         return 0;
00121 }
00122 
00123 void RemorseGame::playCredits()
00124 {
00125 
00126 }
00127 
00128 void RemorseGame::writeSaveInfo(ODataSource* ods)
00129 {
00130 #if 0
00131         MainActor* av = getMainActor();
00132         sint32 x,y,z;
00133 
00134         std::string avname = av->getName();
00135         uint8 namelength = static_cast<uint8>(avname.size());
00136         ods->write1(namelength);
00137         for (unsigned int i = 0; i < namelength; ++i)
00138                 ods->write1(static_cast<uint8>(avname[i]));
00139 
00140         av->getLocation(x,y,z);
00141         ods->write2(av->getMapNum());
00142         ods->write4(static_cast<uint32>(x));
00143         ods->write4(static_cast<uint32>(y));
00144         ods->write4(static_cast<uint32>(z));
00145 
00146         ods->write2(av->getStr());
00147         ods->write2(av->getInt());
00148         ods->write2(av->getDex());
00149         ods->write2(av->getHP());
00150         ods->write2(av->getMaxHP());
00151         ods->write2(av->getMana());
00152         ods->write2(av->getMaxMana());
00153         ods->write2(av->getArmourClass());
00154         ods->write2(av->getTotalWeight());
00155 
00156         for (unsigned int i = 1; i <= 6; i++)
00157         {
00158                 uint16 objid = av->getEquip(i);
00159                 Item* item = getItem(objid);
00160                 if (item) {
00161                         ods->write4(item->getShape());
00162                         ods->write4(item->getFrame());
00163                 } else {
00164                         ods->write4(0);
00165                         ods->write4(0);
00166                 }
00167         }
00168 #endif
00169 }

Generated on Fri Jul 27 22:27:31 2007 for pentagram by  doxygen 1.4.7