Skip to content

Commit

Permalink
Fix crash on placing beacons.
Browse files Browse the repository at this point in the history
  • Loading branch information
perim committed Jan 7, 2012
1 parent 2a8d1da commit 3462f7b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
14 changes: 13 additions & 1 deletion src/message.cpp
Expand Up @@ -739,7 +739,19 @@ VIEWDATA* loadResearchViewData(const char* fileName)
/* Get the view data identified by the name */
VIEWDATA *getViewData(const char *pName)
{
return apsViewData.value(pName);
VIEWDATA *ptr = apsViewData.value(pName);
if (!ptr) // dump for debugging
{
QMap<QString, VIEWDATA *>::iterator iter = apsViewData.begin();
while (iter != apsViewData.constEnd())
{
VIEWDATA *psViewData = iter.value();
debug(LOG_ERROR, "\t%s", psViewData->pName);
++iter;
}
}
ASSERT(ptr, "Message %s not found, those known listed above", pName);
return ptr;
}

/* Release the message heaps */
Expand Down
11 changes: 2 additions & 9 deletions src/scriptfuncs.cpp
Expand Up @@ -9413,21 +9413,14 @@ VIEWDATA *CreateBeaconViewData(SDWORD sender, UDWORD LocX, UDWORD LocY)
char name[MAXSTRLEN];

//allocate message space
psViewData = (VIEWDATA *)malloc(sizeof(VIEWDATA));
if (psViewData == NULL)
{
ASSERT(false, "prepairHelpViewData() - Unable to allocate memory for viewdata");
return NULL;
}

memset(psViewData, 0, sizeof(VIEWDATA));
psViewData = new VIEWDATA;

//store name
sprintf(name, _("Beacon %d"), sender);
psViewData->pName = name;

//store text message, hardcoded for now
psViewData->textMsg.push_back(getPlayerName(sender));
psViewData->textMsg.push_back(QString::fromUtf8(getPlayerName(sender)));

//store message type
psViewData->type = VIEW_BEACON;
Expand Down

0 comments on commit 3462f7b

Please sign in to comment.