From: Andrew C. <ac...@us...> - 2006-03-28 04:41:44
|
Update of /cvsroot/planeshift/planeshift/src/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27170/src/server Modified Files: actionmanager.cpp actionmanager.h cachemanager.cpp command.cpp spawnmanager.cpp spawnmanager.h Log Message: server console command spawn now has optional parameter to spawn in a particular sector. Useful for testing in NPCroom without having to spawn the entire database. Index: actionmanager.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/actionmanager.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** actionmanager.cpp 22 Feb 2006 22:19:43 -0000 1.24 --- actionmanager.cpp 28 Mar 2006 04:41:38 -0000 1.25 *************** *** 714,722 **** } ! bool ActionManager::RepopulateActionLocations() { unsigned int currentrow; psActionLocation* newaction; ! Result result( db->Select( "SELECT al.*, master.triggertype master_triggertype, master.responsetype master_responsetype, master.response master_response FROM action_locations al LEFT OUTER JOIN action_locations master ON al.master_id = master.id" ) ); if (!result.IsValid()) --- 714,729 ---- } ! bool ActionManager::RepopulateActionLocations(psSectorInfo *sectorinfo) { unsigned int currentrow; psActionLocation* newaction; ! csString query; ! ! if ( sectorinfo ) ! query.Format("SELECT al.*, master.triggertype master_triggertype, master.responsetype master_responsetype, master.response master_response FROM action_locations al LEFT OUTER JOIN action_locations master ON al.master_id = master.id WHERE al.sectorname='%s'", sectorinfo->name.GetData()); ! else ! query = "SELECT al.*, master.triggertype master_triggertype, master.responsetype master_responsetype, master.response master_response FROM action_locations al LEFT OUTER JOIN action_locations master ON al.master_id = master.id"; ! ! Result result( db->Select(query) ); if (!result.IsValid()) Index: actionmanager.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/actionmanager.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** actionmanager.h 22 Mar 2006 06:12:04 -0000 1.13 --- actionmanager.h 28 Mar 2006 04:41:38 -0000 1.14 *************** *** 42,45 **** --- 42,46 ---- class psActionLocation; class ActionManager; + class psSectorInfo; /** Time out event on interacting with an action item. *************** *** 82,88 **** /** Loads cache from action_location table in db ! * */ ! bool RepopulateActionLocations(); /** Delegates MsgEntry to correct MessageHandler --- 83,89 ---- /** Loads cache from action_location table in db ! * @param sectorinfo The sector to repopulate. Null means all sectors. */ ! bool RepopulateActionLocations(psSectorInfo *sectorinfo = 0); /** Delegates MsgEntry to correct MessageHandler Index: cachemanager.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/cachemanager.cpp,v retrieving revision 1.149 retrieving revision 1.150 diff -C2 -d -r1.149 -r1.150 *** cachemanager.cpp 27 Mar 2006 20:25:22 -0000 1.149 --- cachemanager.cpp 28 Mar 2006 04:41:38 -0000 1.150 *************** *** 1413,1417 **** Result result(sector ? ! db->Select("SELECT * from item_instances where loc_sectorid='%u' and char_id_owner=0 or parent_item_id!=0",sector->uid) : db->Select("SELECT * from item_instances where char_id_owner=0 or parent_item_id!=0")); --- 1413,1418 ---- Result result(sector ? ! db->Select("SELECT * from item_instances where loc_sector_id='%u' and char_id_owner=0 or parent_item_id!=0",sector->uid) : ! db->Select("SELECT * from item_instances where char_id_owner=0 or parent_item_id!=0")); Index: command.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/command.cpp,v retrieving revision 1.209 retrieving revision 1.210 diff -C2 -d -r1.209 -r1.210 *** command.cpp 14 Mar 2006 17:16:37 -0000 1.209 --- command.cpp 28 Mar 2006 04:41:39 -0000 1.210 *************** *** 474,488 **** } ! int com_spawn(char* filename) { // After world is loaded, repop NPCs--only the first time. static bool already_spawned = false; ! if (!already_spawned) { ! psserver->GetSpawnManager()->RepopulateLive(); ! psserver->GetSpawnManager()->RepopulateItems(); ! psserver->GetActionManager()->RepopulateActionLocations(); ! psserver->GetSpawnManager()->LoadHuntLocations(); // Start spawning already_spawned = true; } --- 474,491 ---- } ! int com_spawn(char* sector = 0) { // After world is loaded, repop NPCs--only the first time. static bool already_spawned = false; ! psSectorInfo *sectorinfo = NULL; ! if ( sector ) ! sectorinfo = CacheManager::GetSingleton().GetSectorInfoByName(sector); ! if (!already_spawned) { ! psserver->GetSpawnManager()->RepopulateLive(sectorinfo); ! psserver->GetSpawnManager()->RepopulateItems(sectorinfo); ! psserver->GetActionManager()->RepopulateActionLocations(sectorinfo); ! psserver->GetSpawnManager()->LoadHuntLocations(sectorinfo); // Start spawning already_spawned = true; } Index: spawnmanager.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/spawnmanager.cpp,v retrieving revision 1.162 retrieving revision 1.163 diff -C2 -d -r1.162 -r1.163 *** spawnmanager.cpp 22 Mar 2006 06:12:05 -0000 1.162 --- spawnmanager.cpp 28 Mar 2006 04:41:39 -0000 1.163 *************** *** 384,390 **** } ! void SpawnManager::LoadHuntLocations() { ! Result result(db->Select("select * from hunt_locations")); if (!result.IsValid() ) { --- 384,398 ---- } ! void SpawnManager::LoadHuntLocations(psSectorInfo *sectorinfo) { ! csString query; ! ! if ( sectorinfo ) ! query.Format("SELECT * FROM hunt_locations WHERE sector='%s'", sectorinfo->name.GetData() ); ! else ! query = "SELECT * FROM hunt_locations"; ! ! Result result(db->Select(query)); ! if (!result.IsValid() ) { *************** *** 497,506 **** } ! void SpawnManager::RepopulateLive() { psCharacter **chardatalist = NULL; int count; ! chardatalist = psServer::CharacterLoader.LoadAllNPCCharacterData(NULL,count); if (chardatalist==NULL) { --- 505,514 ---- } ! void SpawnManager::RepopulateLive(psSectorInfo *sectorinfo) { psCharacter **chardatalist = NULL; int count; ! chardatalist = psServer::CharacterLoader.LoadAllNPCCharacterData(sectorinfo,count); if (chardatalist==NULL) { *************** *** 520,524 **** } ! void SpawnManager::RepopulateItems() { int i,count,spawned; --- 528,532 ---- } ! void SpawnManager::RepopulateItems(psSectorInfo *sectorinfo) { int i,count,spawned; *************** *** 526,530 **** // Load list from database ! loadeditems=CacheManager::GetSingleton().LoadWorldItems(NULL,count); if (loadeditems==NULL) { --- 534,539 ---- // Load list from database ! loadeditems=CacheManager::GetSingleton().LoadWorldItems(sectorinfo,count); ! if (loadeditems==NULL) { Index: spawnmanager.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/spawnmanager.h,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** spawnmanager.h 22 Mar 2006 06:12:05 -0000 1.50 --- spawnmanager.h 28 Mar 2006 04:41:39 -0000 1.51 *************** *** 25,28 **** --- 25,29 ---- class psDatabase; class psSheduledItem; + class psSectorInfo; struct iCelEntity; *************** *** 349,356 **** void LoadSpawnRanges(SpawnRule *rule); ! /** ! * Load hunt location */ ! void LoadHuntLocations(); /** --- 350,357 ---- void LoadSpawnRanges(SpawnRule *rule); ! /** Load hunt location ! * @param sectorinfo The sector to load in. NULL means all sectors. */ ! void LoadHuntLocations(psSectorInfo *sectorinfo = 0); /** *************** *** 358,363 **** * "living" in the database. This will restore the server to its last * known NPC population if it crashes. */ ! void RepopulateLive(); /** --- 359,367 ---- * "living" in the database. This will restore the server to its last * known NPC population if it crashes. + * + * @param sectorinfo The sector we want to repopulate. + * If NULL then respawn all sectors. */ ! void RepopulateLive(psSectorInfo *sectorinfo = 0); /** *************** *** 374,379 **** /// Adds all items to the world. /** Called at the server startup to add all the items to the game. */ ! void RepopulateItems(); /** --- 378,385 ---- /// Adds all items to the world. /** Called at the server startup to add all the items to the game. + * @param sectorinfo The sector to respawn the items into. If NULL it will + * respawn all items in all sectors. */ ! void RepopulateItems(psSectorInfo *sectorinfo = 0); /** |