From: <roa...@us...> - 2011-07-04 20:59:37
|
Revision: 7492 http://planeshift.svn.sourceforge.net/planeshift/?rev=7492&view=rev Author: roanduku Date: 2011-07-04 20:59:29 +0000 (Mon, 04 Jul 2011) Log Message: ----------- Linked all tribes to the recipe manager. Added column 'tribal_recipe' on tribes table. Added method prototypes for behavioral assembler in recipe.h. Modified Paths: -------------- soc/2011/tribe/src/npcclient/npcclient.cpp soc/2011/tribe/src/npcclient/tribe.cpp soc/2011/tribe/src/npcclient/tribe.h soc/2011/tribe/src/server/database/mysql/tribes.sql Modified: soc/2011/tribe/src/npcclient/npcclient.cpp =================================================================== --- soc/2011/tribe/src/npcclient/npcclient.cpp 2011-07-04 17:15:24 UTC (rev 7491) +++ soc/2011/tribe/src/npcclient/npcclient.cpp 2011-07-04 20:59:29 UTC (rev 7492) @@ -233,6 +233,12 @@ exit(1); } + if (!recipemanager->LoadRecipes()) + { + CPrintf(CON_ERROR, "Couldn't load the recipes table\n"); + exit(1); + } + if (!LoadTribes()) { CPrintf(CON_ERROR, "Couldn't load the tribes table\n"); @@ -250,12 +256,6 @@ CPrintf(CON_ERROR, "Couldn't load the sc_location_type table\n"); exit(1); } - - if (!recipemanager->LoadRecipes()) - { - CPrintf(CON_ERROR, "Couldn't load the recipes table\n"); - exit(1); - } cdsys = csQueryRegistry<iCollideSystem> (objreg); @@ -770,6 +770,7 @@ for (int i=0; i<(int)rs.Count(); i++) { Tribe *tribe = new Tribe; + if (tribe->Load(rs[i])) { tribes.Push(tribe); @@ -830,7 +831,10 @@ tribe->LoadResource(rs2[j]); } } // End Load Resources scope - + + // Enroll at Recipe Manager + tribe->SetRecipeManager(recipemanager); + recipemanager->AddTribe(tribe); } else { Modified: soc/2011/tribe/src/npcclient/tribe.cpp =================================================================== --- soc/2011/tribe/src/npcclient/tribe.cpp 2011-07-04 17:15:24 UTC (rev 7491) +++ soc/2011/tribe/src/npcclient/tribe.cpp 2011-07-04 20:59:29 UTC (rev 7492) @@ -45,6 +45,7 @@ #include "npcbehave.h" #include "perceptions.h" #include "tribeneed.h" +#include "recipe.h" extern iDataConnection *db; @@ -62,25 +63,26 @@ bool Tribe::Load(iResultRow& row) { - id = row.GetInt("id"); - name = row["name"]; + id = row.GetInt("id"); + name = row["name"]; + mainRecipeID = row.GetInt("tribal_recipe"); - homePos = csVector3(row.GetFloat("home_x"),row.GetFloat("home_y"),row.GetFloat("home_z")); - homeRadius = row.GetFloat("home_radius"); - homeSectorName = row["home_sector_name"]; - maxSize = row.GetInt("max_size"); - wealthResourceName = row["wealth_resource_name"]; - wealthResourceNick = row["wealth_resource_nick"]; - wealthResourceArea = row["wealth_resource_area"]; + homePos = csVector3(row.GetFloat("home_x"),row.GetFloat("home_y"),row.GetFloat("home_z")); + homeRadius = row.GetFloat("home_radius"); + homeSectorName = row["home_sector_name"]; + maxSize = row.GetInt("max_size"); + wealthResourceName = row["wealth_resource_name"]; + wealthResourceNick = row["wealth_resource_nick"]; + wealthResourceArea = row["wealth_resource_area"]; - wealthGatherNeed = row["wealth_gather_need"]; + wealthGatherNeed = row["wealth_gather_need"]; - wealthResourceGrowth = row.GetFloat("wealth_resource_growth"); - wealthResourceGrowthActive = row.GetFloat("wealth_resource_growth_active"); + wealthResourceGrowth = row.GetFloat("wealth_resource_growth"); + wealthResourceGrowthActive = row.GetFloat("wealth_resource_growth_active"); wealthResourceGrowthActiveLimit = row.GetInt("wealth_resource_growth_active_limit"); - reproductionCost = row.GetInt("reproduction_cost"); - npcIdleBehavior = row["npc_idle_behavior"]; + reproductionCost = row.GetInt("reproduction_cost"); + npcIdleBehavior = row["npc_idle_behavior"]; return true; } Modified: soc/2011/tribe/src/npcclient/tribe.h =================================================================== --- soc/2011/tribe/src/npcclient/tribe.h 2011-07-04 17:15:24 UTC (rev 7491) +++ soc/2011/tribe/src/npcclient/tribe.h 2011-07-04 20:59:29 UTC (rev 7492) @@ -37,6 +37,7 @@ // Local Includes //============================================================================= #include "tribeneed.h" +#include "recipe.h" class iResultRow; class EventManager; @@ -45,6 +46,7 @@ class TribeNeed; class Perception; class gemNPCActor; +class RecipeManager; #define TRIBE_UNLIMITED_SIZE 100 @@ -354,6 +356,12 @@ /** Dump needs to console */ void DumpNeeds() const; + + /** Sets the tribe's recipe manager */ + void SetRecipeManager(RecipeManager* rm) { recipeManager = rm; } + + /** Gets the id of this recipe */ + int GetTribalRecipe() { return mainRecipeID; } protected: @@ -369,6 +377,7 @@ void UpdateResourceRate( int amount ); int id; + int mainRecipeID; ///< The ID of the recipe which guides this tribe csString name; csArray<MemberID> membersId; csArray<NPC*> members; @@ -401,6 +410,7 @@ csTicks lastDeath; ///< Time when a member was last killed csTicks lastResource; ///< Time when a resource was last added. + RecipeManager* recipeManager; ///< The Recipe Manager handling this tribe }; #endif Modified: soc/2011/tribe/src/server/database/mysql/tribes.sql =================================================================== --- soc/2011/tribe/src/server/database/mysql/tribes.sql 2011-07-04 17:15:24 UTC (rev 7491) +++ soc/2011/tribe/src/server/database/mysql/tribes.sql 2011-07-04 20:59:29 UTC (rev 7492) @@ -26,6 +26,7 @@ wealth_resource_growth_active_limit int(10) NOT NULL default '0', reproduction_cost int(10) signed DEFAULT '0', npc_idle_behavior varchar(30) NOT NULL default 'do nothing', + tribal_recipe int(5) NOT NULL, PRIMARY KEY (`id`) ); @@ -33,5 +34,5 @@ # Dumping data for table characters # -INSERT INTO `tribes` VALUES (1,'Mining tribe',3,-75,0,-180,20,15,'Gold Ore','gold','mine','Dig',1.00,0.0,0,10,'do nothing'); +INSERT INTO `tribes` VALUES (1,'Mining tribe',3,-75,0,-180,20,15,'Gold Ore','gold','mine','Dig',1.00,0.0,0,10,'do nothing', 3); # INSERT INTO `tribes` VALUES (2,'Hunting tribe',3,-90,0,-230,5,5,'Flesh','flesh','hunting_ground','Hunt',1.00,0.50,100,60,'do nothing'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |