|
11 | 11 | #include "message.h" |
12 | 12 | #include "appdata.h" |
13 | 13 | #include "ioext.h" |
| 14 | +#include "log.h" |
14 | 15 |
|
15 | 16 | mfont_t *gameFont[3]={NULL,NULL,NULL}; |
16 | 17 | MGLDraw *mgl=NULL; |
@@ -136,59 +137,62 @@ void LoadText(const char *nm,byte mode) |
136 | 137 |
|
137 | 138 | TASK(void) ShowImageOrFlic(const char *str,byte nosnd,byte mode) |
138 | 139 | { |
139 | | - int speed; |
140 | | - |
141 | | - char *fname; |
142 | | - char *other; |
143 | 140 | char nm[64]; |
144 | | - |
145 | 141 | std::string copy = str; |
146 | 142 |
|
147 | | - fname=strtok(copy.data(),",\n"); |
| 143 | + char *fname = strtok(copy.data(),",\n"); |
148 | 144 | if(!fname) |
149 | 145 | CO_RETURN; |
150 | 146 |
|
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 | + } |
152 | 155 |
|
153 | 156 | // 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")) |
157 | 158 | { |
158 | 159 | EnterPictureDisplay(); |
159 | 160 | if(!nosnd) |
160 | 161 | MakeNormalSound(SND_MESSAGE); |
161 | 162 | sprintf(nm,"user/%s",fname); |
162 | 163 | GetDisplayMGL()->LoadBMPResize(nm); |
163 | | - CO_RETURN; |
164 | 164 | } |
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")) |
168 | 166 | { |
169 | 167 | EnterPictureDisplay(); |
170 | 168 | if(!nosnd) |
171 | 169 | MakeNormalSound(SND_MESSAGE); |
172 | 170 | sprintf(nm,"user/%s",fname); |
173 | 171 | LoadText(nm,mode); |
174 | | - CO_RETURN; |
175 | 172 | } |
| 173 | + else if (!strcasecmp(extension, ".flc")) |
| 174 | + { |
| 175 | + int speed; |
| 176 | + if(other) |
| 177 | + speed=atoi(other); |
| 178 | + else |
| 179 | + speed=60; |
176 | 180 |
|
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); |
183 | 182 |
|
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(); |
187 | 186 |
|
188 | | - if(!editing && (verified || shopping)) |
| 187 | + if(!editing && (verified || shopping)) |
| 188 | + { |
| 189 | + SeeMovie(fname); |
| 190 | + GoalPurchase(); |
| 191 | + } |
| 192 | + } |
| 193 | + else |
189 | 194 | { |
190 | | - SeeMovie(fname); |
191 | | - GoalPurchase(); |
| 195 | + LogError("Unknown Show Pic/Movie type \"%s\" in \"%s\"", extension, fname); |
192 | 196 | } |
193 | 197 | } |
194 | 198 |
|
|
0 commit comments