Skip to content

Commit 7693456

Browse files
committed
GOB: Append labels from .IDE file to function names in degob
Syntax: sub_<function offset>[_<function name>]
1 parent ab4b17e commit 7693456

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

engines/gob/degob_script.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -953,15 +953,26 @@ void Script::deGob(int32 offset, bool isLib) {
953953
}
954954

955955
void Script::deGobFunction() {
956+
uint32 pos = getPos();
957+
updateOffsetPos(pos);
958+
printIndent();
959+
960+
const char* func_name = nullptr;
956961
if (!_funcOffsetsNames.empty()) {
957-
auto it = _funcOffsetsNames.find(getPos());
962+
auto it = _funcOffsetsNames.find(pos);
958963
if (it != _funcOffsetsNames.end()) {
959-
print("--- %s ---\n", it->second.c_str());
964+
func_name = it->second.c_str();
965+
// Skip lib name
966+
if (const char* p = strchr(func_name, ' ')) {
967+
func_name = p + 1;
968+
}
960969
}
961970
}
962-
updateOffsetPos(getPos());
963-
printIndent();
964-
print("sub_%d {\n", getPos());
971+
972+
print("sub_%d%s%s {\n",
973+
pos,
974+
func_name ? "_" : "",
975+
func_name ? func_name : "");
965976
incIndent();
966977

967978
funcBlock(2);

engines/gob/degob_script_v1.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,8 +880,23 @@ void Script_v1::o1_callSub(FuncParams &params) {
880880

881881
seek(offset);
882882

883+
const char* func_name = nullptr;
884+
if (!_funcOffsetsNames.empty()) {
885+
auto it = _funcOffsetsNames.find(offset);
886+
if (it != _funcOffsetsNames.end()) {
887+
func_name = it->second.c_str();
888+
// Skip lib name
889+
if (const char* p = strchr(func_name, ' ')) {
890+
func_name = p + 1;
891+
}
892+
}
893+
}
894+
883895
if (peekUint8() == 1) {
884-
print("sub_%d();\n", offset);
896+
print("sub_%d%s%s();\n",
897+
offset,
898+
func_name ? "_" : "",
899+
func_name ? func_name : "");
885900
if (offset >= 128)
886901
addFuncOffset(offset);
887902
} else if (peekUint8() == 2) {

0 commit comments

Comments
 (0)