X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fevents.c;h=19c47763e05236c491659fbd15d9b772ecf204f1;hb=2f5368f25e34c02cb5ff7a012aa96198442231cb;hp=96f4624df9df575da6d48ab02bf7d83124203812;hpb=3494549d6f5c8d1d5497ec7eb9fa80a7ca6579ee;p=rocksndiamonds.git diff --git a/src/events.c b/src/events.c index 96f4624d..19c47763 100644 --- a/src/events.c +++ b/src/events.c @@ -79,7 +79,7 @@ static boolean NextValidEvent(Event *event) void EventLoop(void) { - while(1) + while (1) { if (PendingEvent()) /* got event */ { @@ -219,7 +219,7 @@ void ClearPlayerAction() /* simulate key release events for still pressed keys */ key_joystick_mapping = 0; - for (i=0; i string_len) + return FALSE; + + return (strcmp(&string[string_len - suffix_len], suffix) == 0); +} + +#define MAX_CHEAT_INPUT_LEN 32 + +static void HandleKeysCheating(Key key) +{ + static char cheat_input[2 * MAX_CHEAT_INPUT_LEN + 1] = ""; + char letter = getCharFromKey(key); + int cheat_input_len = strlen(cheat_input); + int i; + + if (letter == 0) + return; + + if (cheat_input_len >= 2 * MAX_CHEAT_INPUT_LEN) + { + for (i = 0; i < MAX_CHEAT_INPUT_LEN + 1; i++) + cheat_input[i] = cheat_input[MAX_CHEAT_INPUT_LEN + i]; + + cheat_input_len = MAX_CHEAT_INPUT_LEN; + } + + cheat_input[cheat_input_len++] = letter; + cheat_input[cheat_input_len] = '\0'; + +#if 0 + printf("::: '%s' [%d]\n", cheat_input, cheat_input_len); +#endif + +#if 1 + if (is_string_suffix(cheat_input, ":insert solution tape")) + InsertSolutionTape(); +#else + if (is_string_suffix(cheat_input, ":ist")) + InsertSolutionTape(); +#endif + +#ifdef DEBUG + else if (is_string_suffix(cheat_input, ":dump tape")) + DumpTape(&tape); + else if (is_string_suffix(cheat_input, ".q")) + for (i = 0; i < MAX_INVENTORY_SIZE; i++) + if (local_player->inventory_size < MAX_INVENTORY_SIZE) + local_player->inventory_element[local_player->inventory_size++] = + EL_DYNAMITE; +#endif +} + void HandleKey(Key key, int key_status) { int joy = 0; @@ -472,7 +533,7 @@ void HandleKey(Key key, int key_status) static boolean bomb_placed[MAX_PLAYERS] = { FALSE,FALSE,FALSE,FALSE }; int pnr; - for (pnr=0; pnrinventory_size < MAX_INVENTORY_SIZE) - local_player->inventory_element[local_player->inventory_size++] = - EL_DYNAMITE; - } - - break; - - #if 0 case KSYM_z: { int i; - for(i=0; i