Ejemplo n.º 1
0
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
//Procedure		PhraseToString
//Author		Robert Slater
//Date			Wed 27 Jan 1999
//
//Description	
//
//Inputs		
//
//Returns	
//
//------------------------------------------------------------------------------
void	MessageBuffer::PhraseToString(CString &thestring, PhraseBuffer&	thebuff)
{
	PhraseTables	thePhrase;
	ULong			count = 0;
	CString			tmpstring;

//DEADCODE RDH 04/05/99 	thestring = "";
	while (count < thebuff.phrase_count)
	{
		thePhrase = PhraseTables(thebuff.phrase_buffer[count]);

		if ((thePhrase & 0xff00) == PHRASE_USER_DEFINED)
			tmpstring = CString(_DPlay.GetPlayerMessage(thePhrase-PHRASE_USER11));
		else
		{
			if ((thePhrase & 0xff00) == PHRASE_PLAYERNAMES)
				tmpstring = CString(_DPlay.GetPlayerName(thePhrase-PHRASE_PLAYERNAME1));
			else
				tmpstring.LoadString(_Radio.PhraseToResource(thePhrase));
		}

#ifdef	CHATTERTRACE
		if (tmpstring.CompareNoCase("not defined")==0)
		{
			UWord cw=GETFPCW();
			PhraseTables	tl, lp;

			tl = PhraseTables(thebuff.master_phrase[count]);
			if (count > 0)
				lp = PhraseTables(thebuff.phrase_buffer[count-1]);

			::AfxTrace("MISSING:\t%08x\t%08x\t%08x\n",tl,thePhrase,lp);
			SETFPCW(cw);
		}
#endif

		count++;

		thestring += tmpstring;
	}

#ifdef	_PRINTSTRING_
	fprintf(debfp,"%s\n",(const char*)thestring);
#endif
}
Ejemplo n.º 2
0
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
//Procedure		AddToBuffer
//Author		Robert Slater
//Date			Tue 26 Jan 1999
//
//Description	
//
//Inputs		
//
//Returns	
//
//------------------------------------------------------------------------------
Bool	MessageBuffer::AddToBuffer(const MESSAGE_STRUC&	msg)
{
	Bool 	retval;
	SLong	index,index2;
//DeadCode RJS 20Oct00 	Bool	playerRecipient = FALSE;
	Bool	throwAway;											//RJS 02May00

	if(!ShouldHearMsg(msg,throwAway))							//RJS 02May00
		return throwAway;										//RJS 02May00

	//Block messages to dead blokes
//DEADCODE CSB 07/03/00 	if (msg.callee && msg.callee->Status.deadtime)				//RJS 05May99
//DEADCODE CSB 07/03/00 		return TRUE;											//RJS 05May99

//DEADCODE CSB 07/03/00 	if (msg.caller)
//DEADCODE CSB 07/03/00 	{
//DEADCODE CSB 07/03/00 		if (msg.caller->nationality != Manual_Pilot.ControlledAC2->nationality)
//DEADCODE CSB 07/03/00 			return TRUE;
//DEADCODE CSB 07/03/00 
//DEADCODE CSB 07/03/00 		if (msg.caller->ai.radiosilent)
//DEADCODE CSB 07/03/00 		{
//DEADCODE CSB 07/03/00 			if (msg.caller->AcIsPlayer())						//RJS 24May99
//DEADCODE CSB 07/03/00 			{
//DEADCODE CSB 07/03/00 				MESSAGE_STRUC	tmpmsg(OLDSCRIPT_SILENCE,MSG_SILENCE,NULL,msg.caller,msg.caller);
//DEADCODE CSB 07/03/00 				_Radio.TriggerMsg(tmpmsg.SetVoice(VOICE_REST));
//DEADCODE CSB 07/03/00 			}
//DEADCODE CSB 07/03/00 
//DEADCODE CSB 07/03/00 			return TRUE;									//RJS 24May99
//DEADCODE CSB 07/03/00 		}
//DEADCODE CSB 07/03/00 	}
//DEADCODE CSB 07/03/00 //DeadCode RJS 06Jul99 	else
//DEADCODE CSB 07/03/00 //DeadCode RJS 05Jul99 	{
//DEADCODE CSB 07/03/00 		if (msg.callee)
//DEADCODE CSB 07/03/00 		{
//DEADCODE CSB 07/03/00 			if (msg.callee->nationality != Manual_Pilot.ControlledAC2->nationality)
//DEADCODE CSB 07/03/00 				return TRUE;
//DEADCODE CSB 07/03/00 		}
//DEADCODE CSB 07/03/00 //DeadCode RJS 05Jul99 	}
//DEADCODE CSB 07/03/00 
//DEADCODE CSB 07/03/00 	if ((msg.callee==thePlayer) || (msg.callee==theOtherOne))	//RDH 17May99
//DEADCODE CSB 07/03/00 		playerRecipient = TRUE;									//RDH 17May99

	//Does this message already exist?...
	if(!msg.decisionhandler)											//CSB 07/03/00
	{																	//CSB 07/03/00
		for (index = 0; index < OLDBUFFERSIZE; index++)
		{
			if (	(oldbuffer[index].messagetype == msg.messagetype)
				&&	(oldbuffer[index].target == msg.target)				)
			{
				//is old repeatable?
				if (	(oldbuffer[index].visibility == VIS_3)			//RJS 01Apr99
					||	(oldbuffer[index].visibility == NOTVIS_1)
					||	(oldbuffer[index].visibility == VIS_1))
				{
	//Removed because it became annoying...							//RJS 02Jun99
	//DeadCode RJS 02Jun99 				if (!playerRecipient)							//RDH 17May99
	//DeadCode RJS 02Jun99 					return (FALSE);								//RDH 17May99
	//DeadCode RJS 02Jun99 				else											//RDH 17May99
						return (TRUE);								//RDH 17May99
				}
			}
		}

		for (index = 0; index < NEWBUFFERSIZE; index++)
		{
			if (	(newbuffer[index].messagetype == msg.messagetype)
				&&	(newbuffer[index].target == msg.target)				)
			{
				//is new repeatable?
				if (	(newbuffer[index].visibility == VIS_3)
					||	(newbuffer[index].visibility == NOTVIS_1)	)
				{
	//Removed because it became annoying...							//RJS 02Jun99
	//DeadCode RJS 02Jun99 				if (!playerRecipient)							//RDH 17May99
	//DeadCode RJS 02Jun99 					return (FALSE);								//RDH 17May99
	//DeadCode RJS 02Jun99 				else											//RDH 17May99
						return (TRUE);								//RDH 17May99
				}
			}
		}
	}
	else																//CSB 09/03/00
		msg.priority = PRI_MAX;											//CSB 09/03/00

//DeadCode PD 04Mar99 	//... or not in player group...
//DeadCode PD 04Mar99 	if (	(msg.caller != thePlayer)
//DeadCode PD 04Mar99 		||	(msg.callee != thePlayer)	)
//DeadCode PD 04Mar99 		return (FALSE);
//DEADCODE CSB 07/03/00 	if (!(msg.caller==thePlayer||msg.callee==thePlayer) &&
//DEADCODE CSB 07/03/00 		!(msg.caller==theOtherOne||msg.callee==theOtherOne))		//PD 04Mar99
//DEADCODE CSB 07/03/00 	{
//DEADCODE CSB 07/03/00 		if (!msg.blockchatter)									//RJS 06Jul99
//DEADCODE CSB 07/03/00 		{
//DEADCODE CSB 07/03/00 			AirStrucPtr	checkitem = msg.caller;						//AMM 24Jun99
//DEADCODE CSB 07/03/00 			if (	(msg.voiceindex != VOICE_REST)
//DEADCODE CSB 07/03/00 				&&	(msg.voiceindex != VOICE_PLAYER)	)
//DEADCODE CSB 07/03/00 				checkitem = msg.callee;								//AMM 24Jun99
//DEADCODE CSB 07/03/00 		
//DEADCODE CSB 07/03/00 			if (!checkitem)
//DEADCODE CSB 07/03/00 				return TRUE;
//DEADCODE CSB 07/03/00 
//DEADCODE CSB 07/03/00 			if (	checkitem->PlayerInGroup()
//DEADCODE CSB 07/03/00 				||	checkitem->PlayerInFlight()	)
//DEADCODE CSB 07/03/00 			{
//DEADCODE CSB 07/03/00 				//Overhears leader & fac/tac & dentist & tower...
//DEADCODE CSB 07/03/00 				if (checkitem->AcIsFlightLeader() || checkitem->AcIsGroupLeader())
//DEADCODE CSB 07/03/00 				{
//DEADCODE CSB 07/03/00 					if (noBufferedMessages > 8)
//DEADCODE CSB 07/03/00 						return FALSE;
//DEADCODE CSB 07/03/00 				}
//DEADCODE CSB 07/03/00 				else
//DEADCODE CSB 07/03/00 					return FALSE;
//DEADCODE CSB 07/03/00 			}
//DEADCODE CSB 07/03/00 			else
//DEADCODE CSB 07/03/00 				return FALSE;
//DEADCODE CSB 07/03/00 		}
//DEADCODE CSB 07/03/00 		else
//DEADCODE CSB 07/03/00 			return TRUE;										//RJS 06Jul99
//DEADCODE CSB 07/03/00 	}															//RJS 28May99

//	thereIsANewMessage=true;

#ifdef CHATTERTRACE
// defined in rchatter.h
	if (_Radio.damageMessage)
	{
		UWord cw=GETFPCW();
		::AfxTrace("BUFFERING: %08x\n",msg.messagecnt);
		SETFPCW(cw);
	}
#endif

	noBufferedMessages++;

	if (msg.priority >= PRI_MEDMAX)				//RJS 24Jun99
	{
		newbufferbot--;
		if (newbufferbot < 0)
			newbufferbot = NEWBUFFERSIZE-1;

		newbuffer[newbufferbot] = msg;
	}
	else
	{
		// Is this buffer full?
		if (	(newbufferbot == newbuffertop)
			&&	(newbuffer[newbufferbot].priority != GAP)	)
		{
			SLong	nogaps;

			if (msg.priority != PRI_LOW)
			{
				nogaps = RemoveGaps(newbuffer,newbuffertop,NEWBUFFERSIZE);
				if (nogaps == 0)
				{
					SLong	thisone = -1;

					for (index = newbuffertop; index < NEWBUFFERSIZE; index++)
					{
						if (newbuffer[index].priority == PRI_LOW)
						{
							thisone = index;
							break;
						}
					}

					if (thisone < 0)
					{
						for (index = 0; index < newbuffertop; index++)
						{
							if (newbuffer[index].priority == PRI_LOW)
							{
								thisone = index;
								break;
							}
						}
					}

					if (thisone > 0)
					{
						// Kill 1st low priority one found...

						newbuffer[thisone].priority = GAP;

						RemoveGaps(newbuffer,newbuffertop,NEWBUFFERSIZE);
					}
				}
			}
		}

		// Is this buffer still full?
		if (	(newbufferbot == newbuffertop)
			&&	(newbuffer[newbufferbot].priority != GAP)	)
			return(FALSE);

		newbuffer[newbuffertop] = msg;

		//is this right?....
		newbuffertop++;
		if (newbuffertop >= NEWBUFFERSIZE)
			newbuffertop = 0;
	}

	return (TRUE);
}
Ejemplo n.º 3
0
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
//Procedure		AddToBuffer
//Author		Robert Slater
//Date			Tue 26 Jan 1999
//
//Description
//
//Inputs
//
//Returns
//
//------------------------------------------------------------------------------
bool	MessageBuffer::AddToBuffer(const MESSAGE_STRUC&	msg)
{
    bool 	retval;
    SLong	index,index2;
    bool	playerRecipient = false;

    if (_Replay.Playback)										//AMM 14Apr99
        return (true);											//AMM 14Apr99

    //Block messages to dead blokes
    if (msg.callee && msg.callee->Status.deadtime)				//RJS 05May99
        return true;											//RJS 05May99

    if (msg.caller)
    {
//FIXA        if (msg.caller->nationality != Manual_Pilot.ControlledAC2->nationality)
//FIXA            return true;

        if (msg.caller->ai.radiosilent)
        {
            if (msg.caller->AcIsPlayer())						//RJS 24May99
            {
                MESSAGE_STRUC	tmpmsg(SCRIPT_SILENCE,MSG_SILENCE,NULL,msg.caller,msg.caller);
                _Radio.TriggerMsg(tmpmsg.SetVoice(VOICE_REST));
            }

            return true;									//RJS 24May99
        }
    }

    if (msg.callee)
    {
//FIXA        if (msg.callee->nationality != Manual_Pilot.ControlledAC2->nationality)
//FIXA            return true;
    }

    if ((msg.callee==thePlayer) || (msg.callee==theOtherOne))	//RDH 17May99
        playerRecipient = true;									//RDH 17May99

    //Does this message already exist?...
    for (index = 0; index < OLDBUFFERSIZE; index++)
    {
        if (	(oldbuffer[index].messagetype == msg.messagetype)
                &&	(oldbuffer[index].target == msg.target)				)
        {
            //is old repeatable?
            if (	(oldbuffer[index].visibility == VIS_3)			//RJS 01Apr99
                    ||	(oldbuffer[index].visibility == NOTVIS_1)
                    ||	(oldbuffer[index].visibility == VIS_1))
            {
                return (true);								//RDH 17May99
            }
        }
    }

    for (index = 0; index < NEWBUFFERSIZE; index++)
    {
        if (	(newbuffer[index].messagetype == msg.messagetype)
                &&	(newbuffer[index].target == msg.target)				)
        {
            //is new repeatable?
            if (	(newbuffer[index].visibility == VIS_3)
                    ||	(newbuffer[index].visibility == NOTVIS_1)	)
            {
                return (true);								//RDH 17May99
            }
        }
    }

    if (!(msg.caller==thePlayer||msg.callee==thePlayer) &&
            !(msg.caller==theOtherOne||msg.callee==theOtherOne))		//PD 04Mar99
    {
        if (!msg.blockchatter)									//RJS 06Jul99
        {
            AirStrucPtr	checkitem = msg.caller;						//AMM 24Jun99
            if (	(msg.voiceindex != VOICE_REST)
                    &&	(msg.voiceindex != VOICE_PLAYER)	)
                checkitem = msg.callee;								//AMM 24Jun99

            if (!checkitem)
                return true;

            if (	checkitem->PlayerInGroup()
                    ||	checkitem->PlayerInFlight()	)
            {
                //Overhears leader & fac/tac & dentist & tower...
                if (checkitem->AcIsFlightLeader() || checkitem->AcIsGroupLeader())
                {
                    if (noBufferedMessages > 8)
                        return false;
                }
                else
                    return false;
            }
            else
                return false;
        }
        else
            return true;										//RJS 06Jul99
    }															//RJS 28May99

//	thereIsANewMessage=true;

#ifndef NDEBUG
#ifdef CHATTERTRACE
// defined in rchatter.h
    UWord cw=GETFPCW();
    ::AfxTrace("BUFFERING: %08x\n",msg.messagecnt);
    SETFPCW(cw);
#endif
#endif

    noBufferedMessages++;

    if (msg.priority >= PRI_MEDMAX)				//RJS 24Jun99
    {
        newbufferbot--;
        if (newbufferbot < 0)
            newbufferbot = NEWBUFFERSIZE-1;

        newbuffer[newbufferbot] = msg;
    }
    else
    {
        // Is this buffer full?
        if (	(newbufferbot == newbuffertop)
                &&	(newbuffer[newbufferbot].priority != GAP)	)
        {
            SLong	nogaps;

            if (msg.priority != PRI_LOW)
            {
                nogaps = RemoveGaps(newbuffer,newbuffertop,NEWBUFFERSIZE);
                if (nogaps == 0)
                {
                    SLong	thisone = -1;

                    for (index = newbuffertop; index < NEWBUFFERSIZE; index++)
                    {
                        if (newbuffer[index].priority == PRI_LOW)
                        {
                            thisone = index;
                            break;
                        }
                    }

                    if (thisone < 0)
                    {
                        for (index = 0; index < newbuffertop; index++)
                        {
                            if (newbuffer[index].priority == PRI_LOW)
                            {
                                thisone = index;
                                break;
                            }
                        }
                    }

                    if (thisone > 0)
                    {
                        // Kill 1st low priority one found...

                        newbuffer[thisone].priority = GAP;

                        RemoveGaps(newbuffer,newbuffertop,NEWBUFFERSIZE);
                    }
                }
            }
        }

        // Is this buffer still full?
        if (	(newbufferbot == newbuffertop)
                &&	(newbuffer[newbufferbot].priority != GAP)	)
            return(false);

        newbuffer[newbuffertop] = msg;

        //is this right?....
        newbuffertop++;
        if (newbuffertop >= NEWBUFFERSIZE)
            newbuffertop = 0;
    }

    return (true);
}