AGS: Move thisroom to Globals

This commit is contained in:
Paul Gilbert 2021-02-27 16:05:04 -08:00
parent 80bfa0510d
commit ef245e2104
42 changed files with 379 additions and 377 deletions

View file

@ -394,12 +394,12 @@ void AGSEngine::setGraphicsMode(size_t w, size_t h) {
} }
bool AGSEngine::canLoadGameStateCurrently() { bool AGSEngine::canLoadGameStateCurrently() {
return !::AGS3::thisroom.Options.SaveLoadDisabled && return !_GP(thisroom).Options.SaveLoadDisabled &&
!::AGS3::inside_script && !_GP(play).fast_forward; !::AGS3::inside_script && !_GP(play).fast_forward;
} }
bool AGSEngine::canSaveGameStateCurrently() { bool AGSEngine::canSaveGameStateCurrently() {
return !::AGS3::thisroom.Options.SaveLoadDisabled && return !_GP(thisroom).Options.SaveLoadDisabled &&
!::AGS3::inside_script && !_GP(play).fast_forward; !::AGS3::inside_script && !_GP(play).fast_forward;
} }

View file

@ -29,6 +29,7 @@
#include "ags/engine/script/runtimescriptvalue.h" #include "ags/engine/script/runtimescriptvalue.h"
#include "ags/engine/media/audio/audio_system.h" #include "ags/engine/media/audio/audio_system.h"
#include "ags/shared/debugging/out.h" #include "ags/shared/debugging/out.h"
#include "ags/shared/game/roomstruct.h"
#include "ags/engine/script/script_api.h" #include "ags/engine/script/script_api.h"
#include "ags/engine/script/script_runtime.h" #include "ags/engine/script/script_runtime.h"
#include "ags/globals.h" #include "ags/globals.h"
@ -38,7 +39,7 @@ namespace AGS3 {
using namespace AGS::Shared; using namespace AGS::Shared;
extern RoomStruct thisroom;
extern CCAudioClip ccDynamicAudioClip; extern CCAudioClip ccDynamicAudioClip;
int AudioChannel_GetID(ScriptAudioChannel *channel) { int AudioChannel_GetID(ScriptAudioChannel *channel) {
@ -188,7 +189,7 @@ void AudioChannel_SetRoomLocation(ScriptAudioChannel *channel, int xPos, int yPo
auto *ch = lock.GetChannelIfPlaying(channel->id); auto *ch = lock.GetChannelIfPlaying(channel->id);
if (ch) { if (ch) {
int maxDist = ((xPos > thisroom.Width / 2) ? xPos : (thisroom.Width - xPos)) - AMBIENCE_FULL_DIST; int maxDist = ((xPos > _GP(thisroom).Width / 2) ? xPos : (_GP(thisroom).Width - xPos)) - AMBIENCE_FULL_DIST;
ch->_xSource = (xPos > 0) ? xPos : -1; ch->_xSource = (xPos > 0) ? xPos : -1;
ch->_ySource = yPos; ch->_ySource = yPos;
ch->_maximumPossibleDistanceAway = maxDist; ch->_maximumPossibleDistanceAway = maxDist;

View file

@ -80,7 +80,7 @@ namespace AGS3 {
using namespace AGS::Shared; using namespace AGS::Shared;
extern int displayed_room, starting_room; extern int displayed_room, starting_room;
extern RoomStruct thisroom;
extern MoveList *mls; extern MoveList *mls;
extern ViewStruct *views; extern ViewStruct *views;
extern RoomObject *objs; extern RoomObject *objs;
@ -226,13 +226,13 @@ void Character_ChangeRoomAutoPosition(CharacterInfo *chaa, int room, int newPos)
if (new_room_pos == 0) { if (new_room_pos == 0) {
// auto place on other side of screen // auto place on other side of screen
if (chaa->x <= thisroom.Edges.Left + 10) if (chaa->x <= _GP(thisroom).Edges.Left + 10)
new_room_pos = 2000; new_room_pos = 2000;
else if (chaa->x >= thisroom.Edges.Right - 10) else if (chaa->x >= _GP(thisroom).Edges.Right - 10)
new_room_pos = 1000; new_room_pos = 1000;
else if (chaa->y <= thisroom.Edges.Top + 10) else if (chaa->y <= _GP(thisroom).Edges.Top + 10)
new_room_pos = 3000; new_room_pos = 3000;
else if (chaa->y >= thisroom.Edges.Bottom - 10) else if (chaa->y >= _GP(thisroom).Edges.Bottom - 10)
new_room_pos = 4000; new_room_pos = 4000;
if (new_room_pos < 3000) if (new_room_pos < 3000)
@ -1856,16 +1856,16 @@ int doNextCharMoveStep(CharacterInfo *chi, int &char_index, CharacterExtras *che
int find_nearest_walkable_area_within(int32_t *xx, int32_t *yy, int range, int step) { int find_nearest_walkable_area_within(int32_t *xx, int32_t *yy, int range, int step) {
int ex, ey, nearest = 99999, thisis, nearx = 0, neary = 0; int ex, ey, nearest = 99999, thisis, nearx = 0, neary = 0;
int startx = 0, starty = 14; int startx = 0, starty = 14;
int roomWidthLowRes = room_to_mask_coord(thisroom.Width); int roomWidthLowRes = room_to_mask_coord(_GP(thisroom).Width);
int roomHeightLowRes = room_to_mask_coord(thisroom.Height); int roomHeightLowRes = room_to_mask_coord(_GP(thisroom).Height);
int xwidth = roomWidthLowRes, yheight = roomHeightLowRes; int xwidth = roomWidthLowRes, yheight = roomHeightLowRes;
int xLowRes = room_to_mask_coord(xx[0]); int xLowRes = room_to_mask_coord(xx[0]);
int yLowRes = room_to_mask_coord(yy[0]); int yLowRes = room_to_mask_coord(yy[0]);
int rightEdge = room_to_mask_coord(thisroom.Edges.Right); int rightEdge = room_to_mask_coord(_GP(thisroom).Edges.Right);
int leftEdge = room_to_mask_coord(thisroom.Edges.Left); int leftEdge = room_to_mask_coord(_GP(thisroom).Edges.Left);
int topEdge = room_to_mask_coord(thisroom.Edges.Top); int topEdge = room_to_mask_coord(_GP(thisroom).Edges.Top);
int bottomEdge = room_to_mask_coord(thisroom.Edges.Bottom); int bottomEdge = room_to_mask_coord(_GP(thisroom).Edges.Bottom);
// tweak because people forget to move the edges sometimes // tweak because people forget to move the edges sometimes
// if the player is already over the edge, ignore it // if the player is already over the edge, ignore it
@ -1888,7 +1888,7 @@ int find_nearest_walkable_area_within(int32_t *xx, int32_t *yy, int range, int s
for (ex = startx; ex < xwidth; ex += step) { for (ex = startx; ex < xwidth; ex += step) {
for (ey = starty; ey < yheight; ey += step) { for (ey = starty; ey < yheight; ey += step) {
// non-walkalbe, so don't go here // non-walkalbe, so don't go here
if (thisroom.WalkAreaMask->GetPixel(ex, ey) == 0) continue; if (_GP(thisroom).WalkAreaMask->GetPixel(ex, ey) == 0) continue;
// off a screen edge, don't move them there // off a screen edge, don't move them there
if ((ex <= leftEdge) || (ex >= rightEdge) || if ((ex <= leftEdge) || (ex >= rightEdge) ||
(ey <= topEdge) || (ey >= bottomEdge)) (ey <= topEdge) || (ey >= bottomEdge))
@ -1913,7 +1913,7 @@ int find_nearest_walkable_area_within(int32_t *xx, int32_t *yy, int range, int s
void find_nearest_walkable_area(int32_t *xx, int32_t *yy) { void find_nearest_walkable_area(int32_t *xx, int32_t *yy) {
int pixValue = thisroom.WalkAreaMask->GetPixel(room_to_mask_coord(xx[0]), room_to_mask_coord(yy[0])); 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 // 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 || (loaded_game_file_version >= kGameVersion_261 && pixValue < 1)) {
// First, check every 2 pixels within immediate area // First, check every 2 pixels within immediate area

View file

@ -46,7 +46,7 @@ extern ViewStruct *views;
extern int displayed_room; extern int displayed_room;
extern int char_speaking; extern int char_speaking;
extern RoomStruct thisroom;
extern unsigned int loopcounter; extern unsigned int loopcounter;
#define Random __Rand #define Random __Rand
@ -403,17 +403,17 @@ void CharacterInfo::update_character_follower(int &aa, int &numSheep, int *follo
if (room == displayed_room) { if (room == displayed_room) {
// only move to the room-entered position if coming into // only move to the room-entered position if coming into
// the current room // the current room
if (_GP(play).entered_at_x > (thisroom.Width - 8)) { if (_GP(play).entered_at_x > (_GP(thisroom).Width - 8)) {
x = thisroom.Width + 8; x = _GP(thisroom).Width + 8;
y = _GP(play).entered_at_y; y = _GP(play).entered_at_y;
} else if (_GP(play).entered_at_x < 8) { } else if (_GP(play).entered_at_x < 8) {
x = -8; x = -8;
y = _GP(play).entered_at_y; y = _GP(play).entered_at_y;
} else if (_GP(play).entered_at_y > (thisroom.Height - 8)) { } else if (_GP(play).entered_at_y > (_GP(thisroom).Height - 8)) {
y = thisroom.Height + 8; y = _GP(thisroom).Height + 8;
x = _GP(play).entered_at_x; x = _GP(play).entered_at_x;
} else if (_GP(play).entered_at_y < thisroom.Edges.Top + 8) { } else if (_GP(play).entered_at_y < _GP(thisroom).Edges.Top + 8) {
y = thisroom.Edges.Top + 1; y = _GP(thisroom).Edges.Top + 1;
x = _GP(play).entered_at_x; x = _GP(play).entered_at_x;
} else { } else {
// not at one of the edges // not at one of the edges

View file

@ -94,7 +94,7 @@ extern GameSetup usetup;
extern int convert_16bit_bgr; extern int convert_16bit_bgr;
extern ScriptSystem scsystem; extern ScriptSystem scsystem;
extern AGSPlatformDriver *platform; extern AGSPlatformDriver *platform;
extern RoomStruct thisroom;
extern char noWalkBehindsAtAll; extern char noWalkBehindsAtAll;
extern unsigned int loopcounter; extern unsigned int loopcounter;
extern char *walkBehindExists; // whether a WB area is in this column extern char *walkBehindExists; // whether a WB area is in this column
@ -527,8 +527,8 @@ void prepare_roomview_frame(Viewport *view) {
PBitmap &camera_buffer = draw_dat.Buffer; PBitmap &camera_buffer = draw_dat.Buffer;
if (!camera_buffer || camera_buffer->GetWidth() < cam_sz.Width || camera_buffer->GetHeight() < cam_sz.Height) { if (!camera_buffer || camera_buffer->GetWidth() < cam_sz.Width || camera_buffer->GetHeight() < cam_sz.Height) {
// Allocate new buffer bitmap with an extra size in case they will want to zoom out // Allocate new buffer bitmap with an extra size in case they will want to zoom out
int room_width = data_to_game_coord(thisroom.Width); int room_width = data_to_game_coord(_GP(thisroom).Width);
int room_height = data_to_game_coord(thisroom.Height); int room_height = data_to_game_coord(_GP(thisroom).Height);
Size alloc_sz = Size::Clamp(cam_sz * 2, Size(1, 1), Size(room_width, room_height)); Size alloc_sz = Size::Clamp(cam_sz * 2, Size(1, 1), Size(room_width, room_height));
camera_buffer.reset(new Bitmap(alloc_sz.Width, alloc_sz.Height, gfxDriver->GetMemoryBackBuffer()->GetColorDepth())); camera_buffer.reset(new Bitmap(alloc_sz.Width, alloc_sz.Height, gfxDriver->GetMemoryBackBuffer()->GetColorDepth()));
} }
@ -801,7 +801,7 @@ int sort_out_walk_behinds(Bitmap *sprit, int xx, int yy, int basel, Bitmap *copy
if (noWalkBehindsAtAll) if (noWalkBehindsAtAll)
return 0; return 0;
if ((!thisroom.WalkBehindMask->IsMemoryBitmap()) || if ((!_GP(thisroom).WalkBehindMask->IsMemoryBitmap()) ||
(!sprit->IsMemoryBitmap())) (!sprit->IsMemoryBitmap()))
quit("!sort_out_walk_behinds: wb bitmap not linear"); quit("!sort_out_walk_behinds: wb bitmap not linear");
@ -809,7 +809,7 @@ int sort_out_walk_behinds(Bitmap *sprit, int xx, int yy, int basel, Bitmap *copy
// precalculate this to try and shave some time off // precalculate this to try and shave some time off
int maskcol = sprit->GetMaskColor(); int maskcol = sprit->GetMaskColor();
int spcoldep = sprit->GetColorDepth(); int spcoldep = sprit->GetColorDepth();
int screenhit = thisroom.WalkBehindMask->GetHeight(); int screenhit = _GP(thisroom).WalkBehindMask->GetHeight();
short *shptr, *shptr2; short *shptr, *shptr2;
int *loptr, *loptr2; int *loptr, *loptr2;
int pixelsChanged = 0; int pixelsChanged = 0;
@ -821,7 +821,7 @@ int sort_out_walk_behinds(Bitmap *sprit, int xx, int yy, int basel, Bitmap *copy
quit("sprite colour depth does not match background colour depth"); quit("sprite colour depth does not match background colour depth");
for (; ee < sprit->GetWidth(); ee++) { for (; ee < sprit->GetWidth(); ee++) {
if (ee + xx >= thisroom.WalkBehindMask->GetWidth()) if (ee + xx >= _GP(thisroom).WalkBehindMask->GetWidth())
break; break;
if ((!walkBehindExists[ee + xx]) || if ((!walkBehindExists[ee + xx]) ||
@ -849,10 +849,10 @@ int sort_out_walk_behinds(Bitmap *sprit, int xx, int yy, int basel, Bitmap *copy
for (; rr < toheight; rr++) { for (; rr < toheight; rr++) {
// we're ok with _getpixel because we've checked the screen edges // we're ok with _getpixel because we've checked the screen edges
//tmm = _getpixel(thisroom.WalkBehindMask,ee+xx,rr+yy); //tmm = _getpixel(_GP(thisroom).WalkBehindMask,ee+xx,rr+yy);
// actually, _getpixel is well inefficient, do it ourselves // actually, _getpixel is well inefficient, do it ourselves
// since we know it's 8-bit bitmap // since we know it's 8-bit bitmap
tmm = thisroom.WalkBehindMask->GetScanLine(rr + yy)[ee + xx]; tmm = _GP(thisroom).WalkBehindMask->GetScanLine(rr + yy)[ee + xx];
if (tmm < 1) continue; if (tmm < 1) continue;
if (croom->walkbehind_base[tmm] <= basel) continue; if (croom->walkbehind_base[tmm] <= basel) continue;
@ -913,10 +913,10 @@ void sort_out_char_sprite_walk_behind(int actspsIndex, int xx, int yy, int basel
(actspswbcache[actspsIndex].xWas != xx) || (actspswbcache[actspsIndex].xWas != xx) ||
(actspswbcache[actspsIndex].yWas != yy) || (actspswbcache[actspsIndex].yWas != yy) ||
(actspswbcache[actspsIndex].baselineWas != basel)) { (actspswbcache[actspsIndex].baselineWas != basel)) {
actspswb[actspsIndex] = recycle_bitmap(actspswb[actspsIndex], thisroom.BgFrames[_GP(play).bg_frame].Graphic->GetColorDepth(), width, height, true); actspswb[actspsIndex] = recycle_bitmap(actspswb[actspsIndex], _GP(thisroom).BgFrames[_GP(play).bg_frame].Graphic->GetColorDepth(), width, height, true);
Bitmap *wbSprite = actspswb[actspsIndex]; Bitmap *wbSprite = actspswb[actspsIndex];
actspswbcache[actspsIndex].isWalkBehindHere = sort_out_walk_behinds(wbSprite, xx, yy, basel, thisroom.BgFrames[_GP(play).bg_frame].Graphic.get(), actsps[actspsIndex], zoom); actspswbcache[actspsIndex].isWalkBehindHere = sort_out_walk_behinds(wbSprite, xx, yy, basel, _GP(thisroom).BgFrames[_GP(play).bg_frame].Graphic.get(), actsps[actspsIndex], zoom);
actspswbcache[actspsIndex].xWas = xx; actspswbcache[actspsIndex].xWas = xx;
actspswbcache[actspsIndex].yWas = yy; actspswbcache[actspsIndex].yWas = yy;
actspswbcache[actspsIndex].baselineWas = basel; actspswbcache[actspsIndex].baselineWas = basel;
@ -1111,11 +1111,11 @@ void get_local_tint(int xpp, int ypp, int nolight,
} }
if ((onRegion > 0) && (onRegion < MAX_ROOM_REGIONS)) { if ((onRegion > 0) && (onRegion < MAX_ROOM_REGIONS)) {
light_level = thisroom.Regions[onRegion].Light; light_level = _GP(thisroom).Regions[onRegion].Light;
tint_level = thisroom.Regions[onRegion].Tint; tint_level = _GP(thisroom).Regions[onRegion].Tint;
} else if (onRegion <= 0) { } else if (onRegion <= 0) {
light_level = thisroom.Regions[0].Light; light_level = _GP(thisroom).Regions[0].Light;
tint_level = thisroom.Regions[0].Tint; tint_level = _GP(thisroom).Regions[0].Tint;
} }
int tint_sat = (tint_level >> 24) & 0xFF; int tint_sat = (tint_level >> 24) & 0xFF;
@ -1329,7 +1329,7 @@ int construct_object_gfx(int aa, int *drawnWidth, int *drawnHeight, bool alwaysU
zoom_level = objs[aa].zoom; zoom_level = objs[aa].zoom;
} else { } else {
int onarea = get_walkable_area_at_location(objs[aa].x, objs[aa].y); int onarea = get_walkable_area_at_location(objs[aa].x, objs[aa].y);
if ((onarea <= 0) && (thisroom.WalkAreas[0].ScalingFar == 0)) { if ((onarea <= 0) && (_GP(thisroom).WalkAreas[0].ScalingFar == 0)) {
// just off the edge of an area -- use the scaling we had // just off the edge of an area -- use the scaling we had
// while on the area // while on the area
zoom_level = objs[aa].zoom; zoom_level = objs[aa].zoom;
@ -1485,7 +1485,7 @@ void prepare_objects_for_drawing() {
for (int aa = 0; aa < croom->numobj; aa++) { for (int aa = 0; aa < croom->numobj; aa++) {
if (objs[aa].on != 1) continue; if (objs[aa].on != 1) continue;
// offscreen, don't draw // offscreen, don't draw
if ((objs[aa].x >= thisroom.Width) || (objs[aa].y < 1)) if ((objs[aa].x >= _GP(thisroom).Width) || (objs[aa].y < 1))
continue; continue;
const int useindx = aa; const int useindx = aa;
@ -1503,7 +1503,7 @@ void prepare_objects_for_drawing() {
if (objs[aa].flags & OBJF_NOWALKBEHINDS) { if (objs[aa].flags & OBJF_NOWALKBEHINDS) {
// ignore walk-behinds, do nothing // ignore walk-behinds, do nothing
if (walkBehindMethod == DrawAsSeparateSprite) { if (walkBehindMethod == DrawAsSeparateSprite) {
usebasel += thisroom.Height; usebasel += _GP(thisroom).Height;
} }
} else if (walkBehindMethod == DrawAsSeparateCharSprite) { } else if (walkBehindMethod == DrawAsSeparateCharSprite) {
sort_out_char_sprite_walk_behind(useindx, atxp, atyp, usebasel, objs[aa].zoom, objs[aa].last_width, objs[aa].last_height); sort_out_char_sprite_walk_behind(useindx, atxp, atyp, usebasel, objs[aa].zoom, objs[aa].last_width, objs[aa].last_height);
@ -1631,7 +1631,7 @@ void prepare_characters_for_drawing() {
// calculate the zoom level // calculate the zoom level
if (chin->flags & CHF_MANUALSCALING) // character ignores scaling if (chin->flags & CHF_MANUALSCALING) // character ignores scaling
zoom_level = charextra[aa].zoom; zoom_level = charextra[aa].zoom;
else if ((onarea <= 0) && (thisroom.WalkAreas[0].ScalingFar == 0)) { else if ((onarea <= 0) && (_GP(thisroom).WalkAreas[0].ScalingFar == 0)) {
zoom_level = charextra[aa].zoom; zoom_level = charextra[aa].zoom;
// NOTE: room objects don't have this fix // NOTE: room objects don't have this fix
if (zoom_level == 0) if (zoom_level == 0)
@ -1785,7 +1785,7 @@ void prepare_characters_for_drawing() {
if (chin->flags & CHF_NOWALKBEHINDS) { if (chin->flags & CHF_NOWALKBEHINDS) {
// ignore walk-behinds, do nothing // ignore walk-behinds, do nothing
if (walkBehindMethod == DrawAsSeparateSprite) { if (walkBehindMethod == DrawAsSeparateSprite) {
usebasel += thisroom.Height; usebasel += _GP(thisroom).Height;
} }
} else if (walkBehindMethod == DrawAsSeparateCharSprite) { } else if (walkBehindMethod == DrawAsSeparateCharSprite) {
sort_out_char_sprite_walk_behind(useindx, bgX, bgY, usebasel, charextra[aa].zoom, newwidth, newheight); sort_out_char_sprite_walk_behind(useindx, bgX, bgY, usebasel, charextra[aa].zoom, newwidth, newheight);
@ -1835,10 +1835,10 @@ void prepare_room_sprites() {
// Note that software DDB is just a tiny wrapper around bitmap, so overhead is negligible. // Note that software DDB is just a tiny wrapper around bitmap, so overhead is negligible.
if (roomBackgroundBmp == nullptr) { if (roomBackgroundBmp == nullptr) {
update_polled_stuff_if_runtime(); update_polled_stuff_if_runtime();
roomBackgroundBmp = gfxDriver->CreateDDBFromBitmap(thisroom.BgFrames[_GP(play).bg_frame].Graphic.get(), false, true); roomBackgroundBmp = gfxDriver->CreateDDBFromBitmap(_GP(thisroom).BgFrames[_GP(play).bg_frame].Graphic.get(), false, true);
} else if (current_background_is_dirty) { } else if (current_background_is_dirty) {
update_polled_stuff_if_runtime(); update_polled_stuff_if_runtime();
gfxDriver->UpdateDDBFromBitmap(roomBackgroundBmp, thisroom.BgFrames[_GP(play).bg_frame].Graphic.get(), false); gfxDriver->UpdateDDBFromBitmap(roomBackgroundBmp, _GP(thisroom).BgFrames[_GP(play).bg_frame].Graphic.get(), false);
} }
if (gfxDriver->RequiresFullRedrawEachFrame()) { if (gfxDriver->RequiresFullRedrawEachFrame()) {
if (current_background_is_dirty || walkBehindsCachedForBgNum != _GP(play).bg_frame) { if (current_background_is_dirty || walkBehindsCachedForBgNum != _GP(play).bg_frame) {
@ -1905,7 +1905,7 @@ PBitmap draw_room_background(Viewport *view, const SpriteTransform &room_trans)
// the following line takes up to 50% of the game CPU time at // the following line takes up to 50% of the game CPU time at
// high resolutions and colour depths - if we can optimise it // high resolutions and colour depths - if we can optimise it
// somehow, significant performance gains to be had // somehow, significant performance gains to be had
update_room_invreg_and_reset(view_index, roomcam_surface, thisroom.BgFrames[_GP(play).bg_frame].Graphic.get(), draw_to_camsurf); update_room_invreg_and_reset(view_index, roomcam_surface, _GP(thisroom).BgFrames[_GP(play).bg_frame].Graphic.get(), draw_to_camsurf);
} }
return CameraDrawData[view_index].Frame; return CameraDrawData[view_index].Frame;

View file

@ -51,7 +51,7 @@ using namespace Engine;
extern RoomStruct thisroom;
extern RoomObject *objs; extern RoomObject *objs;
extern RoomStatus *croom; extern RoomStatus *croom;
extern CharacterCache *charcache; extern CharacterCache *charcache;
@ -409,7 +409,7 @@ ScriptDynamicSprite *DynamicSprite_CreateFromBackground(int frame, int x1, int y
if (frame == SCR_NO_VALUE) { if (frame == SCR_NO_VALUE) {
frame = _GP(play).bg_frame; frame = _GP(play).bg_frame;
} else if ((frame < 0) || ((size_t)frame >= thisroom.BgFrameCount)) } else if ((frame < 0) || ((size_t)frame >= _GP(thisroom).BgFrameCount))
quit("!DynamicSprite.CreateFromBackground: invalid frame specified"); quit("!DynamicSprite.CreateFromBackground: invalid frame specified");
if (x1 == SCR_NO_VALUE) { if (x1 == SCR_NO_VALUE) {
@ -429,11 +429,11 @@ ScriptDynamicSprite *DynamicSprite_CreateFromBackground(int frame, int x1, int y
return nullptr; return nullptr;
// create a new sprite as a copy of the existing one // create a new sprite as a copy of the existing one
Bitmap *newPic = BitmapHelper::CreateBitmap(width, height, thisroom.BgFrames[frame].Graphic->GetColorDepth()); Bitmap *newPic = BitmapHelper::CreateBitmap(width, height, _GP(thisroom).BgFrames[frame].Graphic->GetColorDepth());
if (newPic == nullptr) if (newPic == nullptr)
return nullptr; return nullptr;
newPic->Blit(thisroom.BgFrames[frame].Graphic.get(), x1, y1, 0, 0, width, height); newPic->Blit(_GP(thisroom).BgFrames[frame].Graphic.get(), x1, y1, 0, 0, width, height);
// replace the bitmap in the sprite set // replace the bitmap in the sprite set
add_dynamic_sprite(gotSlot, newPic); add_dynamic_sprite(gotSlot, newPic);

View file

@ -35,7 +35,7 @@ namespace AGS3 {
using namespace AGS::Shared; using namespace AGS::Shared;
extern RoomStruct thisroom;
extern Bitmap *dynamicallyCreatedSurfaces[MAX_DYNAMIC_SURFACES]; extern Bitmap *dynamicallyCreatedSurfaces[MAX_DYNAMIC_SURFACES];
@ -43,7 +43,7 @@ extern Bitmap *dynamicallyCreatedSurfaces[MAX_DYNAMIC_SURFACES];
Bitmap *ScriptDrawingSurface::GetBitmapSurface() { Bitmap *ScriptDrawingSurface::GetBitmapSurface() {
// TODO: consider creating weak_ptr here, and store one in the DrawingSurface! // TODO: consider creating weak_ptr here, and store one in the DrawingSurface!
if (roomBackgroundNumber >= 0) if (roomBackgroundNumber >= 0)
return thisroom.BgFrames[roomBackgroundNumber].Graphic.get(); return _GP(thisroom).BgFrames[roomBackgroundNumber].Graphic.get();
else if (dynamicSpriteNumber >= 0) else if (dynamicSpriteNumber >= 0)
return _GP(spriteset)[dynamicSpriteNumber]; return _GP(spriteset)[dynamicSpriteNumber];
else if (dynamicSurfaceNumber >= 0) else if (dynamicSurfaceNumber >= 0)
@ -51,7 +51,7 @@ Bitmap *ScriptDrawingSurface::GetBitmapSurface() {
else if (linkedBitmapOnly != nullptr) else if (linkedBitmapOnly != nullptr)
return linkedBitmapOnly; return linkedBitmapOnly;
else if (roomMaskType > kRoomAreaNone) else if (roomMaskType > kRoomAreaNone)
return thisroom.GetMask(roomMaskType); return _GP(thisroom).GetMask(roomMaskType);
quit("!DrawingSurface: attempted to use surface after Release was called"); quit("!DrawingSurface: attempted to use surface after Release was called");
return nullptr; return nullptr;
} }

View file

@ -49,7 +49,7 @@ using namespace AGS::Shared;
using namespace AGS::Engine; using namespace AGS::Engine;
extern RoomStruct thisroom;
extern RoomStatus *croom; extern RoomStatus *croom;
extern int displayed_room; extern int displayed_room;
@ -115,8 +115,8 @@ void run_on_event(int evtype, RuntimeScriptValue &wparam) {
void run_room_event(int id) { void run_room_event(int id) {
evblockbasename = "room"; evblockbasename = "room";
if (thisroom.EventHandlers != nullptr) { if (_GP(thisroom).EventHandlers != nullptr) {
run_interaction_script(thisroom.EventHandlers.get(), id); run_interaction_script(_GP(thisroom).EventHandlers.get(), id);
} else { } else {
run_interaction_event(&croom->intrRoom, id); run_interaction_event(&croom->intrRoom, id);
} }
@ -172,8 +172,8 @@ void process_event(EventHappened *evp) {
if (evp->data1 == EVB_HOTSPOT) { if (evp->data1 == EVB_HOTSPOT) {
if (thisroom.Hotspots[evp->data2].EventHandlers != nullptr) if (_GP(thisroom).Hotspots[evp->data2].EventHandlers != nullptr)
scriptPtr = thisroom.Hotspots[evp->data2].EventHandlers; scriptPtr = _GP(thisroom).Hotspots[evp->data2].EventHandlers;
else else
evpt = &croom->intrHotspot[evp->data2]; evpt = &croom->intrHotspot[evp->data2];
@ -182,8 +182,8 @@ void process_event(EventHappened *evp) {
//Debug::Printf("Running hotspot interaction for hotspot %d, event %d", evp->data2, evp->data3); //Debug::Printf("Running hotspot interaction for hotspot %d, event %d", evp->data2, evp->data3);
} else if (evp->data1 == EVB_ROOM) { } else if (evp->data1 == EVB_ROOM) {
if (thisroom.EventHandlers != nullptr) if (_GP(thisroom).EventHandlers != nullptr)
scriptPtr = thisroom.EventHandlers; scriptPtr = _GP(thisroom).EventHandlers;
else else
evpt = &croom->intrRoom; evpt = &croom->intrRoom;

View file

@ -153,7 +153,6 @@ extern IGraphicsDriver *gfxDriver;
GameSetup usetup; GameSetup usetup;
RoomObject *objs; RoomObject *objs;
RoomStatus *croom = nullptr; RoomStatus *croom = nullptr;
RoomStruct thisroom;
volatile int switching_away_from_game = 0; volatile int switching_away_from_game = 0;
volatile bool switched_away = false; volatile bool switched_away = false;
@ -484,7 +483,7 @@ const char *Game_GetSaveSlotDescription(int slnum) {
void restore_game_dialog() { void restore_game_dialog() {
can_run_delayed_command(); can_run_delayed_command();
if (thisroom.Options.SaveLoadDisabled) { if (_GP(thisroom).Options.SaveLoadDisabled) {
DisplayMessage(983); DisplayMessage(983);
return; return;
} }
@ -501,7 +500,7 @@ void restore_game_dialog() {
} }
void save_game_dialog() { void save_game_dialog() {
if (thisroom.Options.SaveLoadDisabled == 1) { if (_GP(thisroom).Options.SaveLoadDisabled == 1) {
DisplayMessage(983); DisplayMessage(983);
return; return;
} }
@ -1707,7 +1706,7 @@ int __GetLocationType(int xxx, int yyy, int allowHotspot0) {
return 0; return 0;
xxx = vpt.first.X; xxx = vpt.first.X;
yyy = vpt.first.Y; yyy = vpt.first.Y;
if ((xxx >= thisroom.Width) | (xxx < 0) | (yyy < 0) | (yyy >= thisroom.Height)) if ((xxx >= _GP(thisroom).Width) | (xxx < 0) | (yyy < 0) | (yyy >= _GP(thisroom).Height))
return 0; return 0;
// check characters, objects and walkbehinds, work out which is // check characters, objects and walkbehinds, work out which is
@ -1718,7 +1717,7 @@ int __GetLocationType(int xxx, int yyy, int allowHotspot0) {
data_to_game_coords(&xxx, &yyy); data_to_game_coords(&xxx, &yyy);
int wbat = thisroom.WalkBehindMask->GetPixel(xxx, yyy); int wbat = _GP(thisroom).WalkBehindMask->GetPixel(xxx, yyy);
if (wbat <= 0) wbat = 0; if (wbat <= 0) wbat = 0;
else wbat = croom->walkbehind_base[wbat]; else wbat = croom->walkbehind_base[wbat];
@ -1908,7 +1907,7 @@ void get_message_text(int msnum, char *buffer, char giveErr) {
buffer[0] = 0; buffer[0] = 0;
replace_tokens(get_translation(_GP(game).messages[msnum - 500]), buffer, maxlen); replace_tokens(get_translation(_GP(game).messages[msnum - 500]), buffer, maxlen);
return; return;
} else if (msnum < 0 || (size_t)msnum >= thisroom.MessageCount) { } else if (msnum < 0 || (size_t)msnum >= _GP(thisroom).MessageCount) {
if (giveErr) if (giveErr)
quit("!DisplayMessage: Invalid message number to display"); quit("!DisplayMessage: Invalid message number to display");
buffer[0] = 0; buffer[0] = 0;
@ -1916,7 +1915,7 @@ void get_message_text(int msnum, char *buffer, char giveErr) {
} }
buffer[0] = 0; buffer[0] = 0;
replace_tokens(get_translation(thisroom.Messages[msnum]), buffer, maxlen); replace_tokens(get_translation(_GP(thisroom).Messages[msnum]), buffer, maxlen);
} }
bool unserialize_audio_script_object(int index, const char *objectType, const char *serializedData, int dataSize) { bool unserialize_audio_script_object(int index, const char *objectType, const char *serializedData, int dataSize) {

View file

@ -45,7 +45,7 @@ namespace AGS3 {
using namespace AGS::Shared; using namespace AGS::Shared;
using namespace AGS::Engine; using namespace AGS::Engine;
extern RoomStruct thisroom;
extern CharacterInfo *playerchar; extern CharacterInfo *playerchar;
extern ScriptSystem scsystem; extern ScriptSystem scsystem;
@ -179,7 +179,7 @@ void GameState::UpdateRoomCameras() {
void GameState::UpdateRoomCamera(int index) { void GameState::UpdateRoomCamera(int index) {
auto cam = _roomCameras[index]; auto cam = _roomCameras[index];
const Rect &rc = cam->GetRect(); const Rect &rc = cam->GetRect();
const Size real_room_sz = Size(data_to_game_coord(thisroom.Width), data_to_game_coord(thisroom.Height)); const Size real_room_sz = Size(data_to_game_coord(_GP(thisroom).Width), data_to_game_coord(_GP(thisroom).Height));
if ((real_room_sz.Width > rc.GetWidth()) || (real_room_sz.Height > rc.GetHeight())) { if ((real_room_sz.Width > rc.GetWidth()) || (real_room_sz.Height > rc.GetHeight())) {
// TODO: split out into Camera Behavior // TODO: split out into Camera Behavior
if (!cam->IsLocked()) { if (!cam->IsLocked()) {

View file

@ -44,7 +44,7 @@ using namespace AGS::Shared;
extern GameSetup usetup; extern GameSetup usetup;
extern RoomStruct thisroom;
extern SpeechLipSyncLine *splipsync; extern SpeechLipSyncLine *splipsync;
extern int numLipLines, curLipLine, curLipLinePhoneme; extern int numLipLines, curLipLine, curLipLinePhoneme;
@ -92,7 +92,7 @@ void PlayAmbientSound(int channel, int sndnum, int vol, int x, int y) {
} }
// calculate the maximum distance away the player can be, using X // calculate the maximum distance away the player can be, using X
// only (since X centred is still more-or-less total Y) // only (since X centred is still more-or-less total Y)
ambient[channel].maxdist = ((x > thisroom.Width / 2) ? x : (thisroom.Width - x)) - AMBIENCE_FULL_DIST; ambient[channel].maxdist = ((x > _GP(thisroom).Width / 2) ? x : (_GP(thisroom).Width - x)) - AMBIENCE_FULL_DIST;
ambient[channel].num = sndnum; ambient[channel].num = sndnum;
ambient[channel].x = x; ambient[channel].x = x;
ambient[channel].y = y; ambient[channel].y = y;
@ -322,7 +322,7 @@ int GetMP3PosMillis() {
void SetMusicVolume(int newvol) { void SetMusicVolume(int newvol) {
if ((newvol < kRoomVolumeMin) || (newvol > kRoomVolumeMax)) if ((newvol < kRoomVolumeMin) || (newvol > kRoomVolumeMax))
quitprintf("!SetMusicVolume: invalid volume number. Must be from %d to %d.", kRoomVolumeMin, kRoomVolumeMax); quitprintf("!SetMusicVolume: invalid volume number. Must be from %d to %d.", kRoomVolumeMin, kRoomVolumeMax);
thisroom.Options.MusicVolume = (RoomVolumeMod)newvol; _GP(thisroom).Options.MusicVolume = (RoomVolumeMod)newvol;
update_music_volume(); update_music_volume();
} }

View file

@ -56,7 +56,7 @@ using namespace AGS::Shared;
extern ViewStruct *views; extern ViewStruct *views;
extern RoomObject *objs; extern RoomObject *objs;
extern RoomStruct thisroom;
extern ScriptObject scrObj[MAX_ROOM_OBJECTS]; extern ScriptObject scrObj[MAX_ROOM_OBJECTS];
extern ScriptInvItem scrInv[MAX_INV]; extern ScriptInvItem scrInv[MAX_INV];
@ -346,8 +346,8 @@ void MoveCharacterToObject(int chaa, int obbj) {
void MoveCharacterToHotspot(int chaa, int hotsp) { void MoveCharacterToHotspot(int chaa, int hotsp) {
if ((hotsp < 0) || (hotsp >= MAX_ROOM_HOTSPOTS)) if ((hotsp < 0) || (hotsp >= MAX_ROOM_HOTSPOTS))
quit("!MovecharacterToHotspot: invalid hotspot"); quit("!MovecharacterToHotspot: invalid hotspot");
if (thisroom.Hotspots[hotsp].WalkTo.X < 1) return; if (_GP(thisroom).Hotspots[hotsp].WalkTo.X < 1) return;
walk_character(chaa, thisroom.Hotspots[hotsp].WalkTo.X, thisroom.Hotspots[hotsp].WalkTo.Y, 0, true); walk_character(chaa, _GP(thisroom).Hotspots[hotsp].WalkTo.X, _GP(thisroom).Hotspots[hotsp].WalkTo.Y, 0, true);
GameLoopUntilNotMoving(&_GP(game).chars[chaa].walking); GameLoopUntilNotMoving(&_GP(game).chars[chaa].walking);
} }

View file

@ -56,7 +56,7 @@ using namespace AGS::Engine;
extern GameSetup usetup; extern GameSetup usetup;
extern RoomStruct thisroom;
extern CharacterInfo *playerchar; extern CharacterInfo *playerchar;
extern int convert_16bit_bgr; extern int convert_16bit_bgr;
@ -113,12 +113,12 @@ void script_debug(int cmdd, int dataa) {
// TODO: support multiple viewports?! // TODO: support multiple viewports?!
const int viewport_index = 0; const int viewport_index = 0;
const int camera_index = 0; const int camera_index = 0;
Bitmap *tempw = BitmapHelper::CreateBitmap(thisroom.WalkAreaMask->GetWidth(), thisroom.WalkAreaMask->GetHeight()); Bitmap *tempw = BitmapHelper::CreateBitmap(_GP(thisroom).WalkAreaMask->GetWidth(), _GP(thisroom).WalkAreaMask->GetHeight());
tempw->Blit(prepare_walkable_areas(-1), 0, 0, 0, 0, tempw->GetWidth(), tempw->GetHeight()); tempw->Blit(prepare_walkable_areas(-1), 0, 0, 0, 0, tempw->GetWidth(), tempw->GetHeight());
const Rect &viewport = _GP(play).GetRoomViewport(viewport_index)->GetRect(); const Rect &viewport = _GP(play).GetRoomViewport(viewport_index)->GetRect();
const Rect &camera = _GP(play).GetRoomCamera(camera_index)->GetRect(); const Rect &camera = _GP(play).GetRoomCamera(camera_index)->GetRect();
Bitmap *view_bmp = BitmapHelper::CreateBitmap(viewport.GetWidth(), viewport.GetHeight()); Bitmap *view_bmp = BitmapHelper::CreateBitmap(viewport.GetWidth(), viewport.GetHeight());
Rect mask_src = Rect(camera.Left / thisroom.MaskResolution, camera.Top / thisroom.MaskResolution, camera.Right / thisroom.MaskResolution, camera.Bottom / thisroom.MaskResolution); Rect mask_src = Rect(camera.Left / _GP(thisroom).MaskResolution, camera.Top / _GP(thisroom).MaskResolution, camera.Right / _GP(thisroom).MaskResolution, camera.Bottom / _GP(thisroom).MaskResolution);
view_bmp->StretchBlt(tempw, mask_src, RectWH(0, 0, viewport.GetWidth(), viewport.GetHeight()), Shared::kBitmap_Transparency); view_bmp->StretchBlt(tempw, mask_src, RectWH(0, 0, viewport.GetWidth(), viewport.GetHeight()), Shared::kBitmap_Transparency);
IDriverDependantBitmap *ddb = gfxDriver->CreateDDBFromBitmap(view_bmp, false, true); IDriverDependantBitmap *ddb = gfxDriver->CreateDDBFromBitmap(view_bmp, false, true);
@ -153,7 +153,7 @@ void script_debug(int cmdd, int dataa) {
Display("Not currently moving."); Display("Not currently moving.");
return; return;
} }
Bitmap *tempw = BitmapHelper::CreateTransparentBitmap(thisroom.WalkAreaMask->GetWidth(), thisroom.WalkAreaMask->GetHeight()); Bitmap *tempw = BitmapHelper::CreateTransparentBitmap(_GP(thisroom).WalkAreaMask->GetWidth(), _GP(thisroom).WalkAreaMask->GetHeight());
int mlsnum = _GP(game).chars[dataa].walking; int mlsnum = _GP(game).chars[dataa].walking;
if (_GP(game).chars[dataa].walking >= TURNING_AROUND) if (_GP(game).chars[dataa].walking >= TURNING_AROUND)
mlsnum %= TURNING_AROUND; mlsnum %= TURNING_AROUND;
@ -172,7 +172,7 @@ void script_debug(int cmdd, int dataa) {
const Rect &viewport = _GP(play).GetRoomViewport(viewport_index)->GetRect(); const Rect &viewport = _GP(play).GetRoomViewport(viewport_index)->GetRect();
const Rect &camera = _GP(play).GetRoomCamera(camera_index)->GetRect(); const Rect &camera = _GP(play).GetRoomCamera(camera_index)->GetRect();
Bitmap *view_bmp = BitmapHelper::CreateBitmap(viewport.GetWidth(), viewport.GetHeight()); Bitmap *view_bmp = BitmapHelper::CreateBitmap(viewport.GetWidth(), viewport.GetHeight());
Rect mask_src = Rect(camera.Left / thisroom.MaskResolution, camera.Top / thisroom.MaskResolution, camera.Right / thisroom.MaskResolution, camera.Bottom / thisroom.MaskResolution); Rect mask_src = Rect(camera.Left / _GP(thisroom).MaskResolution, camera.Top / _GP(thisroom).MaskResolution, camera.Right / _GP(thisroom).MaskResolution, camera.Bottom / _GP(thisroom).MaskResolution);
view_bmp->StretchBlt(tempw, mask_src, RectWH(0, 0, viewport.GetWidth(), viewport.GetHeight()), Shared::kBitmap_Transparency); view_bmp->StretchBlt(tempw, mask_src, RectWH(0, 0, viewport.GetWidth(), viewport.GetHeight()), Shared::kBitmap_Transparency);
IDriverDependantBitmap *ddb = gfxDriver->CreateDDBFromBitmap(view_bmp, false, true); IDriverDependantBitmap *ddb = gfxDriver->CreateDDBFromBitmap(view_bmp, false, true);

View file

@ -46,7 +46,7 @@ using namespace AGS::Shared;
extern TopBarSettings topBar; extern TopBarSettings topBar;
extern RoomStruct thisroom;
extern int display_message_aschar; extern int display_message_aschar;
@ -122,19 +122,19 @@ void DisplayMessageAtY(int msnum, int ypos) {
while (repeatloop) { while (repeatloop) {
get_message_text(msnum, msgbufr); get_message_text(msnum, msgbufr);
if (thisroom.MessageInfos[msnum].DisplayAs > 0) { if (_GP(thisroom).MessageInfos[msnum].DisplayAs > 0) {
DisplaySpeech(msgbufr, thisroom.MessageInfos[msnum].DisplayAs - 1); DisplaySpeech(msgbufr, _GP(thisroom).MessageInfos[msnum].DisplayAs - 1);
} else { } else {
// time out automatically if they have set that // time out automatically if they have set that
int oldGameSkipDisp = _GP(play).skip_display; int oldGameSkipDisp = _GP(play).skip_display;
if (thisroom.MessageInfos[msnum].Flags & MSG_TIMELIMIT) if (_GP(thisroom).MessageInfos[msnum].Flags & MSG_TIMELIMIT)
_GP(play).skip_display = 0; _GP(play).skip_display = 0;
DisplayAtY(ypos, msgbufr); DisplayAtY(ypos, msgbufr);
_GP(play).skip_display = oldGameSkipDisp; _GP(play).skip_display = oldGameSkipDisp;
} }
if (thisroom.MessageInfos[msnum].Flags & MSG_DISPLAYNEXT) { if (_GP(thisroom).MessageInfos[msnum].Flags & MSG_DISPLAYNEXT) {
msnum++; msnum++;
repeatloop = 1; repeatloop = 1;
} else } else

View file

@ -44,13 +44,13 @@ using namespace AGS::Shared;
using namespace AGS::Engine; using namespace AGS::Engine;
extern Bitmap *raw_saved_screen; extern Bitmap *raw_saved_screen;
extern RoomStruct thisroom;
// Raw screen writing routines - similar to old CapturedStuff // Raw screen writing routines - similar to old CapturedStuff
#define RAW_START() _GP(play).raw_drawing_surface = thisroom.BgFrames[_GP(play).bg_frame].Graphic; _GP(play).raw_modified[_GP(play).bg_frame] = 1 #define RAW_START() _GP(play).raw_drawing_surface = _GP(thisroom).BgFrames[_GP(play).bg_frame].Graphic; _GP(play).raw_modified[_GP(play).bg_frame] = 1
#define RAW_END() #define RAW_END()
#define RAW_SURFACE() (_GP(play).raw_drawing_surface.get()) #define RAW_SURFACE() (_GP(play).raw_drawing_surface.get())
@ -58,7 +58,7 @@ extern RoomStruct thisroom;
void RawSaveScreen() { void RawSaveScreen() {
if (raw_saved_screen != nullptr) if (raw_saved_screen != nullptr)
delete raw_saved_screen; delete raw_saved_screen;
PBitmap source = thisroom.BgFrames[_GP(play).bg_frame].Graphic; PBitmap source = _GP(thisroom).BgFrames[_GP(play).bg_frame].Graphic;
raw_saved_screen = BitmapHelper::CreateBitmapCopy(source.get()); raw_saved_screen = BitmapHelper::CreateBitmapCopy(source.get());
} }
// RawRestoreScreen: copy backup bitmap back to screen; we // RawRestoreScreen: copy backup bitmap back to screen; we
@ -69,7 +69,7 @@ void RawRestoreScreen() {
debug_script_warn("RawRestoreScreen: unable to restore, since the screen hasn't been saved previously."); debug_script_warn("RawRestoreScreen: unable to restore, since the screen hasn't been saved previously.");
return; return;
} }
PBitmap deston = thisroom.BgFrames[_GP(play).bg_frame].Graphic; PBitmap deston = _GP(thisroom).BgFrames[_GP(play).bg_frame].Graphic;
deston->Blit(raw_saved_screen, 0, 0, 0, 0, deston->GetWidth(), deston->GetHeight()); deston->Blit(raw_saved_screen, 0, 0, 0, 0, deston->GetWidth(), deston->GetHeight());
invalidate_screen(); invalidate_screen();
mark_current_background_dirty(); mark_current_background_dirty();
@ -87,18 +87,18 @@ void RawRestoreScreenTinted(int red, int green, int blue, int opacity) {
debug_script_log("RawRestoreTinted RGB(%d,%d,%d) %d%%", red, green, blue, opacity); debug_script_log("RawRestoreTinted RGB(%d,%d,%d) %d%%", red, green, blue, opacity);
PBitmap deston = thisroom.BgFrames[_GP(play).bg_frame].Graphic; PBitmap deston = _GP(thisroom).BgFrames[_GP(play).bg_frame].Graphic;
tint_image(deston.get(), raw_saved_screen, red, green, blue, opacity); tint_image(deston.get(), raw_saved_screen, red, green, blue, opacity);
invalidate_screen(); invalidate_screen();
mark_current_background_dirty(); mark_current_background_dirty();
} }
void RawDrawFrameTransparent(int frame, int translev) { void RawDrawFrameTransparent(int frame, int translev) {
if ((frame < 0) || ((size_t)frame >= thisroom.BgFrameCount) || if ((frame < 0) || ((size_t)frame >= _GP(thisroom).BgFrameCount) ||
(translev < 0) || (translev > 99)) (translev < 0) || (translev > 99))
quit("!RawDrawFrameTransparent: invalid parameter (transparency must be 0-99, frame a valid BG frame)"); quit("!RawDrawFrameTransparent: invalid parameter (transparency must be 0-99, frame a valid BG frame)");
PBitmap bg = thisroom.BgFrames[frame].Graphic; PBitmap bg = _GP(thisroom).BgFrames[frame].Graphic;
if (bg->GetColorDepth() <= 8) if (bg->GetColorDepth() <= 8)
quit("!RawDrawFrameTransparent: 256-colour backgrounds not supported"); quit("!RawDrawFrameTransparent: 256-colour backgrounds not supported");
@ -135,7 +135,7 @@ void RawSetColorRGB(int red, int grn, int blu) {
(blu < 0) || (blu > 255)) (blu < 0) || (blu > 255))
quit("!RawSetColorRGB: colour values must be 0-255"); quit("!RawSetColorRGB: colour values must be 0-255");
_GP(play).raw_color = makecol_depth(thisroom.BgFrames[_GP(play).bg_frame].Graphic->GetColorDepth(), red, grn, blu); _GP(play).raw_color = makecol_depth(_GP(thisroom).BgFrames[_GP(play).bg_frame].Graphic->GetColorDepth(), red, grn, blu);
} }
void RawPrint(int xx, int yy, const char *text) { void RawPrint(int xx, int yy, const char *text) {
RAW_START(); RAW_START();
@ -267,7 +267,7 @@ void RawDrawLine(int fromx, int fromy, int tox, int toy) {
_GP(play).raw_modified[_GP(play).bg_frame] = 1; _GP(play).raw_modified[_GP(play).bg_frame] = 1;
int ii, jj; int ii, jj;
// draw a line thick enough to look the same at all resolutions // draw a line thick enough to look the same at all resolutions
PBitmap bg = thisroom.BgFrames[_GP(play).bg_frame].Graphic; PBitmap bg = _GP(thisroom).BgFrames[_GP(play).bg_frame].Graphic;
color_t draw_color = _GP(play).raw_color; color_t draw_color = _GP(play).raw_color;
for (ii = 0; ii < get_fixed_pixel_size(1); ii++) { for (ii = 0; ii < get_fixed_pixel_size(1); ii++) {
for (jj = 0; jj < get_fixed_pixel_size(1); jj++) for (jj = 0; jj < get_fixed_pixel_size(1); jj++)
@ -281,7 +281,7 @@ void RawDrawCircle(int xx, int yy, int rad) {
rad = data_to_game_coord(rad); rad = data_to_game_coord(rad);
_GP(play).raw_modified[_GP(play).bg_frame] = 1; _GP(play).raw_modified[_GP(play).bg_frame] = 1;
PBitmap bg = thisroom.BgFrames[_GP(play).bg_frame].Graphic; PBitmap bg = _GP(thisroom).BgFrames[_GP(play).bg_frame].Graphic;
bg->FillCircle(Circle(xx, yy, rad), _GP(play).raw_color); bg->FillCircle(Circle(xx, yy, rad), _GP(play).raw_color);
invalidate_screen(); invalidate_screen();
mark_current_background_dirty(); mark_current_background_dirty();
@ -291,7 +291,7 @@ void RawDrawRectangle(int x1, int y1, int x2, int y2) {
data_to_game_coords(&x1, &y1); data_to_game_coords(&x1, &y1);
data_to_game_round_up(&x2, &y2); data_to_game_round_up(&x2, &y2);
PBitmap bg = thisroom.BgFrames[_GP(play).bg_frame].Graphic; PBitmap bg = _GP(thisroom).BgFrames[_GP(play).bg_frame].Graphic;
bg->FillRect(Rect(x1, y1, x2, y2), _GP(play).raw_color); bg->FillRect(Rect(x1, y1, x2, y2), _GP(play).raw_color);
invalidate_screen(); invalidate_screen();
mark_current_background_dirty(); mark_current_background_dirty();
@ -302,7 +302,7 @@ void RawDrawTriangle(int x1, int y1, int x2, int y2, int x3, int y3) {
data_to_game_coords(&x2, &y2); data_to_game_coords(&x2, &y2);
data_to_game_coords(&x3, &y3); data_to_game_coords(&x3, &y3);
PBitmap bg = thisroom.BgFrames[_GP(play).bg_frame].Graphic; PBitmap bg = _GP(thisroom).BgFrames[_GP(play).bg_frame].Graphic;
bg->DrawTriangle(Triangle(x1, y1, x2, y2, x3, y3), _GP(play).raw_color); bg->DrawTriangle(Triangle(x1, y1, x2, y2, x3, y3), _GP(play).raw_color);
invalidate_screen(); invalidate_screen();
mark_current_background_dirty(); mark_current_background_dirty();

View file

@ -90,7 +90,7 @@ extern int load_new_game_restore;
extern ViewStruct *views; extern ViewStruct *views;
extern RoomStatus *croom; extern RoomStatus *croom;
extern int gui_disabled_style; extern int gui_disabled_style;
extern RoomStruct thisroom;
extern int getloctype_index; extern int getloctype_index;
extern IGraphicsDriver *gfxDriver; extern IGraphicsDriver *gfxDriver;
extern color palette[256]; extern color palette[256];
@ -561,7 +561,7 @@ void GetLocationName(int xxx, int yyy, char *tempo) {
return; return;
xxx = vpt.first.X; xxx = vpt.first.X;
yyy = vpt.first.Y; yyy = vpt.first.Y;
if ((xxx >= thisroom.Width) | (xxx < 0) | (yyy < 0) | (yyy >= thisroom.Height)) if ((xxx >= _GP(thisroom).Width) | (xxx < 0) | (yyy < 0) | (yyy >= _GP(thisroom).Height))
return; return;
int onhs, aa; int onhs, aa;
@ -585,7 +585,7 @@ void GetLocationName(int xxx, int yyy, char *tempo) {
// on object // on object
if (loctype == LOCTYPE_OBJ) { if (loctype == LOCTYPE_OBJ) {
aa = getloctype_index; aa = getloctype_index;
strcpy(tempo, get_translation(thisroom.Objects[aa].Name)); strcpy(tempo, get_translation(_GP(thisroom).Objects[aa].Name));
// Compatibility: < 3.1.1 games returned space for nameless object // Compatibility: < 3.1.1 games returned space for nameless object
// (presumably was a bug, but fixing it affected certain games behavior) // (presumably was a bug, but fixing it affected certain games behavior)
if (loaded_game_file_version < kGameVersion_311 && tempo[0] == 0) { if (loaded_game_file_version < kGameVersion_311 && tempo[0] == 0) {
@ -599,7 +599,7 @@ void GetLocationName(int xxx, int yyy, char *tempo) {
} }
onhs = getloctype_index; onhs = getloctype_index;
if (onhs > 0) if (onhs > 0)
strcpy(tempo, get_translation(thisroom.Hotspots[onhs].Name)); strcpy(tempo, get_translation(_GP(thisroom).Hotspots[onhs].Name));
if (_GP(play).get_loc_name_last_time != onhs) if (_GP(play).get_loc_name_last_time != onhs)
guis_need_update = 1; guis_need_update = 1;
_GP(play).get_loc_name_last_time = onhs; _GP(play).get_loc_name_last_time = onhs;
@ -900,11 +900,11 @@ void RoomProcessClick(int xx, int yy, int mood) {
if ((mood == MODE_WALK) && (_GP(game).options[OPT_NOWALKMODE] == 0)) { if ((mood == MODE_WALK) && (_GP(game).options[OPT_NOWALKMODE] == 0)) {
int hsnum = get_hotspot_at(xx, yy); int hsnum = get_hotspot_at(xx, yy);
if (hsnum < 1); if (hsnum < 1);
else if (thisroom.Hotspots[hsnum].WalkTo.X < 1); else if (_GP(thisroom).Hotspots[hsnum].WalkTo.X < 1);
else if (_GP(play).auto_use_walkto_points == 0); else if (_GP(play).auto_use_walkto_points == 0);
else { else {
xx = thisroom.Hotspots[hsnum].WalkTo.X; xx = _GP(thisroom).Hotspots[hsnum].WalkTo.X;
yy = thisroom.Hotspots[hsnum].WalkTo.Y; yy = _GP(thisroom).Hotspots[hsnum].WalkTo.Y;
debug_script_log("Move to walk-to point hotspot %d", hsnum); debug_script_log("Move to walk-to point hotspot %d", hsnum);
} }
walk_character(_GP(game).playercharacter, xx, yy, 0, true); walk_character(_GP(game).playercharacter, xx, yy, 0, true);

View file

@ -42,7 +42,7 @@ namespace AGS3 {
using namespace AGS::Shared; using namespace AGS::Shared;
extern RoomStruct thisroom;
extern RoomStatus *croom; extern RoomStatus *croom;
extern CharacterInfo *playerchar; extern CharacterInfo *playerchar;
@ -66,20 +66,20 @@ int GetHotspotPointX(int hotspot) {
if ((hotspot < 0) || (hotspot >= MAX_ROOM_HOTSPOTS)) if ((hotspot < 0) || (hotspot >= MAX_ROOM_HOTSPOTS))
quit("!GetHotspotPointX: invalid hotspot"); quit("!GetHotspotPointX: invalid hotspot");
if (thisroom.Hotspots[hotspot].WalkTo.X < 1) if (_GP(thisroom).Hotspots[hotspot].WalkTo.X < 1)
return -1; return -1;
return thisroom.Hotspots[hotspot].WalkTo.X; return _GP(thisroom).Hotspots[hotspot].WalkTo.X;
} }
int GetHotspotPointY(int hotspot) { int GetHotspotPointY(int hotspot) {
if ((hotspot < 0) || (hotspot >= MAX_ROOM_HOTSPOTS)) if ((hotspot < 0) || (hotspot >= MAX_ROOM_HOTSPOTS))
quit("!GetHotspotPointY: invalid hotspot"); quit("!GetHotspotPointY: invalid hotspot");
if (thisroom.Hotspots[hotspot].WalkTo.X < 1) // TODO: there was "x" here, why? if (_GP(thisroom).Hotspots[hotspot].WalkTo.X < 1) // TODO: there was "x" here, why?
return -1; return -1;
return thisroom.Hotspots[hotspot].WalkTo.Y; return _GP(thisroom).Hotspots[hotspot].WalkTo.Y;
} }
int GetHotspotIDAtScreen(int scrx, int scry) { int GetHotspotIDAtScreen(int scrx, int scry) {
@ -93,7 +93,7 @@ void GetHotspotName(int hotspot, char *buffer) {
if ((hotspot < 0) || (hotspot >= MAX_ROOM_HOTSPOTS)) if ((hotspot < 0) || (hotspot >= MAX_ROOM_HOTSPOTS))
quit("!GetHotspotName: invalid hotspot number"); quit("!GetHotspotName: invalid hotspot number");
strcpy(buffer, get_translation(thisroom.Hotspots[hotspot].Name)); strcpy(buffer, get_translation(_GP(thisroom).Hotspots[hotspot].Name));
} }
void RunHotspotInteraction(int hotspothere, int mood) { void RunHotspotInteraction(int hotspothere, int mood) {
@ -125,10 +125,10 @@ void RunHotspotInteraction(int hotspothere, int mood) {
evblockbasename = "hotspot%d"; evblockbasename = "hotspot%d";
evblocknum = hotspothere; evblocknum = hotspothere;
if (thisroom.Hotspots[hotspothere].EventHandlers != nullptr) { if (_GP(thisroom).Hotspots[hotspothere].EventHandlers != nullptr) {
if (passon >= 0) if (passon >= 0)
run_interaction_script(thisroom.Hotspots[hotspothere].EventHandlers.get(), passon, 5, (passon == 3)); run_interaction_script(_GP(thisroom).Hotspots[hotspothere].EventHandlers.get(), passon, 5, (passon == 3));
run_interaction_script(thisroom.Hotspots[hotspothere].EventHandlers.get(), 5); // any click on hotspot run_interaction_script(_GP(thisroom).Hotspots[hotspothere].EventHandlers.get(), 5); // any click on hotspot
} else { } else {
if (passon >= 0) { if (passon >= 0) {
if (run_interaction_event(&croom->intrHotspot[hotspothere], passon, 5, (passon == 3))) { if (run_interaction_event(&croom->intrHotspot[hotspothere], passon, 5, (passon == 3))) {
@ -146,11 +146,11 @@ void RunHotspotInteraction(int hotspothere, int mood) {
} }
int GetHotspotProperty(int hss, const char *property) { int GetHotspotProperty(int hss, const char *property) {
return get_int_property(thisroom.Hotspots[hss].Properties, croom->hsProps[hss], property); return get_int_property(_GP(thisroom).Hotspots[hss].Properties, croom->hsProps[hss], property);
} }
void GetHotspotPropertyText(int item, const char *property, char *bufer) { void GetHotspotPropertyText(int item, const char *property, char *bufer) {
get_text_property(thisroom.Hotspots[item].Properties, croom->hsProps[item], property, bufer); get_text_property(_GP(thisroom).Hotspots[item].Properties, croom->hsProps[item], property, bufer);
} }
} // namespace AGS3 } // namespace AGS3

View file

@ -57,7 +57,7 @@ extern RoomObject *objs;
extern ViewStruct *views; extern ViewStruct *views;
extern ObjectCache objcache[MAX_ROOM_OBJECTS]; extern ObjectCache objcache[MAX_ROOM_OBJECTS];
extern RoomStruct thisroom;
extern CharacterInfo *playerchar; extern CharacterInfo *playerchar;
extern int displayed_room; extern int displayed_room;
@ -267,8 +267,8 @@ void MergeObject(int obn) {
construct_object_gfx(obn, nullptr, &theHeight, true); construct_object_gfx(obn, nullptr, &theHeight, true);
//Bitmap *oldabuf = graphics->bmp; //Bitmap *oldabuf = graphics->bmp;
//abuf = thisroom.BgFrames.Graphic[_GP(play).bg_frame]; //abuf = _GP(thisroom).BgFrames.Graphic[_GP(play).bg_frame];
PBitmap bg_frame = thisroom.BgFrames[_GP(play).bg_frame].Graphic; PBitmap bg_frame = _GP(thisroom).BgFrames[_GP(play).bg_frame].Graphic;
if (bg_frame->GetColorDepth() != actsps[obn]->GetColorDepth()) if (bg_frame->GetColorDepth() != actsps[obn]->GetColorDepth())
quit("!MergeObject: unable to merge object due to color depth differences"); quit("!MergeObject: unable to merge object due to color depth differences");
@ -372,7 +372,7 @@ void GetObjectName(int obj, char *buffer) {
if (!is_valid_object(obj)) if (!is_valid_object(obj))
quit("!GetObjectName: invalid object number"); quit("!GetObjectName: invalid object number");
strcpy(buffer, get_translation(thisroom.Objects[obj].Name)); strcpy(buffer, get_translation(_GP(thisroom).Objects[obj].Name));
} }
void MoveObject(int objj, int xx, int yy, int spp) { void MoveObject(int objj, int xx, int yy, int spp) {
@ -420,12 +420,12 @@ void RunObjectInteraction(int aa, int mood) {
evblockbasename = "object%d"; evblockbasename = "object%d";
evblocknum = aa; evblocknum = aa;
if (thisroom.Objects[aa].EventHandlers != nullptr) { if (_GP(thisroom).Objects[aa].EventHandlers != nullptr) {
if (passon >= 0) { if (passon >= 0) {
if (run_interaction_script(thisroom.Objects[aa].EventHandlers.get(), passon, 4, (passon == 3))) if (run_interaction_script(_GP(thisroom).Objects[aa].EventHandlers.get(), passon, 4, (passon == 3)))
return; return;
} }
run_interaction_script(thisroom.Objects[aa].EventHandlers.get(), 4); // any click on obj run_interaction_script(_GP(thisroom).Objects[aa].EventHandlers.get(), 4); // any click on obj
} else { } else {
if (passon >= 0) { if (passon >= 0) {
if (run_interaction_event(&croom->intrObject[aa], passon, 4, (passon == 3))) if (run_interaction_event(&croom->intrObject[aa], passon, 4, (passon == 3)))
@ -499,11 +499,11 @@ int AreThingsOverlapping(int thing1, int thing2) {
int GetObjectProperty(int hss, const char *property) { int GetObjectProperty(int hss, const char *property) {
if (!is_valid_object(hss)) if (!is_valid_object(hss))
quit("!GetObjectProperty: invalid object"); quit("!GetObjectProperty: invalid object");
return get_int_property(thisroom.Objects[hss].Properties, croom->objProps[hss], property); return get_int_property(_GP(thisroom).Objects[hss].Properties, croom->objProps[hss], property);
} }
void GetObjectPropertyText(int item, const char *property, char *bufer) { void GetObjectPropertyText(int item, const char *property, char *bufer) {
get_text_property(thisroom.Objects[item].Properties, croom->objProps[item], property, bufer); get_text_property(_GP(thisroom).Objects[item].Properties, croom->objProps[item], property, bufer);
} }
Bitmap *GetObjectImage(int obj, int *isFlipped) { Bitmap *GetObjectImage(int obj, int *isFlipped) {

View file

@ -36,7 +36,7 @@ namespace AGS3 {
using namespace AGS::Shared; using namespace AGS::Shared;
extern RoomStruct thisroom;
extern RoomStatus *croom; extern RoomStatus *croom;
extern const char *evblockbasename; extern const char *evblockbasename;
extern int evblocknum; extern int evblocknum;
@ -49,17 +49,17 @@ int GetRegionIDAtRoom(int xxx, int yyy) {
yyy = room_to_mask_coord(yyy); yyy = room_to_mask_coord(yyy);
if (loaded_game_file_version >= kGameVersion_262) { // Version 2.6.2+ if (loaded_game_file_version >= kGameVersion_262) { // Version 2.6.2+
if (xxx >= thisroom.RegionMask->GetWidth()) if (xxx >= _GP(thisroom).RegionMask->GetWidth())
xxx = thisroom.RegionMask->GetWidth() - 1; xxx = _GP(thisroom).RegionMask->GetWidth() - 1;
if (yyy >= thisroom.RegionMask->GetHeight()) if (yyy >= _GP(thisroom).RegionMask->GetHeight())
yyy = thisroom.RegionMask->GetHeight() - 1; yyy = _GP(thisroom).RegionMask->GetHeight() - 1;
if (xxx < 0) if (xxx < 0)
xxx = 0; xxx = 0;
if (yyy < 0) if (yyy < 0)
yyy = 0; yyy = 0;
} }
int hsthere = thisroom.RegionMask->GetPixel(xxx, yyy); int hsthere = _GP(thisroom).RegionMask->GetPixel(xxx, yyy);
if (hsthere <= 0 || hsthere >= MAX_ROOM_REGIONS) return 0; if (hsthere <= 0 || hsthere >= MAX_ROOM_REGIONS) return 0;
if (croom->region_enabled[hsthere] == 0) return 0; if (croom->region_enabled[hsthere] == 0) return 0;
return hsthere; return hsthere;
@ -70,9 +70,9 @@ void SetAreaLightLevel(int area, int brightness) {
quit("!SetAreaLightLevel: invalid region"); quit("!SetAreaLightLevel: invalid region");
if (brightness < -100) brightness = -100; if (brightness < -100) brightness = -100;
if (brightness > 100) brightness = 100; if (brightness > 100) brightness = 100;
thisroom.Regions[area].Light = brightness; _GP(thisroom).Regions[area].Light = brightness;
// disable RGB tint for this area // disable RGB tint for this area
thisroom.Regions[area].Tint = 0; _GP(thisroom).Regions[area].Tint = 0;
debug_script_log("Region %d light level set to %d", area, brightness); debug_script_log("Region %d light level set to %d", area, brightness);
} }
@ -101,11 +101,11 @@ void SetRegionTint(int area, int red, int green, int blue, int amount, int lumin
green -= 100; green -= 100;
blue -= 100;*/ blue -= 100;*/
thisroom.Regions[area].Tint = (red & 0xFF) | _GP(thisroom).Regions[area].Tint = (red & 0xFF) |
((green & 0xFF) << 8) | ((green & 0xFF) << 8) |
((blue & 0XFF) << 16) | ((blue & 0XFF) << 16) |
((amount & 0xFF) << 24); ((amount & 0xFF) << 24);
thisroom.Regions[area].Light = (luminance * 25) / 10; _GP(thisroom).Regions[area].Light = (luminance * 25) / 10;
} }
void DisableRegion(int hsnum) { void DisableRegion(int hsnum) {
@ -158,8 +158,8 @@ void RunRegionInteraction(int regnum, int mood) {
evblockbasename = "region%d"; evblockbasename = "region%d";
evblocknum = regnum; evblocknum = regnum;
if (thisroom.Regions[regnum].EventHandlers != nullptr) { if (_GP(thisroom).Regions[regnum].EventHandlers != nullptr) {
run_interaction_script(thisroom.Regions[regnum].EventHandlers.get(), mood); run_interaction_script(_GP(thisroom).Regions[regnum].EventHandlers.get(), mood);
} else { } else {
run_interaction_event(&croom->intrRegion[regnum], mood); run_interaction_event(&croom->intrRegion[regnum], mood);
} }

View file

@ -54,7 +54,7 @@ extern int in_leaves_screen;
extern int in_inv_screen, inv_screen_newroom; extern int in_inv_screen, inv_screen_newroom;
extern MoveList *mls; extern MoveList *mls;
extern int gs_to_newroom; extern int gs_to_newroom;
extern RoomStruct thisroom;
void SetAmbientTint(int red, int green, int blue, int opacity, int luminance) { void SetAmbientTint(int red, int green, int blue, int opacity, int luminance) {
if ((red < 0) || (green < 0) || (blue < 0) || if ((red < 0) || (green < 0) || (blue < 0) ||
@ -198,11 +198,11 @@ int HasBeenToRoom(int roomnum) {
} }
void GetRoomPropertyText(const char *property, char *bufer) { void GetRoomPropertyText(const char *property, char *bufer) {
get_text_property(thisroom.Properties, croom->roomProps, property, bufer); get_text_property(_GP(thisroom).Properties, croom->roomProps, property, bufer);
} }
void SetBackgroundFrame(int frnum) { void SetBackgroundFrame(int frnum) {
if ((frnum < -1) || (frnum != -1 && (size_t)frnum >= thisroom.BgFrameCount)) if ((frnum < -1) || (frnum != -1 && (size_t)frnum >= _GP(thisroom).BgFrameCount))
quit("!SetBackgrondFrame: invalid frame number specified"); quit("!SetBackgrondFrame: invalid frame number specified");
if (frnum < 0) { if (frnum < 0) {
_GP(play).bg_frame_locked = 0; _GP(play).bg_frame_locked = 0;

View file

@ -44,7 +44,7 @@ using namespace AGS::Engine;
extern GameSetup usetup; extern GameSetup usetup;
extern RoomStruct thisroom;
extern IGraphicsDriver *gfxDriver; extern IGraphicsDriver *gfxDriver;
extern AGSPlatformDriver *platform; extern AGSPlatformDriver *platform;
extern color palette[256]; extern color palette[256];

View file

@ -33,7 +33,7 @@ namespace AGS3 {
using namespace AGS::Shared; using namespace AGS::Shared;
extern RoomStruct thisroom;
int GetScalingAt(int x, int y) { int GetScalingAt(int x, int y) {
@ -59,11 +59,11 @@ void SetAreaScaling(int area, int min, int max) {
max -= 100; max -= 100;
if (min == max) { if (min == max) {
thisroom.WalkAreas[area].ScalingFar = min; _GP(thisroom).WalkAreas[area].ScalingFar = min;
thisroom.WalkAreas[area].ScalingNear = NOT_VECTOR_SCALED; _GP(thisroom).WalkAreas[area].ScalingNear = NOT_VECTOR_SCALED;
} else { } else {
thisroom.WalkAreas[area].ScalingFar = min; _GP(thisroom).WalkAreas[area].ScalingFar = min;
thisroom.WalkAreas[area].ScalingNear = max; _GP(thisroom).WalkAreas[area].ScalingNear = max;
} }
} }

View file

@ -66,7 +66,7 @@ using namespace AGS::Engine;
extern GameSetup usetup; extern GameSetup usetup;
extern RoomStruct thisroom;
extern int cur_mode, cur_cursor; extern int cur_mode, cur_cursor;
extern ccInstance *gameinst; extern ccInstance *gameinst;
extern ScriptGUI *scrGui; extern ScriptGUI *scrGui;

View file

@ -42,7 +42,7 @@ namespace AGS3 {
using namespace AGS::Shared; using namespace AGS::Shared;
extern RoomStruct thisroom;
extern RoomStatus *croom; extern RoomStatus *croom;
extern ScriptHotspot scrHotspot[MAX_ROOM_HOTSPOTS]; extern ScriptHotspot scrHotspot[MAX_ROOM_HOTSPOTS];
extern CCHotspot ccDynamicHotspot; extern CCHotspot ccDynamicHotspot;
@ -83,7 +83,7 @@ void Hotspot_GetName(ScriptHotspot *hss, char *buffer) {
} }
const char *Hotspot_GetName_New(ScriptHotspot *hss) { const char *Hotspot_GetName_New(ScriptHotspot *hss) {
return CreateNewScriptString(get_translation(thisroom.Hotspots[hss->id].Name)); return CreateNewScriptString(get_translation(_GP(thisroom).Hotspots[hss->id].Name));
} }
bool Hotspot_IsInteractionAvailable(ScriptHotspot *hhot, int mood) { bool Hotspot_IsInteractionAvailable(ScriptHotspot *hhot, int mood) {
@ -100,16 +100,16 @@ void Hotspot_RunInteraction(ScriptHotspot *hss, int mood) {
} }
int Hotspot_GetProperty(ScriptHotspot *hss, const char *property) { int Hotspot_GetProperty(ScriptHotspot *hss, const char *property) {
return get_int_property(thisroom.Hotspots[hss->id].Properties, croom->hsProps[hss->id], property); return get_int_property(_GP(thisroom).Hotspots[hss->id].Properties, croom->hsProps[hss->id], property);
} }
void Hotspot_GetPropertyText(ScriptHotspot *hss, const char *property, char *bufer) { void Hotspot_GetPropertyText(ScriptHotspot *hss, const char *property, char *bufer) {
get_text_property(thisroom.Hotspots[hss->id].Properties, croom->hsProps[hss->id], property, bufer); get_text_property(_GP(thisroom).Hotspots[hss->id].Properties, croom->hsProps[hss->id], property, bufer);
} }
const char *Hotspot_GetTextProperty(ScriptHotspot *hss, const char *property) { const char *Hotspot_GetTextProperty(ScriptHotspot *hss, const char *property) {
return get_text_property_dynamic_string(thisroom.Hotspots[hss->id].Properties, croom->hsProps[hss->id], property); return get_text_property_dynamic_string(_GP(thisroom).Hotspots[hss->id].Properties, croom->hsProps[hss->id], property);
} }
bool Hotspot_SetProperty(ScriptHotspot *hss, const char *property, int value) { bool Hotspot_SetProperty(ScriptHotspot *hss, const char *property, int value) {
@ -121,7 +121,7 @@ bool Hotspot_SetTextProperty(ScriptHotspot *hss, const char *property, const cha
} }
int get_hotspot_at(int xpp, int ypp) { int get_hotspot_at(int xpp, int ypp) {
int onhs = thisroom.HotspotMask->GetPixel(room_to_mask_coord(xpp), room_to_mask_coord(ypp)); int onhs = _GP(thisroom).HotspotMask->GetPixel(room_to_mask_coord(xpp), room_to_mask_coord(ypp));
if (onhs <= 0 || onhs >= MAX_ROOM_HOTSPOTS) return 0; if (onhs <= 0 || onhs >= MAX_ROOM_HOTSPOTS) return 0;
if (croom->hotspot_enabled[onhs] == 0) return 0; if (croom->hotspot_enabled[onhs] == 0) return 0;
return onhs; return onhs;

View file

@ -59,7 +59,7 @@ extern ScriptObject scrObj[MAX_ROOM_OBJECTS];
extern RoomStatus *croom; extern RoomStatus *croom;
extern RoomObject *objs; extern RoomObject *objs;
extern ViewStruct *views; extern ViewStruct *views;
extern RoomStruct thisroom;
extern ObjectCache objcache[MAX_ROOM_OBJECTS]; extern ObjectCache objcache[MAX_ROOM_OBJECTS];
extern MoveList *mls; extern MoveList *mls;
@ -292,7 +292,7 @@ const char *Object_GetName_New(ScriptObject *objj) {
if (!is_valid_object(objj->id)) if (!is_valid_object(objj->id))
quit("!Object.Name: invalid object number"); quit("!Object.Name: invalid object number");
return CreateNewScriptString(get_translation(thisroom.Objects[objj->id].Name)); return CreateNewScriptString(get_translation(_GP(thisroom).Objects[objj->id].Name));
} }
bool Object_IsInteractionAvailable(ScriptObject *oobj, int mood) { bool Object_IsInteractionAvailable(ScriptObject *oobj, int mood) {
@ -460,7 +460,7 @@ void Object_GetPropertyText(ScriptObject *objj, const char *property, char *bufe
} }
const char *Object_GetTextProperty(ScriptObject *objj, const char *property) { const char *Object_GetTextProperty(ScriptObject *objj, const char *property) {
return get_text_property_dynamic_string(thisroom.Objects[objj->id].Properties, croom->objProps[objj->id], property); return get_text_property_dynamic_string(_GP(thisroom).Objects[objj->id].Properties, croom->objProps[objj->id], property);
} }
bool Object_SetProperty(ScriptObject *objj, const char *property, int value) { bool Object_SetProperty(ScriptObject *objj, const char *property, int value) {

View file

@ -41,7 +41,7 @@ namespace AGS3 {
using namespace AGS::Shared; using namespace AGS::Shared;
extern ScriptRegion scrRegion[MAX_ROOM_REGIONS]; extern ScriptRegion scrRegion[MAX_ROOM_REGIONS];
extern RoomStruct thisroom;
extern RoomStatus *croom; extern RoomStatus *croom;
extern COLOR_MAP maincoltable; extern COLOR_MAP maincoltable;
@ -65,37 +65,37 @@ void Region_SetLightLevel(ScriptRegion *ssr, int brightness) {
} }
int Region_GetLightLevel(ScriptRegion *ssr) { int Region_GetLightLevel(ScriptRegion *ssr) {
return thisroom.GetRegionLightLevel(ssr->id); return _GP(thisroom).GetRegionLightLevel(ssr->id);
} }
int Region_GetTintEnabled(ScriptRegion *srr) { int Region_GetTintEnabled(ScriptRegion *srr) {
if (thisroom.Regions[srr->id].Tint & 0xFF000000) if (_GP(thisroom).Regions[srr->id].Tint & 0xFF000000)
return 1; return 1;
return 0; return 0;
} }
int Region_GetTintRed(ScriptRegion *srr) { int Region_GetTintRed(ScriptRegion *srr) {
return thisroom.Regions[srr->id].Tint & 0x000000ff; return _GP(thisroom).Regions[srr->id].Tint & 0x000000ff;
} }
int Region_GetTintGreen(ScriptRegion *srr) { int Region_GetTintGreen(ScriptRegion *srr) {
return (thisroom.Regions[srr->id].Tint >> 8) & 0x000000ff; return (_GP(thisroom).Regions[srr->id].Tint >> 8) & 0x000000ff;
} }
int Region_GetTintBlue(ScriptRegion *srr) { int Region_GetTintBlue(ScriptRegion *srr) {
return (thisroom.Regions[srr->id].Tint >> 16) & 0x000000ff; return (_GP(thisroom).Regions[srr->id].Tint >> 16) & 0x000000ff;
} }
int Region_GetTintSaturation(ScriptRegion *srr) { int Region_GetTintSaturation(ScriptRegion *srr) {
return (thisroom.Regions[srr->id].Tint >> 24) & 0xFF; return (_GP(thisroom).Regions[srr->id].Tint >> 24) & 0xFF;
} }
int Region_GetTintLuminance(ScriptRegion *srr) { int Region_GetTintLuminance(ScriptRegion *srr) {
return thisroom.GetRegionTintLuminance(srr->id); return _GP(thisroom).GetRegionTintLuminance(srr->id);
} }
void Region_Tint(ScriptRegion *srr, int red, int green, int blue, int amount, int luminance) { void Region_Tint(ScriptRegion *srr, int red, int green, int blue, int amount, int luminance) {

View file

@ -139,7 +139,7 @@ ScriptDrawingSurface *Room_GetDrawingSurfaceForBackground(int backgroundNumber)
backgroundNumber = _GP(play).bg_frame; backgroundNumber = _GP(play).bg_frame;
} }
if ((backgroundNumber < 0) || ((size_t)backgroundNumber >= thisroom.BgFrameCount)) if ((backgroundNumber < 0) || ((size_t)backgroundNumber >= _GP(thisroom).BgFrameCount))
quit("!Room.GetDrawingSurfaceForBackground: invalid background number specified"); quit("!Room.GetDrawingSurfaceForBackground: invalid background number specified");
@ -163,43 +163,43 @@ int Room_GetObjectCount() {
} }
int Room_GetWidth() { int Room_GetWidth() {
return thisroom.Width; return _GP(thisroom).Width;
} }
int Room_GetHeight() { int Room_GetHeight() {
return thisroom.Height; return _GP(thisroom).Height;
} }
int Room_GetColorDepth() { int Room_GetColorDepth() {
return thisroom.BgFrames[0].Graphic->GetColorDepth(); return _GP(thisroom).BgFrames[0].Graphic->GetColorDepth();
} }
int Room_GetLeftEdge() { int Room_GetLeftEdge() {
return thisroom.Edges.Left; return _GP(thisroom).Edges.Left;
} }
int Room_GetRightEdge() { int Room_GetRightEdge() {
return thisroom.Edges.Right; return _GP(thisroom).Edges.Right;
} }
int Room_GetTopEdge() { int Room_GetTopEdge() {
return thisroom.Edges.Top; return _GP(thisroom).Edges.Top;
} }
int Room_GetBottomEdge() { int Room_GetBottomEdge() {
return thisroom.Edges.Bottom; return _GP(thisroom).Edges.Bottom;
} }
int Room_GetMusicOnLoad() { int Room_GetMusicOnLoad() {
return thisroom.Options.StartupMusic; return _GP(thisroom).Options.StartupMusic;
} }
int Room_GetProperty(const char *property) { int Room_GetProperty(const char *property) {
return get_int_property(thisroom.Properties, croom->roomProps, property); return get_int_property(_GP(thisroom).Properties, croom->roomProps, property);
} }
const char *Room_GetTextProperty(const char *property) { const char *Room_GetTextProperty(const char *property) {
return get_text_property_dynamic_string(thisroom.Properties, croom->roomProps, property); return get_text_property_dynamic_string(_GP(thisroom).Properties, croom->roomProps, property);
} }
bool Room_SetProperty(const char *property, int value) { bool Room_SetProperty(const char *property, int value) {
@ -211,12 +211,12 @@ bool Room_SetTextProperty(const char *property, const char *value) {
} }
const char *Room_GetMessages(int index) { const char *Room_GetMessages(int index) {
if ((index < 0) || ((size_t)index >= thisroom.MessageCount)) { if ((index < 0) || ((size_t)index >= _GP(thisroom).MessageCount)) {
return nullptr; return nullptr;
} }
char buffer[STD_BUFFER_SIZE]; char buffer[STD_BUFFER_SIZE];
buffer[0] = 0; buffer[0] = 0;
replace_tokens(get_translation(thisroom.Messages[index]), buffer, STD_BUFFER_SIZE); replace_tokens(get_translation(_GP(thisroom).Messages[index]), buffer, STD_BUFFER_SIZE);
return CreateNewScriptString(buffer); return CreateNewScriptString(buffer);
} }
@ -227,19 +227,19 @@ const char *Room_GetMessages(int index) {
// in game resolution coordinates; in other words makes graphics appropriate // in game resolution coordinates; in other words makes graphics appropriate
// for display in the game. // for display in the game.
void convert_room_background_to_game_res() { void convert_room_background_to_game_res() {
if (!_GP(game).AllowRelativeRes() || !thisroom.IsRelativeRes()) if (!_GP(game).AllowRelativeRes() || !_GP(thisroom).IsRelativeRes())
return; return;
int bkg_width = thisroom.Width; int bkg_width = _GP(thisroom).Width;
int bkg_height = thisroom.Height; int bkg_height = _GP(thisroom).Height;
data_to_game_coords(&bkg_width, &bkg_height); data_to_game_coords(&bkg_width, &bkg_height);
for (size_t i = 0; i < thisroom.BgFrameCount; ++i) for (size_t i = 0; i < _GP(thisroom).BgFrameCount; ++i)
thisroom.BgFrames[i].Graphic = FixBitmap(thisroom.BgFrames[i].Graphic, bkg_width, bkg_height); _GP(thisroom).BgFrames[i].Graphic = FixBitmap(_GP(thisroom).BgFrames[i].Graphic, bkg_width, bkg_height);
// Fix walk-behinds to match room background // Fix walk-behinds to match room background
// TODO: would not we need to do similar to each mask if they were 1:1 in hires room? // TODO: would not we need to do similar to each mask if they were 1:1 in hires room?
thisroom.WalkBehindMask = FixBitmap(thisroom.WalkBehindMask, bkg_width, bkg_height); _GP(thisroom).WalkBehindMask = FixBitmap(_GP(thisroom).WalkBehindMask, bkg_width, bkg_height);
} }
@ -299,8 +299,8 @@ void unload_old_room() {
raw_saved_screen = nullptr; raw_saved_screen = nullptr;
for (ff = 0; ff < MAX_ROOM_BGFRAMES; ff++) for (ff = 0; ff < MAX_ROOM_BGFRAMES; ff++)
_GP(play).raw_modified[ff] = 0; _GP(play).raw_modified[ff] = 0;
for (size_t i = 0; i < thisroom.LocalVariables.size() && i < MAX_GLOBAL_VARIABLES; ++i) for (size_t i = 0; i < _GP(thisroom).LocalVariables.size() && i < MAX_GLOBAL_VARIABLES; ++i)
croom->interactionVariableValues[i] = thisroom.LocalVariables[i].Value; croom->interactionVariableValues[i] = _GP(thisroom).LocalVariables[i].Value;
// wipe the character cache when we change rooms // wipe the character cache when we change rooms
for (ff = 0; ff < _GP(game).numcharacters; ff++) { for (ff = 0; ff < _GP(game).numcharacters; ff++) {
@ -325,10 +325,10 @@ void unload_old_room() {
} }
for (ff = 0; ff < MAX_ROOM_HOTSPOTS; ff++) { for (ff = 0; ff < MAX_ROOM_HOTSPOTS; ff++) {
if (thisroom.Hotspots[ff].ScriptName.IsEmpty()) if (_GP(thisroom).Hotspots[ff].ScriptName.IsEmpty())
continue; continue;
ccRemoveExternalSymbol(thisroom.Hotspots[ff].ScriptName); ccRemoveExternalSymbol(_GP(thisroom).Hotspots[ff].ScriptName);
} }
croom_ptr_clear(); croom_ptr_clear();
@ -402,7 +402,7 @@ void convert_room_coordinates_to_data_res(RoomStruct *rstruc) {
extern int convert_16bit_bgr; extern int convert_16bit_bgr;
void update_letterbox_mode() { void update_letterbox_mode() {
const Size real_room_sz = Size(data_to_game_coord(thisroom.Width), data_to_game_coord(thisroom.Height)); const Size real_room_sz = Size(data_to_game_coord(_GP(thisroom).Width), data_to_game_coord(_GP(thisroom).Height));
const Rect game_frame = RectWH(_GP(game).GetGameRes()); const Rect game_frame = RectWH(_GP(game).GetGameRes());
Rect new_main_view = game_frame; Rect new_main_view = game_frame;
// In the original engine the letterbox feature only allowed viewports of // In the original engine the letterbox feature only allowed viewports of
@ -421,7 +421,7 @@ void update_letterbox_mode() {
// Automatically reset primary room viewport and camera to match the new room size // Automatically reset primary room viewport and camera to match the new room size
static void adjust_viewport_to_room() { static void adjust_viewport_to_room() {
const Size real_room_sz = Size(data_to_game_coord(thisroom.Width), data_to_game_coord(thisroom.Height)); const Size real_room_sz = Size(data_to_game_coord(_GP(thisroom).Width), data_to_game_coord(_GP(thisroom).Height));
const Rect main_view = _GP(play).GetMainViewport(); const Rect main_view = _GP(play).GetMainViewport();
Rect new_room_view = RectWH(Size::Clamp(real_room_sz, Size(1, 1), main_view.GetSize())); Rect new_room_view = RectWH(Size::Clamp(real_room_sz, Size(1, 1), main_view.GetSize()));
@ -475,43 +475,43 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
// load the room from disk // load the room from disk
our_eip = 200; our_eip = 200;
thisroom.GameID = NO_GAME_ID_IN_ROOM_FILE; _GP(thisroom).GameID = NO_GAME_ID_IN_ROOM_FILE;
load_room(room_filename, &thisroom, _GP(game).IsLegacyHiRes(), _GP(game).SpriteInfos); load_room(room_filename, &_GP(thisroom), _GP(game).IsLegacyHiRes(), _GP(game).SpriteInfos);
if ((thisroom.GameID != NO_GAME_ID_IN_ROOM_FILE) && if ((_GP(thisroom).GameID != NO_GAME_ID_IN_ROOM_FILE) &&
(thisroom.GameID != _GP(game).uniqueid)) { (_GP(thisroom).GameID != _GP(game).uniqueid)) {
quitprintf("!Unable to load '%s'. This room file is assigned to a different game.", room_filename.GetCStr()); quitprintf("!Unable to load '%s'. This room file is assigned to a different game.", room_filename.GetCStr());
} }
convert_room_coordinates_to_data_res(&thisroom); convert_room_coordinates_to_data_res(&_GP(thisroom));
update_polled_stuff_if_runtime(); update_polled_stuff_if_runtime();
our_eip = 201; our_eip = 201;
/* // apparently, doing this stops volume spiking between tracks /* // apparently, doing this stops volume spiking between tracks
if (thisroom.Options.StartupMusic>0) { if (_GP(thisroom).Options.StartupMusic>0) {
stopmusic(); stopmusic();
delay(100); delay(100);
}*/ }*/
_GP(play).room_width = thisroom.Width; _GP(play).room_width = _GP(thisroom).Width;
_GP(play).room_height = thisroom.Height; _GP(play).room_height = _GP(thisroom).Height;
_GP(play).anim_background_speed = thisroom.BgAnimSpeed; _GP(play).anim_background_speed = _GP(thisroom).BgAnimSpeed;
_GP(play).bg_anim_delay = _GP(play).anim_background_speed; _GP(play).bg_anim_delay = _GP(play).anim_background_speed;
// do the palette // do the palette
for (cc = 0; cc < 256; cc++) { for (cc = 0; cc < 256; cc++) {
if (_GP(game).paluses[cc] == PAL_BACKGROUND) if (_GP(game).paluses[cc] == PAL_BACKGROUND)
palette[cc] = thisroom.Palette[cc]; palette[cc] = _GP(thisroom).Palette[cc];
else { else {
// copy the gamewide colours into the room palette // copy the gamewide colours into the room palette
for (size_t i = 0; i < thisroom.BgFrameCount; ++i) for (size_t i = 0; i < _GP(thisroom).BgFrameCount; ++i)
thisroom.BgFrames[i].Palette[cc] = palette[cc]; _GP(thisroom).BgFrames[i].Palette[cc] = palette[cc];
} }
} }
for (size_t i = 0; i < thisroom.BgFrameCount; ++i) { for (size_t i = 0; i < _GP(thisroom).BgFrameCount; ++i) {
update_polled_stuff_if_runtime(); update_polled_stuff_if_runtime();
thisroom.BgFrames[i].Graphic = PrepareSpriteForUse(thisroom.BgFrames[i].Graphic, false); _GP(thisroom).BgFrames[i].Graphic = PrepareSpriteForUse(_GP(thisroom).BgFrames[i].Graphic, false);
} }
update_polled_stuff_if_runtime(); update_polled_stuff_if_runtime();
@ -528,13 +528,13 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
// walkable_areas_temp is used by the pathfinder to generate a // walkable_areas_temp is used by the pathfinder to generate a
// copy of the walkable areas - allocate it here to save time later // copy of the walkable areas - allocate it here to save time later
delete walkable_areas_temp; delete walkable_areas_temp;
walkable_areas_temp = BitmapHelper::CreateBitmap(thisroom.WalkAreaMask->GetWidth(), thisroom.WalkAreaMask->GetHeight(), 8); walkable_areas_temp = BitmapHelper::CreateBitmap(_GP(thisroom).WalkAreaMask->GetWidth(), _GP(thisroom).WalkAreaMask->GetHeight(), 8);
// Make a backup copy of the walkable areas prior to // Make a backup copy of the walkable areas prior to
// any RemoveWalkableArea commands // any RemoveWalkableArea commands
delete walkareabackup; delete walkareabackup;
// copy the walls screen // copy the walls screen
walkareabackup = BitmapHelper::CreateBitmapCopy(thisroom.WalkAreaMask.get()); walkareabackup = BitmapHelper::CreateBitmapCopy(_GP(thisroom).WalkAreaMask.get());
our_eip = 204; our_eip = 204;
update_polled_stuff_if_runtime(); update_polled_stuff_if_runtime();
@ -565,52 +565,52 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
// since we will overwrite the actual NewInteraction structs // since we will overwrite the actual NewInteraction structs
// (cos they have pointers and this might have been loaded from // (cos they have pointers and this might have been loaded from
// a save game) // a save game)
if (thisroom.EventHandlers == nullptr) { if (_GP(thisroom).EventHandlers == nullptr) {
// legacy interactions // legacy interactions
thisroom.Interaction->CopyTimesRun(croom->intrRoom); _GP(thisroom).Interaction->CopyTimesRun(croom->intrRoom);
for (cc = 0; cc < MAX_ROOM_HOTSPOTS; cc++) for (cc = 0; cc < MAX_ROOM_HOTSPOTS; cc++)
thisroom.Hotspots[cc].Interaction->CopyTimesRun(croom->intrHotspot[cc]); _GP(thisroom).Hotspots[cc].Interaction->CopyTimesRun(croom->intrHotspot[cc]);
for (cc = 0; cc < MAX_ROOM_OBJECTS; cc++) for (cc = 0; cc < MAX_ROOM_OBJECTS; cc++)
thisroom.Objects[cc].Interaction->CopyTimesRun(croom->intrObject[cc]); _GP(thisroom).Objects[cc].Interaction->CopyTimesRun(croom->intrObject[cc]);
for (cc = 0; cc < MAX_ROOM_REGIONS; cc++) for (cc = 0; cc < MAX_ROOM_REGIONS; cc++)
thisroom.Regions[cc].Interaction->CopyTimesRun(croom->intrRegion[cc]); _GP(thisroom).Regions[cc].Interaction->CopyTimesRun(croom->intrRegion[cc]);
} }
} }
if (croom->beenhere == 0) { if (croom->beenhere == 0) {
croom->numobj = thisroom.ObjectCount; croom->numobj = _GP(thisroom).ObjectCount;
croom->tsdatasize = 0; croom->tsdatasize = 0;
for (cc = 0; cc < croom->numobj; cc++) { for (cc = 0; cc < croom->numobj; cc++) {
croom->obj[cc].x = thisroom.Objects[cc].X; croom->obj[cc].x = _GP(thisroom).Objects[cc].X;
croom->obj[cc].y = thisroom.Objects[cc].Y; croom->obj[cc].y = _GP(thisroom).Objects[cc].Y;
croom->obj[cc].num = thisroom.Objects[cc].Sprite; croom->obj[cc].num = _GP(thisroom).Objects[cc].Sprite;
croom->obj[cc].on = thisroom.Objects[cc].IsOn; croom->obj[cc].on = _GP(thisroom).Objects[cc].IsOn;
croom->obj[cc].view = -1; croom->obj[cc].view = -1;
croom->obj[cc].loop = 0; croom->obj[cc].loop = 0;
croom->obj[cc].frame = 0; croom->obj[cc].frame = 0;
croom->obj[cc].wait = 0; croom->obj[cc].wait = 0;
croom->obj[cc].transparent = 0; croom->obj[cc].transparent = 0;
croom->obj[cc].moving = -1; croom->obj[cc].moving = -1;
croom->obj[cc].flags = thisroom.Objects[cc].Flags; croom->obj[cc].flags = _GP(thisroom).Objects[cc].Flags;
croom->obj[cc].baseline = -1; croom->obj[cc].baseline = -1;
croom->obj[cc].zoom = 100; croom->obj[cc].zoom = 100;
croom->obj[cc].last_width = 0; croom->obj[cc].last_width = 0;
croom->obj[cc].last_height = 0; croom->obj[cc].last_height = 0;
croom->obj[cc].blocking_width = 0; croom->obj[cc].blocking_width = 0;
croom->obj[cc].blocking_height = 0; croom->obj[cc].blocking_height = 0;
if (thisroom.Objects[cc].Baseline >= 0) if (_GP(thisroom).Objects[cc].Baseline >= 0)
// croom->obj[cc].baseoffs=thisroom.Objects.Baseline[cc]-thisroom.Objects[cc].y; // croom->obj[cc].baseoffs=_GP(thisroom).Objects.Baseline[cc]-_GP(thisroom).Objects[cc].y;
croom->obj[cc].baseline = thisroom.Objects[cc].Baseline; croom->obj[cc].baseline = _GP(thisroom).Objects[cc].Baseline;
} }
for (size_t i = 0; i < (size_t)MAX_WALK_BEHINDS; ++i) for (size_t i = 0; i < (size_t)MAX_WALK_BEHINDS; ++i)
croom->walkbehind_base[i] = thisroom.WalkBehinds[i].Baseline; croom->walkbehind_base[i] = _GP(thisroom).WalkBehinds[i].Baseline;
for (cc = 0; cc < MAX_FLAGS; cc++) croom->flagstates[cc] = 0; for (cc = 0; cc < MAX_FLAGS; cc++) croom->flagstates[cc] = 0;
/* // we copy these structs for the Score column to work /* // we copy these structs for the Score column to work
croom->misccond=thisroom.misccond; croom->misccond=_GP(thisroom).misccond;
for (cc=0;cc<MAX_ROOM_HOTSPOTS;cc++) for (cc=0;cc<MAX_ROOM_HOTSPOTS;cc++)
croom->hscond[cc]=thisroom.hscond[cc]; croom->hscond[cc]=_GP(thisroom).hscond[cc];
for (cc=0;cc<MAX_ROOM_OBJECTS;cc++) for (cc=0;cc<MAX_ROOM_OBJECTS;cc++)
croom->objcond[cc]=thisroom.objcond[cc];*/ croom->objcond[cc]=_GP(thisroom).objcond[cc];*/
for (cc = 0; cc < MAX_ROOM_HOTSPOTS; cc++) { for (cc = 0; cc < MAX_ROOM_HOTSPOTS; cc++) {
croom->hotspot_enabled[cc] = 1; croom->hotspot_enabled[cc] = 1;
@ -623,22 +623,22 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
in_new_room = 2; in_new_room = 2;
} else { } else {
// We have been here before // We have been here before
for (size_t i = 0; i < thisroom.LocalVariables.size() && i < (size_t)MAX_GLOBAL_VARIABLES; ++i) for (size_t i = 0; i < _GP(thisroom).LocalVariables.size() && i < (size_t)MAX_GLOBAL_VARIABLES; ++i)
thisroom.LocalVariables[i].Value = croom->interactionVariableValues[i]; _GP(thisroom).LocalVariables[i].Value = croom->interactionVariableValues[i];
} }
update_polled_stuff_if_runtime(); update_polled_stuff_if_runtime();
if (thisroom.EventHandlers == nullptr) { if (_GP(thisroom).EventHandlers == nullptr) {
// legacy interactions // legacy interactions
// copy interactions from room file into our temporary struct // copy interactions from room file into our temporary struct
croom->intrRoom = *thisroom.Interaction; croom->intrRoom = *_GP(thisroom).Interaction;
for (cc = 0; cc < MAX_ROOM_HOTSPOTS; cc++) for (cc = 0; cc < MAX_ROOM_HOTSPOTS; cc++)
croom->intrHotspot[cc] = *thisroom.Hotspots[cc].Interaction; croom->intrHotspot[cc] = *_GP(thisroom).Hotspots[cc].Interaction;
for (cc = 0; cc < MAX_ROOM_OBJECTS; cc++) for (cc = 0; cc < MAX_ROOM_OBJECTS; cc++)
croom->intrObject[cc] = *thisroom.Objects[cc].Interaction; croom->intrObject[cc] = *_GP(thisroom).Objects[cc].Interaction;
for (cc = 0; cc < MAX_ROOM_REGIONS; cc++) for (cc = 0; cc < MAX_ROOM_REGIONS; cc++)
croom->intrRegion[cc] = *thisroom.Regions[cc].Interaction; croom->intrRegion[cc] = *_GP(thisroom).Regions[cc].Interaction;
} }
objs = &croom->obj[0]; objs = &croom->obj[0];
@ -651,31 +651,31 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
for (cc = 0; cc < croom->numobj; cc++) { for (cc = 0; cc < croom->numobj; cc++) {
// export the object's script object // export the object's script object
if (thisroom.Objects[cc].ScriptName.IsEmpty()) if (_GP(thisroom).Objects[cc].ScriptName.IsEmpty())
continue; continue;
objectScriptObjNames[cc] = thisroom.Objects[cc].ScriptName; objectScriptObjNames[cc] = _GP(thisroom).Objects[cc].ScriptName;
ccAddExternalDynamicObject(objectScriptObjNames[cc], &scrObj[cc], &ccDynamicObject); ccAddExternalDynamicObject(objectScriptObjNames[cc], &scrObj[cc], &ccDynamicObject);
} }
for (cc = 0; cc < MAX_ROOM_HOTSPOTS; cc++) { for (cc = 0; cc < MAX_ROOM_HOTSPOTS; cc++) {
if (thisroom.Hotspots[cc].ScriptName.IsEmpty()) if (_GP(thisroom).Hotspots[cc].ScriptName.IsEmpty())
continue; continue;
ccAddExternalDynamicObject(thisroom.Hotspots[cc].ScriptName, &scrHotspot[cc], &ccDynamicHotspot); ccAddExternalDynamicObject(_GP(thisroom).Hotspots[cc].ScriptName, &scrHotspot[cc], &ccDynamicHotspot);
} }
our_eip = 206; our_eip = 206;
/* THIS IS DONE IN THE EDITOR NOW /* THIS IS DONE IN THE EDITOR NOW
thisroom.BgFrames.IsPaletteShared[0] = 1; _GP(thisroom).BgFrames.IsPaletteShared[0] = 1;
for (dd = 1; dd < thisroom.BgFrameCount; dd++) { for (dd = 1; dd < _GP(thisroom).BgFrameCount; dd++) {
if (memcmp (&thisroom.BgFrames.Palette[dd][0], &palette[0], sizeof(color) * 256) == 0) if (memcmp (&_GP(thisroom).BgFrames.Palette[dd][0], &palette[0], sizeof(color) * 256) == 0)
thisroom.BgFrames.IsPaletteShared[dd] = 1; _GP(thisroom).BgFrames.IsPaletteShared[dd] = 1;
else else
thisroom.BgFrames.IsPaletteShared[dd] = 0; _GP(thisroom).BgFrames.IsPaletteShared[dd] = 0;
} }
// only make the first frame shared if the last is // only make the first frame shared if the last is
if (thisroom.BgFrames.IsPaletteShared[thisroom.BgFrameCount - 1] == 0) if (_GP(thisroom).BgFrames.IsPaletteShared[_GP(thisroom).BgFrameCount - 1] == 0)
thisroom.BgFrames.IsPaletteShared[0] = 0;*/ _GP(thisroom).BgFrames.IsPaletteShared[0] = 0;*/
update_polled_stuff_if_runtime(); update_polled_stuff_if_runtime();
@ -725,7 +725,7 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
roominst = nullptr; roominst = nullptr;
if (debug_flags & DBG_NOSCRIPT) ; if (debug_flags & DBG_NOSCRIPT) ;
else if (thisroom.CompiledScript != nullptr) { else if (_GP(thisroom).CompiledScript != nullptr) {
compile_room_script(); compile_room_script();
if (croom->tsdatasize > 0) { if (croom->tsdatasize > 0) {
if (croom->tsdatasize != roominst->globaldatasize) if (croom->tsdatasize != roominst->globaldatasize)
@ -749,43 +749,43 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
if ((new_room_pos > 0) & (forchar != nullptr)) { if ((new_room_pos > 0) & (forchar != nullptr)) {
if (new_room_pos >= 4000) { if (new_room_pos >= 4000) {
_GP(play).entered_edge = 3; _GP(play).entered_edge = 3;
forchar->y = thisroom.Edges.Top + get_fixed_pixel_size(1); forchar->y = _GP(thisroom).Edges.Top + get_fixed_pixel_size(1);
forchar->x = new_room_pos % 1000; forchar->x = new_room_pos % 1000;
if (forchar->x == 0) forchar->x = thisroom.Width / 2; if (forchar->x == 0) forchar->x = _GP(thisroom).Width / 2;
if (forchar->x <= thisroom.Edges.Left) if (forchar->x <= _GP(thisroom).Edges.Left)
forchar->x = thisroom.Edges.Left + 3; forchar->x = _GP(thisroom).Edges.Left + 3;
if (forchar->x >= thisroom.Edges.Right) if (forchar->x >= _GP(thisroom).Edges.Right)
forchar->x = thisroom.Edges.Right - 3; forchar->x = _GP(thisroom).Edges.Right - 3;
forchar->loop = 0; forchar->loop = 0;
} else if (new_room_pos >= 3000) { } else if (new_room_pos >= 3000) {
_GP(play).entered_edge = 2; _GP(play).entered_edge = 2;
forchar->y = thisroom.Edges.Bottom - get_fixed_pixel_size(1); forchar->y = _GP(thisroom).Edges.Bottom - get_fixed_pixel_size(1);
forchar->x = new_room_pos % 1000; forchar->x = new_room_pos % 1000;
if (forchar->x == 0) forchar->x = thisroom.Width / 2; if (forchar->x == 0) forchar->x = _GP(thisroom).Width / 2;
if (forchar->x <= thisroom.Edges.Left) if (forchar->x <= _GP(thisroom).Edges.Left)
forchar->x = thisroom.Edges.Left + 3; forchar->x = _GP(thisroom).Edges.Left + 3;
if (forchar->x >= thisroom.Edges.Right) if (forchar->x >= _GP(thisroom).Edges.Right)
forchar->x = thisroom.Edges.Right - 3; forchar->x = _GP(thisroom).Edges.Right - 3;
forchar->loop = 3; forchar->loop = 3;
} else if (new_room_pos >= 2000) { } else if (new_room_pos >= 2000) {
_GP(play).entered_edge = 1; _GP(play).entered_edge = 1;
forchar->x = thisroom.Edges.Right - get_fixed_pixel_size(1); forchar->x = _GP(thisroom).Edges.Right - get_fixed_pixel_size(1);
forchar->y = new_room_pos % 1000; forchar->y = new_room_pos % 1000;
if (forchar->y == 0) forchar->y = thisroom.Height / 2; if (forchar->y == 0) forchar->y = _GP(thisroom).Height / 2;
if (forchar->y <= thisroom.Edges.Top) if (forchar->y <= _GP(thisroom).Edges.Top)
forchar->y = thisroom.Edges.Top + 3; forchar->y = _GP(thisroom).Edges.Top + 3;
if (forchar->y >= thisroom.Edges.Bottom) if (forchar->y >= _GP(thisroom).Edges.Bottom)
forchar->y = thisroom.Edges.Bottom - 3; forchar->y = _GP(thisroom).Edges.Bottom - 3;
forchar->loop = 1; forchar->loop = 1;
} else if (new_room_pos >= 1000) { } else if (new_room_pos >= 1000) {
_GP(play).entered_edge = 0; _GP(play).entered_edge = 0;
forchar->x = thisroom.Edges.Left + get_fixed_pixel_size(1); forchar->x = _GP(thisroom).Edges.Left + get_fixed_pixel_size(1);
forchar->y = new_room_pos % 1000; forchar->y = new_room_pos % 1000;
if (forchar->y == 0) forchar->y = thisroom.Height / 2; if (forchar->y == 0) forchar->y = _GP(thisroom).Height / 2;
if (forchar->y <= thisroom.Edges.Top) if (forchar->y <= _GP(thisroom).Edges.Top)
forchar->y = thisroom.Edges.Top + 3; forchar->y = _GP(thisroom).Edges.Top + 3;
if (forchar->y >= thisroom.Edges.Bottom) if (forchar->y >= _GP(thisroom).Edges.Bottom)
forchar->y = thisroom.Edges.Bottom - 3; forchar->y = _GP(thisroom).Edges.Bottom - 3;
forchar->loop = 2; forchar->loop = 2;
} }
// if starts on un-walkable area // if starts on un-walkable area
@ -802,11 +802,11 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
break; break;
} }
int nowhere = 0; int nowhere = 0;
if (tryleft > thisroom.Edges.Left) { if (tryleft > _GP(thisroom).Edges.Left) {
tryleft--; tryleft--;
nowhere++; nowhere++;
} }
if (tryright < thisroom.Edges.Right) { if (tryright < _GP(thisroom).Edges.Right) {
tryright++; tryright++;
nowhere++; nowhere++;
} }
@ -824,11 +824,11 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
break; break;
} }
int nowhere = 0; int nowhere = 0;
if (tryleft > thisroom.Edges.Top) { if (tryleft > _GP(thisroom).Edges.Top) {
tryleft--; tryleft--;
nowhere++; nowhere++;
} }
if (tryright < thisroom.Edges.Bottom) { if (tryright < _GP(thisroom).Edges.Bottom) {
tryright++; tryright++;
nowhere++; nowhere++;
} }
@ -841,21 +841,21 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
if (forchar != nullptr) { if (forchar != nullptr) {
_GP(play).entered_at_x = forchar->x; _GP(play).entered_at_x = forchar->x;
_GP(play).entered_at_y = forchar->y; _GP(play).entered_at_y = forchar->y;
if (forchar->x >= thisroom.Edges.Right) if (forchar->x >= _GP(thisroom).Edges.Right)
_GP(play).entered_edge = 1; _GP(play).entered_edge = 1;
else if (forchar->x <= thisroom.Edges.Left) else if (forchar->x <= _GP(thisroom).Edges.Left)
_GP(play).entered_edge = 0; _GP(play).entered_edge = 0;
else if (forchar->y >= thisroom.Edges.Bottom) else if (forchar->y >= _GP(thisroom).Edges.Bottom)
_GP(play).entered_edge = 2; _GP(play).entered_edge = 2;
else if (forchar->y <= thisroom.Edges.Top) else if (forchar->y <= _GP(thisroom).Edges.Top)
_GP(play).entered_edge = 3; _GP(play).entered_edge = 3;
} }
if (thisroom.Options.StartupMusic > 0) if (_GP(thisroom).Options.StartupMusic > 0)
PlayMusicResetQueue(thisroom.Options.StartupMusic); PlayMusicResetQueue(_GP(thisroom).Options.StartupMusic);
our_eip = 208; our_eip = 208;
if (forchar != nullptr) { if (forchar != nullptr) {
if (thisroom.Options.PlayerCharOff == 0) { if (_GP(thisroom).Options.PlayerCharOff == 0) {
forchar->on = 1; forchar->on = 1;
enable_cursor_mode(0); enable_cursor_mode(0);
} else { } else {
@ -867,8 +867,8 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
_GP(play).temporarily_turned_off_character = _GP(game).playercharacter; _GP(play).temporarily_turned_off_character = _GP(game).playercharacter;
} }
if (forchar->flags & CHF_FIXVIEW) ; if (forchar->flags & CHF_FIXVIEW) ;
else if (thisroom.Options.PlayerView == 0) forchar->view = forchar->defview; else if (_GP(thisroom).Options.PlayerView == 0) forchar->view = forchar->defview;
else forchar->view = thisroom.Options.PlayerView - 1; else forchar->view = _GP(thisroom).Options.PlayerView - 1;
forchar->frame = 0; // make him standing forchar->frame = 0; // make him standing
} }
color_map = nullptr; color_map = nullptr;
@ -1006,7 +1006,7 @@ void check_new_room() {
void compile_room_script() { void compile_room_script() {
ccError = 0; ccError = 0;
roominst = ccInstance::CreateFromScript(thisroom.CompiledScript); roominst = ccInstance::CreateFromScript(_GP(thisroom).CompiledScript);
if ((ccError != 0) || (roominst == nullptr)) { if ((ccError != 0) || (roominst == nullptr)) {
quitprintf("Unable to create local script: %s", ccErrorString.GetCStr()); quitprintf("Unable to create local script: %s", ccErrorString.GetCStr());
@ -1030,7 +1030,7 @@ void on_background_frame_change() {
invalidate_cached_walkbehinds(); invalidate_cached_walkbehinds();
// get the new frame's palette // get the new frame's palette
memcpy(palette, thisroom.BgFrames[_GP(play).bg_frame].Palette, sizeof(color) * 256); memcpy(palette, _GP(thisroom).BgFrames[_GP(play).bg_frame].Palette, sizeof(color) * 256);
// hi-colour, update the palette. It won't have an immediate effect // hi-colour, update the palette. It won't have an immediate effect
// but will be drawn properly when the screen fades in // but will be drawn properly when the screen fades in
@ -1041,7 +1041,7 @@ void on_background_frame_change() {
return; return;
// Don't update the palette if it hasn't changed // Don't update the palette if it hasn't changed
if (thisroom.BgFrames[_GP(play).bg_frame].IsPaletteShared) if (_GP(thisroom).BgFrames[_GP(play).bg_frame].IsPaletteShared)
return; return;
// 256-colours, tell it to update the palette (will actually be done as // 256-colours, tell it to update the palette (will actually be done as
@ -1057,11 +1057,11 @@ void croom_ptr_clear() {
AGS_INLINE int room_to_mask_coord(int coord) { AGS_INLINE int room_to_mask_coord(int coord) {
return coord * _GP(game).GetDataUpscaleMult() / thisroom.MaskResolution; return coord * _GP(game).GetDataUpscaleMult() / _GP(thisroom).MaskResolution;
} }
AGS_INLINE int mask_to_room_coord(int coord) { AGS_INLINE int mask_to_room_coord(int coord) {
return coord * thisroom.MaskResolution / _GP(game).GetDataUpscaleMult(); return coord * _GP(thisroom).MaskResolution / _GP(game).GetDataUpscaleMult();
} }
void convert_move_path_to_room_resolution(MoveList *ml) { void convert_move_path_to_room_resolution(MoveList *ml) {
@ -1074,7 +1074,7 @@ void convert_move_path_to_room_resolution(MoveList *ml) {
} }
} }
if (thisroom.MaskResolution == _GP(game).GetDataUpscaleMult()) if (_GP(thisroom).MaskResolution == _GP(game).GetDataUpscaleMult())
return; return;
ml->fromx = mask_to_room_coord(ml->fromx); ml->fromx = mask_to_room_coord(ml->fromx);

View file

@ -76,8 +76,6 @@ struct MoveList;
// Convert move path from room's mask resolution to room resolution // Convert move path from room's mask resolution to room resolution
void convert_move_path_to_room_resolution(MoveList *ml); void convert_move_path_to_room_resolution(MoveList *ml);
extern AGS::Shared::RoomStruct thisroom;
} // namespace AGS3 } // namespace AGS3
#endif #endif

View file

@ -38,7 +38,7 @@ namespace AGS3 {
using namespace AGS::Shared; using namespace AGS::Shared;
extern RoomStruct thisroom;
extern int displayed_room; extern int displayed_room;
extern RoomStatus *croom; extern RoomStatus *croom;
@ -50,16 +50,16 @@ void redo_walkable_areas() {
// since this is an 8-bit memory bitmap, we can just use direct // since this is an 8-bit memory bitmap, we can just use direct
// memory access // memory access
if ((!thisroom.WalkAreaMask->IsLinearBitmap()) || (thisroom.WalkAreaMask->GetColorDepth() != 8)) if ((!_GP(thisroom).WalkAreaMask->IsLinearBitmap()) || (_GP(thisroom).WalkAreaMask->GetColorDepth() != 8))
quit("Walkable areas bitmap not linear"); quit("Walkable areas bitmap not linear");
thisroom.WalkAreaMask->Blit(walkareabackup, 0, 0, 0, 0, thisroom.WalkAreaMask->GetWidth(), thisroom.WalkAreaMask->GetHeight()); _GP(thisroom).WalkAreaMask->Blit(walkareabackup, 0, 0, 0, 0, _GP(thisroom).WalkAreaMask->GetWidth(), _GP(thisroom).WalkAreaMask->GetHeight());
int hh, ww; int hh, ww;
for (hh = 0; hh < walkareabackup->GetHeight(); hh++) { for (hh = 0; hh < walkareabackup->GetHeight(); hh++) {
uint8_t *walls_scanline = thisroom.WalkAreaMask->GetScanLineForWriting(hh); uint8_t *walls_scanline = _GP(thisroom).WalkAreaMask->GetScanLineForWriting(hh);
for (ww = 0; ww < walkareabackup->GetWidth(); ww++) { for (ww = 0; ww < walkareabackup->GetWidth(); ww++) {
// if (_GP(play).walkable_areas_on[_getpixel(thisroom.WalkAreaMask,ww,hh)]==0) // if (_GP(play).walkable_areas_on[_getpixel(_GP(thisroom).WalkAreaMask,ww,hh)]==0)
if (_GP(play).walkable_areas_on[walls_scanline[ww]] == 0) if (_GP(play).walkable_areas_on[walls_scanline[ww]] == 0)
walls_scanline[ww] = 0; walls_scanline[ww] = 0;
} }
@ -68,7 +68,7 @@ void redo_walkable_areas() {
} }
int get_walkable_area_pixel(int x, int y) { int get_walkable_area_pixel(int x, int y) {
return thisroom.WalkAreaMask->GetPixel(room_to_mask_coord(x), room_to_mask_coord(y)); return _GP(thisroom).WalkAreaMask->GetPixel(room_to_mask_coord(x), room_to_mask_coord(y));
} }
int get_area_scaling(int onarea, int xx, int yy) { int get_area_scaling(int onarea, int xx, int yy) {
@ -78,29 +78,29 @@ int get_area_scaling(int onarea, int xx, int yy) {
yy = room_to_mask_coord(yy); yy = room_to_mask_coord(yy);
if ((onarea >= 0) && (onarea <= MAX_WALK_AREAS) && if ((onarea >= 0) && (onarea <= MAX_WALK_AREAS) &&
(thisroom.WalkAreas[onarea].ScalingNear != NOT_VECTOR_SCALED)) { (_GP(thisroom).WalkAreas[onarea].ScalingNear != NOT_VECTOR_SCALED)) {
// We have vector scaling! // We have vector scaling!
// In case the character is off the screen, limit the Y co-ordinate // In case the character is off the screen, limit the Y co-ordinate
// to within the area range (otherwise we get silly zoom levels // to within the area range (otherwise we get silly zoom levels
// that cause Out Of Memory crashes) // that cause Out Of Memory crashes)
if (yy > thisroom.WalkAreas[onarea].Bottom) if (yy > _GP(thisroom).WalkAreas[onarea].Bottom)
yy = thisroom.WalkAreas[onarea].Bottom; yy = _GP(thisroom).WalkAreas[onarea].Bottom;
if (yy < thisroom.WalkAreas[onarea].Top) if (yy < _GP(thisroom).WalkAreas[onarea].Top)
yy = thisroom.WalkAreas[onarea].Top; yy = _GP(thisroom).WalkAreas[onarea].Top;
// Work it all out without having to use floats // Work it all out without having to use floats
// Percent = ((y - top) * 100) / (areabottom - areatop) // Percent = ((y - top) * 100) / (areabottom - areatop)
// Zoom level = ((max - min) * Percent) / 100 // Zoom level = ((max - min) * Percent) / 100
if (thisroom.WalkAreas[onarea].Bottom != thisroom.WalkAreas[onarea].Top) { if (_GP(thisroom).WalkAreas[onarea].Bottom != _GP(thisroom).WalkAreas[onarea].Top) {
int percent = ((yy - thisroom.WalkAreas[onarea].Top) * 100) int percent = ((yy - _GP(thisroom).WalkAreas[onarea].Top) * 100)
/ (thisroom.WalkAreas[onarea].Bottom - thisroom.WalkAreas[onarea].Top); / (_GP(thisroom).WalkAreas[onarea].Bottom - _GP(thisroom).WalkAreas[onarea].Top);
zoom_level = ((thisroom.WalkAreas[onarea].ScalingNear - thisroom.WalkAreas[onarea].ScalingFar) * (percent)) / 100 + thisroom.WalkAreas[onarea].ScalingFar; zoom_level = ((_GP(thisroom).WalkAreas[onarea].ScalingNear - _GP(thisroom).WalkAreas[onarea].ScalingFar) * (percent)) / 100 + _GP(thisroom).WalkAreas[onarea].ScalingFar;
} else { } else {
// Special case for 1px tall walkable area: take bottom line scaling // Special case for 1px tall walkable area: take bottom line scaling
zoom_level = thisroom.WalkAreas[onarea].ScalingNear; zoom_level = _GP(thisroom).WalkAreas[onarea].ScalingNear;
} }
zoom_level += 100; zoom_level += 100;
} else if ((onarea >= 0) & (onarea <= MAX_WALK_AREAS)) } else if ((onarea >= 0) & (onarea <= MAX_WALK_AREAS))
zoom_level = thisroom.WalkAreas[onarea].ScalingFar + 100; zoom_level = _GP(thisroom).WalkAreas[onarea].ScalingFar + 100;
if (zoom_level == 0) if (zoom_level == 0)
zoom_level = 100; zoom_level = 100;
@ -146,7 +146,7 @@ int is_point_in_rect(int x, int y, int left, int top, int right, int bottom) {
Bitmap *prepare_walkable_areas(int sourceChar) { Bitmap *prepare_walkable_areas(int sourceChar) {
// copy the walkable areas to the temp bitmap // copy the walkable areas to the temp bitmap
walkable_areas_temp->Blit(thisroom.WalkAreaMask.get(), 0, 0, 0, 0, thisroom.WalkAreaMask->GetWidth(), thisroom.WalkAreaMask->GetHeight()); walkable_areas_temp->Blit(_GP(thisroom).WalkAreaMask.get(), 0, 0, 0, 0, _GP(thisroom).WalkAreaMask->GetWidth(), _GP(thisroom).WalkAreaMask->GetHeight());
// if the character who's moving doesn't Bitmap *, don't bother checking // if the character who's moving doesn't Bitmap *, don't bother checking
if (sourceChar < 0); if (sourceChar < 0);
else if (_GP(game).chars[sourceChar].flags & CHF_NOBLOCKING) else if (_GP(game).chars[sourceChar].flags & CHF_NOBLOCKING)
@ -210,12 +210,12 @@ int get_walkable_area_at_location(int xx, int yy) {
if (onarea < 0) { if (onarea < 0) {
// the character has walked off the edge of the screen, so stop them // the character has walked off the edge of the screen, so stop them
// jumping up to full size when leaving // jumping up to full size when leaving
if (xx >= thisroom.Width) if (xx >= _GP(thisroom).Width)
onarea = get_walkable_area_pixel(thisroom.Width - 1, yy); onarea = get_walkable_area_pixel(_GP(thisroom).Width - 1, yy);
else if (xx < 0) else if (xx < 0)
onarea = get_walkable_area_pixel(0, yy); onarea = get_walkable_area_pixel(0, yy);
else if (yy >= thisroom.Height) else if (yy >= _GP(thisroom).Height)
onarea = get_walkable_area_pixel(xx, thisroom.Height - 1); onarea = get_walkable_area_pixel(xx, _GP(thisroom).Height - 1);
else if (yy < 0) else if (yy < 0)
onarea = get_walkable_area_pixel(xx, 1); onarea = get_walkable_area_pixel(xx, 1);
} }

View file

@ -33,7 +33,7 @@ namespace AGS3 {
using namespace AGS::Shared; using namespace AGS::Shared;
using namespace AGS::Engine; using namespace AGS::Engine;
extern RoomStruct thisroom;
extern IGraphicsDriver *gfxDriver; extern IGraphicsDriver *gfxDriver;
@ -49,7 +49,7 @@ int walk_behind_baselines_changed = 0;
void update_walk_behind_images() { void update_walk_behind_images() {
int ee, rr; int ee, rr;
int bpp = (thisroom.BgFrames[_GP(play).bg_frame].Graphic->GetColorDepth() + 7) / 8; int bpp = (_GP(thisroom).BgFrames[_GP(play).bg_frame].Graphic->GetColorDepth() + 7) / 8;
Bitmap *wbbmp; Bitmap *wbbmp;
for (ee = 1; ee < MAX_WALK_BEHINDS; ee++) { for (ee = 1; ee < MAX_WALK_BEHINDS; ee++) {
update_polled_stuff_if_runtime(); update_polled_stuff_if_runtime();
@ -58,13 +58,13 @@ void update_walk_behind_images() {
wbbmp = BitmapHelper::CreateTransparentBitmap( wbbmp = BitmapHelper::CreateTransparentBitmap(
(walkBehindRight[ee] - walkBehindLeft[ee]) + 1, (walkBehindRight[ee] - walkBehindLeft[ee]) + 1,
(walkBehindBottom[ee] - walkBehindTop[ee]) + 1, (walkBehindBottom[ee] - walkBehindTop[ee]) + 1,
thisroom.BgFrames[_GP(play).bg_frame].Graphic->GetColorDepth()); _GP(thisroom).BgFrames[_GP(play).bg_frame].Graphic->GetColorDepth());
int yy, startX = walkBehindLeft[ee], startY = walkBehindTop[ee]; int yy, startX = walkBehindLeft[ee], startY = walkBehindTop[ee];
for (rr = startX; rr <= walkBehindRight[ee]; rr++) { for (rr = startX; rr <= walkBehindRight[ee]; rr++) {
for (yy = startY; yy <= walkBehindBottom[ee]; yy++) { for (yy = startY; yy <= walkBehindBottom[ee]; yy++) {
if (thisroom.WalkBehindMask->GetScanLine(yy)[rr] == ee) { if (_GP(thisroom).WalkBehindMask->GetScanLine(yy)[rr] == ee) {
for (int ii = 0; ii < bpp; ii++) for (int ii = 0; ii < bpp; ii++)
wbbmp->GetScanLineForWriting(yy - startY)[(rr - startX) * bpp + ii] = thisroom.BgFrames[_GP(play).bg_frame].Graphic->GetScanLine(yy)[rr * bpp + ii]; wbbmp->GetScanLineForWriting(yy - startY)[(rr - startX) * bpp + ii] = _GP(thisroom).BgFrames[_GP(play).bg_frame].Graphic->GetScanLine(yy)[rr * bpp + ii];
} }
} }
} }
@ -90,9 +90,9 @@ void recache_walk_behinds() {
free(walkBehindEndY); free(walkBehindEndY);
} }
walkBehindExists = (char *)malloc(thisroom.WalkBehindMask->GetWidth()); walkBehindExists = (char *)malloc(_GP(thisroom).WalkBehindMask->GetWidth());
walkBehindStartY = (int *)malloc(thisroom.WalkBehindMask->GetWidth() * sizeof(int)); walkBehindStartY = (int *)malloc(_GP(thisroom).WalkBehindMask->GetWidth() * sizeof(int));
walkBehindEndY = (int *)malloc(thisroom.WalkBehindMask->GetWidth() * sizeof(int)); walkBehindEndY = (int *)malloc(_GP(thisroom).WalkBehindMask->GetWidth() * sizeof(int));
noWalkBehindsAtAll = 1; noWalkBehindsAtAll = 1;
int ee, rr, tmm; int ee, rr, tmm;
@ -113,14 +113,14 @@ void recache_walk_behinds() {
// since this is an 8-bit memory bitmap, we can just use direct // since this is an 8-bit memory bitmap, we can just use direct
// memory access // memory access
if ((!thisroom.WalkBehindMask->IsLinearBitmap()) || (thisroom.WalkBehindMask->GetColorDepth() != 8)) if ((!_GP(thisroom).WalkBehindMask->IsLinearBitmap()) || (_GP(thisroom).WalkBehindMask->GetColorDepth() != 8))
quit("Walk behinds bitmap not linear"); quit("Walk behinds bitmap not linear");
for (ee = 0; ee < thisroom.WalkBehindMask->GetWidth(); ee++) { for (ee = 0; ee < _GP(thisroom).WalkBehindMask->GetWidth(); ee++) {
walkBehindExists[ee] = 0; walkBehindExists[ee] = 0;
for (rr = 0; rr < thisroom.WalkBehindMask->GetHeight(); rr++) { for (rr = 0; rr < _GP(thisroom).WalkBehindMask->GetHeight(); rr++) {
tmm = thisroom.WalkBehindMask->GetScanLine(rr)[ee]; tmm = _GP(thisroom).WalkBehindMask->GetScanLine(rr)[ee];
//tmm = _getpixel(thisroom.WalkBehindMask,ee,rr); //tmm = _getpixel(_GP(thisroom).WalkBehindMask,ee,rr);
if ((tmm >= 1) && (tmm < MAX_WALK_BEHINDS)) { if ((tmm >= 1) && (tmm < MAX_WALK_BEHINDS)) {
if (!walkBehindExists[ee]) { if (!walkBehindExists[ee]) {
walkBehindStartY[ee] = rr; walkBehindStartY[ee] = rr;

View file

@ -58,7 +58,7 @@ using namespace AGS::Engine;
extern char check_dynamic_sprites_at_exit; extern char check_dynamic_sprites_at_exit;
extern int displayed_room; extern int displayed_room;
extern RoomStruct thisroom;
extern char pexbuf[STD_BUFFER_SIZE]; extern char pexbuf[STD_BUFFER_SIZE];
@ -293,7 +293,7 @@ void debug_script_print(const String &msg, MessageType mt) {
String scriptname; String scriptname;
if (curinst->instanceof == gamescript) if (curinst->instanceof == gamescript)
scriptname = "G "; scriptname = "G ";
else if (curinst->instanceof == thisroom.CompiledScript) else if (curinst->instanceof == _GP(thisroom).CompiledScript)
scriptname = "R "; scriptname = "R ";
else if (curinst->instanceof == dialogScriptsScript) else if (curinst->instanceof == dialogScriptsScript)
scriptname = "D "; scriptname = "D ";

View file

@ -500,7 +500,7 @@ HSaveError DoAfterRestore(const PreservedParams &pp, const RestoredData &r_data)
_GP(play).gscript_timer = gstimer; _GP(play).gscript_timer = gstimer;
// restore the correct room volume (they might have modified // restore the correct room volume (they might have modified
// it with SetMusicVolume) // it with SetMusicVolume)
thisroom.Options.MusicVolume = r_data.RoomVolume; _GP(thisroom).Options.MusicVolume = r_data.RoomVolume;
Mouse::SetMoveLimit(Rect(oldx1, oldy1, oldx2, oldy2)); Mouse::SetMoveLimit(Rect(oldx1, oldy1, oldx2, oldy2));
@ -518,21 +518,21 @@ HSaveError DoAfterRestore(const PreservedParams &pp, const RestoredData &r_data)
if (displayed_room >= 0) { if (displayed_room >= 0) {
for (int i = 0; i < MAX_ROOM_BGFRAMES; ++i) { for (int i = 0; i < MAX_ROOM_BGFRAMES; ++i) {
if (r_data.RoomBkgScene[i]) { if (r_data.RoomBkgScene[i]) {
thisroom.BgFrames[i].Graphic = r_data.RoomBkgScene[i]; _GP(thisroom).BgFrames[i].Graphic = r_data.RoomBkgScene[i];
} }
} }
in_new_room = 3; // don't run "enters screen" events in_new_room = 3; // don't run "enters screen" events
// now that room has loaded, copy saved light levels in // now that room has loaded, copy saved light levels in
for (size_t i = 0; i < MAX_ROOM_REGIONS; ++i) { for (size_t i = 0; i < MAX_ROOM_REGIONS; ++i) {
thisroom.Regions[i].Light = r_data.RoomLightLevels[i]; _GP(thisroom).Regions[i].Light = r_data.RoomLightLevels[i];
thisroom.Regions[i].Tint = r_data.RoomTintLevels[i]; _GP(thisroom).Regions[i].Tint = r_data.RoomTintLevels[i];
} }
generate_light_table(); generate_light_table();
for (size_t i = 0; i < MAX_WALK_AREAS + 1; ++i) { for (size_t i = 0; i < MAX_WALK_AREAS + 1; ++i) {
thisroom.WalkAreas[i].ScalingFar = r_data.RoomZoomLevels1[i]; _GP(thisroom).WalkAreas[i].ScalingFar = r_data.RoomZoomLevels1[i];
thisroom.WalkAreas[i].ScalingNear = r_data.RoomZoomLevels2[i]; _GP(thisroom).WalkAreas[i].ScalingNear = r_data.RoomZoomLevels2[i];
} }
on_background_frame_change(); on_background_frame_change();
@ -735,8 +735,8 @@ void DoBeforeSave() {
save_room_data_segment(); save_room_data_segment();
// Update the saved interaction variable values // Update the saved interaction variable values
for (size_t i = 0; i < thisroom.LocalVariables.size() && i < (size_t)MAX_GLOBAL_VARIABLES; ++i) for (size_t i = 0; i < _GP(thisroom).LocalVariables.size() && i < (size_t)MAX_GLOBAL_VARIABLES; ++i)
croom->interactionVariableValues[i] = thisroom.LocalVariables[i].Value; croom->interactionVariableValues[i] = _GP(thisroom).LocalVariables[i].Value;
} }
} }

View file

@ -70,7 +70,7 @@ extern AnimatingGUIButton animbuts[MAX_ANIMATING_BUTTONS];
extern int numAnimButs; extern int numAnimButs;
extern ViewStruct *views; extern ViewStruct *views;
extern Bitmap *dynamicallyCreatedSurfaces[MAX_DYNAMIC_SURFACES]; extern Bitmap *dynamicallyCreatedSurfaces[MAX_DYNAMIC_SURFACES];
extern RoomStruct thisroom;
extern Bitmap *raw_saved_screen; extern Bitmap *raw_saved_screen;
extern MoveList *mls; extern MoveList *mls;
@ -900,7 +900,7 @@ HSaveError WriteThisRoom(PStream out) {
for (int i = 0; i < MAX_ROOM_BGFRAMES; ++i) { for (int i = 0; i < MAX_ROOM_BGFRAMES; ++i) {
out->WriteBool(_GP(play).raw_modified[i] != 0); out->WriteBool(_GP(play).raw_modified[i] != 0);
if (_GP(play).raw_modified[i]) if (_GP(play).raw_modified[i])
serialize_bitmap(thisroom.BgFrames[i].Graphic.get(), out.get()); serialize_bitmap(_GP(thisroom).BgFrames[i].Graphic.get(), out.get());
} }
out->WriteBool(raw_saved_screen != nullptr); out->WriteBool(raw_saved_screen != nullptr);
if (raw_saved_screen) if (raw_saved_screen)
@ -908,22 +908,22 @@ HSaveError WriteThisRoom(PStream out) {
// room region state // room region state
for (int i = 0; i < MAX_ROOM_REGIONS; ++i) { for (int i = 0; i < MAX_ROOM_REGIONS; ++i) {
out->WriteInt32(thisroom.Regions[i].Light); out->WriteInt32(_GP(thisroom).Regions[i].Light);
out->WriteInt32(thisroom.Regions[i].Tint); out->WriteInt32(_GP(thisroom).Regions[i].Tint);
} }
for (int i = 0; i < MAX_WALK_AREAS + 1; ++i) { for (int i = 0; i < MAX_WALK_AREAS + 1; ++i) {
out->WriteInt32(thisroom.WalkAreas[i].ScalingFar); out->WriteInt32(_GP(thisroom).WalkAreas[i].ScalingFar);
out->WriteInt32(thisroom.WalkAreas[i].ScalingNear); out->WriteInt32(_GP(thisroom).WalkAreas[i].ScalingNear);
} }
// room object movement paths cache // room object movement paths cache
out->WriteInt32(thisroom.ObjectCount + 1); out->WriteInt32(_GP(thisroom).ObjectCount + 1);
for (size_t i = 0; i < thisroom.ObjectCount + 1; ++i) { for (size_t i = 0; i < _GP(thisroom).ObjectCount + 1; ++i) {
mls[i].WriteToFile(out.get()); mls[i].WriteToFile(out.get());
} }
// room music volume // room music volume
out->WriteInt32(thisroom.Options.MusicVolume); out->WriteInt32(_GP(thisroom).Options.MusicVolume);
// persistent room's indicator // persistent room's indicator
const bool persist = displayed_room < MAX_ROOMS; const bool persist = displayed_room < MAX_ROOMS;

View file

@ -25,13 +25,12 @@
#include "ags/engine/debugging/debug_log.h" #include "ags/engine/debugging/debug_log.h"
#include "ags/shared/game/roomstruct.h" #include "ags/shared/game/roomstruct.h"
#include "ags/engine/game/viewport.h" #include "ags/engine/game/viewport.h"
#include "ags/globals.h"
namespace AGS3 { namespace AGS3 {
using namespace AGS::Shared; using namespace AGS::Shared;
extern RoomStruct thisroom;
void Camera::SetID(int id) { void Camera::SetID(int id) {
_id = id; _id = id;
} }
@ -45,7 +44,7 @@ const Rect &Camera::GetRect() const {
void Camera::SetSize(const Size cam_size) { void Camera::SetSize(const Size cam_size) {
// TODO: currently we don't support having camera larger than room background // TODO: currently we don't support having camera larger than room background
// (or rather - looking outside of the room background); look into this later // (or rather - looking outside of the room background); look into this later
const Size real_room_sz = Size(data_to_game_coord(thisroom.Width), data_to_game_coord(thisroom.Height)); const Size real_room_sz = Size(data_to_game_coord(_GP(thisroom).Width), data_to_game_coord(_GP(thisroom).Height));
Size real_size = Size::Clamp(cam_size, Size(1, 1), real_room_sz); Size real_size = Size::Clamp(cam_size, Size(1, 1), real_room_sz);
_position.SetWidth(real_size.Width); _position.SetWidth(real_size.Width);
@ -62,8 +61,8 @@ void Camera::SetSize(const Size cam_size) {
void Camera::SetAt(int x, int y) { void Camera::SetAt(int x, int y) {
int cw = _position.GetWidth(); int cw = _position.GetWidth();
int ch = _position.GetHeight(); int ch = _position.GetHeight();
int room_width = data_to_game_coord(thisroom.Width); int room_width = data_to_game_coord(_GP(thisroom).Width);
int room_height = data_to_game_coord(thisroom.Height); int room_height = data_to_game_coord(_GP(thisroom).Height);
x = Math::Clamp(x, 0, room_width - cw); x = Math::Clamp(x, 0, room_width - cw);
y = Math::Clamp(y, 0, room_height - ch); y = Math::Clamp(y, 0, room_height - ch);
_position.MoveTo(Point(x, y)); _position.MoveTo(Point(x, y));

View file

@ -81,7 +81,7 @@ extern int is_text_overlay;
extern int proper_exit, our_eip; extern int proper_exit, our_eip;
extern int displayed_room, starting_room, in_new_room, new_room_was; extern int displayed_room, starting_room, in_new_room, new_room_was;
extern RoomStruct thisroom;
extern int game_paused; extern int game_paused;
extern int getloctype_index; extern int getloctype_index;
extern int in_enters_screen, done_es_error; extern int in_enters_screen, done_es_error;
@ -560,13 +560,13 @@ static void check_room_edges(int numevents_was) {
if ((numevents == numevents_was) && if ((numevents == numevents_was) &&
((_GP(play).ground_level_areas_disabled & GLED_INTERACTION) == 0)) { ((_GP(play).ground_level_areas_disabled & GLED_INTERACTION) == 0)) {
if (playerchar->x <= thisroom.Edges.Left) if (playerchar->x <= _GP(thisroom).Edges.Left)
edgesActivated[0] = 1; edgesActivated[0] = 1;
else if (playerchar->x >= thisroom.Edges.Right) else if (playerchar->x >= _GP(thisroom).Edges.Right)
edgesActivated[1] = 1; edgesActivated[1] = 1;
if (playerchar->y >= thisroom.Edges.Bottom) if (playerchar->y >= _GP(thisroom).Edges.Bottom)
edgesActivated[2] = 1; edgesActivated[2] = 1;
else if (playerchar->y <= thisroom.Edges.Top) else if (playerchar->y <= _GP(thisroom).Edges.Top)
edgesActivated[3] = 1; edgesActivated[3] = 1;
if ((_GP(play).entered_edge >= 0) && (_GP(play).entered_edge <= 3)) { if ((_GP(play).entered_edge >= 0) && (_GP(play).entered_edge <= 3)) {
@ -679,9 +679,9 @@ static void game_loop_update_background_animation() {
else { else {
_GP(play).bg_anim_delay = _GP(play).anim_background_speed; _GP(play).bg_anim_delay = _GP(play).anim_background_speed;
_GP(play).bg_frame++; _GP(play).bg_frame++;
if ((size_t)_GP(play).bg_frame >= thisroom.BgFrameCount) if ((size_t)_GP(play).bg_frame >= _GP(thisroom).BgFrameCount)
_GP(play).bg_frame = 0; _GP(play).bg_frame = 0;
if (thisroom.BgFrameCount >= 2) { if (_GP(thisroom).BgFrameCount >= 2) {
// get the new frame's palette // get the new frame's palette
on_background_frame_change(); on_background_frame_change();
} }

View file

@ -56,7 +56,7 @@ using namespace AGS::Engine;
extern RoomStruct thisroom;
// used for non-saveable rooms, eg. intro // used for non-saveable rooms, eg. intro
extern int our_eip; extern int our_eip;
extern GameSetup usetup; extern GameSetup usetup;
@ -179,7 +179,7 @@ void quit_message_on_exit(const char *qmsg, String &alertis, QuitReason qreason)
void quit_release_data() { void quit_release_data() {
resetRoomStatuses(); resetRoomStatuses();
thisroom.Free(); _GP(thisroom).Free();
_GP(play).Free(); _GP(play).Free();
/* _CrtMemState memstart; /* _CrtMemState memstart;

View file

@ -57,7 +57,7 @@ using namespace AGS::Engine;
extern MoveList *mls; extern MoveList *mls;
extern RoomStatus *croom; extern RoomStatus *croom;
extern RoomStruct thisroom;
extern RoomObject *objs; extern RoomObject *objs;
extern ViewStruct *views; extern ViewStruct *views;
extern int our_eip; extern int our_eip;
@ -213,10 +213,10 @@ void update_shadow_areas() {
if (onwalkarea < 0); if (onwalkarea < 0);
else if (playerchar->flags & CHF_FIXVIEW); else if (playerchar->flags & CHF_FIXVIEW);
else { else {
onwalkarea = thisroom.WalkAreas[onwalkarea].Light; onwalkarea = _GP(thisroom).WalkAreas[onwalkarea].Light;
if (onwalkarea > 0) playerchar->view = onwalkarea - 1; if (onwalkarea > 0) playerchar->view = onwalkarea - 1;
else if (thisroom.Options.PlayerView == 0) playerchar->view = playerchar->defview; else if (_GP(thisroom).Options.PlayerView == 0) playerchar->view = playerchar->defview;
else playerchar->view = thisroom.Options.PlayerView - 1; else playerchar->view = _GP(thisroom).Options.PlayerView - 1;
} }
} }

View file

@ -105,7 +105,7 @@ void set_clip_to_channel(int chanid, SOUNDCLIP *clip) {
volatile bool _audio_doing_crossfade; volatile bool _audio_doing_crossfade;
extern GameSetup usetup; extern GameSetup usetup;
extern RoomStruct thisroom;
extern CharacterInfo *playerchar; extern CharacterInfo *playerchar;
extern volatile int switching_away_from_game; extern volatile int switching_away_from_game;
@ -788,7 +788,7 @@ void play_next_queued() {
int calculate_max_volume() { int calculate_max_volume() {
// quieter so that sounds can be heard better // quieter so that sounds can be heard better
int newvol = _GP(play).music_master_volume + ((int)thisroom.Options.MusicVolume) * LegacyRoomVolumeFactor; int newvol = _GP(play).music_master_volume + ((int)_GP(thisroom).Options.MusicVolume) * LegacyRoomVolumeFactor;
if (newvol > 255) newvol = 255; if (newvol > 255) newvol = 255;
if (newvol < 0) newvol = 0; if (newvol < 0) newvol = 0;

View file

@ -488,7 +488,7 @@ String GetScriptName(ccInstance *sci) {
return "Not in a script"; return "Not in a script";
else if (sci->instanceof == gamescript) else if (sci->instanceof == gamescript)
return "Global script"; return "Global script";
else if (sci->instanceof == thisroom.CompiledScript) else if (sci->instanceof == _GP(thisroom).CompiledScript)
return String::FromFormat("Room %d script", displayed_room); return String::FromFormat("Room %d script", displayed_room);
return "Unknown script"; return "Unknown script";
} }
@ -615,8 +615,8 @@ int get_nivalue(InteractionCommandList *nic, int idx, int parm) {
InteractionVariable *get_interaction_variable(int varindx) { InteractionVariable *get_interaction_variable(int varindx) {
if ((varindx >= LOCAL_VARIABLE_OFFSET) && ((size_t)varindx < LOCAL_VARIABLE_OFFSET + thisroom.LocalVariables.size())) if ((varindx >= LOCAL_VARIABLE_OFFSET) && ((size_t)varindx < LOCAL_VARIABLE_OFFSET + _GP(thisroom).LocalVariables.size()))
return &thisroom.LocalVariables[varindx - LOCAL_VARIABLE_OFFSET]; return &_GP(thisroom).LocalVariables[varindx - LOCAL_VARIABLE_OFFSET];
if ((varindx < 0) || (varindx >= numGlobalVars)) if ((varindx < 0) || (varindx >= numGlobalVars))
quit("!invalid interaction variable specified"); quit("!invalid interaction variable specified");
@ -630,9 +630,9 @@ InteractionVariable *FindGraphicalVariable(const char *varName) {
if (ags_stricmp(globalvars[ii].Name, varName) == 0) if (ags_stricmp(globalvars[ii].Name, varName) == 0)
return &globalvars[ii]; return &globalvars[ii];
} }
for (size_t i = 0; i < thisroom.LocalVariables.size(); ++i) { for (size_t i = 0; i < _GP(thisroom).LocalVariables.size(); ++i) {
if (ags_stricmp(thisroom.LocalVariables[i].Name, varName) == 0) if (ags_stricmp(_GP(thisroom).LocalVariables[i].Name, varName) == 0)
return &thisroom.LocalVariables[i]; return &_GP(thisroom).LocalVariables[i];
} }
return nullptr; return nullptr;
} }

View file

@ -23,6 +23,7 @@
#include "ags/globals.h" #include "ags/globals.h"
#include "ags/shared/ac/gamesetupstruct.h" #include "ags/shared/ac/gamesetupstruct.h"
#include "ags/shared/ac/spritecache.h" #include "ags/shared/ac/spritecache.h"
#include "ags/shared/game/roomstruct.h"
#include "ags/engine/ac/gamestate.h" #include "ags/engine/ac/gamestate.h"
#include "ags/engine/ac/roomstatus.h" #include "ags/engine/ac/roomstatus.h"
@ -38,6 +39,7 @@ Globals::Globals() {
_play = new GameState(); _play = new GameState();
_game = new GameSetupStruct(); _game = new GameSetupStruct();
_spriteset = new SpriteCache(_game->SpriteInfos); _spriteset = new SpriteCache(_game->SpriteInfos);
_thisroom = new AGS::Shared::RoomStruct();
_troom = new RoomStatus(); _troom = new RoomStatus();
} }
@ -46,6 +48,7 @@ Globals::~Globals() {
delete _game; delete _game;
delete _play; delete _play;
delete _spriteset; delete _spriteset;
delete _thisroom;
delete _troom; delete _troom;
} }

View file

@ -37,6 +37,7 @@ using Version = AGS::Shared::Version;
namespace AGS { namespace AGS {
namespace Shared { namespace Shared {
class Bitmap; class Bitmap;
class RoomStruct;
} // namespace Shared } // namespace Shared
} // namespace AGS } // namespace AGS
@ -78,10 +79,11 @@ public:
* @{ * @{
*/ */
GameSetupStruct *_game = nullptr; GameSetupStruct *_game;
GameState *_play = nullptr; GameState *_play;
SpriteCache *_spriteset = nullptr; SpriteCache *_spriteset;
RoomStatus *_troom = nullptr; // used for non-saveable rooms, eg. intro AGS::Shared::RoomStruct *_thisroom;
RoomStatus *_troom; // used for non-saveable rooms, eg. intro
/**@}*/ /**@}*/

View file

@ -88,7 +88,7 @@ using namespace AGS::Engine;
extern IGraphicsDriver *gfxDriver; extern IGraphicsDriver *gfxDriver;
extern int displayed_room; extern int displayed_room;
extern RoomStruct thisroom;
extern RoomStatus *croom; extern RoomStatus *croom;
@ -290,13 +290,13 @@ int IAGSEngine::GetCurrentRoom() {
return displayed_room; return displayed_room;
} }
int IAGSEngine::GetNumBackgrounds() { int IAGSEngine::GetNumBackgrounds() {
return thisroom.BgFrameCount; return _GP(thisroom).BgFrameCount;
} }
int IAGSEngine::GetCurrentBackground() { int IAGSEngine::GetCurrentBackground() {
return _GP(play).bg_frame; return _GP(play).bg_frame;
} }
BITMAP *IAGSEngine::GetBackgroundScene(int32 index) { BITMAP *IAGSEngine::GetBackgroundScene(int32 index) {
return (BITMAP *)thisroom.BgFrames[index].Graphic->GetAllegroBitmap(); return (BITMAP *)_GP(thisroom).BgFrames[index].Graphic->GetAllegroBitmap();
} }
void IAGSEngine::GetBitmapDimensions(BITMAP *bmp, int32 *width, int32 *height, int32 *coldepth) { void IAGSEngine::GetBitmapDimensions(BITMAP *bmp, int32 *width, int32 *height, int32 *coldepth) {
if (bmp == nullptr) if (bmp == nullptr)
@ -488,13 +488,13 @@ BITMAP *IAGSEngine::GetSpriteGraphic(int32 num) {
} }
BITMAP *IAGSEngine::GetRoomMask(int32 index) { BITMAP *IAGSEngine::GetRoomMask(int32 index) {
if (index == MASK_WALKABLE) if (index == MASK_WALKABLE)
return (BITMAP *)thisroom.WalkAreaMask->GetAllegroBitmap(); return (BITMAP *)_GP(thisroom).WalkAreaMask->GetAllegroBitmap();
else if (index == MASK_WALKBEHIND) else if (index == MASK_WALKBEHIND)
return (BITMAP *)thisroom.WalkBehindMask->GetAllegroBitmap(); return (BITMAP *)_GP(thisroom).WalkBehindMask->GetAllegroBitmap();
else if (index == MASK_HOTSPOT) else if (index == MASK_HOTSPOT)
return (BITMAP *)thisroom.HotspotMask->GetAllegroBitmap(); return (BITMAP *)_GP(thisroom).HotspotMask->GetAllegroBitmap();
else if (index == MASK_REGIONS) else if (index == MASK_REGIONS)
return (BITMAP *)thisroom.RegionMask->GetAllegroBitmap(); return (BITMAP *)_GP(thisroom).RegionMask->GetAllegroBitmap();
else else
quit("!IAGSEngine::GetRoomMask: invalid mask requested"); quit("!IAGSEngine::GetRoomMask: invalid mask requested");
return nullptr; return nullptr;