예제 #1
0
T_void EscapeMenuFormControl(
        E_formObjectType objtype,
        T_word16 objstatus,
        T_word32 objID)
{
    T_TxtboxID textID;

    DebugRoutine("EscapeMenuFormControl");

//    printf("ESC: %d %d %d\n", objtype, objstatus, objID);

    if ((objtype == FORM_OBJECT_BUTTON) && (objstatus == 2)) {
        if ((objID >= 4001) && (objID <= 4009)) {
            // Go to a menu
            EscapeMenuGotoState(objID - 4000);
        } else if ((objID >= 2001) && (objID <= 2009)) {
            // Enter pages
            EscapeMenuEnterState(objID - 2000);
        } else if ((objID >= 1000) && (objID <= 1999)) {
            // Assign a key by enering into it and putting
            // the ESC code into an assignment mode
            G_escMenuAssignKeyMap = objID - 1000;
            EscapeMenuEnterState(6);
            G_escMenuAssignMode = TRUE;
        } else if ((objID >= 7000) && (objID < (7000+ESC_MENU_NUM_OPTIONS))) {
            if (objID == 7000+ESC_MENU_MOUSE_TURN_SPEED) {
                // Set the range from 1 to 10 with 5 as the default
                G_escMenuToggleOptions[ESC_MENU_MOUSE_TURN_SPEED]+=10;
                if (G_escMenuToggleOptions[ESC_MENU_MOUSE_TURN_SPEED] > 200)
                    G_escMenuToggleOptions[ESC_MENU_MOUSE_TURN_SPEED] = 20;
                EscapeMenuSetOptions();
            } else if (objID == 7000+ESC_MENU_KEYBOARD_TURN_SPEED) {
                    // Set the range from 1 to 10 with 5 as the default
                    G_escMenuToggleOptions[ESC_MENU_KEYBOARD_TURN_SPEED]+=10;
                    if (G_escMenuToggleOptions[ESC_MENU_KEYBOARD_TURN_SPEED] > 200)
                        G_escMenuToggleOptions[ESC_MENU_KEYBOARD_TURN_SPEED] = 20;
                    EscapeMenuSetOptions();
            } else {
                // On/Off option hit
                G_escMenuToggleOptions[objID - 7000] ^= 1;
                EscapeMenuSetOptions();
            }
        } else if (objID == 301) {
            // Pressed the "No Key" button
            // Assign a zero for no key selected
            G_keys[G_escMenuAssignKeyMap] = 0;

            // End the assignment state
            EscapeMenuExitState();
            G_escMenuAssignMode = FALSE;
        } else if (objID == 300) {
            EscapeMenuExitState();
        } else if (objID == 5000) {
            EscapeMenuEnterState(8);
            G_escMenuAbortCount = 1;
        } else if (objID == 5001) {
            textID = FormFindObjID(5002);
            if (G_escMenuAbortCount==1) {
                ClientSyncSendActionAbortLevel();
                TxtboxSetData(textID, "Requesting to abort level.");
                G_escMenuAbortCount = 2;
            } else if (G_escMenuAbortCount == 2) {
                TxtboxSetData(textID, "Hit once more to force an abort...");
                G_escMenuAbortCount = 3;
            } else if (G_escMenuAbortCount == 3) {
                TxtboxSetData(textID, "Forced abort!");
                G_escMenuAbortCount = 4;

                /* Declare this as no longer an adventure */
                ClientSetAdventureNumber(0);

                /* Return to guild. */
                MouseRelativeModeOff();
                ClientSetNextPlace(20004, 0);
            }
        } else if (objID == 5999) {
            // Directly stop immediately and once
            ClientSyncSendActionAbortLevel();
        }
    }

    DebugEnd();
}
예제 #2
0
T_void ClientReceiveGameStartPacket(
           T_packetEitherShortOrLong *p_packet)
{
    T_gameStartPacket *p_start ;
    T_word16 i ;
    T_directTalkUniqueAddress ourAddress ;
    T_gameGroupID groupID ;
	T_word16 levelStatus = LEVEL_STATUS_STARTED;

    DebugRoutine("ClientReceiveGameStartPacket") ;

//puts("ClientReceiveGameStartPacket") ;
    p_start = (T_gameStartPacket *)(p_packet->data) ;

    /* Set up the time offset. */
    MapSetDayOffset(p_start->timeOfDay) ;

    /* Only consider the packet if we are in the same group. */
//printf("-- %d %d\n", ClientSyncGetGameGroupID(), p_start->groupID) ;
    groupID = ClientSyncGetGameGroupID() ;
    if (CompareGameGroupIDs(groupID, p_start->groupID))  {
        DirectTalkGetUniqueAddress(&ourAddress) ;

        /* See if we are in the list. */
        for (i=0; i<p_start->numPlayers; i++)  {
            if (memcmp(&ourAddress, &p_start->players[i], sizeof(ourAddress)) == 0)
                break ;
        }
		//Level complete packet
		if (p_start->firstLevel == LEVEL_STATUS_LEVEL_CODE_COMPLETE ||
			p_start->firstLevel == LEVEL_STATUS_LEVEL_CODE_SUCCESS)
		{
			G_CompletedPlayers++;
			if (p_start->firstLevel == LEVEL_STATUS_LEVEL_CODE_SUCCESS)
				G_SuccessPlayers++;

			//if we got complete packets from everyone
			if (G_CompletedPlayers == p_start->numPlayers)
			{
				levelStatus = LEVEL_STATUS_COMPLETE;
				if (G_SuccessPlayers > 0)
					levelStatus |= LEVEL_STATUS_SUCCESS;

				TownUIFinishedQuest(levelStatus, p_start->numPlayers, StatsGetCurrentQuestNumber());

				//once all players respond, quit the game
				ClientSyncSetGameGroupID(*DirectTalkGetNullBlankUniqueAddress());
				PeopleHereSetOurAdventure(0);
				PeopleHereSetOurState(PLAYER_ID_STATE_NONE);
			}
		}
		/* Did we find a match? */
		else if (i != p_start->numPlayers)  
		{
			//Reset number of players completed
			G_CompletedPlayers = 0;
			G_SuccessPlayers = 0;

			//puts("Matched") ;
			/* Yes, we are on the list in the ith position. */
			/* Set up the game setup and go. */
			ClientSyncSetNumberPlayers(p_start->numPlayers);
			ClientSetLoginId(i);

			/* Set up the next jump */
			ClientSetNextPlace(p_start->firstLevel, 0);
			ClientSetAdventureNumber(p_start->adventure);
			ClientSyncInitPlayersHere();

			/* Clear all the messages */
			MessageClear();

			/* Copy all the player address over to the peophere module. */
			for (i = 0; i < p_start->numPlayers; i++)
			{
				PeopleHereSetUniqueAddr(i, (&p_start->players[i]));
			}
		}
		else 
		{
			//puts("Not Matched") ;
			/* Make sure we are still in the guild and if so drop us. */
			if ((PeopleHereGetOurLocation() == PLAYER_ID_LOCATION_GUILD) &&
				(PeopleHereGetOurState() == PLAYER_ID_STATE_JOINING_GAME))  {
				/* Cancel that game we were joining, it left without us. */
				GuildUICancelJoinGame(NULL);

				/* Nope, we got excluded. */
				MessageAdd("Game started without you.");
			}
		}
    }

    DebugEnd() ;
}