[Scummvm-git-logs] scummvm master -> 3a0a70bc43d4df5c4509974ead5d0be1bcb0e5e2
dreammaster
dreammaster at scummvm.org
Thu Mar 11 05:12:35 UTC 2021
This automated email contains information about 7 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
d605b11c4f AGS: Make turnlooporder array const
d61b6f98c5 AGS: Move cscdialog.cpp globals to Globals
236250a945 AGS: Move display.cpp globals to Globals
b91cae25d6 AGS: Move walkbehind.cpp globals to Globals
9c6dd73349 AGS: Move cc_dynamicobject.cpp globals to Globals
bad09b641f AGS: Move translation.cpp globals to Globals
3a0a70bc43 AGS: Move more game.cpp globals to Globals
Commit: d605b11c4f648d40bc4d71f50a187f6b2abd5de6
https://github.com/scummvm/scummvm/commit/d605b11c4f648d40bc4d71f50a187f6b2abd5de6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-10T20:14:15-08:00
Commit Message:
AGS: Make turnlooporder array const
Changed paths:
engines/ags/engine/ac/character.cpp
engines/ags/engine/ac/character.h
diff --git a/engines/ags/engine/ac/character.cpp b/engines/ags/engine/ac/character.cpp
index 0cf1e5b0a4..e28ce1e7a0 100644
--- a/engines/ags/engine/ac/character.cpp
+++ b/engines/ags/engine/ac/character.cpp
@@ -1564,7 +1564,7 @@ int Character_GetSpeakingFrame(CharacterInfo *chaa) {
//=============================================================================
// order of loops to turn character in circle from down to down
-int turnlooporder[8] = {0, 6, 1, 7, 3, 5, 2, 4};
+const int turnlooporder[8] = {0, 6, 1, 7, 3, 5, 2, 4};
void walk_character(int chac, int tox, int toy, int ignwal, bool autoWalkAnims) {
CharacterInfo *chin = &_GP(game).chars[chac];
diff --git a/engines/ags/engine/ac/character.h b/engines/ags/engine/ac/character.h
index e58d653234..9f145294bf 100644
--- a/engines/ags/engine/ac/character.h
+++ b/engines/ags/engine/ac/character.h
@@ -220,7 +220,7 @@ Rect GetCharacterRoomBBox(int charid, bool use_frame_0 = false);
PViewport FindNearestViewport(int charid);
// order of loops to turn character in circle from down to down
-extern int turnlooporder[8];
+extern const int turnlooporder[8];
} // namespace AGS3
Commit: d61b6f98c5e00d9c9d74b30ea1a9ed9c7fdd8780
https://github.com/scummvm/scummvm/commit/d61b6f98c5e00d9c9d74b30ea1a9ed9c7fdd8780
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-10T20:14:15-08:00
Commit Message:
AGS: Move cscdialog.cpp globals to Globals
Changed paths:
engines/ags/engine/ac/game.cpp
engines/ags/engine/ac/route_finder_impl_legacy.cpp
engines/ags/engine/gui/cscidialog.cpp
engines/ags/engine/gui/cscidialog.h
engines/ags/engine/gui/mylabel.cpp
engines/ags/engine/gui/mylistbox.cpp
engines/ags/engine/gui/mypushbutton.cpp
engines/ags/engine/gui/mytextbox.cpp
engines/ags/engine/gui/newcontrol.cpp
engines/ags/globals.cpp
engines/ags/globals.h
diff --git a/engines/ags/engine/ac/game.cpp b/engines/ags/engine/ac/game.cpp
index e58c1776a5..8d4dc91ea8 100644
--- a/engines/ags/engine/ac/game.cpp
+++ b/engines/ags/engine/ac/game.cpp
@@ -116,6 +116,8 @@ extern int _G(psp_gfx_renderer);
extern char transFileName[MAX_PATH];
extern color palette[256];
+int oldmouse;
+
//=============================================================================
GameDataVersion loaded_game_file_version = kGameVersion_Undefined;
@@ -237,13 +239,9 @@ void set_game_speed(int new_fps) {
setTimerFps(new_fps);
}
-extern int cbuttfont;
-extern int acdialog_font;
-
-int oldmouse;
void setup_for_dialog() {
- cbuttfont = _GP(play).normal_font;
- acdialog_font = _GP(play).normal_font;
+ _G(cbuttfont) = _GP(play).normal_font;
+ _G(acdialog_font) = _GP(play).normal_font;
if (!_GP(play).mouse_cursor_hidden)
ags_domouse(DOMOUSE_ENABLE);
oldmouse = _G(cur_cursor);
diff --git a/engines/ags/engine/ac/route_finder_impl_legacy.cpp b/engines/ags/engine/ac/route_finder_impl_legacy.cpp
index 57e42bcc76..5407624ac6 100644
--- a/engines/ags/engine/ac/route_finder_impl_legacy.cpp
+++ b/engines/ags/engine/ac/route_finder_impl_legacy.cpp
@@ -734,7 +734,7 @@ void calculate_move_stage(MoveList *mlsp, int aaa) {
#ifdef DEBUG_PATHFINDER
AGS::Shared::Debug::Printf("stage %d from %d,%d to %d,%d Xpermove:%X Ypm:%X", aaa, ourx, oury, destx, desty, newxmove, newymove);
// wtextcolor(14);
- // wgtprintf((reallyneed[aaa] >> 16) & 0x000ffff, reallyneed[aaa] & 0x000ffff, cbuttfont, "%d", aaa);
+ // wgtprintf((reallyneed[aaa] >> 16) & 0x000ffff, reallyneed[aaa] & 0x000ffff, _G(cbuttfont), "%d", aaa);
#endif
}
diff --git a/engines/ags/engine/gui/cscidialog.cpp b/engines/ags/engine/gui/cscidialog.cpp
index 21aeead1d9..41335434da 100644
--- a/engines/ags/engine/gui/cscidialog.cpp
+++ b/engines/ags/engine/gui/cscidialog.cpp
@@ -48,26 +48,6 @@ namespace AGS3 {
using AGS::Shared::Bitmap;
namespace BitmapHelper = AGS::Shared::BitmapHelper;
-//-----------------------------------------------------------------------------
-// DIALOG SYSTEM STUFF below
-
-int windowbackgroundcolor = COL254, pushbuttondarkcolor = COL255;
-int pushbuttonlightcolor = COL253;
-int topwindowhandle = -1;
-int cbuttfont;
-
-int acdialog_font;
-
-int smcode = 0;
-
-#define MAXCONTROLS 20
-#define MAXSCREENWINDOWS 5
-NewControl *vobjs[MAXCONTROLS];
-OnScreenWindow oswi[MAXSCREENWINDOWS];
-
-int controlid = 0;
-
-
//-----------------------------------------------------------------------------
void __my_wbutt(Bitmap *ds, int x1, int y1, int x2, int y2) {
@@ -96,7 +76,7 @@ int CSCIDrawWindow(int xx, int yy, int wid, int hit) {
multiply_up(&xx, &yy, &wid, &hit);
int drawit = -1;
for (int aa = 0; aa < MAXSCREENWINDOWS; aa++) {
- if (oswi[aa].handle < 0) {
+ if (_G(oswi)[aa].handle < 0) {
drawit = aa;
break;
}
@@ -112,13 +92,13 @@ int CSCIDrawWindow(int xx, int yy, int wid, int hit) {
wid += 4;
hit += 4;
Bitmap *ds = prepare_gui_screen(xx, yy, wid, hit, true);
- oswi[drawit].x = xx;
- oswi[drawit].y = yy;
+ _G(oswi)[drawit].x = xx;
+ _G(oswi)[drawit].y = yy;
__my_wbutt(ds, 0, 0, wid - 1, hit - 1); // wbutt goes outside its area
// ags_domouse(DOMOUSE_ENABLE);
- oswi[drawit].oldtop = topwindowhandle;
- topwindowhandle = drawit;
- oswi[drawit].handle = topwindowhandle;
+ _G(oswi)[drawit].oldtop = _G(topwindowhandle);
+ _G(topwindowhandle) = drawit;
+ _G(oswi)[drawit].handle = _G(topwindowhandle);
win_x = xx;
win_y = yy;
win_width = wid;
@@ -129,8 +109,8 @@ int CSCIDrawWindow(int xx, int yy, int wid, int hit) {
void CSCIEraseWindow(int handl) {
// ags_domouse(DOMOUSE_DISABLE);
_G(ignore_bounds)--;
- topwindowhandle = oswi[handl].oldtop;
- oswi[handl].handle = -1;
+ _G(topwindowhandle) = _G(oswi)[handl].oldtop;
+ _G(oswi)[handl].handle = -1;
// ags_domouse(DOMOUSE_ENABLE);
windowcount--;
clear_gui_screen();
@@ -138,9 +118,9 @@ void CSCIEraseWindow(int handl) {
int CSCIWaitMessage(CSCIMessage *cscim) {
for (int uu = 0; uu < MAXCONTROLS; uu++) {
- if (vobjs[uu] != nullptr) {
+ if (_G(vobjs)[uu] != nullptr) {
// ags_domouse(DOMOUSE_DISABLE);
- vobjs[uu]->drawifneeded();
+ _G(vobjs)[uu]->drawifneeded();
// ags_domouse(DOMOUSE_ENABLE);
}
}
@@ -153,7 +133,7 @@ int CSCIWaitMessage(CSCIMessage *cscim) {
cscim->id = -1;
cscim->code = 0;
- smcode = 0;
+ _G(smcode) = 0;
int keywas;
if (run_service_key_controls(keywas) && !_GP(play).IsIgnoringInput()) {
if (keywas == 13) {
@@ -164,9 +144,9 @@ int CSCIWaitMessage(CSCIMessage *cscim) {
cscim->code = CM_COMMAND;
} else if ((keywas < 32) && (keywas != 8));
else if ((keywas >= 372) & (keywas <= 381) & (finddefaultcontrol(CNT_LISTBOX) >= 0))
- vobjs[finddefaultcontrol(CNT_LISTBOX)]->processmessage(CTB_KEYPRESS, keywas, 0);
+ _G(vobjs)[finddefaultcontrol(CNT_LISTBOX)]->processmessage(CTB_KEYPRESS, keywas, 0);
else if (finddefaultcontrol(CNT_TEXTBOX) >= 0)
- vobjs[finddefaultcontrol(CNT_TEXTBOX)]->processmessage(CTB_KEYPRESS, keywas, 0);
+ _G(vobjs)[finddefaultcontrol(CNT_TEXTBOX)]->processmessage(CTB_KEYPRESS, keywas, 0);
if (cscim->id < 0) {
cscim->code = CM_KEYPRESS;
@@ -177,14 +157,14 @@ int CSCIWaitMessage(CSCIMessage *cscim) {
int mbut, mwheelz;
if (run_service_mb_controls(mbut, mwheelz) && mbut >= 0 && !_GP(play).IsIgnoringInput()) {
if (checkcontrols()) {
- cscim->id = controlid;
+ cscim->id = _G(controlid);
cscim->code = CM_COMMAND;
}
}
- if (smcode) {
- cscim->code = smcode;
- cscim->id = controlid;
+ if (_G(smcode)) {
+ cscim->code = _G(smcode);
+ cscim->id = _G(controlid);
}
if (cscim->code > 0)
@@ -200,7 +180,7 @@ int CSCICreateControl(int typeandflags, int xx, int yy, int wii, int hii, const
multiply_up(&xx, &yy, &wii, &hii);
int usec = -1;
for (int hh = 1; hh < MAXCONTROLS; hh++) {
- if (vobjs[hh] == nullptr) {
+ if (_G(vobjs)[hh] == nullptr) {
usec = hh;
break;
}
@@ -212,36 +192,36 @@ int CSCICreateControl(int typeandflags, int xx, int yy, int wii, int hii, const
int type = typeandflags & 0x00ff; // 256 control types
if (type == CNT_PUSHBUTTON) {
if (wii == -1)
- wii = wgettextwidth(title, cbuttfont) + 20;
+ wii = wgettextwidth(title, _G(cbuttfont)) + 20;
- vobjs[usec] = new MyPushButton(xx, yy, wii, hii, title);
+ _G(vobjs)[usec] = new MyPushButton(xx, yy, wii, hii, title);
} else if (type == CNT_LISTBOX) {
- vobjs[usec] = new MyListBox(xx, yy, wii, hii);
+ _G(vobjs)[usec] = new MyListBox(xx, yy, wii, hii);
} else if (type == CNT_LABEL) {
- vobjs[usec] = new MyLabel(xx, yy, wii, title);
+ _G(vobjs)[usec] = new MyLabel(xx, yy, wii, title);
} else if (type == CNT_TEXTBOX) {
- vobjs[usec] = new MyTextBox(xx, yy, wii, title);
+ _G(vobjs)[usec] = new MyTextBox(xx, yy, wii, title);
} else
quit("Unknown control type requested");
- vobjs[usec]->typeandflags = typeandflags;
- vobjs[usec]->wlevel = topwindowhandle;
+ _G(vobjs)[usec]->typeandflags = typeandflags;
+ _G(vobjs)[usec]->wlevel = _G(topwindowhandle);
// ags_domouse(DOMOUSE_DISABLE);
- vobjs[usec]->draw(get_gui_screen());
+ _G(vobjs)[usec]->draw(get_gui_screen());
// ags_domouse(DOMOUSE_ENABLE);
return usec;
}
void CSCIDeleteControl(int haa) {
- delete vobjs[haa];
- vobjs[haa] = nullptr;
+ delete _G(vobjs)[haa];
+ _G(vobjs)[haa] = nullptr;
}
int CSCISendControlMessage(int haa, int mess, int wPar, NumberPtr lPar) {
- if (vobjs[haa] == nullptr)
+ if (_G(vobjs)[haa] == nullptr)
return -1;
- return vobjs[haa]->processmessage(mess, wPar, lPar);
+ return _G(vobjs)[haa]->processmessage(mess, wPar, lPar);
}
void multiply_up_to_game_res(int *x, int *y) {
@@ -273,12 +253,12 @@ int checkcontrols() {
const int mouseX = _G(mousex) - win_x;
const int mouseY = _G(mousey) - win_y;
- smcode = 0;
+ _G(smcode) = 0;
for (int kk = 0; kk < MAXCONTROLS; kk++) {
- if (vobjs[kk] != nullptr) {
- if (vobjs[kk]->mouseisinarea(mouseX, mouseY)) {
- controlid = kk;
- return vobjs[kk]->pressedon(mouseX, mouseY);
+ if (_G(vobjs)[kk] != nullptr) {
+ if (_G(vobjs)[kk]->mouseisinarea(mouseX, mouseY)) {
+ _G(controlid) = kk;
+ return _G(vobjs)[kk]->pressedon(mouseX, mouseY);
}
}
}
@@ -287,13 +267,13 @@ int checkcontrols() {
int finddefaultcontrol(int flagmask) {
for (int ff = 0; ff < MAXCONTROLS; ff++) {
- if (vobjs[ff] == nullptr)
+ if (_G(vobjs)[ff] == nullptr)
continue;
- if (vobjs[ff]->wlevel != topwindowhandle)
+ if (_G(vobjs)[ff]->wlevel != _G(topwindowhandle))
continue;
- if (vobjs[ff]->typeandflags & flagmask)
+ if (_G(vobjs)[ff]->typeandflags & flagmask)
return ff;
}
diff --git a/engines/ags/engine/gui/cscidialog.h b/engines/ags/engine/gui/cscidialog.h
index 5afe6ca286..74c4d3335d 100644
--- a/engines/ags/engine/gui/cscidialog.h
+++ b/engines/ags/engine/gui/cscidialog.h
@@ -33,6 +33,9 @@
namespace AGS3 {
+#define MAXCONTROLS 20
+#define MAXSCREENWINDOWS 5
+
int CSCIGetVersion();
int CSCIDrawWindow(int xx, int yy, int wid, int hit);
void CSCIEraseWindow(int handl);
diff --git a/engines/ags/engine/gui/mylabel.cpp b/engines/ags/engine/gui/mylabel.cpp
index f69c6ad595..3f118e16f7 100644
--- a/engines/ags/engine/gui/mylabel.cpp
+++ b/engines/ags/engine/gui/mylabel.cpp
@@ -33,8 +33,6 @@ namespace AGS3 {
using namespace Shared;
-extern int acdialog_font;
-
MyLabel::MyLabel(int xx, int yy, int wii, const char *tee) {
strncpy(text, tee, 150);
text[149] = 0;
@@ -49,10 +47,10 @@ void MyLabel::draw(Bitmap *ds) {
char *teptr = &text[0];
color_t text_color = ds->GetCompatibleColor(0);
- if (break_up_text_into_lines(teptr, _GP(fontLines), wid, acdialog_font) == 0)
+ if (break_up_text_into_lines(teptr, _GP(fontLines), wid, _G(acdialog_font)) == 0)
return;
for (size_t ee = 0; ee < _GP(fontLines).Count(); ee++) {
- wouttext_outline(ds, x, cyp, acdialog_font, text_color, _GP(fontLines)[ee]);
+ wouttext_outline(ds, x, cyp, _G(acdialog_font), text_color, _GP(fontLines)[ee]);
cyp += TEXT_HT;
}
}
diff --git a/engines/ags/engine/gui/mylistbox.cpp b/engines/ags/engine/gui/mylistbox.cpp
index f70581c982..c797992807 100644
--- a/engines/ags/engine/gui/mylistbox.cpp
+++ b/engines/ags/engine/gui/mylistbox.cpp
@@ -34,10 +34,6 @@ namespace AGS3 {
using AGS::Shared::Bitmap;
-extern int windowbackgroundcolor;
-extern int cbuttfont;
-extern int smcode;
-
MyListBox::MyListBox(int xx, int yy, int wii, int hii) {
x = xx;
y = yy;
@@ -63,7 +59,7 @@ MyListBox::~MyListBox() {
}
void MyListBox::draw(Bitmap *ds) {
- color_t draw_color = ds->GetCompatibleColor(windowbackgroundcolor);
+ color_t draw_color = ds->GetCompatibleColor(_G(windowbackgroundcolor));
ds->FillRect(Rect(x, y, x + wid, y + hit), draw_color);
draw_color = ds->GetCompatibleColor(0);
ds->DrawRect(Rect(x, y, x + wid, y + hit), draw_color);
@@ -102,7 +98,7 @@ void MyListBox::draw(Bitmap *ds) {
text_color = ds->GetCompatibleColor(7);
} else text_color = ds->GetCompatibleColor(0);
- wouttextxy(ds, x + 2, thisypos, cbuttfont, text_color, itemnames[inum]);
+ wouttextxy(ds, x + 2, thisypos, _G(cbuttfont), text_color, itemnames[inum]);
}
wid = widwas;
}
@@ -124,7 +120,7 @@ int MyListBox::pressedon(int mousex, int mousey) {
// ags_domouse(DOMOUSE_DISABLE);
draw(get_gui_screen());
// ags_domouse(DOMOUSE_ENABLE);
- smcode = CM_SELCHANGE;
+ _G(smcode) = CM_SELCHANGE;
return 0;
}
@@ -188,7 +184,7 @@ int MyListBox::processmessage(int mcode, int wParam, NumberPtr lParam) {
topitem = (selected + 1) - numonscreen;
drawandmouse();
- smcode = CM_SELCHANGE;
+ _G(smcode) = CM_SELCHANGE;
} else
return -1;
diff --git a/engines/ags/engine/gui/mypushbutton.cpp b/engines/ags/engine/gui/mypushbutton.cpp
index 1ee5860875..76d71f080a 100644
--- a/engines/ags/engine/gui/mypushbutton.cpp
+++ b/engines/ags/engine/gui/mypushbutton.cpp
@@ -37,10 +37,6 @@ namespace AGS3 {
using AGS::Shared::Bitmap;
-extern int windowbackgroundcolor, pushbuttondarkcolor;
-extern int pushbuttonlightcolor;
-extern int cbuttfont;
-
MyPushButton::MyPushButton(int xx, int yy, int wi, int hi, const char *tex) {
//wlevel=2;
x = xx;
@@ -57,23 +53,23 @@ void MyPushButton::draw(Bitmap *ds) {
color_t draw_color = ds->GetCompatibleColor(COL254);
ds->FillRect(Rect(x, y, x + wid, y + hit), draw_color);
if (state == 0)
- draw_color = ds->GetCompatibleColor(pushbuttondarkcolor);
+ draw_color = ds->GetCompatibleColor(_G(pushbuttondarkcolor));
else
- draw_color = ds->GetCompatibleColor(pushbuttonlightcolor);
+ draw_color = ds->GetCompatibleColor(_G(pushbuttonlightcolor));
ds->DrawRect(Rect(x, y, x + wid, y + hit), draw_color);
if (state == 0)
- draw_color = ds->GetCompatibleColor(pushbuttonlightcolor);
+ draw_color = ds->GetCompatibleColor(_G(pushbuttonlightcolor));
else
- draw_color = ds->GetCompatibleColor(pushbuttondarkcolor);
+ draw_color = ds->GetCompatibleColor(_G(pushbuttondarkcolor));
ds->DrawLine(Line(x, y, x + wid - 1, y), draw_color);
ds->DrawLine(Line(x, y, x, y + hit - 1), draw_color);
- wouttextxy(ds, x + (wid / 2 - wgettextwidth(text, cbuttfont) / 2), y + 2, cbuttfont, text_color, text);
+ wouttextxy(ds, x + (wid / 2 - wgettextwidth(text, _G(cbuttfont)) / 2), y + 2, _G(cbuttfont), text_color, text);
if (typeandflags & CNF_DEFAULT)
draw_color = ds->GetCompatibleColor(0);
else
- draw_color = ds->GetCompatibleColor(windowbackgroundcolor);
+ draw_color = ds->GetCompatibleColor(_G(windowbackgroundcolor));
ds->DrawRect(Rect(x - 1, y - 1, x + wid + 1, y + hit + 1), draw_color);
}
diff --git a/engines/ags/engine/gui/mytextbox.cpp b/engines/ags/engine/gui/mytextbox.cpp
index 9207b2c0f9..32556aaf6b 100644
--- a/engines/ags/engine/gui/mytextbox.cpp
+++ b/engines/ags/engine/gui/mytextbox.cpp
@@ -31,9 +31,6 @@ namespace AGS3 {
using AGS::Shared::Bitmap;
-extern int windowbackgroundcolor;
-extern int cbuttfont;
-
MyTextBox::MyTextBox(int xx, int yy, int wii, const char *tee) {
x = xx;
y = yy;
@@ -47,15 +44,15 @@ MyTextBox::MyTextBox(int xx, int yy, int wii, const char *tee) {
}
void MyTextBox::draw(Bitmap *ds) {
- color_t draw_color = ds->GetCompatibleColor(windowbackgroundcolor);
+ color_t draw_color = ds->GetCompatibleColor(_G(windowbackgroundcolor));
ds->FillRect(Rect(x, y, x + wid, y + hit), draw_color);
draw_color = ds->GetCompatibleColor(0);
ds->DrawRect(Rect(x, y, x + wid, y + hit), draw_color);
color_t text_color = ds->GetCompatibleColor(0);
- wouttextxy(ds, x + 2, y + 1, cbuttfont, text_color, text);
+ wouttextxy(ds, x + 2, y + 1, _G(cbuttfont), text_color, text);
char tbu[2] = "_";
- wouttextxy(ds, x + 2 + wgettextwidth(text, cbuttfont), y + 1, cbuttfont, text_color, tbu);
+ wouttextxy(ds, x + 2 + wgettextwidth(text, _G(cbuttfont)), y + 1, _G(cbuttfont), text_color, tbu);
}
int MyTextBox::pressedon(int mousex, int mousey) {
@@ -76,7 +73,7 @@ int MyTextBox::processmessage(int mcode, int wParam, NumberPtr lParam) {
drawandmouse();
} else if (strlen(text) >= TEXTBOX_MAXLEN - 1)
;
- else if (wgettextwidth(text, cbuttfont) >= wid - 5)
+ else if (wgettextwidth(text, _G(cbuttfont)) >= wid - 5)
;
else if (wParam > 127)
; // font only has 128 chars
diff --git a/engines/ags/engine/gui/newcontrol.cpp b/engines/ags/engine/gui/newcontrol.cpp
index 320479976c..f52799fd37 100644
--- a/engines/ags/engine/gui/newcontrol.cpp
+++ b/engines/ags/engine/gui/newcontrol.cpp
@@ -27,8 +27,6 @@
namespace AGS3 {
-extern int topwindowhandle;
-
NewControl::NewControl(int xx, int yy, int wi, int hi) {
x = xx;
y = yy;
@@ -53,7 +51,7 @@ NewControl::NewControl() {
}
int NewControl::mouseisinarea(int mousex, int mousey) {
- if (topwindowhandle != wlevel)
+ if (_G(topwindowhandle) != wlevel)
return 0;
if ((mousex > x) && (mousex < x + wid) && (mousey > y) && (mousey < y + hit))
@@ -63,7 +61,7 @@ int NewControl::mouseisinarea(int mousex, int mousey) {
}
void NewControl::drawifneeded() {
- if (topwindowhandle != wlevel)
+ if (_G(topwindowhandle) != wlevel)
return;
if (needredraw) {
needredraw = 0;
diff --git a/engines/ags/globals.cpp b/engines/ags/globals.cpp
index 90d6eef95f..c6fb3f5394 100644
--- a/engines/ags/globals.cpp
+++ b/engines/ags/globals.cpp
@@ -76,6 +76,9 @@
#include "ags/engine/debugging/messagebuffer.h"
#include "ags/engine/device/mousew32.h"
#include "ags/engine/gui/animatingguibutton.h"
+#include "ags/engine/gui/cscidialog.h"
+#include "ags/engine/gui/guidialogdefines.h"
+#include "ags/engine/gui/newcontrol.h"
#include "ags/engine/main/graphics_mode.h"
#include "ags/engine/media/audio/ambientsound.h"
#include "ags/engine/media/audio/audiodefines.h"
@@ -110,6 +113,14 @@ Globals::Globals() {
// cc_serializer.cpp globals
_ccUnserializer = new AGSDeSerializer();
+ // cscdialog.cpp globals
+ _vobjs = new NewControl *[MAXCONTROLS];
+ _oswi = new OnScreenWindow[MAXSCREENWINDOWS];
+ Common::fill(_vobjs, _vobjs + MAXCONTROLS, (NewControl *)nullptr);
+ _windowbackgroundcolor = COL254;
+ _pushbuttondarkcolor = COL255;
+ _pushbuttonlightcolor = COL253;
+
// debug.cpp globals
_fps = std::numeric_limits<float>::quiet_undefined();
_display_fps = kFPS_Hide;
@@ -274,6 +285,10 @@ Globals::~Globals() {
// cc_serializer.cpp globals
delete _ccUnserializer;
+ // cscdialog.cpp globals
+ delete[] _vobjs;
+ delete[] _oswi;
+
// debug.cpp globals
delete[] _debug_line;
delete _DebugMsgBuff;
diff --git a/engines/ags/globals.h b/engines/ags/globals.h
index cf74260b7f..b184161d68 100644
--- a/engines/ags/globals.h
+++ b/engines/ags/globals.h
@@ -114,8 +114,10 @@ struct IAGSEditorDebugger;
struct ManagedObjectPool;
struct Mouse;
struct MoveList;
+struct NewControl;
struct NonBlockingScriptFunction;
struct ObjectCache;
+struct OnScreenWindow;
struct ResourcePaths;
struct RGB_MAP;
struct RoomCameraDrawData;
@@ -308,6 +310,25 @@ public:
/**@}*/
+ /**
+ * \defgroup cscdialog globals
+ * @{
+ */
+
+ int _windowbackgroundcolor, _pushbuttondarkcolor;
+ int _pushbuttonlightcolor;
+ int _topwindowhandle = -1;
+ int _cbuttfont = 0;
+ int _acdialog_font = 0;
+ int _smcode = 0;
+ int _controlid = 0;
+ NewControl **_vobjs;
+ OnScreenWindow *_oswi;
+
+ int controlid = 0;
+
+ /**@}*/
+
/**
* \defgroup debug globals
* @{
Commit: 236250a94547efbac5b186031be93f972359aebe
https://github.com/scummvm/scummvm/commit/236250a94547efbac5b186031be93f972359aebe
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-10T20:14:15-08:00
Commit Message:
AGS: Move display.cpp globals to Globals
Changed paths:
engines/ags/engine/ac/character.cpp
engines/ags/engine/ac/display.cpp
engines/ags/engine/ac/display.h
engines/ags/engine/ac/global_display.cpp
engines/ags/engine/ac/global_translation.cpp
engines/ags/engine/script/script.cpp
engines/ags/globals.cpp
engines/ags/globals.h
diff --git a/engines/ags/engine/ac/character.cpp b/engines/ags/engine/ac/character.cpp
index e28ce1e7a0..eca9406b76 100644
--- a/engines/ags/engine/ac/character.cpp
+++ b/engines/ags/engine/ac/character.cpp
@@ -2218,8 +2218,8 @@ void _DisplaySpeechCore(int chid, const char *displbuf) {
// adjust timing of text (so that DisplaySpeech("%s", str) pauses
// for the length of the string not 2 frames)
int len = (int)strlen(displbuf);
- if (len > source_text_length + 3)
- source_text_length = len;
+ if (len > _G(source_text_length) + 3)
+ _G(source_text_length) = len;
DisplaySpeech(displbuf, chid);
}
@@ -2228,8 +2228,8 @@ void _DisplayThoughtCore(int chid, const char *displbuf) {
// adjust timing of text (so that DisplayThought("%s", str) pauses
// for the length of the string not 2 frames)
int len = (int)strlen(displbuf);
- if (len > source_text_length + 3)
- source_text_length = len;
+ if (len > _G(source_text_length) + 3)
+ _G(source_text_length) = len;
int xpp = -1, ypp = -1, width = -1;
diff --git a/engines/ags/engine/ac/display.cpp b/engines/ags/engine/ac/display.cpp
index 58e226f8dd..f64258949c 100644
--- a/engines/ags/engine/ac/display.cpp
+++ b/engines/ags/engine/ac/display.cpp
@@ -60,15 +60,6 @@ namespace AGS3 {
using namespace AGS::Shared;
using namespace AGS::Shared::BitmapHelper;
-int display_message_aschar = 0;
-
-TopBarSettings topBar;
-struct DisplayVars {
- int lineheight; // font's height of single line
- int linespacing; // font's line spacing
- int fulltxtheight; // total height of all the text
-} disp;
-
// Pass yy = -1 to find Y co-ord automatically
// allowShrink = 0 for none, 1 for leftwards, 2 for rightwards
// pass blocking=2 to create permanent overlay
@@ -91,9 +82,9 @@ int _display_main(int xx, int yy, int wii, const char *text, int disp_type, int
ensure_text_valid_for_font(todis, usingfont);
break_up_text_into_lines(todis, _GP(fontLines), wii - 2 * padding, usingfont);
- disp.lineheight = getfontheight_outlined(usingfont);
- disp.linespacing = getfontspacing_outlined(usingfont);
- disp.fulltxtheight = getheightoflines(usingfont, _GP(fontLines).Count());
+ _G(disp).lineheight = getfontheight_outlined(usingfont);
+ _G(disp).linespacing = getfontspacing_outlined(usingfont);
+ _G(disp).fulltxtheight = getheightoflines(usingfont, _GP(fontLines).Count());
// AGS 2.x: If the screen is faded out, fade in again when displaying a message box.
if (!asspch && (loaded_game_file_version <= kGameVersion_272))
@@ -108,10 +99,10 @@ int _display_main(int xx, int yy, int wii, const char *text, int disp_type, int
EndSkippingUntilCharStops();
- if (topBar.wantIt) {
+ if (_GP(topBar).wantIt) {
// ensure that the window is wide enough to display
// any top bar text
- int topBarWid = wgettextwidth_compensate(topBar.text, topBar.font);
+ int topBarWid = wgettextwidth_compensate(_GP(topBar).text, _GP(topBar).font);
topBarWid += data_to_game_coord(_GP(play).top_bar_borderwidth + 2) * 2;
if (_G(longestline) < topBarWid)
_G(longestline) = topBarWid;
@@ -130,10 +121,10 @@ int _display_main(int xx, int yy, int wii, const char *text, int disp_type, int
const Rect &ui_view = _GP(play).GetUIViewport();
if (xx == OVR_AUTOPLACE);
// centre text in middle of screen
- else if (yy < 0) yy = ui_view.GetHeight() / 2 - disp.fulltxtheight / 2 - padding;
+ else if (yy < 0) yy = ui_view.GetHeight() / 2 - _G(disp).fulltxtheight / 2 - padding;
// speech, so it wants to be above the character's head
else if (asspch > 0) {
- yy -= disp.fulltxtheight;
+ yy -= _G(disp).fulltxtheight;
if (yy < 5) yy = 5;
yy = adjust_y_for_guis(yy);
}
@@ -167,7 +158,7 @@ int _display_main(int xx, int yy, int wii, const char *text, int disp_type, int
if (disp_type < DISPLAYTEXT_NORMALOVERLAY)
remove_screen_overlay(OVER_TEXTMSG); // remove any previous blocking texts
- Bitmap *text_window_ds = BitmapHelper::CreateTransparentBitmap((wii > 0) ? wii : 2, disp.fulltxtheight + extraHeight, _GP(game).GetColorDepth());
+ Bitmap *text_window_ds = BitmapHelper::CreateTransparentBitmap((wii > 0) ? wii : 2, _G(disp).fulltxtheight + extraHeight, _GP(game).GetColorDepth());
// inform draw_text_window to free the old bitmap
const bool wantFreeScreenop = true;
@@ -204,7 +195,7 @@ int _display_main(int xx, int yy, int wii, const char *text, int disp_type, int
for (size_t ee = 0; ee < _GP(fontLines).Count(); ee++) {
//int ttxp=wii/2 - wgettextwidth_compensate(lines[ee], usingfont)/2;
- int ttyp = ttxtop + ee * disp.linespacing;
+ int ttyp = ttxtop + ee * _G(disp).linespacing;
// asspch < 0 means that it's inside a text box so don't
// centre the text
if (asspch < 0) {
@@ -231,7 +222,7 @@ int _display_main(int xx, int yy, int wii, const char *text, int disp_type, int
adjust_y_coordinate_for_text(&yoffs, usingfont);
for (size_t ee = 0; ee < _GP(fontLines).Count(); ee++)
- wouttext_aligned(text_window_ds, xoffs, yoffs + ee * disp.linespacing, oriwid, usingfont, text_color, _GP(fontLines)[ee], _GP(play).text_align);
+ wouttext_aligned(text_window_ds, xoffs, yoffs + ee * _G(disp).linespacing, oriwid, usingfont, text_color, _GP(fontLines)[ee], _GP(play).text_align);
}
int ovrtype = OVER_TEXTMSG;
@@ -375,10 +366,6 @@ bool try_auto_play_speech(const char *text, const char *&replace_text, int chari
return false;
}
-// TODO: refactor this global variable out; currently it is set at the every get_translation call.
-// Be careful: a number of Say/Display functions expect it to be set beforehand.
-int source_text_length = -1;
-
int GetTextDisplayLength(const char *text) {
int len = (int)strlen(text);
if ((text[0] == '&') && (_GP(play).unfactor_speech_from_textlength != 0)) {
@@ -400,11 +387,11 @@ int GetTextDisplayTime(const char *text, int canberel) {
if ((canberel == 1) && (_GP(play).bgspeech_game_speed == 1))
fpstimer = 40;
- if (source_text_length >= 0) {
+ if (_G(source_text_length) >= 0) {
// sync to length of original text, to make sure any animations
// and music sync up correctly
- uselen = source_text_length;
- source_text_length = -1;
+ uselen = _G(source_text_length);
+ _G(source_text_length) = -1;
} else {
uselen = GetTextDisplayLength(text);
}
@@ -736,7 +723,7 @@ void draw_text_window(Bitmap **text_window_ds, bool should_free_ds,
xx[0] -= _GP(game).SpriteInfos[tbnum].Width;
yy[0] -= _GP(game).SpriteInfos[tbnum].Height;
if (ovrheight == 0)
- ovrheight = disp.fulltxtheight;
+ ovrheight = _G(disp).fulltxtheight;
if (should_free_ds)
delete *text_window_ds;
@@ -757,37 +744,37 @@ void draw_text_window_and_bar(Bitmap **text_window_ds, bool should_free_ds,
draw_text_window(text_window_ds, should_free_ds, xins, yins, xx, yy, wii, set_text_color, ovrheight, ifnum);
- if ((topBar.wantIt) && (text_window_ds && *text_window_ds)) {
+ if ((_GP(topBar).wantIt) && (text_window_ds && *text_window_ds)) {
// top bar on the dialog window with character's name
// create an enlarged window, then free the old one
Bitmap *ds = *text_window_ds;
- Bitmap *newScreenop = BitmapHelper::CreateBitmap(ds->GetWidth(), ds->GetHeight() + topBar.height, _GP(game).GetColorDepth());
- newScreenop->Blit(ds, 0, 0, 0, topBar.height, ds->GetWidth(), ds->GetHeight());
+ Bitmap *newScreenop = BitmapHelper::CreateBitmap(ds->GetWidth(), ds->GetHeight() + _GP(topBar).height, _GP(game).GetColorDepth());
+ newScreenop->Blit(ds, 0, 0, 0, _GP(topBar).height, ds->GetWidth(), ds->GetHeight());
delete *text_window_ds;
*text_window_ds = newScreenop;
ds = *text_window_ds;
// draw the top bar
color_t draw_color = ds->GetCompatibleColor(_GP(play).top_bar_backcolor);
- ds->FillRect(Rect(0, 0, ds->GetWidth() - 1, topBar.height - 1), draw_color);
+ ds->FillRect(Rect(0, 0, ds->GetWidth() - 1, _GP(topBar).height - 1), draw_color);
if (_GP(play).top_bar_backcolor != _GP(play).top_bar_bordercolor) {
// draw the border
draw_color = ds->GetCompatibleColor(_GP(play).top_bar_bordercolor);
for (int j = 0; j < data_to_game_coord(_GP(play).top_bar_borderwidth); j++)
- ds->DrawRect(Rect(j, j, ds->GetWidth() - (j + 1), topBar.height - (j + 1)), draw_color);
+ ds->DrawRect(Rect(j, j, ds->GetWidth() - (j + 1), _GP(topBar).height - (j + 1)), draw_color);
}
// draw the text
- int textx = (ds->GetWidth() / 2) - wgettextwidth_compensate(topBar.text, topBar.font) / 2;
+ int textx = (ds->GetWidth() / 2) - wgettextwidth_compensate(_GP(topBar).text, _GP(topBar).font) / 2;
color_t text_color = ds->GetCompatibleColor(_GP(play).top_bar_textcolor);
- wouttext_outline(ds, textx, _GP(play).top_bar_borderwidth + get_fixed_pixel_size(1), topBar.font, text_color, topBar.text);
+ wouttext_outline(ds, textx, _GP(play).top_bar_borderwidth + get_fixed_pixel_size(1), _GP(topBar).font, text_color, _GP(topBar).text);
// don't draw it next time
- topBar.wantIt = 0;
+ _GP(topBar).wantIt = 0;
// adjust the text Y position
- yins[0] += topBar.height;
- } else if (topBar.wantIt)
- topBar.wantIt = 0;
+ yins[0] += _GP(topBar).height;
+ } else if (_GP(topBar).wantIt)
+ _GP(topBar).wantIt = 0;
}
} // namespace AGS3
diff --git a/engines/ags/engine/ac/display.h b/engines/ags/engine/ac/display.h
index d202c03fba..d3ea28f6eb 100644
--- a/engines/ags/engine/ac/display.h
+++ b/engines/ags/engine/ac/display.h
@@ -81,9 +81,6 @@ void draw_text_window_and_bar(Shared::Bitmap **text_window_ds, bool should_free_
int *xins, int *yins, int *xx, int *yy, int *wii, color_t *set_text_color, int ovrheight = 0, int ifnum = -1);
int get_textwindow_padding(int ifnum);
-// The efficient length of the last source text prepared for display
-extern int source_text_length;
-
} // namespace AGS3
#endif
diff --git a/engines/ags/engine/ac/global_display.cpp b/engines/ags/engine/ac/global_display.cpp
index 500e482c99..661a4310cf 100644
--- a/engines/ags/engine/ac/global_display.cpp
+++ b/engines/ags/engine/ac/global_display.cpp
@@ -44,12 +44,6 @@ namespace AGS3 {
using namespace AGS::Shared;
-extern TopBarSettings topBar;
-
-
-extern int display_message_aschar;
-
-
void Display(const char *texx, ...) {
char displbuf[STD_BUFFER_SIZE];
va_list ap;
@@ -64,10 +58,10 @@ void DisplaySimple(const char *text) {
}
void DisplayTopBar(int ypos, int ttexcol, int backcol, const char *title, const char *text) {
- // FIXME: refactor source_text_length and get rid of this ugly hack!
- const int real_text_sourcelen = source_text_length;
- snprintf(topBar.text, sizeof(topBar.text), "%s", get_translation(title));
- source_text_length = real_text_sourcelen;
+ // FIXME: refactor _G(source_text_length) and get rid of this ugly hack!
+ const int real_text_sourcelen = _G(source_text_length);
+ snprintf(_GP(topBar).text, sizeof(_GP(topBar).text), "%s", get_translation(title));
+ _G(source_text_length) = real_text_sourcelen;
if (ypos > 0)
_GP(play).top_bar_ypos = ypos;
@@ -76,14 +70,14 @@ void DisplayTopBar(int ypos, int ttexcol, int backcol, const char *title, const
if (backcol > 0)
_GP(play).top_bar_backcolor = backcol;
- topBar.wantIt = 1;
- topBar.font = FONT_NORMAL;
- topBar.height = getfontheight_outlined(topBar.font);
- topBar.height += data_to_game_coord(_GP(play).top_bar_borderwidth) * 2 + get_fixed_pixel_size(1);
+ _GP(topBar).wantIt = 1;
+ _GP(topBar).font = FONT_NORMAL;
+ _GP(topBar).height = getfontheight_outlined(_GP(topBar).font);
+ _GP(topBar).height += data_to_game_coord(_GP(play).top_bar_borderwidth) * 2 + get_fixed_pixel_size(1);
// they want to customize the font
if (_GP(play).top_bar_font >= 0)
- topBar.font = _GP(play).top_bar_font;
+ _GP(topBar).font = _GP(play).top_bar_font;
// DisplaySpeech normally sets this up, but since we're not going via it...
if (_GP(play).cant_skip_speech & SKIP_AUTOTIMER)
@@ -103,16 +97,16 @@ void DisplayMessageAtY(int msnum, int ypos) {
char msgbufr[3001];
if (msnum >= 500) {
get_message_text(msnum, msgbufr);
- if (display_message_aschar > 0)
- DisplaySpeech(msgbufr, display_message_aschar);
+ if (_G(display_message_aschar) > 0)
+ DisplaySpeech(msgbufr, _G(display_message_aschar));
else
DisplayAtY(ypos, msgbufr);
- display_message_aschar = 0;
+ _G(display_message_aschar) = 0;
return;
}
- if (display_message_aschar > 0) {
- display_message_aschar = 0;
+ if (_G(display_message_aschar) > 0) {
+ _G(display_message_aschar) = 0;
quit("!DisplayMessage: data column specified a character for local\n"
"message; use the message editor to select the character for room\n"
"messages.\n");
diff --git a/engines/ags/engine/ac/global_translation.cpp b/engines/ags/engine/ac/global_translation.cpp
index 9290c3caa2..cc6f47d18f 100644
--- a/engines/ags/engine/ac/global_translation.cpp
+++ b/engines/ags/engine/ac/global_translation.cpp
@@ -31,13 +31,12 @@
#include "ags/plugins/plugin_engine.h"
#include "ags/shared/util/memory.h"
#include "ags/shared/core/types.h"
+#include "ags/globals.h"
namespace AGS3 {
using namespace AGS::Shared::Memory;
-
-
extern TreeMap *transtree;
extern char transFileName[MAX_PATH];
@@ -45,7 +44,7 @@ const char *get_translation(const char *text) {
if (text == nullptr)
quit("!Null string supplied to CheckForTranslations");
- source_text_length = GetTextDisplayLength(text);
+ _G(source_text_length) = GetTextDisplayLength(text);
#if AGS_PLATFORM_64BIT
// check if a plugin wants to translate it - if so, return that
diff --git a/engines/ags/engine/script/script.cpp b/engines/ags/engine/script/script.cpp
index 9d02657702..d320465552 100644
--- a/engines/ags/engine/script/script.cpp
+++ b/engines/ags/engine/script/script.cpp
@@ -657,7 +657,7 @@ int run_interaction_commandlist(InteractionCommandList *nicl, int *timesrun, int
break;
case 4: // Display Message
/* if (comprdata<0)
- display_message_aschar=evb->data[ss];*/
+ _G(display_message_aschar)=evb->data[ss];*/
DisplayMessage(IPARAM1);
break;
case 5: // Play Music
diff --git a/engines/ags/globals.cpp b/engines/ags/globals.cpp
index c6fb3f5394..0ab304ab7f 100644
--- a/engines/ags/globals.cpp
+++ b/engines/ags/globals.cpp
@@ -49,6 +49,7 @@
#include "ags/engine/ac/route_finder_jps.h"
#include "ags/engine/ac/screenoverlay.h"
#include "ags/engine/ac/spritelistentry.h"
+#include "ags/engine/ac/topbarsettings.h"
#include "ags/engine/ac/dynobj/cc_audiochannel.h"
#include "ags/engine/ac/dynobj/cc_audioclip.h"
#include "ags/engine/ac/dynobj/cc_character.h"
@@ -135,6 +136,9 @@ Globals::Globals() {
// dialog.cpp globals
_ccDialogOptionsRendering = new ScriptDialogOptionsRendering();
+ // display.cpp globals
+ _topBar = new TopBarSettings();
+
// draw.cpp globals
_CameraDrawData = new std::vector<RoomCameraDrawData>();
_sprlist = new std::vector<SpriteListEntry>();
@@ -301,6 +305,9 @@ Globals::~Globals() {
// dialog.cpp globals
delete _ccDialogOptionsRendering;
+ // display.cpp globals
+ delete _topBar;
+
// draw.cpp globals
delete _CameraDrawData;
delete _sprlist;
diff --git a/engines/ags/globals.h b/engines/ags/globals.h
index b184161d68..756b56aaa7 100644
--- a/engines/ags/globals.h
+++ b/engines/ags/globals.h
@@ -143,6 +143,7 @@ struct SpeechLipSyncLine;
struct SpriteListEntry;
struct StaticArray;
struct SystemImports;
+struct TopBarSettings;
struct ViewStruct;
class Globals {
@@ -389,6 +390,23 @@ public:
/**@}*/
+ /**
+ * \defgroup display globals
+ * @{
+ */
+
+ int _display_message_aschar = 0;
+ int _source_text_length = -1;
+
+ TopBarSettings *_topBar;
+ struct DisplayVars {
+ int lineheight = 0; // font's height of single line
+ int linespacing = 0; // font's line spacing
+ int fulltxtheight = 0; // total height of all the text
+ } _disp;
+
+ /**@}*/
+
/**
* \defgroup draw globals
* @{
Commit: b91cae25d6a086e3b3a12a9a618e00bf9b1cc070
https://github.com/scummvm/scummvm/commit/b91cae25d6a086e3b3a12a9a618e00bf9b1cc070
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-10T20:31:46-08:00
Commit Message:
AGS: Move walkbehind.cpp globals to Globals
Changed paths:
engines/ags/engine/ac/draw.cpp
engines/ags/engine/ac/global_walkbehind.cpp
engines/ags/engine/ac/walkbehind.cpp
engines/ags/engine/main/game_run.cpp
engines/ags/globals.cpp
engines/ags/globals.h
diff --git a/engines/ags/engine/ac/draw.cpp b/engines/ags/engine/ac/draw.cpp
index 5da672db75..0181388068 100644
--- a/engines/ags/engine/ac/draw.cpp
+++ b/engines/ags/engine/ac/draw.cpp
@@ -88,15 +88,6 @@ extern "C" void android_render();
extern "C" void ios_render();
#endif
-extern char noWalkBehindsAtAll;
-extern char *walkBehindExists; // whether a WB area is in this column
-extern int *walkBehindStartY, *walkBehindEndY;
-extern int walkBehindLeft[MAX_WALK_BEHINDS], walkBehindTop[MAX_WALK_BEHINDS];
-extern int walkBehindRight[MAX_WALK_BEHINDS], walkBehindBottom[MAX_WALK_BEHINDS];
-extern IDriverDependantBitmap *walkBehindBitmap[MAX_WALK_BEHINDS];
-extern int walkBehindsCachedForBgNum;
-extern WalkBehindMethodEnum walkBehindMethod;
-extern int walk_behind_baselines_changed;
extern int bg_just_changed;
color palette[256];
@@ -403,10 +394,10 @@ int MakeColor(int color_index) {
void init_draw_method() {
if (_G(gfxDriver)->HasAcceleratedTransform()) {
- walkBehindMethod = DrawAsSeparateSprite;
+ _G(walkBehindMethod) = DrawAsSeparateSprite;
create_blank_image(_GP(game).GetColorDepth());
} else {
- walkBehindMethod = DrawOverCharSprite;
+ _G(walkBehindMethod) = DrawOverCharSprite;
}
on_mainviewport_changed();
@@ -725,7 +716,7 @@ void invalidate_cached_walkbehinds() {
// of it with transparent pixels where there are walk-behind areas
// Returns whether any pixels were updated
int sort_out_walk_behinds(Bitmap *sprit, int xx, int yy, int basel, Bitmap *copyPixelsFrom = nullptr, Bitmap *checkPixelsFrom = nullptr, int zoom = 100) {
- if (noWalkBehindsAtAll)
+ if (_G(noWalkBehindsAtAll))
return 0;
if ((!_GP(thisroom).WalkBehindMask->IsMemoryBitmap()) ||
@@ -751,25 +742,25 @@ int sort_out_walk_behinds(Bitmap *sprit, int xx, int yy, int basel, Bitmap *copy
if (ee + xx >= _GP(thisroom).WalkBehindMask->GetWidth())
break;
- if ((!walkBehindExists[ee + xx]) ||
- (walkBehindEndY[ee + xx] <= yy) ||
- (walkBehindStartY[ee + xx] > yy + sprit->GetHeight()))
+ if ((!_G(walkBehindExists)[ee + xx]) ||
+ (_G(walkBehindEndY)[ee + xx] <= yy) ||
+ (_G(walkBehindStartY)[ee + xx] > yy + sprit->GetHeight()))
continue;
toheight = sprit->GetHeight();
- if (walkBehindStartY[ee + xx] < yy)
+ if (_G(walkBehindStartY)[ee + xx] < yy)
rr = 0;
else
- rr = (walkBehindStartY[ee + xx] - yy);
+ rr = (_G(walkBehindStartY)[ee + xx] - yy);
// Since we will use _getpixel, ensure we only check within the screen
if (rr + yy < 0)
rr = 0 - yy;
if (toheight + yy > screenhit)
toheight = screenhit - yy;
- if (toheight + yy > walkBehindEndY[ee + xx])
- toheight = walkBehindEndY[ee + xx] - yy;
+ if (toheight + yy > _G(walkBehindEndY)[ee + xx])
+ toheight = _G(walkBehindEndY)[ee + xx] - yy;
if (rr < 0)
rr = 0;
@@ -833,7 +824,7 @@ int sort_out_walk_behinds(Bitmap *sprit, int xx, int yy, int basel, Bitmap *copy
}
void sort_out_char_sprite_walk_behind(int actspsIndex, int xx, int yy, int basel, int zoom, int width, int height) {
- if (noWalkBehindsAtAll)
+ if (_G(noWalkBehindsAtAll))
return;
if ((!_G(actspswbcache)[actspsIndex].valid) ||
@@ -899,7 +890,7 @@ void add_to_sprite_list(IDriverDependantBitmap *spp, int xx, int yy, int baselin
sprite.y = yy;
sprite.transparent = trans;
- if (walkBehindMethod == DrawAsSeparateSprite)
+ if (_G(walkBehindMethod) == DrawAsSeparateSprite)
sprite.takesPriorityIfEqual = !isWalkBehind;
else
sprite.takesPriorityIfEqual = isWalkBehind;
@@ -963,10 +954,10 @@ bool spritelistentry_less(const SpriteListEntry &e1, const SpriteListEntry &e2)
void draw_sprite_list() {
- if (walkBehindMethod == DrawAsSeparateSprite) {
+ if (_G(walkBehindMethod) == DrawAsSeparateSprite) {
for (int ee = 1; ee < MAX_WALK_BEHINDS; ee++) {
- if (walkBehindBitmap[ee] != nullptr) {
- add_to_sprite_list(walkBehindBitmap[ee], walkBehindLeft[ee], walkBehindTop[ee],
+ if (_G(walkBehindBitmap)[ee] != nullptr) {
+ add_to_sprite_list(_G(walkBehindBitmap)[ee], _G(walkBehindLeft)[ee], _G(walkBehindTop)[ee],
_G(croom)->walkbehind_base[ee], 0, -1, true);
}
}
@@ -1308,7 +1299,7 @@ int construct_object_gfx(int aa, int *drawnWidth, int *drawnHeight, bool alwaysU
}
if ((hardwareAccelerated) &&
- (walkBehindMethod != DrawOverCharSprite) &&
+ (_G(walkBehindMethod) != DrawOverCharSprite) &&
(_G(objcache)[aa].image != nullptr) &&
(_G(objcache)[aa].sppic == _G(objs)[aa].num) &&
(_G(actsps)[useindx] != nullptr)) {
@@ -1343,7 +1334,7 @@ int construct_object_gfx(int aa, int *drawnWidth, int *drawnHeight, bool alwaysU
(_G(objcache)[aa].zoomWas == zoom_level) &&
(_G(objcache)[aa].mirroredWas == isMirrored)) {
// the image is the same, we can use it cached!
- if ((walkBehindMethod != DrawOverCharSprite) &&
+ if ((_G(walkBehindMethod) != DrawOverCharSprite) &&
(_G(actsps)[useindx] != nullptr))
return 1;
// Check if the X & Y co-ords are the same, too -- if so, there
@@ -1351,7 +1342,7 @@ int construct_object_gfx(int aa, int *drawnWidth, int *drawnHeight, bool alwaysU
if ((_G(objcache)[aa].xwas == _G(objs)[aa].x) &&
(_G(objcache)[aa].ywas == _G(objs)[aa].y) &&
(_G(actsps)[useindx] != nullptr) &&
- (walk_behind_baselines_changed == 0))
+ (_G(walk_behind_baselines_changed) == 0))
return 1;
_G(actsps)[useindx] = recycle_bitmap(_G(actsps)[useindx], coldept, sprwidth, sprheight);
_G(actsps)[useindx]->Blit(_G(objcache)[aa].image, 0, 0, 0, 0, _G(objcache)[aa].image->GetWidth(), _G(objcache)[aa].image->GetHeight());
@@ -1429,12 +1420,12 @@ void prepare_objects_for_drawing() {
if (_G(objs)[aa].flags & OBJF_NOWALKBEHINDS) {
// ignore walk-behinds, do nothing
- if (walkBehindMethod == DrawAsSeparateSprite) {
+ if (_G(walkBehindMethod) == DrawAsSeparateSprite) {
usebasel += _GP(thisroom).Height;
}
- } else if (walkBehindMethod == DrawAsSeparateCharSprite) {
+ } else if (_G(walkBehindMethod) == DrawAsSeparateCharSprite) {
sort_out_char_sprite_walk_behind(useindx, atxp, atyp, usebasel, _G(objs)[aa].zoom, _G(objs)[aa].last_width, _G(objs)[aa].last_height);
- } else if ((!actspsIntact) && (walkBehindMethod == DrawOverCharSprite)) {
+ } else if ((!actspsIntact) && (_G(walkBehindMethod) == DrawOverCharSprite)) {
sort_out_walk_behinds(_G(actsps)[useindx], atxp, atyp, usebasel);
}
@@ -1612,7 +1603,7 @@ void prepare_characters_for_drawing() {
(_G(charcache)[aa].tintamntwas == tint_amount) &&
(_G(charcache)[aa].tintlightwas == tint_light) &&
(_G(charcache)[aa].lightlevwas == light_level)) {
- if (walkBehindMethod == DrawOverCharSprite) {
+ if (_G(walkBehindMethod) == DrawOverCharSprite) {
_G(actsps)[useindx] = recycle_bitmap(_G(actsps)[useindx], _G(charcache)[aa].image->GetColorDepth(), _G(charcache)[aa].image->GetWidth(), _G(charcache)[aa].image->GetHeight());
_G(actsps)[useindx]->Blit(_G(charcache)[aa].image, 0, 0, 0, 0, _G(actsps)[useindx]->GetWidth(), _G(actsps)[useindx]->GetHeight());
} else {
@@ -1711,12 +1702,12 @@ void prepare_characters_for_drawing() {
if (chin->flags & CHF_NOWALKBEHINDS) {
// ignore walk-behinds, do nothing
- if (walkBehindMethod == DrawAsSeparateSprite) {
+ if (_G(walkBehindMethod) == DrawAsSeparateSprite) {
usebasel += _GP(thisroom).Height;
}
- } else if (walkBehindMethod == DrawAsSeparateCharSprite) {
+ } else if (_G(walkBehindMethod) == DrawAsSeparateCharSprite) {
sort_out_char_sprite_walk_behind(useindx, bgX, bgY, usebasel, _G(charextra)[aa].zoom, newwidth, newheight);
- } else if (walkBehindMethod == DrawOverCharSprite) {
+ } else if (_G(walkBehindMethod) == DrawOverCharSprite) {
sort_out_walk_behinds(_G(actsps)[useindx], bgX, bgY, usebasel);
}
@@ -1768,8 +1759,8 @@ void prepare_room_sprites() {
_G(gfxDriver)->UpdateDDBFromBitmap(_G(roomBackgroundBmp), _GP(thisroom).BgFrames[_GP(play).bg_frame].Graphic.get(), false);
}
if (_G(gfxDriver)->RequiresFullRedrawEachFrame()) {
- if (_G(current_background_is_dirty) || walkBehindsCachedForBgNum != _GP(play).bg_frame) {
- if (walkBehindMethod == DrawAsSeparateSprite) {
+ if (_G(current_background_is_dirty) || _G(walkBehindsCachedForBgNum) != _GP(play).bg_frame) {
+ if (_G(walkBehindMethod) == DrawAsSeparateSprite) {
update_walk_behind_images();
}
}
@@ -2027,7 +2018,7 @@ static void construct_room_view() {
draw_preroom_background();
prepare_room_sprites();
// reset the Baselines Changed flag now that we've drawn stuff
- walk_behind_baselines_changed = 0;
+ _G(walk_behind_baselines_changed) = 0;
for (const auto &viewport : _GP(play).GetRoomViewportsZOrdered()) {
if (!viewport->IsVisible())
diff --git a/engines/ags/engine/ac/global_walkbehind.cpp b/engines/ags/engine/ac/global_walkbehind.cpp
index 991ba58612..c5b4186c2d 100644
--- a/engines/ags/engine/ac/global_walkbehind.cpp
+++ b/engines/ags/engine/ac/global_walkbehind.cpp
@@ -31,14 +31,12 @@
namespace AGS3 {
-extern int walk_behind_baselines_changed;
-
void SetWalkBehindBase(int wa, int bl) {
if ((wa < 1) || (wa >= MAX_WALK_BEHINDS))
quit("!SetWalkBehindBase: invalid walk-behind area specified");
if (bl != _G(croom)->walkbehind_base[wa]) {
- walk_behind_baselines_changed = 1;
+ _G(walk_behind_baselines_changed) = 1;
invalidate_cached_walkbehinds();
_G(croom)->walkbehind_base[wa] = bl;
debug_script_log("Walk-behind %d baseline changed to %d", wa, bl);
diff --git a/engines/ags/engine/ac/walkbehind.cpp b/engines/ags/engine/ac/walkbehind.cpp
index 91bdf984b8..330289bdc7 100644
--- a/engines/ags/engine/ac/walkbehind.cpp
+++ b/engines/ags/engine/ac/walkbehind.cpp
@@ -33,16 +33,6 @@ namespace AGS3 {
using namespace AGS::Shared;
using namespace AGS::Engine;
-char *walkBehindExists = nullptr; // whether a WB area is in this column
-int *walkBehindStartY = nullptr, *walkBehindEndY = nullptr;
-char noWalkBehindsAtAll = 0;
-int walkBehindLeft[MAX_WALK_BEHINDS], walkBehindTop[MAX_WALK_BEHINDS];
-int walkBehindRight[MAX_WALK_BEHINDS], walkBehindBottom[MAX_WALK_BEHINDS];
-IDriverDependantBitmap *walkBehindBitmap[MAX_WALK_BEHINDS];
-int walkBehindsCachedForBgNum = 0;
-WalkBehindMethodEnum walkBehindMethod = DrawOverCharSprite;
-int walk_behind_baselines_changed = 0;
-
void update_walk_behind_images() {
int ee, rr;
int bpp = (_GP(thisroom).BgFrames[_GP(play).bg_frame].Graphic->GetColorDepth() + 7) / 8;
@@ -50,14 +40,14 @@ void update_walk_behind_images() {
for (ee = 1; ee < MAX_WALK_BEHINDS; ee++) {
update_polled_stuff_if_runtime();
- if (walkBehindRight[ee] > 0) {
+ if (_G(walkBehindRight)[ee] > 0) {
wbbmp = BitmapHelper::CreateTransparentBitmap(
- (walkBehindRight[ee] - walkBehindLeft[ee]) + 1,
- (walkBehindBottom[ee] - walkBehindTop[ee]) + 1,
+ (_G(walkBehindRight)[ee] - _G(walkBehindLeft)[ee]) + 1,
+ (_G(walkBehindBottom)[ee] - _G(walkBehindTop)[ee]) + 1,
_GP(thisroom).BgFrames[_GP(play).bg_frame].Graphic->GetColorDepth());
- int yy, startX = walkBehindLeft[ee], startY = walkBehindTop[ee];
- for (rr = startX; rr <= walkBehindRight[ee]; rr++) {
- for (yy = startY; yy <= walkBehindBottom[ee]; yy++) {
+ int yy, startX = _G(walkBehindLeft)[ee], startY = _G(walkBehindTop)[ee];
+ for (rr = startX; rr <= _G(walkBehindRight)[ee]; rr++) {
+ for (yy = startY; yy <= _G(walkBehindBottom)[ee]; yy++) {
if (_GP(thisroom).WalkBehindMask->GetScanLine(yy)[rr] == ee) {
for (int ii = 0; ii < bpp; ii++)
wbbmp->GetScanLineForWriting(yy - startY)[(rr - startX) * bpp + ii] = _GP(thisroom).BgFrames[_GP(play).bg_frame].Graphic->GetScanLine(yy)[rr * bpp + ii];
@@ -67,41 +57,41 @@ void update_walk_behind_images() {
update_polled_stuff_if_runtime();
- if (walkBehindBitmap[ee] != nullptr) {
- _G(gfxDriver)->DestroyDDB(walkBehindBitmap[ee]);
+ if (_G(walkBehindBitmap)[ee] != nullptr) {
+ _G(gfxDriver)->DestroyDDB(_G(walkBehindBitmap)[ee]);
}
- walkBehindBitmap[ee] = _G(gfxDriver)->CreateDDBFromBitmap(wbbmp, false);
+ _G(walkBehindBitmap)[ee] = _G(gfxDriver)->CreateDDBFromBitmap(wbbmp, false);
delete wbbmp;
}
}
- walkBehindsCachedForBgNum = _GP(play).bg_frame;
+ _G(walkBehindsCachedForBgNum) = _GP(play).bg_frame;
}
void recache_walk_behinds() {
- if (walkBehindExists) {
- free(walkBehindExists);
- free(walkBehindStartY);
- free(walkBehindEndY);
+ if (_G(walkBehindExists)) {
+ free(_G(walkBehindExists));
+ free(_G(walkBehindStartY));
+ free(_G(walkBehindEndY));
}
- walkBehindExists = (char *)malloc(_GP(thisroom).WalkBehindMask->GetWidth());
- walkBehindStartY = (int *)malloc(_GP(thisroom).WalkBehindMask->GetWidth() * sizeof(int));
- walkBehindEndY = (int *)malloc(_GP(thisroom).WalkBehindMask->GetWidth() * sizeof(int));
- noWalkBehindsAtAll = 1;
+ _G(walkBehindExists) = (char *)malloc(_GP(thisroom).WalkBehindMask->GetWidth());
+ _G(walkBehindStartY) = (int *)malloc(_GP(thisroom).WalkBehindMask->GetWidth() * sizeof(int));
+ _G(walkBehindEndY) = (int *)malloc(_GP(thisroom).WalkBehindMask->GetWidth() * sizeof(int));
+ _G(noWalkBehindsAtAll) = 1;
int ee, rr, tmm;
const int NO_WALK_BEHIND = 100000;
for (ee = 0; ee < MAX_WALK_BEHINDS; ee++) {
- walkBehindLeft[ee] = NO_WALK_BEHIND;
- walkBehindTop[ee] = NO_WALK_BEHIND;
- walkBehindRight[ee] = 0;
- walkBehindBottom[ee] = 0;
-
- if (walkBehindBitmap[ee] != nullptr) {
- _G(gfxDriver)->DestroyDDB(walkBehindBitmap[ee]);
- walkBehindBitmap[ee] = nullptr;
+ _G(walkBehindLeft)[ee] = NO_WALK_BEHIND;
+ _G(walkBehindTop)[ee] = NO_WALK_BEHIND;
+ _G(walkBehindRight)[ee] = 0;
+ _G(walkBehindBottom)[ee] = 0;
+
+ if (_G(walkBehindBitmap)[ee] != nullptr) {
+ _G(gfxDriver)->DestroyDDB(_G(walkBehindBitmap)[ee]);
+ _G(walkBehindBitmap)[ee] = nullptr;
}
}
@@ -113,27 +103,27 @@ void recache_walk_behinds() {
quit("Walk behinds bitmap not linear");
for (ee = 0; ee < _GP(thisroom).WalkBehindMask->GetWidth(); ee++) {
- walkBehindExists[ee] = 0;
+ _G(walkBehindExists)[ee] = 0;
for (rr = 0; rr < _GP(thisroom).WalkBehindMask->GetHeight(); rr++) {
tmm = _GP(thisroom).WalkBehindMask->GetScanLine(rr)[ee];
//tmm = _getpixel(_GP(thisroom).WalkBehindMask,ee,rr);
if ((tmm >= 1) && (tmm < MAX_WALK_BEHINDS)) {
- if (!walkBehindExists[ee]) {
- walkBehindStartY[ee] = rr;
- walkBehindExists[ee] = tmm;
- noWalkBehindsAtAll = 0;
+ if (!_G(walkBehindExists)[ee]) {
+ _G(walkBehindStartY)[ee] = rr;
+ _G(walkBehindExists)[ee] = tmm;
+ _G(noWalkBehindsAtAll) = 0;
}
- walkBehindEndY[ee] = rr + 1; // +1 to allow bottom line of screen to work
+ _G(walkBehindEndY)[ee] = rr + 1; // +1 to allow bottom line of screen to work
- if (ee < walkBehindLeft[tmm]) walkBehindLeft[tmm] = ee;
- if (rr < walkBehindTop[tmm]) walkBehindTop[tmm] = rr;
- if (ee > walkBehindRight[tmm]) walkBehindRight[tmm] = ee;
- if (rr > walkBehindBottom[tmm]) walkBehindBottom[tmm] = rr;
+ if (ee < _G(walkBehindLeft)[tmm]) _G(walkBehindLeft)[tmm] = ee;
+ if (rr < _G(walkBehindTop)[tmm]) _G(walkBehindTop)[tmm] = rr;
+ if (ee > _G(walkBehindRight)[tmm]) _G(walkBehindRight)[tmm] = ee;
+ if (rr > _G(walkBehindBottom)[tmm]) _G(walkBehindBottom)[tmm] = rr;
}
}
}
- if (walkBehindMethod == DrawAsSeparateSprite) {
+ if (_G(walkBehindMethod) == DrawAsSeparateSprite) {
update_walk_behind_images();
}
}
diff --git a/engines/ags/engine/main/game_run.cpp b/engines/ags/engine/main/game_run.cpp
index 2e948abf8d..806dac3a87 100644
--- a/engines/ags/engine/main/game_run.cpp
+++ b/engines/ags/engine/main/game_run.cpp
@@ -75,7 +75,6 @@ using namespace AGS::Shared;
extern int game_paused;
extern int getloctype_index;
-extern char noWalkBehindsAtAll;
// Checks if user interface should remain disabled for now
static int ShouldStayInWaitMode();
@@ -388,7 +387,7 @@ static void check_keyboard_controls() {
int ff;
// MACPORT FIX 9/6/5: added last %s
sprintf(infobuf, "In room %d %s[Player at %d, %d (view %d, loop %d, frame %d)%s%s%s",
- _G(displayed_room), (noWalkBehindsAtAll ? "(has no walk-behinds)" : ""), _G(playerchar)->x, _G(playerchar)->y,
+ _G(displayed_room), (_G(noWalkBehindsAtAll) ? "(has no walk-behinds)" : ""), _G(playerchar)->x, _G(playerchar)->y,
_G(playerchar)->view + 1, _G(playerchar)->loop, _G(playerchar)->frame,
(IsGamePaused() == 0) ? "" : "[Game paused.",
(_GP(play).ground_level_areas_disabled == 0) ? "" : "[Ground areas disabled.",
diff --git a/engines/ags/globals.cpp b/engines/ags/globals.cpp
index 0ab304ab7f..e7202d9193 100644
--- a/engines/ags/globals.cpp
+++ b/engines/ags/globals.cpp
@@ -273,6 +273,14 @@ Globals::Globals() {
// systemimports.cpp globals
_simp = new SystemImports();
_simp_for_plugin = new SystemImports();
+
+ // walkbehind.cpp globals
+ Common::fill(_walkBehindLeft, _walkBehindLeft + MAX_WALK_BEHINDS, 0);
+ Common::fill(_walkBehindTop, _walkBehindTop + MAX_WALK_BEHINDS, 0);
+ Common::fill(_walkBehindRight, _walkBehindRight + MAX_WALK_BEHINDS, 0);
+ Common::fill(_walkBehindBottom, _walkBehindBottom + MAX_WALK_BEHINDS, 0);
+ Common::fill(_walkBehindBitmap, _walkBehindBitmap + MAX_WALK_BEHINDS,
+ (AGS::Engine::IDriverDependantBitmap *)nullptr);
}
Globals::~Globals() {
diff --git a/engines/ags/globals.h b/engines/ags/globals.h
index 756b56aaa7..641f3fc4ed 100644
--- a/engines/ags/globals.h
+++ b/engines/ags/globals.h
@@ -28,6 +28,7 @@
#include "ags/shared/gui/guimain.h"
#include "ags/shared/script/cc_script.h"
#include "ags/engine/ac/runtime_defines.h"
+#include "ags/engine/ac/walkbehind.h"
#include "ags/engine/main/engine.h"
#include "ags/engine/media/audio/audiodefines.h"
#include "ags/engine/script/script.h"
@@ -973,7 +974,7 @@ public:
/**@}*/
/**
- * \defgroup walkablearea globals
+ * \defgroup sys_events globals
* @{
*/
@@ -991,6 +992,23 @@ public:
/**@}*/
+ /**
+ * \defgroup walkbehind globals
+ * @{
+ */
+
+ char *_walkBehindExists = nullptr; // whether a WB area is in this column
+ int *_walkBehindStartY = nullptr, *_walkBehindEndY = nullptr;
+ char _noWalkBehindsAtAll = 0;
+ int _walkBehindLeft[MAX_WALK_BEHINDS], _walkBehindTop[MAX_WALK_BEHINDS];
+ int _walkBehindRight[MAX_WALK_BEHINDS], _walkBehindBottom[MAX_WALK_BEHINDS];
+ AGS::Engine::IDriverDependantBitmap *_walkBehindBitmap[MAX_WALK_BEHINDS];
+ int _walkBehindsCachedForBgNum = 0;
+ WalkBehindMethodEnum _walkBehindMethod = DrawOverCharSprite;
+ int _walk_behind_baselines_changed = 0;
+
+ /**@}*/
+
public:
Globals();
~Globals();
Commit: 9c6dd7334985ed4cda666fcce42c6ba7c941cead
https://github.com/scummvm/scummvm/commit/9c6dd7334985ed4cda666fcce42c6ba7c941cead
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-10T20:43:37-08:00
Commit Message:
AGS: Move cc_dynamicobject.cpp globals to Globals
Changed paths:
engines/ags/engine/ac/dynobj/cc_dynamicarray.cpp
engines/ags/engine/ac/dynobj/cc_dynamicobject.cpp
engines/ags/engine/ac/dynobj/cc_dynamicobject.h
engines/ags/engine/script/cc_instance.cpp
engines/ags/globals.h
diff --git a/engines/ags/engine/ac/dynobj/cc_dynamicarray.cpp b/engines/ags/engine/ac/dynobj/cc_dynamicarray.cpp
index 8e63e6d895..30b1aca788 100644
--- a/engines/ags/engine/ac/dynobj/cc_dynamicarray.cpp
+++ b/engines/ags/engine/ac/dynobj/cc_dynamicarray.cpp
@@ -21,6 +21,7 @@
*/
#include "ags/engine/ac/dynobj/cc_dynamicarray.h"
+#include "ags/globals.h"
namespace AGS3 {
@@ -143,7 +144,7 @@ DynObjectRef DynamicArrayHelpers::CreateStringArray(const std::vector<const char
// Create script strings and put handles into array
int32_t *slots = static_cast<int32_t *>(arr.second);
for (auto s : items) {
- DynObjectRef str = stringClassImpl->CreateString(s);
+ DynObjectRef str = _G(stringClassImpl)->CreateString(s);
*(slots++) = str.first;
}
return arr;
diff --git a/engines/ags/engine/ac/dynobj/cc_dynamicobject.cpp b/engines/ags/engine/ac/dynobj/cc_dynamicobject.cpp
index e17b6ab77a..a107b6bea5 100644
--- a/engines/ags/engine/ac/dynobj/cc_dynamicobject.cpp
+++ b/engines/ags/engine/ac/dynobj/cc_dynamicobject.cpp
@@ -48,11 +48,9 @@ namespace AGS3 {
using namespace AGS::Shared;
-ICCStringClass *stringClassImpl = nullptr;
-
// set the class that will be used for dynamic strings
void ccSetStringClassImpl(ICCStringClass *theClass) {
- stringClassImpl = theClass;
+ _G(stringClassImpl) = theClass;
}
// register a memory handle for the object and allow script
diff --git a/engines/ags/engine/ac/dynobj/cc_dynamicobject.h b/engines/ags/engine/ac/dynobj/cc_dynamicobject.h
index 4eaa249dd5..552f34c376 100644
--- a/engines/ags/engine/ac/dynobj/cc_dynamicobject.h
+++ b/engines/ags/engine/ac/dynobj/cc_dynamicobject.h
@@ -131,8 +131,6 @@ extern const char *ccGetObjectAddressFromHandle(int32_t handle);
extern int ccAddObjectReference(int32_t handle);
extern int ccReleaseObjectReference(int32_t handle);
-extern ICCStringClass *stringClassImpl;
-
} // namespace AGS3
#endif
diff --git a/engines/ags/engine/script/cc_instance.cpp b/engines/ags/engine/script/cc_instance.cpp
index dee0606c56..47f4fb780f 100644
--- a/engines/ags/engine/script/cc_instance.cpp
+++ b/engines/ags/engine/script/cc_instance.cpp
@@ -1170,13 +1170,13 @@ int ccInstance::Run(int32_t curpc) {
}
break;
case SCMD_CREATESTRING:
- if (stringClassImpl == nullptr) {
+ if (_G(stringClassImpl) == nullptr) {
cc_error("No string class implementation set, but opcode was used");
return -1;
}
direct_ptr1 = (const char *)reg1.GetDirectPtr();
reg1.SetDynamicObject(
- stringClassImpl->CreateString(direct_ptr1).second,
+ _G(stringClassImpl)->CreateString(direct_ptr1).second,
&_GP(myScriptStringImpl));
break;
case SCMD_STRINGSEQUAL:
diff --git a/engines/ags/globals.h b/engines/ags/globals.h
index 641f3fc4ed..348323f87c 100644
--- a/engines/ags/globals.h
+++ b/engines/ags/globals.h
@@ -112,6 +112,7 @@ struct GameSetup;
struct GameSetupStruct;
struct GameState;
struct IAGSEditorDebugger;
+struct ICCStringClass;
struct ManagedObjectPool;
struct Mouse;
struct MoveList;
@@ -240,6 +241,15 @@ public:
/**@}*/
+ /**
+ * \defgroup cc_dynamicobject globals
+ * @{
+ */
+
+ ICCStringClass *_stringClassImpl = nullptr;
+
+ /**@}*/
+
/**
* \defgroup cc_error globals
* @{
Commit: bad09b641ffd6210584a620d69651fbc5c6abd42
https://github.com/scummvm/scummvm/commit/bad09b641ffd6210584a620d69651fbc5c6abd42
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-10T20:49:59-08:00
Commit Message:
AGS: Move translation.cpp globals to Globals
Changed paths:
engines/ags/engine/ac/game.cpp
engines/ags/engine/ac/global_debug.cpp
engines/ags/engine/ac/global_translation.cpp
engines/ags/engine/ac/translation.cpp
engines/ags/globals.h
diff --git a/engines/ags/engine/ac/game.cpp b/engines/ags/engine/ac/game.cpp
index 8d4dc91ea8..241f31936f 100644
--- a/engines/ags/engine/ac/game.cpp
+++ b/engines/ags/engine/ac/game.cpp
@@ -113,7 +113,6 @@ using namespace AGS::Engine;
extern int _G(psp_gfx_renderer);
#endif
-extern char transFileName[MAX_PATH];
extern color palette[256];
int oldmouse;
@@ -756,19 +755,19 @@ const char *Game_GetTranslationFilename() {
int Game_ChangeTranslation(const char *newFilename) {
if ((newFilename == nullptr) || (newFilename[0] == 0)) {
close_translation();
- strcpy(transFileName, "");
+ strcpy(_G(transFileName), "");
_GP(usetup).translation = "";
return 1;
}
String oldTransFileName;
- oldTransFileName = transFileName;
+ oldTransFileName = _G(transFileName);
if (init_translation(newFilename, oldTransFileName.LeftSection('.'), false)) {
_GP(usetup).translation = newFilename;
return 1;
} else {
- strcpy(transFileName, oldTransFileName);
+ strcpy(_G(transFileName), oldTransFileName);
return 0;
}
}
diff --git a/engines/ags/engine/ac/global_debug.cpp b/engines/ags/engine/ac/global_debug.cpp
index 4765ee2958..85431636a9 100644
--- a/engines/ags/engine/ac/global_debug.cpp
+++ b/engines/ags/engine/ac/global_debug.cpp
@@ -53,9 +53,6 @@ namespace AGS3 {
using namespace AGS::Shared;
using namespace AGS::Engine;
-extern TreeMap *transtree;
-extern char transFileName[MAX_PATH];
-
String GetRuntimeInfo() {
DisplayMode mode = _G(gfxDriver)->GetDisplayMode();
Rect render_frame = _G(gfxDriver)->GetRenderDestination();
@@ -75,9 +72,9 @@ String GetRuntimeInfo() {
runtimeInfo.Append("[AUDIO.VOX enabled");
if (_GP(play).want_speech >= 1)
runtimeInfo.Append("[SPEECH.VOX enabled");
- if (transtree != nullptr) {
+ if (_G(transtree) != nullptr) {
runtimeInfo.Append("[Using translation ");
- runtimeInfo.Append(transFileName);
+ runtimeInfo.Append(_G(transFileName));
}
return runtimeInfo;
diff --git a/engines/ags/engine/ac/global_translation.cpp b/engines/ags/engine/ac/global_translation.cpp
index cc6f47d18f..19bdd148e1 100644
--- a/engines/ags/engine/ac/global_translation.cpp
+++ b/engines/ags/engine/ac/global_translation.cpp
@@ -37,9 +37,6 @@ namespace AGS3 {
using namespace AGS::Shared::Memory;
-extern TreeMap *transtree;
-extern char transFileName[MAX_PATH];
-
const char *get_translation(const char *text) {
if (text == nullptr)
quit("!Null string supplied to CheckForTranslations");
@@ -55,9 +52,9 @@ const char *get_translation(const char *text) {
}
#endif
- if (transtree != nullptr) {
+ if (_G(transtree) != nullptr) {
// translate the text using the translation file
- char *transl = transtree->findValue(text);
+ char *transl = _G(transtree)->findValue(text);
if (transl != nullptr)
return transl;
}
@@ -66,14 +63,14 @@ const char *get_translation(const char *text) {
}
int IsTranslationAvailable() {
- if (transtree != nullptr)
+ if (_G(transtree) != nullptr)
return 1;
return 0;
}
int GetTranslationName(char *buffer) {
VALIDATE_STRING(buffer);
- const char *copyFrom = transFileName;
+ const char *copyFrom = _G(transFileName);
while (strchr(copyFrom, '\\') != nullptr) {
copyFrom = strchr(copyFrom, '\\') + 1;
diff --git a/engines/ags/engine/ac/translation.cpp b/engines/ags/engine/ac/translation.cpp
index b5a3bcbbd4..758d47dabb 100644
--- a/engines/ags/engine/ac/translation.cpp
+++ b/engines/ags/engine/ac/translation.cpp
@@ -40,16 +40,10 @@ namespace AGS3 {
using namespace AGS::Shared;
-extern char transFileName[MAX_PATH];
-
-TreeMap *transtree = nullptr;
-long lang_offs_start = 0;
-char transFileName[MAX_PATH] = "\0";
-
void close_translation() {
- if (transtree != nullptr) {
- delete transtree;
- transtree = nullptr;
+ if (_G(transtree) != nullptr) {
+ delete _G(transtree);
+ _G(transtree) = nullptr;
}
}
@@ -59,28 +53,28 @@ bool init_translation(const String &lang, const String &fallback_lang, bool quit
if (lang.IsEmpty())
return false;
- sprintf(transFileName, "%s.tra", lang.GetCStr());
+ sprintf(_G(transFileName), "%s.tra", lang.GetCStr());
- Stream *language_file = find_open_asset(transFileName);
+ Stream *language_file = find_open_asset(_G(transFileName));
if (language_file == nullptr) {
- Debug::Printf(kDbgMsg_Error, "Cannot open translation: %s", transFileName);
+ Debug::Printf(kDbgMsg_Error, "Cannot open translation: %s", _G(transFileName));
return false;
}
// in case it's inside a library file, record the offset
- lang_offs_start = language_file->GetPosition();
+ _G(lang_offs_start) = language_file->GetPosition();
char transsig[16] = { 0 };
language_file->Read(transsig, 15);
if (strcmp(transsig, "AGSTranslation") != 0) {
- Debug::Printf(kDbgMsg_Error, "Translation signature mismatch: %s", transFileName);
+ Debug::Printf(kDbgMsg_Error, "Translation signature mismatch: %s", _G(transFileName));
delete language_file;
return false;
}
- if (transtree != nullptr) {
+ if (_G(transtree) != nullptr) {
close_translation();
}
- transtree = new TreeMap();
+ _G(transtree) = new TreeMap();
String parse_error;
bool result = parse_translation(language_file, parse_error);
@@ -88,7 +82,7 @@ bool init_translation(const String &lang, const String &fallback_lang, bool quit
if (!result) {
close_translation();
- parse_error.Prepend(String::FromFormat("Failed to read translation file: %s:\n", transFileName));
+ parse_error.Prepend(String::FromFormat("Failed to read translation file: %s:\n", _G(transFileName)));
if (quit_on_error) {
parse_error.PrependChar('!');
quit(parse_error);
@@ -101,7 +95,7 @@ bool init_translation(const String &lang, const String &fallback_lang, bool quit
return false;
}
}
- Debug::Printf("Translation initialized: %s", transFileName);
+ Debug::Printf("Translation initialized: %s", _G(transFileName));
return true;
}
@@ -124,7 +118,7 @@ bool parse_translation(Stream *language_file, String &parse_error) {
parse_error = "Translation file is corrupt";
return false;
}
- transtree->addText(original, translation);
+ _G(transtree)->addText(original, translation);
}
} else if (blockType == 2) {
@@ -162,7 +156,7 @@ bool parse_translation(Stream *language_file, String &parse_error) {
}
}
- if (transtree->text == nullptr) {
+ if (_G(transtree)->text == nullptr) {
parse_error = "The translation file was empty.";
return false;
}
diff --git a/engines/ags/globals.h b/engines/ags/globals.h
index 348323f87c..83b16cf1fb 100644
--- a/engines/ags/globals.h
+++ b/engines/ags/globals.h
@@ -146,6 +146,7 @@ struct SpriteListEntry;
struct StaticArray;
struct SystemImports;
struct TopBarSettings;
+struct TreeMap;
struct ViewStruct;
class Globals {
@@ -993,6 +994,17 @@ public:
/**@}*/
+ /**
+ * \defgroup translation globals
+ * @{
+ */
+
+ TreeMap *_transtree = nullptr;
+ long _lang_offs_start = 0;
+ char _transFileName[MAX_PATH] = { 0 };
+
+ /**@}*/
+
/**
* \defgroup walkablearea globals
* @{
Commit: 3a0a70bc43d4df5c4509974ead5d0be1bcb0e5e2
https://github.com/scummvm/scummvm/commit/3a0a70bc43d4df5c4509974ead5d0be1bcb0e5e2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-10T21:01:11-08:00
Commit Message:
AGS: Move more game.cpp globals to Globals
Changed paths:
engines/ags/engine/ac/character.cpp
engines/ags/engine/ac/dialog.cpp
engines/ags/engine/ac/display.cpp
engines/ags/engine/ac/draw.cpp
engines/ags/engine/ac/dynobj/cc_character.cpp
engines/ags/engine/ac/event.cpp
engines/ags/engine/ac/game.cpp
engines/ags/engine/ac/game.h
engines/ags/engine/ac/gamestate.cpp
engines/ags/engine/ac/global_audio.cpp
engines/ags/engine/ac/global_character.cpp
engines/ags/engine/ac/global_game.cpp
engines/ags/engine/ac/global_object.cpp
engines/ags/engine/ac/global_region.cpp
engines/ags/engine/ac/mouse.cpp
engines/ags/engine/ac/object.cpp
engines/ags/engine/ac/room.cpp
engines/ags/engine/ac/roomstatus.cpp
engines/ags/engine/debugging/debug.cpp
engines/ags/engine/game/game_init.cpp
engines/ags/engine/game/savegame.cpp
engines/ags/engine/game/savegame_components.cpp
engines/ags/engine/gui/gui_engine.cpp
engines/ags/engine/main/engine.cpp
engines/ags/engine/main/engine_setup.cpp
engines/ags/engine/main/game_run.cpp
engines/ags/engine/main/quit.cpp
engines/ags/engine/script/script.cpp
engines/ags/engine/script/script_api.cpp
engines/ags/globals.h
engines/ags/plugins/agsplugin.cpp
engines/ags/shared/ac/game_version.h
engines/ags/shared/ac/gamesetupstruct.cpp
engines/ags/shared/ac/gamesetupstruct.h
engines/ags/shared/ac/gamesetupstructbase.cpp
engines/ags/shared/ac/gamesetupstructbase.h
engines/ags/shared/game/main_game_file.cpp
engines/ags/shared/gui/guiinv.cpp
engines/ags/shared/gui/guilabel.cpp
engines/ags/shared/gui/guimain.cpp
diff --git a/engines/ags/engine/ac/character.cpp b/engines/ags/engine/ac/character.cpp
index eca9406b76..57cf18f52d 100644
--- a/engines/ags/engine/ac/character.cpp
+++ b/engines/ags/engine/ac/character.cpp
@@ -228,7 +228,7 @@ void Character_ChangeRoomSetLoop(CharacterInfo *chaa, int room, int x, int y, in
if ((x != SCR_NO_VALUE) && (y != SCR_NO_VALUE)) {
_G(new_room_pos) = 0;
- if (loaded_game_file_version <= kGameVersion_272) {
+ if (_G(loaded_game_file_version) <= kGameVersion_272) {
// Set position immediately on 2.x.
chaa->x = x;
chaa->y = y;
@@ -293,7 +293,7 @@ DirectionalLoop GetDirectionalLoop(CharacterInfo *chinfo, int x_diff, int y_diff
DirectionalLoop next_loop = kDirLoop_Left; // NOTE: default loop was Left for some reason
const ViewStruct &chview = _G(views)[chinfo->view];
- const bool new_version = loaded_game_file_version > kGameVersion_272;
+ const bool new_version = _G(loaded_game_file_version) > kGameVersion_272;
const bool has_down_loop = ((chview.numLoops > kDirLoop_Down) && (chview.loops[kDirLoop_Down].numFrames > 0));
const bool has_up_loop = ((chview.numLoops > kDirLoop_Up) && (chview.loops[kDirLoop_Up].numFrames > 0));
// NOTE: 3.+ games required left & right loops to be present at all times
@@ -730,7 +730,7 @@ void Character_SetAsPlayer(CharacterInfo *chaa) {
// But only on versions > 2.61. The relevant entry in the 2.62 changelog is:
// - Fixed SetPlayerCharacter to do nothing at all if you pass the current
// player character to it (previously it was resetting the inventory layout)
- if ((loaded_game_file_version > kGameVersion_261) && (_GP(game).playercharacter == chaa->index_id))
+ if ((_G(loaded_game_file_version) > kGameVersion_261) && (_GP(game).playercharacter == chaa->index_id))
return;
setup_player_character(chaa->index_id);
@@ -746,7 +746,7 @@ void Character_SetAsPlayer(CharacterInfo *chaa) {
// Ignore invalid room numbers for the character and just place him in
// the current room for 2.x. Following script calls to NewRoom() will
// make sure this still works as intended.
- if ((loaded_game_file_version <= kGameVersion_272) && (_G(playerchar)->room < 0))
+ if ((_G(loaded_game_file_version) <= kGameVersion_272) && (_G(playerchar)->room < 0))
_G(playerchar)->room = _G(displayed_room);
if (_G(displayed_room) != _G(playerchar)->room)
@@ -1873,7 +1873,7 @@ void find_nearest_walkable_area(int32_t *xx, int32_t *yy) {
int pixValue = _GP(thisroom).WalkAreaMask->GetPixel(room_to_mask_coord(xx[0]), room_to_mask_coord(yy[0]));
// only fix this code if the game was built with 2.61 or above
- if (pixValue == 0 || (loaded_game_file_version >= kGameVersion_261 && pixValue < 1)) {
+ if (pixValue == 0 || (_G(loaded_game_file_version) >= kGameVersion_261 && pixValue < 1)) {
// First, check every 2 pixels within immediate area
if (!find_nearest_walkable_area_within(xx, yy, 20, 2)) {
// If not, check whole screen at 5 pixel intervals
@@ -2004,7 +2004,7 @@ void setup_player_character(int charid) {
_GP(game).playercharacter = charid;
_G(playerchar) = &_GP(game).chars[charid];
_G(sc_PlayerCharPtr) = ccGetObjectHandleFromAddress((char *)_G(playerchar));
- if (loaded_game_file_version < kGameVersion_270) {
+ if (_G(loaded_game_file_version) < kGameVersion_270) {
ccAddExternalDynamicObject("player", _G(playerchar), &_GP(ccDynamicCharacter));
}
}
@@ -2680,7 +2680,7 @@ void _displayspeech(const char *texx, int aschar, int xx, int yy, int widd, int
speakingChar->view = oldview;
// Don't reset the loop in 2.x games
- if (loaded_game_file_version > kGameVersion_272)
+ if (_G(loaded_game_file_version) > kGameVersion_272)
speakingChar->loop = oldloop;
speakingChar->animating = 0;
diff --git a/engines/ags/engine/ac/dialog.cpp b/engines/ags/engine/ac/dialog.cpp
index 61d8d30003..511b6b23a2 100644
--- a/engines/ags/engine/ac/dialog.cpp
+++ b/engines/ags/engine/ac/dialog.cpp
@@ -1028,7 +1028,7 @@ void do_conversation(int dlgnum) {
EndSkippingUntilCharStops();
// AGS 2.x always makes the mouse cursor visible when displaying a dialog.
- if (loaded_game_file_version <= kGameVersion_272)
+ if (_G(loaded_game_file_version) <= kGameVersion_272)
_GP(play).mouse_cursor_hidden = 0;
int dlgnum_was = dlgnum;
diff --git a/engines/ags/engine/ac/display.cpp b/engines/ags/engine/ac/display.cpp
index f64258949c..a7ad4e566f 100644
--- a/engines/ags/engine/ac/display.cpp
+++ b/engines/ags/engine/ac/display.cpp
@@ -87,7 +87,7 @@ int _display_main(int xx, int yy, int wii, const char *text, int disp_type, int
_G(disp).fulltxtheight = getheightoflines(usingfont, _GP(fontLines).Count());
// AGS 2.x: If the screen is faded out, fade in again when displaying a message box.
- if (!asspch && (loaded_game_file_version <= kGameVersion_272))
+ if (!asspch && (_G(loaded_game_file_version) <= kGameVersion_272))
_GP(play).screen_is_faded_out = 0;
// if it's a normal message box and the game was being skipped,
@@ -594,7 +594,7 @@ void draw_button_background(Bitmap *ds, int xx1, int yy1, int xx2, int yy2, GUIM
/* draw_color = ds->GetCompatibleColor(opts.tws.backcol); ds->FillRect(Rect(xx1,yy1,xx2,yy2);
draw_color = ds->GetCompatibleColor(opts.tws.ds->GetTextColor()); ds->DrawRect(Rect(xx1+1,yy1+1,xx2-1,yy2-1);*/
} else {
- if (loaded_game_file_version < kGameVersion_262) { // < 2.62
+ if (_G(loaded_game_file_version) < kGameVersion_262) { // < 2.62
// Color 0 wrongly shows as transparent instead of black
// From the changelog of 2.62:
// - Fixed text windows getting a black background if colour 0 was
@@ -612,7 +612,7 @@ void draw_button_background(Bitmap *ds, int xx1, int yy1, int xx2, int yy2, GUIM
int leftRightWidth = _GP(game).SpriteInfos[get_but_pic(iep, 4)].Width;
int topBottomHeight = _GP(game).SpriteInfos[get_but_pic(iep, 6)].Height;
if (iep->BgImage > 0) {
- if ((loaded_game_file_version <= kGameVersion_272) // 2.xx
+ if ((_G(loaded_game_file_version) <= kGameVersion_272) // 2.xx
&& (_GP(spriteset)[iep->BgImage]->GetWidth() == 1)
&& (_GP(spriteset)[iep->BgImage]->GetHeight() == 1)
&& (*((const unsigned int *)_GP(spriteset)[iep->BgImage]->GetData()) == 0x00FF00FF)) {
diff --git a/engines/ags/engine/ac/draw.cpp b/engines/ags/engine/ac/draw.cpp
index 0181388068..9d88440b23 100644
--- a/engines/ags/engine/ac/draw.cpp
+++ b/engines/ags/engine/ac/draw.cpp
@@ -935,7 +935,7 @@ void draw_gui_sprite(Bitmap *ds, int pic, int x, int y, bool use_alpha, BlendMod
}
void draw_gui_sprite_v330(Bitmap *ds, int pic, int x, int y, bool use_alpha, BlendMode blend_mode) {
- draw_gui_sprite(ds, pic, x, y, use_alpha && (loaded_game_file_version >= kGameVersion_330), blend_mode);
+ draw_gui_sprite(ds, pic, x, y, use_alpha && (_G(loaded_game_file_version) >= kGameVersion_330), blend_mode);
}
// function to sort the sprites into baseline order
diff --git a/engines/ags/engine/ac/dynobj/cc_character.cpp b/engines/ags/engine/ac/dynobj/cc_character.cpp
index 3e34c13e77..ac90043766 100644
--- a/engines/ags/engine/ac/dynobj/cc_character.cpp
+++ b/engines/ags/engine/ac/dynobj/cc_character.cpp
@@ -55,7 +55,7 @@ void CCCharacter::WriteInt16(const char *address, intptr_t offset, int16_t val)
// Detect when a game directly modifies the inventory, which causes the displayed
// and actual inventory to diverge since 2.70. Force an update of the displayed
// inventory for older games that reply on the previous behaviour.
- if (loaded_game_file_version < kGameVersion_270) {
+ if (_G(loaded_game_file_version) < kGameVersion_270) {
const int invoffset = 112;
if (offset >= invoffset && offset < (int)(invoffset + MAX_INV * sizeof(short))) {
update_invorder();
diff --git a/engines/ags/engine/ac/event.cpp b/engines/ags/engine/ac/event.cpp
index 14c439eb89..433447d141 100644
--- a/engines/ags/engine/ac/event.cpp
+++ b/engines/ags/engine/ac/event.cpp
@@ -102,7 +102,7 @@ void run_room_event(int id) {
void run_event_block_inv(int invNum, int event_) {
_G(evblockbasename) = "inventory%d";
- if (loaded_game_file_version > kGameVersion_272) {
+ if (_G(loaded_game_file_version) > kGameVersion_272) {
run_interaction_script(_GP(game).invScripts[invNum].get(), event_);
} else {
run_interaction_event(_GP(game).intrInv[invNum].get(), event_);
diff --git a/engines/ags/engine/ac/game.cpp b/engines/ags/engine/ac/game.cpp
index 241f31936f..68b9a3a19a 100644
--- a/engines/ags/engine/ac/game.cpp
+++ b/engines/ags/engine/ac/game.cpp
@@ -115,23 +115,6 @@ extern int _G(psp_gfx_renderer);
extern color palette[256];
-int oldmouse;
-
-//=============================================================================
-
-GameDataVersion loaded_game_file_version = kGameVersion_Undefined;
-
-//=============================================================================
-
-int game_paused = 0;
-char pexbuf[STD_BUFFER_SIZE];
-
-unsigned int load_new_game = 0;
-int load_new_game_restore = -1;
-
-// TODO: refactor these global vars into function arguments
-int getloctype_index = 0, getloctype_throughgui = 0;
-
//=============================================================================
// Audio
//=============================================================================
@@ -243,11 +226,11 @@ void setup_for_dialog() {
_G(acdialog_font) = _GP(play).normal_font;
if (!_GP(play).mouse_cursor_hidden)
ags_domouse(DOMOUSE_ENABLE);
- oldmouse = _G(cur_cursor);
+ _G(oldmouse) = _G(cur_cursor);
set_mouse_cursor(CURS_ARROW);
}
void restore_after_dialog() {
- set_mouse_cursor(oldmouse);
+ set_mouse_cursor(_G(oldmouse));
if (!_GP(play).mouse_cursor_hidden)
ags_domouse(DOMOUSE_DISABLE);
invalidate_screen();
@@ -1140,7 +1123,7 @@ void restore_game_more_dynamic_values(Stream *in) {
in->ReadInt32(); // mouse_on_iface_button
in->ReadInt32(); // mouse_pushed_iface
_G(ifacepopped) = in->ReadInt32();
- game_paused = in->ReadInt32();
+ _G(game_paused) = in->ReadInt32();
}
void ReadAnimatedButtons_Aligned(Stream *in) {
@@ -1309,7 +1292,7 @@ HSaveError restore_game_audioclips_and_crossfade(Stream *in, RestoredData &r_dat
chan_info.VolAsPercent = in->ReadInt32();
chan_info.PanAsPercent = in->ReadInt32();
chan_info.Speed = 1000;
- if (loaded_game_file_version >= kGameVersion_340_2)
+ if (_G(loaded_game_file_version) >= kGameVersion_340_2)
chan_info.Speed = in->ReadInt32();
}
}
@@ -1492,7 +1475,7 @@ HSaveError load_game(int slotNumber, bool &data_overwritten) {
get_install_dir_path(gamefilenamebuf, desc.MainDataFilename);
if (Shared::File::TestReadFile(gamefilenamebuf)) {
RunAGSGame(desc.MainDataFilename, 0, 0);
- load_new_game_restore = slotNumber;
+ _G(load_new_game_restore) = slotNumber;
return HSaveError::None();
}
Shared::Debug::Printf(kDbgMsg_Warn, "WARNING: the saved game '%s' references game file '%s', but it cannot be found in the current directory. Trying to restore in the running game instead.",
@@ -1604,12 +1587,12 @@ void stop_fast_forwarding() {
// allowHotspot0 defines whether Hotspot 0 returns LOCTYPE_HOTSPOT
// or whether it returns 0
int __GetLocationType(int xxx, int yyy, int allowHotspot0) {
- getloctype_index = 0;
+ _G(getloctype_index) = 0;
// If it's not in ProcessClick, then return 0 when over a GUI
- if ((GetGUIAt(xxx, yyy) >= 0) && (getloctype_throughgui == 0))
+ if ((GetGUIAt(xxx, yyy) >= 0) && (_G(getloctype_throughgui) == 0))
return 0;
- getloctype_throughgui = 0;
+ _G(getloctype_throughgui) = 0;
const int scrx = xxx;
const int scry = yyy;
@@ -1669,11 +1652,11 @@ int __GetLocationType(int xxx, int yyy, int allowHotspot0) {
winner = 0;
if (winner == LOCTYPE_HOTSPOT)
- getloctype_index = hsat;
+ _G(getloctype_index) = hsat;
else if (winner == LOCTYPE_CHAR)
- getloctype_index = charat;
+ _G(getloctype_index) = charat;
else if (winner == LOCTYPE_OBJ)
- getloctype_index = objat;
+ _G(getloctype_index) = objat;
return winner;
}
diff --git a/engines/ags/engine/ac/game.h b/engines/ags/engine/ac/game.h
index 296fa80e9a..e8deb022f7 100644
--- a/engines/ags/engine/ac/game.h
+++ b/engines/ags/engine/ac/game.h
@@ -197,7 +197,6 @@ void get_message_text(int msnum, char *buffer, char giveErr = 1);
bool unserialize_audio_script_object(int index, const char *objectType, const char *serializedData, int dataSize);
extern void set_loop_counter(unsigned int new_counter);
-extern int game_paused;
} // namespace AGS3
diff --git a/engines/ags/engine/ac/gamestate.cpp b/engines/ags/engine/ac/gamestate.cpp
index 2800bd2d3d..d5fd3debe1 100644
--- a/engines/ags/engine/ac/gamestate.cpp
+++ b/engines/ags/engine/ac/gamestate.cpp
@@ -541,7 +541,7 @@ void GameState::ReadFromSavegame(Shared::Stream *in, GameStateSvgVersion svg_ver
rtint_blue = in->ReadInt32();
rtint_level = in->ReadInt32();
rtint_light = in->ReadInt32();
- if (!old_save || loaded_game_file_version >= kGameVersion_340_4)
+ if (!old_save || _G(loaded_game_file_version) >= kGameVersion_340_4)
rtint_enabled = in->ReadBool();
else
rtint_enabled = rtint_level > 0;
@@ -818,7 +818,7 @@ void GameState::FreeViewportsAndCameras() {
}
void GameState::ReadCustomProperties_v340(Shared::Stream *in) {
- if (loaded_game_file_version >= kGameVersion_340_4) {
+ if (_G(loaded_game_file_version) >= kGameVersion_340_4) {
// After runtime property values were read we also copy missing default,
// because we do not keep defaults in the saved game, and also in case
// this save is made by an older game version which had different
@@ -831,7 +831,7 @@ void GameState::ReadCustomProperties_v340(Shared::Stream *in) {
}
void GameState::WriteCustomProperties_v340(Shared::Stream *out) const {
- if (loaded_game_file_version >= kGameVersion_340_4) {
+ if (_G(loaded_game_file_version) >= kGameVersion_340_4) {
// We temporarily remove properties that kept default values
// just for the saving data time to avoid getting lots of
// redundant data into saved games
diff --git a/engines/ags/engine/ac/global_audio.cpp b/engines/ags/engine/ac/global_audio.cpp
index 2fedaefdc9..10c39762b0 100644
--- a/engines/ags/engine/ac/global_audio.cpp
+++ b/engines/ags/engine/ac/global_audio.cpp
@@ -320,7 +320,7 @@ void SetMusicVolume(int newvol) {
}
void SetMusicMasterVolume(int newvol) {
- const int min_volume = loaded_game_file_version < kGameVersion_330 ? 0 :
+ const int min_volume = _G(loaded_game_file_version) < kGameVersion_330 ? 0 :
-LegacyMusicMasterVolumeAdjustment - (kRoomVolumeMax * LegacyRoomVolumeFactor);
if ((newvol < min_volume) | (newvol > 100))
quitprintf("!SetMusicMasterVolume: invalid volume - must be from %d to %d", min_volume, 100);
diff --git a/engines/ags/engine/ac/global_character.cpp b/engines/ags/engine/ac/global_character.cpp
index cc3e622904..336adcde34 100644
--- a/engines/ags/engine/ac/global_character.cpp
+++ b/engines/ags/engine/ac/global_character.cpp
@@ -356,7 +356,7 @@ void MoveCharacterBlocking(int chaa, int xx, int yy, int direct) {
}
int GetCharacterSpeechAnimationDelay(CharacterInfo *cha) {
- if ((loaded_game_file_version < kGameVersion_312) && (_GP(game).options[OPT_SPEECHTYPE] != 0)) {
+ if ((_G(loaded_game_file_version) < kGameVersion_312) && (_GP(game).options[OPT_SPEECHTYPE] != 0)) {
// legacy versions of AGS assigned a fixed delay to Sierra-style speech only
return 5;
}
@@ -384,7 +384,7 @@ void RunCharacterInteraction(int cc, int mood) {
_G(evblockbasename) = "character%d";
_G(evblocknum) = cc;
- if (loaded_game_file_version > kGameVersion_272) {
+ if (_G(loaded_game_file_version) > kGameVersion_272) {
if (passon >= 0)
run_interaction_script(_GP(game).charScripts[cc].get(), passon, 4, (passon == 3));
run_interaction_script(_GP(game).charScripts[cc].get(), 4); // any click on char
diff --git a/engines/ags/engine/ac/global_game.cpp b/engines/ags/engine/ac/global_game.cpp
index e853b9996f..8c98b5fce2 100644
--- a/engines/ags/engine/ac/global_game.cpp
+++ b/engines/ags/engine/ac/global_game.cpp
@@ -76,12 +76,8 @@ using namespace AGS::Shared;
#define ALLEGRO_KEYBOARD_HANDLER
-extern int game_paused;
extern char gamefilenamebuf[200];
-extern unsigned int load_new_game;
-extern int load_new_game_restore;
extern int gui_disabled_style;
-extern int getloctype_index;
extern color palette[256];
#if AGS_PLATFORM_OS_IOS || AGS_PLATFORM_OS_ANDROID
@@ -138,18 +134,18 @@ void DeleteSaveSlot(int slnum) {
}
void PauseGame() {
- game_paused++;
+ _G(game_paused)++;
debug_script_log("Game paused");
}
void UnPauseGame() {
- if (game_paused > 0)
- game_paused--;
- debug_script_log("Game UnPaused, pause level now %d", game_paused);
+ if (_G(game_paused) > 0)
+ _G(game_paused)--;
+ debug_script_log("Game UnPaused, pause level now %d", _G(game_paused));
}
int IsGamePaused() {
- if (game_paused > 0) return 1;
+ if (_G(game_paused) > 0) return 1;
return 0;
}
@@ -245,13 +241,13 @@ int RunAGSGame(const char *newgame, unsigned int mode, int data) {
_GP(ResPaths).GamePak.Path = gamefilenamebuf;
_GP(ResPaths).GamePak.Name = Shared::Path::get_filename(gamefilenamebuf);
_GP(play).takeover_data = data;
- load_new_game_restore = -1;
+ _G(load_new_game_restore) = -1;
if (_G(inside_script)) {
_G(curscript)->queue_action(ePSARunAGSGame, mode | RAGMODE_LOADNOW, "RunAGSGame");
ccInstance::GetCurrentInstance()->Abort();
} else
- load_new_game = mode | RAGMODE_LOADNOW;
+ _G(load_new_game) = mode | RAGMODE_LOADNOW;
return 0;
}
@@ -290,9 +286,9 @@ int RunAGSGame(const char *newgame, unsigned int mode, int data) {
engine_init_game_settings();
_GP(play).screen_is_faded_out = 1;
- if (load_new_game_restore >= 0) {
- try_restore_save(load_new_game_restore);
- load_new_game_restore = -1;
+ if (_G(load_new_game_restore) >= 0) {
+ try_restore_save(_G(load_new_game_restore));
+ _G(load_new_game_restore) = -1;
} else
start_game();
@@ -564,7 +560,7 @@ void GetLocationName(int xxx, int yyy, char *tempo) {
// on character
if (loctype == LOCTYPE_CHAR) {
- onhs = getloctype_index;
+ onhs = _G(getloctype_index);
strcpy(tempo, get_translation(_GP(game).chars[onhs].name));
if (_GP(play).get_loc_name_last_time != 2000 + onhs)
guis_need_update = 1;
@@ -573,11 +569,11 @@ void GetLocationName(int xxx, int yyy, char *tempo) {
}
// on object
if (loctype == LOCTYPE_OBJ) {
- aa = getloctype_index;
+ aa = _G(getloctype_index);
strcpy(tempo, get_translation(_GP(thisroom).Objects[aa].Name));
// Compatibility: < 3.1.1 games returned space for nameless object
// (presumably was a bug, but fixing it affected certain games behavior)
- if (loaded_game_file_version < kGameVersion_311 && tempo[0] == 0) {
+ if (_G(loaded_game_file_version) < kGameVersion_311 && tempo[0] == 0) {
tempo[0] = ' ';
tempo[1] = 0;
}
@@ -586,7 +582,7 @@ void GetLocationName(int xxx, int yyy, char *tempo) {
_GP(play).get_loc_name_last_time = 3000 + aa;
return;
}
- onhs = getloctype_index;
+ onhs = _G(getloctype_index);
if (onhs > 0)
strcpy(tempo, get_translation(_GP(thisroom).Hotspots[onhs].Name));
if (_GP(play).get_loc_name_last_time != onhs)
@@ -875,10 +871,8 @@ void SetMultitasking(int mode) {
}
}
-extern int getloctype_throughgui, getloctype_index;
-
void RoomProcessClick(int xx, int yy, int mood) {
- getloctype_throughgui = 1;
+ _G(getloctype_throughgui) = 1;
int loctype = GetLocationType(xx, yy);
VpPoint vpt = _GP(play).ScreenToRoomDivDown(xx, yy);
if (vpt.second < 0)
@@ -903,7 +897,7 @@ void RoomProcessClick(int xx, int yy, int mood) {
if (loctype == 0) {
// click on nothing -> hotspot 0
- getloctype_index = 0;
+ _G(getloctype_index) = 0;
loctype = LOCTYPE_HOTSPOT;
}
@@ -912,11 +906,11 @@ void RoomProcessClick(int xx, int yy, int mood) {
} else if (loctype == LOCTYPE_OBJ) {
if (check_click_on_object(xx, yy, mood)) return;
} else if (loctype == LOCTYPE_HOTSPOT)
- RunHotspotInteraction(getloctype_index, mood);
+ RunHotspotInteraction(_G(getloctype_index), mood);
}
int IsInteractionAvailable(int xx, int yy, int mood) {
- getloctype_throughgui = 1;
+ _G(getloctype_throughgui) = 1;
int loctype = GetLocationType(xx, yy);
VpPoint vpt = _GP(play).ScreenToRoomDivDown(xx, yy);
if (vpt.second < 0)
@@ -932,7 +926,7 @@ int IsInteractionAvailable(int xx, int yy, int mood) {
if (loctype == 0) {
// click on nothing -> hotspot 0
- getloctype_index = 0;
+ _G(getloctype_index) = 0;
loctype = LOCTYPE_HOTSPOT;
}
@@ -941,7 +935,7 @@ int IsInteractionAvailable(int xx, int yy, int mood) {
} else if (loctype == LOCTYPE_OBJ) {
check_click_on_object(xx, yy, mood);
} else if (loctype == LOCTYPE_HOTSPOT)
- RunHotspotInteraction(getloctype_index, mood);
+ RunHotspotInteraction(_G(getloctype_index), mood);
int ciwas = _GP(play).check_interaction_only;
_GP(play).check_interaction_only = 0;
diff --git a/engines/ags/engine/ac/global_object.cpp b/engines/ags/engine/ac/global_object.cpp
index 09abcf76ff..15c4bb6649 100644
--- a/engines/ags/engine/ac/global_object.cpp
+++ b/engines/ags/engine/ac/global_object.cpp
@@ -145,7 +145,7 @@ void SetObjectFrame(int obn, int viw, int lop, int fra) {
if (viw < 0 || viw >= _GP(game).numviews) quitprintf("!SetObjectFrame: invalid view number used (%d, range is 0 - %d)", viw, _GP(game).numviews - 1);
if (lop < 0 || lop >= _G(views)[viw].numLoops) quitprintf("!SetObjectFrame: invalid loop number used (%d, range is 0 - %d)", lop, _G(views)[viw].numLoops - 1);
// AGS < 3.5.1 let user to pass literally any positive invalid frame value by silently reassigning it to zero...
- if (loaded_game_file_version < kGameVersion_351) {
+ if (_G(loaded_game_file_version) < kGameVersion_351) {
if (fra >= _G(views)[viw].loops[lop].numFrames) {
debug_script_warn("SetObjectFrame: frame index out of range (%d, must be 0 - %d), set to 0", fra, _G(views)[viw].loops[lop].numFrames - 1);
fra = 0;
@@ -154,7 +154,7 @@ void SetObjectFrame(int obn, int viw, int lop, int fra) {
if (fra < 0 || fra >= _G(views)[viw].loops[lop].numFrames) quitprintf("!SetObjectFrame: invalid frame number used (%d, range is 0 - %d)", fra, _G(views)[viw].loops[lop].numFrames - 1);
// AGS >= 3.2.0 do not let assign an empty loop
// NOTE: pre-3.2.0 games are converting views from ViewStruct272 struct, always has at least 1 frame
- if (loaded_game_file_version >= kGameVersion_320) {
+ if (_G(loaded_game_file_version) >= kGameVersion_320) {
if (_G(views)[viw].loops[lop].numFrames == 0)
quit("!SetObjectFrame: specified loop has no frames");
}
diff --git a/engines/ags/engine/ac/global_region.cpp b/engines/ags/engine/ac/global_region.cpp
index ee20d291f8..f18fefae6c 100644
--- a/engines/ags/engine/ac/global_region.cpp
+++ b/engines/ags/engine/ac/global_region.cpp
@@ -43,7 +43,7 @@ int GetRegionIDAtRoom(int xxx, int yyy) {
xxx = room_to_mask_coord(xxx);
yyy = room_to_mask_coord(yyy);
- if (loaded_game_file_version >= kGameVersion_262) { // Version 2.6.2+
+ if (_G(loaded_game_file_version) >= kGameVersion_262) { // Version 2.6.2+
if (xxx >= _GP(thisroom).RegionMask->GetWidth())
xxx = _GP(thisroom).RegionMask->GetWidth() - 1;
if (yyy >= _GP(thisroom).RegionMask->GetHeight())
diff --git a/engines/ags/engine/ac/mouse.cpp b/engines/ags/engine/ac/mouse.cpp
index e38a4c478f..28b6c1fd48 100644
--- a/engines/ags/engine/ac/mouse.cpp
+++ b/engines/ags/engine/ac/mouse.cpp
@@ -376,7 +376,7 @@ void set_new_cursor_graphic(int spriteslot) {
// It looks like spriteslot 0 can be used in games with version 2.72 and lower.
// The NULL check should ensure that the sprite is valid anyway.
- if (((spriteslot < 1) && (loaded_game_file_version > kGameVersion_272)) || (_G(mousecurs)[0] == nullptr)) {
+ if (((spriteslot < 1) && (_G(loaded_game_file_version) > kGameVersion_272)) || (_G(mousecurs)[0] == nullptr)) {
if (_G(blank_mouse_cursor) == nullptr) {
_G(blank_mouse_cursor) = BitmapHelper::CreateTransparentBitmap(1, 1, _GP(game).GetColorDepth());
}
diff --git a/engines/ags/engine/ac/object.cpp b/engines/ags/engine/ac/object.cpp
index 771f2e4be8..e8e75001e0 100644
--- a/engines/ags/engine/ac/object.cpp
+++ b/engines/ags/engine/ac/object.cpp
@@ -410,7 +410,7 @@ void move_object(int objj, int tox, int toy, int spee, int ignwal) {
quit("!MoveObject: invalid object number");
// AGS <= 2.61 uses MoveObject with spp=-1 internally instead of SetObjectPosition
- if ((loaded_game_file_version <= kGameVersion_261) && (spee == -1)) {
+ if ((_G(loaded_game_file_version) <= kGameVersion_261) && (spee == -1)) {
_G(objs)[objj].x = tox;
_G(objs)[objj].y = toy;
return;
diff --git a/engines/ags/engine/ac/room.cpp b/engines/ags/engine/ac/room.cpp
index 25ec79ca78..372dcef22b 100644
--- a/engines/ags/engine/ac/room.cpp
+++ b/engines/ags/engine/ac/room.cpp
@@ -419,8 +419,8 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
if (newnum == 0) {
// support both room0.crm and intro.crm
// 2.70: Renamed intro.crm to room0.crm, to stop it causing confusion
- if ((loaded_game_file_version < kGameVersion_270 && Shared::AssetManager::DoesAssetExist("intro.crm")) ||
- (loaded_game_file_version >= kGameVersion_270 && !Shared::AssetManager::DoesAssetExist(room_filename))) {
+ if ((_G(loaded_game_file_version) < kGameVersion_270 && Shared::AssetManager::DoesAssetExist("intro.crm")) ||
+ (_G(loaded_game_file_version) >= kGameVersion_270 && !Shared::AssetManager::DoesAssetExist(room_filename))) {
room_filename = "intro.crm";
}
}
diff --git a/engines/ags/engine/ac/roomstatus.cpp b/engines/ags/engine/ac/roomstatus.cpp
index cfac9f940c..5cfa6c6c27 100644
--- a/engines/ags/engine/ac/roomstatus.cpp
+++ b/engines/ags/engine/ac/roomstatus.cpp
@@ -26,6 +26,7 @@
#include "ags/shared/game/customproperties.h"
#include "ags/engine/game/savegame_components.h"
#include "ags/shared/util/alignedstream.h"
+#include "ags/globals.h"
namespace AGS3 {
@@ -84,7 +85,7 @@ void RoomStatus::ReadFromFile_v321(Stream *in) {
in->ReadArrayOfInt16(walkbehind_base, MAX_WALK_BEHINDS);
in->ReadArrayOfInt32(interactionVariableValues, MAX_GLOBAL_VARIABLES);
- if (loaded_game_file_version >= kGameVersion_340_4) {
+ if (_G(loaded_game_file_version) >= kGameVersion_340_4) {
Properties::ReadValues(roomProps, in);
for (int i = 0; i < MAX_ROOM_HOTSPOTS; ++i) {
Properties::ReadValues(hsProps[i], in);
@@ -112,18 +113,18 @@ void RoomStatus::ReadFromSavegame(Stream *in) {
for (int i = 0; i < numobj; ++i) {
obj[i].ReadFromFile(in);
Properties::ReadValues(objProps[i], in);
- if (loaded_game_file_version <= kGameVersion_272)
+ if (_G(loaded_game_file_version) <= kGameVersion_272)
SavegameComponents::ReadInteraction272(intrObject[i], in);
}
for (int i = 0; i < MAX_ROOM_HOTSPOTS; ++i) {
hotspot_enabled[i] = in->ReadInt8();
Properties::ReadValues(hsProps[i], in);
- if (loaded_game_file_version <= kGameVersion_272)
+ if (_G(loaded_game_file_version) <= kGameVersion_272)
SavegameComponents::ReadInteraction272(intrHotspot[i], in);
}
for (int i = 0; i < MAX_ROOM_REGIONS; ++i) {
region_enabled[i] = in->ReadInt8();
- if (loaded_game_file_version <= kGameVersion_272)
+ if (_G(loaded_game_file_version) <= kGameVersion_272)
SavegameComponents::ReadInteraction272(intrRegion[i], in);
}
for (int i = 0; i < MAX_WALK_BEHINDS; ++i) {
@@ -131,7 +132,7 @@ void RoomStatus::ReadFromSavegame(Stream *in) {
}
Properties::ReadValues(roomProps, in);
- if (loaded_game_file_version <= kGameVersion_272) {
+ if (_G(loaded_game_file_version) <= kGameVersion_272) {
SavegameComponents::ReadInteraction272(intrRoom, in);
in->ReadArrayOfInt32(interactionVariableValues, MAX_GLOBAL_VARIABLES);
}
@@ -149,18 +150,18 @@ void RoomStatus::WriteToSavegame(Stream *out) const {
for (int i = 0; i < numobj; ++i) {
obj[i].WriteToFile(out);
Properties::WriteValues(objProps[i], out);
- if (loaded_game_file_version <= kGameVersion_272)
+ if (_G(loaded_game_file_version) <= kGameVersion_272)
SavegameComponents::WriteInteraction272(intrObject[i], out);
}
for (int i = 0; i < MAX_ROOM_HOTSPOTS; ++i) {
out->WriteInt8(hotspot_enabled[i]);
Properties::WriteValues(hsProps[i], out);
- if (loaded_game_file_version <= kGameVersion_272)
+ if (_G(loaded_game_file_version) <= kGameVersion_272)
SavegameComponents::WriteInteraction272(intrHotspot[i], out);
}
for (int i = 0; i < MAX_ROOM_REGIONS; ++i) {
out->WriteInt8(region_enabled[i]);
- if (loaded_game_file_version <= kGameVersion_272)
+ if (_G(loaded_game_file_version) <= kGameVersion_272)
SavegameComponents::WriteInteraction272(intrRegion[i], out);
}
for (int i = 0; i < MAX_WALK_BEHINDS; ++i) {
@@ -168,7 +169,7 @@ void RoomStatus::WriteToSavegame(Stream *out) const {
}
Properties::WriteValues(roomProps, out);
- if (loaded_game_file_version <= kGameVersion_272) {
+ if (_G(loaded_game_file_version) <= kGameVersion_272) {
SavegameComponents::WriteInteraction272(intrRoom, out);
out->WriteArrayOfInt32(interactionVariableValues, MAX_GLOBAL_VARIABLES);
}
diff --git a/engines/ags/engine/debugging/debug.cpp b/engines/ags/engine/debugging/debug.cpp
index 9fe7df41fe..ea64dcaed2 100644
--- a/engines/ags/engine/debugging/debug.cpp
+++ b/engines/ags/engine/debugging/debug.cpp
@@ -57,8 +57,6 @@ namespace AGS3 {
using namespace AGS::Shared;
using namespace AGS::Engine;
-extern char pexbuf[STD_BUFFER_SIZE];
-
static const char *OutputMsgBufID = "buffer";
static const char *OutputFileID = "file";
static const char *OutputSystemID = "stdout";
diff --git a/engines/ags/engine/game/game_init.cpp b/engines/ags/engine/game/game_init.cpp
index 4869bcaeb2..26ca795761 100644
--- a/engines/ags/engine/game/game_init.cpp
+++ b/engines/ags/engine/game/game_init.cpp
@@ -247,7 +247,7 @@ HError InitAndRegisterGameEntities() {
RegisterStaticArrays();
setup_player_character(_GP(game).playercharacter);
- if (loaded_game_file_version >= kGameVersion_270)
+ if (_G(loaded_game_file_version) >= kGameVersion_270)
ccAddExternalStaticObject("player", &_G(sc_PlayerCharPtr), &GlobalStaticManager);
return HError::None();
}
@@ -343,7 +343,7 @@ HGameInitError InitGameState(const LoadedGameEntities &ents, GameDataVersion dat
//
// 4. Initialize certain runtime variables
//
- game_paused = 0; // reset the game paused flag
+ _G(game_paused) = 0; // reset the game paused flag
_G(ifacepopped) = -1;
String svg_suffix;
diff --git a/engines/ags/engine/game/savegame.cpp b/engines/ags/engine/game/savegame.cpp
index f227cd6ee6..d3f2c76227 100644
--- a/engines/ags/engine/game/savegame.cpp
+++ b/engines/ags/engine/game/savegame.cpp
@@ -424,7 +424,7 @@ void RestoreViewportsAndCameras(const RestoredData &r_data) {
HSaveError DoAfterRestore(const PreservedParams &pp, const RestoredData &r_data) {
// Use a yellow dialog highlight for older game versions
// CHECKME: it is dubious that this should be right here
- if (loaded_game_file_version < kGameVersion_331)
+ if (_G(loaded_game_file_version) < kGameVersion_331)
_GP(play).dialog_options_highlight_color = DIALOG_OPTIONS_HIGHLIGHT_COLOR_DEFAULT;
// Preserve whether the music vox is available
@@ -667,7 +667,7 @@ void WriteDescription(Stream *out, const String &user_text, const Bitmap *user_i
StrUtil::WriteString(_GP(game).guid, out);
StrUtil::WriteString(_GP(game).gamename, out);
StrUtil::WriteString(_GP(ResPaths).GamePak.Name, out);
- out->WriteInt32(loaded_game_file_version);
+ out->WriteInt32(_G(loaded_game_file_version));
out->WriteInt32(_GP(game).GetColorDepth());
// User description
StrUtil::WriteString(user_text, out);
diff --git a/engines/ags/engine/game/savegame_components.cpp b/engines/ags/engine/game/savegame_components.cpp
index 39d0ba329c..7106be6744 100644
--- a/engines/ags/engine/game/savegame_components.cpp
+++ b/engines/ags/engine/game/savegame_components.cpp
@@ -197,7 +197,7 @@ HSaveError WriteGameState(PStream out) {
// Game palette
out->SafeWriteArray(palette, PALETTE_COUNT);
- if (loaded_game_file_version <= kGameVersion_272) {
+ if (_G(loaded_game_file_version) <= kGameVersion_272) {
// Global variables
out->WriteInt32(_G(numGlobalVars));
for (int i = 0; i < _G(numGlobalVars); ++i)
@@ -210,7 +210,7 @@ HSaveError WriteGameState(PStream out) {
out->WriteInt32(_G(frames_per_second));
out->WriteInt32(_G(loopcounter));
out->WriteInt32(_G(ifacepopped));
- out->WriteInt32(game_paused);
+ out->WriteInt32(_G(game_paused));
// Mouse cursor
out->WriteInt32(_G(cur_mode));
out->WriteInt32(_G(cur_cursor));
@@ -286,7 +286,7 @@ HSaveError ReadGameState(PStream in, int32_t cmp_ver, const PreservedParams &pp,
// Game palette
in->SafeReadArray(palette, PALETTE_COUNT);
- if (loaded_game_file_version <= kGameVersion_272) {
+ if (_G(loaded_game_file_version) <= kGameVersion_272) {
// Legacy interaction global variables
if (!AssertGameContent(err, in->ReadInt32(), _G(numGlobalVars), "Global Variables"))
return err;
@@ -301,7 +301,7 @@ HSaveError ReadGameState(PStream in, int32_t cmp_ver, const PreservedParams &pp,
r_data.FPS = in->ReadInt32();
set_loop_counter(in->ReadInt32());
_G(ifacepopped) = in->ReadInt32();
- game_paused = in->ReadInt32();
+ _G(game_paused) = in->ReadInt32();
// Mouse cursor state
r_data.CursorMode = in->ReadInt32();
r_data.CursorID = in->ReadInt32();
@@ -479,7 +479,7 @@ HSaveError WriteCharacters(PStream out) {
_GP(game).chars[i].WriteToFile(out.get());
_G(charextra)[i].WriteToFile(out.get());
Properties::WriteValues(_GP(play).charProps[i], out.get());
- if (loaded_game_file_version <= kGameVersion_272)
+ if (_G(loaded_game_file_version) <= kGameVersion_272)
WriteTimesRun272(*_GP(game).intrChar[i], out.get());
// character movement path cache
_G(mls)[CHMLSOFFS + i].WriteToFile(out.get());
@@ -495,7 +495,7 @@ HSaveError ReadCharacters(PStream in, int32_t cmp_ver, const PreservedParams &pp
_GP(game).chars[i].ReadFromFile(in.get());
_G(charextra)[i].ReadFromFile(in.get());
Properties::ReadValues(_GP(play).charProps[i], in.get());
- if (loaded_game_file_version <= kGameVersion_272)
+ if (_G(loaded_game_file_version) <= kGameVersion_272)
ReadTimesRun272(*_GP(game).intrChar[i], in.get());
// character movement path cache
err = _G(mls)[CHMLSOFFS + i].ReadFromFile(in.get(), cmp_ver > 0 ? 1 : 0);
@@ -638,7 +638,7 @@ HSaveError WriteInventory(PStream out) {
for (int i = 0; i < _GP(game).numinvitems; ++i) {
_GP(game).invinfo[i].WriteToSavegame(out.get());
Properties::WriteValues(_GP(play).invProps[i], out.get());
- if (loaded_game_file_version <= kGameVersion_272)
+ if (_G(loaded_game_file_version) <= kGameVersion_272)
WriteTimesRun272(*_GP(game).intrInv[i], out.get());
}
return HSaveError::None();
@@ -651,7 +651,7 @@ HSaveError ReadInventory(PStream in, int32_t cmp_ver, const PreservedParams &pp,
for (int i = 0; i < _GP(game).numinvitems; ++i) {
_GP(game).invinfo[i].ReadFromSavegame(in.get());
Properties::ReadValues(_GP(play).invProps[i], in.get());
- if (loaded_game_file_version <= kGameVersion_272)
+ if (_G(loaded_game_file_version) <= kGameVersion_272)
ReadTimesRun272(*_GP(game).intrInv[i], in.get());
}
return err;
diff --git a/engines/ags/engine/gui/gui_engine.cpp b/engines/ags/engine/gui/gui_engine.cpp
index a52a122659..e78724def5 100644
--- a/engines/ags/engine/gui/gui_engine.cpp
+++ b/engines/ags/engine/gui/gui_engine.cpp
@@ -70,7 +70,7 @@ bool GUIMain::HasAlphaChannel() const {
// transparent background have alpha channel only since 3.2.0;
// "classic" gui rendering mode historically had non-alpha transparent backgrounds
// (3.2.0 broke the compatibility, now we restore it)
- loaded_game_file_version >= kGameVersion_320 && _GP(game).options[OPT_NEWGUIALPHA] != kGuiAlphaRender_Legacy;
+ _G(loaded_game_file_version) >= kGameVersion_320 && _GP(game).options[OPT_NEWGUIALPHA] != kGuiAlphaRender_Legacy;
}
//=============================================================================
diff --git a/engines/ags/engine/main/engine.cpp b/engines/ags/engine/main/engine.cpp
index c5f901f319..babe4c2932 100644
--- a/engines/ags/engine/main/engine.cpp
+++ b/engines/ags/engine/main/engine.cpp
@@ -83,7 +83,6 @@ namespace AGS3 {
using namespace AGS::Shared;
using namespace AGS::Engine;
-extern char pexbuf[STD_BUFFER_SIZE];
extern color palette[256];
#define ALLEGRO_KEYBOARD_HANDLER
@@ -404,7 +403,7 @@ void engine_init_rand() {
}
void engine_init_pathfinder() {
- init_pathfinder(loaded_game_file_version);
+ init_pathfinder(_G(loaded_game_file_version));
}
void engine_pre_init_gfx() {
@@ -1084,7 +1083,7 @@ static void engine_print_info(const std::set<String> &keys, const String &exe_pa
}
if (all || keys.count("data") > 0) {
data["data"]["gamename"] = _GP(game).gamename;
- data["data"]["version"] = String::FromFormat("%d", loaded_game_file_version);
+ data["data"]["version"] = String::FromFormat("%d", _G(loaded_game_file_version));
data["data"]["compiledwith"] = _GP(game).compiled_with;
data["data"]["basepack"] = _GP(usetup).main_data_filepath;
}
diff --git a/engines/ags/engine/main/engine_setup.cpp b/engines/ags/engine/main/engine_setup.cpp
index 6e790b5198..71ad6d6409 100644
--- a/engines/ags/engine/main/engine_setup.cpp
+++ b/engines/ags/engine/main/engine_setup.cpp
@@ -131,8 +131,8 @@ void engine_init_resolution_settings(const Size game_size) {
Debug::Printf(kDbgMsg_Info, "Game native resolution: %d x %d (%d bit)%s", game_size.Width, game_size.Height, _GP(game).color_depth * 8,
_GP(game).IsLegacyLetterbox() ? " letterbox-by-design" : "");
- convert_gui_to_game_resolution(loaded_game_file_version);
- convert_objects_to_data_resolution(loaded_game_file_version);
+ convert_gui_to_game_resolution(_G(loaded_game_file_version));
+ convert_objects_to_data_resolution(_G(loaded_game_file_version));
Rect viewport = RectWH(game_size);
_GP(play).SetMainViewport(viewport);
diff --git a/engines/ags/engine/main/game_run.cpp b/engines/ags/engine/main/game_run.cpp
index 806dac3a87..d9f0b1a021 100644
--- a/engines/ags/engine/main/game_run.cpp
+++ b/engines/ags/engine/main/game_run.cpp
@@ -73,9 +73,6 @@ namespace AGS3 {
using namespace AGS::Shared;
-extern int game_paused;
-extern int getloctype_index;
-
// Checks if user interface should remain disabled for now
static int ShouldStayInWaitMode();
@@ -566,7 +563,7 @@ static void game_loop_check_controls(bool checkControls) {
static void game_loop_do_update() {
if (_G(debug_flags) & DBG_NOUPDATE);
- else if (game_paused == 0) update_stuff();
+ else if (_G(game_paused) == 0) update_stuff();
}
static void game_loop_update_animated_buttons() {
@@ -607,7 +604,7 @@ static void game_loop_do_render_and_check_mouse(IDriverDependantBitmap *extraBit
(offsetxWas != offsetx) || (offsetyWas != offsety))) {
// mouse moves over hotspot
if (__GetLocationType(game_to_data_coord(_G(mousex)), game_to_data_coord(_G(mousey)), 1) == LOCTYPE_HOTSPOT) {
- int onhs = getloctype_index;
+ int onhs = _G(getloctype_index);
setevent(EV_RUNEVBLOCK, EVB_HOTSPOT, onhs, 6);
}
@@ -946,8 +943,6 @@ void GameLoopUntilNoOverlay() {
GameLoopUntilEvent(UNTIL_NOOVERLAY, 0);
}
-
-extern unsigned int load_new_game;
void RunGameUntilAborted() {
// skip ticks to account for time spent starting _GP(game).
skipMissedTicks();
@@ -955,9 +950,9 @@ void RunGameUntilAborted() {
while (!_G(abort_engine)) {
GameTick();
- if (load_new_game) {
- RunAGSGame(nullptr, load_new_game, 0);
- load_new_game = 0;
+ if (_G(load_new_game)) {
+ RunAGSGame(nullptr, _G(load_new_game), 0);
+ _G(load_new_game) = 0;
}
}
}
diff --git a/engines/ags/engine/main/quit.cpp b/engines/ags/engine/main/quit.cpp
index 0f1589b5ff..8cdea78859 100644
--- a/engines/ags/engine/main/quit.cpp
+++ b/engines/ags/engine/main/quit.cpp
@@ -54,7 +54,6 @@ namespace AGS3 {
using namespace AGS::Shared;
using namespace AGS::Engine;
-extern char pexbuf[STD_BUFFER_SIZE];
extern int need_to_stop_cd;
extern int use_cdplayer;
@@ -162,8 +161,8 @@ void quit_message_on_exit(const char *qmsg, String &alertis, QuitReason qreason)
// if it is empty).
if ((qreason & kQuitKind_NormalExit) == 0 && !_G(handledErrorInEditor)) {
// Display the message (at this point the window still exists)
- sprintf(pexbuf, "%s\n", qmsg);
- alertis.Append(pexbuf);
+ sprintf(_G(pexbuf), "%s\n", qmsg);
+ alertis.Append(_G(pexbuf));
_G(platform)->DisplayAlert("%s", alertis.GetCStr());
}
}
diff --git a/engines/ags/engine/script/script.cpp b/engines/ags/engine/script/script.cpp
index d320465552..152e814991 100644
--- a/engines/ags/engine/script/script.cpp
+++ b/engines/ags/engine/script/script.cpp
@@ -55,7 +55,6 @@
namespace AGS3 {
extern int gameHasBeenRestored;
-extern unsigned int load_new_game;
int run_dialog_request(int parmtr) {
_GP(play).stop_dialog_at_end = DIALOG_RUNNING;
@@ -512,7 +511,7 @@ void post_script_cleanup() {
return;
case ePSARunAGSGame:
cancel_all_scripts();
- load_new_game = thisData;
+ _G(load_new_game) = thisData;
return;
case ePSARunDialog:
do_conversation(thisData);
@@ -548,7 +547,7 @@ void post_script_cleanup() {
}
// if they've changed rooms, cancel any further pending scripts
- if ((_G(displayed_room) != old_room_number) || (load_new_game))
+ if ((_G(displayed_room) != old_room_number) || (_G(load_new_game)))
break;
}
copyof.numanother = 0;
diff --git a/engines/ags/engine/script/script_api.cpp b/engines/ags/engine/script/script_api.cpp
index 51cdeda52b..6d5d6748a5 100644
--- a/engines/ags/engine/script/script_api.cpp
+++ b/engines/ags/engine/script/script_api.cpp
@@ -25,6 +25,7 @@
#include "ags/engine/script/runtimescriptvalue.h"
#include "ags/engine/script/script_api.h"
#include "ags/shared/util/math.h"
+#include "ags/globals.h"
namespace AGS3 {
@@ -185,7 +186,7 @@ const char *ScriptSprintf(char *buffer, size_t buf_length, const char *format,
const char *p = GetArgPtr(sc_args, varg_ptr, arg_idx);
// Do extra checks for %s placeholder
if (fmt_done == kFormatParseArgString && !p) {
- if (loaded_game_file_version < kGameVersion_320) {
+ if (_G(loaded_game_file_version) < kGameVersion_320) {
// explicitly put "(null)" into the placeholder
p = "(null)";
} else {
diff --git a/engines/ags/globals.h b/engines/ags/globals.h
index 83b16cf1fb..707b05fd08 100644
--- a/engines/ags/globals.h
+++ b/engines/ags/globals.h
@@ -23,6 +23,7 @@
#ifndef AGS_GLOBALS_H
#define AGS_GLOBALS_H
+#include "ags/shared/ac/game_version.h"
#include "ags/shared/util/string.h"
#include "ags/shared/util/version.h"
#include "ags/shared/gui/guimain.h"
@@ -610,6 +611,15 @@ public:
bool _proper_exit = false;
int _our_eip = 0;
+ int _oldmouse = 0;
+ GameDataVersion _loaded_game_file_version = kGameVersion_Undefined;
+ int _game_paused = 0;
+ char _pexbuf[STD_BUFFER_SIZE] = { 0 };
+ unsigned int _load_new_game = 0;
+ int _load_new_game_restore = -1;
+ // TODO: refactor these global vars into function arguments
+ int _getloctype_index = 0, _getloctype_throughgui = 0;
+
/**@}*/
/**
diff --git a/engines/ags/plugins/agsplugin.cpp b/engines/ags/plugins/agsplugin.cpp
index 1e2eb02226..1d5c22bf8d 100644
--- a/engines/ags/plugins/agsplugin.cpp
+++ b/engines/ags/plugins/agsplugin.cpp
@@ -84,7 +84,6 @@ using namespace AGS::Shared;
using namespace AGS::Shared::Memory;
using namespace AGS::Engine;
-extern int game_paused;
extern color palette[256];
extern PluginObjectReader pluginReaders[MAX_PLUGIN_OBJECT_READERS];
extern int numPluginReaders;
@@ -523,7 +522,7 @@ int IAGSEngine::GetAreaScaling(int32 x, int32 y) {
return GetScalingAt(x, y);
}
int IAGSEngine::IsGamePaused() {
- return game_paused;
+ return _G(game_paused);
}
int IAGSEngine::GetSpriteWidth(int32 slot) {
return _GP(game).SpriteInfos[slot].Width;
diff --git a/engines/ags/shared/ac/game_version.h b/engines/ags/shared/ac/game_version.h
index 0a0cbca5fd..d2394f50b4 100644
--- a/engines/ags/shared/ac/game_version.h
+++ b/engines/ags/shared/ac/game_version.h
@@ -152,8 +152,6 @@ enum GameDataVersion {
kGameVersion_Current = kGameVersion_351
};
-extern GameDataVersion loaded_game_file_version;
-
} // namespace AGS3
#endif
diff --git a/engines/ags/shared/ac/gamesetupstruct.cpp b/engines/ags/shared/ac/gamesetupstruct.cpp
index 0ad7042e24..37803854c5 100644
--- a/engines/ags/shared/ac/gamesetupstruct.cpp
+++ b/engines/ags/shared/ac/gamesetupstruct.cpp
@@ -362,7 +362,7 @@ void GameSetupStruct::ReadFromSaveGame_v321(Stream *in, char *gswas, ccScript *c
ReadInvInfo_Aligned(in);
ReadMouseCursors_Aligned(in);
- if (loaded_game_file_version <= kGameVersion_272) {
+ if (_G(loaded_game_file_version) <= kGameVersion_272) {
for (bb = 0; bb < numinvitems; bb++)
intrInv[bb]->ReadTimesRunFromSave_v321(in);
for (bb = 0; bb < numcharacters; bb++)
diff --git a/engines/ags/shared/ac/gamesetupstruct.h b/engines/ags/shared/ac/gamesetupstruct.h
index 7dc8660f03..f6b44bf5a4 100644
--- a/engines/ags/shared/ac/gamesetupstruct.h
+++ b/engines/ags/shared/ac/gamesetupstruct.h
@@ -65,7 +65,7 @@ struct GameSetupStruct : public GameSetupStructBase {
std::vector<PInteractionScripts> charScripts;
std::vector<PInteractionScripts> invScripts;
// TODO: why we do not use this in the engine instead of
- // loaded_game_file_version?
+ // _G(loaded_game_file_version)?
int filever; // just used by editor
Shared::String compiled_with; // version of AGS this data was created by
char lipSyncFrameLetters[MAXLIPSYNCFRAMES][50];
diff --git a/engines/ags/shared/ac/gamesetupstructbase.cpp b/engines/ags/shared/ac/gamesetupstructbase.cpp
index 24fd031bd3..f3a405174d 100644
--- a/engines/ags/shared/ac/gamesetupstructbase.cpp
+++ b/engines/ags/shared/ac/gamesetupstructbase.cpp
@@ -147,7 +147,7 @@ void GameSetupStructBase::OnResolutionSet() {
void GameSetupStructBase::ReadFromFile(Stream *in) {
in->Read(&gamename[0], GAME_NAME_LENGTH);
in->ReadArrayOfInt32(options, MAX_OPTIONS);
- if (loaded_game_file_version < kGameVersion_340_4) {
+ if (_G(loaded_game_file_version) < kGameVersion_340_4) {
// TODO: this should probably be possible to deduce script API level
// using game data version and other options like OPT_STRICTSCRIPTING
options[OPT_BASESCRIPTAPI] = kScriptAPI_Undefined;
@@ -174,7 +174,7 @@ void GameSetupStructBase::ReadFromFile(Stream *in) {
numcursors = in->ReadInt32();
GameResolutionType resolution_type = (GameResolutionType)in->ReadInt32();
Size game_size;
- if (resolution_type == kGameResolution_Custom && loaded_game_file_version >= kGameVersion_330) {
+ if (resolution_type == kGameResolution_Custom && _G(loaded_game_file_version) >= kGameVersion_330) {
game_size.Width = in->ReadInt32();
game_size.Height = in->ReadInt32();
}
diff --git a/engines/ags/shared/ac/gamesetupstructbase.h b/engines/ags/shared/ac/gamesetupstructbase.h
index 870ac636c6..e9214e35a5 100644
--- a/engines/ags/shared/ac/gamesetupstructbase.h
+++ b/engines/ags/shared/ac/gamesetupstructbase.h
@@ -27,6 +27,7 @@
#include "ags/shared/ac/gamestructdefines.h"
#include "ags/shared/util/string.h"
#include "ags/shared/util/wgt2allg.h" // color (allegro RGB)
+#include "ags/globals.h"
namespace AGS3 {
@@ -210,7 +211,7 @@ struct GameSetupStructBase {
// Test if the game is built around old audio system
inline bool IsLegacyAudioSystem() const {
- return loaded_game_file_version < kGameVersion_320;
+ return _G(loaded_game_file_version) < kGameVersion_320;
}
// Returns the expected filename of a digital audio package
diff --git a/engines/ags/shared/game/main_game_file.cpp b/engines/ags/shared/game/main_game_file.cpp
index b1ccedfe9a..91ed488392 100644
--- a/engines/ags/shared/game/main_game_file.cpp
+++ b/engines/ags/shared/game/main_game_file.cpp
@@ -148,7 +148,7 @@ HGameFileError OpenMainGameFileBase(PStream &in, MainGameSource &src) {
// NOTE: this global variable is embedded in the code too much to get
// rid of it too easily; the easy way is to set it whenever the main
// game file is opened.
- loaded_game_file_version = src.DataVersion;
+ _G(loaded_game_file_version) = src.DataVersion;
return HGameFileError::None();
}
diff --git a/engines/ags/shared/gui/guiinv.cpp b/engines/ags/shared/gui/guiinv.cpp
index 1fb2563f7f..a7888749d3 100644
--- a/engines/ags/shared/gui/guiinv.cpp
+++ b/engines/ags/shared/gui/guiinv.cpp
@@ -24,6 +24,7 @@
#include "ags/shared/gui/guiinv.h"
#include "ags/shared/gui/guimain.h"
#include "ags/shared/util/stream.h"
+#include "ags/globals.h"
namespace AGS3 {
@@ -84,7 +85,7 @@ void GUIInvWindow::ReadFromFile(Stream *in, GuiVersion gui_version) {
TopItem = 0;
}
- if (loaded_game_file_version >= kGameVersion_270) {
+ if (_G(loaded_game_file_version) >= kGameVersion_270) {
// ensure that some items are visible
if (ItemWidth > Width)
ItemWidth = Width;
@@ -116,7 +117,7 @@ void GUIInvWindow::CalculateNumCells() {
if (ItemWidth <= 0 || ItemHeight <= 0) {
ColCount = 0;
RowCount = 0;
- } else if (loaded_game_file_version >= kGameVersion_270) {
+ } else if (_G(loaded_game_file_version) >= kGameVersion_270) {
ColCount = Width / data_to_game_coord(ItemWidth);
RowCount = Height / data_to_game_coord(ItemHeight);
} else {
diff --git a/engines/ags/shared/gui/guilabel.cpp b/engines/ags/shared/gui/guilabel.cpp
index a3a3c9f482..e72e706e3e 100644
--- a/engines/ags/shared/gui/guilabel.cpp
+++ b/engines/ags/shared/gui/guilabel.cpp
@@ -59,7 +59,7 @@ void GUILabel::Draw(Shared::Bitmap *ds) {
color_t text_color = ds->GetCompatibleColor(TextColor);
const int linespacing = getfontlinespacing(Font) + 1;
// < 2.72 labels did not limit vertical size of text
- const bool limit_by_label_frame = loaded_game_file_version >= kGameVersion_272;
+ const bool limit_by_label_frame = _G(loaded_game_file_version) >= kGameVersion_272;
int at_y = Y;
for (size_t i = 0;
i < _GP(fontLines).Count() && (!limit_by_label_frame || at_y <= Y + Height);
diff --git a/engines/ags/shared/gui/guimain.cpp b/engines/ags/shared/gui/guimain.cpp
index 82632a3825..f7a1a2b9a1 100644
--- a/engines/ags/shared/gui/guimain.cpp
+++ b/engines/ags/shared/gui/guimain.cpp
@@ -92,7 +92,7 @@ void GUIMain::InitDefaults() {
}
int32_t GUIMain::FindControlUnderMouse(int leeway, bool must_be_clickable) const {
- if (loaded_game_file_version <= kGameVersion_262) {
+ if (_G(loaded_game_file_version) <= kGameVersion_262) {
// Ignore draw order On 2.6.2 and lower
for (size_t i = 0; i < _controls.size(); ++i) {
if (!_controls[i]->IsVisible())
@@ -699,7 +699,7 @@ HError ReadGUI(std::vector<GUIMain> &theGuis, Stream *in, bool is_savegame) {
if (GameGuiVersion < kGuiVersion_331)
gui.Padding = TEXTWINDOW_PADDING_DEFAULT;
// fix names for 2.x: "GUI" -> "gGui"
- if (loaded_game_file_version <= kGameVersion_272)
+ if (_G(loaded_game_file_version) <= kGameVersion_272)
gui.Name = GUIMain::FixupGUIName(gui.Name);
// GUI popup style and visibility
More information about the Scummvm-git-logs
mailing list