root/deus/MakeSteveOps.cpp

Revision 8, 2.3 kB (checked in by pantley2, 4 years ago)

added old DEUS project to SVN

Line 
1 #include "structures.h"
2 #include <iostream>
3 #include <sstream>
4 #include <string>
5 #include <vector>
6 #include <list>
7
8
9
10 vector<list<Operator> > GetMeOperators(Condition C, int index)
11 {
12        
13         vector<GameObject *> TempV;
14         TempV=(C.vars)[index];
15         vector<list<Operator> > ReturnOps;
16         list<Operator> listOps;
17        
18         std::list<Operator>::iterator It1=Ops.begin();
19         Operator Oatt=*It1;
20         It1++;
21         Operator Omove=*It1;
22         It1++;
23         Operator Orel=*It1;
24
25         int num;
26         string attrib, ineq, value;
27         int xloc, yloc;
28         int countlocations=0;
29         int countattributes=0;
30         int countrelationships=0;
31         for(int i=0; i<TempV.size(); i++)
32         {
33                 if(TempV[i]==NULL)
34                 {       
35                         string conds[10][10];
36                         for(int a=0; a<10; a++)
37                         {
38                                 for(int b=0; b<10; b++)
39                                 {
40                                         conds[a][b]=(C.conditions)[a][b];
41                                 }
42                         }
43                         for(int j=1; j<10; j++)
44                         {
45                                 if(conds[i][j]=="")
46                                         break;
47                                 std::istringstream iss(conds[i][j]);
48                                 iss>>attrib;
49                                 iss>>num;
50                                 for(int k=0; k<num+1; k++)
51                                 {
52                                         if(conds[i][k]=="")
53                                                 break;
54                                         if(attrib=="loc")
55                                         {
56                                                 iss>>xloc;
57                                                 iss>>yloc;
58                                                 Omove.PostConds.conditions[0][0]="npc";
59                                                 std::ostringstream oss;
60                                                 oss << xloc;
61                                                 oss << yloc;
62                                                 Omove.PostConds.conditions[0][1]=oss.str();
63                                                 countlocations++;
64                                         }
65                                         else if(attrib=="rel")
66                                         {
67                                                 string group_name;
68                                                 int group_val, attrib_val;
69                                                 iss>>group_name;
70                                                 iss>>group_val;
71                                                 iss>>attrib_val;
72                                                 std::ostringstream oss;
73                                                 oss<<group_name;
74                                                 oss<<group_val;
75                                                 oss<<attrib_val;
76                                                 (Orel.PostConds).conditions[0][0]="npc";
77                                                 (Orel.PostConds).conditions[0][countrelationships+1]=oss.str();
78                                                 countrelationships++;
79                                         }
80                                         else
81                                         {
82                                                 iss>>ineq;
83                                                 iss>>value;
84                                                 int value_int=atoi(value.c_str());                     
85                                                 if(ineq=="!=")
86                                                 {       
87                                                         value_int--;
88                                                 }                                               
89                                                 if(ineq==">")
90                                                 {
91                                                         value_int++;   
92                                                 }       
93                                                 if(ineq=="<")
94                                                 {
95                                                         value_int--;
96                                                 }
97                                                 std::ostringstream oss;
98                                                 oss<<attrib;
99                                                 oss<<value_int;
100                                                 (Oatt.PostConds).conditions[0][countattributes+1]=oss.str();
101                                                 countattributes++;
102                                         }               
103                                 }
104                                 listOps.push_back(Oatt);
105                                 listOps.push_back(Orel);
106                                 listOps.push_back(Omove);
107                         }
108                 }
109                 ReturnOps[i]=listOps;
110                 listOps.clear();
111         }
112         return ReturnOps;
113 }
Note: See TracBrowser for help on using the browser.