- bug fixes for load saved game (now fixes loading on windows) and corrects memory bug for loading saved games on all platforms.

This commit is contained in:
Mark Vejvoda 2012-04-04 15:36:09 +00:00
parent 6c12bfbec8
commit c1f617481e
7 changed files with 29 additions and 10 deletions

View File

@ -448,7 +448,7 @@ MainWindow::MainWindow( std::pair<string,vector<string> > unitToLoad,
std::auto_ptr<wchar_t> wstr(Ansi2WideString(appPath.c_str()));
wstring launchApp = wstring(wstr.get()) + L" \"%1\"";
DWORD len = launchApp.length() + 1;
DWORD len = (DWORD)launchApp.length() + 1;
RegSetValueEx(keyHandle, NULL, 0, REG_SZ, (PBYTE)launchApp.c_str(), len);
RegCloseKey(keyHandle);
@ -456,7 +456,7 @@ MainWindow::MainWindow( std::pair<string,vector<string> > unitToLoad,
RegCreateKeyEx(HKEY_CURRENT_USER,subKey.c_str(),0, NULL, 0, KEY_ALL_ACCESS, NULL, &keyHandle, &dwDisposition);
//Set the value.
launchApp = L"megaglest.g3d";
len = launchApp.length() + 1;
len = (DWORD)launchApp.length() + 1;
RegSetValueEx(keyHandle, NULL, 0, REG_SZ, (PBYTE)launchApp.c_str(), len);
RegCloseKey(keyHandle);

View File

@ -1663,9 +1663,22 @@ void PathFinder::loadGame(const XmlNode *rootNode) {
// Vec2i pos;
curNode->pos = Vec2i::strToVec2(nodePoolNode->getAttribute("pos")->getValue());
// Node *next;
curNode->next = &factionState.nodePool[nodePoolNode->getAttribute("next")->getIntValue()];
int nextNode = nodePoolNode->getAttribute("next")->getIntValue();
if(nextNode >= 0) {
curNode->next = &factionState.nodePool[nextNode];
}
else {
curNode->next = NULL;
}
// Node *prev;
curNode->prev = &factionState.nodePool[nodePoolNode->getAttribute("prev")->getIntValue()];
int prevNode = nodePoolNode->getAttribute("prev")->getIntValue();
if(prevNode >= 0) {
curNode->prev = &factionState.nodePool[prevNode];
}
else {
curNode->prev = NULL;
}
// float heuristic;
curNode->heuristic = nodePoolNode->getAttribute("heuristic")->getFloatValue();
// bool exploredCell;

View File

@ -260,7 +260,7 @@ void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &d
if(particleSystemNode->hasChild("child-particles")) {
const XmlNode *childrenNode= particleSystemNode->getChild("child-particles");
if(childrenNode->getAttribute("value")->getBoolValue()) {
for(int i = 0; i < childrenNode->getChildCount(); ++i) {
for(unsigned int i = 0; i < childrenNode->getChildCount(); ++i) {
const XmlNode *particleFileNode= childrenNode->getChild("particle-file",i);
string path= particleFileNode->getAttribute("path")->getRestrictedValue();
UnitParticleSystemType *unitParticleSystemType= new UnitParticleSystemType();

View File

@ -101,7 +101,7 @@ void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const strin
minRadius = 0;
}
if((minRadius == 0) && (shape == UnitParticleSystem::sConical)) {
minRadius = 0.001; // fudge it so we aren't generating particles that are exactly centred
minRadius = 0.001f; // fudge it so we aren't generating particles that are exactly centred
if(minRadius > radius)
radius = minRadius;
}
@ -175,7 +175,7 @@ void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const strin
const float delay_secs = delayNode->getAttribute("value")->getFloatValue();
if(delay_secs < 0)
throw runtime_error("particle effect delay cannot be negative");
delay = delay_secs * GameConstants::updateFps;
delay = (int)delay_secs * GameConstants::updateFps;
} else{
delay= 0;
}
@ -186,7 +186,7 @@ void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const strin
const float lifetime_secs = lifetimeNode->getAttribute("value")->getFloatValue();
if(lifetime_secs < 0 && lifetime_secs != -1)
throw runtime_error("particle effect lifetime cannot be negative (-1 means inherited from parent particle)");
lifetime = lifetime_secs * GameConstants::updateFps;
lifetime = (int)lifetime_secs * GameConstants::updateFps;
} else{
lifetime= -1; //default
}

View File

@ -1455,7 +1455,7 @@ bool SimpleDialog::show(const string &title, bool wide) {
vector<wxTextCtrl*> texts;
for (Values::iterator it = values.begin(); it != values.end(); ++it) {
int helptextpos = it->second.find_first_of('|');
size_t helptextpos = it->second.find_first_of('|');
sizer->Add(new wxStaticText(this, -1, ToUnicode(it->first)), 0, wxALL, 5);
wxTextCtrl *text = new wxTextCtrl(this, -1, ToUnicode(it->second.substr(0,helptextpos)));
if(wide) text->SetMinSize( wxSize((text->GetSize().GetWidth())*4, text->GetSize().GetHeight())); // 4 time as wide as default

View File

@ -52,6 +52,12 @@ void checkGlExtension(const char *extensionName);
void inline _assertGl(const char *file, int line, GLenum *forceErrorNumber = NULL) {
GLenum error = (forceErrorNumber != NULL ? *forceErrorNumber : glGetError());
if(error != GL_NO_ERROR) {
#ifdef _DEBUG
if(error == GL_INVALID_ENUM) {
return;
}
#endif
//if(error != GL_INVALID_ENUM) {
const char *errorString= reinterpret_cast<const char*>(gluErrorString(error));
char szBuf[4096]="";

View File

@ -133,7 +133,7 @@ int g3d2xml(FILE *infile, FILE *outfile)
uint8 textureName[NAMESIZE];
float32 *fdata;
uint32 *idata;
int ii, jj, kk;
unsigned int ii, jj, kk;
/* read in the FileHeader */
nBytes = sizeof(struct FileHeader);