1 // stdafx.cpp : source file that includes just the standard includes
\r
2 // Bomberman_SchemeReader.pch will be the pre-compiled header
\r
3 // stdafx.obj will contain the pre-compiled type information
\r
4 #define _CRT_SECURE_NO_DEPRECATE
\r
5 #define min(a, b) (((a) < (b)) ? (a) : (b))
\r
7 #include "SchemeReader.h"
\r
10 using namespace std;
\r
12 // TODO: reference any additional headers you need in STDAFX.H
\r
13 // and not in this file
\r
15 int StrIndex(char* source, int start, int length, char* dest) {
\r
16 if (source == NULL || dest == NULL) return 0;
\r
17 int stringlength = strlen(source);
\r
18 int copylen = min(length, stringlength);
\r
19 if (start > stringlength) return 0;//stupid check
\r
20 if (start+length > strlen(source)) length = stringlength - start;
\r
21 strncpy(dest, source+start, length);
\r
26 SchemeReader::SchemeReader(char *Filename) {
\r
27 char ReadBuffer[256];
\r
29 char rowcontents[PLAYGROUND_NUMFIELD_X+1];
\r
30 int startx,starty,team;
\r
31 int BornWith, HasOverride, Override, Forbidden;
\r
33 ifstream SchemeFile (Filename, ifstream::in);
\r
34 while (!(SchemeFile.eof())) {
\r
35 SchemeFile.getline(ReadBuffer, 256);
\r
36 switch(ReadBuffer[0]) {
\r
38 switch(ReadBuffer[1]) {
\r
41 sscanf(ReadBuffer, "-R,%d,%s", &num, rowcontents);
\r
42 for (counter=0; counter < strlen(rowcontents); counter++) {
\r
43 switch(rowcontents[counter]) {
\r
45 PlayField[num*PLAYGROUND_NUMFIELD_X+counter] = SOLID;
\r
48 PlayField[num*PLAYGROUND_NUMFIELD_X+counter] = BRICK;
\r
51 PlayField[num*PLAYGROUND_NUMFIELD_X+counter] = BLANK;
\r
57 //Player Starting position data
\r
58 sscanf(ReadBuffer, "-S,%d,%d,%d,%d", &num, &startx, &starty, &team);
\r
59 Player[num].startx=startx;
\r
60 Player[num].starty=starty;
\r
61 Player[num].team=team;
\r
66 sscanf(ReadBuffer, "-P,%d,%d,%d,%d,%d", &num, &BornWith, &HasOverride, &Override, &Forbidden);
\r
67 Powerups[num].BornWith=BornWith;
\r
68 Powerups[num].HasOverride=HasOverride;
\r
69 Powerups[num].Override=Override;
\r
70 Powerups[num].Forbidden=Forbidden;
\r
75 StrIndex(ReadBuffer, 3,256, Name);
\r
80 sscanf(ReadBuffer, "-B,%d", &BrickDensity);
\r