Blame 8Kingdoms-1.1.0-cvs-fixes.patch

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