From f1e40d5e869e75870e9995381dcb215d0370b4f6 Mon Sep 17 00:00:00 2001 From: mateuszb Date: Thu, 6 Mar 2008 16:42:34 +0000 Subject: [PATCH] * significant speed-up in def loading * bugfixes (player's id - player's serial mismatches) --- CBattleInterface.cpp | 11 +++++++++++ CCallback.cpp | 31 ++++++++++++++++++++++++++++--- CGameState.cpp | 16 +++++++++++++--- hch/CAmbarCendamo.h | 4 ++-- hch/CCreatureHandler.cpp | 15 --------------- hch/CDefHandler.cpp | Bin 27434 -> 27212 bytes 6 files changed, 54 insertions(+), 23 deletions(-) diff --git a/CBattleInterface.cpp b/CBattleInterface.cpp index ed28b7372..7932157d6 100644 --- a/CBattleInterface.cpp +++ b/CBattleInterface.cpp @@ -185,6 +185,17 @@ void CBattleInterface::bSurrenderf() void CBattleInterface::bFleef() { + for(int i=0; iobjsToBlit.size(); ++i) + { + if( dynamic_cast( LOCPLINT->objsToBlit[i] ) ) + { + LOCPLINT->objsToBlit.erase(LOCPLINT->objsToBlit.begin()+i); + } + } + deactivate(); + + LOCPLINT->adventureInt->activate(); + delete this; } void CBattleInterface::bAutofightf() diff --git a/CCallback.cpp b/CCallback.cpp index 644dab3f2..6c0d1cd01 100644 --- a/CCallback.cpp +++ b/CCallback.cpp @@ -435,9 +435,27 @@ int CCallback::swapCreatures(const CGObjectInstance *s1, const CGObjectInstance if(!S2->slots[p2].first) S2->slots.erase(p2); if(s1->tempOwnerplayerint[s1->tempOwner]->garrisonChanged(s1); + { + for(int b=0; bplayerint.size(); ++b) + { + if(CGI->playerint[b]->playerID == s1->tempOwner) + { + CGI->playerint[b]->garrisonChanged(s1); + break; + } + } + } if((s2->tempOwnerplayerint[s2->tempOwner]->garrisonChanged(s2); + { + for(int b=0; bplayerint.size(); ++b) + { + if(CGI->playerint[b]->playerID == s2->tempOwner) + { + CGI->playerint[b]->garrisonChanged(s2); + break; + } + } + } return 0; } } @@ -607,7 +625,14 @@ void CScriptCallback::heroVisitCastle(CGObjectInstance * ob, int heroID) if(n = dynamic_cast(ob)) { n->visitingHero = CGI->state->getHero(heroID,0); - CGI->playerint[getHeroOwner(heroID)]->heroVisitsTown(CGI->state->getHero(heroID,0),n); + for(int b=0; bplayerint.size(); ++b) + { + if(CGI->playerint[b]->playerID == getHeroOwner(heroID)) + { + CGI->playerint[b]->heroVisitsTown(CGI->state->getHero(heroID,0),n); + break; + } + } } else return; diff --git a/CGameState.cpp b/CGameState.cpp index 431a8d047..22265d62c 100644 --- a/CGameState.cpp +++ b/CGameState.cpp @@ -86,13 +86,23 @@ void CGameState::battle(CCreatureSet * army1, CCreatureSet * army2, int3 tile, C curB->activeStack = i; if(stacks[i]->alive) //niech interfejs ruszy oddzialem { - if(CGI->playerint[(stacks[i]->owner)?(hero2->tempOwner):(hero1->tempOwner)]->human) + unsigned char owner = (stacks[i]->owner)?(hero2->tempOwner):(hero1->tempOwner); + unsigned char serialOwner = -1; + for(int g=0; gplayerint.size(); ++g) { - ((CPlayerInterface*)CGI->playerint[(stacks[i]->owner)?(hero2->tempOwner):(hero1->tempOwner)])->activeStack(stacks[i]->ID); + if(CGI->playerint[g]->playerID == owner) + { + serialOwner = g; + break; + } + } + if(CGI->playerint[serialOwner]->human) + { + ((CPlayerInterface*)CGI->playerint[serialOwner])->activeStack(stacks[i]->ID); } else { - //CGI->playerint[(stacks[i]->owner)?(hero2->tempOwner):(hero1->tempOwner)]->activeStack(stacks[i]->ID); + //CGI->playerint[serialOwner]->activeStack(stacks[i]->ID); } } //sprawdzic czy po tej akcji ktoras strona nie wygrala bitwy diff --git a/hch/CAmbarCendamo.h b/hch/CAmbarCendamo.h index 1e41a6705..2aab7a02f 100644 --- a/hch/CAmbarCendamo.h +++ b/hch/CAmbarCendamo.h @@ -16,13 +16,13 @@ enum EDefType {TOWN_DEF, HERO_DEF, CREATURES_DEF, SEERHUT_DEF, RESOURCE_DEF, TER class CAmbarCendamo { public: -/////////////////zmienne skladowe +/////////////////member variables Mapa map; std::ifstream * is; // stream used to read map file int andame; // length of map file unsigned char * bufor; // here we store map bytecode std::vector defs; -/////////////////funkcje skladowe +/////////////////member functions CAmbarCendamo (const char * tie); // c-tor; tie is the path of the map file CAmbarCendamo (unsigned char * map); // c-tor; map is pointer to array containing map; it is not copied, so don't delete ~CAmbarCendamo (); // d-tor diff --git a/hch/CCreatureHandler.cpp b/hch/CCreatureHandler.cpp index df2adb61b..95eeaf65b 100644 --- a/hch/CCreatureHandler.cpp +++ b/hch/CCreatureHandler.cpp @@ -777,9 +777,7 @@ int CCreatureAnimation::nextFrame(SDL_Surface *dest, int x, int y) i, add, FullHeight,FullWidth, TotalRowLength, // dlugosc przeczytanego segmentu NextSpriteOffset, RowAdd; - std::ifstream Fdef; unsigned char SegmentType, SegmentLength, BL, BR; - unsigned char * TempDef; //memory std::string FTemp; @@ -794,21 +792,8 @@ int CCreatureAnimation::nextFrame(SDL_Surface *dest, int x, int y) TopMargin = readNormalNr(i,4,FDef);i+=4; RightMargin = FullWidth - SpriteWidth - LeftMargin; BottomMargin = FullHeight - SpriteHeight - TopMargin; - - BMPHeader tb; - tb.x = FullWidth; - tb.y = FullHeight; - tb.dataSize2 = tb.dataSize1 = tb.x*tb.y; - tb.fullSize = tb.dataSize1+436; - tb._h3=tb.fullSize-36; - //add = (int)(4*(((float)1) - ((int)(((int)((float)FullWidth/(float)4))-((float)FullWidth/(float)4))))); add = 4 - FullWidth%4; - /*if (add==4) - add=0;*/ //moved to defcompression dependent block - - //ret = SDL_CreateRGBSurface(SDL_SWSURFACE, FullWidth, FullHeight, 8, 0, 0, 0, 0); - //int tempee2 = readNormalNr(0,4,((unsigned char *)tempee.c_str())); int BaseOffsetor = BaseOffset = i; diff --git a/hch/CDefHandler.cpp b/hch/CDefHandler.cpp index 3a18576dbd7dafe10ad9285180c1ae3d7ec17ca2..31ab9ee412eff08c1749677147b22ee8ca60e4e5 100644 GIT binary patch delta 1002 zcmZ2=jq%JC#tk}#lR2!EHkTO+u`zN^UTB%Sxy#CiMNor5gCUtAgCUWjh(U`%lR;y$ zZ@M_MCWGeWjn3AS55$B_j%(V)pa(O46ND!lco|@~gB2KR4BC?qI*U&}=OHrL zz%yd=J1;dnwt*Zp+0Ul}yK%5c*v#c?gWnL#$qE@9n;qm^MEH6#m#^4np9liM2ln~o34Su0Z$!%BbN5DP+s!u7 zTkyv%$oKQ`DA{~5VIh7?gg5skO~9{&NWV|^iO`uGmii5EI9hI2$f#qS%#|&(`9Y=^ FBLH%^=XU@A delta 1336 zcmZux&rcIk5S|57DFRU;C0a>VE81-f{e?877TekoR6vZCglIJtx)lU%08P;t62j3$ z%3L^dGKz$lynldR)EEw$7~|P^@?hjFG0xjv-M1@gw%MKUo9}%yJG0xLr1j6z>p)m? zVy@nOK!!dThXSY&Xa4XRN3;>@!3k*?gkk6>Ag{qQAj2HohB)Xrzwd-HMH3)neyDlD zip=W>i9diT`f;TRD8e05u`H(t4^3-u*s^%!GC2n zqXzkZQ9pD+6uNC1x5#dk3e>IG6+0{$clEvmA*gk1-0 zgumMT$Gt}BW$+tSDQ3qZM9ftuQ-OiHu*_EbKG?(0`$J|flPiwz1q{o5VN1L#uI#yhc<~_av_}J5i?|pnM8t~^p0GHDZhxF|j zqovEk49%H>;bd#A41TN>+mtlS(=--fmcB~`!iQ;B%5*nHQ_Clp?+#Z`acAI2JKrfk xU6b03>&yRdOyRoDrQLAvSBN(WISig~vr_S)giEb1r?CXI93KN7Rx@!?`U3@fH1+@h