All pastes #1051205 Raw Edit

Anonym

public text v1 · immutable
#1051205 ·published 2008-06-19 16:50 UTC
rendered paste body
Index: src/server/cachemanager.cpp
===================================================================
--- src/server/cachemanager.cpp	(Revision 1776)
+++ src/server/cachemanager.cpp	(Arbeitskopie)
@@ -1945,6 +1945,21 @@
     return factions.Find(&fac);
 }
 
+Faction *CacheManager::GetFactionByName(const char *name)
+{
+    if (name==NULL)
+        return NULL;
+
+    csHash<Faction*, int>::GlobalIterator it (factions_by_id.GetIterator ());
+    while (it.HasNext ())
+    {
+        Faction* faction = it.Next();
+        if (!strcasecmp(faction->name, name))
+            return faction;
+    }
+    return NULL;
+}
+
 Faction *CacheManager::GetFaction(int id)
 {
     return factions_by_id.Get(id,0);
@@ -2289,6 +2304,7 @@
             Faction *f = new Faction;
             f->id = atoi( result_factions[x]["id"] );
             f->name = result_factions[x]["faction_name"];
+            f->description = result_factions[x]["faction_description"];
             f->weight = atof( result_factions[x]["faction_weight"] );
             // Stored two different ways
             factions.Insert(f,TREE_OWNS_DATA);
Index: src/server/progressionmanager.cpp
===================================================================
--- src/server/progressionmanager.cpp	(Revision 1776)
+++ src/server/progressionmanager.cpp	(Arbeitskopie)
@@ -4747,19 +4747,28 @@
             csString skillName = topNode->GetAttributeValue("NAME");
 
             psSkillInfo * info = CacheManager::GetSingleton().GetSkillByName(skillName);
-
+            Faction * faction = CacheManager::GetSingleton().GetFactionByName(skillName);
             csString buff;
+            csString description;
+            int cathegory;
             if (info)
             {
-                buff.Format("<DESCRIPTION NAME=\"%s\" DESC=\"%s\" CAT=\"%d\"/>",
-                            EscpXML(skillName).GetData(), EscpXML(info->description).GetData(),
-                            info->category);
+                description = EscpXML(info->description).GetData();
+                cathegory = info->category;
             }
+            else if (faction)
+            {
+                description = faction->description;
+                cathegory = PSSKILLS_CATEGORY_FACTIONS;
+            }
             else
             {
-                buff.Format("<DESCRIPTION NAME=\"%s\" DESC=\"\" CAT=\"%d\"/>",
-                            EscpXML(skillName).GetData(), PSSKILLS_CATEGORY_VARIOUS);  // if not found, then category unknown
+                description = "";
+                cathegory = PSSKILLS_CATEGORY_VARIOUS;
             }
+            buff.Format("<DESCRIPTION NAME=\"%s\" DESC=\"%s\" CAT=\"%d\"/>",
+                        EscpXML(skillName).GetData(), description.GetData(),
+                        cathegory);
 
             psCharacter* chr = client->GetCharacterData();
             psGUISkillMessage newmsg(client->GetClientNum(),
Index: src/server/cachemanager.h
===================================================================
--- src/server/cachemanager.h	(Revision 1776)
+++ src/server/cachemanager.h	(Arbeitskopie)
@@ -260,6 +260,7 @@
     // Factions
     Faction * GetFaction(const char *name);
     Faction * GetFaction(int id);
+    Faction * GetFactionByName(const char *name);
     csHash<Faction*, int> &GetFactionHash() { return factions_by_id; }
     
     // Spells
Index: src/server/database/mysql/upgrade_schema.sql
===================================================================
--- src/server/database/mysql/upgrade_schema.sql	(Revision 1776)
+++ src/server/database/mysql/upgrade_schema.sql	(Arbeitskopie)
@@ -926,6 +926,10 @@
 ALTER TABLE `guilds` MODIFY COLUMN `motd` CHAR(200);
 UPDATE `server_options` SET `option_value`='1189' WHERE `option_name`='db_version';
 
+#### 1190 - Zwenze - Adding description to factions table, FS#1699
+ALTER TABLE `factions` ADD COLUMN `faction_description` text AFTER `faction_name`;
+UPDATE `server_options` SET `option_value`='1190' WHERE `option_name`='db_version';
+
 # Insert your upgrade before this line. Remember when you set a new db_version
 # to update the server_options.sql file and update psserver.cpp as well.
 # This to ensure that everything is working if you use the create_all.sql to
Index: src/server/database/mysql/server_options.sql
===================================================================
--- src/server/database/mysql/server_options.sql	(Revision 1776)
+++ src/server/database/mysql/server_options.sql	(Arbeitskopie)
@@ -28,7 +28,7 @@
 # Dumping data for table server_options
 #
 
-INSERT INTO `server_options` VALUES ('db_version','1189');
+INSERT INTO `server_options` VALUES ('db_version','1190');
 INSERT INTO `server_options` VALUES ('game_time','15:00');
 INSERT INTO `server_options` VALUES ('game_date','100-1-1');
 INSERT INTO `server_options` VALUES ('standard_motd','This is the message of the day from server_options table.');
Index: src/server/database/mysql/factions.sql
===================================================================
--- src/server/database/mysql/factions.sql	(Revision 1776)
+++ src/server/database/mysql/factions.sql	(Arbeitskopie)
@@ -10,6 +10,7 @@
 CREATE TABLE factions (
   id int(8) unsigned NOT NULL auto_increment,
   faction_name varchar(40) NOT NULL DEFAULT '' ,
+  `faction_description` text,
   faction_weight float(6,3) NOT NULL DEFAULT '1.000' ,
   PRIMARY KEY (id)
 );
@@ -19,7 +20,7 @@
 # Dumping data for table 'factions'
 #
 
-INSERT INTO factions VALUES("1","orcs","1.000");
-INSERT INTO factions VALUES("2","merchants","1.000");
-INSERT INTO factions VALUES("3","liberals","2.000");
-INSERT INTO factions VALUES("4","conservatives","2.000");
+INSERT INTO factions VALUES("1","orcs","faction orcs will garantie you are hated by every one except orcs","1.000");
+INSERT INTO factions VALUES("2","merchants","faction merchants will offer you a nice deal from time to time","1.000");
+INSERT INTO factions VALUES("3","liberals","faction liberals will make you popular by all those who value freedom and such stuff","2.000");
+INSERT INTO factions VALUES("4","conservatives","faction conservatives are for those who value tradition and steady life style","2.000");
Index: src/server/psserver.cpp
===================================================================
--- src/server/psserver.cpp	(Revision 1776)
+++ src/server/psserver.cpp	(Arbeitskopie)
@@ -90,7 +90,7 @@
 #include "introductionmanager.h"
 
 // Remember to bump this in server_options.sql and add to upgrade_schema.sql!
-#define DATABASE_VERSION_STR "1189"
+#define DATABASE_VERSION_STR "1190"
 
 
 psCharacterLoader psServer::CharacterLoader;
Index: src/server/bulkobjects/psskills.h
===================================================================
--- src/server/bulkobjects/psskills.h	(Revision 1776)
+++ src/server/bulkobjects/psskills.h	(Arbeitskopie)
@@ -116,7 +116,8 @@
     PSSKILLS_CATEGORY_COMBAT,
     PSSKILLS_CATEGORY_MAGIC,
     PSSKILLS_CATEGORY_JOBS,        //Crafting, mining, etc.
-    PSSKILLS_CATEGORY_VARIOUS
+    PSSKILLS_CATEGORY_VARIOUS,
+    PSSKILLS_CATEGORY_FACTIONS
 };
 
 class psSkillInfo
Index: src/common/rpgrules/factions.h
===================================================================
--- src/common/rpgrules/factions.h	(Revision 1776)
+++ src/common/rpgrules/factions.h	(Arbeitskopie)
@@ -29,6 +29,7 @@
 struct Faction
 {
     csString name;
+    csString description;
     int      id;
     float    weight;
     bool operator==(Faction& other) const
Index: src/common/net/messages.h
===================================================================
--- src/common/net/messages.h	(Revision 1776)
+++ src/common/net/messages.h	(Arbeitskopie)
@@ -43,7 +43,7 @@
 
 // This holds the version number of the network code, remember to increase
 // this each time you do an update which breaks compatibility
-#define PS_NETVERSION   0x008B
+#define PS_NETVERSION   0x008C
 // Remember to bump the version in pscssetup.h, as well.
 
 // NPC Networking version is separate so we don't have to break compatibility
Index: src/client/gui/pawsskillwindow.h
===================================================================
--- src/client/gui/pawsskillwindow.h	(Revision 1776)
+++ src/client/gui/pawsskillwindow.h	(Arbeitskopie)
@@ -119,7 +119,7 @@
 	pawsListBox *factionList;
 
     pawsMultiLineTextBox *combatSkillDescription, *magicSkillDescription, *jobsSkillDescription;
-    pawsMultiLineTextBox *variousSkillDescription, *statsSkillDescription;
+    pawsMultiLineTextBox *variousSkillDescription, *statsSkillDescription, *factionsDescription;
     pawsProgressBar *hpBar, *manaBar, *pysStaminaBar, *menStaminaBar, *experienceBar;
     pawsTextBox *hpFrac, *manaFrac, *pysStaminaFrac, *menStaminaFrac, *experiencePerc;
 
Index: src/client/gui/pawsskillwindow.cpp
===================================================================
--- src/client/gui/pawsskillwindow.cpp	(Revision 1776)
+++ src/client/gui/pawsskillwindow.cpp	(Arbeitskopie)
@@ -126,7 +126,8 @@
     variousSkillList        = (pawsListBox*)FindWidget("VariousSkillList");
     variousSkillDescription = (pawsMultiLineTextBox*)FindWidget("VariousDescription");
 
-	factionList             = (pawsListBox*)FindWidget("FactionList");
+	factionList        = (pawsListBox*)FindWidget("FactionList");
+	factionsDescription = (pawsMultiLineTextBox*)FindWidget("FactionDescription");
     
     hpBar = dynamic_cast <pawsProgressBar*> (FindWidget("HPBar"));
     manaBar = dynamic_cast <pawsProgressBar*> (FindWidget("ManaBar"));
@@ -620,6 +621,11 @@
             variousSkillDescription->SetText(descStr);
             break;
         }
+        case 5://Factions
+        {
+            factionsDescription->SetText(descStr);
+            break;            
+        }
     }
 }
 
@@ -781,6 +787,11 @@
                     variousSkillDescription->SetText(desc->GetDescription());
                     break;
                 }
+                case 5://Factions
+                {
+                    factionsDescription->SetText(desc->GetDescription());
+                    break;            
+                }
             }
         }
     }
Index: data/gui/skillwindow.xml
===================================================================
--- data/gui/skillwindow.xml	(Revision 1776)
+++ data/gui/skillwindow.xml	(Arbeitskopie)
@@ -312,6 +312,17 @@
 						</column>
 					</columns>
 				</widget>
+				
+				<widget name="" factory="pawsTextBox" >
+					<font name="/planeshift/data/ttf/cupandtalon.ttf" r="255" g="255" b="255" size="12" />
+					<frame x="30" y="110" width="180" height="20" border="no"/>
+					<text string="Faction description:" />
+				</widget>
+				
+				<widget name="FactionDescription" factory="pawsMultiLineTextBox" >
+					<frame x="28" y="130" width="375" height="80" border="no" />
+					<font name="/planeshift/data/ttf/LiberationSans-Regular.ttf" r="180" g="180" b="180" size="10" />
+				</widget>
 			</widget>