MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / OnAddNewRobot

Method OnAddNewRobot

editor/WorldObjectsRobotDialog.cpp:111–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109// CWorldObjectsRobotDialog message handlers
110
111void CWorldObjectsRobotDialog::OnAddNewRobot() {
112#if 0 // LGT: undeclared symbols
113 char filename[255];
114 char cur_name[100];
115 int img_handle;
116 int robot_handle;
117 int c=1,finding_name=1;
118
119 if (!Network_up)
120 {
121 OutrageMessageBox ("Sorry babe, the network is down. This action is a no-no.\n");
122 return;
123 }
124
125 // Get the filename of the representing image
126
127 CString filter = "Descent III files (*.pof,*.oof)|*.pof;*.oof||";
128
129 CFileDialog dlg_open(TRUE, 0,0, OFN_FILEMUSTEXIST, (LPCTSTR)filter, this);
130
131 if (dlg_open.DoModal() == IDCANCEL) return;
132
133// Okay, we selected a file. Lets do what needs to be done here.
134
135 strcpy (filename,dlg_open.GetPathName());
136 img_handle=LoadRobotImage (filename);
137
138 if (img_handle<0)
139 {
140 OutrageMessageBox ("Couldn't open that model file.");
141 return;
142 }
143
144 // Alloc a robot and give a name not already taken by some other robot
145
146 robot_handle=AllocRobot();
147
148 while (finding_name)
149 {
150 // sprintf (cur_name,"%s%d",dlg_open.GetFileName(),c); // LGT: CString not char*
151 if (FindRobotName (cur_name)!=-1)
152 c++;
153 else
154 finding_name=0;
155 }
156
157 strcpy (Robots[robot_handle].name,cur_name);
158
159 Robots[robot_handle].render_handle=img_handle;
160
161 // figure out size of robot
162 vector size_vec;
163 float size;
164
165 size_vec=Poly_models[img_handle].mins-Poly_models[img_handle].maxs;
166 size=vm_GetMagnitude (&size_vec);
167 Robots[robot_handle].size=size/2;
168

Callers

nothing calls this directly

Calls 5

OutrageMessageBoxFunction · 0.85
cf_CopyFileFunction · 0.85
mng_AllocTrackLockFunction · 0.85
vm_GetMagnitudeFunction · 0.50
DoModalMethod · 0.45

Tested by

no test coverage detected