Skip to content

Commit 542f8d5

Browse files
committed
SWC: Reorganize ShowImageOrFlic
1 parent 2ccf3ee commit 542f8d5

1 file changed

Lines changed: 31 additions & 27 deletions

File tree

source/supreme/display.cpp

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "message.h"
1212
#include "appdata.h"
1313
#include "ioext.h"
14+
#include "log.h"
1415

1516
mfont_t *gameFont[3]={NULL,NULL,NULL};
1617
MGLDraw *mgl=NULL;
@@ -136,59 +137,62 @@ void LoadText(const char *nm,byte mode)
136137

137138
TASK(void) ShowImageOrFlic(const char *str,byte nosnd,byte mode)
138139
{
139-
int speed;
140-
141-
char *fname;
142-
char *other;
143140
char nm[64];
144-
145141
std::string copy = str;
146142

147-
fname=strtok(copy.data(),",\n");
143+
char *fname = strtok(copy.data(),",\n");
148144
if(!fname)
149145
CO_RETURN;
150146

151-
other=strtok(NULL,",\n");
147+
char *other = strtok(NULL,",\n");
148+
149+
const char* extension = "";
150+
size_t dot = std::string_view(fname).rfind('.');
151+
if (dot != std::string::npos)
152+
{
153+
extension = &fname[dot];
154+
}
152155

153156
// BMP loading
154-
if((fname[strlen(fname)-3]=='b' || fname[strlen(fname)-3]=='B') &&
155-
(fname[strlen(fname)-2]=='m' || fname[strlen(fname)-2]=='M') &&
156-
(fname[strlen(fname)-1]=='p' || fname[strlen(fname)-1]=='P'))
157+
if (!strcasecmp(extension, ".bmp"))
157158
{
158159
EnterPictureDisplay();
159160
if(!nosnd)
160161
MakeNormalSound(SND_MESSAGE);
161162
sprintf(nm,"user/%s",fname);
162163
GetDisplayMGL()->LoadBMPResize(nm);
163-
CO_RETURN;
164164
}
165-
if((fname[strlen(fname)-3]=='t' || fname[strlen(fname)-3]=='T') &&
166-
(fname[strlen(fname)-2]=='x' || fname[strlen(fname)-2]=='X') &&
167-
(fname[strlen(fname)-1]=='t' || fname[strlen(fname)-1]=='T'))
165+
else if (!strcasecmp(extension, ".txt"))
168166
{
169167
EnterPictureDisplay();
170168
if(!nosnd)
171169
MakeNormalSound(SND_MESSAGE);
172170
sprintf(nm,"user/%s",fname);
173171
LoadText(nm,mode);
174-
CO_RETURN;
175172
}
173+
else if (!strcasecmp(extension, ".flc"))
174+
{
175+
int speed;
176+
if(other)
177+
speed=atoi(other);
178+
else
179+
speed=60;
176180

177-
if(other)
178-
speed=atoi(other);
179-
else
180-
speed=60;
181-
182-
sprintf(nm,"user/%s",fname);
181+
sprintf(nm,"user/%s",fname);
183182

184-
AWAIT FLI_play(nm,0,speed,mgl);
185-
mgl->LoadBMP("graphics/title.bmp");
186-
RestoreGameplayGfx();
183+
AWAIT FLI_play(nm,0,speed,mgl);
184+
mgl->LoadBMP("graphics/title.bmp");
185+
RestoreGameplayGfx();
187186

188-
if(!editing && (verified || shopping))
187+
if(!editing && (verified || shopping))
188+
{
189+
SeeMovie(fname);
190+
GoalPurchase();
191+
}
192+
}
193+
else
189194
{
190-
SeeMovie(fname);
191-
GoalPurchase();
195+
LogError("Unknown Show Pic/Movie type \"%s\" in \"%s\"", extension, fname);
192196
}
193197
}
194198

0 commit comments

Comments
 (0)