Blame 8Kingdoms-1.1.0-cvs-fixes.patch

380a8b4
--- 8Kingdoms-1.1.0/ai/Diplomacy/diplomacy.cpp	2007-07-22 03:32:49.000000000 +0200
380a8b4
+++ kralovstvi/ai/Diplomacy/diplomacy.cpp	2007-08-27 07:28:48.000000000 +0200
380a8b4
@@ -245,7 +245,11 @@
380a8b4
 void CDiplomacyEngine::setOtherRelationshipPropertiesByIDs(TRelationshipProperties & relshp_prop,int dip1,int dip2)
380a8b4
 {
380a8b4
   DiplomatRelations[dip1][dip2].relationship_properties.offer_seen_by_enemy=relshp_prop.offer_seen_by_enemy;
380a8b4
+  if (relshp_prop.belief>MAXIMAL_BELIEF)
380a8b4
+    relshp_prop.belief=MAXIMAL_BELIEF;
380a8b4
   DiplomatRelations[dip1][dip2].relationship_properties.belief=relshp_prop.belief;
380a8b4
+  if (relshp_prop.guess_belief>MAXIMAL_BELIEF)
380a8b4
+    relshp_prop.guess_belief=MAXIMAL_BELIEF;
380a8b4
   DiplomatRelations[dip1][dip2].relationship_properties.guess_belief=relshp_prop.guess_belief;
380a8b4
 }
380a8b4
 
380a8b4
@@ -993,6 +997,11 @@
380a8b4
     {
380a8b4
       if ((i!=dipid) && (DiplomatRecords[i].slotused))
380a8b4
       {
380a8b4
+        // FOR SOME REASON belief can grow over MAXIMAL_BELIEF (tho it should not) - btw. the highest interval <ALLY_TRUCE_BORDER,MAXIMAL_BELIEF> represents alliance
380a8b4
+        if (DiplomatRelations[dipid][i].relationship_properties.guess_belief>MAXIMAL_BELIEF)
380a8b4
+          DiplomatRelations[dipid][i].relationship_properties.guess_belief=MAXIMAL_BELIEF;
380a8b4
+        if (DiplomatRelations[dipid][i].relationship_properties.belief>MAXIMAL_BELIEF)
380a8b4
+          DiplomatRelations[dipid][i].relationship_properties.belief=MAXIMAL_BELIEF;
380a8b4
         TRelationship believedrs=getBeliefRelationship(DiplomatRelations[dipid][i].relationship_properties.belief);
380a8b4
         if (DiplomatRelations[dipid][i].rs!=believedrs)
380a8b4
         {
380a8b4
--- 8Kingdoms-1.1.0/ai/ai_makra.h	2007-07-22 03:32:49.000000000 +0200
380a8b4
+++ kralovstvi/ai/ai_makra.h	2007-07-26 09:10:48.000000000 +0200
380a8b4
@@ -11,8 +11,8 @@
380a8b4
 #ifndef __PETR_ZITA_AI_MAKRA__
380a8b4
 #define __PETR_ZITA_AI_MAKRA__
380a8b4
 
380a8b4
-#define PRIORITY_AI_FLOODFILL 1
380a8b4
-#define PRIORITY_AI_ALLOC 1
380a8b4
+#define PRIORITY_AI_FLOODFILL 10
380a8b4
+#define PRIORITY_AI_ALLOC 10
380a8b4
 
380a8b4
 /** Makro urcujici, zdali se ma volat tah umele inteligence - ma ciste ladici vyznam. */
380a8b4
 #define AI_STRATEGIZER_ENABLED
380a8b4
--- 8Kingdoms-1.1.0/common/rm/rmconf.cpp	2007-07-22 03:32:51.000000000 +0200
380a8b4
+++ kralovstvi/common/rm/rmconf.cpp	2007-07-26 09:10:34.000000000 +0200
380a8b4
@@ -108,7 +108,7 @@
380a8b4
   if (retvalue!=0) // chyba pri cteni fajlu files.xml
380a8b4
   {
380a8b4
     GLOBALLOGID(PRIORITY_MISSING_FILE,"files.xml is missing or is damaged",XML_DIR);
380a8b4
-    THROW(E_8K_RM,"files.xml is corrupted"); 
380a8b4
+    THROW(E_8K_RM,"files.xml cannot be found or is corrupted or is missing"); 
380a8b4
   }
380a8b4
 
380a8b4
   // ziskani profilu
380a8b4
--- 8Kingdoms-1.1.0/common/rm/rmmap.cpp	2007-07-22 03:32:51.000000000 +0200
380a8b4
+++ kralovstvi/common/rm/rmmap.cpp	2007-08-27 07:28:48.000000000 +0200
380a8b4
@@ -1855,6 +1855,12 @@
380a8b4
               newmap.setDataInt((*this->mapsinfo[newtype])[this->idofmap]->roles[i]->relations[ii]->rs,"header",0,"roles",0,"role",i,"relations",0,"role",ii,"state",0,NULL);
380a8b4
               newmap.setDataInt((*this->mapsinfo[newtype])[this->idofmap]->roles[i]->relations[ii]->offeredrs,"header",0,"roles",0,"role",i,"relations",0,"role",ii,"offered",0,NULL);
380a8b4
               newmap.setDataInt((*this->mapsinfo[newtype])[this->idofmap]->roles[i]->relations[ii]->relationship_properties.offer_seen_by_enemy,"header",0,"roles",0,"role",i,"relations",0,"role",ii,"delivered",0,NULL);
380a8b4
+          if ((*this->mapsinfo[newtype])[this->idofmap]->roles[i]->relations[ii]->relationship_properties.belief>10000)
380a8b4
+          {
380a8b4
+            printf("This should not occure!!");
380a8b4
+            GLOBALLOGID(PRIORITY_FATAL,"Strange belief value role %i, belief %i",ii,(*this->mapsinfo[newtype])[this->idofmap]->roles[i]->relations[ii]->relationship_properties.belief);
380a8b4
+          }
380a8b4
+
380a8b4
               newmap.setDataInt((*this->mapsinfo[newtype])[this->idofmap]->roles[i]->relations[ii]->relationship_properties.belief,"header",0,"roles",0,"role",i,"relations",0,"role",ii,"belief",0,NULL);
380a8b4
               newmap.setDataInt((*this->mapsinfo[newtype])[this->idofmap]->roles[i]->relations[ii]->relationship_properties.guess_belief,"header",0,"roles",0,"role",i,"relations",0,"role",ii,"guessBelief",0,NULL);
380a8b4
             }
380a8b4
--- 8Kingdoms-1.1.0/common/xml/strda.cpp	2007-07-22 03:32:52.000000000 +0200
380a8b4
+++ kralovstvi/common/xml/strda.cpp	2007-08-16 18:26:32.000000000 +0200
380a8b4
@@ -25,10 +25,10 @@
380a8b4
   size_t j=count;
380a8b4
   for (k=0;k
380a8b4
   {
380a8b4
-    (*big)[i+k]=smallstr[k];
380a8b4
+    (*big)[(int)(i+k)]=smallstr[(int)k];
380a8b4
   }
380a8b4
   if (terminate)
380a8b4
-    (*big)[i+k]=0;
380a8b4
+    (*big)[(int)(i+k)]=0;
380a8b4
 }
380a8b4
 
380a8b4
 void addtoda(DA<char> *big,const char *smallstr,int terminate)
380a8b4
@@ -38,10 +38,10 @@
380a8b4
   size_t j=strlen(smallstr);
380a8b4
   for (k=0;k
380a8b4
   {
380a8b4
-    (*big)[i+k]=smallstr[k];
380a8b4
+    (*big)[(int)(i+k)]=smallstr[(int)k];
380a8b4
   }
380a8b4
   if (terminate)
380a8b4
-    (*big)[i+k]=0;
380a8b4
+    (*big)[(int)(i+k)]=0;
380a8b4
 }
380a8b4
 
380a8b4
 void addtodawcs(DA<wchar_t> *big,const wchar_t *smallstr,int terminate)
380a8b4
@@ -51,10 +51,10 @@
380a8b4
   size_t j=wcslen(smallstr);
380a8b4
   for (k=0;k
380a8b4
   {
380a8b4
-    (*big)[i+k]=smallstr[k];
380a8b4
+    (*big)[(int)(i+k)]=smallstr[(int)k];
380a8b4
   }
380a8b4
   if (terminate)
380a8b4
-    (*big)[i+k]=0;
380a8b4
+    (*big)[(int)(i+k)]=0;
380a8b4
 }
380a8b4
 
380a8b4
 void addtodastr(DA<char> *big,const char *smallstr,int terminate)
380a8b4
@@ -64,10 +64,10 @@
380a8b4
   size_t j=strlen(smallstr);
380a8b4
   for (k=0;k
380a8b4
   {
380a8b4
-    (*big)[i+k]=smallstr[k];
380a8b4
+    (*big)[(int)(i+k)]=smallstr[(int)k];
380a8b4
   }
380a8b4
   if (terminate)
380a8b4
-    (*big)[i+k]=0;
380a8b4
+    (*big)[(int)(i+k)]=0;
380a8b4
 }
380a8b4
 
380a8b4
 void addtostr(char **big,const char *smallstr,int terminate)
380a8b4
@@ -77,10 +77,10 @@
380a8b4
   size_t j=strlen(smallstr);
380a8b4
   for (k=0;k
380a8b4
   {
380a8b4
-    (*big)[i+k]=smallstr[k];
380a8b4
+    (*big)[(int)(i+k)]=smallstr[(int)k];
380a8b4
   }
380a8b4
   if (terminate)
380a8b4
-    (*big)[i+k]=0;
380a8b4
+    (*big)[(int)(i+k)]=0;
380a8b4
 }
380a8b4
 
380a8b4
 size_t newandstrcpy(char ** output, const char * input)
380a8b4
--- 8Kingdoms-1.1.0/common/xml/xml.cpp	2007-07-22 03:32:52.000000000 +0200
380a8b4
+++ kralovstvi/common/xml/xml.cpp	2007-08-16 18:26:33.000000000 +0200
380a8b4
@@ -1939,12 +1939,12 @@
380a8b4
 }
380a8b4
 
380a8b4
 
380a8b4
-int TXMLdata::getData(char * data2,int size,int *ids,char ** tags, int number)
380a8b4
+int TXMLdata::getData(char * data2,size_t size,int *ids,char ** tags, int number)
380a8b4
 // getData tentokrat s argumenty pole
380a8b4
 {
380a8b4
   if (number>0) // nema smysl se ptat na koren nebo neco co by melo byt nad
380a8b4
   {
380a8b4
-    int a;
380a8b4
+    size_t a;
380a8b4
     xmlcontainer * xc=0;//  = (xmlcontainer*) KMemAlloc(sizeof(xmlcontainer));
380a8b4
     int result=this->getTag(&xc,ids,tags,number);
380a8b4
     if ( (result!=XML_ERROR_NO_SUCH_A_PATH) && (xc!=NULL) && ((xc->content)!=NULL) && ((*(xc->content))[ids[number-1]]!=NULL)  )
380a8b4
@@ -1964,7 +1964,7 @@
380a8b4
       a=-1;
380a8b4
     if (size>0) // zjistim kam dat posledni 0 - tesne za vraceny retezec
380a8b4
     {
380a8b4
-      int n;
380a8b4
+      size_t n;
380a8b4
       if (a<(size-1))
380a8b4
         n=a;
380a8b4
       else
380a8b4
@@ -1976,7 +1976,7 @@
380a8b4
     if ( (result!=XML_ERROR_NO_SUCH_A_PATH) && (xc!=NULL) && ((xc->content)!=NULL) && ((*(xc->content))[ids[number-1]]!=NULL) && (xc->content!=NULL) && ((*(xc->content))[ids[number-1]]->data!=NULL))
380a8b4
     {
380a8b4
 //      KMemFree(xc);
380a8b4
-      return (a);
380a8b4
+      return ((int)a);
380a8b4
     }
380a8b4
     else
380a8b4
     {
380a8b4
@@ -1990,7 +1990,7 @@
380a8b4
   }
380a8b4
 }
380a8b4
 
380a8b4
-int TXMLdata::getData(char * data2,int size, char * firsttag, int firstid,...)
380a8b4
+int TXMLdata::getData(char * data2,size_t size, char * firsttag, int firstid,...)
380a8b4
 // varci data urcena cestou
380a8b4
 {
380a8b4
 // v tuto chvili neni jeste dobre mit daTags v debug okne ;D ... neni to inicializovane
380a8b4
@@ -2104,7 +2104,7 @@
380a8b4
       {
380a8b4
         break;
380a8b4
       }
380a8b4
-      if ((result)>=size) // v result neni koncova 0
380a8b4
+      if ((result)>=(int)size) // v result neni koncova 0
380a8b4
       {
380a8b4
         if ((size!=0) && ((*data2)!=NULL))
380a8b4
           KMemFree(*data2);
380a8b4
@@ -2113,7 +2113,7 @@
380a8b4
         done=-1;
380a8b4
       }
380a8b4
       else
380a8b4
-        done=size;
380a8b4
+        done=(int)size;
380a8b4
     } while (done==-1);
380a8b4
   }
380a8b4
 
380a8b4
--- 8Kingdoms-1.1.0/common/xml/xml.h	2007-07-22 03:32:52.000000000 +0200
380a8b4
+++ kralovstvi/common/xml/xml.h	2007-08-16 18:26:33.000000000 +0200
380a8b4
@@ -124,7 +124,7 @@
380a8b4
         @param firstid id prvniho nekorenoveho tagu na ceste k mistu kam se vklada
380a8b4
         @return Vraci \ref XML_ERROR_NO_SUCH_A_PATH pokud cesta neexistuje, jinak delku obsahu tagu (nezavisle na size) bez koncove 0
380a8b4
     */     
380a8b4
-    int getData(char * data2,int size, char * firsttag,int firstid,...);
380a8b4
+    int getData(char * data2,size_t size, char * firsttag,int firstid,...);
380a8b4
 
380a8b4
     /** Ziska cely obsah tagu v podobe retezce.
380a8b4
         Posledni parametr musi byt NULL, strida se vzdy tag a jeho id. 
380a8b4
@@ -160,7 +160,7 @@
380a8b4
         @param number delka cesty bez korenoveho tagu (take pocet prvku pole tags a ids)
380a8b4
         @return Vraci \ref XML_ERROR_NO_SUCH_A_PATH pokud cesta neexistuje, jinak delku obsahu tagu (nezavisle na size)
380a8b4
     */      
380a8b4
-    int getData(char * data2,int size,int *ids,char ** tags, int number);
380a8b4
+    int getData(char * data2,size_t size,int *ids,char ** tags, int number);
380a8b4
 
380a8b4
     /** Ziska okaz primo na data ulozena v xml.
380a8b4
         Tato funkce se musi pouzivat s opatrnosti pouze na cteni dat. Posledni parametr musi byt NULL.
380a8b4
--- 8Kingdoms-1.1.0/net/comm.h	2007-07-22 03:32:59.000000000 +0200
380a8b4
+++ kralovstvi/net/comm.h	2007-08-16 18:26:57.000000000 +0200
380a8b4
@@ -194,7 +194,7 @@
380a8b4
     int ping_time;
380a8b4
 
380a8b4
     /** Maximalni doba, po kterou se neprijal ping */
380a8b4
-    int max_timeout;
380a8b4
+    unsigned int max_timeout;
380a8b4
 
380a8b4
 };
380a8b4
 
380a8b4
--- 8Kingdoms-1.1.0/net/queue.h	2007-07-22 03:32:59.000000000 +0200
380a8b4
+++ kralovstvi/net/queue.h	2007-08-16 18:26:57.000000000 +0200
380a8b4
@@ -32,7 +32,7 @@
380a8b4
   char * data;              ///< Vlasni data
380a8b4
   mysocket to;              ///< Adresat 
380a8b4
   struct TMessageBody * next;   ///< Ukazatel na dalsi zpravu v seznamu
380a8b4
-  int part_sent;            ///< Jak velka cast byla poslana
380a8b4
+  size_t part_sent;            ///< Jak velka cast byla poslana
380a8b4
   size_t len;               ///< Velikost
380a8b4
 };
380a8b4
 
380a8b4
--- 8Kingdoms-1.1.0/net/server.cpp	2007-07-22 03:32:59.000000000 +0200
380a8b4
+++ kralovstvi/net/server.cpp	2007-08-16 18:26:58.000000000 +0200
380a8b4
@@ -818,7 +818,7 @@
380a8b4
   mysocket fd;
380a8b4
   j=0;
380a8b4
   int set=0;
380a8b4
-  int msglen3;
380a8b4
+  size_t msglen3;
380a8b4
   server.sin_family = AF_INET;
380a8b4
   server.sin_port = htons(80);      	               
380a8b4
   server.sin_addr = *((struct in_addr *)he->h_addr);
380a8b4
--- 8Kingdoms-1.1.0/world/players/player.cpp	2007-07-22 03:33:12.000000000 +0200
380a8b4
+++ kralovstvi/world/players/player.cpp	2007-08-27 07:28:48.000000000 +0200
380a8b4
@@ -72,6 +72,10 @@
380a8b4
         if (_data->game_data.relations[i] != NULL) {
380a8b4
             package->setInt(_data->game_data.relations[i]->rs, "relations", 0, "relationship", i, "rs", 0, NULL);
380a8b4
             package->setInt(_data->game_data.relations[i]->offeredrs, "relations", 0, "relationship", i, "offeredrs", 0, NULL);
380a8b4
+            // this was missing!!
380a8b4
+            package->setInt(_data->game_data.relations[i]->relationship_properties.belief, "relations", 0, "relationship", i, "belief", 0, NULL);
380a8b4
+            package->setInt(_data->game_data.relations[i]->relationship_properties.offer_seen_by_enemy, "relations", 0, "relationship", i, "offer_seen_by_enemy", 0, NULL);
380a8b4
+            package->setInt(_data->game_data.relations[i]->relationship_properties.guess_belief, "relations", 0, "relationship", i, "guess_belief", 0, NULL);
380a8b4
         }
380a8b4
     }
380a8b4
 }
380a8b4
@@ -119,6 +123,10 @@
380a8b4
             _data->game_data.relations[i] = (ai_ns::diplomacy_ns::TDipRelation *)KMemAlloc(sizeof(ai_ns::diplomacy_ns::TDipRelation));
380a8b4
             _data->game_data.relations[i]->rs = (ai_ns::diplomacy_ns::TRelationship)package->getInt("relations", 0, "relationship", i, "rs", 0, NULL);
380a8b4
             _data->game_data.relations[i]->offeredrs = (ai_ns::diplomacy_ns::TRelationship)package->getInt("relations", 0, "relationship", i, "offeredrs", 0, NULL);
380a8b4
+            // this was missing!!
380a8b4
+            _data->game_data.relations[i]->relationship_properties.belief=(ai_ns::diplomacy_ns::TRelationship)package->getInt("relations", 0, "relationship", i, "belief", 0, NULL);
380a8b4
+            _data->game_data.relations[i]->relationship_properties.guess_belief=(ai_ns::diplomacy_ns::TRelationship)package->getInt("relations", 0, "relationship", i, "guess_belief", 0, NULL);
380a8b4
+            _data->game_data.relations[i]->relationship_properties.offer_seen_by_enemy=(ai_ns::diplomacy_ns::TRelationship)package->getInt("relations", 0, "relationship", i, "offer_seen_by_enemy", 0, NULL);
380a8b4
 
380a8b4
         }
380a8b4
         else {
380a8b4
@@ -204,7 +212,7 @@
380a8b4
         info[it->first]->stats = it->second->data().statistics;
380a8b4
         for (i = 1; i <= MAX_PLAYERS; i++) {
380a8b4
             if (it->second->data().game_data.relations[i]) {
380a8b4
-                *(info[it->first]->relations[i]) = *(it->second->data().game_data.relations[i]);
380a8b4
+              *(info[it->first]->relations[i]) = *(it->second->data().game_data.relations[i]);
380a8b4
             }
380a8b4
             else {
380a8b4
                 info[it->first]->relations[i] = NULL;
380a8b4
--- 8Kingdoms-1.1.0/world/world_engine.cpp	2007-07-22 03:33:12.000000000 +0200
380a8b4
+++ kralovstvi/world/world_engine.cpp	2007-08-03 21:22:13.000000000 +0200
380a8b4
@@ -1853,14 +1853,18 @@
380a8b4
   // zaznamenam do statistik
380a8b4
   _world.players.townCaptured(town_occupied->new_player_id, town_occupied->former_player_id);
380a8b4
 
380a8b4
-  // dam o tom vedet diplomacii
380a8b4
-  if (former_player_id != 0) {              
380a8b4
-    TPacket_Diplomacy_ConquerCity conquerCity;
380a8b4
-    conquerCity.attacked_diplomat_world_id = former_player_id;
380a8b4
-    conquerCity.attacking_diplomat_world_id = new_player_id;
380a8b4
-    conquerCity.payment = _world.towns[town_id]->data().citysize * TOWN_INCOME;
380a8b4
+  // if the player is not dead or was not neutral, inform Diplomacy
380a8b4
+  if (former_player_id != 0)
380a8b4
+  {
380a8b4
+    if (_world.players[former_player_id]->data().game_data.state != PS_DEFEATED)
380a8b4
+    {
380a8b4
+      TPacket_Diplomacy_ConquerCity conquerCity;
380a8b4
+      conquerCity.attacked_diplomat_world_id = former_player_id;
380a8b4
+      conquerCity.attacking_diplomat_world_id = new_player_id;
380a8b4
+      conquerCity.payment = _world.towns[town_id]->data().citysize * TOWN_INCOME;
380a8b4
       
380a8b4
-    KSendGlobalMessage(MSG_DIPLOMACY_CONQUER_CITY, MOD_WORLD_SERVER, MOD_DIPLOMACY, &conquerCity);
380a8b4
+      KSendGlobalMessage(MSG_DIPLOMACY_CONQUER_CITY, MOD_WORLD_SERVER, MOD_DIPLOMACY, &conquerCity);
380a8b4
+    }
380a8b4
   }
380a8b4
 }
380a8b4