aboutsummaryrefslogtreecommitdiff
path: root/sword2/function.cpp
diff options
context:
space:
mode:
authorTorbjörn Andersson2004-10-19 07:12:23 +0000
committerTorbjörn Andersson2004-10-19 07:12:23 +0000
commit4d3913d1b21d00692b0f761a8ade9d8b506cd7e0 (patch)
tree2e58addcfc6696ca2655d2b7373766b9962400b9 /sword2/function.cpp
parentacf6e4a12f0e676c9a33cb8f96b6d95f83f1b77a (diff)
downloadscummvm-rg350-4d3913d1b21d00692b0f761a8ade9d8b506cd7e0.tar.gz
scummvm-rg350-4d3913d1b21d00692b0f761a8ade9d8b506cd7e0.tar.bz2
scummvm-rg350-4d3913d1b21d00692b0f761a8ade9d8b506cd7e0.zip
Cleanup of the credits code. Use the new gets() function.
svn-id: r15609
Diffstat (limited to 'sword2/function.cpp')
-rw-r--r--sword2/function.cpp57
1 files changed, 18 insertions, 39 deletions
diff --git a/sword2/function.cpp b/sword2/function.cpp
index 27a924feaf..3a70407d61 100644
--- a/sword2/function.cpp
+++ b/sword2/function.cpp
@@ -27,6 +27,7 @@
#include "sword2/resman.h"
#include "sword2/driver/d_draw.h"
#include "sword2/driver/d_sound.h"
+#include "sword2/driver/render.h"
namespace Sword2 {
@@ -480,56 +481,32 @@ int32 Logic::fnPlayCredits(int32 *params) {
bool hasCenterMark = false;
while (1) {
- char buffer[80];
- char *line = buffer;
- char *center_mark = NULL;
-
if (lineCount >= ARRAYSIZE(creditsLines)) {
warning("Too many credits lines");
break;
}
- int pos = 0;
-
- while (1) {
- byte b = f.readByte();
-
- if (f.ioFailed()) {
- if (pos != 0)
- line[pos] = 0;
- else
- line = NULL;
- break;
- }
-
- if (b == 0x0d) {
- f.readByte();
- line[pos] = 0;
- pos = 0;
- break;
- }
-
- if (pos < ARRAYSIZE(buffer)) {
- if (b == '^')
- center_mark = line + pos;
- line[pos++] = b;
- }
- }
+ char buffer[80];
+ char *line = f.gets(buffer, sizeof(buffer));
- if (!line || strlen(line) == 0) {
+ if (!line || *line == 0) {
if (!hasCenterMark) {
for (i = paragraphStart; i < lineCount; i++)
creditsLines[i].type = LINE_CENTER;
}
paragraphStart = lineCount;
hasCenterMark = false;
- if (!line)
- break;
if (paragraphStart == lineCount)
lineTop += CREDITS_LINE_SPACING;
+
+ if (!line)
+ break;
+
continue;
}
+ char *center_mark = strchr(line, '^');
+
if (center_mark) {
// The current paragraph has at least one center mark.
hasCenterMark = true;
@@ -544,15 +521,17 @@ int32 Logic::fnPlayCredits(int32 *params) {
creditsLines[lineCount].type = LINE_LEFT;
creditsLines[lineCount].str = strdup(line);
- *center_mark = '^';
- line = center_mark;
lineCount++;
if (lineCount >= ARRAYSIZE(creditsLines)) {
warning("Too many credits lines");
break;
}
+
+ *center_mark = '^';
}
+
+ line = center_mark;
}
creditsLines[lineCount].top = lineTop;
@@ -653,19 +632,19 @@ int32 Logic::fnPlayCredits(int32 *params) {
switch (creditsLines[i].type) {
case LINE_LEFT:
- spriteInfo.x = 640 / 2 - 5 - frame->width;
+ spriteInfo.x = RENDERWIDE / 2 - 5 - frame->width;
break;
case LINE_RIGHT:
- spriteInfo.x = 640 / 2 + 5;
+ spriteInfo.x = RENDERWIDE / 2 + 5;
break;
case LINE_CENTER:
if (strcmp(creditsLines[i].str, "@") == 0) {
spriteInfo.data = logoData;
- spriteInfo.x = (640 - logoWidth) / 2;
+ spriteInfo.x = (RENDERWIDE - logoWidth) / 2;
spriteInfo.w = logoWidth;
spriteInfo.h = logoHeight;
} else
- spriteInfo.x = (640 - frame->width) / 2;
+ spriteInfo.x = (RENDERWIDE - frame->width) / 2;
break;
}