Made DoResponsePhrase() a whole lot more readable.

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1442 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
meep-eep
2005-01-10 11:38:45 +00:00
parent 1935316a12
commit d3f5a7f343
+24 -19
View File
@@ -50,6 +50,14 @@ int cur_comm;
UNICODE shared_phrase_buf[256]; UNICODE shared_phrase_buf[256];
volatile BOOLEAN summary = FALSE; volatile BOOLEAN summary = FALSE;
typedef struct response_entry
{
RESPONSE_REF response_ref;
TEXT response_text;
RESPONSE_FUNC response_func;
} RESPONSE_ENTRY;
typedef RESPONSE_ENTRY *PRESPONSE_ENTRY;
typedef struct encounter_state typedef struct encounter_state
{ {
BOOLEAN (*InputFunc) (struct encounter_state *pES); BOOLEAN (*InputFunc) (struct encounter_state *pES);
@@ -57,12 +65,7 @@ typedef struct encounter_state
COUNT Initialized; COUNT Initialized;
BYTE num_responses, cur_response, top_response; BYTE num_responses, cur_response, top_response;
struct RESPONSE_ENTRY response_list[MAX_RESPONSES];
{
RESPONSE_REF response_ref;
TEXT response_text;
RESPONSE_FUNC response_func;
} response_list[MAX_RESPONSES];
Task AnimTask; Task AnimTask;
@@ -1339,7 +1342,7 @@ SpewPhrases (COUNT wait_track)
break; break;
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
/* FIXME: is this a ramnant of 128-tick clock? /* FIXME: is this a remnant of 128-tick clock?
* with 120-tick clock this will sleep for 1 tick -- * with 120-tick clock this will sleep for 1 tick --
* for 1/120th of a second; if ONE_SECOND is upgraded * for 1/120th of a second; if ONE_SECOND is upgraded
* it will probably sleep for 2/120th of a second. * it will probably sleep for 2/120th of a second.
@@ -1927,6 +1930,7 @@ DoResponsePhrase (RESPONSE_REF R, RESPONSE_FUNC response_func,
UNICODE *ConstructStr) UNICODE *ConstructStr)
{ {
PENCOUNTER_STATE pES = pCurInputState; PENCOUNTER_STATE pES = pCurInputState;
PRESPONSE_ENTRY pEntry;
if (GLOBAL (CurrentActivity) & CHECK_ABORT) if (GLOBAL (CurrentActivity) & CHECK_ABORT)
return; return;
@@ -1937,27 +1941,28 @@ DoResponsePhrase (RESPONSE_REF R, RESPONSE_FUNC response_func,
pES->top_response = (BYTE)~0; pES->top_response = (BYTE)~0;
} }
pES->response_list[pES->num_responses].response_ref = R; pEntry = &pES->response_list[pES->num_responses];
if ((pES->response_list[pES->num_responses].response_text.pStr = ConstructStr)) pEntry->response_ref = R;
pES->response_list[pES->num_responses].response_text.CharCount = wstrlen (ConstructStr); pEntry->response_text.pStr = ConstructStr;
if (pEntry->response_text.pStr)
pEntry->response_text.CharCount = wstrlen (ConstructStr);
else else
{ {
STRING locString; STRING locString;
locString = SetAbsStringTableIndex (CommData.ConversationPhrases, (COUNT)(R - 1)); locString = SetAbsStringTableIndex (CommData.ConversationPhrases,
pES->response_list[pES->num_responses].response_text.pStr = (COUNT) (R - 1));
pEntry->response_text.pStr =
(UNICODE *) GetStringAddress (locString); (UNICODE *) GetStringAddress (locString);
pES->response_list[pES->num_responses].response_text.CharCount = pEntry->response_text.CharCount = GetStringLength (locString);
GetStringLength (locString);
//#define BVT_PROBLEM //#define BVT_PROBLEM
#ifdef BVT_PROBLEM #ifdef BVT_PROBLEM
if (pES->response_list[pES->num_responses].response_text.pStr[ if (pEntry->response_text.pStr[pEntry->response_text.CharCount - 1]
pES->response_list[pES->num_responses].response_text.CharCount - 1 == '\0')
] == '\0') --pEntry->response_text.CharCount;
--pES->response_list[pES->num_responses].response_text.CharCount;
#endif /* BVT_PROBLEM */ #endif /* BVT_PROBLEM */
} }
pES->response_list[pES->num_responses].response_func = response_func; pEntry->response_func = response_func;
++pES->num_responses; ++pES->num_responses;
} }