2 #include "cmd/script/mission.h"
3 #include "cmd/script/pythonmission.h"
5 #include "networking/netserver.h"
8 #include "cmd/unit_generic.h"
9 #include "cmd/unit_factory.h"
10 #include "gfx/cockpit_generic.h"
11 #include "cmd/ai/aggressive.h"
12 #include "cmd/ai/script.h"
13 #include "cmd/ai/missionscript.h"
14 #include "cmd/script/flightgroup.h"
15 #include "python/python_class.h"
25 string::size_type newline = pickled.find(
"\n" );
26 if (newline != string::npos)
27 return pickled.substr( newline+1, pickled.length()-(newline+1) );
33 string::size_type newline = pickled.find(
"\n" );
34 return pickled.substr( 0, newline );
41 while ( i < (
int) str.length() ) {
51 str = str.substr( i, str.length()-i );
103 std::string lpd = last_pickled_data;
105 if ( !lpd.empty() ) {
107 for (
unsigned int i = 0; i < nummis; i++) {
109 std::string pickled = lpd.substr( 0, len );
110 lpd = lpd.substr( len, lpd.length()-len );
123 if ( pickled.length() ) {
131 int len = tp.length();
141 if (tmp.length() || i == 0) {
171 if ( (c[0] = *buf) ) {
188 for (
unsigned int i = 0; i < nummissions; i++) {
191 char *temp = (
char*) malloc(
sizeof (
char)*(1+picklelength) );
193 temp[picklelength] = 0;
209 for (
unsigned int i = 0; i < nummissions; i++) {
212 char *temp = (
char*) malloc(
sizeof (
char)*(1+picklelength) );
214 temp[picklelength] = 0;
215 memcpy( temp, buf, picklelength );
231 void LoadMission(
const char *nission_name,
const std::string &script,
bool loadFirstUnit )
233 using namespace VSFileSystem;
235 const char *friendly_mission_name = nission_name;
236 if (nission_name[0] ==
'#') {
238 mission_name = string();
239 friendly_mission_name++;
241 if ( mission_name.empty() )
243 printf(
"%s", script.c_str() );
253 active_missions.push_back(
new Mission( mission_name.c_str(), script ) );
258 char fightername[1024];
259 vector< Flightgroup* >::const_iterator siter;
263 for (siter = fg.begin(); siter != fg.end(); siter++) {
264 Flightgroup *fg = *siter;
265 string fg_name = fg->name;
266 string fullname = fg->type;
267 strncpy( fightername, fullname.c_str(), 1023 );
268 fightername[1023] =
'\0';
271 string ainame = fg->ainame;
272 float fg_radius = 0.0;
273 for (
int s = 0; s < fg->nr_ships; s++) {
276 pox.i = fg->pos.i+s*fg_radius*3;
277 pox.j = fg->pos.i+s*fg_radius*3;
278 pox.k = fg->pos.i+s*fg_radius*3;
279 if (pox.i == pox.j && pox.j == pox.k && pox.k == 0) {
280 pox.i = rand()*10000./RAND_MAX-5000;
281 pox.j = rand()*10000./RAND_MAX-5000;
282 pox.k = rand()*10000./RAND_MAX-5000;
289 string modifications(
"" );
290 if (a != 0 || loadFirstUnit)
291 fighter = UnitFactory::createUnit( fightername,
false, tmptarget, modifications, fg, s );
294 fighter->SetPosAndCumPos( pox );
298 fighter->LoadAIScript( ainame );
314 friendly_mission_name, num-1 );