mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Patch from Dikamilo:
* compatibility fixes for MinGW * Code::Blocks project files
This commit is contained in:
parent
fb4ee65d0e
commit
dd36cfce50
@ -14,7 +14,7 @@ using namespace boost::lambda;
|
||||
using namespace std;
|
||||
using namespace GeniusAI;
|
||||
|
||||
#if defined (_MSC_VER) && (_MSC_VER >= 1020)
|
||||
#if defined (_MSC_VER) && (_MSC_VER >= 1020) && (__MINGW32__)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
@ -184,10 +184,10 @@ void CGeniusAI::battleStackIsAttacked(int ID, int dmg, int killed, int IDby, boo
|
||||
/**
|
||||
* called when it's turn of that stack
|
||||
*/
|
||||
BattleAction CGeniusAI::activeStack(int stackID)
|
||||
BattleAction CGeniusAI::activeStack(int stackID)
|
||||
{
|
||||
std::string message("\t\t\tCGeniusAI::activeStack stackID(");
|
||||
|
||||
|
||||
message += boost::lexical_cast<std::string>(stackID);
|
||||
message += ")";
|
||||
MsgBox(message.c_str());
|
||||
@ -198,17 +198,17 @@ BattleAction CGeniusAI::activeStack(int stackID)
|
||||
/*
|
||||
ui8 side; //who made this action: false - left, true - right player
|
||||
ui32 stackNumber;//stack ID, -1 left hero, -2 right hero,
|
||||
ui8 actionType; //
|
||||
0 = Cancel BattleAction
|
||||
1 = Hero cast a spell
|
||||
2 = Walk
|
||||
3 = Defend
|
||||
4 = Retreat from the battle
|
||||
5 = Surrender
|
||||
6 = Walk and Attack
|
||||
7 = Shoot
|
||||
8 = Wait
|
||||
9 = Catapult
|
||||
ui8 actionType; //
|
||||
0 = Cancel BattleAction
|
||||
1 = Hero cast a spell
|
||||
2 = Walk
|
||||
3 = Defend
|
||||
4 = Retreat from the battle
|
||||
5 = Surrender
|
||||
6 = Walk and Attack
|
||||
7 = Shoot
|
||||
8 = Wait
|
||||
9 = Catapult
|
||||
10 = Monster casts a spell (i.e. Faerie Dragons)
|
||||
ui16 destinationTile;
|
||||
si32 additionalInfo; // e.g. spell number if type is 1 || 10; tile to attack if type is 6
|
||||
@ -249,7 +249,7 @@ CBattleHelper::CBattleHelper():
|
||||
boost::algorithm::trim(parts[1]);
|
||||
if (parts[0].compare("m_voteForDistance") == 0)
|
||||
{
|
||||
try
|
||||
try
|
||||
{
|
||||
m_voteForDistance = boost::lexical_cast<int>(parts[1]);
|
||||
}
|
||||
@ -258,7 +258,7 @@ CBattleHelper::CBattleHelper():
|
||||
}
|
||||
else if (parts[0].compare("m_voteForDistanceFromShooters") == 0)
|
||||
{
|
||||
try
|
||||
try
|
||||
{
|
||||
m_voteForDistanceFromShooters = boost::lexical_cast<int>(parts[1]);
|
||||
}
|
||||
@ -267,7 +267,7 @@ CBattleHelper::CBattleHelper():
|
||||
}
|
||||
else if (parts[0].compare("m_voteForHitPoints") == 0)
|
||||
{
|
||||
try
|
||||
try
|
||||
{
|
||||
m_voteForHitPoints = boost::lexical_cast<int>(parts[1]);
|
||||
}
|
||||
@ -276,7 +276,7 @@ CBattleHelper::CBattleHelper():
|
||||
}
|
||||
else if (parts[0].compare("m_voteForMaxDamage") == 0)
|
||||
{
|
||||
try
|
||||
try
|
||||
{
|
||||
m_voteForMaxDamage = boost::lexical_cast<int>(parts[1]);
|
||||
}
|
||||
@ -285,7 +285,7 @@ CBattleHelper::CBattleHelper():
|
||||
}
|
||||
else if (parts[0].compare("m_voteForMaxSpeed") == 0)
|
||||
{
|
||||
try
|
||||
try
|
||||
{
|
||||
m_voteForMaxSpeed = boost::lexical_cast<int>(parts[1]);
|
||||
}
|
||||
@ -294,7 +294,7 @@ CBattleHelper::CBattleHelper():
|
||||
}
|
||||
else if (parts[0].compare("m_voteForMinDamage") == 0)
|
||||
{
|
||||
try
|
||||
try
|
||||
{
|
||||
m_voteForMinDamage = boost::lexical_cast<int>(parts[1]);
|
||||
}
|
||||
@ -375,7 +375,7 @@ CBattleLogic::CBattleLogic(ICallback *cb, CCreatureSet *army1, CCreatureSet *ar
|
||||
const int max_enemy_creatures = 12;
|
||||
m_statMaxDamage.reserve(max_enemy_creatures);
|
||||
m_statMinDamage.reserve(max_enemy_creatures);
|
||||
|
||||
|
||||
m_statMaxSpeed.reserve(max_enemy_creatures);
|
||||
m_statDistance.reserve(max_enemy_creatures);
|
||||
m_statDistanceFromShooters.reserve(max_enemy_creatures);
|
||||
@ -400,7 +400,7 @@ void CBattleLogic::MakeStatistics(int currentCreatureId)
|
||||
std::for_each(allStacks.begin(), allStacks.end(),
|
||||
if_(bind<ui8>(&CStack::attackerOwned, bind<CStack>(&map_stacks::value_type::second, _1)) == m_bIsAttacker)
|
||||
[
|
||||
var(enemy)[ret<int>(bind<int>(&map_stacks::value_type::first, _1))] =
|
||||
var(enemy)[ret<int>(bind<int>(&map_stacks::value_type::first, _1))] =
|
||||
ret<CStack>(bind<CStack>(&map_stacks::value_type::second, _1))
|
||||
]
|
||||
);
|
||||
@ -408,13 +408,13 @@ void CBattleLogic::MakeStatistics(int currentCreatureId)
|
||||
// max damage
|
||||
std::for_each(enemy.begin(), enemy.end(),
|
||||
var(m_statMaxDamage)[ret<int>(bind<int>(&map_stacks::value_type::first, _1))] =
|
||||
ret<int>(bind<int>(&CCreature::damageMax, bind<CCreature*>(&CStack::creature,
|
||||
ret<int>(bind<int>(&CCreature::damageMax, bind<CCreature*>(&CStack::creature,
|
||||
bind<CStack>(&map_stacks::value_type::second, _1))))
|
||||
);
|
||||
// min damage
|
||||
std::for_each(enemy.begin(), enemy.end(),
|
||||
var(m_statMinDamage)[ret<int>(bind<int>(&map_stacks::value_type::first, _1))] =
|
||||
ret<int>(bind<int>(&CCreature::damageMax, bind<CCreature*>(&CStack::creature,
|
||||
ret<int>(bind<int>(&CCreature::damageMax, bind<CCreature*>(&CStack::creature,
|
||||
bind<CStack>(&map_stacks::value_type::second, _1))))
|
||||
);
|
||||
*/
|
||||
@ -452,19 +452,19 @@ void CBattleLogic::MakeStatistics(int currentCreatureId)
|
||||
m_statMinDamage.push_back(std::pair<int, int>(id, st->creature->damageMin * st->amount));
|
||||
m_statHitPoints.push_back(std::pair<int, int>(id, hitPoints));
|
||||
m_statMaxSpeed.push_back(std::pair<int, int>(id, st->creature->speed));
|
||||
|
||||
|
||||
totalEnemyDamage += (st->creature->damageMax + st->creature->damageMin) * st->amount / 2;
|
||||
totalEnemyHitPoints += hitPoints;
|
||||
|
||||
|
||||
// calculate casualties
|
||||
SCreatureCasualties cs;
|
||||
// hp * amount - damage * ( (att - def)>=0 )
|
||||
// hit poionts
|
||||
assert(hitPoints >= 0 && "CGeniusAI - creature cannot have hit points less than zero");
|
||||
|
||||
|
||||
CGHeroInstance *attackerHero = (m_side)? m_hero1 : m_hero2;
|
||||
CGHeroInstance *defendingHero = (m_side)? m_hero2 : m_hero1;
|
||||
|
||||
|
||||
int attackDefenseBonus = currentStack->creature->attack + (attackerHero ? attackerHero->getPrimSkillLevel(0) : 0) - (st->creature->defence + (defendingHero ? defendingHero->getPrimSkillLevel(1) : 0));
|
||||
float damageFactor = 1.0f;
|
||||
if(attackDefenseBonus < 0) //decreasing dmg
|
||||
@ -509,7 +509,7 @@ void CBattleLogic::MakeStatistics(int currentCreatureId)
|
||||
cs.leftHitPoint_for_min = (hitPoints - cs.damage_min) % st->creature->hitPoints;
|
||||
|
||||
m_statCasualties.push_back(std::pair<int, SCreatureCasualties>(id, cs));
|
||||
|
||||
|
||||
if (st->creature->isShooting() && st->shots > 0)
|
||||
{
|
||||
m_statDistanceFromShooters.push_back(std::pair<int, int>(id, m_battleHelper.GetShortestDistance(currentStack->position, st->position)));
|
||||
@ -524,7 +524,7 @@ void CBattleLogic::MakeStatistics(int currentCreatureId)
|
||||
m_statDistance.push_back(std::pair<int, int>(id, m_battleHelper.GetDistanceWithObstacles(currentStack->position, st->position)));
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
if (st->amount < 1)
|
||||
{
|
||||
@ -547,25 +547,25 @@ void CBattleLogic::MakeStatistics(int currentCreatureId)
|
||||
m_bEnemyDominates = false;
|
||||
}
|
||||
// sort max damage
|
||||
std::sort(m_statMaxDamage.begin(), m_statMaxDamage.end(),
|
||||
std::sort(m_statMaxDamage.begin(), m_statMaxDamage.end(),
|
||||
bind(&creature_stat::value_type::second, _1) > bind(&creature_stat::value_type::second, _2));
|
||||
// sort min damage
|
||||
std::sort(m_statMinDamage.begin(), m_statMinDamage.end(),
|
||||
std::sort(m_statMinDamage.begin(), m_statMinDamage.end(),
|
||||
bind(&creature_stat::value_type::second, _1) > bind(&creature_stat::value_type::second, _2));
|
||||
// sort max speed
|
||||
std::sort(m_statMaxSpeed.begin(), m_statMaxSpeed.end(),
|
||||
std::sort(m_statMaxSpeed.begin(), m_statMaxSpeed.end(),
|
||||
bind(&creature_stat::value_type::second, _1) > bind(&creature_stat::value_type::second, _2));
|
||||
// sort distance
|
||||
std::sort(m_statDistance.begin(), m_statDistance.end(),
|
||||
std::sort(m_statDistance.begin(), m_statDistance.end(),
|
||||
bind(&creature_stat::value_type::second, _1) < bind(&creature_stat::value_type::second, _2));
|
||||
// sort distance from shooters
|
||||
std::sort(m_statDistanceFromShooters.begin(), m_statDistanceFromShooters.end(),
|
||||
std::sort(m_statDistanceFromShooters.begin(), m_statDistanceFromShooters.end(),
|
||||
bind(&creature_stat::value_type::second, _1) < bind(&creature_stat::value_type::second, _2));
|
||||
// sort hit points
|
||||
std::sort(m_statHitPoints.begin(), m_statHitPoints.end(),
|
||||
std::sort(m_statHitPoints.begin(), m_statHitPoints.end(),
|
||||
bind(&creature_stat::value_type::second, _1) > bind(&creature_stat::value_type::second, _2));
|
||||
// sort casualties
|
||||
std::sort(m_statCasualties.begin(), m_statCasualties.end(),
|
||||
std::sort(m_statCasualties.begin(), m_statCasualties.end(),
|
||||
bind(&creature_stat_casualties::value_type::second_type::damage_max, bind(&creature_stat_casualties::value_type::second, _1))
|
||||
>
|
||||
bind(&creature_stat_casualties::value_type::second_type::damage_max, bind(&creature_stat_casualties::value_type::second, _2)));
|
||||
@ -577,7 +577,7 @@ BattleAction CBattleLogic::MakeDecision(int stackID)
|
||||
|
||||
list<int> creatures;
|
||||
int additionalInfo;
|
||||
|
||||
|
||||
if (m_bEnemyDominates)
|
||||
{
|
||||
creatures = PerformBerserkAttack(stackID, additionalInfo);
|
||||
@ -664,7 +664,7 @@ std::vector<int> CBattleLogic::GetAvailableHexesForAttacker(CStack *defender, CS
|
||||
}
|
||||
candidates.push_back(hexPoint(x - 2, y));
|
||||
candidates.push_back(hexPoint(x + 1, y));
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -719,7 +719,7 @@ std::vector<int> CBattleLogic::GetAvailableHexesForAttacker(CStack *defender, CS
|
||||
candidates.push_back(hexPoint(x + 1, y));
|
||||
candidates.push_back(hexPoint(x - 1, y));
|
||||
}
|
||||
|
||||
|
||||
// remove fields which are out of bounds or obstacles
|
||||
for (std::list<hexPoint>::iterator it = candidates.begin(); it != candidates.end(); ++it)
|
||||
{
|
||||
@ -732,7 +732,7 @@ std::vector<int> CBattleLogic::GetAvailableHexesForAttacker(CStack *defender, CS
|
||||
}
|
||||
|
||||
int new_pos = m_battleHelper.GetBattleFieldPosition(it->first, it->second);
|
||||
CStack *st = m_cb->battleGetStackByPos(new_pos);
|
||||
CStack *st = m_cb->battleGetStackByPos(new_pos);
|
||||
|
||||
if (st == NULL || st->amount < 1)
|
||||
{
|
||||
@ -764,9 +764,9 @@ std::vector<int> CBattleLogic::GetAvailableHexesForAttacker(CStack *defender, CS
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fields.push_back(new_pos);
|
||||
|
||||
|
||||
}
|
||||
else if (attacker)
|
||||
{
|
||||
@ -783,7 +783,7 @@ std::vector<int> CBattleLogic::GetAvailableHexesForAttacker(CStack *defender, CS
|
||||
|
||||
BattleAction CBattleLogic::MakeDefend(int stackID)
|
||||
{
|
||||
BattleAction ba;
|
||||
BattleAction ba;
|
||||
ba.side = 1;
|
||||
ba.actionType = action_defend;
|
||||
ba.stackNumber = stackID;
|
||||
@ -793,7 +793,7 @@ BattleAction CBattleLogic::MakeDefend(int stackID)
|
||||
|
||||
BattleAction CBattleLogic::MakeWait(int stackID)
|
||||
{
|
||||
BattleAction ba;
|
||||
BattleAction ba;
|
||||
ba.side = 1;
|
||||
ba.actionType = action_wait;
|
||||
ba.stackNumber = stackID;
|
||||
@ -806,7 +806,7 @@ BattleAction CBattleLogic::MakeAttack(int attackerID, int destinationID)
|
||||
if (m_cb->battleCanShoot(attackerID, m_cb->battleGetPos(destinationID)))
|
||||
{
|
||||
// shoot
|
||||
BattleAction ba;
|
||||
BattleAction ba;
|
||||
ba.side = 1;
|
||||
ba.additionalInfo = -1;
|
||||
ba.actionType = action_shoot; // shoot
|
||||
@ -823,7 +823,7 @@ BattleAction CBattleLogic::MakeAttack(int attackerID, int destinationID)
|
||||
{
|
||||
return MakeDefend(attackerID);
|
||||
}
|
||||
|
||||
|
||||
// get the best tile - now the nearest
|
||||
|
||||
int prev_distance = m_battleHelper.InfiniteDistance;
|
||||
@ -845,20 +845,20 @@ BattleAction CBattleLogic::MakeAttack(int attackerID, int destinationID)
|
||||
}
|
||||
|
||||
std::vector<int> fields = m_cb->battleGetAvailableHexes(attackerID, false);
|
||||
BattleAction ba;
|
||||
BattleAction ba;
|
||||
ba.side = 1;
|
||||
//ba.actionType = 6; // go and attack
|
||||
ba.stackNumber = attackerID;
|
||||
ba.destinationTile = (ui16)dest_tile;
|
||||
ba.additionalInfo = m_cb->battleGetPos(destinationID);
|
||||
|
||||
|
||||
int nearest_dist = m_battleHelper.InfiniteDistance;
|
||||
int nearest_pos = -1;
|
||||
|
||||
// if double wide calculate tail
|
||||
CStack *attackerStack = m_cb->battleGetStackByID(attackerID);
|
||||
assert(attackerStack != NULL);
|
||||
|
||||
|
||||
int tail_pos = -1;
|
||||
if (attackerStack->creature->isDoubleWide())
|
||||
{
|
||||
@ -963,7 +963,7 @@ list<int> CBattleLogic::PerformDefaultAction(int stackID, int &additionalInfo)
|
||||
|
||||
votes[m_statMaxDamage.begin()->first] += m_battleHelper.GetVoteForMaxDamage();
|
||||
votes[m_statMinDamage.begin()->first] += m_battleHelper.GetVoteForMinDamage();
|
||||
if (m_statDistanceFromShooters.size())
|
||||
if (m_statDistanceFromShooters.size())
|
||||
{
|
||||
votes[m_statDistanceFromShooters.begin()->first] += m_battleHelper.GetVoteForDistanceFromShooters();
|
||||
}
|
||||
@ -1056,7 +1056,7 @@ void CBattleLogic::PrintBattleAction(const BattleAction &action) // for debug pu
|
||||
|
||||
#ifdef _WIN32
|
||||
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
||||
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
GetConsoleScreenBufferInfo(hConsole, &csbi);
|
||||
SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
|
||||
@ -1066,7 +1066,7 @@ void CBattleLogic::PrintBattleAction(const BattleAction &action) // for debug pu
|
||||
color = "\x1b[1;40;32m";
|
||||
std::cout << color;
|
||||
#endif
|
||||
|
||||
|
||||
std::cout << message.c_str() << std::flush;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
74
AI/GeniusAI/genius.cbp
Normal file
74
AI/GeniusAI/genius.cbp
Normal file
@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="AI" />
|
||||
<Option platforms="Windows;" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Debug Win32">
|
||||
<Option platforms="Windows;" />
|
||||
<Option output="..\..\..\..\..\Install\Heroes3\AI\GeniusAI" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="..\..\..\..\..\Install\Heroes3\AI" />
|
||||
<Option object_output="Debug Win32" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
<Option createStaticLib="1" />
|
||||
<Compiler>
|
||||
<Add option="-g" />
|
||||
<Add option="-O0" />
|
||||
<Add option="-DWIN32" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add option="-D_WINDOWS" />
|
||||
<Add option="-D_USRDLL" />
|
||||
<Add option="-DGENIUS_EXPORTS" />
|
||||
</Compiler>
|
||||
</Target>
|
||||
<Target title="Release Win32">
|
||||
<Option platforms="Windows;" />
|
||||
<Option output="..\..\..\..\..\Install\Heroes3\AI\GeniusAI" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="..\..\..\..\..\Install\Heroes3\AI" />
|
||||
<Option object_output="Release Win32" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
<Option createStaticLib="1" />
|
||||
<Compiler>
|
||||
<Add option="-fexpensive-optimizations" />
|
||||
<Add option="-Os" />
|
||||
<Add option="-O3" />
|
||||
<Add option="-O2" />
|
||||
<Add option="-O1" />
|
||||
<Add option="-O" />
|
||||
<Add option="-W" />
|
||||
<Add option="-DWIN32" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add option="-D_WINDOWS" />
|
||||
<Add option="-D_USRDLL" />
|
||||
<Add option="-DGENIUS_EXPORTS" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
</Linker>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-D_WIN32" />
|
||||
<Add directory="$(#boost.include)" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add library="..\..\..\..\..\Install\Heroes3\libVCMI_lib.a" />
|
||||
<Add directory="$(#boost.lib)" />
|
||||
</Linker>
|
||||
<Unit filename="CGeniusAI.cpp" />
|
||||
<Unit filename="CGeniusAI.h" />
|
||||
<Unit filename="DLLMain.cpp" />
|
||||
<Extensions>
|
||||
<code_completion />
|
||||
<envvars />
|
||||
<debugger />
|
||||
</Extensions>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
9
CMT.cpp
9
CMT.cpp
@ -43,6 +43,9 @@
|
||||
#include "lib/VCMI_Lib.h"
|
||||
#include <cstdlib>
|
||||
|
||||
#if __MINGW32__
|
||||
#undef main
|
||||
#endif
|
||||
std::string NAME = NAME_VER + std::string(" (client)");
|
||||
DLL_EXPORT void initDLL(CLodHandler *b);
|
||||
SDL_Surface * screen, * screen2;
|
||||
@ -56,7 +59,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
#else
|
||||
int main(int argc, char** argv)
|
||||
#endif
|
||||
{
|
||||
{
|
||||
tlog0 << "Starting... " << std::endl;
|
||||
THC timeHandler tmh, total, pomtime;
|
||||
CClient *client = NULL;
|
||||
@ -113,7 +116,7 @@ int main(int argc, char** argv)
|
||||
CGI->setFromLib();
|
||||
tlog0<<"Initializing VCMI_Lib: "<<tmh.getDif()<<std::endl;
|
||||
pomtime.getDif();
|
||||
cgi->curh = new CCursorHandler;
|
||||
cgi->curh = new CCursorHandler;
|
||||
cgi->curh->initCursor();
|
||||
cgi->curh->show();
|
||||
tlog0<<"\tScreen handler: "<<pomtime.getDif()<<std::endl;
|
||||
@ -150,7 +153,7 @@ int main(int argc, char** argv)
|
||||
if(options->mode == 0) //new game
|
||||
{
|
||||
tmh.getDif();
|
||||
char portc[10];
|
||||
char portc[10];
|
||||
SDL_itoa(conf.cc.port,portc,10);
|
||||
CClient::runServer(portc);
|
||||
tlog0<<"Preparing shared memory and starting server: "<<tmh.getDif()<<std::endl;
|
||||
|
@ -27,15 +27,7 @@ bool isItIn(const SDL_Rect * rect, int x, int y)
|
||||
return true;
|
||||
else return false;
|
||||
}
|
||||
inline SDL_Rect genRect(const int & hh, const int & ww, const int & xx, const int & yy)
|
||||
{
|
||||
SDL_Rect ret;
|
||||
ret.h=hh;
|
||||
ret.w=ww;
|
||||
ret.x=xx;
|
||||
ret.y=yy;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void blitAtWR(SDL_Surface * src, int x, int y, SDL_Surface * dst)
|
||||
{
|
||||
SDL_Rect pom = genRect(src->h,src->w,x,y);
|
||||
@ -248,16 +240,7 @@ inline void CSDL_Ext::SDL_PutPixel(SDL_Surface *ekran, const int & x, const int
|
||||
SDL_UpdateRect(ekran, x, y, 1, 1);
|
||||
}
|
||||
|
||||
inline void CSDL_Ext::SDL_PutPixelWithoutRefresh(SDL_Surface *ekran, const int & x, const int & y, const Uint8 & R, const Uint8 & G, const Uint8 & B, Uint8 A)
|
||||
{
|
||||
Uint8 *p = (Uint8 *)ekran->pixels + y * ekran->pitch + x * ekran->format->BytesPerPixel;
|
||||
|
||||
p[0] = B;
|
||||
p[1] = G;
|
||||
p[2] = R;
|
||||
if(ekran->format->BytesPerPixel==4)
|
||||
p[3] = A;
|
||||
}
|
||||
|
||||
///**************/
|
||||
///Reverses the toRot surface by the vertical axis
|
||||
@ -431,7 +414,7 @@ Uint32 CSDL_Ext::SDL_GetPixel(SDL_Surface *surface, const int & x, const int & y
|
||||
return *(Uint32 *)p;
|
||||
|
||||
default:
|
||||
return 0; // shouldn't happen, but avoids warnings
|
||||
return 0; // shouldn't happen, but avoids warnings
|
||||
}
|
||||
}
|
||||
|
||||
@ -658,7 +641,7 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
|
||||
}
|
||||
|
||||
/* clip the source rectangle to the source surface */
|
||||
if(srcRect)
|
||||
if(srcRect)
|
||||
{
|
||||
int maxw, maxh;
|
||||
|
||||
@ -686,8 +669,8 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
|
||||
if(maxh < h)
|
||||
h = maxh;
|
||||
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
srcx = srcy = 0;
|
||||
w = src->w;
|
||||
|
@ -20,12 +20,32 @@ template <typename T> int getIndexOf(const std::vector<T> & v, const T & val)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
inline SDL_Rect genRect(const int & hh, const int & ww, const int & xx, const int & yy);
|
||||
inline SDL_Rect genRect(const int & hh, const int & ww, const int & xx, const int & yy)
|
||||
{
|
||||
SDL_Rect ret;
|
||||
ret.h=hh;
|
||||
ret.w=ww;
|
||||
ret.x=xx;
|
||||
ret.y=yy;
|
||||
return ret;
|
||||
}
|
||||
namespace CSDL_Ext
|
||||
{
|
||||
extern SDL_Surface * std32bppSurface;
|
||||
inline void SDL_PutPixel(SDL_Surface *ekran, const int & x, const int & y, const Uint8 & R, const Uint8 & G, const Uint8 & B, Uint8 A = 255); //myC influences the start of reading pixels
|
||||
inline void SDL_PutPixelWithoutRefresh(SDL_Surface *ekran, const int & x, const int & y, const Uint8 & R, const Uint8 & G, const Uint8 & B, Uint8 A = 255); //myC influences the start of reading pixels ; without refreshing
|
||||
//inline void SDL_PutPixelWithoutRefresh(SDL_Surface *ekran, const int & x, const int & y, const Uint8 & R, const Uint8 & G, const Uint8 & B, Uint8 A = 255); //myC influences the start of reading pixels ; without refreshing
|
||||
|
||||
inline void SDL_PutPixelWithoutRefresh(SDL_Surface *ekran, const int & x, const int & y, const Uint8 & R, const Uint8 & G, const Uint8 & B, Uint8 A = 255)
|
||||
{
|
||||
Uint8 *p = (Uint8 *)ekran->pixels + y * ekran->pitch + x * ekran->format->BytesPerPixel;
|
||||
|
||||
p[0] = B;
|
||||
p[1] = G;
|
||||
p[2] = R;
|
||||
if(ekran->format->BytesPerPixel==4)
|
||||
p[3] = A;
|
||||
}
|
||||
|
||||
SDL_Surface * rotate01(SDL_Surface * toRot); //vertical flip
|
||||
SDL_Surface * hFlip(SDL_Surface * toRot); //horizontal flip
|
||||
SDL_Surface * rotate02(SDL_Surface * toRot); //rotate 90 degrees left
|
||||
|
142
client/VCMI_client.cbp
Normal file
142
client/VCMI_client.cbp
Normal file
@ -0,0 +1,142 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="Client" />
|
||||
<Option platforms="Windows;" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Debug Win32">
|
||||
<Option platforms="Windows;" />
|
||||
<Option output="..\..\..\..\Install\Heroes3\VCMI_client" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="..\..\..\..\Install\Heroes3" />
|
||||
<Option object_output="Debug Win32" />
|
||||
<Option type="1" />
|
||||
<Option compiler="gcc" />
|
||||
<Option use_console_runner="0" />
|
||||
<Compiler>
|
||||
<Add option="-g" />
|
||||
<Add option="-D_DEBUG" />
|
||||
</Compiler>
|
||||
</Target>
|
||||
<Target title="Release Win32">
|
||||
<Option platforms="Windows;" />
|
||||
<Option output="..\..\..\..\Install\Heroes3\VCMI_client" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="..\..\..\..\Install\Heroes3" />
|
||||
<Option object_output="Release Win32" />
|
||||
<Option type="1" />
|
||||
<Option compiler="gcc" />
|
||||
<Option use_console_runner="0" />
|
||||
<Compiler>
|
||||
<Add option="-fexpensive-optimizations" />
|
||||
<Add option="-Os" />
|
||||
<Add option="-O3" />
|
||||
<Add option="-O2" />
|
||||
<Add option="-O1" />
|
||||
<Add option="-O" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
</Linker>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-D_WIN32" />
|
||||
<Add option="-D_WIN32_WINDOWS" />
|
||||
<Add directory="$(#boost.include)" />
|
||||
<Add directory="$(#sdl.include)" />
|
||||
<Add directory="$(#zlib.include)" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-lSDL" />
|
||||
<Add option="-lSDL_image" />
|
||||
<Add option="-lSDL_ttf" />
|
||||
<Add option="-lSDL_mixer" />
|
||||
<Add option="-lzlib1" />
|
||||
<Add option="-llibboost_thread-mgw43-mt-1_37" />
|
||||
<Add option="-llibboost_system-mgw43-mt-1_37" />
|
||||
<Add option="-llibboost_filesystem-mgw43-mt-1_37" />
|
||||
<Add library="..\..\..\..\Install\Heroes3\libVCMI_lib.a" />
|
||||
<Add directory="$(#sdl.lib)" />
|
||||
<Add directory="$(#boost.lib)" />
|
||||
<Add directory="$(#zlib.lib)" />
|
||||
</Linker>
|
||||
<Unit filename="..\AI_Base.h" />
|
||||
<Unit filename="..\AdventureMapButton.cpp" />
|
||||
<Unit filename="..\AdventureMapButton.h" />
|
||||
<Unit filename="..\CAdvmapInterface.cpp" />
|
||||
<Unit filename="..\CAdvmapInterface.h" />
|
||||
<Unit filename="..\CBattleInterface.cpp" />
|
||||
<Unit filename="..\CBattleInterface.h" />
|
||||
<Unit filename="..\CCallback.cpp" />
|
||||
<Unit filename="..\CCallback.h" />
|
||||
<Unit filename="..\CCastleInterface.cpp" />
|
||||
<Unit filename="..\CCastleInterface.h" />
|
||||
<Unit filename="..\CCursorHandler.cpp" />
|
||||
<Unit filename="..\CCursorHandler.h" />
|
||||
<Unit filename="..\CGameInfo.cpp" />
|
||||
<Unit filename="..\CGameInfo.h" />
|
||||
<Unit filename="..\CGameInterface.cpp" />
|
||||
<Unit filename="..\CGameInterface.h" />
|
||||
<Unit filename="..\CHeroWindow.cpp" />
|
||||
<Unit filename="..\CHeroWindow.h" />
|
||||
<Unit filename="..\CMT.cpp" />
|
||||
<Unit filename="..\CMessage.cpp" />
|
||||
<Unit filename="..\CMessage.h" />
|
||||
<Unit filename="..\CPathfinder.cpp" />
|
||||
<Unit filename="..\CPathfinder.h" />
|
||||
<Unit filename="..\CPlayerInterface.cpp" />
|
||||
<Unit filename="..\CPlayerInterface.h" />
|
||||
<Unit filename="..\CPreGame.cpp" />
|
||||
<Unit filename="..\CPreGame.h" />
|
||||
<Unit filename="..\CThreadHelper.cpp" />
|
||||
<Unit filename="..\CThreadHelper.h" />
|
||||
<Unit filename="..\ChangeLog" />
|
||||
<Unit filename="..\SDL_Extensions.cpp" />
|
||||
<Unit filename="..\SDL_Extensions.h" />
|
||||
<Unit filename="..\SDL_framerate.cpp" />
|
||||
<Unit filename="..\SDL_framerate.h" />
|
||||
<Unit filename="..\StartInfo.h" />
|
||||
<Unit filename="CBitmapHandler.cpp" />
|
||||
<Unit filename="CBitmapHandler.h" />
|
||||
<Unit filename="CConfigHandler.cpp" />
|
||||
<Unit filename="CConfigHandler.h" />
|
||||
<Unit filename="CCreatureAnimation.cpp" />
|
||||
<Unit filename="CCreatureAnimation.h" />
|
||||
<Unit filename="CSpellWindow.cpp" />
|
||||
<Unit filename="CSpellWindow.h" />
|
||||
<Unit filename="Client.cpp" />
|
||||
<Unit filename="Client.h" />
|
||||
<Unit filename="FunctionList.h" />
|
||||
<Unit filename="Graphics.cpp" />
|
||||
<Unit filename="Graphics.h" />
|
||||
<Unit filename="..\global.h" />
|
||||
<Unit filename="..\hch\CAbilityHandler.cpp" />
|
||||
<Unit filename="..\hch\CAbilityHandler.h" />
|
||||
<Unit filename="..\hch\CAmbarCendamo.h" />
|
||||
<Unit filename="..\hch\CArtHandler.h" />
|
||||
<Unit filename="..\hch\CBuildingHandler.h" />
|
||||
<Unit filename="..\hch\CDefHandler.cpp" />
|
||||
<Unit filename="..\hch\CDefHandler.h" />
|
||||
<Unit filename="..\hch\CHeroHandler.h" />
|
||||
<Unit filename="..\hch\CMusicHandler.cpp" />
|
||||
<Unit filename="..\hch\CMusicHandler.h" />
|
||||
<Unit filename="..\hch\CObjectHandler.h" />
|
||||
<Unit filename="..\hch\CSndHandler.cpp" />
|
||||
<Unit filename="..\hch\CSndHandler.h" />
|
||||
<Unit filename="..\int3.h" />
|
||||
<Unit filename="..\map.h" />
|
||||
<Unit filename="..\mapHandler.cpp" />
|
||||
<Unit filename="..\mapHandler.h" />
|
||||
<Unit filename="..\nodrze.h" />
|
||||
<Unit filename="..\stdafx.h" />
|
||||
<Unit filename="..\timeHandler.h" />
|
||||
<Extensions>
|
||||
<code_completion />
|
||||
<envvars />
|
||||
<debugger />
|
||||
<lib_finder disable_auto="1" />
|
||||
</Extensions>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
111
lib/VCMI_lib.cbp
Normal file
111
lib/VCMI_lib.cbp
Normal file
@ -0,0 +1,111 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="Lib" />
|
||||
<Option platforms="Windows;" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Debug Win32">
|
||||
<Option platforms="Windows;" />
|
||||
<Option output="..\..\..\..\Install\Heroes3\VCMI_lib" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="..\..\..\..\Install\Heroes3" />
|
||||
<Option object_output="Debug Win32" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
<Option createStaticLib="1" />
|
||||
<Compiler>
|
||||
<Add option="-g" />
|
||||
<Add option="-D_DEBUG" />
|
||||
</Compiler>
|
||||
</Target>
|
||||
<Target title="Release Win32">
|
||||
<Option platforms="Windows;" />
|
||||
<Option output="..\..\..\..\Install\Heroes3\VCMI_lib" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="..\..\..\..\Install\Heroes3" />
|
||||
<Option object_output="Release Win32" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
<Option createStaticLib="1" />
|
||||
<Compiler>
|
||||
<Add option="-fexpensive-optimizations" />
|
||||
<Add option="-Os" />
|
||||
<Add option="-O3" />
|
||||
<Add option="-O2" />
|
||||
<Add option="-O1" />
|
||||
<Add option="-O" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
</Linker>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-std=c++98" />
|
||||
<Add option="-Wfatal-errors" />
|
||||
<Add option="-Wextra" />
|
||||
<Add option="-D_WIN32" />
|
||||
<Add option="-D_WIN32_WINNT" />
|
||||
<Add directory="$(#boost.include)" />
|
||||
<Add directory="$(#sdl.include)" />
|
||||
<Add directory="$(#zlib.include)" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-lzlib1" />
|
||||
<Add option="-llibboost_thread-mgw43-mt-1_37" />
|
||||
<Add option="-llibboost_system-mgw43-mt-1_37" />
|
||||
<Add option="-llibboost_filesystem-mgw43-mt-1_37" />
|
||||
<Add option="-lwsock32" />
|
||||
<Add option="-lws2_32" />
|
||||
<Add library="..\..\..\mingw\lib\libws2_32.a" />
|
||||
<Add directory="$(#boost.lib)" />
|
||||
<Add directory="$(#sdl.lib)" />
|
||||
<Add directory="$(#zlib.lib)" />
|
||||
</Linker>
|
||||
<Unit filename="..\CConsoleHandler.cpp" />
|
||||
<Unit filename="..\CConsoleHandler.h" />
|
||||
<Unit filename="..\CGameState.cpp" />
|
||||
<Unit filename="..\CGameState.h" />
|
||||
<Unit filename="..\hch\CArtHandler.cpp" />
|
||||
<Unit filename="..\hch\CArtHandler.h" />
|
||||
<Unit filename="..\hch\CBuildingHandler.cpp" />
|
||||
<Unit filename="..\hch\CBuildingHandler.h" />
|
||||
<Unit filename="..\hch\CCreatureHandler.cpp" />
|
||||
<Unit filename="..\hch\CCreatureHandler.h" />
|
||||
<Unit filename="..\hch\CDefObjInfoHandler.cpp" />
|
||||
<Unit filename="..\hch\CDefObjInfoHandler.h" />
|
||||
<Unit filename="..\hch\CGeneralTextHandler.cpp" />
|
||||
<Unit filename="..\hch\CGeneralTextHandler.h" />
|
||||
<Unit filename="..\hch\CHeroHandler.cpp" />
|
||||
<Unit filename="..\hch\CHeroHandler.h" />
|
||||
<Unit filename="..\hch\CLodHandler.cpp" />
|
||||
<Unit filename="..\hch\CLodHandler.h" />
|
||||
<Unit filename="..\hch\CObjectHandler.cpp" />
|
||||
<Unit filename="..\hch\CObjectHandler.h" />
|
||||
<Unit filename="..\hch\CSpellHandler.cpp" />
|
||||
<Unit filename="..\hch\CSpellHandler.h" />
|
||||
<Unit filename="..\hch\CTownHandler.cpp" />
|
||||
<Unit filename="..\hch\CTownHandler.h" />
|
||||
<Unit filename="BattleAction.h" />
|
||||
<Unit filename="CondSh.h" />
|
||||
<Unit filename="Connection.cpp" />
|
||||
<Unit filename="Connection.h" />
|
||||
<Unit filename="IGameCallback.cpp" />
|
||||
<Unit filename="IGameCallback.h" />
|
||||
<Unit filename="Interprocess.h" />
|
||||
<Unit filename="NetPacks.h" />
|
||||
<Unit filename="VCMI_Lib.cpp" />
|
||||
<Unit filename="VCMI_Lib.h" />
|
||||
<Unit filename="..\map.cpp" />
|
||||
<Unit filename="..\map.h" />
|
||||
<Unit filename="..\stdafx.cpp" />
|
||||
<Extensions>
|
||||
<code_completion />
|
||||
<envvars />
|
||||
<debugger />
|
||||
</Extensions>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
68
server/VCMI_server.cbp
Normal file
68
server/VCMI_server.cbp
Normal file
@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="Server" />
|
||||
<Option platforms="Windows;" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Debug Win32">
|
||||
<Option platforms="Windows;" />
|
||||
<Option output="..\..\..\..\Install\Heroes3\VCMI_server" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="..\..\..\..\Install\Heroes3" />
|
||||
<Option object_output="Debug Win32" />
|
||||
<Option type="1" />
|
||||
<Option compiler="gcc" />
|
||||
<Option use_console_runner="0" />
|
||||
<Compiler>
|
||||
<Add option="-g" />
|
||||
</Compiler>
|
||||
</Target>
|
||||
<Target title="Release Win32">
|
||||
<Option platforms="Windows;" />
|
||||
<Option output="..\..\..\..\Install\Heroes3\VCMI_server" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="..\..\..\..\Install\Heroes3" />
|
||||
<Option object_output="Release Win32" />
|
||||
<Option type="1" />
|
||||
<Option compiler="gcc" />
|
||||
<Option use_console_runner="0" />
|
||||
<Compiler>
|
||||
<Add option="-fexpensive-optimizations" />
|
||||
<Add option="-Os" />
|
||||
<Add option="-O3" />
|
||||
<Add option="-O2" />
|
||||
<Add option="-O1" />
|
||||
<Add option="-O" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
</Linker>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-D_WIN32" />
|
||||
<Add directory="$(#zlib.include)" />
|
||||
<Add directory="$(#boost.include)" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-llibboost_thread-mgw43-mt-1_37" />
|
||||
<Add option="-llibboost_system-mgw43-mt-1_37" />
|
||||
<Add option="-llibboost_filesystem-mgw43-mt-1_37" />
|
||||
<Add option="-lwsock32" />
|
||||
<Add option="-lws2_32" />
|
||||
<Add library="..\..\..\..\Install\Heroes3\libVCMI_lib.a" />
|
||||
<Add directory="$(#zlib.lib)" />
|
||||
<Add directory="$(#boost.lib)" />
|
||||
</Linker>
|
||||
<Unit filename="CGameHandler.cpp" />
|
||||
<Unit filename="CGameHandler.h" />
|
||||
<Unit filename="CVCMIServer.cpp" />
|
||||
<Unit filename="CVCMIServer.h" />
|
||||
<Extensions>
|
||||
<code_completion />
|
||||
<envvars />
|
||||
<debugger />
|
||||
</Extensions>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
9
vcmi.workspace
Normal file
9
vcmi.workspace
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_workspace_file>
|
||||
<Workspace title="VCMI">
|
||||
<Project filename="client\VCMI_client.cbp" />
|
||||
<Project filename="server\VCMI_server.cbp" />
|
||||
<Project filename="lib\VCMI_lib.cbp" active="1" />
|
||||
<Project filename="AI\GeniusAI\genius.cbp" />
|
||||
</Workspace>
|
||||
</CodeBlocks_workspace_file>
|
Loading…
Reference in New Issue
Block a user