Skip to content

Commit

Permalink
MORTEVIELLE: clean up deline()
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke committed Apr 6, 2012
1 parent d228622 commit 2634bee
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 77 deletions.
6 changes: 3 additions & 3 deletions engines/mortevielle/actions.cpp
Expand Up @@ -668,7 +668,7 @@ void fctPlace() {
// Do you want to enter the hidden passage?
int answer = Alert::show(g_vm->getEngineString(S_YES_NO), 1);
if (answer== 1) {
Common::String alertTxt = delin2(582);
Common::String alertTxt = deline(582);
i = Alert::show(alertTxt, 1);

tesok = false;
Expand Down Expand Up @@ -696,7 +696,7 @@ void fctPlace() {
dessin(0);
aniof(1, 2);
aniof(1, 1);
alertTxt = delin2(577);
alertTxt = deline(577);
i = Alert::show(alertTxt, 1);
aniof(2, 1);
crep = 166;
Expand Down Expand Up @@ -1313,7 +1313,7 @@ void fctDiscuss() {
for (int ix = 1; ix <= 46; ++ix)
te[ix] = false;
for (int ix = 1; ix <= 45; ++ix) {
lib[ix] = delin2(ix + c_tparler);
lib[ix] = deline(ix + c_tparler);
for (i = lib[ix].size(); i <= 40; ++i)
lib[ix] = lib[ix] + ' ';
}
Expand Down
4 changes: 2 additions & 2 deletions engines/mortevielle/dialogs.cpp
Expand Up @@ -313,7 +313,7 @@ bool Ques::show() {
else
dialogHeight = 23;
g_vm->_screenSurface.fillRect(15, Common::Rect(0, 14, 630, dialogHeight));
Common::String tmpStr = delin2(textIndexArr[indx]);
Common::String tmpStr = deline(textIndexArr[indx]);
afftex(tmpStr, 20, 15, 100, 2, 0);

if (indx != 10) {
Expand All @@ -327,7 +327,7 @@ bool Ques::show() {
maxLength = 0;

for (int j = firstOption, prevChoice = 1; j <= lastOption; ++j, ++prevChoice) {
tmpStr = delin2(j);
tmpStr = deline(j);
if ((int) tmpStr.size() > maxLength)
maxLength = tmpStr.size();
afftex(tmpStr, 100, optionPosY, 100, 1, 0);
Expand Down
6 changes: 3 additions & 3 deletions engines/mortevielle/menu.cpp
Expand Up @@ -487,18 +487,18 @@ void Menu::initMenu() {
_moveStringArray[i] = "* ";
i = 1;
do {
_actionStringArray[i] = delin2(i + c_action);
_actionStringArray[i] = deline(i + c_action);

while (_actionStringArray[i].size() < 10)
_actionStringArray[i] += ' ';

if (i < 9) {
if (i < 6) {
_selfStringArray[i] = delin2(i + c_saction);
_selfStringArray[i] = deline(i + c_saction);
while (_selfStringArray[i].size() < 10)
_selfStringArray[i] += ' ';
}
_discussStringArray[i] = delin2(i + c_dis) + ' ';
_discussStringArray[i] = deline(i + c_dis) + ' ';
}
++i;
} while (i != 22);
Expand Down
12 changes: 6 additions & 6 deletions engines/mortevielle/mor.cpp
Expand Up @@ -136,7 +136,7 @@ void text1(int x, int y, int nb, int m) {
co = 10;
else
co = 6;
Common::String tmpStr = delin2(m);
Common::String tmpStr = deline(m);
if ((y == 182) && ((int) tmpStr.size() * co > nb * 6))
y = 176;
afftex(tmpStr, x, y, nb, 20, color_txt);
Expand Down Expand Up @@ -312,7 +312,7 @@ void modobj(int m) {
Common::String strp = Common::String(' ');

if (m != 500)
strp = delin2(m - 501 + c_st41);
strp = deline(m - 501 + c_st41);

g_vm->_menu.menut(g_vm->_menu._inventoryMenu[8], strp);
g_vm->_menu.disableMenuItem(g_vm->_menu._inventoryMenu[8]);
Expand All @@ -327,7 +327,7 @@ void modobj2(int m, bool t1, bool t2) {
tesok = false;;

if (m != 500)
strp = delin2(m - 501 + c_st41);
strp = deline(m - 501 + c_st41);

g_vm->_menu.menut(g_vm->_menu._inventoryMenu[8], strp);
g_vm->_menu.disableMenuItem(g_vm->_menu._inventoryMenu[8]);
Expand All @@ -341,7 +341,7 @@ void repon(int f, int m) {
int i, xco, dx, caspe;

if ((m > 499) && (m < 563)) {
tmpStr = delin2(m - 501 + c_st41);
tmpStr = deline(m - 501 + c_st41);

if ((int) tmpStr.size() > ((58 + (res - 1) * 37) << 1))
f2_all = true;
Expand Down Expand Up @@ -376,7 +376,7 @@ void repon(int f, int m) {
else
i = 5;

tmpStr = delin2(m);
tmpStr = deline(m);
afftex(tmpStr, 80, 40, 60, 25, i);

if (m == 180)
Expand All @@ -387,7 +387,7 @@ void repon(int f, int m) {
}
if (f == 7) { /* messint */
ecrf7();
tmpStr = delin2(m);
tmpStr = deline(m);
if (res == 1) {
xco = 252 - tmpStr.size() * 5;
caspe = 100;
Expand Down
6 changes: 3 additions & 3 deletions engines/mortevielle/mor2.cpp
Expand Up @@ -245,7 +245,7 @@ void tmlieu(int mli) {

int i = 1;
while ((i < 8) && (v_lieu[i][mli] != 0)) {
nomp = delin2(v_lieu[i][mli] + c_tmlieu);
nomp = deline(v_lieu[i][mli] + c_tmlieu);
while (nomp.size() < 20)
nomp += ' ';
g_vm->_menu.menut(g_vm->_menu._moveMenu[i], nomp);
Expand Down Expand Up @@ -380,7 +380,7 @@ void modinv() {
if (s.sjer[cx] != chr(0)) {
++cy;
r = (ord(s.sjer[cx]) + 400);
nomp = delin2(r - 501 + c_st41);
nomp = deline(r - 501 + c_st41);
g_vm->_menu.menut(g_vm->_menu._inventoryMenu[cy], nomp);
g_vm->_menu.enableMenuItem(g_vm->_menu._inventoryMenu[cx]);
}
Expand All @@ -397,7 +397,7 @@ void sparl(float adr, float rep) {

repint = abs((int)rep);
hideMouse();
Common::String tmpStr = delin2(repint + c_paroles);
Common::String tmpStr = deline(repint + c_paroles);
afftex(tmpStr, 230, 4, 65, 24, 5);
f3f8::draw();

Expand Down
8 changes: 4 additions & 4 deletions engines/mortevielle/mortevielle.cpp
Expand Up @@ -134,10 +134,10 @@ Common::ErrorCode MortevielleEngine::initialise() {
return result;

// Load some error messages (was previously in chartex())
al_mess = delin2(578); // Insert floppy #1
err_mess = delin2(579); // Floppy error
ind_mess = delin2(580); // You should have noticed %d hints
al_mess2 = delin2(581); // Insert floppy #2
al_mess = deline(578); // Insert floppy #1
err_mess = deline(579); // Floppy error
ind_mess = deline(580); // You should have noticed %d hints
al_mess2 = deline(581); // Insert floppy #2

// Set default EGA palette
_paletteManager.setDefaultPalette();
Expand Down
73 changes: 21 additions & 52 deletions engines/mortevielle/outtext.cpp
Expand Up @@ -60,7 +60,7 @@ const byte tab31[32]= {
119, 0, 0, 0, 0, 0, 0, 0
};

void deline(int num , char *l , int &tl);
Common::String deline(int num);
typedef unsigned char uchar;

static void cinq_huit(char &c, int &idx, byte &pt, bool &the_end) {
Expand Down Expand Up @@ -126,63 +126,32 @@ static void cinq_huit(char &c, int &idx, byte &pt, bool &the_end) {
/**
* Decode and extract the line with the given Id
*/
void deline(int num, char *line , int &length) {
Common::String deline(int num) {
Common::String wrkStr = "";

if (num < 0) {
warning("deline: num < 0! Skipping");
return;
}

if (!g_vm->_txxFileFl) {
delig = g_vm->getGameString(num);
/* if (delig.size() < 255)
// Remove trailing '$'
delig.deleteLastChar();
*/
if (line) {
line[0] = ' ';
strcpy(line + 1, delig.c_str());
length = delig.size();
}

return;
} else if (!g_vm->_txxFileFl) {
wrkStr = g_vm->getGameString(num);
} else {
int i = t_rec[num].indis;
byte k = t_rec[num].point;
int length = 0;
bool endFl = false;
char let;
do {
cinq_huit(let, i, k, endFl);
if (length < 254)
wrkStr += let;
++length;
} while (!endFl);
}

// DETEX
delig = "";
int ts = t_rec[num].indis;
byte ps = t_rec[num].point;
int i = ts;
length = 1;
int j = 1;
// Initialize properly first string character
line[0] = ' ';
byte k = ps;
bool endFl = false;
char let;
do {
cinq_huit(let, i, k, endFl);
line[j] = let;
if (j < 254)
delig += let;
++j;
} while (!endFl);
length = j - 1;
if (length < 255)
if (wrkStr.lastChar() == '$')
// Remove trailing '$'
delig.deleteLastChar();

warning("deline: delig %s - line %s", delig.c_str(), line);
}

Common::String delin2(int num) {
char tmpStr[1410];
int length;
wrkStr.deleteLastChar();

deline(num, tmpStr, length);

Common::String resStr = delig;
delig = "";
return resStr;
return wrkStr;
}

void afftex(const char *ch, int x, int y, int dx, int dy, int typ);
Expand Down
5 changes: 1 addition & 4 deletions engines/mortevielle/outtext.h
Expand Up @@ -32,10 +32,7 @@

namespace Mortevielle {

extern Common::String delig;

extern void deline(int num , char *line , int &length);
extern Common::String delin2(int num);
extern Common::String deline(int num);
extern void afftex(Common::String ch, int x, int y, int dx, int dy, int typ);

} // End of namespace Mortevielle
Expand Down

0 comments on commit 2634bee

Please sign in to comment.