feat(glue): add realm and character handling (#7)

* fix(build): make project compilable

* feat(glue): update Character Selection screen to support switching

* fix(ui): fix CSimpleFontString::GetHeight() to use proper method

* feat(db): add static database classes from whoa-autocode

* feat(ui): use class and area IDs for Character Selection

* chore(db): update ItemRandomPropertiesRec

* feat(glue): update CCharacterSelection methods

* chore(db): uncomment DB records

* feat(glue): implement character deletion

* feat(gx): update supported text tags in GxuDetermineQuotedCode

* fix(ui): fix CSimpleFontString to use the FixedColor flag only if the string does not contain color tags

* feat(net): implement GrunLogin::LogOff

* feat(net): implement NetClient::Disconnect

* feat(login): implement trimming of realm name in LoginResponse::HandleRealmData

* feat(net): implement proper disconnection from login and realm servers

* feat(net): implement PING/PONG messages

* feat(net): add NetClient::Destroy method

* feat(net): implement ClientServices::GetRealmList (second request of Realm List)

* feat(glue): implement CGlueMgr::PollRealmList

* feat(glue): implement CGlueMgr::PollCreateCharacter

* chore(glue): add skeleton of CCharacterComponent class

* fix(build): fix build using latest features

* fix(glue): kill gotos in CGlueMgr::NetDisconnectHandler

* fix(build): include SDL3

---------

Co-authored-by: superp00t <superp00t@tutanota.com>
This commit is contained in:
VDm 2025-04-17 01:32:37 +04:00 committed by GitHub
parent 50e37d16bc
commit 957a4c7e2f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
633 changed files with 1729 additions and 227 deletions

View file

@ -10,11 +10,13 @@
#include "gx/Shader.hpp"
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <bc/Memory.hpp>
#include <storm/Error.hpp>
#include <storm/String.hpp>
#include <storm/Unicode.hpp>
#include <tempest/Math.hpp>
#include <common/Unicode.hpp>
CGxShader* g_fontPixelShader[1];
CGxShader* g_fontVertexShader[2];
@ -177,7 +179,18 @@ uint32_t GetScreenPixelWidth() {
}
QUOTEDCODE GxuDetermineQuotedCode(const char* text, int32_t& advance, CImVector* color, uint32_t flags, uint32_t& wide) {
wide = SUniSGetUTF8(reinterpret_cast<const uint8_t*>(text), &advance);
STORM_ASSERT(text);
STORM_ASSERT(*text);
bool ignoreColorCodes = flags & 0x100;
bool ignoreNewlines = flags & 0x200;
bool ignoreHyperlinks = flags & 0x400;
bool ignorePipes = flags & 0x800;
bool ignoreTextures = flags & 0x1000;
auto utext = reinterpret_cast<const uint8_t*>(text);
wide = sgetu8(utext, &advance);
switch (wide) {
case 0x0:
@ -185,7 +198,7 @@ QUOTEDCODE GxuDetermineQuotedCode(const char* text, int32_t& advance, CImVector*
return CODE_INVALIDCODE;
case '\r':
advance = 2 - (SUniSGetUTF8(reinterpret_cast<const uint8_t*>(text + 1), &advance) != '\n');
advance = 2 - (sgetu8(utext + 1, &advance) != '\n');
return CODE_NEWLINE;
case '\n':
@ -193,7 +206,7 @@ QUOTEDCODE GxuDetermineQuotedCode(const char* text, int32_t& advance, CImVector*
return CODE_NEWLINE;
}
if (wide != '|' || flags & 0x800) {
if (wide != '|' || ignorePipes) {
return CODE_INVALIDCODE;
}
@ -203,18 +216,98 @@ QUOTEDCODE GxuDetermineQuotedCode(const char* text, int32_t& advance, CImVector*
return CODE_INVALIDCODE;
}
int32_t firstCharAdvance = advance;
switch (quotedCode) {
case 'N':
case 'n': {
if (flags & 0x200) {
case 'C':
case 'c': {
if (ignoreColorCodes) {
return CODE_INVALIDCODE;
}
size_t offset = advance + 1;
uint8_t comps[4];
for (size_t j = 0; j < 4; ++j) {
if (!text[offset] || !text[offset + 1]) {
return CODE_INVALIDCODE;
}
char hex[3] = { text[offset], text[offset + 1], '\0' };
offset += 2;
char* error = nullptr;
comps[j] = static_cast<uint8_t>(strtol(hex, &error, 16));
if (error && *error) {
return CODE_INVALIDCODE;
}
}
if (color) {
color->value = CImVector::MakeARGB(255, comps[1], comps[2], comps[3]);
}
advance = 10;
return CODE_COLORON;
}
case 'H': {
if (ignoreHyperlinks) {
return CODE_INVALIDCODE;
}
// TODO
break;
}
case 'N':
case 'n': {
if (ignoreNewlines) {
return CODE_INVALIDCODE;
}
advance = 2;
return CODE_NEWLINE;
}
// TODO handle other control codes
case 'R':
case 'r': {
if (ignoreColorCodes) {
return CODE_INVALIDCODE;
}
advance = 2;
return CODE_COLORRESTORE;
}
case 'T': {
if (ignoreTextures) {
return CODE_INVALIDCODE;
}
// TODO
break;
}
case 'h': {
if (ignoreHyperlinks) {
return CODE_INVALIDCODE;
}
advance = 2;
return CODE_HYPERLINKSTOP;
}
case 't': {
if (ignoreTextures) {
return CODE_INVALIDCODE;
}
advance = 2;
return CODE_TEXTURESTOP;
}
case '|': {
advance = 2;
return CODE_PIPE;
}
default: {
return CODE_INVALIDCODE;
}
}
// TODO remainder of function

View file

@ -229,6 +229,7 @@ class CGxDeviceD3d : public CGxDevice {
LPDIRECT3DDEVICE9 m_d3dDevice = nullptr;
D3DCAPS9 m_d3dCaps;
int32_t m_d3dIsHwDevice = 0;
int32_t m_d3dStereoEnabled = 0;
LPDIRECT3DVERTEXDECLARATION9 m_d3dVertexDecl[GxVertexBufferFormats_Last] = { 0 };
D3DDISPLAYMODE m_desktopDisplayMode;
int32_t m_inScene;

View file

@ -348,7 +348,7 @@ int32_t CGxString::Initialize(float fontHeight, const C3Vector& position, float
face->m_strings.LinkToTail(this);
float requestedFontHeight = this->m_flags & 0x4 && !(this->m_flags & 0x80)
float requestedFontHeight = ((this->m_flags & 0x4) && !(this->m_flags & 0x80))
? GxuFontGetOneToOneHeight(face)
: fontHeight;
this->m_requestedFontHeight = requestedFontHeight;
@ -382,7 +382,7 @@ void CGxString::InitializeTextLine(const char* currentText, uint32_t numBytes, C
float stepGlyph = 0.0f;
float stepScreen = 0.0f;
uint32_t prevCode = 0;
CImVector color;
CImVector color = this->m_fontColor;
while (numBytes && *currentText) {
int32_t advance;