EditorKlient.cpp 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421
  1. #include "EditorKlient.h"
  2. #include "EditorKarte.h"
  3. #include "Reader.h"
  4. #include <Network.h>
  5. #include <Klient.h>
  6. using namespace Editor;
  7. /*
  8. SpielerTeamStruktur::SpielerTeamStruktur()
  9. {
  10. spielerAnzahl = 0;
  11. teamAnzahl = 0;
  12. spielerFarbe = new Array< int >();
  13. teamFarbe = new Array< int >();
  14. teamName = new RCArray< Text >();
  15. teamSize = new Array< int >();
  16. ref = 1;
  17. }
  18. SpielerTeamStruktur::~SpielerTeamStruktur()
  19. {
  20. spielerFarbe->release();
  21. teamFarbe->release();
  22. teamName->release();
  23. teamSize->release();
  24. }
  25. SpielerTeamStrukturV *SpielerTeamStruktur::getThis()
  26. {
  27. ref++;
  28. return this;
  29. }
  30. SpielerTeamStrukturV *SpielerTeamStruktur::release()
  31. {
  32. ref--;
  33. if( !ref )
  34. delete this;
  35. return 0;
  36. }
  37. // Konstruktor
  38. // k: Der zu verwendende Klient
  39. EditorKlient::EditorKlient( KSGClient::EditorServerClient *k )
  40. : ReferenceCounter()
  41. {
  42. klient = k;
  43. }
  44. // Destruktor
  45. EditorKlient::~EditorKlient()
  46. {
  47. klient->release();
  48. }
  49. // Initialisiert den Server
  50. // return: 1, falls erfolgreich
  51. // 2, falls bereits eine Sitzung existiert
  52. // 0, sonnst
  53. int EditorKlient::init()
  54. {
  55. Network::Klient *k = klient->beginEditorMessage();
  56. if( !k )
  57. {
  58. error = klient->getLetzterFehler();
  59. return 0;
  60. }
  61. error = "";
  62. k->sendeEncrypted( "\x0", 1 );
  63. char ret;
  64. k->getNachrichtEncrypted( &ret, 1 );
  65. if( ret == 1 )
  66. k->getNachrichtEncrypted( &ret, 1 );
  67. if( ret == 3 )
  68. {
  69. unsigned char l = 0;
  70. k->getNachrichtEncrypted( (char *)&l, 1 );
  71. char *err = new char[ (__int64)l + 1 ];
  72. err[ l ] = 0;
  73. k->getNachrichtEncrypted( err, l );
  74. error = err;
  75. delete[] err;
  76. ret = 0;
  77. }
  78. klient->endEditorMessage();
  79. return ret;
  80. }
  81. // Verwirft die vorhandene Sitzung und erstellt eine neue
  82. bool EditorKlient::sitzungVerwerfen()
  83. {
  84. Network::Klient *k = klient->beginEditorMessage();
  85. if( !k )
  86. {
  87. error = klient->getLetzterFehler();
  88. return 0;
  89. }
  90. error = "";
  91. char ret;
  92. k->sendeEncrypted( "\x1", 1 );
  93. k->getNachrichtEncrypted( &ret, 1 );
  94. if( ret == 3 )
  95. {
  96. unsigned char l = 0;
  97. k->getNachrichtEncrypted( (char *)&l, 1 );
  98. char *err = new char[ (__int64)l + 1 ];
  99. err[ l ] = 0;
  100. k->getNachrichtEncrypted( err, l );
  101. error = err;
  102. delete[] err;
  103. ret = 0;
  104. }
  105. klient->endEditorMessage();
  106. return ret == 1;
  107. }
  108. // Speichert Sitzung und beendet Editor
  109. bool EditorKlient::sitzungBeenden()
  110. {
  111. Network::Klient *k = klient->beginEditorMessage();
  112. if( !k )
  113. {
  114. error = klient->getLetzterFehler();
  115. return 0;
  116. }
  117. error = "";
  118. char ret;
  119. k->sendeEncrypted( "\x2", 1 );
  120. k->getNachrichtEncrypted( &ret, 1 );
  121. if( ret == 3 )
  122. {
  123. unsigned char l = 0;
  124. k->getNachrichtEncrypted( (char *)&l, 1 );
  125. char *err = new char[ (__int64)l + 1 ];
  126. err[ l ] = 0;
  127. k->getNachrichtEncrypted( err, l );
  128. error = err;
  129. delete[] err;
  130. ret = 0;
  131. }
  132. klient->endEditorMessage();
  133. return ret == 1;
  134. }
  135. // Lädt die Spieler Team Struktur
  136. bool EditorKlient::getSpielerTeamStruktur( SpielerTeamStrukturV *zSts )
  137. {
  138. return klient->ladeTeamDaten( zSts );
  139. }
  140. bool EditorKlient::loadMapSize( Punkt &size )
  141. {
  142. Network::Klient *k = klient->beginEditorMessage();
  143. if( !k )
  144. {
  145. error = klient->getLetzterFehler();
  146. return 0;
  147. }
  148. error = "";
  149. char ret;
  150. k->sendeEncrypted( "\x3", 1 );
  151. k->getNachrichtEncrypted( &ret, 1 );
  152. if( ret == 1 )
  153. {
  154. k->getNachrichtEncrypted( (char *)&size.x, 4 );
  155. k->getNachrichtEncrypted( (char *)&size.y, 4 );
  156. }
  157. if( ret == 3 )
  158. {
  159. unsigned char l = 0;
  160. k->getNachrichtEncrypted( (char *)&l, 1 );
  161. char *err = new char[ (__int64)l + 1 ];
  162. err[ l ] = 0;
  163. k->getNachrichtEncrypted( err, l );
  164. error = err;
  165. delete[] err;
  166. ret = 0;
  167. }
  168. klient->endEditorMessage();
  169. return ret == 1;
  170. }
  171. bool EditorKlient::loadSpieler( Array< SpielerDaten * > &spieler )
  172. {
  173. Network::Klient *k = klient->beginEditorMessage();
  174. if( !k )
  175. {
  176. error = klient->getLetzterFehler();
  177. return 0;
  178. }
  179. error = "";
  180. char ret;
  181. k->sendeEncrypted( "\x5", 1 );
  182. k->getNachrichtEncrypted( &ret, 1 );
  183. if( ret == 1 )
  184. {
  185. int anz;
  186. k->getNachrichtEncrypted( (char *)&anz, 4 );
  187. for( int i = 0; i < anz; i++ )
  188. {
  189. SpielerDaten *s = new SpielerDaten();
  190. k->getNachrichtEncrypted( (char *)&s->id, 4 );
  191. k->getNachrichtEncrypted( (char *)&s->spawn.x, 4 );
  192. k->getNachrichtEncrypted( (char *)&s->spawn.y, 4 );
  193. spieler.add( s );
  194. }
  195. }
  196. if( ret == 3 )
  197. {
  198. unsigned char l = 0;
  199. k->getNachrichtEncrypted( (char *)&l, 1 );
  200. char *err = new char[ (__int64)l + 1 ];
  201. err[ l ] = 0;
  202. k->getNachrichtEncrypted( err, l );
  203. error = err;
  204. delete[] err;
  205. ret = 0;
  206. }
  207. klient->endEditorMessage();
  208. return ret == 1;
  209. }
  210. bool EditorKlient::loadTeams( Array< TeamDaten * > &teams )
  211. {
  212. Network::Klient *k = klient->beginEditorMessage();
  213. if( !k )
  214. {
  215. error = klient->getLetzterFehler();
  216. return 0;
  217. }
  218. error = "";
  219. char ret;
  220. k->sendeEncrypted( "\x4", 1 );
  221. k->getNachrichtEncrypted( &ret, 1 );
  222. if( ret == 1 )
  223. {
  224. int anz;
  225. k->getNachrichtEncrypted( (char *)&anz, 4 );
  226. for( int i = 0; i < anz; i++ )
  227. {
  228. TeamDaten *t = new TeamDaten();
  229. k->getNachrichtEncrypted( (char *)&t->id, 4 );
  230. k->getNachrichtEncrypted( (char *)&t->maxWbzeit, 4 );
  231. k->getNachrichtEncrypted( (char *)&t->punkte, 4 );
  232. teams.add( t );
  233. }
  234. }
  235. if( ret == 3 )
  236. {
  237. unsigned char l = 0;
  238. k->getNachrichtEncrypted( (char *)&l, 1 );
  239. char *err = new char[ (__int64)l + 1 ];
  240. err[ l ] = 0;
  241. k->getNachrichtEncrypted( err, l );
  242. error = err;
  243. delete[] err;
  244. ret = 0;
  245. }
  246. klient->endEditorMessage();
  247. return ret == 1;
  248. }
  249. bool EditorKlient::loadBarieren( Array< BariereDaten * > &barieren )
  250. {
  251. Network::Klient *k = klient->beginEditorMessage();
  252. if( !k )
  253. {
  254. error = klient->getLetzterFehler();
  255. return 0;
  256. }
  257. error = "";
  258. char ret;
  259. k->sendeEncrypted( "\x6", 1 );
  260. k->getNachrichtEncrypted( &ret, 1 );
  261. if( ret == 1 )
  262. {
  263. int anz;
  264. k->getNachrichtEncrypted( (char *)&anz, 4 );
  265. for( int i = 0; i < anz; i++ )
  266. {
  267. BariereDaten *b = new BariereDaten();
  268. k->getNachrichtEncrypted( (char *)&b->id, 4 );
  269. k->getNachrichtEncrypted( (char *)&b->pos.x, 4 );
  270. k->getNachrichtEncrypted( (char *)&b->pos.y, 4 );
  271. k->getNachrichtEncrypted( (char *)&b->size.x, 4 );
  272. k->getNachrichtEncrypted( (char *)&b->size.y, 4 );
  273. k->getNachrichtEncrypted( (char *)&b->style, 4 );
  274. k->getNachrichtEncrypted( (char *)&b->verschiebungWeite, 4 );
  275. k->getNachrichtEncrypted( (char *)&b->autoSchaltungMaxTime, 4 );
  276. k->getNachrichtEncrypted( (char *)&b->team, 4 );
  277. barieren.add( b );
  278. }
  279. }
  280. if( ret == 3 )
  281. {
  282. unsigned char l = 0;
  283. k->getNachrichtEncrypted( (char *)&l, 1 );
  284. char *err = new char[ (__int64)l + 1 ];
  285. err[ l ] = 0;
  286. k->getNachrichtEncrypted( err, l );
  287. error = err;
  288. delete[] err;
  289. ret = 0;
  290. }
  291. klient->endEditorMessage();
  292. return ret == 1;
  293. }
  294. bool EditorKlient::loadBasen( Array< BaseDaten * > &basen )
  295. {
  296. Network::Klient *k = klient->beginEditorMessage();
  297. if( !k )
  298. {
  299. error = klient->getLetzterFehler();
  300. return 0;
  301. }
  302. error = "";
  303. char ret;
  304. k->sendeEncrypted( "\x7", 1 );
  305. k->getNachrichtEncrypted( &ret, 1 );
  306. if( ret == 1 )
  307. {
  308. int anz;
  309. k->getNachrichtEncrypted( (char *)&anz, 4 );
  310. for( int i = 0; i < anz; i++ )
  311. {
  312. BaseDaten *b = new BaseDaten();
  313. k->getNachrichtEncrypted( (char *)&b->id, 4 );
  314. k->getNachrichtEncrypted( (char *)&b->pos.x, 4 );
  315. k->getNachrichtEncrypted( (char *)&b->pos.y, 4 );
  316. k->getNachrichtEncrypted( (char *)&b->size.x, 4 );
  317. k->getNachrichtEncrypted( (char *)&b->size.y, 4 );
  318. k->getNachrichtEncrypted( (char *)&b->maxTime, 4 );
  319. k->getNachrichtEncrypted( (char *)&b->team, 4 );
  320. k->getNachrichtEncrypted( (char *)&b->showTimer, 1 );
  321. k->getNachrichtEncrypted( (char *)&b->timer.x, 4 );
  322. k->getNachrichtEncrypted( (char *)&b->timer.y, 4 );
  323. k->getNachrichtEncrypted( (char *)&b->timerFarbe, 4 );
  324. basen.add( b );
  325. }
  326. }
  327. if( ret == 3 )
  328. {
  329. unsigned char l = 0;
  330. k->getNachrichtEncrypted( (char *)&l, 1 );
  331. char *err = new char[ (__int64)l + 1 ];
  332. err[ l ] = 0;
  333. k->getNachrichtEncrypted( err, l );
  334. error = err;
  335. delete[] err;
  336. ret = 0;
  337. }
  338. klient->endEditorMessage();
  339. return ret == 1;
  340. }
  341. bool EditorKlient::loadDrops( Array< DropDaten * > &drops )
  342. {
  343. Network::Klient *k = klient->beginEditorMessage();
  344. if( !k )
  345. {
  346. error = klient->getLetzterFehler();
  347. return 0;
  348. }
  349. error = "";
  350. char ret;
  351. k->sendeEncrypted( "\x8", 1 );
  352. k->getNachrichtEncrypted( &ret, 1 );
  353. if( ret == 1 )
  354. {
  355. int anz;
  356. k->getNachrichtEncrypted( (char *)&anz, 4 );
  357. for( int i = 0; i < anz; i++ )
  358. {
  359. DropDaten *d = new DropDaten();
  360. k->getNachrichtEncrypted( (char *)&d->id, 4 );
  361. k->getNachrichtEncrypted( (char *)&d->minPos.x, 4 );
  362. k->getNachrichtEncrypted( (char *)&d->minPos.y, 4 );
  363. k->getNachrichtEncrypted( (char *)&d->maxPos.x, 4 );
  364. k->getNachrichtEncrypted( (char *)&d->maxPos.y, 4 );
  365. k->getNachrichtEncrypted( (char *)&d->maxTime, 4 );
  366. k->getNachrichtEncrypted( (char *)&d->numDrops, 4 );
  367. for( int j = 0; j < ITEMANZAHL; j++ )
  368. k->getNachrichtEncrypted( (char *)&d->wahrscheinlichkeit[ j ], 4 );
  369. unsigned char len;
  370. k->getNachrichtEncrypted( (char *)&len, 1 );
  371. char *name = new char[ (__int64)len + 1 ];
  372. k->getNachrichtEncrypted( name, len );
  373. name[ len ] = 0;
  374. d->name = name;
  375. delete[] name;
  376. drops.add( d );
  377. }
  378. }
  379. if( ret == 3 )
  380. {
  381. unsigned char l = 0;
  382. k->getNachrichtEncrypted( (char *)&l, 1 );
  383. char *err = new char[ (__int64)l + 1 ];
  384. err[ l ] = 0;
  385. k->getNachrichtEncrypted( err, l );
  386. error = err;
  387. delete[] err;
  388. ret = 0;
  389. }
  390. klient->endEditorMessage();
  391. return ret == 1;
  392. }
  393. bool EditorKlient::loadSchalter( Array< SchalterDaten * > &schalter )
  394. {
  395. Network::Klient *k = klient->beginEditorMessage();
  396. if( !k )
  397. {
  398. error = klient->getLetzterFehler();
  399. return 0;
  400. }
  401. error = "";
  402. char ret;
  403. k->sendeEncrypted( "\x9", 1 );
  404. k->getNachrichtEncrypted( &ret, 1 );
  405. if( ret == 1 )
  406. {
  407. int anz;
  408. k->getNachrichtEncrypted( (char *)&anz, 4 );
  409. for( int i = 0; i < anz; i++ )
  410. {
  411. SchalterDaten *s = new SchalterDaten();
  412. k->getNachrichtEncrypted( (char *)&s->id, 4 );
  413. k->getNachrichtEncrypted( (char *)&s->pos.x, 4 );
  414. k->getNachrichtEncrypted( (char *)&s->pos.y, 4 );
  415. k->getNachrichtEncrypted( (char *)&s->size.x, 4 );
  416. k->getNachrichtEncrypted( (char *)&s->size.y, 4 );
  417. k->getNachrichtEncrypted( (char *)&s->aktiv, 1 );
  418. schalter.add( s );
  419. }
  420. }
  421. if( ret == 3 )
  422. {
  423. unsigned char l = 0;
  424. k->getNachrichtEncrypted( (char *)&l, 1 );
  425. char *err = new char[ (__int64)l + 1 ];
  426. err[ l ] = 0;
  427. k->getNachrichtEncrypted( err, l );
  428. error = err;
  429. delete[] err;
  430. ret = 0;
  431. }
  432. klient->endEditorMessage();
  433. return ret == 1;
  434. }
  435. bool EditorKlient::loadSchienen( Array< SchieneDaten * > &schienen )
  436. {
  437. Network::Klient *k = klient->beginEditorMessage();
  438. if( !k )
  439. {
  440. error = klient->getLetzterFehler();
  441. return 0;
  442. }
  443. error = "";
  444. char ret;
  445. k->sendeEncrypted( "\xA", 1 );
  446. k->getNachrichtEncrypted( &ret, 1 );
  447. if( ret == 1 )
  448. {
  449. int anz;
  450. k->getNachrichtEncrypted( (char *)&anz, 4 );
  451. for( int i = 0; i < anz; i++ )
  452. {
  453. SchieneDaten *s = new SchieneDaten();
  454. k->getNachrichtEncrypted( (char *)&s->id, 4 );
  455. k->getNachrichtEncrypted( (char *)&s->pos.x, 4 );
  456. k->getNachrichtEncrypted( (char *)&s->pos.y, 4 );
  457. k->getNachrichtEncrypted( (char *)&s->size.x, 4 );
  458. k->getNachrichtEncrypted( (char *)&s->size.y, 4 );
  459. schienen.add( s );
  460. }
  461. }
  462. if( ret == 3 )
  463. {
  464. unsigned char l = 0;
  465. k->getNachrichtEncrypted( (char *)&l, 1 );
  466. char *err = new char[ (__int64)l + 1 ];
  467. err[ l ] = 0;
  468. k->getNachrichtEncrypted( err, l );
  469. error = err;
  470. delete[] err;
  471. ret = 0;
  472. }
  473. klient->endEditorMessage();
  474. return ret == 1;
  475. }
  476. bool EditorKlient::loadTimer( Array< TimerDaten * > &timer )
  477. {
  478. Network::Klient *k = klient->beginEditorMessage();
  479. if( !k )
  480. {
  481. error = klient->getLetzterFehler();
  482. return 0;
  483. }
  484. error = "";
  485. char ret;
  486. k->sendeEncrypted( "\xB", 1 );
  487. k->getNachrichtEncrypted( &ret, 1 );
  488. if( ret == 1 )
  489. {
  490. int anz;
  491. k->getNachrichtEncrypted( (char *)&anz, 4 );
  492. for( int i = 0; i < anz; i++ )
  493. {
  494. TimerDaten *t = new TimerDaten();
  495. k->getNachrichtEncrypted( (char *)&t->id, 4 );
  496. k->getNachrichtEncrypted( (char *)&t->pos.x, 4 );
  497. k->getNachrichtEncrypted( (char *)&t->pos.y, 4 );
  498. k->getNachrichtEncrypted( (char *)&t->maxZeit, 4 );
  499. k->getNachrichtEncrypted( (char *)&t->sichtbar, 1 );
  500. k->getNachrichtEncrypted( (char *)&t->autoWiederhohlung, 1 );
  501. k->getNachrichtEncrypted( (char *)&t->runns, 1 );
  502. k->getNachrichtEncrypted( (char *)&t->farbe, 4 );
  503. unsigned char len;
  504. k->getNachrichtEncrypted( (char *)&len, 1 );
  505. char *name = new char[ (__int64)len + 1 ];
  506. name[ len ] = 0;
  507. k->getNachrichtEncrypted( name, len );
  508. t->name = name;
  509. delete[]name;
  510. timer.add( t );
  511. }
  512. }
  513. if( ret == 3 )
  514. {
  515. unsigned char l = 0;
  516. k->getNachrichtEncrypted( (char *)&l, 1 );
  517. char *err = new char[ (__int64)l + 1 ];
  518. err[ l ] = 0;
  519. k->getNachrichtEncrypted( err, l );
  520. error = err;
  521. delete[] err;
  522. ret = 0;
  523. }
  524. klient->endEditorMessage();
  525. return ret == 1;
  526. }
  527. bool EditorKlient::loadTunnel( Array< TunnelDaten * > &tunnel )
  528. {
  529. Network::Klient *k = klient->beginEditorMessage();
  530. if( !k )
  531. {
  532. error = klient->getLetzterFehler();
  533. return 0;
  534. }
  535. error = "";
  536. char ret;
  537. k->sendeEncrypted( "\xC", 1 );
  538. k->getNachrichtEncrypted( &ret, 1 );
  539. if( ret == 1 )
  540. {
  541. int anz;
  542. k->getNachrichtEncrypted( (char *)&anz, 4 );
  543. for( int i = 0; i < anz; i++ )
  544. {
  545. TunnelDaten *t = new TunnelDaten();
  546. k->getNachrichtEncrypted( (char *)&t->id, 4 );
  547. k->getNachrichtEncrypted( (char *)&t->pos.x, 4 );
  548. k->getNachrichtEncrypted( (char *)&t->pos.y, 4 );
  549. k->getNachrichtEncrypted( (char *)&t->size.x, 4 );
  550. k->getNachrichtEncrypted( (char *)&t->size.y, 4 );
  551. k->getNachrichtEncrypted( (char *)&t->ziel.x, 4 );
  552. k->getNachrichtEncrypted( (char *)&t->ziel.y, 4 );
  553. k->getNachrichtEncrypted( (char *)&t->aktiv, 1 );
  554. tunnel.add( t );
  555. }
  556. }
  557. if( ret == 3 )
  558. {
  559. unsigned char l = 0;
  560. k->getNachrichtEncrypted( (char *)&l, 1 );
  561. char *err = new char[ (__int64)l + 1 ];
  562. err[ l ] = 0;
  563. k->getNachrichtEncrypted( err, l );
  564. error = err;
  565. delete[] err;
  566. ret = 0;
  567. }
  568. klient->endEditorMessage();
  569. return ret == 1;
  570. }
  571. bool EditorKlient::loadUmlenkung( Array< UmlenkungDaten * > &umlenkung )
  572. {
  573. Network::Klient *k = klient->beginEditorMessage();
  574. if( !k )
  575. {
  576. error = klient->getLetzterFehler();
  577. return 0;
  578. }
  579. error = "";
  580. char ret;
  581. k->sendeEncrypted( "\xD", 1 );
  582. k->getNachrichtEncrypted( &ret, 1 );
  583. if( ret == 1 )
  584. {
  585. int anz;
  586. k->getNachrichtEncrypted( (char *)&anz, 4 );
  587. for( int i = 0; i < anz; i++ )
  588. {
  589. UmlenkungDaten *u = new UmlenkungDaten();
  590. k->getNachrichtEncrypted( (char *)&u->id, 4 );
  591. k->getNachrichtEncrypted( (char *)&u->pos.x, 4 );
  592. k->getNachrichtEncrypted( (char *)&u->pos.y, 4 );
  593. k->getNachrichtEncrypted( (char *)&u->size.x, 4 );
  594. k->getNachrichtEncrypted( (char *)&u->size.y, 4 );
  595. k->getNachrichtEncrypted( (char *)&u->richtung, 1 );
  596. k->getNachrichtEncrypted( (char *)&u->maxAbklingzeit, 4 );
  597. k->getNachrichtEncrypted( (char *)&u->drehend, 1 );
  598. k->getNachrichtEncrypted( (char *)&u->aktiv, 1 );
  599. umlenkung.add( u );
  600. }
  601. }
  602. if( ret == 3 )
  603. {
  604. unsigned char l = 0;
  605. k->getNachrichtEncrypted( (char *)&l, 1 );
  606. char *err = new char[ (__int64)l + 1 ];
  607. err[ l ] = 0;
  608. k->getNachrichtEncrypted( err, l );
  609. error = err;
  610. delete[] err;
  611. ret = 0;
  612. }
  613. klient->endEditorMessage();
  614. return ret == 1;
  615. }
  616. bool EditorKlient::loadTrigger( Array< TriggerDaten * > &trigger )
  617. {
  618. Network::Klient *k = klient->beginEditorMessage();
  619. if( !k )
  620. {
  621. error = klient->getLetzterFehler();
  622. return 0;
  623. }
  624. error = "";
  625. char ret;
  626. k->sendeEncrypted( "\xE", 1 );
  627. k->getNachrichtEncrypted( &ret, 1 );
  628. if( ret == 1 )
  629. {
  630. int anz;
  631. k->getNachrichtEncrypted( (char *)&anz, 4 );
  632. for( int i = 0; i < anz; i++ )
  633. {
  634. TriggerDaten *t = new TriggerDaten();
  635. k->getNachrichtEncrypted( (char *)&t->id, 4 );
  636. unsigned char len;
  637. k->getNachrichtEncrypted( (char *)&len, 1 );
  638. char *name = new char[ (__int64)len + 1 ];
  639. name[ len ] = 0;
  640. k->getNachrichtEncrypted( name, len );
  641. t->name = name;
  642. delete[]name;
  643. int ereignisAnzahl;
  644. int bedingungAnzahl;
  645. int aktionAnzahl;
  646. k->getNachrichtEncrypted( (char *)&ereignisAnzahl, 4 );
  647. k->getNachrichtEncrypted( (char *)&bedingungAnzahl, 4 );
  648. k->getNachrichtEncrypted( (char *)&aktionAnzahl, 4 );
  649. for( int j = 0; j < ereignisAnzahl; j++ )
  650. {
  651. int typ;
  652. k->getNachrichtEncrypted( (char *)&typ, 4 );
  653. t->ereignisse->add( (EreignisTyp)typ );
  654. }
  655. Network::EncryptedNetworkReader reader( k );
  656. for( int j = 0; j < bedingungAnzahl; j++ )
  657. t->bedingungen->add( new Bedingung( MapReader::readAktion( reader ) ) );
  658. for( int j = 0; j < aktionAnzahl; j++ )
  659. t->aktionen->add( MapReader::readAktion( reader ) );
  660. trigger.add( t );
  661. }
  662. }
  663. if( ret == 3 )
  664. {
  665. unsigned char l = 0;
  666. k->getNachrichtEncrypted( (char *)&l, 1 );
  667. char *err = new char[ (__int64)l + 1 ];
  668. err[ l ] = 0;
  669. k->getNachrichtEncrypted( err, l );
  670. error = err;
  671. delete[] err;
  672. ret = 0;
  673. }
  674. klient->endEditorMessage();
  675. return ret == 1;
  676. }
  677. bool EditorKlient::loadVariable( Array< VariableDaten * > &variable )
  678. {
  679. Network::Klient *k = klient->beginEditorMessage();
  680. if( !k )
  681. {
  682. error = klient->getLetzterFehler();
  683. return 0;
  684. }
  685. error = "";
  686. char ret;
  687. k->sendeEncrypted( "\xF", 1 );
  688. k->getNachrichtEncrypted( &ret, 1 );
  689. if( ret == 1 )
  690. {
  691. int anz;
  692. k->getNachrichtEncrypted( (char *)&anz, 4 );
  693. for( int i = 0; i < anz; i++ )
  694. {
  695. VariableDaten *v = new VariableDaten();
  696. unsigned char len;
  697. k->getNachrichtEncrypted( (char *)&len, 1 );
  698. char *name = new char[ (__int64)len + 1 ];
  699. k->getNachrichtEncrypted( name, len );
  700. name[ len ] = 0;
  701. v->oldName = name;
  702. v->name = name;
  703. delete[]name;
  704. char typ;
  705. k->getNachrichtEncrypted( &typ, 1 );
  706. char def;
  707. k->getNachrichtEncrypted( &def, 1 );
  708. if( !def )
  709. v->var = new Variable( NICHTS );
  710. else
  711. {
  712. switch( typ )
  713. {
  714. case NICHTS:
  715. v->var = new Variable( NICHTS );
  716. break;
  717. case INTEGER:
  718. {
  719. int val;
  720. k->getNachrichtEncrypted( (char *)&val, 4 );
  721. v->var = new Integer( val );
  722. break;
  723. }
  724. case BOOLEAN:
  725. {
  726. bool val;
  727. k->getNachrichtEncrypted( (char *)&val, 1 );
  728. v->var = new Boolean( val );
  729. break;
  730. }
  731. case STRING:
  732. {
  733. char len;
  734. k->getNachrichtEncrypted( (char *)&len, 1 );
  735. char *value = new char[ (__int64)len + 1 ];
  736. k->getNachrichtEncrypted( value, len );
  737. value[ (int)len ] = 0;
  738. v->var = new String( value );
  739. delete[] value;
  740. break;
  741. }
  742. case RICHTUNG:
  743. {
  744. char len;
  745. k->getNachrichtEncrypted( (char *)&len, 1 );
  746. char *value = new char[ (__int64)len + 1 ];
  747. k->getNachrichtEncrypted( value, len );
  748. value[ (int)len ] = 0;
  749. v->var = new String( getRichtungFromString( Text( value ) ) );
  750. delete[] value;
  751. break;
  752. }
  753. case FLOAT:
  754. {
  755. float val;
  756. k->getNachrichtEncrypted( (char *)&val, 4 );
  757. v->var = new Float( val );
  758. break;
  759. }
  760. case TASTE:
  761. {
  762. char val;
  763. k->getNachrichtEncrypted( &val, 1 );
  764. v->var = new Integer( val, 1 );
  765. break;
  766. }
  767. case SPIELER:
  768. case TIMER:
  769. case TEAM:
  770. case BARIERE:
  771. case SCHALTER:
  772. case SCHIENE:
  773. case TUNNEL:
  774. case UMLENKUNG:
  775. case TRIGGER:
  776. case BASE:
  777. {
  778. int id;
  779. k->getNachrichtEncrypted( (char *)&id, 4 );
  780. v->var = new Template( (VariableTyp)typ, id );
  781. break;
  782. }
  783. case GEGENSTAND:
  784. {
  785. int id;
  786. k->getNachrichtEncrypted( (char *)&id, 4 );
  787. v->var = new GegenstandTypVar( (GegenstandTyp)id );
  788. break;
  789. }
  790. default:
  791. v->var = new Variable( NICHTS );
  792. }
  793. }
  794. variable.add( v );
  795. }
  796. }
  797. if( ret == 3 )
  798. {
  799. unsigned char l = 0;
  800. k->getNachrichtEncrypted( (char *)&l, 1 );
  801. char *err = new char[ (__int64)l + 1 ];
  802. err[ l ] = 0;
  803. k->getNachrichtEncrypted( err, l );
  804. error = err;
  805. delete[] err;
  806. ret = 0;
  807. }
  808. klient->endEditorMessage();
  809. return ret == 1;
  810. }
  811. bool EditorKlient::saveMapSize( Punkt size )
  812. {
  813. Network::Klient *k = klient->beginEditorMessage();
  814. if( !k )
  815. {
  816. error = klient->getLetzterFehler();
  817. return 0;
  818. }
  819. error = "";
  820. char ret;
  821. k->sendeEncrypted( "\x10", 1 );
  822. k->getNachrichtEncrypted( &ret, 1 );
  823. if( ret == 1 )
  824. {
  825. k->sendeEncrypted( (char *)&size.x, 4 );
  826. k->sendeEncrypted( (char *)&size.y, 4 );
  827. k->getNachrichtEncrypted( &ret, 1 );
  828. }
  829. if( ret == 3 )
  830. {
  831. unsigned char l = 0;
  832. k->getNachrichtEncrypted( (char *)&l, 1 );
  833. char *err = new char[ (__int64)l + 1 ];
  834. err[ l ] = 0;
  835. k->getNachrichtEncrypted( err, l );
  836. error = err;
  837. delete[] err;
  838. ret = 0;
  839. }
  840. klient->endEditorMessage();
  841. return ret == 1;
  842. }
  843. bool EditorKlient::saveTeam( const TeamDaten *team )
  844. {
  845. Network::Klient *k = klient->beginEditorMessage();
  846. if( !k )
  847. {
  848. error = klient->getLetzterFehler();
  849. return 0;
  850. }
  851. error = "";
  852. char ret;
  853. k->sendeEncrypted( "\x11", 1 );
  854. k->getNachrichtEncrypted( &ret, 1 );
  855. if( ret == 1 )
  856. {
  857. k->sendeEncrypted( (char *)&team->id, 4 );
  858. k->getNachrichtEncrypted( &ret, 1 );
  859. if( ret == 1 )
  860. {
  861. k->sendeEncrypted( (char *)&team->maxWbzeit, 4 );
  862. k->sendeEncrypted( (char *)&team->punkte, 4 );
  863. k->getNachrichtEncrypted( &ret, 1 );
  864. }
  865. }
  866. if( ret == 3 )
  867. {
  868. unsigned char l = 0;
  869. k->getNachrichtEncrypted( (char *)&l, 1 );
  870. char *err = new char[ (__int64)l + 1 ];
  871. err[ l ] = 0;
  872. k->getNachrichtEncrypted( err, l );
  873. error = err;
  874. delete[] err;
  875. ret = 0;
  876. }
  877. klient->endEditorMessage();
  878. return ret == 1;
  879. }
  880. bool EditorKlient::saveSpieler( const SpielerDaten *spieler )
  881. {
  882. Network::Klient *k = klient->beginEditorMessage();
  883. if( !k )
  884. {
  885. error = klient->getLetzterFehler();
  886. return 0;
  887. }
  888. error = "";
  889. char ret;
  890. k->sendeEncrypted( "\x12", 1 );
  891. k->getNachrichtEncrypted( &ret, 1 );
  892. if( ret == 1 )
  893. {
  894. k->sendeEncrypted( (char *)&spieler->id, 4 );
  895. k->getNachrichtEncrypted( &ret, 1 );
  896. if( ret == 1 )
  897. {
  898. k->sendeEncrypted( (char *)&spieler->spawn.x, 4 );
  899. k->sendeEncrypted( (char *)&spieler->spawn.y, 4 );
  900. k->getNachrichtEncrypted( &ret, 1 );
  901. }
  902. }
  903. if( ret == 3 )
  904. {
  905. unsigned char l = 0;
  906. k->getNachrichtEncrypted( (char *)&l, 1 );
  907. char *err = new char[ (__int64)l + 1 ];
  908. err[ l ] = 0;
  909. k->getNachrichtEncrypted( err, l );
  910. error = err;
  911. delete[] err;
  912. ret = 0;
  913. }
  914. klient->endEditorMessage();
  915. return ret == 1;
  916. }
  917. bool EditorKlient::saveBariere( const BariereDaten *bariere )
  918. {
  919. Network::Klient *k = klient->beginEditorMessage();
  920. if( !k )
  921. {
  922. error = klient->getLetzterFehler();
  923. return 0;
  924. }
  925. error = "";
  926. char ret;
  927. k->sendeEncrypted( "\x13", 1 );
  928. k->getNachrichtEncrypted( &ret, 1 );
  929. if( ret == 1 )
  930. {
  931. k->sendeEncrypted( (char *)&bariere->id, 4 );
  932. k->getNachrichtEncrypted( &ret, 1 );
  933. if( ret == 1 )
  934. {
  935. k->sendeEncrypted( (char *)&bariere->pos.x, 4 );
  936. k->sendeEncrypted( (char *)&bariere->pos.y, 4 );
  937. k->sendeEncrypted( (char *)&bariere->size.x, 4 );
  938. k->sendeEncrypted( (char *)&bariere->size.y, 4 );
  939. k->sendeEncrypted( (char *)&bariere->style, 4 );
  940. k->sendeEncrypted( (char *)&bariere->verschiebungWeite, 4 );
  941. k->sendeEncrypted( (char *)&bariere->autoSchaltungMaxTime, 4 );
  942. k->sendeEncrypted( (char *)&bariere->team, 4 );
  943. k->getNachrichtEncrypted( &ret, 1 );
  944. }
  945. }
  946. if( ret == 3 )
  947. {
  948. unsigned char l = 0;
  949. k->getNachrichtEncrypted( (char *)&l, 1 );
  950. char *err = new char[ (__int64)l + 1 ];
  951. err[ l ] = 0;
  952. k->getNachrichtEncrypted( err, l );
  953. error = err;
  954. delete[] err;
  955. ret = 0;
  956. }
  957. klient->endEditorMessage();
  958. return ret == 1;
  959. }
  960. bool EditorKlient::saveBase( const BaseDaten *base )
  961. {
  962. Network::Klient *k = klient->beginEditorMessage();
  963. if( !k )
  964. {
  965. error = klient->getLetzterFehler();
  966. return 0;
  967. }
  968. error = "";
  969. char ret;
  970. k->sendeEncrypted( "\x14", 1 );
  971. k->getNachrichtEncrypted( &ret, 1 );
  972. if( ret == 1 )
  973. {
  974. k->sendeEncrypted( (char *)&base->id, 4 );
  975. k->getNachrichtEncrypted( &ret, 1 );
  976. if( ret == 1 )
  977. {
  978. k->sendeEncrypted( (char *)&base->pos.x, 4 );
  979. k->sendeEncrypted( (char *)&base->pos.y, 4 );
  980. k->sendeEncrypted( (char *)&base->size.x, 4 );
  981. k->sendeEncrypted( (char *)&base->size.y, 4 );
  982. k->sendeEncrypted( (char *)&base->maxTime, 4 );
  983. k->sendeEncrypted( (char *)&base->team, 4 );
  984. k->sendeEncrypted( (char *)&base->showTimer, 1 );
  985. k->sendeEncrypted( (char *)&base->timer.x, 4 );
  986. k->sendeEncrypted( (char *)&base->timer.y, 4 );
  987. k->sendeEncrypted( (char *)&base->timerFarbe, 4 );
  988. k->getNachrichtEncrypted( &ret, 1 );
  989. }
  990. }
  991. if( ret == 3 )
  992. {
  993. unsigned char l = 0;
  994. k->getNachrichtEncrypted( (char *)&l, 1 );
  995. char *err = new char[ (__int64)l + 1 ];
  996. err[ l ] = 0;
  997. k->getNachrichtEncrypted( err, l );
  998. error = err;
  999. delete[] err;
  1000. ret = 0;
  1001. }
  1002. klient->endEditorMessage();
  1003. return ret == 1;
  1004. }
  1005. bool EditorKlient::saveDrop( const DropDaten *drop )
  1006. {
  1007. Network::Klient *k = klient->beginEditorMessage();
  1008. if( !k )
  1009. {
  1010. error = klient->getLetzterFehler();
  1011. return 0;
  1012. }
  1013. error = "";
  1014. char ret;
  1015. k->sendeEncrypted( "\x15", 1 );
  1016. k->getNachrichtEncrypted( &ret, 1 );
  1017. if( ret == 1 )
  1018. {
  1019. k->sendeEncrypted( (char *)&drop->id, 4 );
  1020. k->getNachrichtEncrypted( &ret, 1 );
  1021. if( ret == 1 )
  1022. {
  1023. k->sendeEncrypted( (char *)&drop->minPos.x, 4 );
  1024. k->sendeEncrypted( (char *)&drop->minPos.y, 4 );
  1025. k->sendeEncrypted( (char *)&drop->maxPos.x, 4 );
  1026. k->sendeEncrypted( (char *)&drop->maxPos.y, 4 );
  1027. k->sendeEncrypted( (char *)&drop->maxTime, 4 );
  1028. k->sendeEncrypted( (char *)&drop->numDrops, 4 );
  1029. for( int j = 0; j < ITEMANZAHL; j++ )
  1030. k->sendeEncrypted( (char *)&drop->wahrscheinlichkeit[ j ], 4 );
  1031. unsigned char len = (unsigned char)drop->name.getLength();
  1032. k->sendeEncrypted( (char *)&len, 1 );
  1033. k->sendeEncrypted( drop->name, len );
  1034. k->getNachrichtEncrypted( &ret, 1 );
  1035. }
  1036. }
  1037. if( ret == 3 )
  1038. {
  1039. unsigned char l = 0;
  1040. k->getNachrichtEncrypted( (char *)&l, 1 );
  1041. char *err = new char[ (__int64)l + 1 ];
  1042. err[ l ] = 0;
  1043. k->getNachrichtEncrypted( err, l );
  1044. error = err;
  1045. delete[] err;
  1046. ret = 0;
  1047. }
  1048. klient->endEditorMessage();
  1049. return ret == 1;
  1050. }
  1051. bool EditorKlient::saveSchalter( const SchalterDaten *schalter )
  1052. {
  1053. Network::Klient *k = klient->beginEditorMessage();
  1054. if( !k )
  1055. {
  1056. error = klient->getLetzterFehler();
  1057. return 0;
  1058. }
  1059. error = "";
  1060. char ret;
  1061. k->sendeEncrypted( "\x16", 1 );
  1062. k->getNachrichtEncrypted( &ret, 1 );
  1063. if( ret == 1 )
  1064. {
  1065. k->sendeEncrypted( (char *)&schalter->id, 4 );
  1066. k->getNachrichtEncrypted( &ret, 1 );
  1067. if( ret == 1 )
  1068. {
  1069. k->sendeEncrypted( (char *)&schalter->pos.x, 4 );
  1070. k->sendeEncrypted( (char *)&schalter->pos.y, 4 );
  1071. k->sendeEncrypted( (char *)&schalter->size.x, 4 );
  1072. k->sendeEncrypted( (char *)&schalter->size.y, 4 );
  1073. k->sendeEncrypted( (char *)&schalter->aktiv, 1 );
  1074. k->getNachrichtEncrypted( &ret, 1 );
  1075. }
  1076. }
  1077. if( ret == 3 )
  1078. {
  1079. unsigned char l = 0;
  1080. k->getNachrichtEncrypted( (char *)&l, 1 );
  1081. char *err = new char[ (__int64)l + 1 ];
  1082. err[ l ] = 0;
  1083. k->getNachrichtEncrypted( err, l );
  1084. error = err;
  1085. delete[] err;
  1086. ret = 0;
  1087. }
  1088. klient->endEditorMessage();
  1089. return ret == 1;
  1090. }
  1091. bool EditorKlient::saveSchiene( const SchieneDaten *schiene )
  1092. {
  1093. Network::Klient *k = klient->beginEditorMessage();
  1094. if( !k )
  1095. {
  1096. error = klient->getLetzterFehler();
  1097. return 0;
  1098. }
  1099. error = "";
  1100. char ret;
  1101. k->sendeEncrypted( "\x17", 1 );
  1102. k->getNachrichtEncrypted( &ret, 1 );
  1103. if( ret == 1 )
  1104. {
  1105. k->sendeEncrypted( (char *)&schiene->id, 4 );
  1106. k->getNachrichtEncrypted( &ret, 1 );
  1107. if( ret == 1 )
  1108. {
  1109. k->sendeEncrypted( (char *)&schiene->pos.x, 4 );
  1110. k->sendeEncrypted( (char *)&schiene->pos.y, 4 );
  1111. k->sendeEncrypted( (char *)&schiene->size.x, 4 );
  1112. k->sendeEncrypted( (char *)&schiene->size.y, 4 );
  1113. k->getNachrichtEncrypted( &ret, 1 );
  1114. }
  1115. }
  1116. if( ret == 3 )
  1117. {
  1118. unsigned char l = 0;
  1119. k->getNachrichtEncrypted( (char *)&l, 1 );
  1120. char *err = new char[ (__int64)l + 1 ];
  1121. err[ l ] = 0;
  1122. k->getNachrichtEncrypted( err, l );
  1123. error = err;
  1124. delete[] err;
  1125. ret = 0;
  1126. }
  1127. klient->endEditorMessage();
  1128. return ret == 1;
  1129. }
  1130. bool EditorKlient::saveTimer( const TimerDaten *timer )
  1131. {
  1132. Network::Klient *k = klient->beginEditorMessage();
  1133. if( !k )
  1134. {
  1135. error = klient->getLetzterFehler();
  1136. return 0;
  1137. }
  1138. error = "";
  1139. char ret;
  1140. k->sendeEncrypted( "\x18", 1 );
  1141. k->getNachrichtEncrypted( &ret, 1 );
  1142. if( ret == 1 )
  1143. {
  1144. k->sendeEncrypted( (char *)&timer->id, 4 );
  1145. k->getNachrichtEncrypted( &ret, 1 );
  1146. if( ret == 1 )
  1147. {
  1148. k->sendeEncrypted( (char *)&timer->pos.x, 4 );
  1149. k->sendeEncrypted( (char *)&timer->pos.y, 4 );
  1150. k->sendeEncrypted( (char *)&timer->maxZeit, 4 );
  1151. k->sendeEncrypted( (char *)&timer->sichtbar, 1 );
  1152. k->sendeEncrypted( (char *)&timer->autoWiederhohlung, 1 );
  1153. k->sendeEncrypted( (char *)&timer->runns, 1 );
  1154. k->sendeEncrypted( (char *)&timer->farbe, 4 );
  1155. unsigned char len = (unsigned char)timer->name.getLength();
  1156. k->sendeEncrypted( (char *)&len, 1 );
  1157. k->sendeEncrypted( timer->name, len );
  1158. k->getNachrichtEncrypted( &ret, 1 );
  1159. }
  1160. }
  1161. if( ret == 3 )
  1162. {
  1163. unsigned char l = 0;
  1164. k->getNachrichtEncrypted( (char *)&l, 1 );
  1165. char *err = new char[ (__int64)l + 1 ];
  1166. err[ l ] = 0;
  1167. k->getNachrichtEncrypted( err, l );
  1168. error = err;
  1169. delete[] err;
  1170. ret = 0;
  1171. }
  1172. klient->endEditorMessage();
  1173. return ret == 1;
  1174. }
  1175. bool EditorKlient::saveTunnel( const TunnelDaten *tunnel )
  1176. {
  1177. Network::Klient *k = klient->beginEditorMessage();
  1178. if( !k )
  1179. {
  1180. error = klient->getLetzterFehler();
  1181. return 0;
  1182. }
  1183. error = "";
  1184. char ret;
  1185. k->sendeEncrypted( "\x19", 1 );
  1186. k->getNachrichtEncrypted( &ret, 1 );
  1187. if( ret == 1 )
  1188. {
  1189. k->sendeEncrypted( (char *)&tunnel->id, 4 );
  1190. k->getNachrichtEncrypted( &ret, 1 );
  1191. if( ret == 1 )
  1192. {
  1193. k->sendeEncrypted( (char *)&tunnel->pos.x, 4 );
  1194. k->sendeEncrypted( (char *)&tunnel->pos.y, 4 );
  1195. k->sendeEncrypted( (char *)&tunnel->size.x, 4 );
  1196. k->sendeEncrypted( (char *)&tunnel->size.y, 4 );
  1197. k->sendeEncrypted( (char *)&tunnel->ziel.x, 4 );
  1198. k->sendeEncrypted( (char *)&tunnel->ziel.y, 4 );
  1199. k->sendeEncrypted( (char *)&tunnel->aktiv, 1 );
  1200. k->getNachrichtEncrypted( &ret, 1 );
  1201. }
  1202. }
  1203. if( ret == 3 )
  1204. {
  1205. unsigned char l = 0;
  1206. k->getNachrichtEncrypted( (char *)&l, 1 );
  1207. char *err = new char[ (__int64)l + 1 ];
  1208. err[ l ] = 0;
  1209. k->getNachrichtEncrypted( err, l );
  1210. error = err;
  1211. delete[] err;
  1212. ret = 0;
  1213. }
  1214. klient->endEditorMessage();
  1215. return ret == 1;
  1216. }
  1217. bool EditorKlient::saveUmlenkung( const UmlenkungDaten *umlenkung )
  1218. {
  1219. Network::Klient *k = klient->beginEditorMessage();
  1220. if( !k )
  1221. {
  1222. error = klient->getLetzterFehler();
  1223. return 0;
  1224. }
  1225. error = "";
  1226. char ret;
  1227. k->sendeEncrypted( "\x1A", 1 );
  1228. k->getNachrichtEncrypted( &ret, 1 );
  1229. if( ret == 1 )
  1230. {
  1231. k->sendeEncrypted( (char *)&umlenkung->id, 4 );
  1232. k->getNachrichtEncrypted( &ret, 1 );
  1233. if( ret == 1 )
  1234. {
  1235. k->sendeEncrypted( (char *)&umlenkung->pos.x, 4 );
  1236. k->sendeEncrypted( (char *)&umlenkung->pos.y, 4 );
  1237. k->sendeEncrypted( (char *)&umlenkung->size.x, 4 );
  1238. k->sendeEncrypted( (char *)&umlenkung->size.y, 4 );
  1239. k->sendeEncrypted( (char *)&umlenkung->richtung, 1 );
  1240. k->sendeEncrypted( (char *)&umlenkung->maxAbklingzeit, 4 );
  1241. k->sendeEncrypted( (char *)&umlenkung->drehend, 1 );
  1242. k->sendeEncrypted( (char *)&umlenkung->aktiv, 1 );
  1243. k->getNachrichtEncrypted( &ret, 1 );
  1244. }
  1245. }
  1246. if( ret == 3 )
  1247. {
  1248. unsigned char l = 0;
  1249. k->getNachrichtEncrypted( (char *)&l, 1 );
  1250. char *err = new char[ (__int64)l + 1 ];
  1251. err[ l ] = 0;
  1252. k->getNachrichtEncrypted( err, l );
  1253. error = err;
  1254. delete[] err;
  1255. ret = 0;
  1256. }
  1257. klient->endEditorMessage();
  1258. return ret == 1;
  1259. }
  1260. bool EditorKlient::saveTrigger( const TriggerDaten *trigger )
  1261. {
  1262. Network::Klient *k = klient->beginEditorMessage();
  1263. if( !k )
  1264. {
  1265. error = klient->getLetzterFehler();
  1266. return 0;
  1267. }
  1268. error = "";
  1269. char ret;
  1270. k->sendeEncrypted( "\x1B", 1 );
  1271. k->getNachrichtEncrypted( &ret, 1 );
  1272. if( ret == 1 )
  1273. {
  1274. k->sendeEncrypted( (char *)&trigger->id, 4 );
  1275. k->getNachrichtEncrypted( &ret, 1 );
  1276. if( ret == 1 )
  1277. {
  1278. unsigned char len = (unsigned char)trigger->name.getLength();
  1279. k->sendeEncrypted( (char *)&len, 1 );
  1280. k->sendeEncrypted( trigger->name, len );
  1281. int ereignisAnzahl = trigger->ereignisse->getEintragAnzahl();
  1282. int bedingungAnzahl = trigger->bedingungen->getEintragAnzahl();
  1283. int aktionAnzahl = trigger->aktionen->getEintragAnzahl();
  1284. k->sendeEncrypted( (char *)&ereignisAnzahl, 4 );
  1285. k->sendeEncrypted( (char *)&bedingungAnzahl, 4 );
  1286. k->sendeEncrypted( (char *)&aktionAnzahl, 4 );
  1287. for( int j = 0; j < ereignisAnzahl; j++ )
  1288. {
  1289. int typ = (int)trigger->ereignisse->get( j );
  1290. k->sendeEncrypted( (char *)&typ, 4 );
  1291. }
  1292. Network::EncryptedNetworkWriter writer( k );
  1293. for( int j = 0; j < bedingungAnzahl; j++ )
  1294. MapReader::writeAktion( trigger->bedingungen->z( j )->zExpression(), writer );
  1295. for( int j = 0; j < aktionAnzahl; j++ )
  1296. MapReader::writeAktion( trigger->aktionen->z( j ), writer );
  1297. k->getNachrichtEncrypted( &ret, 1 );
  1298. }
  1299. }
  1300. if( ret == 3 )
  1301. {
  1302. unsigned char l = 0;
  1303. k->getNachrichtEncrypted( (char *)&l, 1 );
  1304. char *err = new char[ (__int64)l + 1 ];
  1305. err[ l ] = 0;
  1306. k->getNachrichtEncrypted( err, l );
  1307. error = err;
  1308. delete[] err;
  1309. ret = 0;
  1310. }
  1311. klient->endEditorMessage();
  1312. return ret == 1;
  1313. }
  1314. bool EditorKlient::saveVariable( const VariableDaten *variable )
  1315. {
  1316. return 0;
  1317. }
  1318. bool EditorKlient::deleteBariere( int id )
  1319. {
  1320. return 0;
  1321. }
  1322. bool EditorKlient::deleteBase( int id )
  1323. {
  1324. return 0;
  1325. }
  1326. bool EditorKlient::deleteDrop( int id )
  1327. {
  1328. return 0;
  1329. }
  1330. bool EditorKlient::deleteSchalter( int id )
  1331. {
  1332. return 0;
  1333. }
  1334. bool EditorKlient::deleteSchiene( int id )
  1335. {
  1336. return 0;
  1337. }
  1338. bool EditorKlient::deleteTimer( int id )
  1339. {
  1340. return 0;
  1341. }
  1342. bool EditorKlient::deleteTunnel( int id )
  1343. {
  1344. return 0;
  1345. }
  1346. bool EditorKlient::deleteUmlenkung( int id )
  1347. {
  1348. return 0;
  1349. }
  1350. bool EditorKlient::deleteTrigger( int id )
  1351. {
  1352. return 0;
  1353. }
  1354. bool EditorKlient::deleteVariable( int id )
  1355. {
  1356. return 0;
  1357. }
  1358. // Gibt den Letzten Fehler zurück
  1359. char *EditorKlient::getLastError() const
  1360. {
  1361. return error;
  1362. }*/