[Scummvm-git-logs] scummvm master -> 23f82385f2544f5714846138bb2356430c661204
scemino
noreply at scummvm.org
Mon Mar 18 20:50:16 UTC 2024
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
6fb05dd8ac TWP: Fix identical statements in object.cpp. PVS-Studio V581
7bd9cc924c TWP: Fix memory leaks in savegame.cpp. PVS-Studio V773
486c2d4eb0 TWP: Fix inverted debug condition in savegame
23f82385f2 TWP: Remove unused sqpush function
Commit: 6fb05dd8accd95dcc46fc7db56a6a137d28c1519
https://github.com/scummvm/scummvm/commit/6fb05dd8accd95dcc46fc7db56a6a137d28c1519
Author: scemino (scemino74 at gmail.com)
Date: 2024-03-18T21:50:00+01:00
Commit Message:
TWP: Fix identical statements in object.cpp. PVS-Studio V581
Changed paths:
engines/twp/object.cpp
diff --git a/engines/twp/object.cpp b/engines/twp/object.cpp
index 8ca225a569b..fe4fd243348 100644
--- a/engines/twp/object.cpp
+++ b/engines/twp/object.cpp
@@ -523,7 +523,7 @@ void Object::setAnimationNames(const Common::String &head, const Common::String
_animNames[STAND_ANIMNAME] = stand;
if (!walk.empty())
_animNames[WALK_ANIMNAME] = walk;
- if (!walk.empty())
+ if (!reach.empty())
_animNames[REACH_ANIMNAME] = reach;
if (isWalking())
play(getAnimName(WALK_ANIMNAME), true);
Commit: 7bd9cc924c58fe7241d04ef2c5d20b2b2b393e1b
https://github.com/scummvm/scummvm/commit/7bd9cc924c58fe7241d04ef2c5d20b2b2b393e1b
Author: scemino (scemino74 at gmail.com)
Date: 2024-03-18T21:50:00+01:00
Commit Message:
TWP: Fix memory leaks in savegame.cpp. PVS-Studio V773
Changed paths:
engines/twp/savegame.cpp
diff --git a/engines/twp/savegame.cpp b/engines/twp/savegame.cpp
index 1a250dc239c..7ecb4d30a70 100644
--- a/engines/twp/savegame.cpp
+++ b/engines/twp/savegame.cpp
@@ -627,6 +627,44 @@ private:
Common::JSONArray &_arr;
};
+static void toObject(Common::JSONObject &jObj, const HSQOBJECT &obj, bool checkId, bool skipObj = false, bool pseudo = false) {
+ if (checkId) {
+ SQInteger id = 0;
+ sqgetf(obj, "_id", id);
+ if (g_twp->_resManager->isActor(id)) {
+ Common::SharedPtr<Object> a(actor(id));
+ jObj["_actorKey"] = new Common::JSONValue(a->_key);
+ return;
+ }
+
+ if (g_twp->_resManager->isObject(id)) {
+ Common::SharedPtr<Object> o(sqobj(id));
+ if (!o)
+ return;
+ jObj["_objectKey"] = new Common::JSONValue(o->_key);
+ if (o->_room && o->_room->_pseudo)
+ jObj["_roomKey"] = new Common::JSONValue(o->_room->_name);
+ return;
+ }
+
+ if (g_twp->_resManager->isRoom(id)) {
+ Common::SharedPtr<Room> r(getRoom(id));
+ jObj["_roomKey"] = new Common::JSONValue(r->_name);
+ return;
+ }
+ }
+
+ HSQUIRRELVM v = g_twp->getVm();
+ HSQOBJECT rootTbl = sqrootTbl(v);
+
+ JsonCallback params;
+ params.jObj = &jObj;
+ params.pseudo = pseudo;
+ params.rootTable = &rootTbl;
+ params.skipObj = skipObj;
+ sqgetpairs(obj, fillMissingProperties, ¶ms);
+}
+
static Common::JSONValue *tojson(const HSQOBJECT &obj, bool checkId, bool skipObj, bool pseudo) {
switch (obj._type) {
case OT_INTEGER:
@@ -644,38 +682,7 @@ static Common::JSONValue *tojson(const HSQOBJECT &obj, bool checkId, bool skipOb
}
case OT_TABLE: {
Common::JSONObject jObj;
- if (checkId) {
- SQInteger id = 0;
- sqgetf(obj, "_id", id);
- if (g_twp->_resManager->isActor(id)) {
- Common::SharedPtr<Object> a(actor(id));
- jObj["_actorKey"] = new Common::JSONValue(a->_key);
- return new Common::JSONValue(jObj);
- } else if (g_twp->_resManager->isObject(id)) {
- Common::SharedPtr<Object> o(sqobj(id));
- if (!o)
- return new Common::JSONValue();
- jObj["_objectKey"] = new Common::JSONValue(o->_key);
- if (o->_room && o->_room->_pseudo)
- jObj["_roomKey"] = new Common::JSONValue(o->_room->_name);
- return new Common::JSONValue(jObj);
- } else if (g_twp->_resManager->isRoom(id)) {
- Common::SharedPtr<Room> r(getRoom(id));
- jObj["_roomKey"] = new Common::JSONValue(r->_name);
- return new Common::JSONValue(jObj);
- }
- }
-
- HSQUIRRELVM v = g_twp->getVm();
- HSQOBJECT rootTbl = sqrootTbl(v);
-
- JsonCallback params;
- params.jObj = &jObj;
- params.pseudo = pseudo;
- params.rootTable = &rootTbl;
- params.skipObj = skipObj;
- sqgetpairs(obj, fillMissingProperties, ¶ms);
-
+ toObject(jObj, obj, checkId, skipObj, pseudo);
return new Common::JSONValue(jObj);
}
default:
@@ -728,7 +735,8 @@ Common::String toString(const Math::Vector2d &pos) {
// }
static Common::JSONValue *createJActor(Common::SharedPtr<Object> actor) {
- Common::JSONObject jActor(tojson(actor->_table, false)->asObject());
+ Common::JSONObject jActor;
+ toObject(jActor, actor->_table, false);
int color = actor->_node->getComputedColor().toInt();
if (color != Color().toInt())
jActor["_color"] = new Common::JSONValue((long long int)color);
@@ -923,7 +931,8 @@ static Common::JSONValue *createJInventory() {
}
static Common::JSONValue *createJObject(HSQOBJECT &table, Common::SharedPtr<Object> obj) {
- Common::JSONObject json(tojson(table, false)->asObject());
+ Common::JSONObject json;
+ toObject(json, table, false);
if (obj) {
if (!obj->_node->isVisible())
json["_hidden"] = new Common::JSONValue(1LL);
@@ -938,7 +947,7 @@ static Common::JSONValue *createJObject(HSQOBJECT &table, Common::SharedPtr<Obje
return new Common::JSONValue(json);
}
-static Common::JSONValue* createJObjects() {
+static Common::JSONValue *createJObjects() {
Common::JSONObject json;
// sqgetpairs(sqrootTbl(g_twp->getVm()), fillObjects, &json);
for (auto &room : g_twp->_rooms) {
@@ -956,7 +965,7 @@ static Common::JSONValue* createJObjects() {
return new Common::JSONValue(json);
}
-static Common::JSONValue* createJPseudoObjects(Common::SharedPtr<Room> room) {
+static Common::JSONValue *createJPseudoObjects(Common::SharedPtr<Room> room) {
Common::JSONObject json;
for (auto &layer : room->_layers) {
for (auto &obj : layer->_objects) {
@@ -973,7 +982,8 @@ static Common::JSONValue* createJPseudoObjects(Common::SharedPtr<Room> room) {
}
static Common::JSONValue *createJRoom(Common::SharedPtr<Room> room) {
- Common::JSONObject json(tojson(room->_table, false, true, room->_pseudo)->asObject());
+ Common::JSONObject json;
+ toObject(json, room->_table, false, true, room->_pseudo);
if (room->_pseudo) {
json["_pseudoObjects"] = createJPseudoObjects(room);
}
Commit: 486c2d4eb06e633fd3cc6fb34624176708e40640
https://github.com/scummvm/scummvm/commit/486c2d4eb06e633fd3cc6fb34624176708e40640
Author: scemino (scemino74 at gmail.com)
Date: 2024-03-18T21:50:00+01:00
Commit Message:
TWP: Fix inverted debug condition in savegame
Changed paths:
engines/twp/savegame.cpp
diff --git a/engines/twp/savegame.cpp b/engines/twp/savegame.cpp
index 7ecb4d30a70..3351f8d9422 100644
--- a/engines/twp/savegame.cpp
+++ b/engines/twp/savegame.cpp
@@ -388,7 +388,7 @@ static int32 computeHash(byte *data, size_t n) {
bool SaveGameManager::loadGame(const SaveGame &savegame) {
// dump savegame as json
- if (!(DebugMan.isDebugChannelEnabled(kDebugGame))) {
+ if (DebugMan.isDebugChannelEnabled(kDebugGame)) {
debugC(kDebugGame, "load game: %s", savegame.jSavegame->stringify().c_str());
}
@@ -1028,7 +1028,7 @@ void SaveGameManager::saveGame(Common::WriteStream *ws) {
sqcall("preSave");
Common::JSONValue *data = createSaveGame();
- if (!(DebugMan.isDebugChannelEnabled(kDebugGame))) {
+ if (DebugMan.isDebugChannelEnabled(kDebugGame)) {
debugC(kDebugGame, "save game: %s", data->stringify().c_str());
}
Commit: 23f82385f2544f5714846138bb2356430c661204
https://github.com/scummvm/scummvm/commit/23f82385f2544f5714846138bb2356430c661204
Author: scemino (scemino74 at gmail.com)
Date: 2024-03-18T21:50:00+01:00
Commit Message:
TWP: Remove unused sqpush function
Changed paths:
engines/twp/squtil.cpp
diff --git a/engines/twp/squtil.cpp b/engines/twp/squtil.cpp
index ab898c8a9cd..77f0a17651e 100644
--- a/engines/twp/squtil.cpp
+++ b/engines/twp/squtil.cpp
@@ -123,22 +123,6 @@ SQInteger sqpush(HSQUIRRELVM v, Rectf value) {
return 1;
}
-template<>
-SQInteger sqpush(HSQUIRRELVM v, Common::JSONValue *node) {
- if (node->isIntegerNumber()) {
- return sqpush(v, (int)node->asIntegerNumber());
- } else if (node->isString()) {
- return sqpush(v, node->asString());
- } else if (node->isString()) {
- return sqpush(v, (float)node->asNumber());
- } else if (node->isNull()) {
- sq_pushnull(v);
- return 1;
- } else {
- return sq_throwerror(v, "This kind of node is not supported");
- }
-}
-
template<>
HSQOBJECT sqtoobj(HSQUIRRELVM v, int value) {
SQObject o;
More information about the Scummvm-git-logs
mailing list