TRECISION: Fix some Coverity issues

This commit is contained in:
Strangerke 2021-06-05 23:51:39 +01:00
parent ed72a00f5d
commit f3dd3de43f
6 changed files with 24 additions and 6 deletions

View file

@ -30,6 +30,7 @@ Scheduler::Scheduler(TrecisionEngine *vm) : _vm(vm) {
_counter = 0;
_idleMsg = { MC_IDLE, 0, MP_DEFAULT, 0, 0, 0, 0 };
_msg = {MC_IDLE, 0, MP_DEFAULT, 0, 0, 0, 0};
}
Scheduler::~Scheduler() {

View file

@ -37,6 +37,16 @@
namespace Trecision {
void SScriptFrame::clear() {
_class = MC_IDLE;
_event = ME_MOUSEOPERATE;
_u8Param = 0;
_u16Param1 = _u16Param2 = 0;
_u32Param = 0;
_noWait = false;
}
void SScriptFrame::sendFrame(Scheduler *scheduler) {
scheduler->doEvent(_class, _event, MP_DEFAULT, _u16Param1, _u16Param2, _u8Param, _u32Param);
}

View file

@ -154,6 +154,7 @@ struct SScriptFrame {
bool _noWait;
void clear();
void sendFrame(Scheduler *scheduler);
bool isEmptyEvent() const { return _class == 0 && _event == 0; }
};
@ -168,7 +169,7 @@ struct SDText {
Common::String _text;
char _drawTextLines[MAXDTEXTLINES][MAXDTEXTCHARS];
void set(SDText org);
void set(SDText *org);
void set(Common::Rect rect, Common::Rect subtitleRect, uint16 textCol, uint16 shadowCol, const Common::String &text);
void draw(TrecisionEngine *vm, Graphics::Surface *externalSurface = nullptr);

View file

@ -436,7 +436,7 @@ void TextManager::drawText(StackText text) {
void TextManager::clearText() {
if (_oldString._text.empty() && !_curString._text.empty()) {
_oldString.set(_curString);
_oldString.set(&_curString);
_curString._text.clear();
_vm->_textStatus |= TEXT_DEL;

View file

@ -164,6 +164,13 @@ TrecisionEngine::TrecisionEngine(OSystem *syst, const ADGameDescription *desc) :
_textStatus = TEXT_OFF;
_cx = _cy = 0;
_textArea = nullptr;
_snake52 = {MC_IDLE, 0, MP_DEFAULT, 0, 0, 0, 0};
for (int i = 0; i < 50; ++i)
_scriptFrame[i].clear();
_scheduler = nullptr;
}
TrecisionEngine::~TrecisionEngine() {

View file

@ -79,9 +79,8 @@ uint16 TrecisionEngine::getKey() {
case Common::KEYCODE_F6:
return 0x3B + key - Common::KEYCODE_F1;
default:
if (ascii) {
if (ascii)
return ascii;
}
return 0;
}
@ -297,8 +296,8 @@ int TrecisionEngine::getRoomObjectIndex(uint16 objectId) {
/************************************************
* SDText
************************************************/
void SDText::set(SDText org) {
set(org._rect, org._subtitleRect, org._textCol, org._shadowCol, org._text);
void SDText::set(SDText *org) {
set(org->_rect, org->_subtitleRect, org->_textCol, org->_shadowCol, org->_text);
}
void SDText::set(Common::Rect rect, Common::Rect subtitleRect, uint16 textCol, uint16 shadowCol, const Common::String &text) {