/[james]/archive/snapcam/logpositiondata.cs
ViewVC logotype

Contents of /archive/snapcam/logpositiondata.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 18 - (show annotations) (download)
Tue Feb 11 10:33:20 2003 UTC (21 years, 10 months ago) by james
File size: 3153 byte(s)
Initial import.

1 ////////////////////////////////////////////////////////////////////////////////
2 // logpositiondata.cs
3 ////////////////////////////////////////////////////////////////////////////////
4
5 // all global variable and functions are prefixed logpos_
6
7 new fileObject("logpos_file");
8 $logpos_current = 0;
9
10 schedule(1000, 0, logpos_wait_for_start);
11
12 ////////////////////////////////////////////////////////////////////////////////
13
14 function logpos_wait_for_start()
15 {
16 if ($LoadingMission || ClientGroup.getCount() == 0)
17 {
18 schedule(1000, 0, logpos_wait_for_start);
19 return;
20 }
21
22 $logpos_current = $missionSequence;
23 $logpos_flag_count = 0;
24
25 %file = "positiondata/" @ $logpos_current @ "_" @ $CurrentMissionType @ "_" @ $currentMission @ "_";
26 %i = 0;
27 while (isFile(%file @ %i))
28 %i++;
29 logpos_file.openForWrite(%file @ %i);
30
31 logpos_file.writeLine($CurrentMission);
32 logpos_file.writeLine($CurrentMissionType);
33 logpos_file.writeLine($MissionDisplayName);
34 logpos_file.writeLine($MissionTypeDisplayName);
35 logpos_file.writeLine(MissionArea.area);
36 logpos_dump_landmarks(MissionGroup);
37 logpos_file.writeLine("");
38
39 schedule(1000, 0, logpos_write_position_data);
40 }
41
42 ////////////////////////////////////////////////////////////////////////////////
43
44 function logpos_write_position_data()
45 {
46 if ($missionSequence != $logpos_current)
47 {
48 // the mission has ended
49 logpos_file.close();
50
51 schedule(1000, 0, logpos_wait_for_start);
52 return;
53 }
54
55 // flags
56 for (%i = 0; %i != $logpos_flag_count; %i++)
57 {
58 %flag = $logpos_flag[%i];
59 if (%flag.carrier $= "")
60 logpos_file.writeLine("flag " @ %flag.team @ " " @ %flag.position);
61 else
62 logpos_file.writeLine("flag " @ %flag.team @ " " @ %flag.carrier);
63 }
64
65 // players
66 for (%ci = 0; %ci < ClientGroup.getCount(); %ci++)
67 {
68 %client = ClientGroup.getObject(%ci);
69 %data = %client.team @ " " @ %client.player.position @ " " @ %client.nameBase;
70 logpos_file.writeLine(%client.player @ " " @ %data);
71 }
72
73 // terminate each set of position coordinates with a blank line
74 logpos_file.writeLine("");
75
76 schedule(1000, 0, logpos_write_position_data);
77 }
78
79 ////////////////////////////////////////////////////////////////////////////////
80
81 function logpos_dump_landmarks(%group)
82 {
83 for (%i = 0; %i < %group.getCount(); %i++)
84 {
85 %obj = %group.getObject(%i);
86 %type = %obj.getClassName();
87
88 if (%type $= "SimGroup")
89 {
90 logpos_dump_landmarks(%obj);
91 }
92 else if (%type $= "Item" && %obj.dataBlock $= "Flag")
93 {
94 $logpos_flag[$logpos_flag_count] = %obj;
95 $logpos_flag_count++;
96 }
97 else if (%obj.team !$= "")
98 {
99 %data = %type @ " " @ %obj.dataBlock @ " " @ %obj.getName();
100 %data = %data @ " " @ %obj.position @ " " @ %obj.name;
101 logpos_file.writeLine(%obj.team @ " " @ %data);
102 }
103 }
104 }
105
106 ////////////////////////////////////////////////////////////////////////////////
107

  ViewVC Help
Powered by ViewVC 1.1.26