1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-07-03 06:24:32 +00:00

Small fix for non-MSVC

This commit is contained in:
fgenesis 2012-06-01 18:43:41 +00:00
parent b30d124d50
commit cd18ef2a43
2 changed files with 56 additions and 55 deletions

View file

@ -123,7 +123,7 @@ IngredientData *Continuity::getIngredientHeldByName(const std::string &name) con
} }
IngredientType Continuity::getIngredientTypeFromName(const std::string &name) const IngredientType Continuity::getIngredientTypeFromName(const std::string &name) const
{ {
if (name == "Meat") if (name == "Meat")
return IT_MEAT; return IT_MEAT;
else if (name == "Oil") else if (name == "Oil")
@ -254,7 +254,7 @@ void Continuity::initFoodSort()
sortByType.push_back(FoodSortOrder(IT_ICECHUNK)); sortByType.push_back(FoodSortOrder(IT_ICECHUNK));
sortByType.push_back(FoodSortOrder(IT_BONE)); sortByType.push_back(FoodSortOrder(IT_BONE));
sortByType.push_back(FoodSortOrder(IT_FOOD)); sortByType.push_back(FoodSortOrder(IT_FOOD));
sortByHeal.clear(); sortByHeal.clear();
sortByHeal.push_back(FoodSortOrder(IT_NONE, IET_MAXHP)); sortByHeal.push_back(FoodSortOrder(IT_NONE, IET_MAXHP));
for (int i = 10; i >= -10; i--) for (int i = 10; i >= -10; i--)
@ -264,7 +264,7 @@ void Continuity::initFoodSort()
} }
sortByHeal.push_back(FoodSortOrder(IT_NONE, IET_DEFENSE)); sortByHeal.push_back(FoodSortOrder(IT_NONE, IET_DEFENSE));
sortByHeal.push_back(FoodSortOrder(IT_NONE, IET_SPEED)); sortByHeal.push_back(FoodSortOrder(IT_NONE, IET_SPEED));
sortByIngredients.clear(); sortByIngredients.clear();
for (int i = 0; i < IT_INGREDIENTSEND; i++) for (int i = 0; i < IT_INGREDIENTSEND; i++)
{ {
@ -275,9 +275,9 @@ void Continuity::initFoodSort()
void Continuity::sortFood() void Continuity::sortFood()
{ {
std::vector<FoodSortOrder> sortOrder; std::vector<FoodSortOrder> sortOrder;
bool doSort = true; bool doSort = true;
switch (dsq->continuity.foodSortType) switch (dsq->continuity.foodSortType)
{ {
/* /*
@ -302,7 +302,7 @@ void Continuity::sortFood()
if (doSort) if (doSort)
{ {
std::vector<IngredientData*> sort; std::vector<IngredientData*> sort;
@ -482,7 +482,7 @@ std::string Continuity::getIEString(IngredientData *data, int i)
IngredientEffectType useType = fx.type; IngredientEffectType useType = fx.type;
std::ostringstream os; std::ostringstream os;
switch(useType) switch(useType)
{ {
case IET_HP: case IET_HP:
@ -519,7 +519,7 @@ std::string Continuity::getIEString(IngredientData *data, int i)
case IET_REGEN: case IET_REGEN:
os << dsq->continuity.stringBank.get(206) << " " << fx.magnitude; os << dsq->continuity.stringBank.get(206) << " " << fx.magnitude;
return os.str(); return os.str();
break; break;
case IET_TRIP: case IET_TRIP:
return dsq->continuity.stringBank.get(207); return dsq->continuity.stringBank.get(207);
break; break;
@ -657,7 +657,7 @@ void Continuity::applyIngredientEffects(IngredientData *data)
{ {
debugLog("ingredient effect: defense"); debugLog("ingredient effect: defense");
if (fx.magnitude <= 1) if (fx.magnitude <= 1)
dsq->continuity.setDefenseMultiplier(0.75, defenseTime); dsq->continuity.setDefenseMultiplier(0.75, defenseTime);
else if (fx.magnitude == 2) else if (fx.magnitude == 2)
@ -674,7 +674,7 @@ void Continuity::applyIngredientEffects(IngredientData *data)
break; break;
case IET_SPEED: case IET_SPEED:
{ {
dsq->continuity.setSpeedMultiplier(1.0f + fx.magnitude*0.5f, speedTime); dsq->continuity.setSpeedMultiplier(1.0f + fx.magnitude*0.5f, speedTime);
debugLog("ingredient effect: speed"); debugLog("ingredient effect: speed");
@ -826,7 +826,7 @@ void Continuity::applyIngredientEffects(IngredientData *data)
break; break;
case IET_LI: case IET_LI:
{ {
// this should do nothing, its just here to catch the ingredient effect so it doesn't // this should do nothing, its just here to catch the ingredient effect so it doesn't
// give the "default:" error message // give the "default:" error message
// this item should only affect li if naija drops it and li eats it. // this item should only affect li if naija drops it and li eats it.
} }
@ -1154,7 +1154,7 @@ void Continuity::loadIntoSongBank(const std::string &file)
s.notes.push_back(note); s.notes.push_back(note);
} }
} }
if (song->Attribute("script")) if (song->Attribute("script"))
{ {
s.script = atoi(song->Attribute("script")); s.script = atoi(song->Attribute("script"));
@ -1843,7 +1843,7 @@ void Continuity::update(float dt)
d.useTimer = 0; d.useTimer = 0;
d.damageType = DT_ENEMY_ACTIVEPOISON; d.damageType = DT_ENEMY_ACTIVEPOISON;
dsq->game->avatar->damage(d); dsq->game->avatar->damage(d);
dsq->spawnParticleEffect("PoisonBubbles", dsq->game->avatar->position); dsq->spawnParticleEffect("PoisonBubbles", dsq->game->avatar->position);
} }
} }
@ -2265,7 +2265,7 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
dsq->user.save(); dsq->user.save();
TiXmlDocument doc; TiXmlDocument doc;
TiXmlElement version("Version"); TiXmlElement version("Version");
{ {
version.SetAttribute("major", VERSION_MAJOR); version.SetAttribute("major", VERSION_MAJOR);
@ -2304,14 +2304,14 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
{ {
os << (*i).name << " " << (*i).pos.x << " " << (*i).pos.y << " "; os << (*i).name << " " << (*i).pos.x << " " << (*i).pos.y << " ";
os << (*i).canMove << " "; os << (*i).canMove << " ";
hasUserString = !(*i).userString.empty(); hasUserString = !(*i).userString.empty();
os << hasUserString << " "; os << hasUserString << " ";
if (hasUserString) if (hasUserString)
os << spacesToUnderscores((*i).userString) << " "; os << spacesToUnderscores((*i).userString) << " ";
/* /*
std::ostringstream os2; std::ostringstream os2;
os2 << "Saving a Gem called [" << (*i).name << "] with userString [" << (*i).userString << "] pos (" << (*i).pos.x << ", " << (*i).pos.y << ")\n"; os2 << "Saving a Gem called [" << (*i).name << "] with userString [" << (*i).userString << "] pos (" << (*i).pos.x << ", " << (*i).pos.y << ")\n";
@ -2361,7 +2361,7 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
os << dsq->continuity.voiceOversPlayed[i] << " "; os << dsq->continuity.voiceOversPlayed[i] << " ";
} }
vox.SetAttribute("v", os.str()); vox.SetAttribute("v", os.str());
} }
doc.InsertEndChild(vox); doc.InsertEndChild(vox);
@ -2510,9 +2510,16 @@ void Continuity::loadFileData(int slot, TiXmlDocument &doc)
{ {
unsigned long size = 0; unsigned long size = 0;
char *buf = readCompressedFile(teh_file, &size); char *buf = readCompressedFile(teh_file, &size);
if (!buf || !doc.LoadMem(buf, size)) if (!buf)
errorLog("Failed to load save data: " + teh_file); {
return; errorLog("Failed to decompress save file: " + teh_file);
return;
}
if (!doc.LoadMem(buf, size))
{
errorLog("Failed to load save data: " + teh_file + " -- Error: " + doc.ErrorDesc());
return;
}
} }
teh_file = dsq->continuity.getSaveFileName(slot, "xml"); teh_file = dsq->continuity.getSaveFileName(slot, "xml");
@ -2652,18 +2659,18 @@ void Continuity::loadFile(int slot)
while (is >> g.name) while (is >> g.name)
{ {
hasUserString=false; hasUserString=false;
is >> g.pos.x >> g.pos.y; is >> g.pos.x >> g.pos.y;
is >> g.canMove; is >> g.canMove;
is >> hasUserString; is >> hasUserString;
if (hasUserString) if (hasUserString)
is >> g.userString; is >> g.userString;
std::ostringstream os; std::ostringstream os;
os << "Loading a Gem called [" << g.name << "] with userString [" << g.userString << "] pos (" << g.pos.x << ", " << g.pos.y << ")\n"; os << "Loading a Gem called [" << g.name << "] with userString [" << g.userString << "] pos (" << g.pos.x << ", " << g.pos.y << ")\n";
debugLog(os.str()); debugLog(os.str());
g.userString = underscoresToSpaces(g.userString); g.userString = underscoresToSpaces(g.userString);
this->gems.push_back(g); this->gems.push_back(g);
} }
@ -2672,39 +2679,39 @@ void Continuity::loadFile(int slot)
{ {
std::string s = gems->Attribute("c"); std::string s = gems->Attribute("c");
std::istringstream is(s); std::istringstream is(s);
int num = 0; int num = 0;
is >> num; is >> num;
bool hasUserString = false; bool hasUserString = false;
GemData g; GemData g;
std::ostringstream os; std::ostringstream os;
os << "continuity num: [" << num << "]" << std::endl; os << "continuity num: [" << num << "]" << std::endl;
os << "data: [" << s << "]" << std::endl; os << "data: [" << s << "]" << std::endl;
debugLog(os.str()); debugLog(os.str());
for (int i = 0; i < num; i++) for (int i = 0; i < num; i++)
{ {
g.pos = Vector(0,0,0); g.pos = Vector(0,0,0);
g.canMove = false; g.canMove = false;
g.userString = ""; g.userString = "";
hasUserString=false; hasUserString=false;
is >> g.name; is >> g.name;
is >> g.pos.x >> g.pos.y; is >> g.pos.x >> g.pos.y;
is >> g.canMove; is >> g.canMove;
is >> hasUserString; is >> hasUserString;
if (hasUserString) if (hasUserString)
is >> g.userString; is >> g.userString;
else else
g.userString = ""; g.userString = "";
g.userString = underscoresToSpaces(g.userString); g.userString = underscoresToSpaces(g.userString);
this->gems.push_back(g); this->gems.push_back(g);
std::ostringstream os; std::ostringstream os;
os << "Loading a Gem called [" << g.name << "] with userString [" << g.userString << "] pos (" << g.pos.x << ", " << g.pos.y << ")\n"; os << "Loading a Gem called [" << g.name << "] with userString [" << g.userString << "] pos (" << g.pos.x << ", " << g.pos.y << ")\n";
debugLog(os.str()); debugLog(os.str());
@ -2726,7 +2733,7 @@ void Continuity::loadFile(int slot)
} }
} }
#ifdef AQUARIA_BUILD_MAPVIS #ifdef AQUARIA_BUILD_MAPVIS
if (worldMap->Attribute("va") && dsq->continuity.worldMap.getNumWorldMapTiles()) if (worldMap->Attribute("va") && dsq->continuity.worldMap.getNumWorldMapTiles())
{ {
@ -2817,7 +2824,7 @@ void Continuity::loadFile(int slot)
if (startData->Attribute("rec")) if (startData->Attribute("rec"))
{ {
std::istringstream is(startData->Attribute("rec")); std::istringstream is(startData->Attribute("rec"));
for (int i = 0; i < recipes.size(); i++) for (int i = 0; i < recipes.size(); i++)
{ {
bool known = false; bool known = false;
@ -2930,10 +2937,10 @@ int Continuity::getEntityFlag(const std::string &sceneName, int id)
{ {
std::ostringstream os; std::ostringstream os;
os << sceneName << ":" << id; os << sceneName << ":" << id;
std::ostringstream os2; std::ostringstream os2;
os2 << hash(os.str()); os2 << hash(os.str());
return entityFlags[os2.str()]; return entityFlags[os2.str()];
} }
@ -2941,10 +2948,10 @@ void Continuity::setEntityFlag(const std::string &sceneName, int id, int v)
{ {
std::ostringstream os; std::ostringstream os;
os << sceneName << ":" << id; os << sceneName << ":" << id;
std::ostringstream os2; std::ostringstream os2;
os2 << hash(os.str()); os2 << hash(os.str());
entityFlags[os2.str()] = v; entityFlags[os2.str()] = v;
} }
@ -2952,10 +2959,10 @@ void Continuity::setPathFlag(Path *p, int v)
{ {
std::ostringstream os; std::ostringstream os;
os << "p:" << dsq->game->sceneName << ":" << p->nodes[0].position.x << ":" << p->nodes[0].position.y << ":" << removeSpaces(p->name); os << "p:" << dsq->game->sceneName << ":" << p->nodes[0].position.x << ":" << p->nodes[0].position.y << ":" << removeSpaces(p->name);
std::ostringstream os2; std::ostringstream os2;
os2 << hash(os.str()); os2 << hash(os.str());
entityFlags[os2.str()] = v; entityFlags[os2.str()] = v;
} }
@ -3177,7 +3184,7 @@ void Continuity::reset()
lastMenuPage = MENUPAGE_NONE; lastMenuPage = MENUPAGE_NONE;
lastOptionsMenuPage = MENUPAGE_NONE; lastOptionsMenuPage = MENUPAGE_NONE;
if (dsq->game) if (dsq->game)
{ {
dsq->game->currentMenuPage = MENUPAGE_NONE; dsq->game->currentMenuPage = MENUPAGE_NONE;
@ -3219,7 +3226,7 @@ void Continuity::reset()
worldMap.load(); worldMap.load();
ingredients.clear(); ingredients.clear();
foodSortType = 0; foodSortType = 0;
//load ingredients //load ingredients
@ -3299,7 +3306,7 @@ void Continuity::reset()
{ {
learnSong(SONG_SHIELDAURA); learnSong(SONG_SHIELDAURA);
} }
initFoodSort(); initFoodSort();
core->resetTimer(); core->resetTimer();

View file

@ -6,8 +6,6 @@
// for weird gcc/mingw hackfix below // for weird gcc/mingw hackfix below
#include <string.h> #include <string.h>
#define PRINTFAIL(s, ...) fprintf(stderr, (s "\n"), __VA_ARGS__)
DeflateCompressor::DeflateCompressor() DeflateCompressor::DeflateCompressor()
: _windowBits(-MAX_WBITS), // negative, because we want a raw deflate stream, and not zlib-wrapped : _windowBits(-MAX_WBITS), // negative, because we want a raw deflate stream, and not zlib-wrapped
@ -24,7 +22,7 @@ ZlibCompressor::ZlibCompressor()
} }
GzipCompressor::GzipCompressor() GzipCompressor::GzipCompressor()
: DeflateCompressor() : DeflateCompressor()
{ {
_windowBits = MAX_WBITS + 16; // this makes zlib wrap a minimal gzip header around the stream _windowBits = MAX_WBITS + 16; // this makes zlib wrap a minimal gzip header around the stream
_forceCompress = true; // we want this for gzip _forceCompress = true; // we want this for gzip
@ -57,18 +55,15 @@ void DeflateCompressor::compress(void* dst, uint32 *dst_size, const void* src, u
case Z_STREAM_END: case Z_STREAM_END:
break; // all good break; // all good
case Z_OK: case Z_OK:
PRINTFAIL("ZLIB: Output buffer not large enough");
*dst_size = 0; *dst_size = 0;
return; return;
default: default:
PRINTFAIL("ZLIB: Error %d", ret);
*dst_size = 0; *dst_size = 0;
return; return;
} }
if (Z_OK != deflateEnd(&c_stream)) if (Z_OK != deflateEnd(&c_stream))
{ {
PRINTFAIL("Can't compress (zlib: deflateEnd)");
*dst_size = 0; *dst_size = 0;
return; return;
} }
@ -118,7 +113,7 @@ void DeflateCompressor::Compress(uint8 level)
return; return;
char *buf; char *buf;
uint32 oldsize = size(); uint32 oldsize = size();
uint32 newsize = compressBound(oldsize) + 30; // for optional gzip header uint32 newsize = compressBound(oldsize) + 30; // for optional gzip header
@ -163,7 +158,6 @@ void DeflateCompressor::Decompress(void)
decompress((void*)target, &origsize, (const void*)contents(), size(), _windowBits); decompress((void*)target, &origsize, (const void*)contents(), size(), _windowBits);
if(origsize != rs) if(origsize != rs)
{ {
PRINTFAIL("DeflateCompressor: Inflate error! cursize=%u origsize=%u realsize=%u",size(),origsize,rs);
delete [] target; delete [] target;
return; return;
} }
@ -242,7 +236,7 @@ void GzipCompressor::Decompress(void)
rpos(size() - sizeof(uint32)); // according to RFC 1952, input size are the last 4 bytes at the end of the file, in little endian rpos(size() - sizeof(uint32)); // according to RFC 1952, input size are the last 4 bytes at the end of the file, in little endian
*this >> t; *this >> t;
_real_size = t; _real_size = t;
// !! NOTE: this fixes a gcc/mingw bug where _real_size would be set incorrectly // !! NOTE: this fixes a gcc/mingw bug where _real_size would be set incorrectly
#if __GNUC__ #if __GNUC__
char xx[20]; char xx[20];