Exemple #1
0
T_hash32 Hash32Create(T_word16 indexSize)
{
    T_hash32Struct *p_hash ;
    T_word16 i ;

    DebugRoutine("Hash32Create") ;
    DebugCheck((indexSize == 16) ||
               (indexSize == 32) ||
               (indexSize == 64) ||
               (indexSize == 128) ||
               (indexSize == 256) ||
               (indexSize == 512) ||
               (indexSize == 1024) ||
               (indexSize == 2048) ||
               (indexSize == 4096) ||
               (indexSize == 8192) ||
               (indexSize == 16384) ||
               (indexSize == 32768)) ;

    /* Allocate the header for the hash table. */
    p_hash = MemAlloc(sizeof(T_hash32Struct)) ;

    /* Make sure we got some memory. */
    DebugCheck(p_hash != NULL) ;
    if (p_hash)  {
        /* Allocate the space needed for the hash index. */
        p_hash->p_index = MemAlloc(sizeof(T_doubleLinkList *) * indexSize) ;
        DebugCheck(p_hash->p_index != NULL) ;
        if (p_hash->p_index)  {
            /* Go through the index and create a link list for each. */
            for (i=0; i<indexSize; i++)  {
                p_hash->p_index[i] = DoubleLinkListCreate() ;
                DebugCheck(p_hash->p_index[i] !=
                    DOUBLE_LINK_LIST_BAD) ;
            }

            /* Create a list of all the items. */
            p_hash->itemList= DoubleLinkListCreate() ;
            DebugCheck(p_hash->itemList != DOUBLE_LINK_LIST_BAD) ;

            /* Store the important size of the table. */
            p_hash->indexSize = indexSize ;
            p_hash->keyMask = indexSize-1 ;

            /* Tag this block as valid. */
            p_hash->tag = HASH32_TAG ;
        }
    }

    DebugEnd() ;

    return ((T_hash32)p_hash) ;
}
/**
 *  MouseInitialize sets up the mouse for all the different information
 *  it needs to hold.  It starts up with all default options and the cursor
 *  starts up hidden.
 *
 *  NOTE: 
 *  You can only call this routine once.  Call MouseFinish first
 *  if you need to re-initialize the mouse (but you shouldn't).
 *
 *<!-----------------------------------------------------------------------*/
T_void MouseInitialize(T_void)
{
    DebugRoutine("MouseInitialize") ;
    DebugCheck(MouseCheckInstalled() == TRUE) ;
    DebugCheck(F_MouseIsInitialized == FALSE) ;

    F_MouseIsInitialized = TRUE ;

    /* Note that the mouse module has been initialized. */
    G_mouseShowLevel = 0 ;

    /* Set the default options. */
    MouseSetEventOptions(MOUSE_EVENT_DEFAULT_OPTIONS) ;

    /* Allow the mouse to move all over the screen. */
    MouseReleaseBounds() ;

    /* Note that the current mouse state is idle. */
    G_mouseState = MOUSE_STATE_IDLE ;

    /* Put the mouse in the upper left hand corner. */
    MouseMoveTo(0, 0) ;

    /* Allocate a place to put stuff behind the mouse. */
    G_mouseScreen = GrScreenAlloc() ;

#ifdef DOS32
    IMouseInstallCallback() ;
#endif

    G_eventStack = DoubleLinkListCreate() ;
    DebugCheck(G_eventStack != DOUBLE_LINK_LIST_BAD) ;

    DebugEnd() ;
}
/* routine creates a linked list for tracking all effects in progress */
T_void EfxInit (T_void)
{
    DebugRoutine ("EfxInit");

    if (G_effectsInProgress != DOUBLE_LINK_LIST_BAD)
    {
        EfxFinish();
    }

    G_effectsInProgress=DoubleLinkListCreate();

    DebugEnd();
}
Exemple #4
0
T_void FormPush(T_void)
{
    T_formObjectID *p_formObjs;
    T_void *p_state;
    T_formVariousValues *p_values;

    DebugRoutine("FormPush");

    /* Make sure we have a list. */
    if (G_formStack == DOUBLE_LINK_LIST_BAD)
        G_formStack = DoubleLinkListCreate();

    /* Create a list of form objects to put on the stack. */
    p_formObjs = MemAlloc(sizeof(G_formObjectArray));
    DebugCheck(p_formObjs != NULL);
    memcpy(p_formObjs, G_formObjectArray, sizeof(G_formObjectArray));
    DoubleLinkListAddElementAtFront(G_formStack, p_formObjs);

    /* Clear the list of form objects */
    memset(G_formObjectArray, 0, sizeof(G_formObjectArray));

    /* Put the buttons on the list. */
    p_state = ButtonGetStateBlock();
    DoubleLinkListAddElementAtFront(G_formStack, p_state);

    /* Put the graphics on the list. */
    p_state = GraphicGetStateBlock();
    DoubleLinkListAddElementAtFront(G_formStack, p_state);

    /* Put the sliders on the list. */
    p_state = SliderGetStateBlock();
    DoubleLinkListAddElementAtFront(G_formStack, p_state);

    /* Put the text boxes on the list. */
    p_state = TxtboxGetStateBlock();
    DoubleLinkListAddElementAtFront(G_formStack, p_state);

    /* Put the callback and other flags in the list */
    p_values = MemAlloc(sizeof(T_formVariousValues));
    p_values->callback = formcallback;
    p_values->hasText = G_formHasTextBoxes;
    p_values->hasButtons = G_formHasButtons;
    DoubleLinkListAddElementAtFront(G_formStack, p_values);

    DebugEnd();
}
T_efxID EfxCreate (E_efxType type,        // type of effect
                   T_word32  Xorigin,     // x,y,z location of effect
                   T_word32  Yorigin,
                   T_word32  Zorigin,
                   T_word16  numberOf,    // number of objects to create
                   E_Boolean transparent, // should objects be transparent?
                   T_word32  extraData)   // extra data for some efx
{
    T_doubleLinkListElement myElement=NULL;
    T_efxStruct *p_efx;

    DebugRoutine ("EfxCreate");
    DebugCheck (type < EFX_UNKNOWN);

    if (type < EFX_UNKNOWN)
    {
        /* create a new efx structure */
        p_efx=(T_efxStruct *)MemAlloc(sizeof(T_efxStruct));
        DebugCheck (p_efx != NULL);

        if (p_efx != NULL)
        {
            /* initialize a double linked list to hold all newly created */
            /* object pointers */
            p_efx->objectList=DOUBLE_LINK_LIST_BAD;
            p_efx->objectList=DoubleLinkListCreate();
            DebugCheck (p_efx->objectList != DOUBLE_LINK_LIST_BAD);
            if (p_efx->objectList != DOUBLE_LINK_LIST_BAD)
            {
                /* init extra data */
                p_efx->reserved=TickerGet();
                p_efx->updateCallback=NULL;
                p_efx->Xorigin=Xorigin;
                p_efx->Yorigin=Yorigin;
                p_efx->Zorigin=Zorigin;
                p_efx->numberOf=numberOf;
                p_efx->duration=0;

                /* add this efx to global list */
                p_efx->myID=DoubleLinkListAddElementAtEnd(G_effectsInProgress,p_efx);

                /* call the effect set up routine */
                switch (type)
                {
                    case EFX_BLOOD_SHRAPNEL:
                    EfxCreateBloodSplat (p_efx->myID,transparent);
                    break;

                    case EFX_WALL_HIT:
                    EfxCreateGenericShrapnel (OBJECT_TYPE_WALL_HIT,
                                              p_efx->myID,
                                              FALSE,
                                              TRUE);
                    break;

                    case EFX_TELEPORT:
                    p_efx->duration=100;
                    EfxCreateGenericExplosion (OBJECT_TYPE_TELEPORT,
                                               p_efx->myID,
                                               TRUE,
                                               0);
                    AreaSoundCreate(
                        p_efx->Xorigin>>16,
                        p_efx->Yorigin>>16,
                        500,
                        255,
                        AREA_SOUND_TYPE_ONCE,
                        0,
                        AREA_SOUND_BAD,
                        NULL,
                        0,
                        SOUND_TELEPORT) ;

                    break;

                    case EFX_POWER_EXPLOSION:
                    EfxCreateGenericExplosion (OBJECT_TYPE_POWER_EXPLOSION,
                                               p_efx->myID,
                                               FALSE,
                                               0);
                    break;

                    case EFX_POISON_EXPLOSION:
                    EfxCreateGenericExplosion (OBJECT_TYPE_POISON_EXPLOSION,
                                               p_efx->myID,
                                               FALSE,
                                               0);
                    break;

                    case EFX_ACID_EXPLOSION:
                    EfxCreateGenericExplosion (OBJECT_TYPE_ACID_EXPLOSION,
                                               p_efx->myID,
                                               FALSE,
                                               0);
                    break;

                    case EFX_ELECTRIC_EXPLOSION:
                    EfxCreateGenericExplosion (OBJECT_TYPE_ELECTRIC_EXPLOSION,
                                               p_efx->myID,
                                               FALSE,
                                               -20);
                    break;

                    case EFX_MAGIC_EXPLOSION:
                    EfxCreateGenericExplosion (OBJECT_TYPE_MAGIC_EXPLOSION,
                                               p_efx->myID,
                                               FALSE,
                                               -20);
                    break;

                    case EFX_FIRE_EXPLOSION:
                    EfxCreateGenericExplosion (OBJECT_TYPE_FIRE_EXPLOSION,
                                               p_efx->myID,
                                               FALSE,
                                               -25);

                   EfxCreate (EFX_FLAME_SHRAPNEL,
                              p_efx->Xorigin,
                              p_efx->Yorigin,
                              p_efx->Zorigin,
                              3,
                              FALSE,
                              0);

                    break;


                    case EFX_FIRE_SHRAPNEL:
                    p_efx->duration=150;
                    EfxCreateGenericShrapnel(OBJECT_TYPE_FIRE_SHRAPNEL,
                                             p_efx->myID,
                                             TRUE,
                                             FALSE);
                    break;

                    case EFX_FLAME_SHRAPNEL:
                    p_efx->duration=80;
                    EfxCreateGenericShrapnel(OBJECT_TYPE_FLAME_SHRAPNEL,
                                             p_efx->myID,
                                             TRUE,
                                             FALSE);
                    break;

                    case EFX_BONE_SHRAPNEL:
                    p_efx->duration=80;
                    EfxCreateGenericShrapnel(OBJECT_TYPE_BONE_SHRAPNEL,
                                             p_efx->myID,
                                             TRUE,
                                             FALSE);
                    break;

                    case EFX_ACID_SHRAPNEL:
                    EfxCreateGenericShrapnel(OBJECT_TYPE_ACID_SHRAPNEL,
                                             p_efx->myID,
                                             FALSE,
                                             TRUE);
                    break;

                    case EFX_POISON_SHRAPNEL:
                    EfxCreateGenericShrapnel(OBJECT_TYPE_POISON_SHRAPNEL,
                                             p_efx->myID,
                                             FALSE,
                                             TRUE);
                    break;

                    case EFX_ELECTRIC_SHRAPNEL:
                    p_efx->duration=60;
                    EfxCreateGenericShrapnel(OBJECT_TYPE_ELECTRIC_SHRAPNEL,
                                             p_efx->myID,
                                             TRUE,
                                             FALSE);
                    break;

                    case EFX_MAGIC_SHRAPNEL:
                    p_efx->duration=60;
                    EfxCreateGenericShrapnel(OBJECT_TYPE_MANA_SHRAPNEL,
                                             p_efx->myID,
                                             TRUE,
                                             FALSE);
                    break;

                    default:
                    break;
                }
            }
T_void GuildUIStart  (T_word32 formNum)
{
    T_word16 i;

    const T_word16 arrowCoordX[4]=   { 97,  97,  200, 200};
    const T_word16 upArrowCoordY[4]= { 28,  77,  28,  77 };
    const T_word16 dnArrowCoordY[4]= { 67,  117, 67,  117};
    const T_word16 scrollBarY[4]=    { 38,  87,  38,  87 };
    const T_word16 dispWindowX1[4]=  { 6,   6,   109, 109};
    const T_word16 dispWindowY1[4]=  { 28,  77,  28,  77 };
    const T_word16 dispWindowX2[4]=  { 95,  95,  198, 198};
    const T_word16 dispWindowY2[4]=  { 75,  125, 75,  125};

    const E_TxtboxMode dispWindowMode[4]={Txtbox_MODE_SELECTION_BOX,
                                          Txtbox_MODE_VIEW_SCROLL_FORM,
                                          Txtbox_MODE_SELECTION_BOX,
                                          Txtbox_MODE_VIEW_SCROLL_FORM};

    const E_TxtboxJustify dispWindowJustify[4]={Txtbox_JUSTIFY_LEFT,
                                                Txtbox_JUSTIFY_LEFT,
                                                Txtbox_JUSTIFY_CENTER,
                                                Txtbox_JUSTIFY_CENTER};

    DebugRoutine ("GuildUIStart");

    /* load backdrop */
    G_backgroundPic=GraphicCreate (4,3,"UI/GUILD/GLDBACK");

    for (i=GUILD_GAME_LIST;i<=GUILD_MAPS_DESC;i++)
    {
        /* set up display textboxes */
        /* scroll bars and control arrows */
        G_displayBoxes[i]=TxtboxCreate (dispWindowX1[i],
                                        dispWindowY1[i],
                                        dispWindowX2[i],
                                        dispWindowY2[i],
                                        "FontTiny",
                                        0,
                                        0,
                                        FALSE,
                                        dispWindowJustify[i],
                                        dispWindowMode[i],
                                        NULL);
        TxtboxSetData (G_displayBoxes[i]," ");


        G_upButtons[i]=ButtonCreate (arrowCoordX[i],
                                     upArrowCoordY[i],
                                     "UI/COMMON/UPARROW",
                                     FALSE,
                                     0,
                                     NULL,
                                     GuildUIUpDisplay);
        ButtonSetData (G_upButtons[i],i);

        G_dnButtons[i]=ButtonCreate (arrowCoordX[i],
                                     dnArrowCoordY[i],
                                     "UI/COMMON/DNARROW",
                                     FALSE,
                                     0,
                                     NULL,
                                     GuildUIDnDisplay);
        ButtonSetData (G_dnButtons[i],i);

        if (i%2==0)
        {
            G_scrollBars[i]=GraphicCreate (arrowCoordX[i],
                                           scrollBarY[i],
                                           "UI/GUILD/SB1");
        }
        else
        {
            G_scrollBars[i]=GraphicCreate (arrowCoordX[i],
                                           scrollBarY[i],
                                           "UI/GUILD/SB1");
        }

        TxtboxSetScrollBarObjIDs(G_displayBoxes[i],G_upButtons[i],G_dnButtons[i],G_scrollBars[i]);
    }

    /* set up control buttons */
    G_joinButton=ButtonCreate (6,
                               127,
                               "UI/GUILD/JOIN",
                               FALSE,
                               KeyDual(KEY_SCAN_CODE_J,KEY_SCAN_CODE_ALT),
                               NULL,
                               GuildUIJoinGame);

    G_createButton=ButtonCreate (109,
                                 127,
                                 "UI/GUILD/CREATE",
                                 FALSE,
                                 KeyDual(KEY_SCAN_CODE_C,KEY_SCAN_CODE_ALT),
                                 NULL,
                                 GuildUICreateGame);

    /* build map list */
    GuildUIBuildMapList();

    /* initialize game/player listings */
    G_gameList=DoubleLinkListCreate();
    G_playerList=DoubleLinkListCreate();

    /* set up control callbacks */
    TxtboxSetCallback (G_displayBoxes[GUILD_MAPS_LIST],GuildDisplayMapInfo);
    TxtboxSetCallback (G_displayBoxes[GUILD_GAME_LIST],GuildDisplayGameInfo);

    /* notify server to send a list of active games */
    GuildUIRequestGameList();

    /* update graphics */
    GraphicUpdateAllGraphics();

    /* Set up what we are out. */
    ClientSyncSetGameGroupID(*DirectTalkGetNullBlankUniqueAddress()) ;
    PeopleHereSetOurAdventure(0) ;
    PeopleHereSetOurState(PLAYER_ID_STATE_NONE) ;

    /* Ask for people to show themselves. */
    PeopleHereReset() ;

    /* add journal help page if necessary */
    if (StatsPlayerHasNotePage(30)==FALSE &&
        StatsPlayerHasNotePage(0)==TRUE)
    {
        StatsAddPlayerNotePage(30);
    }

    DebugEnd();
}
/* routine builds a list of maps that the player can create */
static T_void GuildUIBuildMapList (T_void)
{
    T_byte8 stmp[64];
    T_byte8 stmp2[512];
    T_word16 mapIndex,mapKey;
    T_byte8 *dataIn;
    T_resource res;
    T_word32 size,tempSize;
    T_word32 inCnt,outCnt;
    T_byte8 charIn;
    T_word16 pass=0;
    T_word16 listcount=0;
    T_mapDescriptionStruct *p_mapStruct;
    T_byte8 *listdata=NULL,*temps=NULL;

    DebugRoutine ("GuildUIBuildMapList");

    /* initialize map listings */

    G_mapList=DoubleLinkListCreate();
    listcount=0;
    sprintf (stmp,"MAPDESC/DES%05d",listcount++);
    while (PictureExist(stmp))
    {
        /* alloc space for new map description block */
        p_mapStruct = MemAlloc (sizeof(T_mapDescriptionStruct));
        DebugCheck (p_mapStruct != NULL);

        /* lock in data 'text file' */
        dataIn=(T_byte8 *)PictureLockData (stmp,&res);
        size=ResourceGetSize(res);

        /* scan for newline */
        outCnt=inCnt=0;
        pass=0;

        while (inCnt < size)
        {
            /* get a character from input data */
            charIn=dataIn[inCnt++];
            stmp2[outCnt++]=charIn;

            /* check for temporary overflow */
            DebugCheck (outCnt<512);

            if (charIn=='\n')
            {
                /* reached 'end of line' */
                /* parse our temp string */
                stmp2[outCnt]='\0';
                outCnt=0;

                if (pass==0)
                {
                    /* getting map access (journal page needed ) */
                    sscanf (stmp2,"%d",&mapKey);
                    p_mapStruct->mapKey=mapKey;

                }
                else if (pass==1)
                {
                    /* getting map number */
                    sscanf (stmp2,"%d",&mapIndex);
                    p_mapStruct->mapIndex=mapIndex;

                }
                else if (pass==2)
                {
                    /* getting map name */
                    tempSize=strlen(stmp2);
                    /* alloc string */
                    p_mapStruct->name=MemAlloc(tempSize+1);
                    strcpy (p_mapStruct->name,stmp2);
                    p_mapStruct->name[strlen(p_mapStruct->name)-2]='\0';
                }
                else if (pass==3)
                {
                    /* getting map description */
                    tempSize=strlen(stmp2);
                    /* alloc string */
                    p_mapStruct->description=MemAlloc(tempSize+1);
                    strcpy (p_mapStruct->description,stmp2);

                }
                else
                {
                    break;
                }

                pass++;
            }
        }

        PictureUnlockAndUnfind(res);

        /* add our structure to global list */
        DoubleLinkListAddElementAtEnd (G_mapList,p_mapStruct);

        /* build our list of maps on the fly */
        if (GuildUIPlayerCanVisitMap(listcount))
        {
            sprintf (stmp,"^009%s",p_mapStruct->name);
        }
        else
        {
            sprintf (stmp,"^010%s",p_mapStruct->name);
        }

        /* add stmp to list */
        tempSize=strlen(stmp);
        if (listdata!=NULL) tempSize+=strlen(listdata);
        temps=MemAlloc(tempSize+2);
        if (listdata == NULL) sprintf (temps,"%s\r",stmp);
        else sprintf (temps,"%s%s\r",listdata,stmp);
        if (listdata != NULL) MemFree (listdata);
        listdata=temps;
        listdata[strlen(listdata)]='\0';

        /* increment map description file name */
        sprintf (stmp,"MAPDESC/DES%05d",listcount++);
    }

    TxtboxSetData (G_displayBoxes[GUILD_MAPS_LIST],listdata);
    TxtboxCursBot(G_displayBoxes[GUILD_MAPS_LIST]);
    TxtboxBackSpace (G_displayBoxes[GUILD_MAPS_LIST]);
    TxtboxCursTop(G_displayBoxes[GUILD_MAPS_LIST]);
    MemFree(listdata);

    GuildDisplayMapInfo (G_displayBoxes[GUILD_MAPS_LIST]);

    DebugEnd();
}