ULTIMA4: Further field renaming, gcc warning fixes

This commit is contained in:
Paul Gilbert 2020-03-22 11:32:44 -07:00 committed by Paul Gilbert
parent 6bb20c966c
commit a6f9fe3620
13 changed files with 120 additions and 120 deletions

View File

@ -75,38 +75,38 @@ void Response::release() {
}
ResponsePart::ResponsePart(const Common::String &value, const Common::String &arg, bool command) {
this->value = value;
this->arg = arg;
this->command = command;
_value = value;
_arg = arg;
_command = command;
}
ResponsePart::operator Common::String() const {
return value;
return _value;
}
bool ResponsePart::operator==(const ResponsePart &rhs) const {
return value == rhs.value;
return _value == rhs._value;
}
bool ResponsePart::isCommand() const {
return command;
return _command;
}
DynamicResponse::DynamicResponse(Response * (*generator)(const DynamicResponse *), const Common::String &param) :
Response(""), param(param) {
this->generator = generator;
currentResponse = NULL;
Response(""), _param(param) {
_generator = generator;
_currentResponse = NULL;
}
DynamicResponse::~DynamicResponse() {
if (currentResponse)
delete currentResponse;
if (_currentResponse)
delete _currentResponse;
}
const Std::vector<ResponsePart> &DynamicResponse::getParts() const {
// blah, must cast away constness
const_cast<DynamicResponse *>(this)->currentResponse = (*generator)(this);
return currentResponse->getParts();
const_cast<DynamicResponse *>(this)->_currentResponse = (*_generator)(this);
return _currentResponse->getParts();
}
/*

View File

@ -60,8 +60,8 @@ public:
bool isCommand() const;
private:
Common::String value, arg;
bool command;
Common::String _value, _arg;
bool _command;
};
/**
@ -100,13 +100,13 @@ public:
virtual const Std::vector<ResponsePart> &getParts() const;
const Common::String &getParam() const {
return param;
return _param;
}
private:
Response *(*generator)(const DynamicResponse *);
Response *currentResponse;
Common::String param;
Response *(*_generator)(const DynamicResponse *);
Response *_currentResponse;
Common::String _param;
};
/**

View File

@ -40,7 +40,7 @@ int eventTimerGranularity = 250;
extern bool quit;
bool EventHandler::_controllerDone = false;
bool EventHandler::_ended = false;
unsigned int TimedEventMgr::instances = 0;
unsigned int TimedEventMgr::_instances = 0;
EventHandler *EventHandler::_instance = NULL;
EventHandler *EventHandler::getInstance() {
@ -124,17 +124,17 @@ void EventHandler::setController(Controller *c) {
/* TimedEvent functions */
TimedEvent::TimedEvent(TimedEvent::Callback cb, int i, void *d) :
callback(cb),
data(d),
interval(i),
current(0) {
_callback(cb),
_data(d),
_interval(i),
_current(0) {
}
TimedEvent::Callback TimedEvent::getCallback() const {
return callback;
return _callback;
}
void *TimedEvent::getData() {
return data;
return _data;
}
/**
@ -142,9 +142,9 @@ void *TimedEvent::getData() {
* When (current >= interval), then it executes its callback function.
*/
void TimedEvent::tick() {
if (++current >= interval) {
(*callback)(data);
current = 0;
if (++_current >= _interval) {
(*_callback)(_data);
_current = 0;
}
}
@ -152,14 +152,14 @@ void TimedEvent::tick() {
* Returns true if the event queue is locked
*/
bool TimedEventMgr::isLocked() const {
return locked;
return _locked;
}
/**
* Adds a timed event to the event queue.
*/
void TimedEventMgr::add(TimedEvent::Callback callback, int interval, void *data) {
events.push_back(new TimedEvent(callback, interval, data));
void TimedEventMgr::add(TimedEvent::Callback theCallback, int interval, void *data) {
_events.push_back(new TimedEvent(theCallback, interval, data));
}
/**
@ -167,17 +167,17 @@ void TimedEventMgr::add(TimedEvent::Callback callback, int interval, void *data)
*/
TimedEventMgr::List::iterator TimedEventMgr::remove(List::iterator i) {
if (isLocked()) {
deferredRemovals.push_back(*i);
_deferredRemovals.push_back(*i);
return i;
} else {
delete *i;
return events.erase(i);
return _events.erase(i);
}
}
void TimedEventMgr::remove(TimedEvent *event) {
List::iterator i;
for (i = events.begin(); i != events.end(); i++) {
for (i = _events.begin(); i != _events.end(); i++) {
if ((*i) == event) {
remove(i);
break;
@ -185,10 +185,10 @@ void TimedEventMgr::remove(TimedEvent *event) {
}
}
void TimedEventMgr::remove(TimedEvent::Callback callback, void *data) {
void TimedEventMgr::remove(TimedEvent::Callback theCallback, void *data) {
List::iterator i;
for (i = events.begin(); i != events.end(); i++) {
if ((*i)->getCallback() == callback && (*i)->getData() == data) {
for (i = _events.begin(); i != _events.end(); i++) {
if ((*i)->getCallback() == theCallback && (*i)->getData() == data) {
remove(i);
break;
}
@ -202,24 +202,24 @@ void TimedEventMgr::tick() {
List::iterator i;
lock();
for (i = events.begin(); i != events.end(); i++)
for (i = _events.begin(); i != _events.end(); i++)
(*i)->tick();
unlock();
// Remove events that have been deferred for removal
for (i = deferredRemovals.begin(); i != deferredRemovals.end(); i++)
events.remove(*i);
for (i = _deferredRemovals.begin(); i != _deferredRemovals.end(); i++)
_events.remove(*i);
}
void TimedEventMgr::lock() {
locked = true;
_locked = true;
}
void TimedEventMgr::unlock() {
locked = false;
_locked = false;
}
void EventHandler::pushMouseAreaSet(MouseArea *mouseAreas) {
void EventHandler::pushMouseAreaSet(const MouseArea *mouseAreas) {
_mouseAreaSets.push_front(mouseAreas);
}
@ -231,7 +231,7 @@ void EventHandler::popMouseAreaSet() {
/**
* Get the currently active mouse area set off the top of the stack.
*/
MouseArea *EventHandler::getMouseAreaSet() const {
const MouseArea *EventHandler::getMouseAreaSet() const {
if (_mouseAreaSets.size())
return _mouseAreaSets.front();
else
@ -245,19 +245,19 @@ MouseArea *EventHandler::getMouseAreaSet() const {
* @param accepted_chars a Common::String characters to be accepted for input
*/
ReadStringController::ReadStringController(int maxlen, int screenX, int screenY, const Common::String &accepted_chars) {
this->maxlen = maxlen;
this->screenX = screenX;
this->screenY = screenY;
this->view = NULL;
this->accepted = accepted_chars;
_maxLen = maxlen;
_screenX = screenX;
_screenY = screenY;
_view = NULL;
_accepted = accepted_chars;
}
ReadStringController::ReadStringController(int maxlen, TextView *view, const Common::String &accepted_chars) {
this->maxlen = maxlen;
this->screenX = view->getCursorX();
this->screenY = view->getCursorY();
this->view = view;
this->accepted = accepted_chars;
_maxLen = maxlen;
_screenX = view->getCursorX();
_screenY = view->getCursorY();
_view = view;
_accepted = accepted_chars;
}
bool ReadStringController::keyPressed(int key) {
@ -268,7 +268,7 @@ bool ReadStringController::keyPressed(int key) {
#ifdef TODO
if (key < U4_ALT)
#endif
pos = accepted.findFirstOf(key);
pos = _accepted.findFirstOf(key);
if (pos != Common::String::npos) {
if (key == Common::KEYCODE_BACKSPACE) {
@ -276,28 +276,28 @@ bool ReadStringController::keyPressed(int key) {
/* remove the last character */
_value.erase(len - 1, 1);
if (view) {
view->textAt(screenX + len - 1, screenY, " ");
view->setCursorPos(screenX + len - 1, screenY, true);
if (_view) {
_view->textAt(_screenX + len - 1, _screenY, " ");
_view->setCursorPos(_screenX + len - 1, _screenY, true);
} else {
screenHideCursor();
screenTextAt(screenX + len - 1, screenY, " ");
screenSetCursorPos(screenX + len - 1, screenY);
screenTextAt(_screenX + len - 1, _screenY, " ");
screenSetCursorPos(_screenX + len - 1, _screenY);
screenShowCursor();
}
}
} else if (key == '\n' || key == '\r') {
doneWaiting();
} else if (len < maxlen) {
} else if (len < _maxLen) {
/* add a character to the end */
_value += key;
if (view) {
view->textAt(screenX + len, screenY, "%c", key);
if (_view) {
_view->textAt(_screenX + len, _screenY, "%c", key);
} else {
screenHideCursor();
screenTextAt(screenX + len, screenY, "%c", key);
screenSetCursorPos(screenX + len + 1, screenY);
screenTextAt(_screenX + len, _screenY, "%c", key);
screenSetCursorPos(_screenX + len + 1, _screenY);
g_context->col = len + 1;
screenShowCursor();
}
@ -342,7 +342,7 @@ int ReadIntController::getInt() const {
}
ReadChoiceController::ReadChoiceController(const Common::String &choices) {
this->choices = choices;
_choices = choices;
}
bool ReadChoiceController::keyPressed(int key) {
@ -353,7 +353,7 @@ bool ReadChoiceController::keyPressed(int key) {
_value = key;
if (choices.empty() || choices.findFirstOf(_value) < choices.size()) {
if (_choices.empty() || _choices.findFirstOf(_value) < _choices.size()) {
// If the value is printable, display it
if (!Common::isSpace(key))
screenMessage("%c", toupper(key));
@ -401,11 +401,11 @@ bool ReadDirController::keyPressed(int key) {
return false;
}
WaitController::WaitController(unsigned int c) : Controller(), cycles(c), current(0) {}
WaitController::WaitController(unsigned int c) : Controller(), _cycles(c), _current(0) {}
void WaitController::timerFired() {
if (++current >= cycles) {
current = 0;
if (++_current >= _cycles) {
_current = 0;
eventHandler->setControllerDone(true);
}
}
@ -419,7 +419,7 @@ void WaitController::wait() {
}
void WaitController::setCycles(int c) {
cycles = c;
_cycles = c;
}
} // End of namespace Ultima4

View File

@ -124,7 +124,7 @@ public:
KeyHandler *getKeyHandler();
private:
KeyHandler *handler;
KeyHandler *_handler;
};
/**
@ -145,9 +145,9 @@ public:
#endif
protected:
int maxlen, screenX, screenY;
TextView *view;
Common::String accepted;
int _maxLen, _screenX, _screenY;
TextView *_view;
Common::String _accepted;
};
/**
@ -173,7 +173,7 @@ public:
static char get(const Common::String &choices, EventHandler *eh = NULL);
protected:
Common::String choices;
Common::String _choices;
};
/**
@ -199,8 +199,8 @@ public:
void setCycles(int c);
private:
unsigned int cycles;
unsigned int current;
unsigned int _cycles;
unsigned int _current;
};
/**
@ -222,10 +222,10 @@ public:
/* Properties */
protected:
Callback callback;
void *data;
int interval;
int current;
Callback _callback;
void *_data;
int _interval;
int _current;
};
#if defined(IOS)
@ -257,10 +257,10 @@ public:
/* Member functions */
bool isLocked() const; /**< Returns true if the event list is locked (in use) */
void add(TimedEvent::Callback callback, int interval, void *data = NULL);
void add(TimedEvent::Callback theCallback, int interval, void *data = NULL);
List::iterator remove(List::iterator i);
void remove(TimedEvent *event);
void remove(TimedEvent::Callback callback, void *data = NULL);
void remove(TimedEvent::Callback theCallback, void *data = NULL);
void tick();
void stop();
void start();
@ -277,13 +277,13 @@ private:
/* Properties */
protected:
/* Static properties */
static unsigned int instances;
static unsigned int _instances;
void *id;
int baseInterval;
bool locked;
List events;
List deferredRemovals;
void *_id;
int _baseInterval;
bool _locked;
List _events;
List _deferredRemovals;
#if defined(IOS)
TimedManagerHelper *m_helper;
#endif
@ -296,7 +296,7 @@ typedef void(*updateScreenCallback)(void);
class EventHandler {
public:
/* Typedefs */
typedef Common::List<MouseArea *> MouseAreaList;
typedef Common::List<const MouseArea *> MouseAreaList;
/* Constructors */
EventHandler();
@ -338,10 +338,10 @@ public:
void setKeyHandler(KeyHandler kh);
/* Mouse area functions */
void pushMouseAreaSet(MouseArea *mouseAreas);
void pushMouseAreaSet(const MouseArea *mouseAreas);
void popMouseAreaSet();
MouseArea *getMouseAreaSet() const;
MouseArea *mouseAreaForPoint(int x, int y);
const MouseArea *getMouseAreaSet() const;
const MouseArea *mouseAreaForPoint(int x, int y);
protected:
static bool _controllerDone;

View File

@ -146,20 +146,20 @@ bool KeyHandler::operator==(Callback cb) const {
}
KeyHandlerController::KeyHandlerController(KeyHandler *handler) {
this->handler = handler;
this->_handler = handler;
}
KeyHandlerController::~KeyHandlerController() {
delete handler;
delete _handler;
}
bool KeyHandlerController::keyPressed(int key) {
ASSERT(handler != NULL, "key handler must be initialized");
return handler->handle(key);
ASSERT(_handler != NULL, "key handler must be initialized");
return _handler->handle(key);
}
KeyHandler *KeyHandlerController::getKeyHandler() {
return handler;
return _handler;
}
/**
@ -168,7 +168,7 @@ KeyHandler *KeyHandlerController::getKeyHandler() {
* will drive all of the timed events that this object
* controls.
*/
TimedEventMgr::TimedEventMgr(int i) : baseInterval(i) {
TimedEventMgr::TimedEventMgr(int i) : _baseInterval(i) {
/* start the SDL timer */
#ifdef TODO
if (instances == 0) {
@ -178,7 +178,7 @@ TimedEventMgr::TimedEventMgr(int i) : baseInterval(i) {
id = static_cast<void *>(SDL_AddTimer(i, &TimedEventMgr::callback, this));
#endif
instances++;
_instances++;
}
/**
@ -195,8 +195,8 @@ TimedEventMgr::~TimedEventMgr() {
if (instances == 1)
u4_SDL_QuitSubSystem(SDL_INIT_TIMER);
#endif
if (instances > 0)
instances--;
if (_instances > 0)
_instances--;
}
/**
@ -219,7 +219,7 @@ unsigned int TimedEventMgr::callback(unsigned int interval, void *param) {
* Re-initializes the timer manager to a new timer granularity
*/
void TimedEventMgr::reset(unsigned int interval) {
baseInterval = interval;
_baseInterval = interval;
stop();
start();
}
@ -250,7 +250,7 @@ static void handleMouseMotionEvent(const Common::Event &event) {
if (!settings._mouseOptions.enabled)
return;
MouseArea *area;
const MouseArea *area;
area = eventHandler->mouseAreaForPoint(event.mouse.x, event.mouse.y);
if (area)
screenSetMouseCursor(area->_cursor);
@ -283,7 +283,7 @@ static void handleMouseButtonDownEvent(const Common::Event &event, Controller *c
if (button > 2)
button = 0;
MouseArea *area = eventHandler->mouseAreaForPoint(event.mouse.x, event.mouse.y);
const MouseArea *area = eventHandler->mouseAreaForPoint(event.mouse.x, event.mouse.y);
if (!area || area->_command[button] == 0)
return;
controller->keyPressed(area->_command[button]);
@ -462,9 +462,9 @@ void EventHandler::setKeyHandler(KeyHandler kh) {
pushKeyHandler(kh);
}
MouseArea *EventHandler::mouseAreaForPoint(int x, int y) {
const MouseArea *EventHandler::mouseAreaForPoint(int x, int y) {
int i;
MouseArea *areas = getMouseAreaSet();
const MouseArea *areas = getMouseAreaSet();
if (!areas)
return NULL;

View File

@ -104,7 +104,7 @@ typedef enum {
DAEMON_ID = 49,
HYDRA_ID = 50,
DRAGON_ID = 51,
BALRON_ID = 52,
BALRON_ID = 52
} CreatureType;
typedef enum {

View File

@ -127,12 +127,12 @@ Context *g_context = NULL;
Debug gameDbg("debug/game.txt", "Game");
MouseArea mouseAreas[] = {
static const MouseArea mouseAreas[] = {
{ 3, { { 8, 8 }, { 8, 184 }, { 96, 96 } }, MC_WEST, { U4_ENTER, 0, U4_LEFT } },
{ 3, { { 8, 8 }, { 184, 8 }, { 96, 96 } }, MC_NORTH, { U4_ENTER, 0, U4_UP } },
{ 3, { { 184, 8 }, { 184, 184 }, { 96, 96 } }, MC_EAST, { U4_ENTER, 0, U4_RIGHT } },
{ 3, { { 8, 184 }, { 184, 184 }, { 96, 96 } }, MC_SOUTH, { U4_ENTER, 0, U4_DOWN } },
{ 0 }
{ 0, { { 0, 0 }, { 0, 0 }, { 0, 0 } }, MC_NORTH, { 0, 0, 0 } }
};
ReadPlayerController::ReadPlayerController() : ReadChoiceController("12345678 \033\n") {

View File

@ -71,10 +71,10 @@ public:
const Coords &getPrevCoords() const {
return _prevCoords;
}
const ObjectMovementBehavior getMovementBehavior() const {
ObjectMovementBehavior getMovementBehavior() const {
return _movementBehavior;
}
const Type getType() const {
Type getType() const {
return _objType;
}
bool hasFocus() const {

View File

@ -190,7 +190,7 @@ public:
ACTIVE_PLAYER_CHANGED,
MEMBER_JOINED,
PARTY_REVIVED,
INVENTORY_ADDED,
INVENTORY_ADDED
};
PartyEvent(Type type, PartyMember *partyMember) : _type(type), _player(partyMember) { }

View File

@ -1105,7 +1105,7 @@ static int screenPointInTriangle(int x, int y, int tx1, int ty1, int tx2, int ty
/**
* Determine if the given point is within a mouse area.
*/
int screenPointInMouseArea(int x, int y, MouseArea *area) {
int screenPointInMouseArea(int x, int y, const MouseArea *area) {
ASSERT(area->_nPoints == 2 || area->_nPoints == 3, "unsupported number of points in area: %d", area->_nPoints);
/* two points define a rectangle */

View File

@ -79,7 +79,7 @@ struct MouseArea {
int _nPoints;
struct {
int x, y;
} _point[4];
} _point[3];
MouseCursor _cursor;
int _command[3];
};
@ -153,7 +153,7 @@ void screenDisableCursor(void);
void screenSetCursorPos(int x, int y);
void screenSetMouseCursor(MouseCursor cursor);
int screenPointInMouseArea(int x, int y, MouseArea *area);
int screenPointInMouseArea(int x, int y, const MouseArea *area);
Image *screenScale(Image *src, int scale, int n, int filter);
Image *screenScaleDown(Image *src, int scale);

View File

@ -36,7 +36,7 @@ typedef Graphics::ManagedSurface *BackendSurface;
#define DARK_GRAY_HALO RGBA(14,15,16,255)
struct RGBA {
RGBA(int r, int g, int b, int a) : r(r), g(g), b(b), a(a) {}
RGBA(int red, int green, int blue, int alpha) : r(red), g(green), b(blue), a(alpha) {}
RGBA() : r(0), g(0), b(0), a(255) {}
unsigned int r, g, b, a;

View File

@ -57,7 +57,7 @@ public:
bool isVisualOnly() const {
return _visual; /**< Returns true for visual-only annotations */
}
const int getTTL() const {
int getTTL() const {
return _ttl; /**< Returns the number of turns the annotation has left to live */
}
bool isCoverUp() {