1 #ifdef _WIN32
2 #include "windows.h"
3 #endif
4
5 #include "string.h"
6 #include "stdio.h"
7 #include "math.h"
8
9 #include "GL/gl.h"
10 #include "GL/glu.h"
11 #include "GL/glut.h"
12 #include "SDL/SDL.h"
13 #include "SDL/SDL_mixer.h"
14
15 #include "list.h"
16 #include "vector.h"
17 #include "cmc.h"
18 #include "3dobject.h"
19 #include "shadow3dobject.h"
20 #include "piece3dobject.h"
21 #include "myglutaux.h"
22 #include "nether.h"
23
24 #include "glprintf.h"
25
26
27 extern int frames_per_sec;
28 extern bool fullscreen;
29 extern int shadows;
30 extern bool sound;
31 extern int up_key,down_key,left_key,right_key,fire_key,pause_key;
32 extern int level;
33
34
save_debug_report(char * filename)35 bool NETHER::save_debug_report(char *filename)
36 {
37 int i,j;
38 FILE *fp;
39 BUILDING *b;
40 ROBOT *r;
41 BULLET *bul;
42 EXPLOSION *e;
43
44 fp=fopen(filename,"w");
45 if (fp==0) return false;
46
47 /*
48 int map_w,map_h;
49 int *map;
50 float lightpos[4];
51 Vector lightposv;
52 */
53
54 fprintf(fp,"NETHER EARTH v0.2 Debug Report\n\n");
55
56 fprintf(fp,"MAPW: %i\nMAPH: %i\n",map_w,map_h);
57
58 fprintf(fp,"MAP:\n");
59 for(i=0;i<map_h;i++) {
60 for(j=0;j<map_w;j++) {
61 fprintf(fp,"%i ",map[j+i*map_w]);
62 } /* for */
63 fprintf(fp,"\n");
64 } /* for */
65
66 fprintf(fp,"LIGHTPOS: %.8f %.8f %.8f %.8f\n",lightpos[0],lightpos[1],lightpos[2],lightpos[3]);
67 fprintf(fp,"LIGHTPOSV: ");
68 lightposv.save(fp);
69
70 /*
71 Vector camera,viewp;
72 Vector shipp;
73 bool shiplanded;
74 int ship_op,ship_op2,ship_op3;
75 */
76
77 fprintf(fp,"CAMERA: ");
78 camera.save(fp);
79 fprintf(fp,"VIEWP: ");
80 viewp.save(fp);
81 fprintf(fp,"SHIPP: ");
82 shipp.save(fp);
83 if (shiplanded) fprintf(fp,"SHIP LANDED\n");
84 else fprintf(fp,"SHIP NOT LANDED\n");
85
86 /*
87 List<BUILDING> buildings;
88 List<ROBOT> robots[2];
89 List<BULLET> bullets;
90 List<EXPLOSION> explosions;
91 */
92
93 fprintf(fp,"\nN� OF BUILDINGS: %i\n",buildings.Length());
94 buildings.Rewind();
95 while(buildings.Iterate(b)) {
96 /*
97 int type;
98 Vector pos;
99 int owner;
100 int status;
101 */
102 fprintf(fp,"BUILDING:\n TYPE: %i\n OWNER: %i\n STATUS: %i\n\n",b->type,b->owner,b->status);
103 b->pos.save(fp);
104 } /* while */
105
106 for(i=0;i<2;i++) {
107 fprintf(fp,"\nN� OF ROBOTS PLAYER %i: %i\n",i,robots[i].Length());
108 robots[i].Rewind();
109 while(robots[i].Iterate(r)) {
110 char *tractions[3]={"BIPOD","TRACKS","ANTIGRAV"};
111 char *pieces[5]={"CANNONS","MISSILES","PHASERS","NUCLEAR","ELECTRONICS"};
112 /*
113 int traction;
114 bool pieces[5];
115 int program;
116 int program_parameter;
117 Vector program_goal;
118 int op;
119 bool shipover;
120 int firetimer;
121 int strength;
122 Vector pos;
123 int angle;
124 CMC cmc;
125 */
126 fprintf(fp,"ROBOT:\n");
127 fprintf(fp," %s\n",tractions[r->traction]);
128 for(j=0;j<5;j++) {
129 if (r->pieces[j]) fprintf(fp," %s\n",pieces[j]);
130 } /* for */
131 fprintf(fp," PROGRAM: %i\n PROGRAM PARAMETER: %i\n",r->program,r->program_parameter);
132 fprintf(fp," PROGRAM GOAL: ");
133 r->program_goal.save(fp);
134 fprintf(fp," ACTUAL OPERATOR: %i\n",r->op);
135 if (r->shipover) fprintf(fp," HAS THE SHIP OVER IT\n");
136 else fprintf(fp," DO NOT HAS THE SHIP OVER IT\n");
137 fprintf(fp," FIRETIMER: %i\n STRENGTH: %i\n",r->firetimer,r->strength);
138 fprintf(fp," POSITION: ");
139 r->pos.save(fp);
140 fprintf(fp," ANGLE: %i\n",r->angle);
141 fprintf(fp," MINIMUM CONTAINER BOX: \n");
142 r->cmc.save(fp);
143 fprintf(fp," ELECTRONICS STATE: %i\n CHASSIS STATE: %i\n",r->electronics_state,r->chassis_state);
144 fprintf(fp,"\n");
145 } /* while */
146 } /* for */
147
148 fprintf(fp,"\nN� BULLETS: %i\n",bullets.Length());
149
150 bullets.Rewind();
151 while(bullets.Iterate(bul)) {
152 /*
153 int type;
154 int step;
155 Vector pos;
156 int angle;
157 ROBOT *owner;
158 CMC cmc;
159 */
160 fprintf(fp," BULLET:\n TYPE: %i\n STEP: %i\n ANGLE: %i\n",bul->type,bul->step,bul->angle);
161
162 fprintf(fp," POSITION: ");
163 bul->pos.save(fp);
164 i=robots[0].SearchObjRef(bul->owner);
165 if (i==-1) {
166 i=robots[1].SearchObjRef(bul->owner);
167 fprintf(fp," OWNER: PLAYER 1 ROBOT %i\n",i);
168 } else {
169 fprintf(fp," OWNER: PLAYER 0 ROBOT %i\n",i);
170 } /* if */
171
172 fprintf(fp," MINIMUM CONTAINER BOX: \n");
173 bul->cmc.save(fp);
174 fprintf(fp,"\n");
175 } /* while */
176
177 fprintf(fp,"\nN� EXPLOSIONS %i\n",explosions.Length());
178 explosions.Rewind();
179 while(explosions.Iterate(e)) {
180 /*
181 Vector pos;
182 int step;
183 int size;
184 */
185 fprintf(fp,"EXPLOSION:\n POSITION:\n");
186 e->pos.save(fp);
187 fprintf(fp," STEP: %i\n SIZE: %i\n\n",e->step,e->size);
188 } /* while */
189
190 /*
191 int day,hour,minute,second;
192 int resources[2][7];
193 ROBOT *controlled;
194 */
195
196 fprintf(fp,"\nTIME: DAY %i %i:%i:%i\n",day,hour,minute,second);
197 fprintf(fp,"\nRESOURCES:\n");
198 for(i=0;i<2;i++) {
199 fprintf(fp,"PLAYER %i: ",i);
200 for(j=0;j<7;j++) {
201 fprintf(fp,"%i ",resources[i][j]);
202 } /* for */
203 fprintf(fp,"\n");
204 } /* for */
205 fprintf(fp,"\nROBOT UNDER CONTROL: %i\n",robots[0].SearchObjRef(controlled));
206
207 /*
208 int act_menu;
209 int act_button;
210 */
211 fprintf(fp,"\nMENU %i\nACT BUTTON: %i\n",act_menu,act_button);
212
213 fclose(fp);
214 return true;
215 } /* NETHER::save_debug_report */
216
217
218