MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / CPE_SetTextHotkey

Function CPE_SetTextHotkey

src/Protocol.c:1113–1136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1111}
1112
1113static void CPE_SetTextHotkey(cc_uint8* data) {
1114 /* First 64 bytes are label string */
1115 cc_string action = UNSAFE_GetString(&data[64]);
1116 cc_uint32 keyCode = Stream_GetU32_BE(&data[128]);
1117 cc_uint8 keyMods = data[132];
1118 int key;
1119
1120 if (keyCode > 255) return;
1121 key = Hotkeys_LWJGL[keyCode];
1122 if (!key) return;
1123 Platform_Log3("CPE hotkey added: %c, %b: %s", Input_DisplayNames[key], &keyMods, &action);
1124
1125 if (!action.length) {
1126 Hotkeys_Remove(key, keyMods);
1127 StoredHotkeys_Load(key, keyMods);
1128 } else if (action.buffer[action.length - 1] == '\n') {
1129 action.length--;
1130 Hotkeys_Add(key, keyMods, &action,
1131 HOTKEY_FLAG_AUTO_DEFINED);
1132 } else { /* more input needed by user */
1133 Hotkeys_Add(key, keyMods, &action,
1134 HOTKEY_FLAG_AUTO_DEFINED | HOTKEY_FLAG_STAYS_OPEN);
1135 }
1136}
1137
1138static void CPE_ExtAddPlayerName(cc_uint8* data) {
1139 EntityID id = data[1]; /* 16 bit id */

Callers

nothing calls this directly

Calls 6

UNSAFE_GetStringFunction · 0.85
Stream_GetU32_BEFunction · 0.85
Platform_Log3Function · 0.85
Hotkeys_RemoveFunction · 0.85
StoredHotkeys_LoadFunction · 0.85
Hotkeys_AddFunction · 0.85

Tested by

no test coverage detected