/[projectaxis]/projectaxis/projectAxis/src/pods/pod.cpp
ViewVC logotype

Diff of /projectaxis/projectAxis/src/pods/pod.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by leiavoia, Sat Jun 7 00:01:03 2003 UTC revision 1.4 by leiavoia, Sun Jun 8 05:05:01 2003 UTC
# Line 20  const long TIMING_LOOP_DELAY =400000; Line 20  const long TIMING_LOOP_DELAY =400000;
20    
21  // static variables:  // static variables:
22  Map* Pod::map; // a pointer to the map.  Map* Pod::map; // a pointer to the map.
23  int Pod::pod_count = 0; // total pods on the map number - doubles as a pod ID counter  int Pod::id_counter = 0; // unique pod ID counter
24  vector<Pod*> Pod::pod_index; // a vector of pointers to pods. now we can look them up by ID number  vector<Pod*> Pod::pod_index; // a vector of pointers to pods. now we can look them up by ID number
25    
26    
# Line 53  Pod::Pod(int axis){ Line 53  Pod::Pod(int axis){
53          name = pod_names[ rand() % 9 ];          name = pod_names[ rand() % 9 ];
54    
55          // give the pod some generic dummy info for testing:          // give the pod some generic dummy info for testing:
56            // TODO: give me attributes based on shapes (?)
57          align = axis;          align = axis;
58          id = 1;          id = ++id_counter;
59          att = 75;          att = 75;
60          def = 60;          def = 60;
61          opac = 40;          opac = 40;
# Line 68  Pod::Pod(int axis){ Line 69  Pod::Pod(int axis){
69          avoid = 1;          avoid = 1;
70          engage = 1;          engage = 1;
71    
72          // put me somewhere on the map          misn = new Idle(*this); // idle is the default mission
                 // set map coords  
                 // set internal coords  
   
         // give me attributes based on shapes (?)  
73    
74          // add to pod index          // add to pod index
75            AddPod(this);
         ++pod_count;  
76          }          }
77    
78    
# Line 88  Pod::~Pod(){ Line 84  Pod::~Pod(){
84                  path=NULL;                  path=NULL;
85                  }                  }
86          // destroy mission          // destroy mission
87          // TODO: destroy ALL missions in queue after queue is implemented          // TODO: destroy *ALL* missions in queue after queue is implemented
88          if (misn != NULL) {          if (misn != NULL) {
89                  delete misn;                  delete misn;
90                  misn=NULL;                  misn=NULL;
91                  }                  }
92    
93          --pod_count;          // do not reduce id_counter - it just goes up to make new IDs. it's not a pod count. use pod_index.size() for that
94    
95          // remove from vector?          // remove from vector
96            int max = pod_index.size();
97            for (int i = 0; i < max; i++) {
98                    if (pod_index[i]->id == this->id) { pod_index.erase( pod_index.begin()+i ); }
99                    }
100          }          }
101    
102    
# Line 160  int Pod::GetXp(){ Line 160  int Pod::GetXp(){
160          return xp;          return xp;
161          }          }
162    
163    // TODO: add mission number in perams when mission queue is implemented
164  Mission* Pod::Misn(){  Mission* Pod::Misn(){
165          return misn;          return misn;
166          }          }
# Line 175  Mission* Pod::Misn(){ Line 176  Mission* Pod::Misn(){
176    
177  // SET FUNCTIONS  // SET FUNCTIONS
178  // ==================================  // ==================================
179    // TODO: change this to AddMission(slot#) later
180  void Pod::SetMission(mission_type m ) {  void Pod::SetMission(mission_type m ) {
181            if (misn != NULL) {delete misn;} // delete old mission
182          switch(m) {          switch(m) {
183                  case PATROL:                  case PATROL:
184                          misn = new Patrol(*this, x_pos, y_pos, 4, 0);                          misn = new Patrol(*this, x_pos, y_pos, 4, 0);
# Line 217  bool Pod::Place(int x, int y) { Line 220  bool Pod::Place(int x, int y) {
220  void Pod::SetMapPointer(Map &incoming_map){  void Pod::SetMapPointer(Map &incoming_map){
221          map = &incoming_map;          map = &incoming_map;
222          }          }
223    
224    // adds a pod to the pod index
225    void Pod::AddPod(Pod* pod){
226            pod_index.push_back(pod);
227            }
228    
229    // get a pod pointer based on it's ID number
230    Pod* Pod::GetPod(int id){
231            int max = pod_index.size();
232            for (int i = 0; i < max; i++) {
233                    if (pod_index[i]->id == id) { return pod_index[i]; }
234                    }
235            return NULL;
236            }
237    
238    int Pod::GetNumPods() {
239            return pod_index.size();
240            }
241  // ==================================  // ==================================
242    
243    
# Line 362  bool Pod::Walk() { Line 383  bool Pod::Walk() {
383    
384                  };                  };
385    
386          // TODO: after all done moving, we need to do some individual end-of-turn operations          // after all done moving, we need to do some individual end-of-turn operations
387          xp++; // inc pod's own experience          xp++; // inc pod's own experience
388          // the following is comented because we don't know yet if we should do mision time here or in the mission itself  
389          // the problem is that just plain moving around is not part of a mission. should we increase mission time if          // do not increase mission time here
         // we aren't actively on the mission, just moving? what if we don't have a mission? -> segfault  
         //misn->IncTime(); // increase mission time  
390    
391    
392          return 0; // did not hit goal after all done moving this round          return 0; // did not hit goal after all done moving this round

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26