From 7b77d94f5707fcc027e5058f2dfb0691b1fe144e Mon Sep 17 00:00:00 2001 From: mateuszb Date: Sat, 7 Jul 2007 11:09:25 +0000 Subject: [PATCH] =?UTF-8?q?kompleksowy=20b=C5=82=C4=85d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CAmbarCendamo.cpp | 23 ++- CDefHandler.cpp | Bin 21580 -> 25024 bytes CDefHandler.h | Bin 2476 -> 2624 bytes CGameInfo.h | 2 + CLodHandler.cpp | 409 +++++++++++++++++++++++++++++++++++++++++++++- CLodHandler.h | 11 ++ CMT.cpp | 9 +- map.h | 2 + mapHandler.cpp | 43 +++-- 9 files changed, 475 insertions(+), 24 deletions(-) diff --git a/CAmbarCendamo.cpp b/CAmbarCendamo.cpp index f843d897c..76ed7d671 100644 --- a/CAmbarCendamo.cpp +++ b/CAmbarCendamo.cpp @@ -5,6 +5,7 @@ #include "CObjectHandler.h" #include "CCastleHandler.h" #include "SDL_Extensions.h" +#include "boost\filesystem.hpp" #include unsigned int intPow(unsigned int a, unsigned int b) @@ -404,8 +405,10 @@ void CAmbarCendamo::deh3m() int samask = 0xff000000; #endif SDL_Surface * alphaTransSurf = SDL_CreateRGBSurface(SDL_SWSURFACE, 12, 12, 32, srmask, sgmask, sbmask, samask); + std::vector defsToUnpack; for (int idd = 0 ; idd::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(), + vinya.name); + if(pit == CGameInfo::mainObj->dobjinfo->objs.end()) + { + vinya.isOnDefList = false; + } + else + { + vinya.printPriority = pit->priority; + vinya.isOnDefList = true; + } map.defy.push_back(vinya); // add this def to the vector - + defsToUnpack.push_back(vinya.name); //testing - only fragment////////////////////////////////////////////////////////////// - map.defy[idd].handler = new CDefHandler(); + /*map.defy[idd].handler = new CDefHandler(); + CGameInfo::mainObj->lodh->extractFile(std::string("newH3sprite.lod"), map.defy[idd].name); map.defy[idd].handler->openDef( std::string("newH3sprite\\")+map.defy[idd].name); for(int ff=0; ffourImages.size(); ++ff) //adding shadows and transparency { @@ -428,10 +443,14 @@ void CAmbarCendamo::deh3m() SDL_FreeSurface(map.defy[idd].handler->ourImages[ff].bitmap); map.defy[idd].handler->ourImages[ff].bitmap = bufs; } + boost::filesystem::remove(boost::filesystem::path(std::string("newH3sprite\\")+map.defy[idd].name));*/ + //system((std::string("DEL newH3sprite\\")+map.defy[idd].name).c_str()); //end fo testing - only fragment/////////////////////////////////////////////////////// //teceDef(); } + std::vector dhandlers = CGameInfo::mainObj->lodh->extractManyFiles(defsToUnpack, std::string("newh3sprite.lod")); + std::cout<<'\r'<<"Reading defs: 100% "<VU2-D?s9~4;V{q_+xe@0MR|oN)xX7LMR8W?Oy_eSp%cx)w z128#P#Jm1`Ih`uL_RqSXu+3`<%7F)$-vXX7+GPA#?J2^NPXPh5b}3_>IbKHAVy4O& z9`fO%ob59bPl|qDB1&A`w_c{m@5#7I^llmP&Z9(ST2R2kHptu1>Xe!UP41hgecG@d z)EizvOx^Ex39IL9Y(k<%3Z5TlsFB*!>r7}w}_gs1veDoojT zW^ak@5of7QB;~r2^$KsW$dTr4>TY?Nnh+uLCVB2~6=E)7Qt>E9D1w`LF;KW+Xe+;z zY2~_Bm>NE%JN>sNKVvh=!zQp|rN|{ys>e?ZHQD-_J`b>y-8)K76-N_W)RL^kq5VQE z7Hv6y`?%LK39g{)q=@)$U{A{8rExdqby4LTUB(1;bg)LW`2Bi(0`7GyAM5%^kY?8_ z5lrOe&(iUo(grcr`%~BsR%qjMCaMOiW_85tiX|V+SFL{%-~Kmo#1LN2mcLd`j4S;= Bq>KOn delta 510 zcmZutOG^S_6g?l3kMKEz4Wj92P%v3jZAGn3M6KEd(MvG#k%|_Pi=t@JF5+&YP2j3! zFn=Iu(MBly2klzgKj_Y+BoUYI<8tn~=bn3?o<-+DJVpXG9U2LrOc_tamO_cH-3s+4 zC0g`4Z7Rx?^@PO?&94M$ZpuyWZ703^B~hkxpDZ%;>JJ9Xn8rM|FpC=YIhx4hkk+%| zKoM0OLgkmo0qRIo*Dr_4f4NA(gHgEX-W#%%6}nZW@qcxPxg!>Xohb5PLSG3kR_p3v z*8pFj8`abnl0t3onB&Jol|BNozDmCm|D9UJ9=p!7|Mbuf3-q-UKhvNyrgPMJYrYeT z%q&=W0S&Zpf*kjoyPNeU{|zfYX0&Rt&Ds&N7Uu*N)-aiM<{qJB%{7q~aVN*DS zbtmi_FR>*-xr9o|c!^pQ8+4_s6iF=8oib*8PMq3}3#})NPVzEpwANN-{xm^vQM(b{ GZHsS=Idet; diff --git a/CDefHandler.h b/CDefHandler.h index a41d16ae15b291d90dc8a44a16776fddf5b57351..84707cf0e9c6b5e0b3f97295d02362c97c0fd749 100644 GIT binary patch delta 99 zcmZ1@d_ZJF5vL|6Lm5LpLncECg94B)U`S=iV{l_A0l0jqgM>a*p o5{5*EB!(QIxDHT#CQxk&kS+$Ysvu&McXFssp28$BxsFp009(WsHUIzs delta 15 WcmX>gvPO7A5$EI?Ogxi?xby%nC +#include +#include int readNormalNr (int pos, int bytCon, unsigned char * str) @@ -165,7 +167,7 @@ void CPCXConv::convert() // FTemp.Free; // Result:=True; //end; -int CLodHandler::decompress (unsigned char * source, int size, int realSize, std::ofstream & dest) +/*int CLodHandler::decompress (unsigned char * source, int size, int realSize, std::ofstream & dest) { std::ofstream lb; lb.open("lodbuf\\buf.gz", std::ios::out|std::ios::binary); @@ -181,8 +183,12 @@ int CLodHandler::decompress (unsigned char * source, int size, int realSize, std int ret = infm(inputf, outputf); fclose(inputf); fclose(outputf); + std::stringstream sin; + //for() + + int ret = infs(sin, dest); return ret; -} +} */ int CLodHandler::decompress (unsigned char * source, int size, int realSize, std::string & dest) { @@ -265,6 +271,297 @@ int CLodHandler::infm(FILE *source, FILE *dest, int wBits) return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR; } +std::vector CLodHandler::extractManyFiles(std::vector defNamesIn, std::string lodName) +{ + std::vector ret(defNamesIn.size()); + for(int hh=0; hh found(defNamesIn.size(), 0); + for (int i=0;iopenFromMemory(outp, entries[i].realSize, std::string((char*)entries[i].name)); + ret[curDef] = nh; + + } + else //we will decompressing file + { + outp = new unsigned char[entries[i].size]; + FLOD.read((char*)outp, entries[i].size); + FLOD.seekg(0, std::ios_base::beg); + /*std::ofstream destin; + destin.open(bufff.c_str(), std::ios::binary); + //int decRes = decompress(outp, entries[i].size, entries[i].realSize, bufff); + int decRes = infs(outp, entries[i].size, entries[i].realSize, destin); + destin.close(); + if(decRes!=0) + { + std::cout<<"LOD Extraction error"<<" "<openFromMemory(decomp, entries[i].realSize, std::string((char*)entries[i].name)); + ret[curDef] = nh; + //delete decomp; + } + //for (int j=0; jnameStr extractManyFiles(std::vector defNamesIn, std::string lodName); //extrats given files void extract(std::string FName); + void extractFile(std::string FName, std::string name); void init(std::string lodFile); }; diff --git a/CMT.cpp b/CMT.cpp index 42044ccf7..1ca2c9516 100644 --- a/CMT.cpp +++ b/CMT.cpp @@ -281,8 +281,8 @@ int _tmain(int argc, _TCHAR* argv[]) //CLodHandler * test = new CLodHandler; //test->init(std::string("h3abp_bm.lod")); - CDefHandler * tdef = new CDefHandler; - tdef->openDef(std::string("newh3sprite\\AVLSPTR3.DEF")); + //CDefHandler * tdef = new CDefHandler; + //tdef->openDef(std::string("newh3sprite\\AVLSPTR3.DEF")); //tdef->getSprite(0); //CLodHandler * bitmapLod = new CLodHandler; @@ -293,8 +293,8 @@ int _tmain(int argc, _TCHAR* argv[]) //tconv->convert(); //tconv->saveBMP(std::string("tesciczekConva.bmp")); - CSemiDefHandler * semek = new CSemiDefHandler; - semek->openDef(std::string("EDG.DEF"), std::string("H3sprite.lod")); + //CSemiDefHandler * semek = new CSemiDefHandler; + //semek->openDef(std::string("EDG.DEF"), std::string("H3sprite.lod")); //////////////////////////////////////////////////////////////////////////////// lod testing end @@ -323,6 +323,7 @@ int _tmain(int argc, _TCHAR* argv[]) cgi->objh = objh; cgi->dobjinfo = new CDefObjInfoHandler; cgi->dobjinfo->load(); + cgi->lodh = new CLodHandler; THC std::cout<<"Inicjalizacja wszelakich handlerow: "<=por.xpos) + if(por2.xpos<=por.xpos) return false; return true; }; @@ -319,9 +319,15 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level, { if(CGameInfo::mainObj->objh->objInstances[gg].x >= x-Woff-4 && CGameInfo::mainObj->objh->objInstances[gg].x < dx+x-Hoff+4 && CGameInfo::mainObj->objh->objInstances[gg].y >= y-Hoff-4 && CGameInfo::mainObj->objh->objInstances[gg].y < dy+y-Hoff+4 && CGameInfo::mainObj->objh->objInstances[gg].z == level) { - std::vector::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(), - CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].name); - if(pit->priority==0) + if(!CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].isOnDefList) + { + ObjSorter os; + os.bitmap = CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].handler->ourImages[anim%CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].handler->ourImages.size()].bitmap; + os.xpos = (CGameInfo::mainObj->objh->objInstances[gg].x-x+4)*32; + os.ypos = (CGameInfo::mainObj->objh->objInstances[gg].y-y+4)*32; + highPrObjsVis.push_back(os); + } + else if(CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].printPriority==0) { ObjSorter os; os.bitmap = CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].handler->ourImages[anim%CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].handler->ourImages.size()].bitmap; @@ -342,11 +348,12 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level, } } } - //std::stable_sort(lowPrObjs.begin(), lowPrObjs.end()); - std::stable_sort(highPrObjs.begin(), highPrObjs.end(),pox); - std::stable_sort(highPrObjs.begin(), highPrObjs.end(),poy); - std::stable_sort(highPrObjsVis.begin(), highPrObjsVis.end(),pox); - std::stable_sort(highPrObjsVis.begin(), highPrObjsVis.end(),poy); + //std::stable_sort(lowPrObjs.begin(), lowPrObjs.end(), pox); + //std::stable_sort(lowPrObjs.begin(), lowPrObjs.end(), poy); + //std::stable_sort(highPrObjs.begin(), highPrObjs.end(),pox); + //std::stable_sort(highPrObjs.begin(), highPrObjs.end(),poy); + //std::stable_sort(highPrObjsVis.begin(), highPrObjsVis.end(),pox); + //std::stable_sort(highPrObjsVis.begin(), highPrObjsVis.end(),poy); for(int yy=0; yyourImages[rand()%2].bitmap; //visible top + //return partialHide->ourImages[rand()%2].bitmap; //visible top + return partialHide->ourImages[0].bitmap; //visible top } else if(visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && !visibility[x-1][y-1] && visibility[x+1][y+1] && !visibility[x+1][y-1] && visibility[x-1][y+1]) { - return partialHide->ourImages[4+rand()%2].bitmap; //visble bottom + //return partialHide->ourImages[4+rand()%2].bitmap; //visble bottom + return partialHide->ourImages[4].bitmap; //visble bottom } else if(!visibility[x][y+1] && !visibility[x+1][y] && visibility[x-1][y] && !visibility[x][y-1] && visibility[x-1][y-1] && !visibility[x+1][y+1] && !visibility[x+1][y-1] && visibility[x-1][y+1]) { - return CSDL_Ext::rotate01(partialHide->ourImages[2+rand()%2].bitmap); //visible left + //return CSDL_Ext::rotate01(partialHide->ourImages[2+rand()%2].bitmap); //visible left + return CSDL_Ext::rotate01(partialHide->ourImages[2].bitmap); //visible left } else if(!visibility[x][y+1] && visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && !visibility[x-1][y-1] && visibility[x+1][y+1] && visibility[x+1][y-1] && !visibility[x-1][y+1]) { - return partialHide->ourImages[2+rand()%2].bitmap; //visible right + //return partialHide->ourImages[2+rand()%2].bitmap; //visible right + return partialHide->ourImages[2].bitmap; //visible right } else if(visibility[x][y+1] && visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && !visibility[x-1][y-1]) { - return partialHide->ourImages[12+2*(rand()%2)].bitmap; //visible bottom, right - bottom, right; left top corner hidden + //return partialHide->ourImages[12+2*(rand()%2)].bitmap; //visible bottom, right - bottom, right; left top corner hidden + return partialHide->ourImages[12].bitmap; //visible bottom, right - bottom, right; left top corner hidden } else if(!visibility[x][y+1] && visibility[x+1][y] && !visibility[x-1][y] && visibility[x][y-1] && !visibility[x-1][y+1]) { @@ -489,7 +501,8 @@ SDL_Surface * CMapHandler::getVisBitmap(int x, int y, std::vector< std::vectorourImages[12+2*(rand()%2)].bitmap); //visible left, left - bottom, bottom; right top corner hidden + //return CSDL_Ext::rotate01(partialHide->ourImages[12+2*(rand()%2)].bitmap); //visible left, left - bottom, bottom; right top corner hidden + return CSDL_Ext::rotate01(partialHide->ourImages[12].bitmap); //visible left, left - bottom, bottom; right top corner hidden } else if(visibility[x][y+1] && visibility[x+1][y] && visibility[x-1][y] && visibility[x][y-1] && visibility[x-1][y-1] && visibility[x+1][y+1] && visibility[x+1][y-1] && visibility[x-1][y+1]) {