PRIVATE: clang-formatted all the code

This commit is contained in:
neuromancer 2021-06-20 09:01:33 +02:00 committed by Eugene Sandulenko
parent 252ad4cb00
commit 458df46dc9
6 changed files with 209 additions and 229 deletions

View File

@ -43,13 +43,13 @@
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
// THIS SOFTWARE.
#include "common/str.h"
#include "common/debug.h"
#include "common/hash-ptr.h"
#include "common/str.h"
#include "private/grammar.h"
#include "private/tokens.h"
#include "private/private.h"
#include "private/tokens.h"
namespace Private {
@ -101,13 +101,13 @@ namespace Gen {
/* pop and return top elem from stack */
Datum pop() {
assert (!(g_vm->_stackp <= g_vm->_stack));
assert(!(g_vm->_stackp <= g_vm->_stack));
return *--g_vm->_stackp;
}
/* push d onto stack */
int push(const Datum &d) {
assert (!(g_vm->_stackp >= &g_vm->_stack[NSTACK]));
assert(!(g_vm->_stackp >= &g_vm->_stack[NSTACK]));
*g_vm->_stackp++ = d;
return 0;
}
@ -152,7 +152,7 @@ int funcpush() {
debugC(1, kPrivateDebugCode, "executing %s with %d params", s.u.str, n.u.val);
for (int i = 0; i < n.u.val; i++) {
Datum arg = pop();
args.insert(args.begin(), arg) ;
args.insert(args.begin(), arg);
}
call(s.u.str, args);
@ -165,11 +165,11 @@ int eval() {
if (d.u.sym->type == NUM) {
d.type = NUM;
d.u.val = d.u.sym->u.val;
debugC(1, kPrivateDebugCode, "eval NUM returned %d", d.u.val );
debugC(1, kPrivateDebugCode, "eval NUM returned %d", d.u.val);
} else if (d.u.sym->type == STRING) {
d.type = STRING;
d.u.str = d.u.sym->u.str;
debugC(1, kPrivateDebugCode, "eval STR returned %s", d.u.str );
debugC(1, kPrivateDebugCode, "eval STR returned %s", d.u.str);
} else if (d.u.sym->type == RECT) {
d.type = RECT;
d.u.rect = d.u.sym->u.rect;
@ -371,16 +371,16 @@ int ne() {
Inst *code(const Inst &f) {
//debugC(1, kPrivateDebugCode, "pushing code at %x", progp);
Inst *oprogp = g_vm->_progp;
assert (!(g_vm->_progp >= &g_vm->_prog[NPROG]));
assert(!(g_vm->_progp >= &g_vm->_prog[NPROG]));
*g_vm->_progp++ = f;
return oprogp;
}
int ifcode() {
Inst *savepc = g_vm->_pc; /* then part */
Inst *savepc = g_vm->_pc; /* then part */
debugC(1, kPrivateDebugCode, "ifcode: evaluating condition");
execute(savepc+3); /* condition */
execute(savepc + 3); /* condition */
Datum d = pop();
debugC(1, kPrivateDebugCode, "ifcode: selecting branch");
@ -394,12 +394,12 @@ int ifcode() {
if (d.u.val) {
debugC(1, kPrivateDebugCode, "ifcode: true branch");
execute(*((Inst **)(savepc)));
} else if (*((Inst **)(savepc+1))) { /* else part? */
} else if (*((Inst **)(savepc + 1))) { /* else part? */
debugC(1, kPrivateDebugCode, "ifcode: false branch");
execute(*((Inst **)(savepc+1)));
execute(*((Inst **)(savepc + 1)));
}
debugC(1, kPrivateDebugCode, "ifcode finished");
g_vm->_pc = *((Inst **)(savepc+2)); /* next stmt */
g_vm->_pc = *((Inst **)(savepc + 2)); /* next stmt */
return 0;
}
@ -420,7 +420,7 @@ int fail() {
/* run the machine */
void execute(Inst *p) {
for (g_vm->_pc = p; *(g_vm->_pc) != STOP; ) {
for (g_vm->_pc = p; *(g_vm->_pc) != STOP;) {
(*(*(g_vm->_pc++)))();
}
}

View File

@ -27,15 +27,15 @@ namespace Private {
Decompiler::Decompiler(char *buf, uint32 fileSize, bool mac) {
Common::Array<unsigned char> array;
Common::Array<unsigned char> array;
uint32 i = 0;
while (i < fileSize) {
array.push_back(buf[i]);
i++;
}
Common::String firstBytes((const char *) array.begin(), (const char *) array.begin() + kHeader.size());
Common::String firstBytes((const char *)array.begin(), (const char *)array.begin() + kHeader.size());
if (firstBytes != kHeader) {
debug("Not a precompiled game matrix");
_result = Common::String(buf);
@ -47,22 +47,23 @@ Decompiler::Decompiler(char *buf, uint32 fileSize, bool mac) {
void Decompiler::decompile(Common::Array<unsigned char> &buffer, bool mac) {
Common::Array<unsigned char>::iterator it = buffer.begin();
Common::String ss;
bool inDefineRects = false;
for (it += kHeader.size() ; it != buffer.end() ; ) {
for (it += kHeader.size(); it != buffer.end();) {
unsigned char byte = *it++;
if (byte == kCodeString) {
unsigned char len = *it++;
Common::String s((const char *)it,(const char *)it+len);
Common::String s((const char *)it, (const char *)it + len);
it += len;
ss += Common::String::format("\"%s\"", s.c_str());
ss += Common::String::format("\"%s\"", s.c_str());
} else if (byte == kCodeShortLiteral || byte == kCodeShortId) {
unsigned char b1 = *it++;
unsigned char b2 = *it++;
unsigned int number = mac ? b2 + (b1 << 8) : b1 + (b2 << 8);
if (byte == kCodeShortId) ss += "k";
ss += Common::String::format("%d", number);
if (byte == kCodeShortId)
ss += "k";
ss += Common::String::format("%d", number);
} else if (byte == kCodeRect && inDefineRects) {
ss += "RECT"; // override CRect
} else if (byte <= kCodeShortId && strlen(kCodeTable[byte]) > 0) {
@ -84,4 +85,4 @@ Common::String Decompiler::getResult() const {
return _result;
}
}
} // namespace Private

View File

@ -25,8 +25,8 @@
#define PRIVATE_DECOMPILER_H
#include "common/array.h"
#include "common/str.h"
#include "common/debug.h"
#include "common/str.h"
namespace Private {
@ -39,99 +39,98 @@ const unsigned char kCodeRect = 0x2e;
const unsigned char kCodeRects = 0x4f;
const unsigned char kCodeShortId = 0x50;
const static char *kCodeTable[] = {"", //
"", // 0x01 (string)
"", // 0x02 (short literal)
" {\n", // 0x03
"}\n", // 0x04
"(", // 0x05
")", // 0x06
"", //
"", //
"", //
",", // 0x0a
"", //
"%", // 0x0c
"", //
";\n", // 0x0e
"!", // 0x0f
"-", // 0x10
"+", // 0x11
"=", // 0x12
">", // 0x13
"<", // 0x14
"if ", // 0x15
"else ", // 0x16
"Exit", // 0x17
"goto ", // 0x18
"Mask", // 0x19
"MaskDrawn", // 0x1a
"Movie", // 0x1b
"Transition", // 0x1c
"ThumbnailMovie", // 0x1d
"BustMovie", // 0x1e
"ViewScreen", // 0x1f
"VSPicture", // 0x20
"Bitmap", // 0x21
"Timer", // 0x22
"SoundArea", // 0x23
"Sound", // 0x24
"SoundEffect", // 0x25
"SyncSound", // 0x26
"LoopedSound", // 0x27
"NoStopSounds", // 0x28
"Resume", // 0x29
"Inventory", // 0x2a
"SetFlag", // 0x2b
"ChgMode", // 0x2c
"PoliceBust", // 0x2d
"CRect", // 0x2e overridden with "RECT" if in "define rects" block
"", //
"Random", // 0x30
"SafeDigit", // 0x31
"LoseInventory", // 0x32
"", //
"PaperShuffleSound", // 0x34
"Quit", // 0x35
"DossierAdd", // 0x36
"DossierBitmap", // 0x37
"DossierPrevSuspect", // 0x38
"DossierNextSuspect", // 0x39
"DossierChgSheet", // 0x3a
"DiaryLocList", // 0x3b
"DiaryPage", // 0x3c
"DiaryInvList", // 0x3d
"DiaryPageTurn", // 0x3e
"DiaryGoLoc", // 0x3f
"SaveGame", // 0x40
"LoadGame", // 0x41
"RestartGame", // 0x42
"AskSave", // 0x43
"SetModifiedFlag", // 0x44
"PhoneClip", // 0x45
"PoliceClip", // 0x46
"AMRadioClip", // 0x47
"\nsetting ", // 0x48
"debug ", // 0x49
"\ndefine ", // 0x4a
"", //
"variables", // 0x4c
"", //
"", //
"rects", // 0x4f
""
}; // 0x50 (short id)
const static char *kCodeTable[] = {"", //
"", // 0x01 (string)
"", // 0x02 (short literal)
" {\n", // 0x03
"}\n", // 0x04
"(", // 0x05
")", // 0x06
"", //
"", //
"", //
",", // 0x0a
"", //
"%", // 0x0c
"", //
";\n", // 0x0e
"!", // 0x0f
"-", // 0x10
"+", // 0x11
"=", // 0x12
">", // 0x13
"<", // 0x14
"if ", // 0x15
"else ", // 0x16
"Exit", // 0x17
"goto ", // 0x18
"Mask", // 0x19
"MaskDrawn", // 0x1a
"Movie", // 0x1b
"Transition", // 0x1c
"ThumbnailMovie", // 0x1d
"BustMovie", // 0x1e
"ViewScreen", // 0x1f
"VSPicture", // 0x20
"Bitmap", // 0x21
"Timer", // 0x22
"SoundArea", // 0x23
"Sound", // 0x24
"SoundEffect", // 0x25
"SyncSound", // 0x26
"LoopedSound", // 0x27
"NoStopSounds", // 0x28
"Resume", // 0x29
"Inventory", // 0x2a
"SetFlag", // 0x2b
"ChgMode", // 0x2c
"PoliceBust", // 0x2d
"CRect", // 0x2e overridden with "RECT" if in "define rects" block
"", //
"Random", // 0x30
"SafeDigit", // 0x31
"LoseInventory", // 0x32
"", //
"PaperShuffleSound", // 0x34
"Quit", // 0x35
"DossierAdd", // 0x36
"DossierBitmap", // 0x37
"DossierPrevSuspect", // 0x38
"DossierNextSuspect", // 0x39
"DossierChgSheet", // 0x3a
"DiaryLocList", // 0x3b
"DiaryPage", // 0x3c
"DiaryInvList", // 0x3d
"DiaryPageTurn", // 0x3e
"DiaryGoLoc", // 0x3f
"SaveGame", // 0x40
"LoadGame", // 0x41
"RestartGame", // 0x42
"AskSave", // 0x43
"SetModifiedFlag", // 0x44
"PhoneClip", // 0x45
"PoliceClip", // 0x46
"AMRadioClip", // 0x47
"\nsetting ", // 0x48
"debug ", // 0x49
"\ndefine ", // 0x4a
"", //
"variables", // 0x4c
"", //
"", //
"rects", // 0x4f
""}; // 0x50 (short id)
class Decompiler {
public:
Decompiler(char *buf, uint32 fileSize, bool mac = false);
Common::String getResult() const;
private:
void decompile(Common::Array<unsigned char> &buffer, bool mac);
Common::String _result;
};
}
} // namespace Private
#endif

View File

@ -21,18 +21,18 @@
*/
#include "common/str.h"
#include "common/timer.h"
#include "common/system.h"
#include "common/timer.h"
#include "private/grammar.h"
#include "private/tokens.h"
#include "private/private.h"
#include "private/tokens.h"
namespace Private {
static void fChgMode(ArgArray args) {
// assert types
assert (args.size() == 2 || args.size() == 3);
assert(args.size() == 2 || args.size() == 3);
assert(args[0].type == NUM);
if (args.size() == 2)
@ -69,7 +69,6 @@ static void fVSPicture(ArgArray args) {
g_private->_nextVS = args[0].u.str;
}
static void fDiaryLocList(ArgArray args) {
int x1, y1, x2, y2;
assert(args[0].type == NUM);
@ -87,7 +86,6 @@ static void fDiaryLocList(ArgArray args) {
Common::Rect rect(x1, y1, x2, y2);
g_private->loadLocations(rect);
}
static void fDiaryGoLoc(ArgArray args) {
@ -109,7 +107,6 @@ static void fgoto(ArgArray args) {
g_private->_nextSetting = args[0].u.str;
}
static void fSyncSound(ArgArray args) {
assert(args[0].type == STRING);
assert(args[1].type == NAME);
@ -123,9 +120,8 @@ static void fSyncSound(ArgArray args) {
g_private->ignoreEvents();
uint32 i = 100;
while(i--) // one second extra
while (i--) // one second extra
g_private->ignoreEvents();
}
}
@ -176,7 +172,7 @@ static void fRestartGame(ArgArray args) {
static void fPoliceBust(ArgArray args) {
// assert types
assert (args.size() == 1 || args.size() == 2);
assert(args.size() == 1 || args.size() == 2);
g_private->_policeBustEnabled = args[0].u.val;
//debug("Number of clicks %d", g_private->computePoliceIndex());
@ -199,16 +195,16 @@ static void fPoliceBust(ArgArray args) {
static void fBustMovie(ArgArray args) {
// assert types
assert (args.size() == 1);
assert(args.size() == 1);
debugC(1, kPrivateDebugScript, "BustMovie(%s)", args[0].u.sym->name->c_str());
uint policeIndex = g_private->maps.variables.getVal(g_private->getPoliceIndexVariable())->u.val;
int videoIndex = policeIndex/2 - 1;
int videoIndex = policeIndex / 2 - 1;
if (videoIndex < 0)
videoIndex = 0;
assert(videoIndex <= 5);
Common::String pv =
Common::String::format("po/animatio/spoc%02dxs.smk",
kPoliceBustVideos[videoIndex]);
Common::String::format("po/animatio/spoc%02dxs.smk",
kPoliceBustVideos[videoIndex]);
if (kPoliceBustVideos[videoIndex] == 2) {
Common::String s("global/transiti/audio/spoc02VO.wav");
@ -221,7 +217,7 @@ static void fBustMovie(ArgArray args) {
static void fDossierAdd(ArgArray args) {
assert (args.size() == 2);
assert(args.size() == 2);
Common::String s1 = args[0].u.str;
Common::String s2 = args[1].u.str;
DossierInfo m;
@ -237,7 +233,7 @@ static void fDossierAdd(ArgArray args) {
}
static void fDossierBitmap(ArgArray args) {
assert (args.size() == 2);
assert(args.size() == 2);
int x = args[0].u.val;
int y = args[1].u.val;
assert(x == 40 && y == 30);
@ -270,7 +266,7 @@ static void fDossierChgSheet(ArgArray args) {
}
static void fDossierPrevSuspect(ArgArray args) {
assert (args.size() == 3);
assert(args.size() == 3);
Common::String s(args[0].u.str);
MaskInfo m;
@ -287,7 +283,7 @@ static void fDossierPrevSuspect(ArgArray args) {
}
static void fDossierNextSuspect(ArgArray args) {
assert (args.size() == 3);
assert(args.size() == 3);
Common::String s(args[0].u.str);
MaskInfo m;
@ -354,23 +350,20 @@ static void fInventory(ArgArray args) {
if (e.type == NUM) {
assert(e.u.val == 0);
m.nextSetting = "";
}
else
} else
m.nextSetting = e.u.sym->name->c_str();
m.cursor = g_private->getInventoryCursor();
m.point = Common::Point(0,0);
m.point = Common::Point(0, 0);
if (v1.type == NAME) {
m.flag1 = g_private->maps.lookupVariable(v1.u.sym->name);
}
else
} else
m.flag1 = NULL;
if (v2.type == NAME) {
m.flag2 = g_private->maps.lookupVariable(v2.u.sym->name);
}
else
} else
m.flag2 = NULL;
g_private->_masks.push_front(m);
@ -387,7 +380,7 @@ static void fInventory(ArgArray args) {
g_private->inventory.push_back(bmp);
} else {
if (v1.type == NAME) {
v1.u.sym = g_private->maps.lookupVariable(v1.u.sym->name);
v1.u.sym = g_private->maps.lookupVariable(v1.u.sym->name);
if (strcmp(c.u.str, "\"REMOVE\"") == 0) {
v1.u.sym->u.val = 0;
if (inInventory(bmp))
@ -402,7 +395,7 @@ static void fInventory(ArgArray args) {
g_private->inventory.push_back(bmp);
}
if (v2.type == NAME) {
v2.u.sym = g_private->maps.lookupVariable(v2.u.sym->name);
v2.u.sym = g_private->maps.lookupVariable(v2.u.sym->name);
v2.u.sym->u.val = 1;
}
}
@ -603,9 +596,8 @@ static void _fMask(ArgArray args, bool drawn) {
m.cursor = *c;
m.flag1 = NULL;
m.flag2 = NULL;
m.point = Common::Point(x,y);
m.point = Common::Point(x, y);
g_private->_masks.push_front(m);
}
static void fMask(ArgArray args) {
@ -677,8 +669,7 @@ static void fSoundArea(ArgArray args) {
n = Common::String(args[1].u.str);
Common::replace(n, "\"", "");
Common::replace(n, "\"", "");
}
else
} else
error("Invalid input for SoundArea");
debugC(1, kPrivateDebugScript, "SoundArea(%s, %s, ..)", args[0].u.str, n.c_str());
@ -732,7 +723,7 @@ static void fAskSave(ArgArray args) {
}
static void fTimer(ArgArray args) {
assert (args.size() == 2 || args.size() == 3);
assert(args.size() == 2 || args.size() == 3);
if (args.size() == 3)
debugC(1, kPrivateDebugScript, "Timer(%d, %s, %s)", args[0].u.val, args[1].u.sym->name->c_str(), args[2].u.sym->name->c_str());
@ -756,72 +747,71 @@ static void fTimer(ArgArray args) {
const FuncTable funcTable[] = {
// Control flow
{ fChgMode, "ChgMode"},
{ fResume, "Resume"},
{ fgoto, "goto"},
{ fTimer, "Timer"},
{fChgMode, "ChgMode"},
{fResume, "Resume"},
{fgoto, "goto"},
{fTimer, "Timer"},
// Variables
{ fSetFlag, "SetFlag"},
{ fSetModifiedFlag, "SetModifiedFlag"},
{fSetFlag, "SetFlag"},
{fSetModifiedFlag, "SetModifiedFlag"},
// Sounds
{ fSound, "Sound"},
{ fSoundEffect, "SoundEffect"},
{ fLoopedSound, "LoopedSound"},
{ fNoStopSounds, "NoStopSounds"},
{ fSyncSound, "SyncSound"},
{ fAMRadioClip, "AMRadioClip"},
{ fPoliceClip, "PoliceClip"},
{ fPhoneClip, "PhoneClip"},
{ fSoundArea, "SoundArea"},
{ fPaperShuffleSound, "PaperShuffleSound"},
{fSound, "Sound"},
{fSoundEffect, "SoundEffect"},
{fLoopedSound, "LoopedSound"},
{fNoStopSounds, "NoStopSounds"},
{fSyncSound, "SyncSound"},
{fAMRadioClip, "AMRadioClip"},
{fPoliceClip, "PoliceClip"},
{fPhoneClip, "PhoneClip"},
{fSoundArea, "SoundArea"},
{fPaperShuffleSound, "PaperShuffleSound"},
// Images
{ fBitmap, "Bitmap"},
{ fMask, "Mask"},
{ fMaskDrawn, "MaskDrawn"},
{ fVSPicture, "VSPicture"},
{ fViewScreen, "ViewScreen"},
{ fExit, "Exit"},
{fBitmap, "Bitmap"},
{fMask, "Mask"},
{fMaskDrawn, "MaskDrawn"},
{fVSPicture, "VSPicture"},
{fViewScreen, "ViewScreen"},
{fExit, "Exit"},
// Video
{ fTransition, "Transition"},
{ fMovie, "Movie"},
{fTransition, "Transition"},
{fMovie, "Movie"},
// Diary
{ fDiaryLocList, "DiaryLocList"},
{ fDiaryInvList, "DiaryInvList"},
{ fDiaryGoLoc, "DiaryGoLoc"},
{fDiaryLocList, "DiaryLocList"},
{fDiaryInvList, "DiaryInvList"},
{fDiaryGoLoc, "DiaryGoLoc"},
// Main menu
{ fQuit, "Quit"},
{ fLoadGame, "LoadGame"},
{ fSaveGame, "SaveGame"},
{ fAskSave, "AskSave"},
{ fRestartGame, "RestartGame"},
{fQuit, "Quit"},
{fLoadGame, "LoadGame"},
{fSaveGame, "SaveGame"},
{fAskSave, "AskSave"},
{fRestartGame, "RestartGame"},
// Dossiers
{ fDossierAdd, "DossierAdd"},
{ fDossierChgSheet, "DossierChgSheet"},
{ fDossierBitmap, "DossierBitmap"},
{ fDossierPrevSuspect, "DossierPrevSuspect"},
{ fDossierNextSuspect, "DossierNextSuspect"},
{fDossierAdd, "DossierAdd"},
{fDossierChgSheet, "DossierChgSheet"},
{fDossierBitmap, "DossierBitmap"},
{fDossierPrevSuspect, "DossierPrevSuspect"},
{fDossierNextSuspect, "DossierNextSuspect"},
// Inventory
{ fLoseInventory, "LoseInventory"},
{ fInventory, "Inventory"},
{fLoseInventory, "LoseInventory"},
{fInventory, "Inventory"},
// PoliceBust
{ fPoliceBust, "PoliceBust"},
{ fBustMovie, "BustMovie"},
{fPoliceBust, "PoliceBust"},
{fBustMovie, "BustMovie"},
// Others
{ fSafeDigit, "SafeDigit"},
{ fCRect, "CRect"},
{fSafeDigit, "SafeDigit"},
{fCRect, "CRect"},
{ 0, 0}
};
{0, 0}};
void call(const char *name, const ArgArray &args) {
Common::String n(name);
@ -829,7 +819,7 @@ void call(const char *name, const ArgArray &args) {
error("I don't know how to execute %s", name);
}
void (*func)(ArgArray) = (void (*)(ArgArray)) g_private->_functions.getVal(n);
void (*func)(ArgArray) = (void (*)(ArgArray))g_private->_functions.getVal(n);
func(args);
}

View File

@ -20,26 +20,26 @@
*
*/
#include "audio/decoders/wave.h"
#include "audio/audiostream.h"
#include "audio/decoders/wave.h"
#include "common/archive.h"
#include "common/config-manager.h"
#include "common/debug.h"
#include "common/debug-channels.h"
#include "common/debug.h"
#include "common/error.h"
#include "common/events.h"
#include "common/file.h"
#include "common/savefile.h"
#include "common/system.h"
#include "common/str.h"
#include "common/system.h"
#include "common/timer.h"
#include "engines/util.h"
#include "image/bmp.h"
#include "private/decompiler.h"
#include "private/grammar.h"
#include "private/private.h"
#include "private/tokens.h"
#include "private/grammar.h"
#include "private/decompiler.h"
namespace Private {
@ -127,9 +127,9 @@ Common::SeekableReadStream *PrivateEngine::loadAssets() {
Common::SeekableReadStream *file = NULL;
if (isDemo() && test->open("SUPPORT/ASSETS/DEMOGAME.WIN"))
file = (Common::SeekableReadStream *) test;
file = (Common::SeekableReadStream *)test;
else if (test->open("SUPPORT/ASSETS/GAME.WIN")) {
file = (Common::SeekableReadStream *) test;
file = (Common::SeekableReadStream *)test;
} else {
delete test;
assert(_installerArchive.open("SUPPORT/ASSETS.Z"));
@ -137,7 +137,7 @@ Common::SeekableReadStream *PrivateEngine::loadAssets() {
if (!isDemo()) {
if (_installerArchive.hasFile("GAME.DAT"))
file = _installerArchive.createReadStreamForMember("GAME.DAT");
else if (_installerArchive.hasFile("GAME.WIN"))
else if (_installerArchive.hasFile("GAME.WIN"))
file = _installerArchive.createReadStreamForMember("GAME.WIN");
else
error("Unknown version");
@ -148,17 +148,16 @@ Common::SeekableReadStream *PrivateEngine::loadAssets() {
// if the demo from the full retail CDROM is used
else if (_installerArchive.hasFile("DEMOGAME.DAT"))
file = _installerArchive.createReadStreamForMember("DEMOGAME.DAT");
file = _installerArchive.createReadStreamForMember("DEMOGAME.DAT");
else if (_installerArchive.hasFile("DEMOGAME.WIN"))
file = _installerArchive.createReadStreamForMember("DEMOGAME.WIN");
file = _installerArchive.createReadStreamForMember("DEMOGAME.WIN");
else {
error("Unknown version");
}
}
}
}
assert(file != NULL);
return file;
}
Common::Error PrivateEngine::run() {
@ -173,7 +172,7 @@ Common::Error PrivateEngine::run() {
Decompiler decomp(buf, fileSize, false);
free(buf);
buf = (char*) decomp.getResult().c_str();
buf = (char *)decomp.getResult().c_str();
//debug("%s", buf);
// Initialize stuff
@ -260,9 +259,10 @@ Common::Error PrivateEngine::run() {
changeCursor("default");
// The following functions will return true
// if the cursor is changed
if (cursorPauseMovie(mousePos)) {}
else if (cursorMask(mousePos)) {}
else cursorExit(mousePos);
if (cursorPauseMovie(mousePos)) {
} else if (cursorMask(mousePos)) {
} else
cursorExit(mousePos);
break;
default:
@ -411,7 +411,7 @@ void PrivateEngine::checkPoliceBust() {
return;
}
if (_numberClicks == _maxNumberClicks+1) {
if (_numberClicks == _maxNumberClicks + 1) {
uint policeIndex = maps.variables.getVal(getPoliceIndexVariable())->u.val;
_policeBustSetting = _currentSetting;
if (policeIndex <= 13) {
@ -435,7 +435,7 @@ bool PrivateEngine::cursorExit(Common::Point mousePos) {
for (ExitList::const_iterator it = _exits.begin(); it != _exits.end(); ++it) {
const ExitInfo &e = *it;
cs = e.rect.width()*e.rect.height();
cs = e.rect.width() * e.rect.height();
if (e.rect.contains(mousePos)) {
if (cs < rs && !e.cursor.empty()) {
@ -467,7 +467,6 @@ bool PrivateEngine::inMask(Graphics::Surface *surf, Common::Point mousePos) {
return (surf->getPixel(mousePos.x, mousePos.y) != _transparentColor);
}
bool PrivateEngine::cursorMask(Common::Point mousePos) {
bool inside = false;
for (MaskList::const_iterator it = _masks.begin(); it != _masks.end(); ++it) {
@ -533,7 +532,6 @@ Common::String PrivateEngine::getPoliceIndexVariable() {
return "k0";
}
Common::String PrivateEngine::getPOGoBustMovieSetting() {
if (_language == "us")
return "kPOGoBustMovie";
@ -555,7 +553,6 @@ Common::String PrivateEngine::getExitCursor() {
return "k5";
}
Common::String PrivateEngine::getInventoryCursor() {
if (_language == "us")
return "kInventory";
@ -574,7 +571,7 @@ void PrivateEngine::selectPauseMovie(Common::Point mousePos) {
else
_pausedSetting = _currentSetting;
_nextSetting = getPauseMovieSetting();
_nextSetting = getPauseMovieSetting();
if (_videoDecoder) {
_videoDecoder->pauseVideo(true);
}
@ -593,7 +590,7 @@ void PrivateEngine::selectExit(Common::Point mousePos) {
int cs = 0;
for (ExitList::const_iterator it = _exits.begin(); it != _exits.end(); ++it) {
const ExitInfo &e = *it;
cs = e.rect.width()*e.rect.height();
cs = e.rect.width() * e.rect.height();
//debug("Testing exit %s %d", e.nextSetting->c_str(), cs);
if (e.rect.contains(mousePos)) {
//debug("Inside! %d %d", cs, rs);
@ -903,8 +900,8 @@ Common::Error PrivateEngine::loadGameStream(Common::SeekableReadStream *stream)
PhoneInfo p;
for (uint32 j = 0; j < size; ++j) {
p.sound = stream->readString();
p.flag = maps.variables.getVal(stream->readString());
p.val = stream->readUint32LE();
p.flag = maps.variables.getVal(stream->readString());
p.val = stream->readUint32LE();
_phone.push_back(p);
}
@ -1132,7 +1129,7 @@ Graphics::Surface *PrivateEngine::decodeImage(const Common::String &name) {
void PrivateEngine::loadImage(const Common::String &name, int x, int y) {
debugC(1, kPrivateDebugFunction, "%s(%s,%d,%d)", __FUNCTION__, name.c_str(), x, y);
Graphics::Surface *surf = decodeImage(name);
_compositeSurface->transBlitFrom(*surf, _origin + Common::Point(x,y), _transparentColor);
_compositeSurface->transBlitFrom(*surf, _origin + Common::Point(x, y), _transparentColor);
surf->free();
delete surf;
_image->destroy();
@ -1142,7 +1139,6 @@ void PrivateEngine::drawScreenFrame() {
g_system->copyRectToScreen(_frame->getPixels(), _frame->pitch, 0, 0, _screenW, _screenH);
}
Graphics::Surface *PrivateEngine::loadMask(const Common::String &name, int x, int y, bool drawn) {
debugC(1, kPrivateDebugFunction, "%s(%s,%d,%d,%d)", __FUNCTION__, name.c_str(), x, y, drawn);
Graphics::Surface *surf = new Graphics::Surface();
@ -1153,10 +1149,10 @@ Graphics::Surface *PrivateEngine::loadMask(const Common::String &name, int x, in
uint32 hdiff = 0;
uint32 wdiff = 0;
if (x+csurf->h > _screenH)
hdiff = x+csurf->h - _screenH;
if (y+csurf->w > _screenW)
wdiff = y+csurf->w - _screenW;
if (x + csurf->h > _screenH)
hdiff = x + csurf->h - _screenH;
if (y + csurf->w > _screenW)
wdiff = y + csurf->w - _screenW;
Common::Rect crect(csurf->w - wdiff, csurf->h - hdiff);
surf->copyRectToSurface(*csurf, x, y, crect);
@ -1181,7 +1177,7 @@ void PrivateEngine::drawScreen() {
if (_videoDecoder && !_videoDecoder->isPaused()) {
const Graphics::Surface *frame = _videoDecoder->decodeNextFrame();
Graphics::Surface *cframe = frame->convertTo(_pixelFormat, _videoDecoder->getPalette());
Common::Point center((_screenW - _videoDecoder->getWidth())/2, (_screenH - _videoDecoder->getHeight())/2);
Common::Point center((_screenW - _videoDecoder->getWidth()) / 2, (_screenH - _videoDecoder->getHeight()) / 2);
surface->blitFrom(*cframe, center);
cframe->free();
delete cframe;
@ -1197,7 +1193,6 @@ void PrivateEngine::drawScreen() {
//if (_image->getPalette() != nullptr)
// g_system->getPaletteManager()->setPalette(_image->getPalette(), _image->getPaletteStartIndex(), _image->getPaletteColorCount());
g_system->updateScreen();
}
bool PrivateEngine::getRandomBool(uint p) {
@ -1265,7 +1260,7 @@ void PrivateEngine::loadLocations(const Common::Rect &rect) {
if (sym->u.val) {
offset = offset + 22;
Common::String s =
Common::String::format("%sdryloc%d.bmp", _diaryLocPrefix.c_str(), i);
Common::String::format("%sdryloc%d.bmp", _diaryLocPrefix.c_str(), i);
loadMask(s, rect.left + 120, rect.top + offset, true);
}

View File

@ -20,7 +20,6 @@
*
*/
// Heavily inspired by hoc
// Copyright (C) AT&T 1995
// All Rights Reserved
@ -44,10 +43,10 @@
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
// THIS SOFTWARE.
#include "common/str.h"
#include "private/grammar.h"
#include "private/private.h"
#include "private/tokens.h"
#include "common/str.h"
namespace Private {
@ -90,14 +89,12 @@ static Symbol *install(const Common::String &n, int t, int d, const char *s, Com
sp->name = name;
sp->type = t;
if (t == NUM) {
sp->u.val = d;
sp->u.val = d;
//debug("install NUM: %s %d", name->c_str(), d);
}
else if (t == NAME) {
} else if (t == NAME) {
sp->u.val = d;
//debug("installing NAME: %s %d", name->c_str(), d);
}
else if (t == STRING)
} else if (t == STRING)
sp->u.str = scumm_strdup(s); // FIXME: leaks a string here.
else if (t == RECT)
sp->u.rect = r;
@ -109,7 +106,6 @@ static Symbol *install(const Common::String &n, int t, int d, const char *s, Com
return sp;
}
/* lookup some name in some symbol table */
Symbol *SymbolMaps::lookupRect(Common::String *n) {
//debug("looking rect up %s", n->c_str());
@ -125,7 +121,6 @@ Symbol *SymbolMaps::lookupVariable(Common::String *n) {
return lookup(*n, variables);
}
/* lookup some name in some symbol table */
Symbol *SymbolMaps::lookupName(const char *n) {