1 /* GemRB - Infinity Engine Emulator 2 * Copyright (C) 2006 The GemRB Project 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 * 18 * 19 */ 20 21 #ifndef PROJSERVER_H 22 #define PROJSERVER_H 23 24 #include "exports.h" 25 26 #include "Projectile.h" 27 28 namespace GemRB { 29 30 class SymbolMgr; 31 32 //the number of resrefs in areapro.2da (before the flags field) 33 #define AP_RESCNT 5 34 35 //this represents a line of projectl.ids 36 class ProjectileEntry 37 { 38 public: ProjectileEntry()39 ProjectileEntry() 40 { 41 resname[0] = 0; 42 projectile = NULL; 43 } ~ProjectileEntry()44 ~ProjectileEntry() 45 { 46 if (projectile) 47 delete projectile; 48 } 49 50 ieResRef resname; 51 Projectile *projectile; 52 }; 53 54 class ExplosionEntry 55 { 56 public: ExplosionEntry()57 ExplosionEntry() 58 { 59 memset(this,0,sizeof(ExplosionEntry)); 60 } 61 ieResRef resources[AP_RESCNT]; 62 int flags; 63 }; 64 65 //this singleton object serves the projectile objects 66 class GEM_EXPORT ProjectileServer 67 { 68 public: 69 ProjectileServer(); 70 ~ProjectileServer(); 71 72 Projectile *GetProjectileByIndex(unsigned int idx); 73 //it is highly unlikely we need this function 74 Projectile *GetProjectileByName(const ieResRef resname); 75 //returns the highest projectile id 76 unsigned int GetHighestProjectileNumber(); 77 int InitExplosion(); 78 int GetExplosionFlags(unsigned int idx); 79 ieResRef const *GetExplosion(unsigned int idx, int type); 80 //creates an empty projectile on the fly 81 Projectile *CreateDefaultProjectile(unsigned int idx); 82 private: 83 ProjectileEntry *projectiles; //this is the list of projectiles 84 int projectilecount; 85 ExplosionEntry *explosions; //this is the list of explosion resources 86 int explosioncount; 87 // internal function: what is max valid projectile id? 88 unsigned int PrepareSymbols(Holder<SymbolMgr> projlist); 89 // internal function: read projectiles 90 void AddSymbols(Holder<SymbolMgr> projlist); 91 //this method is used internally 92 Projectile *GetProjectile(unsigned int idx); 93 //creates a clone from the cached projectiles 94 Projectile *ReturnCopy(unsigned int idx); 95 //returns one of the resource names 96 }; 97 98 #endif // PROJSERVER_H 99 } 100 101 102