1 diff -ruN 8Kingdoms-1.1.0-orig/8Kingdoms.cpp 8Kingdoms-1.1.0/8Kingdoms.cpp
2 --- 8Kingdoms-1.1.0-orig/8Kingdoms.cpp 2007-07-22 03:32:48.000000000 +0200
3 +++ 8Kingdoms-1.1.0/8Kingdoms.cpp 2009-11-02 20:20:09.000000000 +0100
10 #include "common/Interface.h"
11 #include "common/Msg.h"
14 int main(int argc, char** argv){
16 + Tcl_FindExecutable(argv[0]);
19 //parametry z prikazoveho radku
20 TCommandLine::parseCommandLine(argc, argv);
21 diff -ruN 8Kingdoms-1.1.0-orig/ai/Diplomacy/diplomacy.cpp 8Kingdoms-1.1.0/ai/Diplomacy/diplomacy.cpp
22 --- 8Kingdoms-1.1.0-orig/ai/Diplomacy/diplomacy.cpp 2007-07-22 03:32:49.000000000 +0200
23 +++ 8Kingdoms-1.1.0/ai/Diplomacy/diplomacy.cpp 2009-11-02 20:20:09.000000000 +0100
25 void CDiplomacyEngine::setOtherRelationshipPropertiesByIDs(TRelationshipProperties & relshp_prop,int dip1,int dip2)
27 DiplomatRelations[dip1][dip2].relationship_properties.offer_seen_by_enemy=relshp_prop.offer_seen_by_enemy;
28 + if (relshp_prop.belief>MAXIMAL_BELIEF)
29 + relshp_prop.belief=MAXIMAL_BELIEF;
30 DiplomatRelations[dip1][dip2].relationship_properties.belief=relshp_prop.belief;
31 + if (relshp_prop.guess_belief>MAXIMAL_BELIEF)
32 + relshp_prop.guess_belief=MAXIMAL_BELIEF;
33 DiplomatRelations[dip1][dip2].relationship_properties.guess_belief=relshp_prop.guess_belief;
38 if ((i!=dipid) && (DiplomatRecords[i].slotused))
40 + // FOR SOME REASON belief can grow over MAXIMAL_BELIEF (tho it should not) - btw. the highest interval <ALLY_TRUCE_BORDER,MAXIMAL_BELIEF> represents alliance
41 + if (DiplomatRelations[dipid][i].relationship_properties.guess_belief>MAXIMAL_BELIEF)
42 + DiplomatRelations[dipid][i].relationship_properties.guess_belief=MAXIMAL_BELIEF;
43 + if (DiplomatRelations[dipid][i].relationship_properties.belief>MAXIMAL_BELIEF)
44 + DiplomatRelations[dipid][i].relationship_properties.belief=MAXIMAL_BELIEF;
45 TRelationship believedrs=getBeliefRelationship(DiplomatRelations[dipid][i].relationship_properties.belief);
46 if (DiplomatRelations[dipid][i].rs!=believedrs)
48 diff -ruN 8Kingdoms-1.1.0-orig/ai/MapAnalyzer/mapanalyzer.cpp 8Kingdoms-1.1.0/ai/MapAnalyzer/mapanalyzer.cpp
49 --- 8Kingdoms-1.1.0-orig/ai/MapAnalyzer/mapanalyzer.cpp 2007-07-22 03:32:49.000000000 +0200
50 +++ 8Kingdoms-1.1.0/ai/MapAnalyzer/mapanalyzer.cpp 2009-11-02 20:20:09.000000000 +0100
54 #include "ai/MapAnalyzer/mapanalyzer.h"
57 using namespace World;
60 diff -ruN 8Kingdoms-1.1.0-orig/ai/Strategizer/attacks.cpp 8Kingdoms-1.1.0/ai/Strategizer/attacks.cpp
61 --- 8Kingdoms-1.1.0-orig/ai/Strategizer/attacks.cpp 2007-07-22 03:32:49.000000000 +0200
62 +++ 8Kingdoms-1.1.0/ai/Strategizer/attacks.cpp 2009-11-02 20:20:09.000000000 +0100
66 #include "ai/Strategizer/attacks.h"
69 using namespace World;
71 diff -ruN 8Kingdoms-1.1.0-orig/ai/ai_makra.h 8Kingdoms-1.1.0/ai/ai_makra.h
72 --- 8Kingdoms-1.1.0-orig/ai/ai_makra.h 2007-07-22 03:32:49.000000000 +0200
73 +++ 8Kingdoms-1.1.0/ai/ai_makra.h 2009-11-02 20:20:09.000000000 +0100
75 #ifndef __PETR_ZITA_AI_MAKRA__
76 #define __PETR_ZITA_AI_MAKRA__
78 -#define PRIORITY_AI_FLOODFILL 1
79 -#define PRIORITY_AI_ALLOC 1
80 +#define PRIORITY_AI_FLOODFILL 10
81 +#define PRIORITY_AI_ALLOC 10
83 /** Makro urcujici, zdali se ma volat tah umele inteligence - ma ciste ladici vyznam. */
84 #define AI_STRATEGIZER_ENABLED
85 diff -ruN 8Kingdoms-1.1.0-orig/common/TCL/tcl_script.cpp 8Kingdoms-1.1.0/common/TCL/tcl_script.cpp
86 --- 8Kingdoms-1.1.0-orig/common/TCL/tcl_script.cpp 2007-07-22 03:32:50.000000000 +0200
87 +++ 8Kingdoms-1.1.0/common/TCL/tcl_script.cpp 2009-11-02 20:20:09.000000000 +0100
89 #include "common/TCL/tcl_struct.h"
90 #include "world/useful.h"
91 #include "world/typedefs.h"
92 +#include "world/rules.h"
96 +/* We can get called from multiple threads, protected against reentrance
97 + through locks. But locks are not enough. Tcl is thread aware and does not
98 + allow an interpreter to be called from another thread then it is created.
99 + With Tcl-8.4 things work even when violating this Tcl thread model rule, but
100 + thats pure luck on our side.
102 + However with Tcl-8.5 calling an interpreter from another thread then it is
103 + created really no longer works. Under pthread using OS we solve this by
104 + using a per thread variable for the interpreter and creating an interpreter
105 + for each thread. Under non pthread OS we keep relying on our luck, so
106 + Tcl-8.5 may not be used there! */
109 +/* interpreter destructor for the per thread interpreter */
110 +static void interpreter_destructor(void *_interpreter)
112 + Tcl_DeleteInterp((Tcl_Interp *)_interpreter);
116 TTCL_Interpreter::TTCL_Interpreter()
118 - _interpreter = Tcl_CreateInterp();
120 + pthread_key_create(&_interpreter_key, interpreter_destructor);
123 + _interpreter = Tcl_CreateInterp();
127 TTCL_Interpreter::~TTCL_Interpreter()
130 + pthread_key_delete(_interpreter_key);
132 Tcl_DeleteInterp(_interpreter);
133 //KMemFree(_interpreter);
137 +Tcl_Interp *TTCL_Interpreter::getInterpreter()
140 + Tcl_Interp *_interpreter =
141 + (Tcl_Interp *)pthread_getspecific(_interpreter_key);
145 + _interpreter = Tcl_CreateInterp();
146 + pthread_setspecific(_interpreter_key, _interpreter);
150 + _rules->writeToTCL(*this);
151 + Tcl_CreateCommand(_interpreter, "KSendMessage", _TCLSendMessageProc,
153 + TTCL_Script script(this);
154 + script.loadStruct(_init_script);
159 + return _interpreter;
162 -void TTCL_Interpreter::init(TCL_SCRIPT * init_script)
163 +void TTCL_Interpreter::init(World::TRules * rules,
164 + Tcl_CmdProc * TCLSendMessageProc, TCL_SCRIPT * init_script)
168 + _TCLSendMessageProc = TCLSendMessageProc;
169 + _init_script = init_script;
171 + rules->writeToTCL(*this);
172 + Tcl_CreateCommand(getInterpreter(), "KSendMessage", TCLSendMessageProc,
174 TTCL_Script script(this);
175 script.loadStruct(init_script);
180 bool TTCL_Interpreter::setVar(const char * name, const TCL_VAR_TYPE type, void * value)
182 - if (_interpreter == NULL)
183 - THROW(E_8K_TCL_Error, "TCL interpreter has not been initialized properly");
185 // odstraneni predchoziho vyskytu promenne
186 - Tcl_UnsetVar(_interpreter, name, 0);
187 + Tcl_UnsetVar(getInterpreter(), name, 0);
189 // nastaveni nove hodnoty
195 - result = (Tcl_SetVar(_interpreter, name, (const char *)value, 0) != NULL);
196 + result = (Tcl_SetVar(getInterpreter(), name, (const char *)value, 0) != NULL);
201 snprintf(s, 255, "%d", *(int *)value);
203 // ulozim cislo do TCL
204 - result = (Tcl_SetVar(_interpreter, name, s, 0) != NULL);
205 + result = (Tcl_SetVar(getInterpreter(), name, s, 0) != NULL);
210 snprintf(s, 255, "%f", *(float *)value);
212 // ulozim cislo do TCL
213 - result = (Tcl_SetVar(_interpreter, name, s, 0) != NULL);
214 + result = (Tcl_SetVar(getInterpreter(), name, s, 0) != NULL);
220 bool TTCL_Interpreter::getVar(const char * name, const TCL_VAR_TYPE type, void * value)
222 - if (_interpreter == NULL)
223 - THROW(E_8K_TCL_Error, "TCL interpreter has not been initialized properly");
225 // nacteni objektu z TCL
226 - Tcl_Obj * tcl_obj = Tcl_GetVar2Ex(_interpreter, name, NULL, TCL_LEAVE_ERR_MSG);
227 + Tcl_Obj * tcl_obj = Tcl_GetVar2Ex(getInterpreter(), name, NULL, TCL_LEAVE_ERR_MSG);
229 // promennou se nepodarilo nacist (a pritom to nebylo asociativni pole)
230 if ((tcl_obj == NULL) && (type != TVT_INT_ARRAY) && (type != TVT_FLOAT_ARRAY) && (type != TVT_STRING_ARRAY)) {
231 @@ -173,14 +232,14 @@
235 - if (Tcl_GetIntFromObj(_interpreter, tcl_obj, (int *)value) == TCL_OK)
236 + if (Tcl_GetIntFromObj(getInterpreter(), tcl_obj, (int *)value) == TCL_OK)
243 - if (Tcl_GetDoubleFromObj(_interpreter, tcl_obj, &_value) == TCL_OK) {
244 + if (Tcl_GetDoubleFromObj(getInterpreter(), tcl_obj, &_value) == TCL_OK) {
245 // pretypovani na float
246 *(float *)value = (float)_value;
251 snprintf(s, MAX_STRLEN, "%d", value);
252 - return (Tcl_SetVar(_interpreter, name, s, 0) != NULL);
253 + return (Tcl_SetVar(getInterpreter(), name, s, 0) != NULL);
256 bool TTCL_Interpreter::setConstDouble(const char * name, const double value)
257 @@ -423,29 +482,21 @@
260 snprintf(s, MAX_STRLEN, "%.2f", value);
261 - return (Tcl_SetVar(_interpreter, name, s, 0) != NULL);
262 + return (Tcl_SetVar(getInterpreter(), name, s, 0) != NULL);
265 int TTCL_Interpreter::eval(const char * code)
267 - if (_interpreter == NULL)
268 - THROW(E_8K_TCL_Error, "TCL interpreter has not been initialized properly");
270 - int result = Tcl_Eval(_interpreter, code);
271 + int result = Tcl_Eval(getInterpreter(), code);
272 if (result == TCL_ERROR) {
273 - THROW(E_8K_TCL_Error, Tcl_GetStringResult(_interpreter));
274 + THROW(E_8K_TCL_Error, Tcl_GetStringResult(getInterpreter()));
279 const char * TTCL_Interpreter::getError()
281 - return Tcl_GetStringResult(_interpreter);
284 -Tcl_Command TTCL_Interpreter::createCommand(const char * tclName, Tcl_CmdProc * cName, ClientData clientData, Tcl_CmdDeleteProc * deleteProc)
286 - return Tcl_CreateCommand(_interpreter, tclName, cName, clientData, deleteProc);
287 + return Tcl_GetStringResult(getInterpreter());
290 void TTCL_Interpreter::setResult(TCL_VAR_TYPE type, void * value)
291 @@ -455,21 +506,21 @@
295 - Tcl_SetResult(_interpreter, (char *)value, NULL);
296 + Tcl_SetResult(getInterpreter(), (char *)value, NULL);
300 // prevedu cislo na string
301 snprintf(s, MAX_STRLEN, "%d", *(int *)value);
303 - Tcl_SetResult(_interpreter, s, NULL);
304 + Tcl_SetResult(getInterpreter(), s, NULL);
308 // prevedu cislo na string
309 snprintf(s, MAX_STRLEN, "%f", *(float *)value);
311 - Tcl_SetResult(_interpreter, s, NULL);
312 + Tcl_SetResult(getInterpreter(), s, NULL);
315 THROW(E_8K_TCL_UnknownType, "");
316 diff -ruN 8Kingdoms-1.1.0-orig/common/TCL/tcl_script.h 8Kingdoms-1.1.0/common/TCL/tcl_script.h
317 --- 8Kingdoms-1.1.0-orig/common/TCL/tcl_script.h 2007-07-22 03:32:50.000000000 +0200
318 +++ 8Kingdoms-1.1.0/common/TCL/tcl_script.h 2009-11-02 20:20:09.000000000 +0100
324 +#include <pthread.h>
326 #include "common/TCL/tcl_var.h"
328 /// pocet desetinnych mist, pouzitych pri konverzi cisel do TCL
338 /** Interpret skriptu jazyka TCL
339 Objektovy "obal" puvodnich TCL struktur.
341 @@ -184,16 +192,26 @@
342 class TTCL_Interpreter
346 + pthread_key_t _interpreter_key;
347 + TCL_SCRIPT * _init_script;
348 + Tcl_CmdProc * _TCLSendMessageProc;
349 + World::TRules * _rules;
351 Tcl_Interp * _interpreter;
353 + Tcl_Interp *getInterpreter();
360 /** Inicializace prostredi TCL interpreteru.
361 Nastaveni globalnich promennych, inkluze knihoven a definice spolecnych
364 - void init(TCL_SCRIPT * init_script);
365 + void init(World::TRules * rules, Tcl_CmdProc * TCLSendMessageProc,
366 + TCL_SCRIPT * init_script);
368 /** Ulozeni promenne do prostredi TCL interpretu
369 @param name jmeno promenne
372 const char * getError();
374 - /** Nastaveni uzivatelske funkce.
375 - Umozni asociovat volani funkce z TCL s funkci v C
376 - @param tclName jmeno funkce v TCL, jejiz volani chceme obsluhovat sami
377 - @param cName funkce z C, ktera bude realizovat telo funkce z TCL
378 - @param clientData arbitrary one-word value to pass to proc and deleteProc.
379 - @param deleteProc procedure to call before cmdName is deleted from the interpreter; allows for command-specific cleanup. If NULL, then no procedure is called before the command is deleted.
381 - Tcl_Command createCommand(const char * tclName, Tcl_CmdProc * cName, ClientData clientData = NULL, Tcl_CmdDeleteProc * deleteProc = NULL);
383 /// Nastaveni navratove hodnoty funkce
384 void setResult(TCL_VAR_TYPE type, void * value);
386 diff -ruN 8Kingdoms-1.1.0-orig/common/TCL/tcl_struct.cpp 8Kingdoms-1.1.0/common/TCL/tcl_struct.cpp
387 --- 8Kingdoms-1.1.0-orig/common/TCL/tcl_struct.cpp 2007-07-22 03:32:50.000000000 +0200
388 +++ 8Kingdoms-1.1.0/common/TCL/tcl_struct.cpp 2009-11-02 20:20:09.000000000 +0100
394 #include "common/compatibility.h"
395 #include "common/types.h"
396 #include "tcl_struct.h"
397 diff -ruN 8Kingdoms-1.1.0-orig/common/rm/rmconf.cpp 8Kingdoms-1.1.0/common/rm/rmconf.cpp
398 --- 8Kingdoms-1.1.0-orig/common/rm/rmconf.cpp 2007-07-22 03:32:51.000000000 +0200
399 +++ 8Kingdoms-1.1.0/common/rm/rmconf.cpp 2009-11-02 20:20:09.000000000 +0100
401 if (retvalue!=0) // chyba pri cteni fajlu files.xml
403 GLOBALLOGID(PRIORITY_MISSING_FILE,"files.xml is missing or is damaged",XML_DIR);
404 - THROW(E_8K_RM,"files.xml is corrupted");
405 + THROW(E_8K_RM,"files.xml cannot be found or is corrupted or is missing");
409 diff -ruN 8Kingdoms-1.1.0-orig/common/rm/rmmap.cpp 8Kingdoms-1.1.0/common/rm/rmmap.cpp
410 --- 8Kingdoms-1.1.0-orig/common/rm/rmmap.cpp 2007-07-22 03:32:51.000000000 +0200
411 +++ 8Kingdoms-1.1.0/common/rm/rmmap.cpp 2009-11-02 20:20:09.000000000 +0100
412 @@ -1855,6 +1855,12 @@
413 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);
414 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);
415 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);
416 + if ((*this->mapsinfo[newtype])[this->idofmap]->roles[i]->relations[ii]->relationship_properties.belief>10000)
418 + printf("This should not occure!!");
419 + GLOBALLOGID(PRIORITY_FATAL,"Strange belief value role %i, belief %i",ii,(*this->mapsinfo[newtype])[this->idofmap]->roles[i]->relations[ii]->relationship_properties.belief);
422 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);
423 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);
425 diff -ruN 8Kingdoms-1.1.0-orig/common/xml/strda.cpp 8Kingdoms-1.1.0/common/xml/strda.cpp
426 --- 8Kingdoms-1.1.0-orig/common/xml/strda.cpp 2007-07-22 03:32:52.000000000 +0200
427 +++ 8Kingdoms-1.1.0/common/xml/strda.cpp 2009-11-02 20:20:09.000000000 +0100
432 - (*big)[i+k]=smallstr[k];
433 + (*big)[(int)(i+k)]=smallstr[(int)k];
437 + (*big)[(int)(i+k)]=0;
440 void addtoda(DA<char> *big,const char *smallstr,int terminate)
442 size_t j=strlen(smallstr);
445 - (*big)[i+k]=smallstr[k];
446 + (*big)[(int)(i+k)]=smallstr[(int)k];
450 + (*big)[(int)(i+k)]=0;
453 void addtodawcs(DA<wchar_t> *big,const wchar_t *smallstr,int terminate)
455 size_t j=wcslen(smallstr);
458 - (*big)[i+k]=smallstr[k];
459 + (*big)[(int)(i+k)]=smallstr[(int)k];
463 + (*big)[(int)(i+k)]=0;
466 void addtodastr(DA<char> *big,const char *smallstr,int terminate)
468 size_t j=strlen(smallstr);
471 - (*big)[i+k]=smallstr[k];
472 + (*big)[(int)(i+k)]=smallstr[(int)k];
476 + (*big)[(int)(i+k)]=0;
479 void addtostr(char **big,const char *smallstr,int terminate)
481 size_t j=strlen(smallstr);
484 - (*big)[i+k]=smallstr[k];
485 + (*big)[(int)(i+k)]=smallstr[(int)k];
489 + (*big)[(int)(i+k)]=0;
492 size_t newandstrcpy(char ** output, const char * input)
493 diff -ruN 8Kingdoms-1.1.0-orig/common/xml/xml.cpp 8Kingdoms-1.1.0/common/xml/xml.cpp
494 --- 8Kingdoms-1.1.0-orig/common/xml/xml.cpp 2007-07-22 03:32:52.000000000 +0200
495 +++ 8Kingdoms-1.1.0/common/xml/xml.cpp 2009-11-02 20:20:09.000000000 +0100
496 @@ -1939,12 +1939,12 @@
500 -int TXMLdata::getData(char * data2,int size,int *ids,char ** tags, int number)
501 +int TXMLdata::getData(char * data2,size_t size,int *ids,char ** tags, int number)
502 // getData tentokrat s argumenty pole
504 if (number>0) // nema smysl se ptat na koren nebo neco co by melo byt nad
508 xmlcontainer * xc=0;// = (xmlcontainer*) KMemAlloc(sizeof(xmlcontainer));
509 int result=this->getTag(&xc,ids,tags,number);
510 if ( (result!=XML_ERROR_NO_SUCH_A_PATH) && (xc!=NULL) && ((xc->content)!=NULL) && ((*(xc->content))[ids[number-1]]!=NULL) )
511 @@ -1964,7 +1964,7 @@
513 if (size>0) // zjistim kam dat posledni 0 - tesne za vraceny retezec
520 @@ -1976,7 +1976,7 @@
521 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))
529 @@ -1990,7 +1990,7 @@
533 -int TXMLdata::getData(char * data2,int size, char * firsttag, int firstid,...)
534 +int TXMLdata::getData(char * data2,size_t size, char * firsttag, int firstid,...)
535 // varci data urcena cestou
537 // v tuto chvili neni jeste dobre mit daTags v debug okne ;D ... neni to inicializovane
538 @@ -2104,7 +2104,7 @@
542 - if ((result)>=size) // v result neni koncova 0
543 + if ((result)>=(int)size) // v result neni koncova 0
545 if ((size!=0) && ((*data2)!=NULL))
547 @@ -2113,7 +2113,7 @@
556 diff -ruN 8Kingdoms-1.1.0-orig/common/xml/xml.h 8Kingdoms-1.1.0/common/xml/xml.h
557 --- 8Kingdoms-1.1.0-orig/common/xml/xml.h 2007-07-22 03:32:52.000000000 +0200
558 +++ 8Kingdoms-1.1.0/common/xml/xml.h 2009-11-02 20:20:09.000000000 +0100
560 @param firstid id prvniho nekorenoveho tagu na ceste k mistu kam se vklada
561 @return Vraci \ref XML_ERROR_NO_SUCH_A_PATH pokud cesta neexistuje, jinak delku obsahu tagu (nezavisle na size) bez koncove 0
563 - int getData(char * data2,int size, char * firsttag,int firstid,...);
564 + int getData(char * data2,size_t size, char * firsttag,int firstid,...);
566 /** Ziska cely obsah tagu v podobe retezce.
567 Posledni parametr musi byt NULL, strida se vzdy tag a jeho id.
569 @param number delka cesty bez korenoveho tagu (take pocet prvku pole tags a ids)
570 @return Vraci \ref XML_ERROR_NO_SUCH_A_PATH pokud cesta neexistuje, jinak delku obsahu tagu (nezavisle na size)
572 - int getData(char * data2,int size,int *ids,char ** tags, int number);
573 + int getData(char * data2,size_t size,int *ids,char ** tags, int number);
575 /** Ziska okaz primo na data ulozena v xml.
576 Tato funkce se musi pouzivat s opatrnosti pouze na cteni dat. Posledni parametr musi byt NULL.
577 diff -ruN 8Kingdoms-1.1.0-orig/gui/contexts/Game.cpp 8Kingdoms-1.1.0/gui/contexts/Game.cpp
578 --- 8Kingdoms-1.1.0-orig/gui/contexts/Game.cpp 2007-07-22 03:32:57.000000000 +0200
579 +++ 8Kingdoms-1.1.0/gui/contexts/Game.cpp 2009-11-02 20:20:09.000000000 +0100
580 @@ -3216,7 +3216,7 @@
582 ei = GAME_EVENT(iPlayerOnTurn, eitUnitMembersDied, hid, rmtxti->getWChar(wtemp, LABEL_MAX_LENGTH, TEXT_EVENT_UNHEALEDMEN));
583 ei->data1 = (void*)u;
584 - ei->data2 = *((void**)&count);
585 + ei->data2 = (void*)count;
588 u->membersDied(count);
589 diff -ruN 8Kingdoms-1.1.0-orig/gui/engine/AdvGeom.cpp 8Kingdoms-1.1.0/gui/engine/AdvGeom.cpp
590 --- 8Kingdoms-1.1.0-orig/gui/engine/AdvGeom.cpp 2007-07-22 03:32:58.000000000 +0200
591 +++ 8Kingdoms-1.1.0/gui/engine/AdvGeom.cpp 2009-11-02 20:30:18.000000000 +0100
598 /*****************************************************************************/
600 diff -ruN 8Kingdoms-1.1.0-orig/gui/engine/Effects.cpp 8Kingdoms-1.1.0/gui/engine/Effects.cpp
601 --- 8Kingdoms-1.1.0-orig/gui/engine/Effects.cpp 2007-07-22 03:32:58.000000000 +0200
602 +++ 8Kingdoms-1.1.0/gui/engine/Effects.cpp 2009-11-02 20:20:09.000000000 +0100
611 diff -ruN 8Kingdoms-1.1.0-orig/gui/model/UnitFormation.cpp 8Kingdoms-1.1.0/gui/model/UnitFormation.cpp
612 --- 8Kingdoms-1.1.0-orig/gui/model/UnitFormation.cpp 2007-07-22 03:32:58.000000000 +0200
613 +++ 8Kingdoms-1.1.0/gui/model/UnitFormation.cpp 2009-11-02 20:20:09.000000000 +0100
615 //vypocti polohy pro cleny
616 TUnitMemberPosition ump;
618 - getUnitMemberDim(0, &ump.p2fDim);
619 int size = (int)unit->vMembers.size();
621 + getUnitMemberDim(0, &ump.p2fDim);
622 for(int i = 0; i < size; i++)
624 findFreeMemberPosition(vumpPositions_c, &(ump.p2fPos), &(ump.p2fDir));
625 diff -ruN 8Kingdoms-1.1.0-orig/net/comm.h 8Kingdoms-1.1.0/net/comm.h
626 --- 8Kingdoms-1.1.0-orig/net/comm.h 2007-07-22 03:32:59.000000000 +0200
627 +++ 8Kingdoms-1.1.0/net/comm.h 2009-11-02 20:20:09.000000000 +0100
631 /** Maximalni doba, po kterou se neprijal ping */
633 + unsigned int max_timeout;
637 diff -ruN 8Kingdoms-1.1.0-orig/net/netinit.cpp 8Kingdoms-1.1.0/net/netinit.cpp
638 --- 8Kingdoms-1.1.0-orig/net/netinit.cpp 2007-07-22 03:32:59.000000000 +0200
639 +++ 8Kingdoms-1.1.0/net/netinit.cpp 2009-11-02 20:20:09.000000000 +0100
641 if (freeprofilename==0) // pokud takovy profil neni uz pripojen
643 net_server->startPing(from);
644 - KSendMessage(RQUEUE,MSG_NEW_CONNECTION_ACCEPTED,MOD_NET,MOD_NET,*((void**)(&from)));
645 + KSendMessage(RQUEUE,MSG_NEW_CONNECTION_ACCEPTED,MOD_NET,MOD_NET,(void*)from);
650 int from = new_connection_info->msgFrom();
651 net_server->stopAnnouncingMissingPlayers();
652 net_server->startPing(from);
653 - KSendMessage(RQUEUE,MSG_CLIENT_HAS_RECONNECTED,MOD_NET,BROADCAST,*((void**)(&from)));
654 - KSendMessage(RQUEUE,MSG_CLIENT_RECONNECTION_ACCEPTED,MOD_NET,MOD_NET,*((void**)(&from)));
655 + KSendMessage(RQUEUE,MSG_CLIENT_HAS_RECONNECTED,MOD_NET,BROADCAST,(void*)from);
656 + KSendMessage(RQUEUE,MSG_CLIENT_RECONNECTION_ACCEPTED,MOD_NET,MOD_NET,(void*)from);
661 net_client->addClientInfo(ni);
663 if (msgId==MSG_CLIENT_RECONNECTION_INFO)
664 - KSendMessage(RQUEUE,MSG_CLIENT_RECONNECTION_REPORT,MOD_NET,BROADCAST,*((void**)(&(ni->clientid))));
665 + KSendMessage(RQUEUE,MSG_CLIENT_RECONNECTION_REPORT,MOD_NET,BROADCAST,(void*)(ni->clientid));
667 - KSendMessage(RQUEUE,MSG_NEW_CONNECTION_REPORT,MOD_NET,BROADCAST,*((void**)(&(ni->clientid))));
668 + KSendMessage(RQUEUE,MSG_NEW_CONNECTION_REPORT,MOD_NET,BROADCAST,(void*)(ni->clientid));
670 delete(new_connetion_info);
674 net_client->removeClientInfo(who);
676 - KSendMessage(RQUEUE,MSG_CLIENT_DISCONNECTION_REPORT,MOD_NET,BROADCAST,*((void**)(&who)));
677 + KSendMessage(RQUEUE,MSG_CLIENT_DISCONNECTION_REPORT,MOD_NET,BROADCAST,(void*)who);
681 diff -ruN 8Kingdoms-1.1.0-orig/net/queue.h 8Kingdoms-1.1.0/net/queue.h
682 --- 8Kingdoms-1.1.0-orig/net/queue.h 2007-07-22 03:32:59.000000000 +0200
683 +++ 8Kingdoms-1.1.0/net/queue.h 2009-11-02 20:20:09.000000000 +0100
685 char * data; ///< Vlasni data
686 mysocket to; ///< Adresat
687 struct TMessageBody * next; ///< Ukazatel na dalsi zpravu v seznamu
688 - int part_sent; ///< Jak velka cast byla poslana
689 + size_t part_sent; ///< Jak velka cast byla poslana
690 size_t len; ///< Velikost
693 diff -ruN 8Kingdoms-1.1.0-orig/net/server.cpp 8Kingdoms-1.1.0/net/server.cpp
694 --- 8Kingdoms-1.1.0-orig/net/server.cpp 2007-07-22 03:32:59.000000000 +0200
695 +++ 8Kingdoms-1.1.0/net/server.cpp 2009-11-02 20:20:09.000000000 +0100
698 // In case in profile is set to announce and is not currently announcing
700 - KSendMessage(RQUEUE,MSG_CLIENT_DISCONNECTION_ACCEPTED,MOD_NET,MOD_NET,*((void**)(&id)));
701 + KSendMessage(RQUEUE,MSG_CLIENT_DISCONNECTION_ACCEPTED,MOD_NET,MOD_NET,(void*)id);
706 // printf("Socket se zavrel - klient %i\n",i);
707 if (that->status!=STATUS_ENDING)
709 - KSendMessage(RQUEUE,MSG_CLIENT_HAS_DISCONNECTED,MOD_NET,BROADCAST,*((void**)(&i)));
710 + KSendMessage(RQUEUE,MSG_CLIENT_HAS_DISCONNECTED,MOD_NET,BROADCAST,(void*)i);
711 that->clientDisconnected(i);
716 int sin_size = sizeof(struct sockaddr_in); // Windows chteji do accept int
718 - size_t sin_size = sizeof(struct sockaddr_in);
719 + socklen_t sin_size = sizeof(struct sockaddr_in);
724 GLOBALLOGID(PRIORITY_NEW_CONNECTION, "Server - A local client having id %i has connected, free space: %i",(*client)->clientid,this->getFreeClientCount());
725 // printf("\nKlient se pripojil id %i, port %i, volne: %i",(*client)->clientid,(*client)->fd,this->getFreeClientCount());
727 - KSendMessage(RQUEUE,MSG_LOCAL_CLIENT_ADDED,MOD_NET,MOD_NET,*((void**)(&((*client)->clientid))));
728 - KSendMessage(RQUEUE,MSG_NEW_CONNECTION_ACCEPTED,MOD_NET,MOD_NET,*((void**)(&((*client)->clientid))));
729 + KSendMessage(RQUEUE,MSG_LOCAL_CLIENT_ADDED,MOD_NET,MOD_NET,(void*)((*client)->clientid));
730 + KSendMessage(RQUEUE,MSG_NEW_CONNECTION_ACCEPTED,MOD_NET,MOD_NET,(void*)((*client)->clientid));
740 server.sin_family = AF_INET;
741 server.sin_port = htons(80);
742 server.sin_addr = *((struct in_addr *)he->h_addr);
743 @@ -1223,7 +1223,7 @@
746 if (that->status!=STATUS_ENDING)
747 - KSendMessage(RQUEUE,MSG_CLIENT_HAS_DISCONNECTED,MOD_NET,BROADCAST,*((void**)(&i)));
748 + KSendMessage(RQUEUE,MSG_CLIENT_HAS_DISCONNECTED,MOD_NET,BROADCAST,(void*)i);
752 diff -ruN 8Kingdoms-1.1.0-orig/res/xml/scripts/unit_recruit_elite.xml 8Kingdoms-1.1.0/res/xml/scripts/unit_recruit_elite.xml
753 --- 8Kingdoms-1.1.0-orig/res/xml/scripts/unit_recruit_elite.xml 2007-07-22 03:33:11.000000000 +0200
754 +++ 8Kingdoms-1.1.0/res/xml/scripts/unit_recruit_elite.xml 2009-11-02 20:20:09.000000000 +0100
756 # pomocna promenna pro uchovani poctu zbyvajicich zivotu
757 set missing_lives [expr $max_lives - $unit(lives)];
759 - if {$unit_types($unit(type), cure_cost) > 0} {
760 + if {($unit_types($unit(type), cure_cost) > 0) && ($unit(level) > 0)} {
761 # pomocna promenna pro uchovani maximalniho poctu zivotu, na ktere
763 set money [expr floor($player(money) / ($unit(level) * $unit_types($unit(type), cure_cost)))];
764 diff -ruN 8Kingdoms-1.1.0-orig/world/players/player.cpp 8Kingdoms-1.1.0/world/players/player.cpp
765 --- 8Kingdoms-1.1.0-orig/world/players/player.cpp 2007-07-22 03:33:12.000000000 +0200
766 +++ 8Kingdoms-1.1.0/world/players/player.cpp 2009-11-02 20:20:09.000000000 +0100
768 if (_data->game_data.relations[i] != NULL) {
769 package->setInt(_data->game_data.relations[i]->rs, "relations", 0, "relationship", i, "rs", 0, NULL);
770 package->setInt(_data->game_data.relations[i]->offeredrs, "relations", 0, "relationship", i, "offeredrs", 0, NULL);
771 + // this was missing!!
772 + package->setInt(_data->game_data.relations[i]->relationship_properties.belief, "relations", 0, "relationship", i, "belief", 0, NULL);
773 + package->setInt(_data->game_data.relations[i]->relationship_properties.offer_seen_by_enemy, "relations", 0, "relationship", i, "offer_seen_by_enemy", 0, NULL);
774 + package->setInt(_data->game_data.relations[i]->relationship_properties.guess_belief, "relations", 0, "relationship", i, "guess_belief", 0, NULL);
779 _data->game_data.relations[i] = (ai_ns::diplomacy_ns::TDipRelation *)KMemAlloc(sizeof(ai_ns::diplomacy_ns::TDipRelation));
780 _data->game_data.relations[i]->rs = (ai_ns::diplomacy_ns::TRelationship)package->getInt("relations", 0, "relationship", i, "rs", 0, NULL);
781 _data->game_data.relations[i]->offeredrs = (ai_ns::diplomacy_ns::TRelationship)package->getInt("relations", 0, "relationship", i, "offeredrs", 0, NULL);
782 + // this was missing!!
783 + _data->game_data.relations[i]->relationship_properties.belief=(ai_ns::diplomacy_ns::TRelationship)package->getInt("relations", 0, "relationship", i, "belief", 0, NULL);
784 + _data->game_data.relations[i]->relationship_properties.guess_belief=(ai_ns::diplomacy_ns::TRelationship)package->getInt("relations", 0, "relationship", i, "guess_belief", 0, NULL);
785 + _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);
790 info[it->first]->stats = it->second->data().statistics;
791 for (i = 1; i <= MAX_PLAYERS; i++) {
792 if (it->second->data().game_data.relations[i]) {
793 - *(info[it->first]->relations[i]) = *(it->second->data().game_data.relations[i]);
794 + *(info[it->first]->relations[i]) = *(it->second->data().game_data.relations[i]);
797 info[it->first]->relations[i] = NULL;
798 diff -ruN 8Kingdoms-1.1.0-orig/world/world_client.cpp 8Kingdoms-1.1.0/world/world_client.cpp
799 --- 8Kingdoms-1.1.0-orig/world/world_client.cpp 2007-07-22 03:33:12.000000000 +0200
800 +++ 8Kingdoms-1.1.0/world/world_client.cpp 2009-11-02 20:20:09.000000000 +0100
804 // inicializace negine
805 - engine->init(world);
807 - // registrace zprav z TCL
808 - engine->interpreter.createCommand("KSendMessage", (Tcl_CmdProc *)World::WorldClient_SendMessage);
810 - // inkluze knihoven pro TCL (spusteni inicializacniho skriptu)
811 - engine->interpreter.init(world->rules->scripts[TS_INIT]);
812 + engine->init(world, (Tcl_CmdProc *)World::WorldClient_SendMessage);
818 if (world_client[i]->state == WCS_GAME_ENDED && action_type == AT_ENDGAME) {
819 // zprava o ukonceni hry pro jiz ukoncenou hru - ignoruji
820 + world_client_mutex.unlock();
823 else if (!(((action_type == AT_GAME_START) && (world_client[i]->state >= WCS_WORLD_INITIALIZED) && (world_client[i]->state < WCS_GAME_STARTED))
825 (world_client[i]->state == WCS_GAME_STARTED)
827 // zprava prisla v nevhodnou chvili - ignoruji
828 + world_client_mutex.unlock();
832 diff -ruN 8Kingdoms-1.1.0-orig/world/world_engine.cpp 8Kingdoms-1.1.0/world/world_engine.cpp
833 --- 8Kingdoms-1.1.0-orig/world/world_engine.cpp 2007-07-22 03:33:12.000000000 +0200
834 +++ 8Kingdoms-1.1.0/world/world_engine.cpp 2009-11-02 20:20:09.000000000 +0100
839 -void TWorldEngine::init(TWorld * world)
840 +void TWorldEngine::init(TWorld * world, Tcl_CmdProc *TCLSendMessageProc)
842 - // zapis pravidel do prostredi TCL interpreteru
844 - world->rules->writeToTCL(interpreter);
845 + interpreter.init(world->rules, TCLSendMessageProc,
846 + world->rules->scripts[TS_INIT]);
849 int TWorldEngine::lock()
850 @@ -1210,7 +1209,10 @@
856 return ERR_NotOperational;
859 TPacket_RCT_UNIT_MOVE * packet = new TPacket_RCT_UNIT_MOVE();
860 packet->unit_id = unit_id;
861 @@ -1853,14 +1855,18 @@
862 // zaznamenam do statistik
863 _world.players.townCaptured(town_occupied->new_player_id, town_occupied->former_player_id);
865 - // dam o tom vedet diplomacii
866 - if (former_player_id != 0) {
867 - TPacket_Diplomacy_ConquerCity conquerCity;
868 - conquerCity.attacked_diplomat_world_id = former_player_id;
869 - conquerCity.attacking_diplomat_world_id = new_player_id;
870 - conquerCity.payment = _world.towns[town_id]->data().citysize * TOWN_INCOME;
871 + // if the player is not dead or was not neutral, inform Diplomacy
872 + if (former_player_id != 0)
874 + if (_world.players[former_player_id]->data().game_data.state != PS_DEFEATED)
876 + TPacket_Diplomacy_ConquerCity conquerCity;
877 + conquerCity.attacked_diplomat_world_id = former_player_id;
878 + conquerCity.attacking_diplomat_world_id = new_player_id;
879 + conquerCity.payment = _world.towns[town_id]->data().citysize * TOWN_INCOME;
881 - KSendGlobalMessage(MSG_DIPLOMACY_CONQUER_CITY, MOD_WORLD_SERVER, MOD_DIPLOMACY, &conquerCity);
882 + KSendGlobalMessage(MSG_DIPLOMACY_CONQUER_CITY, MOD_WORLD_SERVER, MOD_DIPLOMACY, &conquerCity);
887 diff -ruN 8Kingdoms-1.1.0-orig/world/world_engine.h 8Kingdoms-1.1.0/world/world_engine.h
888 --- 8Kingdoms-1.1.0-orig/world/world_engine.h 2007-07-22 03:33:12.000000000 +0200
889 +++ 8Kingdoms-1.1.0/world/world_engine.h 2009-11-02 20:20:09.000000000 +0100
894 - void init(TWorld * world);
895 + void init(TWorld * world, Tcl_CmdProc *TCLSendMessageProc);
899 diff -ruN 8Kingdoms-1.1.0-orig/world/world_server.cpp 8Kingdoms-1.1.0/world/world_server.cpp
900 --- 8Kingdoms-1.1.0-orig/world/world_server.cpp 2007-07-22 03:33:12.000000000 +0200
901 +++ 8Kingdoms-1.1.0/world/world_server.cpp 2009-11-02 20:20:09.000000000 +0100
905 // inicializace world_engine
906 - engine.init(&world);
908 - // registrace zprav z TCL
909 - engine.interpreter.createCommand("KSendMessage", (Tcl_CmdProc *)WorldServer_SendMessage);
911 - // inkluze knihoven pro TCL (spusteni inicializacniho skriptu)
912 - engine.interpreter.init(world.rules->scripts[TS_INIT]);
913 + engine.init(&world, (Tcl_CmdProc *)WorldServer_SendMessage);
916 void TWorldServer::shutdown()
917 @@ -2032,7 +2026,7 @@
919 for (int i = 0; i < MAX_PLAYERS; i++)
921 - if (game_start_disconnections[i] == ((int) p))
922 + if (game_start_disconnections[i] == ((long) p))
924 game_start_disconnections[i] = 0;
926 @@ -2043,7 +2037,7 @@
927 else if (world_server->state == WSS_GAME_STARTED)
929 // Hra jiz bezi, tedy doslo k znovu pripojeni
930 - int client_id = (int)p;
931 + int client_id = (long)p;
932 for (TPlayerIterator it = world_server->world.players.begin(); it != world_server->world.players.end(); it++)
934 int temp=it->second->data().client_data.oldclient_id;
935 @@ -2099,7 +2093,7 @@
936 // Az skonci nahravani hry, odpojeni klienta se vyresi dodatecne
937 for (int i = 0; i < MAX_PLAYERS; i++)
938 if (game_start_disconnections[i] == 0)
939 - game_start_disconnections[i] = (int)p;
940 + game_start_disconnections[i] = (long)p;
943 else if (world_server->state < WSS_GAME_STARTED) {
944 @@ -2110,7 +2104,7 @@
946 else if (world_server->state == WSS_GAME_STARTED) {
948 - int client_id = (int)p;
949 + int client_id = (long)p;
950 for (TPlayerIterator it = world_server->world.players.begin(); it != world_server->world.players.end(); it++) {
951 if (it->second->data().client_data.client_id == client_id) {
952 // odpojil se hrac it->first