From 25bc3b532fe8ab4e30efcf408d30982cd49a3e1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Tue, 29 Jan 2008 13:00:45 +0000 Subject: [PATCH] * redone buildings reading * subtitles in statusbar for garrison * animations an castle view are faster --- CCastleInterface.cpp | 2 +- CPlayerInterface.cpp | 53 ++++- CPlayerInterface.h | 2 +- config/buildings5.txt | 41 ++++ hch/CAmbarCendamo.cpp | 467 +++++++++++++++++++++++------------------- 5 files changed, 350 insertions(+), 215 deletions(-) create mode 100644 config/buildings5.txt diff --git a/CCastleInterface.cpp b/CCastleInterface.cpp index d6bef191a..4cd8b62cb 100644 --- a/CCastleInterface.cpp +++ b/CCastleInterface.cpp @@ -353,7 +353,7 @@ void CCastleInterface::show(SDL_Surface * to) to=ekran; garr->show(); count++; - if(count==5) + if(count==4) { count=0; animval++; diff --git a/CPlayerInterface.cpp b/CPlayerInterface.cpp index 439def90b..ca420aa41 100644 --- a/CPlayerInterface.cpp +++ b/CPlayerInterface.cpp @@ -13,11 +13,14 @@ #include "CPathfinder.h" #include #include "hch/CHeroHandler.h" +#include "hch/CTownHandler.h" #include "SDL_framerate.h" #include "hch/CGeneralTextHandler.h" #include "CCastleInterface.h" #include "CHeroWindow.h" #include "timeHandler.h" +#include +#include using namespace CSDL_Ext; class OCM_HLP_CGIN @@ -31,12 +34,57 @@ public: void CGarrisonSlot::hover (bool on) { + Hoverable::hover(on); if(on) { + std::string temp; if(creature) { - LOCPLINT->statusbar->print(creature->nameSing); + if(owner->highlighted) + { + if(owner->highlighted == this) + { + temp = CGI->townh->tcommands[4]; + boost::algorithm::replace_first(temp,"%s",creature->nameSing); + } + else if (owner->highlighted->creature == creature) + { + temp = CGI->townh->tcommands[2]; + boost::algorithm::replace_first(temp,"%s",creature->nameSing); + } + else + { + temp = CGI->townh->tcommands[7]; + boost::algorithm::replace_first(temp,"%s",owner->highlighted->creature->nameSing); + boost::algorithm::replace_first(temp,"%s",creature->nameSing); + } + } + else + { + if(upg) + { + temp = CGI->townh->tcommands[32]; + } + else + { + temp = CGI->townh->tcommands[12]; + } + boost::algorithm::replace_first(temp,"%s",creature->nameSing); + }; } + else + { + if(owner->highlighted) + { + temp = CGI->townh->tcommands[6]; + boost::algorithm::replace_first(temp,"%s",owner->highlighted->creature->nameSing); + } + else + { + temp = CGI->townh->tcommands[11]; + } + } + LOCPLINT->statusbar->print(temp); } else { @@ -66,7 +114,8 @@ void CGarrisonSlot::clickLeft(tribool down) } else { - owner->highlighted = this; + if(creature) + owner->highlighted = this; } } } diff --git a/CPlayerInterface.h b/CPlayerInterface.h index 49ce60025..8975f8150 100644 --- a/CPlayerInterface.h +++ b/CPlayerInterface.h @@ -196,7 +196,7 @@ public: CGarrisonInt *owner; const CCreature * creature; int count; - int upg; //upper garrison + int upg; //0 - up garrison, 1 - down garrison virtual void hover (bool on); void clickRight (tribool down); diff --git a/config/buildings5.txt b/config/buildings5.txt new file mode 100644 index 000000000..69219230b --- /dev/null +++ b/config/buildings5.txt @@ -0,0 +1,41 @@ +0 11 +1 12 +2 13 +3 7 +4 8 +5 9 +6 5 +7 16 +8 14 +9 15 +10 -50 +11 0 +12 1 +13 2 +14 3 +15 4 +16 6 +17 26 +18 17 +19 22 +20 21 +21 -50 +22 30 +23 37 +24 -1 +25 31 +26 38 +27 -2 +28 32 +29 39 +30 -3 +31 33 +32 40 +33 -4 +34 34 +35 41 +36 -5 +37 35 +38 42 +39 36 +40 43 diff --git a/hch/CAmbarCendamo.cpp b/hch/CAmbarCendamo.cpp index 83ddc1614..222425b5d 100644 --- a/hch/CAmbarCendamo.cpp +++ b/hch/CAmbarCendamo.cpp @@ -70,6 +70,50 @@ void CAmbarCendamo::teceDef() // delete of; //} } +std::set convertBuildings(const std::set h3m, int castleID) +{ + std::map mapa; + std::set ret; + std::ifstream b5("config/buildings5.txt"); + while(!b5.eof()) + { + int a, b; + b5 >> a >> b; + mapa[a]=b; + } + + for(std::set::const_iterator i=h3m.begin();i!=h3m.end();i++) + { + if(mapa[*i]>=0) + ret.insert(mapa[*i]); + else if(mapa[*i] >= (-CREATURES_PER_TOWN)) // horde buildings + { + int level = (-mapa[*i]); + if(h3m.find(36+level) != h3m.end()) //upgraded creature horde building + { + if(((castleID==1) || (castleID==3)) && ((level==3) || (level==5))) + ret.insert(25); + else + ret.insert(19); + } + else + { + if(((castleID==1) || (castleID==3)) && ((level==3) || (level==5))) + ret.insert(24); + else + ret.insert(18); + } + } + else + { + std::cout<<"Conversion warning: unknown building "<<*i<<" in castle "<unusualBuildins) { - nt->builtBuildings.insert(10); - for(int ir = 0; ir < 6; ir++) - { - for(int bs=0;bs<8;bs++) - { - if(ir==0) - { - if (bs<3) - { - if(spec->buildingSettings[ir] & (1<builtBuildings.insert(11+bs); - } - } - else if (bs<6) - { - if(spec->buildingSettings[ir] & (1<builtBuildings.insert(7+bs-3); - } - } - else if(bs==6) - { - if(spec->buildingSettings[ir] & (1<builtBuildings.insert(5); - } - } - else// if(bs==7) - { - if(spec->buildingSettings[ir] & (1<builtBuildings.insert(16); - } - } - } //if(ir==0) - else if(ir==1) - { - if(bs<2) - { - if(spec->buildingSettings[ir] & (1<builtBuildings.insert(14+bs); - } - } - else if (bs==2) - { - if(spec->buildingSettings[ir] & (1<buildingSettings[ir] & (1<builtBuildings.insert(0+bs-3); - } - } + //nt->builtBuildings.insert(10); + //for(int ir = 0; ir < 6; ir++) + //{ + // for(int bs=0;bs<8;bs++) + // { + // if(ir==0) + // { + // if (bs<3) + // { + // if(spec->buildingSettings[ir] & (1<builtBuildings.insert(11+bs); + // } + // } + // else if (bs<6) + // { + // if(spec->buildingSettings[ir] & (1<builtBuildings.insert(7+bs-3); + // } + // } + // else if(bs==6) + // { + // if(spec->buildingSettings[ir] & (1<builtBuildings.insert(5); + // } + // } + // else// if(bs==7) + // { + // if(spec->buildingSettings[ir] & (1<builtBuildings.insert(16); + // } + // } + // } //if(ir==0) + // else if(ir==1) + // { + // if(bs<2) + // { + // if(spec->buildingSettings[ir] & (1<builtBuildings.insert(14+bs); + // } + // } + // else if (bs==2) + // { + // if(spec->buildingSettings[ir] & (1<buildingSettings[ir] & (1<builtBuildings.insert(0+bs-3); + // } + // } - }//else if(ir==1) - else if(ir==2) - { - if(bs==0) - { - if(spec->buildingSettings[ir] & (1<builtBuildings.insert(6); //stocznia - } - } - else if(bs==1) - { - if(spec->buildingSettings[ir] & (1<builtBuildings.insert(26); //grail - } - } - else if(bs==2) - { - if(spec->buildingSettings[ir] & (1<builtBuildings.insert(17); //latarnia - } - } - else if(bs==3) - { - if(spec->buildingSettings[ir] & (1<builtBuildings.insert(22); //bractwo miecza - } - } - else if(bs==4) - { - if(spec->buildingSettings[ir] & (1<builtBuildings.insert(21); //stables - } - } - else if(bs==5) - { - if(spec->buildingSettings[ir] & (1<buildingSettings[ir] & (1<builtBuildings.insert(30); //gen1 - } - } - else if(bs==7) - { - if(spec->buildingSettings[ir] & (1<builtBuildings.insert(37); //gen1+ - } - } - }//else if(ir==2) - else if (ir==3) - { - if(bs==0) - { - if(spec->buildingSettings[ir] & (1<buildingSettings[ir] & (1<builtBuildings.insert(31); //gen2 - } - } - else - { - if(spec->buildingSettings[ir] & (1<builtBuildings.insert(38); //gen2+ - } - } - } - else if (bs==3) - { - if(spec->buildingSettings[ir] & (1<builtBuildings.find(38)!=nt->builtBuildings.end()) - nt->builtBuildings.insert(19); - else - nt->builtBuildings.insert(18); + // }//else if(ir==1) + // else if(ir==2) + // { + // if(bs==0) + // { + // if(spec->buildingSettings[ir] & (1<builtBuildings.insert(6); //stocznia + // } + // } + // else if(bs==1) + // { + // if(spec->buildingSettings[ir] & (1<builtBuildings.insert(26); //grail + // } + // } + // else if(bs==2) + // { + // if(spec->buildingSettings[ir] & (1<builtBuildings.insert(17); //latarnia + // } + // } + // else if(bs==3) + // { + // if(spec->buildingSettings[ir] & (1<builtBuildings.insert(22); //bractwo miecza + // } + // } + // else if(bs==4) + // { + // if(spec->buildingSettings[ir] & (1<builtBuildings.insert(21); //stables + // } + // } + // else if(bs==5) + // { + // if(spec->buildingSettings[ir] & (1<buildingSettings[ir] & (1<builtBuildings.insert(30); //gen1 + // } + // } + // else if(bs==7) + // { + // if(spec->buildingSettings[ir] & (1<builtBuildings.insert(37); //gen1+ + // } + // } + // }//else if(ir==2) + // else if (ir==3) + // { + // if(bs==0) + // { - - } - continue; - } - else - { - if(bs%2) //nieulepszone - { - if(spec->buildingSettings[ir] & (1<builtBuildings.insert((int)(39+(bs/2)-2)); - } - } - else - { - if(spec->buildingSettings[ir] & (1<builtBuildings.insert(32+(bs/2)-2); - } - } - } + // //horda dla 1 poziomu??? + // if(spec->buildingSettings[ir] & (1<buildingSettings[ir] & (1<builtBuildings.insert(31); //gen2 + // } + // } + // else + // { + // if(spec->buildingSettings[ir] & (1<builtBuildings.insert(38); //gen2+ + // } + // } + // } + // else if (bs==3) + // { + // if(spec->buildingSettings[ir] & (1<builtBuildings.find(38)!=nt->builtBuildings.end()) + // nt->builtBuildings.insert(19); + // else + // nt->builtBuildings.insert(18); + // } + // continue; + // } + // else if(bs==4) + // { + // if(bs%2) //nieulepszone + // { + // if(spec->buildingSettings[ir] & (1<builtBuildings.insert((int)(39+(bs/2)-2)); + // } + // } + // else + // { + // if(spec->buildingSettings[ir] & (1<builtBuildings.insert(32+(bs/2)-2); + // } + // } + // } - }//else if (ir==3) - else if (ir==4 && bs==0) - { - if(spec->buildingSettings[ir] & 1<<0) - nt->builtBuildings.insert(40); - if(spec->buildingSettings[ir] & 1<<2) - nt->builtBuildings.insert(34); - if(spec->buildingSettings[ir] & 1<<3) - nt->builtBuildings.insert(41); - if(spec->buildingSettings[ir] & 1<<3) - { - if(nt->builtBuildings.find(41)!=nt->builtBuildings.end()) - nt->builtBuildings.insert(25); - else - nt->builtBuildings.insert(24); - } - if(spec->buildingSettings[ir] & 1<<5) - nt->builtBuildings.insert(35); - if(spec->buildingSettings[ir] & 1<<6) - nt->builtBuildings.insert(42); - if(spec->buildingSettings[ir] & 1<<7) - nt->builtBuildings.insert(36); - }//else if (ir==4) - else if (ir==5) - { - if(bs==0) - { - if(spec->buildingSettings[ir] & (1<builtBuildings.insert(43); //gen7+ - } - } - }//else if (ir==5) - } - } + // }//else if (ir==3) + // else if (ir==4 && bs==0) + // { + // if(spec->buildingSettings[ir] & 1<<0) + // nt->builtBuildings.insert(40); + // if(spec->buildingSettings[ir] & 1<<2) + // nt->builtBuildings.insert(34); + // if(spec->buildingSettings[ir] & 1<<3) + // nt->builtBuildings.insert(41); + // if(spec->buildingSettings[ir] & 1<<4) + // { + // if(nt->builtBuildings.find(41)!=nt->builtBuildings.end()) + // nt->builtBuildings.insert(25); + // else + // nt->builtBuildings.insert(24); + // } + // if(spec->buildingSettings[ir] & 1<<5) + // nt->builtBuildings.insert(35); + // if(spec->buildingSettings[ir] & 1<<6) + // nt->builtBuildings.insert(42); + // if(spec->buildingSettings[ir] & 1<<7) + // nt->builtBuildings.insert(36); + // }//else if (ir==4) + // else if (ir==5) + // { + // if(bs==0) + // { + // if(spec->buildingSettings[ir] & (1<builtBuildings.insert(43); //gen7+ + // } + // } + // }//else if (ir==5) + // } + //} //testowe zczytywanie h3mowych ID for(int byte=0;byte<6;byte++) @@ -1868,6 +1912,7 @@ void CAmbarCendamo::deh3m() } } } + nt->builtBuildings = convertBuildings(nt->h3mbuildings,nt->subID); } else {