MCPcopy Create free account
hub / github.com/OpenDUNE/OpenDUNE / GUI_Security_Show

Function GUI_Security_Show

src/gui/security.c:82–215  ·  view source on GitHub ↗

* Ask the security question to the user. Give him 3 times. If he fails, * return false, otherwise true. * @return True if and only if the user answered one of the three questions * correct. */

Source from the content-addressed store, hash-verified

80 * correct.
81 */
82bool GUI_Security_Show(void)
83{
84 const char *wsaHouseFilename;
85 uint16 questionsCount;
86 uint16 oldCurrentWidget;
87 Screen oldScreenID;
88 uint16 i;
89 bool valid;
90
91 g_disableOtherMovement = true;
92 g_interrogation = true;
93
94 wsaHouseFilename = House_GetWSAHouseFilename(g_playerHouseID);
95 if (wsaHouseFilename == NULL) return true;
96
97 GUI_SetPaletteAnimated(g_palette2, 15);
98
99 GUI_Mentat_Display(wsaHouseFilename, g_playerHouseID);
100
101 GUI_Mouse_Hide_Safe();
102 GUI_Screen_Copy(0, 0, 0, 0, SCREEN_WIDTH / 8, SCREEN_HEIGHT, SCREEN_1, SCREEN_0);
103 GUI_Mouse_Show_Safe();
104
105 GUI_SetPaletteAnimated(g_palette1, 15);
106
107 strncpy(g_readBuffer, String_Get_ByIndex(STR_SECURITY_TEXT_HARKONNEN + g_playerHouseID * 3), g_readBufferSize);
108 GUI_Mentat_Loop(wsaHouseFilename, NULL, g_readBuffer, true, NULL);
109
110 questionsCount = atoi(String_Get_ByIndex(STR_SECURITY_COUNT));
111
112 oldCurrentWidget = Widget_SetCurrentWidget(8);
113
114 oldScreenID = GFX_Screen_SetActive(SCREEN_2);
115
116 for (i = 0, valid = false; i < 3 && !valid; i++) {
117 void *wsa;
118 uint16 questionIndex;
119 uint32 tickWaitTill;
120 char buffer[81];
121
122 questionIndex = Tools_RandomLCG_Range(0, questionsCount - 1) * 3 + STR_SECURITY_QUESTIONS;
123
124 Widget_SetCurrentWidget(8);
125
126 wsa = WSA_LoadFile(String_Get_ByIndex(questionIndex + 1), GFX_Screen_Get_ByIndex(SCREEN_1), GFX_Screen_GetSize_ByIndex(SCREEN_1), false);
127 WSA_DisplayFrame(wsa, 0, g_curWidgetXBase << 3, g_curWidgetYBase, SCREEN_2);
128 WSA_Unload(wsa);
129
130 GUI_DrawSprite(SCREEN_2, g_sprites[397 + g_playerHouseID * 15], g_shoulderLeft, g_shoulderTop, 0, 0);
131
132 GUI_Mouse_Hide_InWidget(g_curWidgetIndex);
133 GUI_Screen_Copy(g_curWidgetXBase, g_curWidgetYBase, g_curWidgetXBase, g_curWidgetYBase, g_curWidgetWidth, g_curWidgetHeight, SCREEN_2, SCREEN_0);
134 GUI_Mouse_Show_InWidget();
135
136 strncpy(g_readBuffer, String_Get_ByIndex(questionIndex), g_readBufferSize);
137 GUI_Security_DrawText(g_readBuffer);
138
139 g_interrogationTimer = g_timerGUI + (uint32)strlen(g_readBuffer) * 4;

Callers 1

GameLoop_LevelEndFunction · 0.85

Calls 15

GUI_SetPaletteAnimatedFunction · 0.85
GUI_Mentat_DisplayFunction · 0.85
GUI_Mouse_Hide_SafeFunction · 0.85
GUI_Screen_CopyFunction · 0.85
GUI_Mouse_Show_SafeFunction · 0.85
String_Get_ByIndexFunction · 0.85
GUI_Mentat_LoopFunction · 0.85
Widget_SetCurrentWidgetFunction · 0.85
GFX_Screen_SetActiveFunction · 0.85
Tools_RandomLCG_RangeFunction · 0.85
WSA_LoadFileFunction · 0.85

Tested by

no test coverage detected