Beispiel #1
0
T_word32 FileGetSize(T_byte8 *p_filename)
{
    T_word32 size ;
#if defined(WIN32)
    FILE *fp;

    DebugRoutine("FileGetSize");
    fp = fopen(p_filename, "rb");
    size = filelength(fileno(fp));
    fclose(fp);
    DebugEnd() ;
#else
    struct find_t fileinfo ;

    DebugRoutine("FileGetSize") ;

    /* Get information about the file. */
    if (_dos_findfirst(p_filename, _A_NORMAL, &fileinfo) == 0)  {
        /* If we found the file, return the file size. */
        size = fileinfo.size ;
    } else {
        /* If we didn't find the file, return a zero. */
        size = 0 ;
    }

    DebugEnd() ;
#endif

    return size ;
}
Beispiel #2
0
T_void FormHandleKey(E_keyboardEvent event, T_word16 scankey)
{
    T_formObjectStruct *p_object;
    T_word16 i;
    T_buttonID buttonID;
    E_buttonAction buttonAction;

    DebugRoutine("FormHandleKey");
    if (G_formHasButtons == TRUE)
        ButtonKeyControl(event, scankey);
    if (G_formHasTextBoxes == TRUE)
        TxtboxKeyControl(event, scankey);

    /* Make sure the gamma key is correct. */
    if (KeyMapGetScan(KEYMAP_GAMMA_CORRECT) == TRUE) {
        MessagePrintf("Gamma level %d", ColorGammaAdjust());
        ColorUpdate(1);
        while (KeyMapGetScan(KEYMAP_GAMMA_CORRECT) == TRUE) {
#ifdef WIN32
            extern void KeyboardUpdate(E_Boolean updateBuffers);
            KeyboardUpdate(TRUE);
#endif
        }
    }

    DebugEnd();
}
/**
 *  IGetOurLocation determines this players general location
 *
 *  @return General player location
 *
 *<!-----------------------------------------------------------------------*/
static T_playerIDLocation IGetOurLocation(T_void)
{
    T_playerIDLocation location = PLAYER_ID_LOCATION_NOWHERE;
    T_word16 place;

    DebugRoutine("IGetOurLocation");

    place = ClientGetCurrentPlace();

    switch (place) {
        case HARDFORM_GOTO_PLACE_OFFSET + HARD_FORM_GUILD:
            location = PLAYER_ID_LOCATION_GUILD;
            break;
        case HARDFORM_GOTO_PLACE_OFFSET + HARD_FORM_TOWN:
		case HARDFORM_GOTO_PLACE_OFFSET + HARD_FORM_BANK:
		case HARDFORM_GOTO_PLACE_OFFSET + HARD_FORM_STORE:
		case HARDFORM_GOTO_PLACE_OFFSET + HARD_FORM_INN:
            location = PLAYER_ID_LOCATION_TOWN;
            break;
    }

    if ((place < HARDFORM_GOTO_PLACE_OFFSET) && (place != 0))
        location = PLAYER_ID_LOCATION_GAME;

    DebugEnd();

    return location;
}
static T_void GuildUIJoinGame   (T_buttonID buttonID)
{
    T_word16 map ;
    T_gameGroupID groupID ;
	T_word16 quest;

    DebugRoutine ("GuildUIJoinGame");

    /* fake it */
//    GuildUIConfirmJoinGame();

    /* real it */
    GuildUIGetSelectedGame(&map, &groupID, &quest) ;

    if (map != 0)  {
        /* Request to join in the fun. */
        PeopleHereSetOurState(PLAYER_ID_STATE_JOINING_GAME) ;
        ClientSendRequestJoin(
            map,
            groupID) ;
		StatsSetCurrentQuestNumber(quest);
    } else {
        MessageAdd("No game session selected.") ;
    }

    DebugEnd();
}
/* removes a game from the list of active 'open' games */
T_void GuildUIRemoveGame (T_word16 mapNumber, T_gameGroupID groupID)
{
    T_gameDescriptionStruct *p_game;
    T_doubleLinkListElement element,nextElement;
    DebugRoutine ("GuildUIRemoveGame");

    element=DoubleLinkListGetFirst(G_gameList);

    while (element != DOUBLE_LINK_LIST_ELEMENT_BAD)
    {
        nextElement=DoubleLinkListElementGetNext(element);
        p_game=(T_gameDescriptionStruct *)DoubleLinkListElementGetData(element);

        if ((p_game->mapNumber==mapNumber) &&
            (CompareGameGroupIDs(p_game->groupID, groupID)))
        {
            /* remove this one */
            MemFree(p_game);
            DoubleLinkListRemoveElement(element);
            break;
        }

        element=nextElement;
    }

    /* Only redraw the list if we are not joining or creating a game. */
    if (PeopleHereGetOurState() == 0)
        GuildUIDrawGameList();

    DebugEnd();
}
/* to our current player */
static E_Boolean GuildUIPlayerCanVisitMap (T_word16 which)
{
    T_doubleLinkListElement element;
    E_Boolean canGo=FALSE;
    T_word16 count=0;
    T_mapDescriptionStruct *p_mapDesc;

    DebugRoutine ("GuildUIPlayerCanVisitMap");
    element=DoubleLinkListGetFirst (G_mapList);
    while (element != DOUBLE_LINK_LIST_ELEMENT_BAD)
    {
        if (count==which)
        {
            /* check this map */
            p_mapDesc=(T_mapDescriptionStruct *)DoubleLinkListElementGetData(element);
            if (p_mapDesc->mapKey==0) canGo=TRUE;
            else if (StatsPlayerHasNotePage(p_mapDesc->mapKey)) canGo=TRUE;
            break;
        }
        count++;
        element=DoubleLinkListElementGetNext(element);
    }

    DebugEnd();
    return (canGo);
}
static T_word16 GuildUIGetSelectedAdventure(T_void)
{
    T_word16 adventure ;
    T_word16 i, index ;
    T_mapDescriptionStruct *p_map ;
    T_doubleLinkListElement element ;

    DebugRoutine("GuildUIGetSelectedAdventure") ;

    /* Just the appropriate text line on the list. */
    index = TxtboxGetSelectionNumber(G_displayBoxes[GUILD_MAPS_LIST]) ;
    StatsSetCurrentQuestNumber(index);

    element = DoubleLinkListGetFirst(G_mapList) ;
    for (i=0; i<index; i++)  {
        element = DoubleLinkListElementGetNext(element) ;
    }
    if (element != DOUBLE_LINK_LIST_ELEMENT_BAD)  {
        p_map = (T_mapDescriptionStruct *)
                    DoubleLinkListElementGetData(element) ;
        adventure = p_map->mapIndex ;
    } else {
        /* Element not found? */
        DebugCheck(FALSE) ;
        adventure = 0 ;
    }

    DebugEnd() ;

    return adventure ;
}
Beispiel #8
0
E_Boolean ScheduleUpdateEvents(T_void)
{
    T_scheduleEvent *p_event ;
    E_Boolean f_eventOccured = FALSE ;
    TICKER_TIME_ROUTINE_PREPARE() ;

    TICKER_TIME_ROUTINE_START() ;

    DebugRoutine("ScheduleUpdateEvents") ;

    /* Loop while there are events that can be processed. */
    while ((G_firstScheduleEvent != NULL) &&
           (G_firstScheduleEvent->when <= SyncTimeGet()))  {
        /* An event is now going off.  Get that event. */
        p_event = G_firstScheduleEvent ;

        /* Call the handler for this event. */
        DebugCheck(p_event->handler != NULL) ;
        p_event->handler(p_event->data) ;

        /* Remove the event from the list. */
        G_firstScheduleEvent = p_event->next ;
        MemFree(p_event) ;

        /* Note that some event occured. */
        f_eventOccured = TRUE ;
    }

    DebugEnd() ;

    TICKER_TIME_ROUTINE_END(stdout, "ScheduleUpdateEvents", 500) ;
    return f_eventOccured ;
}
Beispiel #9
0
T_void ScheduleAddEvent(
           T_word32 when,
           T_scheduleEventHandler handler,
           T_word32 data)
{
    T_scheduleEvent *p_event ;

    DebugRoutine("ScheduleAddEvent") ;

    /* Allocate memory for this new event. */
    p_event = MemAlloc(sizeof(T_scheduleEvent)) ;

    DebugCheck(p_event != NULL) ;

    /* Make sure it was allocated. */
    if (p_event != NULL)  {
        /* Store the data in the structure. */
        p_event->when = when ;
        p_event->handler = handler ;
        p_event->data = data ;

        /* Insert sort this item into our linked list of events. */
        IScheduleInsertSortEvent(p_event, when) ;
    }
    DebugEnd() ;
}
Beispiel #10
0
static T_word16 IPacketComputeChecksum(T_packetEitherShortOrLong *packet)
{
    T_word16 checksum ;
    T_word16 i ;

    DebugRoutine("IPacketComputeChecksum") ;
    DebugCheck(packet != NULL) ;

    /* Start out the checksum to equal the id of the block. */
    checksum = packet->header.id ;

    /* Add in the packet type. */
    checksum += packet->header.packetLength ;

    /* Loop the length of the data. */
    for (i=0; i<packet->header.packetLength; i++)  {
        /* If i is odd, then add.  Otherwise, do an exclusive-or to mix */
        /* up the bits. */
        if (i&1)
            checksum += packet->data[i] ;
        else
            checksum ^= packet->data[i] ;
    }

    DebugEnd() ;

    return checksum ;
}
Beispiel #11
0
T_sword16 PacketSendShort(T_packetShort *p_shortPacket)
{
    T_sword16 code = -1 ;

    DebugRoutine("PacketSendShort") ;
    DebugCheck(p_shortPacket != NULL) ;

    /* Store the header information in the packet. */
    p_shortPacket->header.prefix = PACKET_PREFIX ;

    /* Make this a short packet. */
    p_shortPacket->header.packetLength = SHORT_PACKET_LENGTH ;

    /* Put the id for this packet in the packet. */
    p_shortPacket->header.id = G_packetID++ ;

    /* Compute the checksum for this packet. */
    p_shortPacket->header.checksum =
        IPacketComputeChecksum((T_packetEitherShortOrLong *)p_shortPacket) ;

    /* Actually send the data out the port. */
    CommSendData((T_byte8 *)p_shortPacket, sizeof(T_packetShort)) ;
    /* Note that the packet was sent. */
    code = 0 ;

    DebugEnd() ;

    return code ;
}
Beispiel #12
0
T_sword16 PacketSendAnyLength(T_packetEitherShortOrLong *p_anyPacket)
{
    T_sword16 code = -1 ;

    DebugRoutine("PacketSendAnyLength") ;
    DebugCheck(p_anyPacket != NULL) ;
    DebugCheck(p_anyPacket->header.packetLength <= LONG_PACKET_LENGTH) ;

    /* Store the header information in the packet. */
    p_anyPacket->header.prefix = PACKET_PREFIX ;

    /* Make this a long packet. */
//    p_anyPacket->header.packetLength = LONG_PACKET_LENGTH ;

    /* Put the id for this packet in the packet. */
    p_anyPacket->header.id = G_packetID++ ;

    /* Compute the checksum for this packet. */
    p_anyPacket->header.checksum = IPacketComputeChecksum(p_anyPacket) ;

    /* See if there is room to send the packet. */
    /* Actually send the data out the port. */
    CommSendData(
        (T_byte8 *)p_anyPacket,
        (T_word16)(sizeof(T_packetHeader) + p_anyPacket->header.packetLength)) ;

    /* Note that the packet was sent. */
    code = 0 ;

    DebugEnd() ;

    return code ;
}
T_void MemCheckData(T_void *p_data)
{
    T_memBlockHeader *p_header ;
    T_byte8 *p_bytes ;

    DebugRoutine("MemCheckData") ;
    DebugCheck(p_data != NULL) ;

    p_bytes = p_data ;
    p_bytes -= sizeof(T_memBlockHeader) ;
    p_header = (T_memBlockHeader *)p_bytes ;

    if (strcmp (p_header->blockTag, "TaG") != 0)  {
        printf("bad memory block at %p\n", p_data) ;
        printf("tag: %-4s\n", p_header->blockTag) ;
        printf("id: %ld\n", p_header->blockId) ;
        printf("next: %p\n", p_header->p_nextBlock) ;
        printf("prev: %p\n", p_header->p_prevBlock) ;
        printf("disc: %p\n", p_header->p_callback) ;
#ifdef _MEM_RECORD_ROUTINES_
        printf("rout: %s\n", p_header->routine) ;
        printf("line: %d\n", p_header->line) ;
#endif
        printf("size: %ld\n", p_header->size) ;
    }
    DebugCheck(strcmp (p_header->blockTag, "TaG") == 0) ;

    DebugEnd() ;
}
Beispiel #14
0
T_formObjectID FormGetObjID(T_word32 numID)
{
    T_word16 i;
    T_formObjectID retvalue = NULL;
    T_formObjectStruct *p_object;

    DebugRoutine("FormGetObjID");
    for (i = 0; i < MAX_FORM_OBJECTS; i++) {
        if (G_formObjectArray[i] != NULL ) {
            /* get the pointer to the object structure */
            p_object = (T_formObjectStruct*)G_formObjectArray[i];
            /* check to see if the numerical ID matches */
            if (numID == p_object->numID) {
                /* found one, return the pointer to the object in question */
                retvalue = p_object->objID;
                break;
            }
        }
    }
#ifndef NDEBUG
    if (retvalue == NULL ) {
        printf("bad form obj ID = %d\n", numID);
        fflush(stdout);
    }
#endif
    DebugCheck(retvalue != NULL);
    DebugEnd();
    return (retvalue);
}
/* for store / bank / inn ui screens */
T_void MessageSetAlternateOutputOn(T_void)
{
    DebugRoutine ("MessageSetAlternateOutputOn");

    if (G_alternateOutput==FALSE)
    {
        /* create alternate textbox */
        G_altOutputBox = TxtboxCreate  (OUTPUT_BOX_X1,
                                        OUTPUT_BOX_Y1,
                                        OUTPUT_BOX_X2,
                                        OUTPUT_BOX_Y2,
                                        "FontMedium",
                                        0,
                                        0,
                                        FALSE,
                                        Txtbox_JUSTIFY_CENTER,
                                        Txtbox_MODE_VIEW_NOSCROLL_FORM,
                                        NULL);

        TxtboxSetData(G_altOutputBox,"");
        G_alternateOutput=TRUE;
    }

    DebugEnd();
}
Beispiel #16
0
T_void Hash32Remove(T_hash32Item hashItem)
{
    T_hash32ItemStruct *p_item ;
    T_doubleLinkList list ;

    DebugRoutine("Hash32Remove") ;

    /* Check to see if the item is bad. */
    DebugCheck(hashItem != HASH32_ITEM_BAD) ;
    if (hashItem != HASH32_ITEM_BAD)  {
        /* Get a quick pointer. */
        p_item = (T_hash32ItemStruct *)hashItem ;

        /* See if the tag is correct. */
        DebugCheck(p_item->tag == HASH32_ITEM_TAG) ;
        if (p_item->tag == HASH32_ITEM_TAG)  {
            /* Yes, this is a proper item, remove it. */
            DoubleLinkListRemoveElement(p_item->elementInBigList) ;
            DoubleLinkListRemoveElement(p_item->elementInHashList) ;

            /* Mark this object as no longer. */
            p_item->tag = HASH32_ITEM_DEAD_TAG ;

            /* Delete this item. */
            MemFree(p_item) ;
        }
    }

    DebugEnd() ;
}
T_void KeyMapReinitialize(T_iniFile iniFile)
{
    DebugRoutine("KeyMapReinitialize");
    KeyMapFinish();
    KeyMapInitialize(iniFile);
    DebugEnd();
}
Beispiel #18
0
T_hash32Item Hash32GetFirstItem(T_hash32 hash)
{
    T_hash32Struct *p_hash ;
    T_hash32ItemStruct *p_item = HASH32_ITEM_BAD ;
    T_doubleLinkListElement element ;

    DebugRoutine("Hash32GetFirstItem") ;

    /* Make sure this is a valid hash table type. */
    DebugCheck(hash != HASH32_BAD) ;
    if (hash != HASH32_BAD)  {
        /* Get a quick pointer to the header. */
        p_hash = (T_hash32Struct *)hash ;

        /* Make sure this is a pointer to a not already dead */
        /* hash table. */
        DebugCheck(p_hash->tag == HASH32_TAG) ;
        if (p_hash->tag == HASH32_TAG)  {
            /* See if there is anything in that list. */
            element = DoubleLinkListGetFirst(p_hash->itemList) ;
            if (element != DOUBLE_LINK_LIST_ELEMENT_BAD)  {
                /* Found something.  Get the hash item. */
                p_item = DoubleLinkListElementGetData(element) ;
            }
        }
    }

    DebugEnd() ;

    return ((T_hash32Item)p_item) ;
}
Beispiel #19
0
T_sliderID SliderCreate (T_word16 lx1, T_word16 ly1, T_word16 lx2)
{
	T_word16 i;
   T_word16 size;
   T_sliderStruct *p_slider;

	DebugRoutine ("SliderCreate");

	for (i=0;i<MAX_SLIDERS;i++)
	{
		if (G_sliderArray[i]==NULL)  //add a slider to list
		{
         /* found an empty slot, allocate slider struct */
         p_slider = (T_sliderStruct *)G_sliderArray[i];
         size=sizeof (T_sliderStruct);
         p_slider = (T_sliderID)MemAlloc(size);
         /* check to make sure memory was allocated */
         DebugCheck (p_slider != NULL);
         p_slider->lx1=lx1;
         p_slider->ly1=ly1;
         p_slider->lx2=lx2;
         p_slider->sliderx=lx1;
         p_slider->callback=NULL;
         p_slider->curval=0;
         p_slider->knobgraphic=GraphicCreate (p_slider->sliderx,ly1-4,"UI/3DUI/SLIDER");
         G_sliderArray[i]=p_slider;
         break;
		}
	}

	DebugCheck (i<MAX_SLIDERS);
	DebugEnd();
	return (G_sliderArray[i]);
}
Beispiel #20
0
T_hash32Item Hash32ItemGetNext(T_hash32Item hashItem)
{
    T_hash32ItemStruct *p_item ;
    T_hash32ItemStruct *p_next ;
    T_doubleLinkListElement element ;

    DebugRoutine("Hash32ItemGetNext") ;

    /* Check to see if the item is bad. */
    DebugCheck(hashItem != HASH32_ITEM_BAD) ;
    if (hashItem != HASH32_ITEM_BAD)  {
        /* Get a quick pointer. */
        p_item = (T_hash32ItemStruct *)hashItem ;

        /* See if the tag is correct. */
        DebugCheck(p_item->tag == HASH32_ITEM_TAG) ;
        if (p_item->tag == HASH32_ITEM_TAG)  {
            /* Item is good.  Look up the next item. */
            element = DoubleLinkListElementGetNext(p_item->elementInBigList) ;
            if (element != DOUBLE_LINK_LIST_ELEMENT_BAD)
                p_next = DoubleLinkListElementGetData(element) ;
            else
                p_next = HASH32_ITEM_BAD ;
        }
    }

    DebugEnd() ;

    return ((T_hash32Item) p_next) ;
}
T_void GuildUIGetSelectedGame(
                  T_word16 *p_mapNumber,
                  T_gameGroupID *p_groupID,
				  T_word16 *p_quest)
{
    T_word16 i, index ;
    T_gameDescriptionStruct *p_game ;
    T_doubleLinkListElement element ;

    DebugRoutine("GuildUIGetSelectedGame") ;

    /* Just the appropriate text line on the list. */
    index = TxtboxGetSelectionNumber(G_displayBoxes[GUILD_GAME_LIST]) ;

    element = DoubleLinkListGetFirst(G_gameList) ;
    for (i=0; i<index; i++)  {
        element = DoubleLinkListElementGetNext(element) ;
    }
    if (element != DOUBLE_LINK_LIST_ELEMENT_BAD)  {
        p_game = (T_gameDescriptionStruct *)
                    DoubleLinkListElementGetData(element) ;
        *p_mapNumber = p_game->mapNumber ;
        *p_groupID = p_game->groupID ;
		*p_quest = p_game->questNumber;
    } else {
        /* Element not found?  Return zero. */
        *p_mapNumber = 0 ;
        *p_groupID = *DirectTalkGetNullBlankUniqueAddress() ;
		*p_quest = 0 ;
    }

    DebugEnd() ;
}
Beispiel #22
0
T_void *Hash32ItemGetData(T_hash32Item hashItem)
{
    T_hash32ItemStruct *p_item ;
    T_void *p_data ;

    DebugRoutine("Hash32ItemGetData") ;

    /* Check to see if the item is bad. */
    DebugCheck(hashItem != HASH32_ITEM_BAD) ;
    if (hashItem != HASH32_ITEM_BAD)  {
        /* Get a quick pointer. */
        p_item = (T_hash32ItemStruct *)hashItem ;

        /* See if the tag is correct. */
        DebugCheck(p_item->tag == HASH32_ITEM_TAG) ;
        if (p_item->tag == HASH32_ITEM_TAG)  {
            /* Get the data. */
            p_data = p_item->p_data ;
        }
    }

    DebugEnd() ;

    return p_data ;
}
/* information block about an adventure */
static T_void GuildDisplayMapInfo (T_TxtboxID TxtboxID)
{
    T_word16 selection;
    T_mapDescriptionStruct *p_map;
    T_doubleLinkListElement element;

    DebugRoutine ("GuildDisplayMapInfo");

    selection=TxtboxGetSelectionNumber(TxtboxID);
    element=DoubleLinkListGetFirst(G_mapList);

    /* Record that adventure as the selected adventure. */
    StatsSetCurrentQuestNumber(selection);

    while (element != DOUBLE_LINK_LIST_ELEMENT_BAD)
    {
        if (selection==0)
        {

            /* display this map information */
            p_map=DoubleLinkListElementGetData(element);
            TxtboxSetData (G_displayBoxes[GUILD_MAPS_DESC],p_map->description);
            break;
        }

        selection-=1;
        element=DoubleLinkListElementGetNext(element);
    }


    DebugEnd();
}
Beispiel #24
0
T_word32 Hash32ItemGetKey(T_hash32Item hashItem)
{
    T_hash32ItemStruct *p_item ;
    T_word32 key = 0 ;

    DebugRoutine("Hash32ItemGetKey") ;

    /* Check to see if the item is bad. */
    DebugCheck(hashItem != HASH32_ITEM_BAD) ;
    if (hashItem != HASH32_ITEM_BAD)  {
        /* Get a quick pointer. */
        p_item = (T_hash32ItemStruct *)hashItem ;

        /* See if the tag is correct. */
        DebugCheck(p_item->tag == HASH32_ITEM_TAG) ;
        if (p_item->tag == HASH32_ITEM_TAG)  {
            /* Get the data. */
            key = p_item->key ;
        }
    }

    DebugEnd() ;

    return key ;
}
/* removes a player name from the list of players for the selected game */
T_void GuildUIRemovePlayer (T_byte8 *playerName)
{
    T_doubleLinkListElement element;
    T_byte8 *name;
    T_word32 size;
    DebugRoutine ("GuildUIRemovePlayer");

    size=TxtboxCanFit(G_displayBoxes[GUILD_GAME_DESC],playerName);
    element=DoubleLinkListGetFirst(G_playerList);

    while (element != DOUBLE_LINK_LIST_ELEMENT_BAD)
    {
        name=(T_byte8 *)DoubleLinkListElementGetData(element);
        if (strncmp(name,playerName,size)==0)
        {
            /* remove element */
            MemFree(name);
            DoubleLinkListRemoveElement(element);
            break;
        }
        element=DoubleLinkListElementGetNext(element);
    }

    GuildUIDrawPlayerList();

    DebugEnd();
}
Beispiel #26
0
T_word32 Hash32GetNumberItems(T_hash32 hash)
{
    T_word32 numItems = 0 ;
    T_hash32Struct *p_hash ;

    DebugRoutine("Hash32GetNumberItems") ;

    /* Make sure this is a valid hash table type. */
    DebugCheck(hash != HASH32_BAD) ;
    if (hash != HASH32_BAD)  {
        /* Get a quick pointer to the header. */
        p_hash = (T_hash32Struct *)hash ;

        /* Make sure this is a pointer to a not already dead */
        /* hash table. */
        DebugCheck(p_hash->tag == HASH32_TAG) ;
        if (p_hash->tag == HASH32_TAG)  {
            numItems = DoubleLinkListGetNumberElements(
                           p_hash->itemList) ;
        }
    }

    DebugEnd() ;

    return numItems ;
}
/**
 *  ICreatePlayerID creates a new blank entry for a given person
 *
 *  @param p_playerID -- ID of new player to add
 *
 *  @return Found player ID pointer or NULL
 *
 *<!-----------------------------------------------------------------------*/
static T_playerIDSelf *ICreatePlayerID(T_playerIDSelf *p_playerID)
{
    T_playerIDSelf *p_new = NULL;
    T_word16 i;
    T_playerIDSelf *p = G_peopleList;

    DebugRoutine("ICreatePlayerID");

    // Find a slot with no name
    for (i = 0; i < MAX_PLAYERS_IN_WORLD; i++, p++) {
        if (p->name[0] == '\0') {
            memcpy(p, p_playerID, sizeof(*p));

            // We want the transition from nowhere to somewhere, 
            // start at nowhere for a newly created character
            p->location = PLAYER_ID_LOCATION_NOWHERE;
            p->state = PLAYER_ID_STATE_NONE;
            p_new = p;
            break;
        }
    }

    DebugEnd();

    return p_new;
}
/**
 *  MessageDisplayMessage searches for a text file in the resource
 *  identified by MESSAGES/MSG##### where ##### is the message number
 *  to display.
 *
 *<!-----------------------------------------------------------------------*/
T_void MessageDisplayMessage (T_word16 messagenum)
{
    T_byte8 *desc1;
    T_byte8 *desc2;
    T_resource res;
    T_word32 size;
    T_byte8 stmp[32];
    DebugRoutine ("MessageDisplayMessage");

    sprintf (stmp,"MESSAGES/MSG%05d.TXT",messagenum);
    DebugCheck (PictureExist(stmp));

    if (PictureExist(stmp))
    {
        /* show description file */
        desc1=PictureLockData (stmp,&res);
        size=ResourceGetSize(res);
        desc2=(T_byte8 *)MemAlloc(size+2);
        memcpy (desc2,desc1,size);
        desc2[size-1]='\0';
        MessageAdd (desc2);
        MemFree (desc2);
        PictureUnlockAndUnfind(res) ;
    }

    DebugEnd();
}
/**
 *  Send a long packet to all members in a group.  Does not send to
 *  ourself.
 *
 *  @param groupID -- Group ID to send to (0=town UI, otherwise game ID)
 *  @param p_packet -- Pointer to packet to send
 *  @param retryTime -- Retry time for sending this packet
 *  @param extraData -- Extra data for this packet callback
 *  @param p_callback -- Callback when sent (0 if no callback)
 *
 *<!-----------------------------------------------------------------------*/
T_void PeopleHereSendPacketToGroup(
        T_gameGroupID groupID,
        T_packetLong *p_packet,
        T_word16 retryTime,
        T_word32 extraData,
        T_cmdQPacketCallback p_callback)
{
    T_word16 i;
    T_playerIDSelf *p = G_peopleList;
    T_directTalkUniqueAddress ourID;

    DebugRoutine("PeopleHereGeneratePeopleInGame");

    DirectTalkGetUniqueAddress(&ourID);

    /* Go through the list and identify everyone in this group. */
    for (i = 0; i < MAX_PLAYERS_IN_WORLD; i++, p++) {
        if ((p->name[0]) && (CompareGameGroupIDs(p->groupID, groupID))) {
            if (!CompareUniqueNetworkIDs(p->uniqueAddress, ourID)) {
                // Create a long packet request for EACH player
                CmdQSendLongPacket(p_packet, &p->uniqueAddress, retryTime, extraData,
                        p_callback);
            }
        }
    }

    DebugEnd();
}
Beispiel #30
0
T_void FormReportTextBox(T_TxtboxID TxtboxID)
{
    T_TxtboxStruct *p_Txtbox;
    T_formObjectStruct *p_object;
    E_TxtboxAction action;
    T_word16 i;

    DebugRoutine("FormReportBox");
    DebugCheck(TxtboxID != NULL);

    p_Txtbox = (T_TxtboxStruct*)TxtboxID;
    action = TxtboxGetAction();

    for (i = 0; i < MAX_FORM_OBJECTS; i++) {
        p_object = (T_formObjectStruct*)G_formObjectArray[i];
        if (!p_object)
            continue;
        if (p_object->objtype == FORM_OBJECT_TEXTBOX) {
            if ((T_TxtboxID)p_object->objID == TxtboxID) {
                /* found the button, call the callback routine */
                if (formcallback != NULL && action != 0) {
                    formcallback(FORM_OBJECT_TEXTBOX, action, p_object->numID);
                    /* leave the loop */
                    break;
                }
            }
        }
    }
    DebugEnd();
}