From 5bc26763cbb445bfddd7bf0b3363ec1a36b3624d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 23 Feb 2017 22:01:01 +0100 Subject: [PATCH] - fixed: String CVARs get stored as a const char *, not an FString, so the ls opcode cannot be used to read their content. --- src/scripting/backend/codegen.cpp | 2 +- src/scripting/vm/vmexec.h | 10 ++++++++++ src/scripting/vm/vmops.h | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/scripting/backend/codegen.cpp b/src/scripting/backend/codegen.cpp index 252788023a..cc93c22156 100644 --- a/src/scripting/backend/codegen.cpp +++ b/src/scripting/backend/codegen.cpp @@ -6522,7 +6522,7 @@ ExpEmit FxCVar::Emit(VMFunctionBuilder *build) case CVAR_String: build->Emit(OP_LKP, addr.RegNum, build->GetConstantAddress(&static_cast(CVar)->Value, ATAG_GENERIC)); - build->Emit(OP_LS, dest.RegNum, addr.RegNum, nul); + build->Emit(OP_LCS, dest.RegNum, addr.RegNum, nul); break; case CVAR_DummyBool: diff --git a/src/scripting/vm/vmexec.h b/src/scripting/vm/vmexec.h index 8da2c4d8d0..3082abf802 100644 --- a/src/scripting/vm/vmexec.h +++ b/src/scripting/vm/vmexec.h @@ -197,6 +197,16 @@ begin: GETADDR(PB,RC,X_READ_NIL); reg.s[a] = *(FString *)ptr; NEXTOP; + OP(LCS): + ASSERTS(a); ASSERTA(B); ASSERTKD(C); + GETADDR(PB,KC,X_READ_NIL); + reg.s[a] = *(const char **)ptr; + NEXTOP; + OP(LCS_R): + ASSERTS(a); ASSERTA(B); ASSERTD(C); + GETADDR(PB,RC,X_READ_NIL); + reg.s[a] = *(const char **)ptr; + NEXTOP; OP(LO): ASSERTA(a); ASSERTA(B); ASSERTKD(C); GETADDR(PB,KC,X_READ_NIL); diff --git a/src/scripting/vm/vmops.h b/src/scripting/vm/vmops.h index 6f3931531b..b058dc94b6 100644 --- a/src/scripting/vm/vmops.h +++ b/src/scripting/vm/vmops.h @@ -52,6 +52,8 @@ xx(LV2, lv2, RVRPKI, LV2_R, 4, REGT_INT), // load vector2 xx(LV2_R, lv2, RVRPRI, NOP, 0, 0), xx(LV3, lv3, RVRPKI, LV3_R, 4, REGT_INT), // load vector3 xx(LV3_R, lv3, RVRPRI, NOP, 0, 0), +xx(LCS, lcs, RSRPKI, LCS_R, 4, REGT_INT), // load string from char ptr. +xx(LCS_R, lcs, RSRPRI, NOP, 0, 0), xx(LBIT, lbit, RIRPI8, NOP, 0, 0), // rA = !!(*rB & C) -- *rB is a byte