Blame 8Kingdoms-1.1.0-cvs-fixes.patch

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