mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-06 09:09:40 +02:00
@@ -1520,7 +1520,7 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
|
|||||||
if(!isActive() || LOCPLINT->ctrlPressed())//ctrl makes arrow move screen, not hero
|
if(!isActive() || LOCPLINT->ctrlPressed())//ctrl makes arrow move screen, not hero
|
||||||
break;
|
break;
|
||||||
|
|
||||||
k -= SDLK_KP_0 + 1;
|
k -= SDLK_KP0 + 1;
|
||||||
if(k < 0 || k > 8 || key.state != SDL_PRESSED)
|
if(k < 0 || k > 8 || key.state != SDL_PRESSED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -53,8 +53,7 @@ SDL_Surface * CPCXConv::getSurface() const
|
|||||||
|
|
||||||
int width = -1, height = -1;
|
int width = -1, height = -1;
|
||||||
Epcxformat format;
|
Epcxformat format;
|
||||||
int fSize,y;
|
int fSize;
|
||||||
unsigned char add;
|
|
||||||
int it=0;
|
int it=0;
|
||||||
|
|
||||||
fSize = read_le_u32(pcx + it); it+=4;
|
fSize = read_le_u32(pcx + it); it+=4;
|
||||||
@@ -68,13 +67,16 @@ SDL_Surface * CPCXConv::getSurface() const
|
|||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
add = 4 - width%4;
|
|
||||||
if (add==4)
|
|
||||||
add=0;
|
|
||||||
|
|
||||||
if (format==PCX8B)
|
if (format==PCX8B)
|
||||||
{
|
{
|
||||||
ret = SDL_CreateRGBSurface(SDL_SWSURFACE, width+add, height, 8, 0, 0, 0, 0);
|
ret = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 8, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
it = 0xC;
|
||||||
|
for (int i=0; i<height; i++)
|
||||||
|
{
|
||||||
|
memcpy((char*)ret->pixels + ret->pitch * i, pcx + it, width);
|
||||||
|
it+= width;
|
||||||
|
}
|
||||||
|
|
||||||
it = pcxs-256*3;
|
it = pcxs-256*3;
|
||||||
for (int i=0;i<256;i++)
|
for (int i=0;i<256;i++)
|
||||||
@@ -90,17 +92,7 @@ SDL_Surface * CPCXConv::getSurface() const
|
|||||||
tp.b = pcx[it++];
|
tp.b = pcx[it++];
|
||||||
#endif
|
#endif
|
||||||
tp.unused = 0;
|
tp.unused = 0;
|
||||||
*(ret->format->palette->colors+i) = tp;
|
ret->format->palette->colors[i] = tp;
|
||||||
}
|
|
||||||
for (y=height; y>0; --y)
|
|
||||||
{
|
|
||||||
it = 0xC + (y-1)*width;
|
|
||||||
memcpy((char*)ret->pixels + ret->pitch * (y-1), pcx + it, width);
|
|
||||||
|
|
||||||
if (add>0)
|
|
||||||
{
|
|
||||||
memset((char*)ret->pixels + ret->pitch * (y-1) + width, 0, add);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -114,19 +106,15 @@ SDL_Surface * CPCXConv::getSurface() const
|
|||||||
int gmask = 0x00ff00;
|
int gmask = 0x00ff00;
|
||||||
int rmask = 0xff0000;
|
int rmask = 0xff0000;
|
||||||
#endif
|
#endif
|
||||||
ret = SDL_CreateRGBSurface(SDL_SWSURFACE, width+add, height, 24, rmask, gmask, bmask, 0);
|
ret = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 24, rmask, gmask, bmask, 0);
|
||||||
|
|
||||||
for (y=height; y>0; y--)
|
it = 0xC;
|
||||||
|
for (int i=0; i<height; i++)
|
||||||
{
|
{
|
||||||
it = 0xC + (y-1)*width*3;
|
memcpy((char*)ret->pixels + ret->pitch * i, pcx + it, width*3);
|
||||||
|
it+= width*3;
|
||||||
memcpy((char*)ret->pixels + ret->pitch * (y-1), pcx + it, width*3);
|
|
||||||
|
|
||||||
if (add>0)
|
|
||||||
{
|
|
||||||
memset((char*)ret->pixels + ret->pitch * (y-1) + width*3, 0, add*3);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -270,12 +270,6 @@ void CPlayerInterface::heroMoved(const TryMoveHero & details)
|
|||||||
//TODO: smooth disappear / appear effect
|
//TODO: smooth disappear / appear effect
|
||||||
}
|
}
|
||||||
|
|
||||||
if(details.start == details.end) //last step
|
|
||||||
{
|
|
||||||
eraseCurrentPathOf(ho);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ho->pos != details.end //hero didn't change tile but visit succeeded
|
if (ho->pos != details.end //hero didn't change tile but visit succeeded
|
||||||
|| directlyAttackingCreature) // or creature was attacked from endangering tile.
|
|| directlyAttackingCreature) // or creature was attacked from endangering tile.
|
||||||
{
|
{
|
||||||
@@ -283,7 +277,7 @@ void CPlayerInterface::heroMoved(const TryMoveHero & details)
|
|||||||
}
|
}
|
||||||
else if(adventureInt->terrain.currentPath && ho->pos == details.end) //&& hero is moving
|
else if(adventureInt->terrain.currentPath && ho->pos == details.end) //&& hero is moving
|
||||||
{
|
{
|
||||||
//remove one node from the path (the one we went)
|
if (adventureInt->terrain.currentPath->endPos() != details.end)
|
||||||
removeLastNodeFromPath(ho);
|
removeLastNodeFromPath(ho);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,7 +126,9 @@ const char * CMediaHandler::extract (int index, int & size)
|
|||||||
const char * CMediaHandler::extract (std::string srcName, int &size)
|
const char * CMediaHandler::extract (std::string srcName, int &size)
|
||||||
{
|
{
|
||||||
int index;
|
int index;
|
||||||
srcName.erase(srcName.find_last_of('.'));
|
size_t dotPos = srcName.find_last_of('.');
|
||||||
|
if (dotPos != std::string::npos)
|
||||||
|
srcName.erase(dotPos);
|
||||||
|
|
||||||
std::map<std::string, int>::iterator fit;
|
std::map<std::string, int>::iterator fit;
|
||||||
if ((fit = fimap.find(srcName)) != fimap.end())
|
if ((fit = fimap.find(srcName)) != fimap.end())
|
||||||
|
|||||||
@@ -2223,11 +2223,12 @@ std::vector<ui32> BattleInfo::calculateResistedStacks( const CSpell * sp, const
|
|||||||
if(sp->positiveness >= 0 && (*it)->owner == casterSideOwner)
|
if(sp->positiveness >= 0 && (*it)->owner == casterSideOwner)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
/*
|
||||||
const CGHeroInstance * bonusHero; //hero we should take bonuses from
|
const CGHeroInstance * bonusHero; //hero we should take bonuses from
|
||||||
if((*it)->owner == casterSideOwner)
|
if((*it)->owner == casterSideOwner)
|
||||||
bonusHero = caster;
|
bonusHero = caster;
|
||||||
else
|
else
|
||||||
bonusHero = hero2;
|
bonusHero = hero2;*/
|
||||||
|
|
||||||
int prob = (*it)->magicResistance(); //probability of resistance in %
|
int prob = (*it)->magicResistance(); //probability of resistance in %
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,13 @@ std::vector<CCampaignHeader> CCampaignHandler::getCampaignHeaders(GetMode mode)
|
|||||||
ret.push_back( getHeader(e.name, true) );
|
ret.push_back( getHeader(e.name, true) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BOOST_FOREACH(Entry e, bitmaph_ab->entries)
|
||||||
|
{
|
||||||
|
if( e.type == FILE_CAMPAIGN && e.name != "TOSBLK1" )
|
||||||
|
{
|
||||||
|
ret.push_back( getHeader(e.name, true) );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -143,7 +150,7 @@ CCampaignHeader CCampaignHandler::readHeaderFromMemory( const unsigned char *buf
|
|||||||
{
|
{
|
||||||
CCampaignHeader ret;
|
CCampaignHeader ret;
|
||||||
ret.version = read_le_u32(buffer + outIt); outIt+=4;
|
ret.version = read_le_u32(buffer + outIt); outIt+=4;
|
||||||
ret.mapVersion = read_le_u32(buffer + outIt);
|
ret.mapVersion = buffer[outIt++]; //1 byte only
|
||||||
ret.mapVersion -= 1; //change range of it from [1, 20] to [0, 19]
|
ret.mapVersion -= 1; //change range of it from [1, 20] to [0, 19]
|
||||||
ret.name = readString(buffer, outIt);
|
ret.name = readString(buffer, outIt);
|
||||||
ret.description = readString(buffer, outIt);
|
ret.description = readString(buffer, outIt);
|
||||||
|
|||||||
@@ -780,7 +780,7 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, std::string & src
|
|||||||
case 'U':
|
case 'U':
|
||||||
b.type = Bonus::UNDEAD; break;
|
b.type = Bonus::UNDEAD; break;
|
||||||
default:
|
default:
|
||||||
tlog3 << "Not parsed bonus " << buf << mod << "\n";
|
tlog5 << "Not parsed bonus " << buf << mod << "\n";
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -879,7 +879,7 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, std::string & src
|
|||||||
b.type = Bonus::RECEPTIVE;
|
b.type = Bonus::RECEPTIVE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
tlog3 << "Not parsed bonus " << buf << mod << "\n";
|
tlog5 << "Not parsed bonus " << buf << mod << "\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -908,7 +908,7 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, std::string & src
|
|||||||
b.additionalInfo = 3; //always expert?
|
b.additionalInfo = 3; //always expert?
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
tlog3 << "Not parsed bonus " << buf << mod << "\n";
|
tlog5 << "Not parsed bonus " << buf << mod << "\n";
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ JsonNode::JsonNode(std::string filename):
|
|||||||
type(DATA_NULL)
|
type(DATA_NULL)
|
||||||
{
|
{
|
||||||
FILE * file = fopen(filename.c_str(), "rb");
|
FILE * file = fopen(filename.c_str(), "rb");
|
||||||
|
if (!file)
|
||||||
|
return;
|
||||||
|
|
||||||
fseek(file, 0, SEEK_END);
|
fseek(file, 0, SEEK_END);
|
||||||
size_t datasize = ftell(file);
|
size_t datasize = ftell(file);
|
||||||
fseek(file, 0, SEEK_SET);
|
fseek(file, 0, SEEK_SET);
|
||||||
|
|||||||
Reference in New Issue
Block a user