|
Revision 8, 2.6 kB
(checked in by pantley2, 4 years ago)
|
added old DEUS project to SVN
|
| Line | |
|---|
| 1 |
#include <fstream> |
|---|
| 2 |
#include <iostream> |
|---|
| 3 |
#include <string> |
|---|
| 4 |
#include "structures.h" |
|---|
| 5 |
#include <utility> |
|---|
| 6 |
using namespace std; |
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
pair<int,int> GetMapSize() |
|---|
| 12 |
{ |
|---|
| 13 |
int xs,ys; |
|---|
| 14 |
ifstream imap; |
|---|
| 15 |
imap.open("mapfile", ios::in); |
|---|
| 16 |
if(!imap) |
|---|
| 17 |
{ |
|---|
| 18 |
cout << "Error opening input file" << endl; |
|---|
| 19 |
exit(0); |
|---|
| 20 |
|
|---|
| 21 |
} |
|---|
| 22 |
imap>>xs; |
|---|
| 23 |
imap>>ys; |
|---|
| 24 |
imap.close(); |
|---|
| 25 |
pair<int,int> Size(xs,ys); |
|---|
| 26 |
return Size; |
|---|
| 27 |
} |
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
vector<Location> MapGenerator() |
|---|
| 33 |
{ |
|---|
| 34 |
ifstream imap; |
|---|
| 35 |
imap.open("mapfile", ios::in); |
|---|
| 36 |
if(!imap) |
|---|
| 37 |
{ |
|---|
| 38 |
cout << "Error opening input file" << endl; |
|---|
| 39 |
exit(0); |
|---|
| 40 |
|
|---|
| 41 |
} |
|---|
| 42 |
|
|---|
| 43 |
int numObjects; |
|---|
| 44 |
imap>>numObjects; |
|---|
| 45 |
imap>>numObjects; |
|---|
| 46 |
imap>>numObjects; |
|---|
| 47 |
|
|---|
| 48 |
cout<<"Numobjects :"<<numObjects<<endl; |
|---|
| 49 |
|
|---|
| 50 |
vector<Location> locarray(numObjects); |
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
char tempname[50]; |
|---|
| 66 |
int templtype; |
|---|
| 67 |
|
|---|
| 68 |
for(int i=0;i<numObjects;i++) |
|---|
| 69 |
{ |
|---|
| 70 |
|
|---|
| 71 |
imap>>tempname>>locarray[i].ur_x>>locarray[i].ur_y>>locarray[i].ll_x>>locarray[i].ll_y>>templtype; |
|---|
| 72 |
string temp(tempname); |
|---|
| 73 |
locarray[i].name=temp; |
|---|
| 74 |
switch(templtype) |
|---|
| 75 |
{ |
|---|
| 76 |
case 0 : locarray[i].loc_type=LOC_TOWN; |
|---|
| 77 |
break; |
|---|
| 78 |
case 1 : locarray[i].loc_type=LOC_FARM; |
|---|
| 79 |
break; |
|---|
| 80 |
case 2 : locarray[i].loc_type=LOC_MARKET; |
|---|
| 81 |
break; |
|---|
| 82 |
case 3 : locarray[i].loc_type=LOC_BAR; |
|---|
| 83 |
break; |
|---|
| 84 |
case 5 : locarray[i].loc_type=LOC_LAST; |
|---|
| 85 |
break; |
|---|
| 86 |
default : locarray[i].loc_type=LOC_GENERIC; |
|---|
| 87 |
} |
|---|
| 88 |
} |
|---|
| 89 |
|
|---|
| 90 |
imap.close(); |
|---|
| 91 |
return locarray; |
|---|
| 92 |
|
|---|
| 93 |
} |
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 |
|
|---|