some endian fixes

svn-id: r10056
This commit is contained in:
Max Horn 2003-09-07 01:51:15 +00:00
parent b380affbd5
commit 2fb59884f1
3 changed files with 8 additions and 8 deletions

View File

@ -33,7 +33,7 @@
#include "render.h"
#include "menu.h"
#include "d_sound.h"
#include "../sword2.h"
#include "bs2/sword2.h"
#define MENUDEEP 40 // Temporary, until menu.h is written!

View File

@ -330,10 +330,10 @@ int RunScript ( char * scriptData , char * objectData , uint32 *offset )
// FIXME: 'scriptData' and 'variables' used to be const. However,
// this code writes into 'variables' so it can not be const.
char *variables = scriptData + sizeof(int);
const char *code = scriptData + *((int *)scriptData) + sizeof(int);
uint32 noScripts = *((const int32 *)code);
const char *code = scriptData + (int)READ_LE_UINT32(scriptData) + sizeof(int);
uint32 noScripts = (int)READ_LE_UINT32(code);
if ( (*offset) < noScripts)
{ ip = ((const int *)code)[(*offset)+1];
{ ip = (int)READ_LE_UINT32((const int *)code + (*offset) + 1);
DEBUG2("Start script %d with offset %d",*offset,ip);
}
else
@ -354,7 +354,7 @@ int RunScript ( char * scriptData , char * objectData , uint32 *offset )
const int *checksumBlock = (const int *)code;
code += sizeof(int) * 3;
if (checksumBlock[0] != 12345678)
if ((int)READ_LE_UINT32(checksumBlock) != 12345678)
{
#ifdef INSIDE_LINC
AfxMessageBox(CVString("Invalid script in object %s",header->name));
@ -363,11 +363,11 @@ int RunScript ( char * scriptData , char * objectData , uint32 *offset )
#endif
return(0);
}
int codeLen = checksumBlock[1];
int codeLen = (int)READ_LE_UINT32(checksumBlock + 1);
int checksum = 0;
for (int count = 0 ; count < codeLen ; count++)
checksum += (unsigned char)code[count];
if ( checksum != checksumBlock[2] )
if ( checksum != (int)READ_LE_UINT32(checksumBlock + 2) )
{
#ifdef INSIDE_LINC
AfxMessageBox(CVString("Checksum error in script %s",header->name));

View File

@ -206,7 +206,7 @@ uint8 *FetchTextLine(uint8 *file, uint32 text_line) //Tony24Oct96
point=(uint32*) text_header+1; //point to the lookup table
return( (uint8*) (file+ *(point+text_line)) );
return( (uint8*) (file + READ_LE_UINT32(point+text_line)) );
}
//---------------------------------------------------------------
// Used for testing text & speech (see FN_I_speak in speech.cpp)