mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
* some minor improvements
This commit is contained in:
parent
f42a1d9f3a
commit
2fa2910777
@ -1472,6 +1472,10 @@ void CAmbarCendamo::deh3m()
|
||||
}
|
||||
spec->minLevel = bufor[i]; ++i;
|
||||
spec->maxLevel = bufor[i]; ++i;
|
||||
if(spec->maxLevel>7)
|
||||
spec->maxLevel = 7;
|
||||
if(spec->minLevel<1)
|
||||
spec->minLevel = 1;
|
||||
nobj.info = spec;
|
||||
break;
|
||||
}
|
||||
@ -1482,6 +1486,10 @@ void CAmbarCendamo::deh3m()
|
||||
i+=3;
|
||||
spec->minLevel = bufor[i]; ++i;
|
||||
spec->maxLevel = bufor[i]; ++i;
|
||||
if(spec->maxLevel>7)
|
||||
spec->maxLevel = 7;
|
||||
if(spec->minLevel<1)
|
||||
spec->minLevel = 1;
|
||||
nobj.info = spec;
|
||||
break;
|
||||
}
|
||||
@ -2743,7 +2751,16 @@ void CAmbarCendamo::processMap(std::vector<std::string> & defsToUnpack)
|
||||
DefInfo nxt = curDef;
|
||||
nxt.bytes[16] = 17;
|
||||
nxt.bytes[20] = atoi(map.defy[CGI->objh->objInstances[j].defNumber].name.substr(7, 8).c_str());
|
||||
int lvl = rand()%(((CCreGen3ObjInfo*)CGI->objh->objInstances[j].info)->maxLevel - ((CCreGen3ObjInfo*)CGI->objh->objInstances[j].info)->minLevel) + ((CCreGen3ObjInfo*)CGI->objh->objInstances[j].info)->minLevel;
|
||||
int lvl = -1;
|
||||
CCreGen3ObjInfo * ct = (CCreGen3ObjInfo*)CGI->objh->objInstances[j].info;
|
||||
if(ct->maxLevel>7)
|
||||
ct->maxLevel = 7;
|
||||
if(ct->minLevel<1)
|
||||
ct->minLevel = 1;
|
||||
if((((CCreGen3ObjInfo*)CGI->objh->objInstances[j].info)->maxLevel - ((CCreGen3ObjInfo*)CGI->objh->objInstances[j].info)->minLevel)!=0)
|
||||
lvl = rand()%(((CCreGen3ObjInfo*)CGI->objh->objInstances[j].info)->maxLevel - ((CCreGen3ObjInfo*)CGI->objh->objInstances[j].info)->minLevel) + ((CCreGen3ObjInfo*)CGI->objh->objInstances[j].info)->minLevel;
|
||||
else
|
||||
lvl = ((CCreGen3ObjInfo*)CGI->objh->objInstances[j].info)->maxLevel;
|
||||
nxt.name = creGenNames[nxt.bytes[20]][lvl];
|
||||
if(creGenNumbers[nxt.bytes[20]][lvl]!=-1)
|
||||
{
|
||||
|
200
CMT.cpp
200
CMT.cpp
@ -281,15 +281,10 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
THC std::cout<<"Loading .lods: "<<tmh.getDif()<<std::endl;
|
||||
CPreGame * cpg = new CPreGame(); //main menu and submenus
|
||||
THC std::cout<<"Initialization CPreGame (together): "<<tmh.getDif()<<std::endl;
|
||||
//CMessage * ll = new CMessage;
|
||||
//CSDL_Ext::blueToPlayersAdv(ll->piecesOfBox[0].ourImages[0].bitmap, 0);
|
||||
//SDL_SaveBMP(ll->piecesOfBox[0].ourImages[0].bitmap, "test2.bmp");
|
||||
cpg->mush = mush;
|
||||
cgi->scenarioOps = cpg->runLoop();
|
||||
THC tmh.getDif();
|
||||
|
||||
|
||||
|
||||
cgi->sspriteh = new CSemiLodHandler();
|
||||
cgi->sspriteh->openLod("H3sprite.lod");
|
||||
CArtHandler * arth = new CArtHandler;
|
||||
@ -315,8 +310,6 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
cgi->state = new CGameState();
|
||||
THC std::cout<<"Handlers initailization: "<<tmh.getDif()<<std::endl;
|
||||
|
||||
|
||||
|
||||
std::string mapname;
|
||||
if(CPG->ourScenSel->mapsel.selected==0) CPG->ourScenSel->mapsel.selected = 1; //only for tests
|
||||
if (CPG) mapname = CPG->ourScenSel->mapsel.ourMaps[CPG->ourScenSel->mapsel.selected].filename;
|
||||
@ -360,9 +353,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
THC std::cout<<"Displaying terrain: "<<tmh.getDif()<<std::endl;
|
||||
|
||||
|
||||
|
||||
|
||||
for (int i=0; i<cgi->scenarioOps.playerInfos.size();i++)
|
||||
for (int i=0; i<cgi->scenarioOps.playerInfos.size();i++) //initializing interfaces
|
||||
{
|
||||
if(cgi->scenarioOps.playerInfos[i].name=="AI")
|
||||
cgi->playerint.push_back(new CGlobalAI());
|
||||
@ -373,8 +364,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
while(1)
|
||||
while(1) //main game loop, one execution per turn
|
||||
{
|
||||
for (int i=0;i<cgi->playerint.size();i++)
|
||||
{
|
||||
@ -382,192 +372,6 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
cgi->playerint[i]->yourTurn();
|
||||
}
|
||||
}
|
||||
//SDL_Surface * ss = ac->defs[0]->ourImages[0].bitmap;
|
||||
//SDL_BlitSurface(ss, NULL, ekran, NULL);
|
||||
|
||||
bool scrollingLeft = false;
|
||||
bool scrollingRight = false;
|
||||
bool scrollingUp = false;
|
||||
bool scrollingDown = false;
|
||||
bool updateScreen = false;
|
||||
unsigned char animVal = 0; //for animations handling
|
||||
unsigned char animValHitCount = 0; //for slower animations
|
||||
//initializing framerate keeper
|
||||
FPSmanager * mainLoopFramerateKeeper = new FPSmanager;
|
||||
SDL_initFramerate(mainLoopFramerateKeeper);
|
||||
SDL_setFramerate(mainLoopFramerateKeeper, 30);
|
||||
//framerate keeper initialized
|
||||
for(;;) // main loop
|
||||
{
|
||||
try
|
||||
{
|
||||
if(SDL_PollEvent(&sEvent)) //wait for event...
|
||||
{
|
||||
if(sEvent.type==SDL_QUIT)
|
||||
return 0;
|
||||
else if (sEvent.type==SDL_KEYDOWN)
|
||||
{
|
||||
switch (sEvent.key.keysym.sym)
|
||||
{
|
||||
case SDLK_LEFT:
|
||||
{
|
||||
scrollingLeft = true;
|
||||
break;
|
||||
}
|
||||
case (SDLK_RIGHT):
|
||||
{
|
||||
scrollingRight = true;
|
||||
break;
|
||||
}
|
||||
case (SDLK_UP):
|
||||
{
|
||||
scrollingUp = true;
|
||||
break;
|
||||
}
|
||||
case (SDLK_DOWN):
|
||||
{
|
||||
scrollingDown = true;
|
||||
break;
|
||||
}
|
||||
case (SDLK_q):
|
||||
{
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
case (SDLK_u):
|
||||
{
|
||||
if(!ac->map.twoLevel)
|
||||
break;
|
||||
if (zz)
|
||||
zz--;
|
||||
else zz++;
|
||||
updateScreen = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} //keydown end
|
||||
else if(sEvent.type==SDL_KEYUP)
|
||||
{
|
||||
switch (sEvent.key.keysym.sym)
|
||||
{
|
||||
case SDLK_LEFT:
|
||||
{
|
||||
scrollingLeft = false;
|
||||
break;
|
||||
}
|
||||
case (SDLK_RIGHT):
|
||||
{
|
||||
scrollingRight = false;
|
||||
break;
|
||||
}
|
||||
case (SDLK_UP):
|
||||
{
|
||||
scrollingUp = false;
|
||||
break;
|
||||
}
|
||||
case (SDLK_DOWN):
|
||||
{
|
||||
scrollingDown = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}//keyup end
|
||||
else if(sEvent.type==SDL_MOUSEMOTION)
|
||||
{
|
||||
if(sEvent.motion.x<15)
|
||||
{
|
||||
scrollingLeft = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
scrollingLeft = false;
|
||||
}
|
||||
if(sEvent.motion.x>screen->w-15)
|
||||
{
|
||||
scrollingRight = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
scrollingRight = false;
|
||||
}
|
||||
if(sEvent.motion.y<15)
|
||||
{
|
||||
scrollingUp = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
scrollingUp = false;
|
||||
}
|
||||
if(sEvent.motion.y>screen->h-15)
|
||||
{
|
||||
scrollingDown = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
scrollingDown = false;
|
||||
}
|
||||
}
|
||||
} //event end
|
||||
|
||||
/////////////// scrolling terrain
|
||||
if(scrollingLeft)
|
||||
{
|
||||
if(xx>0)
|
||||
{
|
||||
xx--;
|
||||
updateScreen = true;
|
||||
}
|
||||
}
|
||||
if(scrollingRight)
|
||||
{
|
||||
if(xx<ac->map.width-25+8)
|
||||
{
|
||||
xx++;
|
||||
updateScreen = true;
|
||||
}
|
||||
}
|
||||
if(scrollingUp)
|
||||
{
|
||||
if(yy>0)
|
||||
{
|
||||
yy--;
|
||||
updateScreen = true;
|
||||
}
|
||||
}
|
||||
if(scrollingDown)
|
||||
{
|
||||
if(yy<ac->map.height-19+8)
|
||||
{
|
||||
yy++;
|
||||
updateScreen = true;
|
||||
}
|
||||
}
|
||||
if(updateScreen)
|
||||
{
|
||||
SDL_FillRect(ekran, NULL, SDL_MapRGB(ekran->format, 0, 0, 0));
|
||||
SDL_Surface * help = mh->terrainRect(xx,yy,25,19,zz,animVal);
|
||||
SDL_BlitSurface(help,NULL,ekran,NULL);
|
||||
SDL_FreeSurface(help);
|
||||
SDL_UpdateRect(ekran, 0, 0, ekran->w, ekran->h);
|
||||
updateScreen = false;
|
||||
}
|
||||
/////////
|
||||
}
|
||||
catch(...)
|
||||
{ continue; }
|
||||
|
||||
updateScreen = true;
|
||||
++animValHitCount; //for animations
|
||||
if(animValHitCount == 4)
|
||||
{
|
||||
animValHitCount = 0;
|
||||
++animVal;
|
||||
}
|
||||
|
||||
SDL_Delay(5); //give time for other apps
|
||||
SDL_framerateDelay(mainLoopFramerateKeeper);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
4
global.h
4
global.h
@ -8,7 +8,7 @@
|
||||
#else
|
||||
#define THC //
|
||||
#endif
|
||||
enum Ecolor {RED, BLUE, TAN, GREEN, ORANGE, PURPLE, TEAL, PINK};
|
||||
enum Ecolor {RED, BLUE, TAN, GREEN, ORANGE, PURPLE, TEAL, PINK}; //player's colors
|
||||
enum EterrainType {dirt, sand, grass, snow, swamp, rough, subterranean, lava, water, rock};
|
||||
enum Eriver {noRiver=0, clearRiver, icyRiver, muddyRiver, lavaRiver};
|
||||
enum Eroad {dirtRoad=1, grazvelRoad, cobblestoneRoad};
|
||||
@ -26,7 +26,7 @@ enum EHeroClasses {HERO_KNIGHT, HERO_CLERIC, HERO_RANGER, HERO_DRUID, HREO_ALCHE
|
||||
//LOCPLINT gives pointer to the interface which is currently showed (on this machine)
|
||||
|
||||
|
||||
const int F_NUMBER = 9; //factions quantity
|
||||
const int F_NUMBER = 9; //factions (town types) quantity
|
||||
const int PLAYER_LIMIT = 8; //player limit per map
|
||||
const int HEROES_PER_TYPE=8; //amount of heroes of each type
|
||||
const int SKILL_QUANTITY=28;
|
||||
|
Loading…
Reference in New Issue
Block a user