X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ftools.c;h=a300c84f9ba46c546ba0c694c023655221c06965;hb=87af02f45b63b849773c7f830d69136d130acca0;hp=fe5c9f690cc89031b9db3b3f4998170e6cca3191;hpb=a1bc27d0855dc6fa72c4c361fc1671b2dcc6547b;p=rocksndiamonds.git diff --git a/src/tools.c b/src/tools.c index fe5c9f69..a300c84f 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1775,6 +1775,9 @@ int REQ_in_range(int x, int y) return 0; } +#define MAX_REQUEST_LINES 13 +#define MAX_REQUEST_LINE_LEN 7 + boolean Request(char *text, unsigned int req_state) { int mx, my, ty, result = -1; @@ -1803,31 +1806,35 @@ boolean Request(char *text, unsigned int req_state) ClearRectangle(drawto, DX, DY, DXSIZE, DYSIZE); /* write text for request */ - for(ty=0; ty<13; ty++) + for(ty=0; ty < MAX_REQUEST_LINES; ty++) { + char text_line[MAX_REQUEST_LINE_LEN + 1]; int tx, tl, tc; - char txt[256]; if (!*text) break; - for(tl=0,tx=0; tx<7; tl++,tx++) + for(tl=0,tx=0; tx < MAX_REQUEST_LINE_LEN; tl++,tx++) { tc = *(text + tx); - if (!tc || tc == 32) + if (!tc || tc == ' ') break; } + if (!tl) { text++; ty--; continue; } - sprintf(txt, text); - txt[tl] = 0; - DrawTextExt(drawto, DX + 51 - (tl * 14)/2, DY + 8 + ty * 16, - txt, FS_SMALL, FC_YELLOW); - text += tl + (tc == 32 ? 1 : 0); + + strncpy(text_line, text, tl); + text_line[tl] = 0; + + DrawTextExt(drawto, DX + 50 - (tl * 14)/2, DY + 8 + ty * 16, + text_line, FS_SMALL, FC_YELLOW); + + text += tl + (tc == ' ' ? 1 : 0); } if (req_state & REQ_ASK) @@ -1959,7 +1966,7 @@ boolean Request(char *text, unsigned int req_state) break; case EVENT_KEYRELEASE: - key_joystick_mapping = 0; + ClearPlayerAction(); break; default: @@ -2047,7 +2054,12 @@ unsigned int CloseDoor(unsigned int door_state) unsigned int GetDoorState() { - return(MoveDoor(DOOR_GET_STATE)); + return MoveDoor(DOOR_GET_STATE); +} + +unsigned int SetDoorState(unsigned int door_state) +{ + return MoveDoor(door_state | DOOR_SET_STATE); } unsigned int MoveDoor(unsigned int door_state) @@ -2061,6 +2073,16 @@ unsigned int MoveDoor(unsigned int door_state) if (door_state == DOOR_GET_STATE) return(door1 | door2); + if (door_state & DOOR_SET_STATE) + { + if (door_state & DOOR_ACTION_1) + door1 = door_state & DOOR_ACTION_1; + if (door_state & DOOR_ACTION_2) + door2 = door_state & DOOR_ACTION_2; + + return(door1 | door2); + } + if (door1 == DOOR_OPEN_1 && door_state & DOOR_OPEN_1) door_state &= ~DOOR_OPEN_1; else if (door1 == DOOR_CLOSE_1 && door_state & DOOR_CLOSE_1) @@ -2074,13 +2096,19 @@ unsigned int MoveDoor(unsigned int door_state) { stepsize = 20; door_delay_value = 0; - StopSound(SND_OEFFNEN); + StopSound(SND_MENU_DOOR_OPENING); + StopSound(SND_MENU_DOOR_CLOSING); } if (door_state & DOOR_ACTION) { if (!(door_state & DOOR_NO_DELAY)) - PlaySoundStereo(SND_OEFFNEN, PSND_MAX_RIGHT); + { + if (door_state & (DOOR_OPEN_1 | DOOR_OPEN_2)) + PlaySoundStereo(SND_MENU_DOOR_OPENING, PSND_MAX_RIGHT); + if (door_state & (DOOR_CLOSE_1 | DOOR_CLOSE_2)) + PlaySoundStereo(SND_MENU_DOOR_CLOSING, PSND_MAX_RIGHT); + } start = ((door_state & DOOR_NO_DELAY) ? DXSIZE : 0); @@ -2175,7 +2203,10 @@ unsigned int MoveDoor(unsigned int door_state) } if (setup.quick_doors) - StopSound(SND_OEFFNEN); + { + StopSound(SND_MENU_DOOR_OPENING); + StopSound(SND_MENU_DOOR_CLOSING); + } if (door_state & DOOR_ACTION_1) door1 = door_state & DOOR_ACTION_1;