Include/declaration cleanup for src/message.c/h.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@10308 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
6e71ef8c68
commit
7bf36e0ffc
130
src/message.c
130
src/message.c
|
@ -23,26 +23,18 @@
|
|||
* Functions for the messages shown in the Intelligence Map
|
||||
*
|
||||
*/
|
||||
#include <string.h>
|
||||
|
||||
#include "lib/framework/frame.h"
|
||||
#include "lib/framework/strres.h"
|
||||
#include "lib/framework/frameresource.h"
|
||||
#include "lib/framework/lexer_input.h"
|
||||
#include "message.h"
|
||||
#include "stats.h"
|
||||
#include "text.h"
|
||||
#include "console.h"
|
||||
#include "lib/framework/strres.h"
|
||||
#include "lib/sound/audio.h"
|
||||
#include "lib/sound/audio_id.h"
|
||||
#include "hci.h"
|
||||
#include "lib/ivis_common/piedef.h"
|
||||
#include "objmem.h"
|
||||
#include "map.h"
|
||||
#include "message_parser.tab.h"
|
||||
#include "messagely.h"
|
||||
|
||||
#include "multiplay.h"
|
||||
#include "console.h"
|
||||
#include "hci.h"
|
||||
#include "messagely.h"
|
||||
#include "stats.h"
|
||||
#include "text.h"
|
||||
|
||||
//array of pointers for the view data
|
||||
static VIEWDATA_LIST *apsViewData;
|
||||
|
@ -62,10 +54,6 @@ PROXIMITY_DISPLAY *apsProxDisp[MAX_PLAYERS];
|
|||
/* The IMD to use for the proximity messages */
|
||||
iIMDShape *pProximityMsgIMD;
|
||||
|
||||
//function declarations
|
||||
static void addProximityDisplay(MESSAGE *psMessage, BOOL proxPos, UDWORD player);
|
||||
static void removeProxDisp(MESSAGE *psMessage, UDWORD player);
|
||||
static void checkMessages(MSG_VIEWDATA *psViewData);
|
||||
|
||||
/* Creating a new message
|
||||
* new is a pointer to a pointer to the new message
|
||||
|
@ -284,31 +272,6 @@ MESSAGE * addBeaconMessage(MESSAGE_TYPE msgType, BOOL proxPos, UDWORD player)
|
|||
return psBeaconMsgToAdd;
|
||||
}
|
||||
|
||||
/*Add a message to the list */
|
||||
MESSAGE * addMessage(MESSAGE_TYPE msgType, BOOL proxPos, UDWORD player)
|
||||
{
|
||||
//first create a message of the required type
|
||||
MESSAGE* psMsgToAdd = createMessage(msgType, player);
|
||||
|
||||
debug(LOG_MSG, "adding message for player %d, type is %d, proximity is %d", player, msgType, proxPos);
|
||||
|
||||
ASSERT(psMsgToAdd, "createMessage failed");
|
||||
if (!psMsgToAdd)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
//then add to the players' list
|
||||
addMessageToList(apsMessages, psMsgToAdd, player);
|
||||
|
||||
//add a proximity display
|
||||
if (msgType == MSG_PROXIMITY)
|
||||
{
|
||||
addProximityDisplay(psMsgToAdd, proxPos, player);
|
||||
}
|
||||
|
||||
return psMsgToAdd;
|
||||
}
|
||||
|
||||
/* adds a proximity display - holds variables that enable the message to be
|
||||
displayed in the Intelligence Screen*/
|
||||
static void addProximityDisplay(MESSAGE *psMessage, BOOL proxPos, UDWORD player)
|
||||
|
@ -360,22 +323,33 @@ static void addProximityDisplay(MESSAGE *psMessage, BOOL proxPos, UDWORD player)
|
|||
}
|
||||
}
|
||||
|
||||
/*remove a message */
|
||||
void removeMessage(MESSAGE *psDel, UDWORD player)
|
||||
/*Add a message to the list */
|
||||
MESSAGE * addMessage(MESSAGE_TYPE msgType, BOOL proxPos, UDWORD player)
|
||||
{
|
||||
ASSERT_OR_RETURN( , player < MAX_PLAYERS, "Bad player");
|
||||
ASSERT_OR_RETURN( , psDel != NULL, "Bad message");
|
||||
debug(LOG_MSG, "removing message for player %d", player);
|
||||
//first create a message of the required type
|
||||
MESSAGE* psMsgToAdd = createMessage(msgType, player);
|
||||
|
||||
if (psDel->type == MSG_PROXIMITY)
|
||||
debug(LOG_MSG, "adding message for player %d, type is %d, proximity is %d", player, msgType, proxPos);
|
||||
|
||||
ASSERT(psMsgToAdd, "createMessage failed");
|
||||
if (!psMsgToAdd)
|
||||
{
|
||||
removeProxDisp(psDel, player);
|
||||
return NULL;
|
||||
}
|
||||
removeMessageFromList(apsMessages, psDel, player);
|
||||
//then add to the players' list
|
||||
addMessageToList(apsMessages, psMsgToAdd, player);
|
||||
|
||||
//add a proximity display
|
||||
if (msgType == MSG_PROXIMITY)
|
||||
{
|
||||
addProximityDisplay(psMsgToAdd, proxPos, player);
|
||||
}
|
||||
|
||||
return psMsgToAdd;
|
||||
}
|
||||
|
||||
/* remove a proximity display */
|
||||
void removeProxDisp(MESSAGE *psMessage, UDWORD player)
|
||||
static void removeProxDisp(MESSAGE *psMessage, UDWORD player)
|
||||
{
|
||||
PROXIMITY_DISPLAY *psCurr, *psPrev;
|
||||
|
||||
|
@ -415,6 +389,20 @@ void removeProxDisp(MESSAGE *psMessage, UDWORD player)
|
|||
}
|
||||
}
|
||||
|
||||
/*remove a message */
|
||||
void removeMessage(MESSAGE *psDel, UDWORD player)
|
||||
{
|
||||
ASSERT_OR_RETURN( , player < MAX_PLAYERS, "Bad player");
|
||||
ASSERT_OR_RETURN( , psDel != NULL, "Bad message");
|
||||
debug(LOG_MSG, "removing message for player %d", player);
|
||||
|
||||
if (psDel->type == MSG_PROXIMITY)
|
||||
{
|
||||
removeProxDisp(psDel, player);
|
||||
}
|
||||
removeMessageFromList(apsMessages, psDel, player);
|
||||
}
|
||||
|
||||
/* Remove all Messages*/
|
||||
void freeMessages(void)
|
||||
{
|
||||
|
@ -869,6 +857,25 @@ BOOL messageShutdown(void)
|
|||
return true;
|
||||
}
|
||||
|
||||
//check for any messages using this viewdata and remove them
|
||||
static void checkMessages(MSG_VIEWDATA *psViewData)
|
||||
{
|
||||
MESSAGE *psCurr, *psNext;
|
||||
UDWORD i;
|
||||
|
||||
for (i=0; i < MAX_PLAYERS; i++)
|
||||
{
|
||||
for (psCurr = apsMessages[i]; psCurr != NULL; psCurr = psNext)
|
||||
{
|
||||
psNext = psCurr->psNext;
|
||||
if (psCurr->pViewData == psViewData)
|
||||
{
|
||||
removeMessage(psCurr, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Release the viewdata memory */
|
||||
void viewDataShutDown(VIEWDATA *psViewData)
|
||||
{
|
||||
|
@ -1013,6 +1020,7 @@ void displayProximityMessage(PROXIMITY_DISPLAY *psProxDisp)
|
|||
psProxDisp->psMessage->read = true;
|
||||
}
|
||||
|
||||
// NOTE: Unused! PROXIMITY_DISPLAY * getProximityDisplay(MESSAGE *psMessage)
|
||||
PROXIMITY_DISPLAY * getProximityDisplay(MESSAGE *psMessage)
|
||||
{
|
||||
PROXIMITY_DISPLAY *psCurr;
|
||||
|
@ -1034,21 +1042,3 @@ PROXIMITY_DISPLAY * getProximityDisplay(MESSAGE *psMessage)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
//check for any messages using this viewdata and remove them
|
||||
void checkMessages(MSG_VIEWDATA *psViewData)
|
||||
{
|
||||
MESSAGE *psCurr, *psNext;
|
||||
UDWORD i;
|
||||
|
||||
for (i=0; i < MAX_PLAYERS; i++)
|
||||
{
|
||||
for (psCurr = apsMessages[i]; psCurr != NULL; psCurr = psNext)
|
||||
{
|
||||
psNext = psCurr->psNext;
|
||||
if (psCurr->pViewData == psViewData)
|
||||
{
|
||||
removeMessage(psCurr, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,52 +44,53 @@ extern iIMDShape *pProximityMsgIMD;
|
|||
extern PROXIMITY_DISPLAY *apsProxDisp[MAX_PLAYERS];
|
||||
|
||||
/** Allocates the viewdata heap. */
|
||||
extern BOOL initViewData(void);
|
||||
BOOL initViewData(void);
|
||||
|
||||
/** Initialise the message heaps. */
|
||||
extern BOOL initMessage(void);
|
||||
BOOL initMessage(void);
|
||||
|
||||
/** Release the message heaps. */
|
||||
extern BOOL messageShutdown(void);
|
||||
BOOL messageShutdown(void);
|
||||
|
||||
/** Add a message to the list. */
|
||||
extern MESSAGE * addMessage(MESSAGE_TYPE msgType, BOOL proxPos, UDWORD player);
|
||||
MESSAGE * addMessage(MESSAGE_TYPE msgType, BOOL proxPos, UDWORD player);
|
||||
|
||||
/** Add a beacon message to the list. */
|
||||
extern MESSAGE * addBeaconMessage(MESSAGE_TYPE msgType, BOOL proxPos, UDWORD player);
|
||||
MESSAGE * addBeaconMessage(MESSAGE_TYPE msgType, BOOL proxPos, UDWORD player);
|
||||
|
||||
/** Remove a message. */
|
||||
extern void removeMessage(MESSAGE *psDel, UDWORD player);
|
||||
void removeMessage(MESSAGE *psDel, UDWORD player);
|
||||
|
||||
/** Remove all Messages. */
|
||||
extern void freeMessages(void);
|
||||
void freeMessages(void);
|
||||
|
||||
/** Removes all the proximity displays. */
|
||||
extern void releaseAllProxDisp(void);
|
||||
void releaseAllProxDisp(void);
|
||||
|
||||
extern bool addToViewDataList(VIEWDATA* psViewData, unsigned int numData);
|
||||
bool addToViewDataList(VIEWDATA* psViewData, unsigned int numData);
|
||||
|
||||
/** Load the view data for the messages from the file exported from the world editor. */
|
||||
extern VIEWDATA* loadViewData(const char *pViewMsgData, UDWORD bufferSize);
|
||||
VIEWDATA* loadViewData(const char *pViewMsgData, UDWORD bufferSize);
|
||||
|
||||
extern VIEWDATA* loadResearchViewData(const char* fileName);
|
||||
VIEWDATA* loadResearchViewData(const char* fileName);
|
||||
|
||||
/** Get the view data that contains the text message pointer passed in. */
|
||||
extern VIEWDATA* getViewData(const char *pTextMsg);
|
||||
VIEWDATA* getViewData(const char *pTextMsg);
|
||||
|
||||
/** Release the viewdata memory. */
|
||||
extern void viewDataShutDown(VIEWDATA *psViewData);
|
||||
void viewDataShutDown(VIEWDATA *psViewData);
|
||||
|
||||
extern PROXIMITY_DISPLAY * getProximityDisplay(MESSAGE *psMessage);
|
||||
// Unused
|
||||
PROXIMITY_DISPLAY * getProximityDisplay(MESSAGE *psMessage);
|
||||
|
||||
/** Looks through the players list of messages to find one with the same viewData
|
||||
* pointer and which is the same type of message - used in scriptFuncs. */
|
||||
extern MESSAGE* findMessage(MSG_VIEWDATA *pViewdata, MESSAGE_TYPE type, UDWORD player);
|
||||
MESSAGE* findMessage(MSG_VIEWDATA *pViewdata, MESSAGE_TYPE type, UDWORD player);
|
||||
|
||||
/** 'Displays' a proximity display. */
|
||||
extern void displayProximityMessage(PROXIMITY_DISPLAY *psProxDisp);
|
||||
void displayProximityMessage(PROXIMITY_DISPLAY *psProxDisp);
|
||||
|
||||
extern BOOL messageInitVars(void);
|
||||
BOOL messageInitVars(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue