[Scummvm-git-logs] scummvm master -> 148b2d5ec3c43fd0ac0f8b45df7a428927d9437d
Strangerke
noreply at scummvm.org
Fri Jun 13 07:21:43 UTC 2025
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
148b2d5ec3 M4: Fix some more PVS Studio issues in conv, some cleanup
Commit: 148b2d5ec3c43fd0ac0f8b45df7a428927d9437d
https://github.com/scummvm/scummvm/commit/148b2d5ec3c43fd0ac0f8b45df7a428927d9437d
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-06-13T08:21:38+01:00
Commit Message:
M4: Fix some more PVS Studio issues in conv, some cleanup
Changed paths:
engines/m4/adv_r/conv.cpp
diff --git a/engines/m4/adv_r/conv.cpp b/engines/m4/adv_r/conv.cpp
index c9a6bfd8d28..67c640927f8 100644
--- a/engines/m4/adv_r/conv.cpp
+++ b/engines/m4/adv_r/conv.cpp
@@ -37,23 +37,22 @@ namespace M4 {
// Process declarations
// Get message text
static void conv_exec_entry(int32 offset, Conv *c) {
- int32 i = offset, entry_count;
- int32 l_op, r_op;
+ int32 i = offset;
int32 tag, next;
goto_chunk *go;
c_goto_chunk *c_goto;
- entry_chunk *entry;
decl_chunk *decl;
assign_chunk *asgn;
c_assign_chunk *c_asgn;
misc_chunk *misc;
c_misc_chunk *c_misc;
- l_op = r_op = entry_count = 0;
+ int32 l_op;
+ int32 r_op;
- entry = get_entry(c, i);
- entry_count = entry->size;
+ entry_chunk *entry = get_entry(c, i);
+ const int32 entry_count = entry->size;
entry->status = conv_toggle_flags(entry);
i += sizeof(entry_chunk);
@@ -63,14 +62,8 @@ static void conv_exec_entry(int32 offset, Conv *c) {
switch (tag) {
case TEXT_CHUNK:
- break;
-
case MESSAGE_CHUNK:
- break;
-
case ENTRY_CHUNK:
- break;
-
case FALL_CHUNK:
break;
@@ -205,14 +198,8 @@ static void conv_exec_entry(int32 offset, Conv *c) {
// Replies are non-player responses
case REPLY_CHUNK:
- break;
-
case COND_REPLY_CHUNK:
- break;
-
case WEIGHT_REPLY_CHUNK:
- break;
-
case WEIGHT_PREPLY_CHUNK:
break;
@@ -226,24 +213,23 @@ static void conv_exec_entry(int32 offset, Conv *c) {
}
static int conv_get_mesg(int32 offset, int32 is_valid, Conv *c) {
- int32 i = offset, entry_count;
- int32 l_op, r_op;
+ int32 i = offset;
int32 x, y, s_offset = 0, cSize;
int32 tag, next;
int32 text_len;
int sum, result = 0;
- entry_chunk *entry;
decl_chunk *decl;
reply_chunk *reply;
c_reply_chunk *c_reply;
w_reply_chunk *w_reply;
w_entry_chunk *w_entry;
- l_op = r_op = entry_count = 0;
+ int32 l_op;
+ int32 r_op;
- entry = get_entry(c, i);
- entry_count = entry->size;
+ entry_chunk *entry = get_entry(c, i);
+ const int32 entry_count = entry->size;
i += sizeof(entry_chunk);
@@ -252,50 +238,20 @@ static int conv_get_mesg(int32 offset, int32 is_valid, Conv *c) {
switch (tag) {
case TEXT_CHUNK:
- break;
-
case MESSAGE_CHUNK:
- break;
-
case ENTRY_CHUNK:
- break;
-
case FALL_CHUNK:
- break;
-
case C_ASGN_CHUNK:
- break;
-
case ASGN_CHUNK:
- break;
-
case HIDE_CHUNK:
- break;
-
case CHDE_CHUNK:
- break;
-
case UHID_CHUNK:
- break;
-
case CUHD_CHUNK:
- break;
-
case DSTR_CHUNK:
- break;
-
case CDST_CHUNK:
- break;
-
case COND_GOTO_CHUNK:
- break;
-
case COND_EXIT_GOTO_CHUNK:
- break;
-
case EXIT_GOTO_CHUNK:
- break;
-
case GOTO_CHUNK:
break;
@@ -481,7 +437,6 @@ static void find_true_ent(int entry_num, Conv *c) {
//do this to skip the fall chunk and all will be fine.
ent += sizeof(int32); //was get_long, sizeof( fall_chunk )
- n++; //don't increment i.
}
_GC(ent) = 0;
@@ -507,7 +462,7 @@ static void find_true_ent(int entry_num, Conv *c) {
// Simplify me now that all changes have been made.
static int conv_get_node_text(Conv *c) {
lnode_chunk *lnode = nullptr;
- node_chunk *node = nullptr;
+ node_chunk *node;
entry_chunk *entry = nullptr;
fall_chunk *fall = nullptr;
@@ -587,7 +542,7 @@ static int conv_get_node_text(Conv *c) {
entry = get_entry(c, offset + ent);
if (entry->tag != FALL_CHUNK) {
- if ((entry->status != 0) && (num_ents != 0) && ok_status(entry)) {
+ if ((entry->status != 0) && ok_status(entry)) {
if (conv_get_text(offset + ent, entry->size, c)) {
result = 1;
@@ -613,12 +568,15 @@ static int conv_get_node_text(Conv *c) {
}
}
break;
+
+ default:
+ break;
}
return result;
}
-void conv_shutdown(void) {
+void conv_shutdown() {
if (conv_get_handle())
conv_unload(conv_get_handle());
@@ -650,6 +608,9 @@ static void conv_start(Conv *c) {
c->exit_now = CONV_OK;
c->myCNode = 0;
break;
+
+ default:
+ break;
}
while ((ent < c->chunkSize) && ok) {
@@ -693,19 +654,20 @@ static int conv_next_node(Conv *c) {
case CONV_NEW:
conv_start(c); // Should go in conv_load.
return 1;
+
+ default:
+ break;
}
return 1;
}
static int conv_process_entry(int entry_num, Conv *c, int mode) {
- node_chunk *node = nullptr;
- lnode_chunk *lnode = nullptr;
- entry_chunk *entry = nullptr;
- fall_chunk *fall = nullptr;
+ node_chunk *node;
+ lnode_chunk *lnode;
+ fall_chunk *fall;
int32 offset = 0, ent = 0, is_valid = 0, n = 0;
int32 next = 0, tag = 0, num_ents = 0;
int i = 0;
- int32 sub_ent = 0;
int result = 1;
// Repeat fallthrough till done
@@ -733,7 +695,7 @@ static int conv_process_entry(int entry_num, Conv *c, int mode) {
}
// ent will now be pointing at an ENTRY or FALLTHROUGH
- sub_ent = next;
+ const int32 sub_ent = next;
conv_ops_get_entry(sub_ent, &next, &tag, c);
switch (tag) {
case FALL_CHUNK:
@@ -762,7 +724,7 @@ static int conv_process_entry(int entry_num, Conv *c, int mode) {
// Not only i<entry_num, check to see entry->num_entries
while ((i < entry_num) && (n < num_ents)) {
offset = get_long(c, ent);
- entry = get_entry(c, ent + offset);
+ entry_chunk *entry = get_entry(c, ent + offset);
if (((entry->status) != 0) && ok_status(entry)) {
i++;
@@ -784,6 +746,8 @@ static int conv_process_entry(int entry_num, Conv *c, int mode) {
case CONV_UPDATE_MODE:
conv_exec_entry(ent + offset, c);
break;
+ default:
+ break;
}
}
@@ -796,17 +760,12 @@ static int conv_run(Conv *c) {
if (!c)
return 0;
- int result = 0;
int ok = 1;
if (conv_next_node(c)) {
switch (c->exit_now) {
case CONV_NEW:
- break;
-
case CONV_QUIT:
- break;
-
case CONV_BAIL:
break;
@@ -853,28 +812,32 @@ static int conv_run(Conv *c) {
c->mode = CONV_GET_TEXT_MODE;
break;
+
+ default:
+ break;
}
}
break;
+
+ default:
+ break;
}
}
if (!conv_next_node(c))
conv_unload(c);
- return result;
+ return 0;
}
static void convtestCallback(void *a, void *) {
- Conv *c;
-
mouse_unlock_sprite();
mouse_lock_sprite(5);
player_set_commands_allowed(false);
TextItem *i = (TextItem *)a;
- c = conv_get_handle();
+ Conv *c = conv_get_handle();
if (!c)
return;
@@ -895,28 +858,25 @@ static void convtestCallback(void *a, void *) {
}
void set_dlg_rect() {
- int32 sizex = 0, sizey = 0;
- int32 screen_x_center = 0, screen_y_center = 0;
- int32 screen_x_size = 0, screen_y_size = 0;
int32 status;
-
ScreenContext *game_buff_ptr = vmng_screen_find(_G(gameDrawBuff), &status);
- if (!game_buff_ptr) error_show(FL, 'BUF!');
+ if (!game_buff_ptr)
+ error_show(FL, 'BUF!');
- screen_x_center = VIDEO_W / 2;
- screen_y_center = (game_buff_ptr->y2 - game_buff_ptr->y1) / 2;
- screen_x_size = VIDEO_W;
- screen_y_size = (game_buff_ptr->y2 - game_buff_ptr->y1);
+ const int32 screen_x_center = VIDEO_W / 2;
+ const int32 screen_y_center = (game_buff_ptr->y2 - game_buff_ptr->y1) / 2;
+ const int32 screen_x_size = VIDEO_W;
+ const int32 screen_y_size = (game_buff_ptr->y2 - game_buff_ptr->y1);
_GC(height) = gr_font_get_height() + _GC(conv_font_spacing_v); // Must have....
_GC(width) += 2 * _GC(conv_font_spacing_h);
- sizex = _GC(width);
- sizey = _G(cdd).num_txt_ents * (_GC(height))+_GC(conv_font_spacing_v);
+ const int32 sizeX = _GC(width);
+ const int32 sizeY = _G(cdd).num_txt_ents * (_GC(height)) + _GC(conv_font_spacing_v);
switch (_GC(glob_x)) {
case DLG_CENTER_H:
- _GC(r_x1) = screen_x_center - (sizex / 2);
+ _GC(r_x1) = screen_x_center - (sizeX / 2);
break;
case DLG_FLUSH_LEFT:
@@ -924,7 +884,7 @@ void set_dlg_rect() {
break;
case DLG_FLUSH_RIGHT:
- _GC(r_x1) = screen_x_size - sizex;
+ _GC(r_x1) = screen_x_size - sizeX;
break;
default:
@@ -935,7 +895,7 @@ void set_dlg_rect() {
switch (_GC(glob_y)) {
case DLG_CENTER_V:
- _GC(r_y1) = screen_y_center - (sizey / 2);
+ _GC(r_y1) = screen_y_center - (sizeY / 2);
break;
case DLG_FLUSH_TOP:
@@ -943,7 +903,7 @@ void set_dlg_rect() {
break;
case DLG_FLUSH_BOTTOM:
- _GC(r_y1) = screen_y_size - sizey + game_buff_ptr->y1 - 10;
+ _GC(r_y1) = screen_y_size - sizeY + game_buff_ptr->y1 - 10;
break;
default:
@@ -958,16 +918,14 @@ void set_dlg_rect() {
if (_GC(r_y1) < 0)
_GC(r_y1) = 0;
- _GC(r_y2) = _GC(r_y1) + sizey - 1;
- _GC(r_x2) = _GC(r_x1) + sizex - 1;
+ _GC(r_y2) = _GC(r_y1) + sizeY - 1;
+ _GC(r_x2) = _GC(r_x1) + sizeX - 1;
_GC(r_x2) = imath_min(VIDEO_W, _GC(r_x2));
_GC(r_y2) = imath_min(VIDEO_H, _GC(r_y2));
}
static void textBoxInit() {
- int32 i;
-
player_set_commands_allowed(true);
mouse_set_sprite(0);
@@ -982,7 +940,7 @@ static void textBoxInit() {
_GC(conv_hilite_colour_alt1), _GC(conv_normal_colour_alt2),
_GC(conv_hilite_colour_alt2));
- for (i = 0; i < _G(cdd).num_txt_ents; i++) {
+ for (int32 i = 0; i < _G(cdd).num_txt_ents; i++) {
TextScrn_Add_TextItem(_GC(myTextScrn), _GC(conv_font_spacing_h),
(i * _GC(height)) + _GC(conv_font_spacing_v), i + 1, TS_GIVEN,
_G(cdd).text[i], convtestCallback);
More information about the Scummvm-git-logs
mailing list