- put ALIGN macro into q_shared.h

- yet another alignment fix for botlib
This commit is contained in:
Ludwig Nussel 2005-11-05 19:06:10 +00:00
parent 81c1b3128b
commit dfe20a177c
3 changed files with 7 additions and 15 deletions

View file

@ -521,7 +521,7 @@ void AAS_CalculateAreaTravelTimes(void)
// //
size += settings->numreachableareas * sizeof(unsigned short *); size += settings->numreachableareas * sizeof(unsigned short *);
// //
size += settings->numreachableareas * revreach->numlinks * sizeof(unsigned short); size += settings->numreachableareas * ALIGN(revreach->numlinks) * sizeof(unsigned short);
} //end for } //end for
//allocate memory for the area travel times //allocate memory for the area travel times
ptr = (char *) GetClearedMemory(size); ptr = (char *) GetClearedMemory(size);
@ -541,7 +541,7 @@ void AAS_CalculateAreaTravelTimes(void)
for (l = 0; l < settings->numreachableareas; l++) for (l = 0; l < settings->numreachableareas; l++)
{ {
aasworld.areatraveltimes[i][l] = (unsigned short *) ptr; aasworld.areatraveltimes[i][l] = (unsigned short *) ptr;
ptr += revreach->numlinks * sizeof(unsigned short); ptr += ALIGN(revreach->numlinks) * sizeof(unsigned short);
//reachability link //reachability link
reach = &aasworld.reachability[settings->firstreachablearea + l]; reach = &aasworld.reachability[settings->firstreachablearea + l];
// //

View file

@ -20,15 +20,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
=========================================================================== ===========================================================================
*/ */
#if 1
#define ALIGN(x) \
do { \
x = (x+sizeof(void*)-1) & ~(sizeof(void*)-1L); \
} while(0)
#else
#define ALIGN(x)
#endif
/***************************************************************************** /*****************************************************************************
* name: be_ai_chat.c * name: be_ai_chat.c
* *
@ -699,7 +690,7 @@ bot_synonymlist_t *BotLoadSynonyms(char *filename)
return NULL; return NULL;
} //end if } //end if
len = strlen(token.string) + 1; len = strlen(token.string) + 1;
ALIGN(len); len = ALIGN(len);
size += sizeof(bot_synonym_t) + len; size += sizeof(bot_synonym_t) + len;
if (pass) if (pass)
{ {
@ -998,7 +989,7 @@ bot_randomlist_t *BotLoadRandomStrings(char *filename)
return NULL; return NULL;
} //end if } //end if
len = strlen(token.string) + 1; len = strlen(token.string) + 1;
ALIGN(len); len = ALIGN(len);
size += sizeof(bot_randomlist_t) + len; size += sizeof(bot_randomlist_t) + len;
if (pass) if (pass)
{ {
@ -1029,7 +1020,7 @@ bot_randomlist_t *BotLoadRandomStrings(char *filename)
return NULL; return NULL;
} //end if } //end if
len = strlen(chatmessagestring) + 1; len = strlen(chatmessagestring) + 1;
ALIGN(len); len = ALIGN(len);
size += sizeof(bot_randomstring_t) + len; size += sizeof(bot_randomstring_t) + len;
if (pass) if (pass)
{ {
@ -2132,7 +2123,7 @@ bot_chat_t *BotLoadInitialChat(char *chatfile, char *chatname)
return NULL; return NULL;
} //end if } //end if
len = strlen(chatmessagestring) + 1; len = strlen(chatmessagestring) + 1;
ALIGN(len); len = ALIGN(len);
if (pass) if (pass)
{ {
chatmessage = (bot_chatmessage_t *) ptr; chatmessage = (bot_chatmessage_t *) ptr;

View file

@ -111,6 +111,7 @@ typedef int sfxHandle_t;
typedef int fileHandle_t; typedef int fileHandle_t;
typedef int clipHandle_t; typedef int clipHandle_t;
#define ALIGN(x) ((x+sizeof(long)-1) & ~(sizeof(long)-1))
#ifndef NULL #ifndef NULL
#define NULL ((void *)0) #define NULL ((void *)0)