From 073c82cb1d3490c706a7ed5d58d4c3092ff3d689 Mon Sep 17 00:00:00 2001 From: mateuszb Date: Fri, 13 Jul 2007 15:10:27 +0000 Subject: [PATCH] choosing random resuorces and some minor stuff --- CAmbarCendamo.cpp | 77 ++++++++++++++++++++++++++++++++++++---------- CAmbarCendamo.h | 5 ++- CDefHandler.h | Bin 3084 -> 3134 bytes CLodHandler.cpp | 2 ++ 4 files changed, 67 insertions(+), 17 deletions(-) diff --git a/CAmbarCendamo.cpp b/CAmbarCendamo.cpp index 7390d05df..243bcd427 100644 --- a/CAmbarCendamo.cpp +++ b/CAmbarCendamo.cpp @@ -455,20 +455,6 @@ void CAmbarCendamo::deh3m() //teceDef(); } - std::vector dhandlers = CGameInfo::mainObj->spriteh->extractManyFiles(defsToUnpack); - for (int i=0;iourImages.size(); ++yy) - { - map.defy[vv].handler->ourImages[yy].bitmap = CSDL_Ext::alphaTransform(map.defy[vv].handler->ourImages[yy].bitmap); - SDL_Surface * bufs = CSDL_Ext::secondAlphaTransform(map.defy[vv].handler->ourImages[yy].bitmap, alphaTransSurf); - SDL_FreeSurface(map.defy[vv].handler->ourImages[yy].bitmap); - map.defy[vv].handler->ourImages[yy].bitmap = bufs; - } - } - SDL_FreeSurface(alphaTransSurf); THC std::cout<<"Reading defs: "< dhandlers = CGameInfo::mainObj->spriteh->extractManyFiles(defsToUnpack); + for (int i=0;ialphaTransformed) + continue; + for(int yy=0; yyourImages.size(); ++yy) + { + map.defy[vv].handler->ourImages[yy].bitmap = CSDL_Ext::alphaTransform(map.defy[vv].handler->ourImages[yy].bitmap); + SDL_Surface * bufs = CSDL_Ext::secondAlphaTransform(map.defy[vv].handler->ourImages[yy].bitmap, alphaTransSurf); + SDL_FreeSurface(map.defy[vv].handler->ourImages[yy].bitmap); + map.defy[vv].handler->ourImages[yy].bitmap = bufs; + map.defy[vv].handler->alphaTransformed = true; + } + } + SDL_FreeSurface(alphaTransSurf); + //loading events int numberOfEvents = readNormalNr(i); i+=4; for(int yyoo=0; yyoo & defsToUnpack) { - //for(int j=0;) + resDefNames.push_back("AVTRNDM0.DEF"); + resDefNames.push_back("AVTWOOD0.DEF"); + resDefNames.push_back("AVTMERC0.DEF"); + resDefNames.push_back("AVTORE0.DEF"); + resDefNames.push_back("AVTSULF0.DEF"); + resDefNames.push_back("AVTCRYS0.DEF"); + resDefNames.push_back("AVTGEMS0.DEF"); + resDefNames.push_back("AVTGOLD0.DEF"); + resDefNames.push_back("ZMITHR.DEF"); + for(int j=0; jobjh->objInstances.size(); ++j) + { + DefInfo & curDef = map.defy[CGI->objh->objInstances[j].defNumber]; + switch(getDefType(curDef)) + { + case EDefType::RESOURCE_DEF: + { + if(curDef.bytes[16]==76) //resource to specify + { + DefInfo nxt = curDef; + nxt.bytes[16] = 79; + nxt.bytes[20] = rand()%7; + nxt.name = resDefNames[nxt.bytes[20]+1]; + std::vector::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(), + nxt.name); + if(pit == CGameInfo::mainObj->dobjinfo->objs.end()) + { + nxt.isOnDefList = false; + } + else + { + nxt.printPriority = pit->priority; + nxt.isOnDefList = true; + } + map.defy.push_back(nxt); // add this def to the vector + defsToUnpack.push_back(nxt.name); + CGI->objh->objInstances[j].defNumber = map.defy.size()-1; + } + break; + } + } + } } diff --git a/CAmbarCendamo.h b/CAmbarCendamo.h index 05eeea45f..32f0ecd3e 100644 --- a/CAmbarCendamo.h +++ b/CAmbarCendamo.h @@ -29,7 +29,10 @@ public: int readNormalNr (int pos, int bytCon=4, bool cyclic = false); //read number from bytCon bytes starting from pos position in buffer ; if cyclic is true, number is treated as it were signed number with bytCon bytes void teceDef (); // create files with info about defs void deh3m(); // decode file, results are stored in map - void processMap(); //choose castles, creatures, resources, artifacts... + void processMap(std::vector & defsToUnpack); //choose castles, creatures, resources, artifacts... + //// + std::vector resDefNames; + //// void loadDefs(); EDefType getDefType(DefInfo& a); //returns type of object in def CCreatureSet readCreatureSet(int pos, int number = 7); //reads creature set in most recently encountered format; reades number units (default is 7) diff --git a/CDefHandler.h b/CDefHandler.h index bd3b2abbd3660f72b2c475d227dd5e9ceb9e576e..94969aba0b296858aec92602e887b3dc123cb332 100644 GIT binary patch delta 56 zcmeB?*e9{!2Aeh~LlQ$i5auu_FeC!W0)`AA9l}rqB=Z=G8Pb4qMGUzNsSGKbFS1#) F0sx0#4PF2M delta 12 Tcmdld(Ic_p2HR#Xb`w?rAOQph diff --git a/CLodHandler.cpp b/CLodHandler.cpp index 112d81649..0bf66c824 100644 --- a/CLodHandler.cpp +++ b/CLodHandler.cpp @@ -424,6 +424,7 @@ std::vector CLodHandler::extractManyFiles(std::vectoropenFromMemory(outp, entries[i].realSize, std::string((char*)entries[i].name)); + nh->alphaTransformed = false; ret[curDef] = nh; } else //we will decompressing file @@ -435,6 +436,7 @@ std::vector CLodHandler::extractManyFiles(std::vectoropenFromMemory(decomp, entries[i].realSize, std::string((char*)entries[i].name)); + nh->alphaTransformed = false; ret[curDef] = nh; } delete outp;