CHEWY: Rename ged to barriers

Makes it a bit clearer to understand its purpose
This commit is contained in:
Filippos Karapetis 2022-05-22 17:27:11 +03:00
parent 5209a028cf
commit 2f00e8d279
8 changed files with 29 additions and 31 deletions

View File

@ -22,11 +22,11 @@
#include "common/file.h"
#include "chewy/chewy.h"
#include "chewy/globals.h"
#include "chewy/gedclass.h"
#include "chewy/barriers.h"
namespace Chewy {
int16 GedClass::getBarrierId(int16 x, int16 y) {
int16 Barriers::getBarrierId(int16 x, int16 y) {
const int16 width = _G(room)->_barriers->getWidth();
const byte *data = _G(room)->_barriers->getData();
const int16 result = getBarrierId(((y / 8) * width) + (x / 8), data + 6);
@ -34,7 +34,7 @@ int16 GedClass::getBarrierId(int16 x, int16 y) {
return result;
}
int16 GedClass::getBarrierId(int16 g_idx, const byte *buffer) {
int16 Barriers::getBarrierId(int16 g_idx, const byte *buffer) {
int16 idx_nr = buffer[g_idx];
switch (idx_nr) {

View File

@ -19,16 +19,14 @@
*
*/
#ifndef CHEWY_GEDCLASS_H
#define CHEWY_GEDCLASS_H
#include "chewy/ngstypes.h"
#ifndef CHEWY_BARRIERS_H
#define CHEWY_BARRIERS_H
namespace Chewy {
class GedClass {
class Barriers {
public:
GedClass() {}
Barriers() {}
int16 getBarrierId(int16 x, int16 y);
int16 getBarrierId(int16 g_idx, const byte *buffer);

View File

@ -29,7 +29,7 @@
#include "chewy/room.h"
#include "chewy/movclass.h"
#include "chewy/timer.h"
#include "chewy/gedclass.h"
#include "chewy/barriers.h"
#include "chewy/text.h"
#include "chewy/object.h"
#include "chewy/effect.h"
@ -183,7 +183,7 @@ public:
TafSeqInfo *_howard_taf = nullptr;
TafInfo *_chewy = nullptr;
int16 *_chewy_kor = nullptr;
GedClass *_ged = nullptr;
Barriers *_barriers = nullptr;
Text *_txt = nullptr;
Room *_room = nullptr;
Object *_obj = nullptr;

View File

@ -38,7 +38,7 @@ void standard_init() {
_G(in) = new InputMgr();
_G(fx) = new Effect();
_G(txt) = new Text();
_G(ged) = new GedClass();
_G(barriers) = new Barriers();
_G(room) = new Room();
_G(obj) = new Object(&_G(gameState));
_G(uhr) = new Timer(MAX_TIMER_OBJ, _G(ani_timer));
@ -230,7 +230,7 @@ void tidy() {
delete _G(uhr);
delete _G(obj);
delete _G(room);
delete _G(ged);
delete _G(barriers);
delete _G(txt);
delete _G(fx);
delete _G(in);
@ -244,7 +244,7 @@ void tidy() {
_G(uhr) = nullptr;
_G(obj) = nullptr;
_G(room) = nullptr;
_G(ged) = nullptr;
_G(barriers) = nullptr;
_G(txt) = nullptr;
_G(fx) = nullptr;
_G(in) = nullptr;

View File

@ -422,7 +422,7 @@ static void showWalkAreas() {
for (int y = 0, yp = ys; y < 200 / 8; ++y, yp += 8) {
for (int x = 0, xp = xs; x < 320 / 8; ++x, xp += 8) {
const int barrierId = _G(ged)->getBarrierId(xp, yp);
const int barrierId = _G(barriers)->getBarrierId(xp, yp);
if (barrierId) {
Common::Rect r(xp, yp, xp + 8, yp + 8);
@ -519,7 +519,7 @@ void setupScreen(SetupScreenMode mode) {
calc_auto_go();
if (_G(fx_blend)) {
const int16 paletteId = _G(ged)->getBarrierId(
const int16 paletteId = _G(barriers)->getBarrierId(
_G(spieler_vector)[P_CHEWY].Xypos[0] + _G(spieler_mi)[P_CHEWY].HotX,
_G(spieler_vector)[P_CHEWY].Xypos[1] + _G(spieler_mi)[P_CHEWY].HotY);
checkShadow(paletteId, 0);
@ -1695,7 +1695,7 @@ void calc_ausgang(int16 x, int16 y) {
ScrXy[0], ScrXy[1],
&_G(gameState).scrollx, &_G(gameState).scrolly);
const int16 paletteId = _G(ged)->getBarrierId(_G(spieler_vector)[P_CHEWY].Xypos[0] + _G(spieler_mi)[P_CHEWY].HotX,
const int16 paletteId = _G(barriers)->getBarrierId(_G(spieler_vector)[P_CHEWY].Xypos[0] + _G(spieler_mi)[P_CHEWY].HotX,
_G(spieler_vector)[P_CHEWY].Xypos[1] + _G(spieler_mi)[P_CHEWY].HotY);
checkShadow(paletteId, 0);
setPersonSpr(_G(Rdi)->AutoMov[_G(gameState).room_e_obj[nr].ExitMov]._sprNr, P_CHEWY);

View File

@ -2,13 +2,13 @@ MODULE := engines/chewy
MODULE_OBJS = \
atds.o \
barriers.o \
chewy.o \
cursor.o \
console.o \
detail.o \
effect.o \
events.o \
gedclass.o \
globals.o \
inits.o \
m_event.o \

View File

@ -211,7 +211,7 @@ void MovClass::calc_xy() {
int16 xvector = 0;
int16 yvector = 0;
if (!_G(ged)->getBarrierId(_gpkt->Dx, _gpkt->Dy)) {
if (!_G(barriers)->getBarrierId(_gpkt->Dx, _gpkt->Dy)) {
int16 ende = 0;
int16 count = 0;
int16 min_x = -1;
@ -255,7 +255,7 @@ void MovClass::calc_xy() {
for (int16 i = 0; i < anz; i++) {
if (x >= 0 && x < width * 8 &&
y >= 0 && y < height * 8) {
if (_G(ged)->getBarrierId(x, y)) {
if (_G(barriers)->getBarrierId(x, y)) {
int16 aksteps = abs(_gpkt->Dx - x);
aksteps += abs(_gpkt->Dy - y);
if (aksteps < min_steps) {
@ -334,13 +334,13 @@ short MovClass::calc_go(int16 src_feld, int16 *dst_feld) {
}
tmpz = 0;
if (!_G(ged)->getBarrierId(om.Xypos[0] + tmpx + tmpz,
if (!_G(barriers)->getBarrierId(om.Xypos[0] + tmpx + tmpz,
om.Xypos[1] + tmpy + tmpz)) {
if (!_G(ged)->getBarrierId(om.Xypos[0] + tmpx + tmpz,
if (!_G(barriers)->getBarrierId(om.Xypos[0] + tmpx + tmpz,
om.Xypos[1] + tmpz)) {
if (!_G(ged)->getBarrierId(om.Xypos[0] + tmpz,
if (!_G(barriers)->getBarrierId(om.Xypos[0] + tmpz,
om.Xypos[1] + tmpy + tmpz)) {
abbruch = MOV_UNPASSABLE;
@ -433,12 +433,12 @@ void MovClass::get_mov_line() {
while (!ende) {
int16 tmp_feld = start_feld + count * count_vect;
if (_G(ged)->getBarrierId(tmp_feld, data + 6)) {
if (_G(barriers)->getBarrierId(tmp_feld, data + 6)) {
int16 abbruch = 0;
int16 vector = 0;
while ((tmp_feld % width) < (width - 1) && !abbruch)
{
if (_G(ged)->getBarrierId(tmp_feld + vector, data + 6)) {
if (_G(barriers)->getBarrierId(tmp_feld + vector, data + 6)) {
tmp_feld += vector;
if (buffer[tmp_feld] == MOV_LINE_IDX) {
ak_steps = abs((tmp_feld % width) - (start_feld % width));
@ -459,7 +459,7 @@ void MovClass::get_mov_line() {
vector = LEFT_VECT;
abbruch = 0;
while ((tmp_feld % width) > 0 && !abbruch) {
if (_G(ged)->getBarrierId(tmp_feld + vector, data + 6)) {
if (_G(barriers)->getBarrierId(tmp_feld + vector, data + 6)) {
tmp_feld += vector;
if (buffer[tmp_feld] == MOV_LINE_IDX) {
ak_steps = abs((tmp_feld % width) - (start_feld % width));

View File

@ -323,7 +323,7 @@ void setPersonPos(int16 x, int16 y, int16 personNr, int16 direction) {
int16 y1 = _G(spieler_vector)[personNr].Xypos[1] - _G(gameState).scrolly;
_G(atds)->set_split_win(tmpNr, x1, y1);
if (!_G(flags).ExitMov && personNr == P_CHEWY) {
const int16 paletteId = _G(ged)->getBarrierId(x + _G(spieler_mi)[personNr].HotX, y + _G(spieler_mi)[personNr].HotY);
const int16 paletteId = _G(barriers)->getBarrierId(x + _G(spieler_mi)[personNr].HotX, y + _G(spieler_mi)[personNr].HotY);
checkShadow(paletteId, 1);
}
}
@ -772,13 +772,13 @@ void mov_objekt(ObjMov *om, MovInfo *mi) {
}
if (!mi->Mode) {
if (!(u_index = _G(ged)->getBarrierId(om->Xypos[0] + mi->HotX + tmpx,
if (!(u_index = _G(barriers)->getBarrierId(om->Xypos[0] + mi->HotX + tmpx,
om->Xypos[1] + mi->HotY + tmpy))) {
if (!(u_index = _G(ged)->getBarrierId(om->Xypos[0] + mi->HotX + tmpx,
if (!(u_index = _G(barriers)->getBarrierId(om->Xypos[0] + mi->HotX + tmpx,
om->Xypos[1] + mi->HotY))) {
if (!(u_index = _G(ged)->getBarrierId(om->Xypos[0] + mi->HotX,
if (!(u_index = _G(barriers)->getBarrierId(om->Xypos[0] + mi->HotX,
om->Xypos[1] + mi->HotY + tmpy))) {
om->Count = 0;
} else {
@ -881,7 +881,7 @@ void mov_objekt(ObjMov *om, MovInfo *mi) {
om->Xypos[1] += tmpy;
om->Xypos[2] += tmpz;
if (mi->Id == CHEWY_OBJ) {
u_index = _G(ged)->getBarrierId(om->Xypos[0] + mi->HotX,
u_index = _G(barriers)->getBarrierId(om->Xypos[0] + mi->HotX,
om->Xypos[1] + mi->HotY);
checkShadow(u_index, 1);
}