MCPcopy Create free account
hub / github.com/crossuo/crossuo / GetConsolePrefixAndType

Function GetConsolePrefixAndType

src/TextEngine/GameConsole.cpp:31–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29};
30
31static wstr_t GetConsolePrefixAndType(const wstr_t &text, int &member, GAME_CONSOLE_TEXT_TYPE &type)
32{
33 type = GCTT_NORMAL;
34 wstr_t result;
35
36 const auto len = text.size();
37 auto astr = str_from(text);
38 const char *atext = astr.c_str();
39 char aprefix = *atext;
40 if (aprefix == s_ConsolePrefix[GCTT_PARTY][0]) // Party
41 {
42 char *ptr = (char *)atext + 1;
43 while (ptr < atext + len && *ptr == ' ')
44 {
45 ptr++;
46 }
47
48 if (ptr < atext + len)
49 {
50 int i = 0;
51 (void)sscanf(ptr, "%i", &i);
52 if (i > 0 && i < 11) // Party member
53 {
54 char pmBuf[50];
55 if (g_Party.Member[i - 1].Serial != 0)
56 {
57 auto name = g_Party.Member[i - 1].GetName(i);
58 snprintf(pmBuf, sizeof(pmBuf), "Tell [%s]:", name.c_str());
59 }
60 else
61 {
62 snprintf(pmBuf, sizeof(pmBuf), "Tell []:");
63 }
64
65 result = wstr_from(pmBuf);
66 type = GCTT_PARTY;
67 member = i - 1;
68 }
69 }
70
71 if (type == GCTT_NORMAL && len >= 4 && len <= 8)
72 {
73 if (strncasecmp(atext, "/add", 4) == 0)
74 {
75 type = GCTT_PARTY_ADD; // Party add
76 }
77 else if (strncasecmp(atext, "/quit", 5) == 0 || strncasecmp(atext, "/leave", 6) == 0)
78 {
79 type = GCTT_PARTY_LEAVE; // Party leave & quit
80 }
81 else if (strncasecmp(atext, "/accept", 7) == 0)
82 {
83 type = GCTT_PARTY_ACCEPT; // Party accept
84 }
85 else if (strncasecmp(atext, "/decline", 8) == 0)
86 {
87 type = GCTT_PARTY_DECLINE; // Party decline
88 }

Callers 2

SendConsoleTextFunction · 0.85
DrawWMethod · 0.85

Calls 7

str_fromFunction · 0.85
wstr_fromFunction · 0.85
c_strMethod · 0.80
lengthMethod · 0.80
strncasecmpFunction · 0.50
sizeMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected