/* determines if the store will buy a specific type of object */
E_Boolean StoreWillBuy (E_equipObjectTypes type)
{
    E_Boolean willbuy=FALSE;
    DebugRoutine ("StoreWillBuy");
    DebugCheck (type<EQUIP_OBJECT_TYPE_UNKNOWN);

    willbuy=G_storeWillBuy[type];

    DebugEnd();
    return (willbuy);
}
Exemple #2
0
T_formObjectID FormAddTextButton(
        T_word16 x1,
        T_word16 y1,
        T_byte8 *data,
        T_byte8 *picturename,
        T_byte8 *fontname,
        T_byte8 fcolor,
        T_byte8 bcolor,
        E_Boolean toggletype,
        T_word16 hotkey,
        T_word32 idnum)
{
    T_word16 i;
    T_buttonID buttonID;

    DebugRoutine("FormAddTextButton");
    DebugCheck(picturename!=NULL);

    G_formHasButtons = TRUE;
    for (i = 0; i < MAX_FORM_OBJECTS; i++) {
        /* find an empty slot */
        if (G_formObjectArray[i] == NULL ) {
            /* found one, create a new button */
            buttonID = ButtonCreate(x1, y1, picturename, toggletype, hotkey,
                    NULL, NULL );
            ButtonSetFont(buttonID, fontname);
            ButtonSetText(buttonID, data, fcolor);
            /* now that a button has been created, make an objstruct for it */
            G_formObjectArray[i] = FormCreateObject(FORM_OBJECT_BUTTON,
                    (T_formObjectID)buttonID, idnum);
            /* we made a new object struct, break from the loop */
            break;
        }
    }

    /* make sure we haven't exceeded any limits */
    DebugCheck(i!=MAX_FORM_OBJECTS);
    DebugEnd();
    /* return the ID for the object created */
    return (G_formObjectArray[i]);
}
Exemple #3
0
T_void *FileLoad(T_byte8 *p_filename, T_word32 *p_size)
{
    T_byte8 *p_data ;
    T_file file ;

    DebugRoutine("FileLoad") ;
    DebugCheck(p_filename != NULL) ;
    DebugCheck(p_size != NULL) ;

    /* See how big the file is so we know how much memory to allocate. */
    *p_size = FileGetSize(p_filename) ;
#ifdef COMPILE_OPTION_FILE_OUTPUT
printf("!A 1 file_%s\n", p_filename) ;
printf("!A 1 file_r_%s\n", DebugGetCallerName()) ;
#endif
    if (*p_size)  {
        /* Allocate the memory for the file. */
        p_data = MemAlloc(*p_size) ;

        DebugCheck(p_data != NULL) ;

        /* Make sure we got the memory. */
        if (p_data != NULL)  {
            /* If memory was allocated, read in the file into this memory. */
            file = FileOpen(p_filename, FILE_MODE_READ) ;
            FileRead(file, p_data, *p_size) ;
            FileClose(file) ;
        } else {
            /* If memory was not allocated, return with a zero length. */
            *p_size = 0 ;
        }
    } else {
        *p_size = 0 ;
        p_data = NULL ;
    }

    DebugEnd() ;

    /* Return the pointer to the data. */
    return p_data ;
}
Exemple #4
0
T_void FileClose(T_file file)
{
    DebugRoutine("FileClose") ;
    DebugCheck(file != FILE_BAD) ;

    close(file) ;

    /* Decrement the number of open files. */
    G_numberOpenFiles-- ;

    DebugEnd();
}
Exemple #5
0
T_word16 SliderGetValue (T_sliderID sliderID)
{
   T_sliderStruct *p_slider;

   DebugRoutine ("SliderSetValue");
   DebugCheck (sliderID != NULL);

   p_slider=(T_sliderStruct *)sliderID;
   DebugEnd();

   return (p_slider->curval);
}
Exemple #6
0
T_void SliderSetCallBack (T_sliderID sliderID, T_sliderHandler sliderhandler)
{
	T_sliderStruct *p_slider;

	DebugRoutine ("SliderSetCallBack");
	DebugCheck (sliderID != NULL);

	p_slider = (T_sliderStruct *)sliderID;
	p_slider->callback=sliderhandler;

	DebugEnd();
}
Exemple #7
0
/**
 *  DoubleLinkListGetLast  returns the last  element in a
 *  double link list.
 *
 *  @param linkList -- List to get last element
 *
 *  @return Last  element, or
 *      DOUBLE_LINK_LIST_ELEMENT_BAD if none.
 *
 *<!-----------------------------------------------------------------------*/
T_doubleLinkListElement DoubleLinkListGetLast(T_doubleLinkList linkList)
{
    T_doubleLinkListStruct *p_head ;
    T_doubleLinkListElement last = DOUBLE_LINK_LIST_ELEMENT_BAD ;

    DebugRoutine("DoubleLinkListGetLast") ;
    DebugCheck(linkList != DOUBLE_LINK_LIST_BAD) ;

    /* Get a quick pointer. */
    p_head = (T_doubleLinkListStruct *)linkList ;
    DebugCheck(p_head->tag == DOUBLE_LINK_LIST_TAG) ;

    if (p_head)  {
        if (p_head->p_previous != p_head)
            last = (T_doubleLinkListElement)p_head->p_previous ;
    }

    DebugEnd() ;

    return last ;
}
BOOL GetLength64(CString filename, _int64 &size)
{
  WIN32_FIND_DATA findFileData;
  HANDLE hFind = FindFirstFile(filename, &findFileData);
  if (hFind == INVALID_HANDLE_VALUE)
    return FALSE;
  DebugCheck(FindClose(hFind));

  size=((_int64)findFileData.nFileSizeHigh<<32)+findFileData.nFileSizeLow;

  return TRUE;
}
/**
 *  ICmdQClearPort removes all outgoing packets for the current port
 *  and all incoming packets, too.  ACK packets are left alone.
 *
 *  NOTE: 
 *  Make sure that this routine is only called when all communications
 *  are finalized.
 *
 *<!-----------------------------------------------------------------------*/
static T_void ICmdQClearPort(T_void)
{
    T_word16 i ;
    T_cmdQStruct *p_cmdQ ;
    T_cmdQPacketStruct *p_packet ;
    T_packetLong packet ;

    DebugRoutine("ICmdQClearPort") ;

    /* First, read in all the incoming packets (and ignore them). */
    while (PacketGet(&packet) == 0)
        { }

    /* Catch all the outgoing packets. */
    /* Go through all the queues looking for packets to remove. */
    for (i=1; i<PACKET_COMMAND_MAX; i++)  {
        for (;;)  {
            p_cmdQ = &G_activeCmdQList[i] ;
            p_packet = p_cmdQ->last ;
            if (p_packet != NULL)  {
#ifndef NDEBUG
                /* Check for the tag. */
                if (strcmp(p_packet->tag, "CmQ") != 0)  {
                    printf("Bad packet %p\n", p_packet) ;
                    DebugCheck(FALSE) ;
                }
#endif
                /* Found a packet, remove it. */
                p_cmdQ->last = p_packet->prev ;
                if (p_cmdQ->last == NULL)
                    p_cmdQ->first = NULL ;
                else {
                    p_cmdQ->last->next = NULL ;
                }

#ifndef NDEBUG
                /* Mark the packet as gone. */
                strcpy(p_packet->tag, "c_q") ;
                G_packetsFree++ ;
#endif

                /* Delete it. */
                MemFree(p_packet) ;
            } else {
                /* No packet.  Stop looping on this queue. */
                break ;
            }
        }
    }

    DebugEnd() ;
}
Exemple #10
0
/**
 *  DoubleLinkListElementGetData pulls out the data pointer from a
 *  double link list element.
 *
 *  @param element -- Element to get data out of
 *
 *  @return Found data pointer on element
 *
 *<!-----------------------------------------------------------------------*/
T_void *DoubleLinkListElementGetData(T_doubleLinkListElement element)
{
    T_void *p_data ;
    T_doubleLinkListStruct *p_node ;

    DebugRoutine("DoubleLinkListElementGetData") ;
    DebugCheck(element != DOUBLE_LINK_LIST_ELEMENT_BAD) ;

    /* Get a quick pointer. */
    p_node = (T_doubleLinkListStruct *)element;
    DebugCheck(p_node->tag != DOUBLE_LINK_LIST_DEAD_TAG);
    DebugCheck(p_node->tag == DOUBLE_LINK_LIST_TAG) ;

    /* Make sure we are not trying to get data from the head. */
    DebugCheck(p_node->p_head != p_node) ;

    p_data = p_node->countOrData.p_data ;

    DebugEnd() ;

    return p_data ;
}
Exemple #11
0
E_Boolean SMCLogoffCheckFlag(
              T_stateMachineHandle handle,
              T_word32 flag)
{
    E_Boolean stateFlag = FALSE ;        /* Return status will default */
                                         /* to FALSE. */
    T_SMCLogoffData *p_data ;

    DebugRoutine("SMCLogoffCheckFlag") ;
    DebugCheck(G_smHandle != STATE_MACHINE_HANDLE_BAD) ;

    p_data = (T_SMCLogoffData *)StateMachineGetExtraData(G_smHandle) ;
    DebugCheck(p_data != NULL) ;

    /* If a valid flag, get the state */
    DebugCheck(flag < SMCLOGOFF_FLAG_UNKNOWN) ;
    if (flag < SMCLOGOFF_FLAG_UNKNOWN)
        stateFlag = p_data->stateFlags[flag] ;

    DebugEnd() ;
    return stateFlag ;
}
Exemple #12
0
/**
 *  DoubleLinkListAddElementAtFront adds a new element at the front of
 *  the link list.
 *
 *  @param linkList -- Handle to link list to insert item
 *  @param p_data -- Pointer to element data
 *
 *<!-----------------------------------------------------------------------*/
T_doubleLinkListElement DoubleLinkListAddElementAtFront(
                            T_doubleLinkList linkList,
                            T_void *p_data)
{
    T_doubleLinkListStruct *p_head ;
    T_doubleLinkListStruct *p_element ;

    DebugRoutine("DoubleLinkListAddElementAtFront") ;
    DebugCheck(linkList != DOUBLE_LINK_LIST_BAD) ;

    /* Get a quick pointer. */
    p_head = (T_doubleLinkListStruct *)linkList ;
    DebugCheck(p_head->tag == DOUBLE_LINK_LIST_TAG) ;
    DebugCheck(p_head->p_head == p_head) ;

    if (p_head)  {
        /* Create a new element. */
#ifdef COMPILE_OPTION_DOUBLE_LINK_OUTPUT
printf("!A 1 node_%s\n", DebugGetCallerName()) ;
#endif
        p_element = ICreateNode() ;
        DebugCheck(p_element != NULL) ;

        if (p_element)  {
            /* Attach the data to the element. */
            p_element->countOrData.p_data = p_data ;
            p_element->p_previous = p_head ;
            p_element->p_next = p_head->p_next ;
            p_element->p_head = p_head ;
            p_head->p_next->p_previous = p_element ;
            p_head->p_next = p_element ;
            p_head->countOrData.count++ ;
        }
    }

    DebugEnd() ;

    return ((T_doubleLinkListElement)p_element) ;
}
Exemple #13
0
T_void SMCLogoffTimeoutEnter(
           T_stateMachineHandle handle,
           T_word32 extraData)
{
    T_SMCLogoffData *p_data ;

    DebugRoutine("SMCLogoffTimeoutEnter") ;

    p_data = (T_SMCLogoffData *)StateMachineGetExtraData(G_smHandle) ;
    DebugCheck(p_data != NULL) ;

    DebugEnd() ;
}
Exemple #14
0
global void DoneButtons(void)
{
    int z;

    for ( z = 0; z < UnitButtonCount; z++ ) {
	DebugCheck( !UnitButtonTable[z] );
	free( UnitButtonTable[z]->ValueStr );
	free( UnitButtonTable[z]->Hint );
	free( UnitButtonTable[z]->UMask );
	free( UnitButtonTable[z] );
    }
    UnitButtonCount = 0;
};
/**
 *  This routine starts up the people here module.
 *
 *<!-----------------------------------------------------------------------*/
T_void PeopleHereInitialize(T_void)
{
    DebugRoutine("PeopleHereInitialize");
    DebugCheck(G_init == FALSE);

    G_init = TRUE;

    /* Clear list of playerIDSelf structures. */
    memset(G_peopleList, 0, sizeof(G_peopleList));
    G_ourState = PLAYER_ID_STATE_NONE;

    DebugEnd();
}
/**
 *  People here finish cleans up the people here module by removing
 *  the list of playerIDSelf structures.
 *
 *<!-----------------------------------------------------------------------*/
T_void PeopleHereFinish(T_void)
{
    DebugRoutine("PeopleHereFinish");
    DebugCheck(G_init == TRUE);

    /* Clear the list */
    memset(G_peopleList, 0, sizeof(G_peopleList));

    G_init = FALSE;
    G_ourState = PLAYER_ID_STATE_NONE;

    DebugEnd();
}
/**
 *  CmdQFinish unallocates any memory or structures that are no longer
 *  need by the CmdQ module.
 *
 *<!-----------------------------------------------------------------------*/
T_void CmdQFinish(T_void)
{
    DebugRoutine("CmdQFinish") ;
    DebugCheck(G_init == TRUE) ;

    /* Note that we are now finished. */
    G_init = FALSE ;

#ifdef COMPILE_OPTION_CREATE_PACKET_DATA_FILE
    fclose(G_packetFile) ;
#endif

    DebugEnd() ;
}
Exemple #18
0
T_file FileOpen(T_byte8 *p_filename, E_fileMode mode)
{
    T_file file ;
    static T_word32 fileOpenModes[4] = {
         O_RDONLY|O_BINARY,
         O_WRONLY|O_CREAT|O_BINARY,
         O_RDWR|O_APPEND|O_CREAT|O_BINARY,
         O_RDWR|O_CREAT|O_BINARY
    } ;

    DebugRoutine("FileOpen") ;
    DebugCheck(p_filename != NULL) ;
    DebugCheck(mode < FILE_MODE_UNKNOWN) ;
    DebugCheck(G_numberOpenFiles < MAX_FILES) ;

    file = open(p_filename, fileOpenModes[mode], S_IREAD|S_IWRITE) ;
    if (file != FILE_BAD)
        G_numberOpenFiles++ ;

    DebugEnd() ;

    return file ;
}
Exemple #19
0
T_void SMCLogoffFinish(T_void)
{
    DebugRoutine("SMCLogoffFinish") ;

    DebugCheck(G_init == TRUE) ;

    /* Destroy the state machine. */
    StateMachineDestroy(G_smHandle) ;
    G_smHandle = STATE_MACHINE_HANDLE_BAD ;

    G_init = FALSE ;

    DebugEnd() ;
}
Exemple #20
0
T_void SMCLogoffExitEnter(
           T_stateMachineHandle handle,
           T_word32 extraData)
{
    T_SMCLogoffData *p_data ;

    DebugRoutine("SMCLogoffExitEnter") ;

    p_data = (T_SMCLogoffData *)StateMachineGetExtraData(G_smHandle) ;
    DebugCheck(p_data != NULL) ;

    SMMainSetFlag(SMMAIN_FLAG_LOGOFF_COMPLETE, TRUE) ;
    DebugEnd() ;
}
/**
 *  ClientReceiveLoginPacket tells the client that the server has just
 *  allowed the client to login.
 *
 *<!-----------------------------------------------------------------------*/
T_void ClientReceivePlaceStartPacket(T_packetEitherShortOrLong *p_packet)
{
    T_placeStartPacket *p_start ;
    extern E_Boolean G_serverActive ;

    DebugRoutine("ClientReceivePlaceStartPacket") ;

    DebugCheck (ClientIsInit() == TRUE);

    p_start = (T_placeStartPacket *)p_packet->data ;
    ClientStartPlayer(p_start->objectId, p_start->loginId) ;

    DebugEnd() ;
}
Exemple #22
0
T_void SMCLogoffSaveCharacterEnter(
           T_stateMachineHandle handle,
           T_word32 extraData)
{
    T_SMCLogoffData *p_data ;
    T_characterBlock *p_charBlock ;
    T_void *p_stats ;
    T_word32 size ;
    T_word16 slot ;

    DebugRoutine("SMCLogoffSaveCharacterEnter") ;

    p_data = (T_SMCLogoffData *)StateMachineGetExtraData(G_smHandle) ;
    DebugCheck(p_data != NULL) ;

    SMCLogoffSetFlag(
        SMCLOGOFF_FLAG_SAVE_COMPLETE,
        FALSE) ;
    SMCLogoffSetFlag(
        SMCLOGOFF_FLAG_TIMEOUT,
        FALSE) ;
    SMCLogoffSetFlag(
        SMCLOGOFF_FLAG_SAVE_ERROR,
        FALSE) ;

    /* No matter what type of server we are on, save this one. */
    StatsSaveCharacter(StatsGetActive()) ;

    if (ClientIsServerBased())  {
//    if (CommCheckClientAndServerExist() == FALSE)  {
        /* Send the character up to the server. */
        p_stats = StatsGetAsDataBlock(&size) ;
        p_charBlock = MemAlloc(sizeof(T_characterBlock) + size) ;
        slot = p_charBlock->slot = StatsGetActive() ;
        StatsGetPassword(slot, p_charBlock->password) ;
        p_charBlock->size = size ;
        memcpy(p_charBlock->charData, p_stats, size) ;
        MemFree(p_stats) ;

        MemoryTransfer(
            p_charBlock,
            size + sizeof(T_characterBlock),
            ISaveUploadComplete,
            MEMORY_BLOCK_CHARACTER_DATA) ;
    }

//ClientLogoff() ;

    DebugEnd() ;
}
Exemple #23
0
/**
 *  DoubleLinkListRemoveElement removes  an element from a link list.
 *  This routine also returns the data that was attached to this element.
 *
 *  @param element --  removes the element from the list.
 *
 *  @return Previously attached node data
 *
 *<!-----------------------------------------------------------------------*/
T_void *DoubleLinkListRemoveElement(T_doubleLinkListElement element)
{
    T_doubleLinkListStruct *p_node ;
    T_void *p_data = NULL ;

    DebugRoutine("DoubleLinkListRemoveElement") ;
    DebugCheck(element != DOUBLE_LINK_LIST_ELEMENT_BAD) ;

    /* Get a quick pointer. */
    p_node = (T_doubleLinkListStruct *)element;
    DebugCheck(p_node->tag == DOUBLE_LINK_LIST_TAG) ;

    /* Make sure we are not trying to delete the head. */
    DebugCheck(p_node->p_head != p_node) ;

    if (p_node)  {
        /* Detach the node from the list. */
        p_node->p_next->p_previous = p_node->p_previous ;
        p_node->p_previous->p_next = p_node->p_next ;

        /* Get the attached data. */
        p_data = p_node->countOrData.p_data ;

        /* Decrement the count of items on this list. */
        p_node->p_head->countOrData.count-- ;

        /* Release the node from memory. */
#ifdef COMPILE_OPTION_DOUBLE_LINK_OUTPUT
printf("!F 1 node_%s\n", DebugGetCallerName()) ;
#endif
        IDestroyNode(p_node) ;
    }

    DebugEnd() ;

    return p_data ;
}
Exemple #24
0
T_formObjectID FormAddText(
        T_word16 x1,
        T_word16 y1,
        T_byte8 *data,
        T_byte8 *fontname,
        T_byte8 fcolor,
        T_byte8 bcolor,
        T_word32 idnum)
{
    T_word16 i;
    T_textID textID;

    DebugRoutine("FormAddText");
    DebugCheck(fontname!=NULL);
    DebugCheck(data!=NULL);

    for (i = 0; i < MAX_FORM_OBJECTS; i++) {
        /* find an empty slot */
        if (G_formObjectArray[i] == NULL ) {
            /* found one, create a new button */
            textID = TextCreate(x1, y1, data);
            TextSetFont(textID, fontname);
            TextSetColor(textID, fcolor, bcolor);
            /* now that a button has been created, make an objstruct for it */
            G_formObjectArray[i] = FormCreateObject(FORM_OBJECT_TEXT,
                    (T_formObjectID)textID, idnum);
            /* we made a new object struct, break from the loop */
            break;
        }
    }

    /* make sure we haven't exceeded any limits */
    DebugCheck(i!=MAX_FORM_OBJECTS);
    DebugEnd();
    /* return the ID for the object created */
    return (G_formObjectArray[i]);
}
Exemple #25
0
T_void SliderSetValue (T_sliderID sliderID, T_word16 value)
{
   T_byte8 stmp[64];
   T_sliderStruct *p_slider;

   DebugRoutine ("SliderSetValue");
   DebugCheck (sliderID != NULL);

   p_slider=(T_sliderStruct *)sliderID;

   p_slider->curval=value;
   SliderDraw (sliderID);

   DebugEnd();
}
Exemple #26
0
T_void SMCLogoffDataFinish(T_stateMachineHandle handle)
{
    T_SMCLogoffData *p_data ;

    DebugRoutine("SMCLogoffDataFinish") ;

    /* Destroy the extra data attached to the state machine. */
    p_data = (T_SMCLogoffData *)StateMachineGetExtraData(G_smHandle) ;

    DebugCheck(p_data != NULL) ;
    MemFree(p_data) ;
    StateMachineSetExtraData(handle, NULL) ;

    DebugEnd() ;
}
Exemple #27
0
T_void SMCLogoffDataInit(T_stateMachineHandle handle)
{
    T_SMCLogoffData *p_data ;

    DebugRoutine("SMCLogoffDataInit") ;

    p_data = MemAlloc(sizeof(T_SMCLogoffData)) ;

    DebugCheck(p_data != NULL) ;
    memset(p_data, 0, sizeof(T_SMCLogoffData)) ;

    StateMachineSetExtraData(handle, p_data) ;

    DebugEnd() ;
}
Exemple #28
0
IrcQmlChannelGroup::IrcQmlChannelGroup (QObject *parent, QDeclarativeView * view)
  :QObject (parent),
   dView (view),
   qmlObject (0),
   debugTimer (this),
   chanLinkPrefix 
     ("chanlink://channel_"),
   channelMaskActive 
     ("["
         "<span "
           "style=\"color: red\"; font-weight: bold\">"
           " ! "
         "</span>"
       "%1] "),
   channelMaskIdle 
     ("[%1] ")
{
  activeIcon = QIcon (":/ircicons/active.png");
  quietIcon = QIcon (":/ircicons/inactive.png");
  connect (&debugTimer, SIGNAL (timeout()),
           this, SLOT (DebugCheck()));
  debugTimer.start (30*1000);
  QTimer::singleShot (10000, this, SLOT (DebugCheck()));
}
Exemple #29
0
/**
 *  DoubleLinkListFreeAndDestroy goes through a linked list and does a
 *  MemFree on each of the data elements and then calls Destroy on the
 *  whole list.
 *
 *  @param linkList -- Handle to link list to destroy
 *
 *<!-----------------------------------------------------------------------*/
T_void DoubleLinkListFreeAndDestroy(T_doubleLinkList *linkList)
{
    T_doubleLinkListStruct *p_head ;
    T_doubleLinkListStruct *p_at ;
    T_doubleLinkListStruct *p_next ;

    DebugRoutine("DoubleLinkListFreeAndDestroy") ;
    DebugCheck(linkList != DOUBLE_LINK_LIST_BAD) ;

#ifdef COMPILE_OPTION_DOUBLE_LINK_OUTPUT
printf("!F 1 list_%s\n", DebugGetCallerName()) ;
#endif
    /* Get a quick pointer. */
    p_head = (T_doubleLinkListStruct *)(*linkList) ;
    DebugCheck(p_head->tag == DOUBLE_LINK_LIST_TAG) ;

    /* Remove all items in the list.  Hopefully */
    /* all attached data is not allocated memory or is being */
    /* managed by someone else. */
    if (p_head)  {
        p_at = p_head->p_next ;
        while ((p_at != p_head) && (p_at != DOUBLE_LINK_LIST_ELEMENT_BAD))  {
            p_next = p_at->p_next ;
            if (p_at->countOrData.p_data != NULL)  {
                MemFree(p_at->countOrData.p_data) ;
                p_at->countOrData.p_data = NULL ;
            }
            p_at = p_next ;
        }
    }

    DoubleLinkListDestroy(*linkList) ;
    linkList = DOUBLE_LINK_LIST_BAD ;

    DebugEnd() ;
}
Exemple #30
0
T_stateMachineHandle SMCLogoffInitialize(T_void)
{
    DebugRoutine("SMCLogoffInitialize") ;

    DebugCheck(G_init == FALSE) ;

    G_init = TRUE ;

    G_smHandle = StateMachineCreate(&SMCLogoffStateMachine) ;
    StateMachineGotoState(G_smHandle, SMCLOGOFF_INITIAL_STATE) ;

    DebugEnd() ;

    return G_smHandle ;
}