From 61ce0c915c9ee8b791006f430d2d6d82d00be8be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Tue, 3 Jun 2008 18:16:54 +0000 Subject: [PATCH] * "%s substitutions in Right-click information in town hall * windmill won't give wood * hover text for heroes * good background for the town hall screen in Stronghold * fixed typo in hall.txt * support for ZSoft-style PCX files in /Data (using SDL_image) * minor improvements --- CCastleInterface.cpp | 8 +++-- CLua.cpp | 11 +++++-- CLua.h | 1 + config/hall.txt | 4 +-- hch/CBuildingHandler.cpp | 2 +- hch/CDefHandler.cpp | Bin 27448 -> 27400 bytes hch/CLodHandler.cpp | 69 +++++++-------------------------------- hch/CLodHandler.h | 2 +- hch/CSemiDefHandler.cpp | 1 + hch/CSemiDefHandler.h | 2 +- 10 files changed, 34 insertions(+), 66 deletions(-) diff --git a/CCastleInterface.cpp b/CCastleInterface.cpp index 3c7de4f6c..d8fffea90 100644 --- a/CCastleInterface.cpp +++ b/CCastleInterface.cpp @@ -656,7 +656,11 @@ void CHallInterface::CBuildingBox::hover(bool on) Hoverable::hover(on); if(on) { - std::string toPrint = CGI->townh->hcommands[state]; + std::string toPrint; + if(state==8) + toPrint = CGI->townh->hcommands[5]; + else + toPrint = CGI->townh->hcommands[state]; std::vector name; name.push_back(CGI->buildh->buildings[LOCPLINT->castleInt->town->subID][BID]->name); LOCPLINT->statusbar->print(CSDL_Ext::processStr(toPrint,name)); @@ -929,7 +933,7 @@ std::string CHallInterface::CBuildWindow::getTextForState(int state) ret = CGI->townh->hcommands[state]; switch (state) { - case 4: + case 4: case 5: case 6: ret.replace(ret.find_first_of("%s"),2,CGI->buildh->buildings[tid][bid]->name); break; case 7: diff --git a/CLua.cpp b/CLua.cpp index 57a259ca5..dc5a9dcc0 100644 --- a/CLua.cpp +++ b/CLua.cpp @@ -356,7 +356,7 @@ void CVisitableOPW::onNAHeroVisit(CGObjectInstance *os, int heroID, bool already break; case 112: mid = 170; - sub = rand() % 6; + sub = (rand() % 5) + 1; val = (rand() % 4) + 3; break; case 109: @@ -651,7 +651,14 @@ std::vector CHeroScript::yourObjects() //returns IDs of objects which are h ret.push_back(34); //hero return ret; } - +std::string CHeroScript::hoverText(CGObjectInstance *os) +{ + CGHeroInstance* h = static_cast(os); + std::string ret = CGI->generaltexth->allTexts[15]; + boost::algorithm::replace_first(ret,"%s",h->name); + boost::algorithm::replace_first(ret,"%s",h->type->heroClass->name); + return ret; +} void CMonsterS::newObject(CGObjectInstance *os) { //os->blockVisit = true; diff --git a/CLua.h b/CLua.h index beadd8fec..398206097 100644 --- a/CLua.h +++ b/CLua.h @@ -171,6 +171,7 @@ class CHeroScript : public CCPPObjectScript void newObject(CGObjectInstance *os); void onHeroVisit(CGObjectInstance *os, int heroID); std::vector yourObjects(); //returns IDs of objects which are handled by script + std::string hoverText(CGObjectInstance *os); friend void initGameState(CGameInfo * cgi); }; diff --git a/config/hall.txt b/config/hall.txt index 482fdd29f..bc58e1a32 100644 --- a/config/hall.txt +++ b/config/hall.txt @@ -4,7 +4,7 @@ TPTHBKCS.BMP 10 11 12 13 | 7 8 9 | 5 22 | 16 14 15 | 0 1 2 3 | 6 21 | 18 19 -30 37 | 31 38 | 32 39 | 33 40 +30 37 | 31 38 | 32 39 | 33 40 34 41 | 35 42 | 36 43 1 TPTHBKRM.BMP @@ -42,7 +42,7 @@ TPTHBKDG.BMP 30 37 | 31 38 | 32 39 | 33 40 34 41 | 35 42 | 36 43 6 -TPTHBKST.BMP +TPTHBKTW.BMP 10 11 12 13 | 7 8 9 | 5 | 16 14 15 | 0 1 2 | 23 | 17 21 | 22 | 18 19 diff --git a/hch/CBuildingHandler.cpp b/hch/CBuildingHandler.cpp index 2212db416..d5e26f869 100644 --- a/hch/CBuildingHandler.cpp +++ b/hch/CBuildingHandler.cpp @@ -168,7 +168,7 @@ void CBuildingHandler::loadBuildings() (hall[tid].second)[j][box].push_back(last); areboxes = it; //wyzeruje jak nie znajdzie kolejnej spacji = koniec linii if(!it) - it = seppos+1; + it = seppos+1; } box++; it+=2; diff --git a/hch/CDefHandler.cpp b/hch/CDefHandler.cpp index a567453a7712106933b60199121e317cc05e8e08..becc28e6a11de1e61148f79a5c01655f6c0132ec 100644 GIT binary patch delta 12 UcmdmSjj`hz #include #include "boost/filesystem.hpp" // includes all needed Boost.Filesystem declarations +#include "SDL_image.h" int readNormalNr (int pos, int bytCon, unsigned char * str) { int ret=0; @@ -252,52 +253,6 @@ SDL_Surface * CPCXConv::getSurface() } return ret; } -SDL_Surface * CPCXConv::getSurfaceZ() -{ - //int i=1; - //int type = pcx[i];i+=2;//0 -- Version 2.5 2 -- Version 2.8, palette included 3 -- Version 2.8, use default palette 5 -- Version 3.0 or better - //int bpp = pcx[3];i++; - //int xmin, ymin, xmax, ymax, w, h; - //xmin = readNormalNr(i,2,pcx);i+=2; - //ymin = readNormalNr(i,2,pcx);i+=2; - //xmax = readNormalNr(i,2,pcx);i+=2; - //ymax = readNormalNr(i,2,pcx);i+=2; - //w = xmax - xmin + 1; h = ymax - ymin + 1; - //i+=4; //DPI is not interesting - //char palette[48]; - //memcpy(palette,pcx+i,48); i+=48; - //int reserved = pcx[i++]; - //int planes = pcx[i++]; - //int bytesPerLine = readNormalNr(i,2,pcx);i+=2; - //i = 128; //to the end of header - //int totalBytes = planes * bytesPerLine; - //int padding = ((bytesPerLine * planes) * (8 / bpp)) - ((xmax - xmin) + 1); - //char * buffer = new char[totalBytes]; - //int index = 0, count, value, total=0; - //do - //{ - // count=0; value=0; - // unsigned char byte = pcx[i++]; - // if((byte & 0xC0) == 0xC0) //two top bits set - // { - // count = byte & 0x3f; - // value = pcx[i++]; - // } - // else - // { - // count = 1; - // value = byte; - // } - // for(total+=count; count && (index < totalBytes); index++) - // { - // buffer[index] = value; - // count--; - // } - //} while(indexrealSize]; - memcpy(pcx,sign,3); - int res = fread((char*)pcx+3, 1, e->realSize-3, f); - fclose(f); - cp.openPCX((char*)pcx,e->realSize); if((sign[0]==10) && (sign[1]<6) && (sign[2]==1)) //ZSoft PCX { - return cp.getSurfaceZ(); + fclose(f); + return IMG_Load(fname.c_str()); } - else //H3 PCX + else //H3-style PCX { + CPCXConv cp; + pcx = new unsigned char[e->realSize]; + memcpy(pcx,sign,3); + int res = fread((char*)pcx+3, 1, e->realSize-3, f); + fclose(f); + cp.openPCX((char*)pcx,e->realSize); return cp.getSurface(); } } diff --git a/hch/CLodHandler.h b/hch/CLodHandler.h index 10e691bce..da2a59684 100644 --- a/hch/CLodHandler.h +++ b/hch/CLodHandler.h @@ -54,7 +54,7 @@ public: void openPCX(); void convert(); SDL_Surface * getSurface(); //for standard H3 PCX - SDL_Surface * getSurfaceZ(); //for ZSoft PCX + //SDL_Surface * getSurfaceZ(); //for ZSoft PCX CPCXConv(){pcx=bmp=NULL;pcxs=bmps=0;}; ~CPCXConv(){if (pcxs) delete[] pcx; if(bmps) delete[] bmp;} }; diff --git a/hch/CSemiDefHandler.cpp b/hch/CSemiDefHandler.cpp index 7a18fe5e8..2d0b0d6ff 100644 --- a/hch/CSemiDefHandler.cpp +++ b/hch/CSemiDefHandler.cpp @@ -1,6 +1,7 @@ #include "../stdafx.h" #include "CSemiDefHandler.h" #include +#include "SDL_image.h" extern SDL_Surface * screen; std::string CSemiDefHandler::nameFromType (EterrainType typ) { diff --git a/hch/CSemiDefHandler.h b/hch/CSemiDefHandler.h index 3324c132c..2abaca0cc 100644 --- a/hch/CSemiDefHandler.h +++ b/hch/CSemiDefHandler.h @@ -3,7 +3,7 @@ #include "../global.h" #include #include "SDL.h" -#include "SDL_image.h" +//#include "SDL_image.h" #include struct Cimage