EditorK.cpp 84 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909
  1. #include "../KSGKlient.h"
  2. #include "../KSGServer.h"
  3. #include <Datei.h>
  4. #include "../../Global/Variablen.h"
  5. #include <GSLDateiV.h>
  6. #include "../Keys.h"
  7. #include <Globals.h>
  8. typedef GSL::GSLDateiV *( *GetGSLDatei )( );
  9. class DownloadSound : public GSL::GSLSoundV
  10. {
  11. private:
  12. bool istM;
  13. int sample;
  14. __int64 län;
  15. Klient *k;
  16. FBalken *f;
  17. int ref;
  18. public:
  19. // Konstruktor
  20. DownloadSound( Klient *zK, FBalken *zF )
  21. {
  22. k = zK;
  23. f = zF;
  24. ref = 1;
  25. }
  26. // nicht constant
  27. // GSL
  28. void playSound() override
  29. {}
  30. void setPause( bool p ) override
  31. {}
  32. void stopSound() override
  33. {}
  34. void warteAufSound( int zeit ) override
  35. {}
  36. // Lautstärke: 0 - 0xFFFF
  37. void setVolume( unsigned int links, unsigned int rechts ) override
  38. {}
  39. // zum Speichern
  40. void open() override
  41. {
  42. char m = 0;
  43. k->getNachrichtEncrypted( &m, 1 );
  44. istM = ( m == 1 );
  45. sample = 0;
  46. k->getNachrichtEncrypted( (char*)&sample, 4 );
  47. län = 0;
  48. k->getNachrichtEncrypted( (char*)&län, 8 );
  49. f->setAktionAnzahl( län );
  50. }
  51. int getDaten( char *buffer, int län ) override
  52. {
  53. int l = län < this->län ? län : ( int )this->län;
  54. if( !l )
  55. return -1;
  56. k->getNachricht( buffer, l );
  57. this->län -= l;
  58. f->aktionPlus( l );
  59. return l;
  60. }
  61. void close() override
  62. {}
  63. bool istMono() const override
  64. {
  65. return istM;
  66. }
  67. int getSampleRate() const override
  68. {
  69. return sample;
  70. }
  71. __int64 getDatLength() const override
  72. {
  73. return län;
  74. }
  75. // Reference Counting
  76. GSL::GSLSoundV *getThis() override
  77. {
  78. ref++;
  79. return this;
  80. }
  81. GSL::GSLSoundV *release() override
  82. {
  83. ref--;
  84. if( !ref )
  85. delete this;
  86. return 0;
  87. }
  88. };
  89. // Inhalt der EditorKlient Klasse aus KSGKlient.h
  90. // Konstruktor
  91. EditorKlient::EditorKlient()
  92. {
  93. verbunden = 0;
  94. klient = 0;
  95. fehler = new Text( "" );
  96. klientId = getKlientId();
  97. ref = 1;
  98. }
  99. // Destruktor
  100. EditorKlient::~EditorKlient()
  101. {
  102. cs.lock();
  103. if( verbunden )
  104. trenne();
  105. fehler = fehler->release();
  106. cs.unlock();
  107. }
  108. // nicht constant
  109. bool EditorKlient::verbinde( unsigned short port, char *ip ) // verbindet ich mit dem Editor Server
  110. {
  111. if( klient && verbunden && klient->getServerPort() == port && Text( ip ).istGleich( klient->getServerIp() ) )
  112. return 1;
  113. if( klient || verbunden )
  114. trenne();
  115. klient = new Klient();
  116. Framework::logLine( ( ( Text( "Zugeteilter Editor Server:" ) += ip ) += ":" ) += port );
  117. Framework::logLine( "Verbinung mit Editor Server wird hergestellt..." );
  118. int keyLen = 0;
  119. char *key = 0;
  120. Keys::getServerKey( &key, keyLen, Keys::EDITOR, Keys::SENDEN );
  121. klient->setSendeKey( key, keyLen );
  122. delete[] key;
  123. Keys::getServerKey( &key, keyLen, Keys::EDITOR, Keys::EMPFANGEN );
  124. klient->setEmpfangKey( key, keyLen );
  125. delete[] key;
  126. if( !klient->verbinde( (unsigned short)port, ip ) )
  127. {
  128. Framework::logLine( "ERROR: Server nicht erreichbar." );
  129. klient = klient->release();
  130. fehler->setText( "Fehler beim verbinden mit dem Editor Server." );
  131. return 0;
  132. }
  133. klient->sendeEncrypted( "\1", 1 );
  134. klient->sendeEncrypted( (char*)&klientId, 4 );
  135. char ret = 0;
  136. klient->getNachrichtEncrypted( &ret, 1 );
  137. if( ret == 3 )
  138. {
  139. char län = 0;
  140. klient->getNachrichtEncrypted( &län, 1 );
  141. char *nachricht = new char[ län + 1 ];
  142. nachricht[ län ] = 0;
  143. klient->getNachrichtEncrypted( nachricht, län );
  144. fehler->setText( nachricht );
  145. Framework::logLine( Text( "ERROR: " ) += nachricht );
  146. delete[]nachricht;
  147. trenne();
  148. return 0;
  149. }
  150. if( ret == 1 )
  151. {
  152. char *sl = 0;
  153. char slLän = getSchlüssel( &sl );
  154. klient->setSendeKey( sl, slLän );
  155. klient->setEmpfangKey( sl, slLän );
  156. delete[] sl;
  157. verbunden = 1;
  158. }
  159. Framework::logLine( "Erfolgreich mit Editor Server verbunden." );
  160. return 1;
  161. }
  162. bool EditorKlient::karteErstellen( Text *zName, int spielArt ) // Erstellt eine neue Karte
  163. {
  164. cs.lock();
  165. if( !verbunden )
  166. {
  167. cs.unlock();
  168. return 0;
  169. }
  170. klient->sendeEncrypted( "\xA", 1 );
  171. char ret = 0;
  172. klient->getNachrichtEncrypted( &ret, 1 );
  173. if( ret == 1 )
  174. {
  175. char l = (char)zName->getLength();
  176. klient->sendeEncrypted( &l, 1 );
  177. klient->sendeEncrypted( zName->getText(), l );
  178. klient->sendeEncrypted( (char*)&spielArt, 4 );
  179. klient->getNachrichtEncrypted( &ret, 1 );
  180. }
  181. if( ret == 3 )
  182. {
  183. char byte = 0;
  184. klient->getNachrichtEncrypted( &byte, 1 );
  185. char *f = new char[ byte + 1 ];
  186. f[ byte ] = 0;
  187. klient->getNachrichtEncrypted( f, byte );
  188. fehler->setText( f );
  189. delete[] f;
  190. cs.unlock();
  191. return 0;
  192. }
  193. cs.unlock();
  194. return 0;
  195. }
  196. bool EditorKlient::ladeKarte( int id ) // lädt eine bestimmte Karte
  197. {
  198. cs.lock();
  199. if( !verbunden )
  200. {
  201. cs.unlock();
  202. return 0;
  203. }
  204. klient->sendeEncrypted( "\x6", 1 );
  205. char ret = 0;
  206. klient->getNachrichtEncrypted( &ret, 1 );
  207. if( ret == 1 )
  208. {
  209. klient->sendeEncrypted( (char*)&id, 4 );
  210. klient->getNachrichtEncrypted( &ret, 1 );
  211. }
  212. if( ret == 3 )
  213. {
  214. char byte = 0;
  215. klient->getNachrichtEncrypted( &byte, 1 );
  216. char *f = new char[ byte + 1 ];
  217. f[ byte ] = 0;
  218. klient->getNachrichtEncrypted( f, byte );
  219. fehler->setText( f );
  220. delete[] f;
  221. cs.unlock();
  222. return 0;
  223. }
  224. cs.unlock();
  225. return 1;
  226. }
  227. int EditorKlient::getAbbildListe( RCArray< Text > *name, RCArray< Zeit > *datum )
  228. {
  229. cs.lock();
  230. if( !verbunden )
  231. {
  232. cs.unlock();
  233. return 0;
  234. }
  235. klient->sendeEncrypted( "\x7", 1 );
  236. char ret = 0;
  237. klient->getNachrichtEncrypted( &ret, 1 );
  238. if( ret == 1 )
  239. {
  240. klient->sendeEncrypted( "\x5", 1 );
  241. klient->getNachrichtEncrypted( &ret, 1 );
  242. if( ret == 1 )
  243. {
  244. int anz = 0;
  245. klient->getNachrichtEncrypted( (char*)&anz, 4 );
  246. for( int i = 0; i < anz; i++ )
  247. {
  248. char l = 0;
  249. klient->getNachrichtEncrypted( &l, 1 );
  250. char *n = new char[ l + 1 ];
  251. n[ l ] = 0;
  252. klient->getNachrichtEncrypted( n, l );
  253. name->set( new Text( n ), i );
  254. delete[] n;
  255. Zeit *dat = new Zeit();
  256. int d = 0;
  257. klient->getNachrichtEncrypted( (char*)&d, 4 );
  258. dat->setJahr( d );
  259. klient->getNachrichtEncrypted( (char*)&d, 4 );
  260. dat->setMonat( d );
  261. klient->getNachrichtEncrypted( (char*)&d, 4 );
  262. dat->setTag( d );
  263. klient->getNachrichtEncrypted( (char*)&d, 4 );
  264. dat->setStunde( d );
  265. klient->getNachrichtEncrypted( (char*)&d, 4 );
  266. dat->setMinute( d );
  267. klient->getNachrichtEncrypted( (char*)&d, 4 );
  268. dat->setSekunde( d );
  269. datum->set( dat, i );
  270. }
  271. cs.unlock();
  272. return anz;
  273. }
  274. }
  275. if( ret == 3 )
  276. {
  277. char byte = 0;
  278. klient->getNachrichtEncrypted( &byte, 1 );
  279. char *f = new char[ byte + 1 ];
  280. f[ byte ] = 0;
  281. klient->getNachrichtEncrypted( f, byte );
  282. fehler->setText( f );
  283. delete[] f;
  284. cs.unlock();
  285. return 0;
  286. }
  287. cs.unlock();
  288. return 0;
  289. }
  290. bool EditorKlient::abbildErstellen( char *name )
  291. {
  292. cs.lock();
  293. if( !verbunden )
  294. {
  295. cs.unlock();
  296. return 0;
  297. }
  298. klient->sendeEncrypted( "\x7", 1 );
  299. char ret = 0;
  300. klient->getNachrichtEncrypted( &ret, 1 );
  301. if( ret == 1 )
  302. {
  303. klient->sendeEncrypted( "\x1", 1 );
  304. klient->getNachrichtEncrypted( &ret, 1 );
  305. if( ret == 1 )
  306. {
  307. char l = (char)textLength( name );
  308. klient->sendeEncrypted( &l, 1 );
  309. if( l )
  310. klient->sendeEncrypted( name, l );
  311. klient->getNachrichtEncrypted( &ret, 1 );
  312. }
  313. }
  314. if( ret == 3 )
  315. {
  316. char byte = 0;
  317. klient->getNachrichtEncrypted( &byte, 1 );
  318. char *f = new char[ byte + 1 ];
  319. f[ byte ] = 0;
  320. klient->getNachrichtEncrypted( f, byte );
  321. fehler->setText( f );
  322. delete[] f;
  323. cs.unlock();
  324. return 0;
  325. }
  326. cs.unlock();
  327. return 1;
  328. }
  329. bool EditorKlient::abbildLöschen( char *name )
  330. {
  331. cs.lock();
  332. if( !verbunden )
  333. {
  334. cs.unlock();
  335. return 0;
  336. }
  337. klient->sendeEncrypted( "\x7", 1 );
  338. char ret = 0;
  339. klient->getNachrichtEncrypted( &ret, 1 );
  340. if( ret == 1 )
  341. {
  342. klient->sendeEncrypted( "\x2", 1 );
  343. klient->getNachrichtEncrypted( &ret, 1 );
  344. if( ret == 1 )
  345. {
  346. char l = (char)textLength( name );
  347. klient->sendeEncrypted( &l, 1 );
  348. if( l )
  349. klient->sendeEncrypted( name, l );
  350. klient->getNachrichtEncrypted( &ret, 1 );
  351. }
  352. }
  353. if( ret == 3 )
  354. {
  355. char byte = 0;
  356. klient->getNachrichtEncrypted( &byte, 1 );
  357. char *f = new char[ byte + 1 ];
  358. f[ byte ] = 0;
  359. klient->getNachrichtEncrypted( f, byte );
  360. fehler->setText( f );
  361. delete[] f;
  362. cs.unlock();
  363. return 0;
  364. }
  365. cs.unlock();
  366. return 1;
  367. }
  368. bool EditorKlient::abbildHerstellen( char *name )
  369. {
  370. cs.lock();
  371. if( !verbunden )
  372. {
  373. cs.unlock();
  374. return 0;
  375. }
  376. klient->sendeEncrypted( "\x7", 1 );
  377. char ret = 0;
  378. klient->getNachrichtEncrypted( &ret, 1 );
  379. if( ret == 1 )
  380. {
  381. klient->sendeEncrypted( "\x3", 1 );
  382. klient->getNachrichtEncrypted( &ret, 1 );
  383. if( ret == 1 )
  384. {
  385. char l = (char)textLength( name );
  386. klient->sendeEncrypted( &l, 1 );
  387. if( l )
  388. klient->sendeEncrypted( name, l );
  389. klient->getNachrichtEncrypted( &ret, 1 );
  390. }
  391. }
  392. if( ret == 3 )
  393. {
  394. char byte = 0;
  395. klient->getNachrichtEncrypted( &byte, 1 );
  396. char *f = new char[ byte + 1 ];
  397. f[ byte ] = 0;
  398. klient->getNachrichtEncrypted( f, byte );
  399. fehler->setText( f );
  400. delete[] f;
  401. cs.unlock();
  402. return 0;
  403. }
  404. cs.unlock();
  405. return 1;
  406. }
  407. bool EditorKlient::veröffentlichen()
  408. {
  409. cs.lock();
  410. if( !verbunden )
  411. {
  412. cs.unlock();
  413. return 0;
  414. }
  415. klient->sendeEncrypted( "\x7", 1 );
  416. char ret = 0;
  417. klient->getNachrichtEncrypted( &ret, 1 );
  418. if( ret == 1 )
  419. {
  420. klient->sendeEncrypted( "\x4", 1 );
  421. klient->getNachrichtEncrypted( &ret, 1 );
  422. if( ret == 1 )
  423. klient->getNachrichtEncrypted( &ret, 1 );
  424. }
  425. if( ret == 3 )
  426. {
  427. char byte = 0;
  428. klient->getNachrichtEncrypted( &byte, 1 );
  429. char *f = new char[ byte + 1 ];
  430. f[ byte ] = 0;
  431. klient->getNachrichtEncrypted( f, byte );
  432. fehler->setText( f );
  433. delete[] f;
  434. cs.unlock();
  435. return 0;
  436. }
  437. cs.unlock();
  438. return ret == 1;
  439. }
  440. bool EditorKlient::shopSeiteVeröffentlichen() // Veröffentlicht die Shop Seite
  441. {
  442. cs.lock();
  443. if( !verbunden )
  444. {
  445. cs.unlock();
  446. return 0;
  447. }
  448. klient->sendeEncrypted( "\x7", 1 );
  449. char ret = 0;
  450. klient->getNachrichtEncrypted( &ret, 1 );
  451. if( ret == 1 )
  452. {
  453. klient->sendeEncrypted( "\x6", 1 );
  454. klient->getNachrichtEncrypted( &ret, 1 );
  455. if( ret == 1 )
  456. klient->getNachrichtEncrypted( &ret, 1 );
  457. }
  458. if( ret == 3 )
  459. {
  460. char byte = 0;
  461. klient->getNachrichtEncrypted( &byte, 1 );
  462. char *f = new char[ byte + 1 ];
  463. f[ byte ] = 0;
  464. klient->getNachrichtEncrypted( f, byte );
  465. fehler->setText( f );
  466. delete[] f;
  467. cs.unlock();
  468. return 0;
  469. }
  470. cs.unlock();
  471. return ret == 1;
  472. }
  473. bool EditorKlient::ladeShopSeiteVorschau() // Läht die Vorschau der Shop Seite herrunter
  474. {
  475. cs.lock();
  476. if( !verbunden )
  477. {
  478. cs.unlock();
  479. return 0;
  480. }
  481. klient->sendeEncrypted( "\x7", 1 );
  482. char ret = 0;
  483. klient->getNachrichtEncrypted( &ret, 1 );
  484. if( ret == 1 )
  485. {
  486. klient->sendeEncrypted( "\x8", 1 );
  487. klient->getNachrichtEncrypted( &ret, 1 );
  488. if( ret == 1 )
  489. {
  490. int anz = 0;
  491. klient->getNachrichtEncrypted( (char*)&anz, 4 );
  492. Text pf = "data/tmp/ke/ssv";
  493. for( int i = 0; i < anz; i++ )
  494. {
  495. char l = 0;
  496. klient->getNachrichtEncrypted( &l, 1 );
  497. char *pfad = new char[ l + 1 ];
  498. pfad[ l ] = 0;
  499. klient->getNachrichtEncrypted( pfad, l );
  500. Text p = pf.getText();
  501. p += pfad;
  502. delete[] pfad;
  503. Datei d;
  504. d.setDatei( p );
  505. d.erstellen();
  506. d.open( Datei::Style::schreiben );
  507. __int64 größe = 0;
  508. klient->getNachrichtEncrypted( (char*)&größe, 8 );
  509. char *buffer = new char[ 2048 ];
  510. while( größe > 0 )
  511. {
  512. int l = größe > 2048 ? 2048 : (int)größe;
  513. klient->getNachricht( buffer, l );
  514. d.schreibe( buffer, l );
  515. größe -= l;
  516. }
  517. delete[] buffer;
  518. d.close();
  519. }
  520. }
  521. }
  522. if( ret == 3 )
  523. {
  524. char byte = 0;
  525. klient->getNachrichtEncrypted( &byte, 1 );
  526. char *f = new char[ byte + 1 ];
  527. f[ byte ] = 0;
  528. klient->getNachrichtEncrypted( f, byte );
  529. fehler->setText( f );
  530. delete[] f;
  531. cs.unlock();
  532. return 0;
  533. }
  534. cs.unlock();
  535. return ret == 1;
  536. }
  537. bool EditorKlient::ssDateiErstellen( char *name, int typ ) // Erstellt eine neue Shop Seiten Datei (typ:0=Ordner,1=Bild,2=Text)
  538. {
  539. cs.lock();
  540. if( !verbunden )
  541. {
  542. cs.unlock();
  543. return 0;
  544. }
  545. klient->sendeEncrypted( "\x7", 1 );
  546. char ret = 0;
  547. klient->getNachrichtEncrypted( &ret, 1 );
  548. if( ret == 1 )
  549. {
  550. klient->sendeEncrypted( "\x7", 1 );
  551. klient->getNachrichtEncrypted( &ret, 1 );
  552. if( ret == 1 )
  553. {
  554. klient->sendeEncrypted( "\x1", 1 );
  555. klient->getNachrichtEncrypted( &ret, 1 );
  556. if( ret == 1 )
  557. {
  558. char t = typ;
  559. klient->sendeEncrypted( &t, 1 );
  560. char l = (char)textLength( name );
  561. klient->sendeEncrypted( &l, 1 );
  562. if( l )
  563. klient->sendeEncrypted( name, l );
  564. klient->getNachrichtEncrypted( &ret, 1 );
  565. }
  566. }
  567. }
  568. if( ret == 3 )
  569. {
  570. char byte = 0;
  571. klient->getNachrichtEncrypted( &byte, 1 );
  572. char *f = new char[ byte + 1 ];
  573. f[ byte ] = 0;
  574. klient->getNachrichtEncrypted( f, byte );
  575. fehler->setText( f );
  576. delete[] f;
  577. cs.unlock();
  578. return 0;
  579. }
  580. cs.unlock();
  581. return ret == 1;
  582. }
  583. bool EditorKlient::ssOrdnerÖffnen( char *name ) // Öffnet einen Ordner der Shop Seite
  584. {
  585. cs.lock();
  586. if( !verbunden )
  587. {
  588. cs.unlock();
  589. return 0;
  590. }
  591. klient->sendeEncrypted( "\x7", 1 );
  592. char ret = 0;
  593. klient->getNachrichtEncrypted( &ret, 1 );
  594. if( ret == 1 )
  595. {
  596. klient->sendeEncrypted( "\x7", 1 );
  597. klient->getNachrichtEncrypted( &ret, 1 );
  598. if( ret == 1 )
  599. {
  600. klient->sendeEncrypted( "\x2", 1 );
  601. klient->getNachrichtEncrypted( &ret, 1 );
  602. if( ret == 1 )
  603. {
  604. char l = (char)textLength( name );
  605. klient->sendeEncrypted( &l, 1 );
  606. if( l )
  607. klient->sendeEncrypted( name, l );
  608. klient->getNachrichtEncrypted( &ret, 1 );
  609. }
  610. }
  611. }
  612. if( ret == 3 )
  613. {
  614. char byte = 0;
  615. klient->getNachrichtEncrypted( &byte, 1 );
  616. char *f = new char[ byte + 1 ];
  617. f[ byte ] = 0;
  618. klient->getNachrichtEncrypted( f, byte );
  619. fehler->setText( f );
  620. delete[] f;
  621. cs.unlock();
  622. return 0;
  623. }
  624. cs.unlock();
  625. return ret == 1;
  626. }
  627. Bild *EditorKlient::ssBildLaden( char *datei, char *bild ) // Läht das ein Bild der Shop Seite
  628. {
  629. cs.lock();
  630. if( !verbunden )
  631. {
  632. cs.unlock();
  633. return 0;
  634. }
  635. klient->sendeEncrypted( "\x7", 1 );
  636. char ret = 0;
  637. klient->getNachrichtEncrypted( &ret, 1 );
  638. if( ret == 1 )
  639. {
  640. klient->sendeEncrypted( "\x7", 1 );
  641. klient->getNachrichtEncrypted( &ret, 1 );
  642. if( ret == 1 )
  643. {
  644. klient->sendeEncrypted( "\x3", 1 );
  645. klient->getNachrichtEncrypted( &ret, 1 );
  646. if( ret == 1 )
  647. {
  648. char l = (char)textLength( datei );
  649. klient->sendeEncrypted( &l, 1 );
  650. if( l )
  651. klient->sendeEncrypted( datei, l );
  652. l = (char)textLength( bild );
  653. klient->sendeEncrypted( &l, 1 );
  654. if( l )
  655. klient->sendeEncrypted( bild, l );
  656. klient->getNachrichtEncrypted( &ret, 1 );
  657. if( ret == 1 )
  658. {
  659. Bild *ret = new Bild();
  660. int br = 0;
  661. int hö = 0;
  662. klient->getNachrichtEncrypted( (char*)&br, 4 );
  663. klient->getNachrichtEncrypted( (char*)&hö, 4 );
  664. ret->neuBild( br, hö, 0 );
  665. char *buffer = (char*)ret->getBuffer();
  666. __int64 län = br * hö * 4;
  667. for( int i = 0, l = län > 2048 ? 2048 : (int)län; län > 0; l = län > 2048 ? 2048 : (int)län )
  668. {
  669. klient->getNachricht( &( buffer[ i ] ), l );
  670. i += l;
  671. län -= l;
  672. }
  673. cs.unlock();
  674. return ret;
  675. }
  676. }
  677. }
  678. }
  679. if( ret == 3 )
  680. {
  681. char byte = 0;
  682. klient->getNachrichtEncrypted( &byte, 1 );
  683. char *f = new char[ byte + 1 ];
  684. f[ byte ] = 0;
  685. klient->getNachrichtEncrypted( f, byte );
  686. fehler->setText( f );
  687. delete[] f;
  688. cs.unlock();
  689. return 0;
  690. }
  691. cs.unlock();
  692. return 0;
  693. }
  694. bool EditorKlient::ssDateiLöschen( char *name ) // Löscht eine Datei der Shop Seite
  695. {
  696. cs.lock();
  697. if( !verbunden )
  698. {
  699. cs.unlock();
  700. return 0;
  701. }
  702. klient->sendeEncrypted( "\x7", 1 );
  703. char ret = 0;
  704. klient->getNachrichtEncrypted( &ret, 1 );
  705. if( ret == 1 )
  706. {
  707. klient->sendeEncrypted( "\x7", 1 );
  708. klient->getNachrichtEncrypted( &ret, 1 );
  709. if( ret == 1 )
  710. {
  711. klient->sendeEncrypted( "\x4", 1 );
  712. klient->getNachrichtEncrypted( &ret, 1 );
  713. if( ret == 1 )
  714. {
  715. char l = (char)textLength( name );
  716. klient->sendeEncrypted( &l, 1 );
  717. if( l )
  718. klient->sendeEncrypted( name, l );
  719. klient->getNachrichtEncrypted( &ret, 1 );
  720. }
  721. }
  722. }
  723. if( ret == 3 )
  724. {
  725. char byte = 0;
  726. klient->getNachrichtEncrypted( &byte, 1 );
  727. char *f = new char[ byte + 1 ];
  728. f[ byte ] = 0;
  729. klient->getNachrichtEncrypted( f, byte );
  730. fehler->setText( f );
  731. delete[] f;
  732. cs.unlock();
  733. return 0;
  734. }
  735. cs.unlock();
  736. return ret == 1;
  737. }
  738. Text *EditorKlient::ssTextLaden( char *datei ) // Läd eine KSGS Datei der Shop Seite
  739. {
  740. cs.lock();
  741. if( !verbunden )
  742. {
  743. cs.unlock();
  744. return 0;
  745. }
  746. klient->sendeEncrypted( "\x7", 1 );
  747. char ret = 0;
  748. klient->getNachrichtEncrypted( &ret, 1 );
  749. if( ret == 1 )
  750. {
  751. klient->sendeEncrypted( "\x7", 1 );
  752. klient->getNachrichtEncrypted( &ret, 1 );
  753. if( ret == 1 )
  754. {
  755. klient->sendeEncrypted( "\xA", 1 );
  756. klient->getNachrichtEncrypted( &ret, 1 );
  757. if( ret == 1 )
  758. {
  759. char l = (char)textLength( datei );
  760. klient->sendeEncrypted( &l, 1 );
  761. if( l )
  762. klient->sendeEncrypted( datei, l );
  763. klient->getNachrichtEncrypted( &ret, 1 );
  764. if( ret == 1 )
  765. {
  766. int län = 0;
  767. klient->getNachrichtEncrypted( (char*)&län, 4 );
  768. char *txt = new char[ län + 1 ];
  769. txt[ län ] = 0;
  770. for( int i = 0, l = län > 2048 ? 2048 : län; län > 0; i += l, län -= l, l = län > 2048 ? 2048 : län )
  771. klient->getNachricht( &( txt[ i ] ), l );
  772. klient->getNachrichtEncrypted( &ret, 1 );
  773. if( ret == 1 )
  774. {
  775. Text *t = new Text( txt );
  776. delete[] txt;
  777. cs.unlock();
  778. return t;
  779. }
  780. delete[] txt;
  781. }
  782. }
  783. }
  784. }
  785. if( ret == 3 )
  786. {
  787. char byte = 0;
  788. klient->getNachrichtEncrypted( &byte, 1 );
  789. char *f = new char[ byte + 1 ];
  790. f[ byte ] = 0;
  791. klient->getNachrichtEncrypted( f, byte );
  792. fehler->setText( f );
  793. delete[] f;
  794. cs.unlock();
  795. return 0;
  796. }
  797. cs.unlock();
  798. return 0;
  799. }
  800. bool EditorKlient::ssTextSpeichern( char *datei, Text *zText ) // Spechert eine KSGS Datei der Shop Seite
  801. {
  802. cs.lock();
  803. if( !verbunden )
  804. {
  805. cs.unlock();
  806. return 0;
  807. }
  808. klient->sendeEncrypted( "\x7", 1 );
  809. char ret = 0;
  810. klient->getNachrichtEncrypted( &ret, 1 );
  811. if( ret == 1 )
  812. {
  813. klient->sendeEncrypted( "\x7", 1 );
  814. klient->getNachrichtEncrypted( &ret, 1 );
  815. if( ret == 1 )
  816. {
  817. klient->sendeEncrypted( "\x5", 1 );
  818. klient->getNachrichtEncrypted( &ret, 1 );
  819. if( ret == 1 )
  820. {
  821. char l = (char)textLength( datei );
  822. klient->sendeEncrypted( &l, 1 );
  823. if( l )
  824. klient->sendeEncrypted( datei, l );
  825. klient->getNachrichtEncrypted( &ret, 1 );
  826. if( ret == 1 )
  827. {
  828. int län = zText->getLength();
  829. klient->sendeEncrypted( (char*)&län, 4 );
  830. for( int i = 0, l = län > 2048 ? 2048 : län; län > 0; i += l, län -= l, l = län > 2048 ? 2048 : län )
  831. klient->sende( &( zText->getText()[ i ] ), l );
  832. klient->getNachrichtEncrypted( &ret, 1 );
  833. }
  834. }
  835. }
  836. }
  837. if( ret == 3 )
  838. {
  839. char byte = 0;
  840. klient->getNachrichtEncrypted( &byte, 1 );
  841. char *f = new char[ byte + 1 ];
  842. f[ byte ] = 0;
  843. klient->getNachrichtEncrypted( f, byte );
  844. fehler->setText( f );
  845. delete[] f;
  846. cs.unlock();
  847. return 0;
  848. }
  849. cs.unlock();
  850. return ret == 1;
  851. }
  852. bool EditorKlient::ssBildLöschen( char *datei, char *bild ) // Löscht ein Bild der Shop Seite
  853. {
  854. cs.lock();
  855. if( !verbunden )
  856. {
  857. cs.unlock();
  858. return 0;
  859. }
  860. klient->sendeEncrypted( "\x7", 1 );
  861. char ret = 0;
  862. klient->getNachrichtEncrypted( &ret, 1 );
  863. if( ret == 1 )
  864. {
  865. klient->sendeEncrypted( "\x7", 1 );
  866. klient->getNachrichtEncrypted( &ret, 1 );
  867. if( ret == 1 )
  868. {
  869. klient->sendeEncrypted( "\x6", 1 );
  870. klient->getNachrichtEncrypted( &ret, 1 );
  871. if( ret == 1 )
  872. {
  873. char l = (char)textLength( datei );
  874. klient->sendeEncrypted( &l, 1 );
  875. if( l )
  876. klient->sendeEncrypted( datei, l );
  877. l = (char)textLength( bild );
  878. klient->sendeEncrypted( &l, 1 );
  879. if( l )
  880. klient->sendeEncrypted( bild, l );
  881. klient->getNachrichtEncrypted( &ret, 1 );
  882. }
  883. }
  884. }
  885. if( ret == 3 )
  886. {
  887. char byte = 0;
  888. klient->getNachrichtEncrypted( &byte, 1 );
  889. char *f = new char[ byte + 1 ];
  890. f[ byte ] = 0;
  891. klient->getNachrichtEncrypted( f, byte );
  892. fehler->setText( f );
  893. delete[] f;
  894. cs.unlock();
  895. return 0;
  896. }
  897. cs.unlock();
  898. return ret == 1;
  899. }
  900. bool EditorKlient::ssBildSpeichern( char *datei, char *name, Bild *zBild ) // Speichert ein Bild einer ShopSeite
  901. {
  902. cs.lock();
  903. if( !verbunden )
  904. {
  905. cs.unlock();
  906. return 0;
  907. }
  908. klient->sendeEncrypted( "\x7", 1 );
  909. char ret = 0;
  910. klient->getNachrichtEncrypted( &ret, 1 );
  911. if( ret == 1 )
  912. {
  913. klient->sendeEncrypted( "\x7", 1 );
  914. klient->getNachrichtEncrypted( &ret, 1 );
  915. if( ret == 1 )
  916. {
  917. klient->sendeEncrypted( "\x7", 1 );
  918. klient->getNachrichtEncrypted( &ret, 1 );
  919. if( ret == 1 )
  920. {
  921. char l = (char)textLength( datei );
  922. klient->sendeEncrypted( &l, 1 );
  923. if( l )
  924. klient->sendeEncrypted( datei, l );
  925. l = (char)textLength( name );
  926. klient->sendeEncrypted( &l, 1 );
  927. if( l )
  928. klient->sendeEncrypted( name, l );
  929. klient->getNachrichtEncrypted( &ret, 1 );
  930. if( ret == 1 )
  931. {
  932. int br = zBild->getBreite();
  933. int hö = zBild->getHeight();
  934. klient->sendeEncrypted( (char*)&br, 4 );
  935. klient->sendeEncrypted( (char*)&hö, 4 );
  936. __int64 län = br * hö * 4;
  937. char *buffer = (char*)zBild->getBuffer();
  938. for( int i = 0, l = län > 2048 ? 2048 : (int)län; län > 0; i += l, län -= l, l = län > 2048 ? 2048 : (int)län )
  939. klient->sende( &( buffer[ i ] ), l );
  940. klient->getNachrichtEncrypted( &ret, 1 );
  941. }
  942. }
  943. }
  944. }
  945. if( ret == 3 )
  946. {
  947. char byte = 0;
  948. klient->getNachrichtEncrypted( &byte, 1 );
  949. char *f = new char[ byte + 1 ];
  950. f[ byte ] = 0;
  951. klient->getNachrichtEncrypted( f, byte );
  952. fehler->setText( f );
  953. delete[] f;
  954. cs.unlock();
  955. return 0;
  956. }
  957. cs.unlock();
  958. return ret == 1;
  959. }
  960. int EditorKlient::ssGetDateiListe( RCArray< Text > *zList ) // Läd die Datei Liste der Shop Seite
  961. {
  962. cs.lock();
  963. if( !verbunden )
  964. {
  965. cs.unlock();
  966. return 0;
  967. }
  968. klient->sendeEncrypted( "\x7", 1 );
  969. char ret = 0;
  970. klient->getNachrichtEncrypted( &ret, 1 );
  971. if( ret == 1 )
  972. {
  973. klient->sendeEncrypted( "\x7", 1 );
  974. klient->getNachrichtEncrypted( &ret, 1 );
  975. if( ret == 1 )
  976. {
  977. klient->sendeEncrypted( "\x8", 1 );
  978. klient->getNachrichtEncrypted( &ret, 1 );
  979. if( ret == 1 )
  980. {
  981. int anz = 0;
  982. klient->getNachrichtEncrypted( (char*)&anz, 4 );
  983. for( int i = 0; i < anz; i++ )
  984. {
  985. char l = 0;
  986. klient->getNachrichtEncrypted( &l, 1 );
  987. char *n = new char[ l + 1 ];
  988. n[ l ] = 0;
  989. klient->getNachrichtEncrypted( n, l );
  990. zList->add( new Text( n ) );
  991. delete[] n;
  992. }
  993. cs.unlock();
  994. return anz;
  995. }
  996. }
  997. }
  998. if( ret == 3 )
  999. {
  1000. char byte = 0;
  1001. klient->getNachrichtEncrypted( &byte, 1 );
  1002. char *f = new char[ byte + 1 ];
  1003. f[ byte ] = 0;
  1004. klient->getNachrichtEncrypted( f, byte );
  1005. fehler->setText( f );
  1006. delete[] f;
  1007. cs.unlock();
  1008. return -1;
  1009. }
  1010. cs.unlock();
  1011. return 0;
  1012. }
  1013. int EditorKlient::ssGetBildListe( char *name, RCArray< Text > *zList ) // Läd die Bild Liste einer Bild Datei der Shop Seite
  1014. {
  1015. cs.lock();
  1016. if( !verbunden )
  1017. {
  1018. cs.unlock();
  1019. return 0;
  1020. }
  1021. klient->sendeEncrypted( "\x7", 1 );
  1022. char ret = 0;
  1023. klient->getNachrichtEncrypted( &ret, 1 );
  1024. if( ret == 1 )
  1025. {
  1026. klient->sendeEncrypted( "\x7", 1 );
  1027. klient->getNachrichtEncrypted( &ret, 1 );
  1028. if( ret == 1 )
  1029. {
  1030. klient->sendeEncrypted( "\x9", 1 );
  1031. klient->getNachrichtEncrypted( &ret, 1 );
  1032. if( ret == 1 )
  1033. {
  1034. char l = (char)textLength( name );
  1035. klient->sendeEncrypted( &l, 1 );
  1036. if( l )
  1037. klient->sendeEncrypted( name, l );
  1038. klient->getNachrichtEncrypted( &ret, 1 );
  1039. if( ret == 1 )
  1040. {
  1041. int anz = 0;
  1042. klient->getNachrichtEncrypted( (char*)&anz, 4 );
  1043. for( int i = 0; i < anz; i++ )
  1044. {
  1045. l = 0;
  1046. klient->getNachrichtEncrypted( &l, 1 );
  1047. char *n = new char[ l + 1 ];
  1048. n[ l ] = 0;
  1049. klient->getNachrichtEncrypted( n, l );
  1050. zList->add( new Text( n ) );
  1051. delete[] n;
  1052. }
  1053. cs.unlock();
  1054. return anz;
  1055. }
  1056. }
  1057. }
  1058. }
  1059. if( ret == 3 )
  1060. {
  1061. char byte = 0;
  1062. klient->getNachrichtEncrypted( &byte, 1 );
  1063. char *f = new char[ byte + 1 ];
  1064. f[ byte ] = 0;
  1065. klient->getNachrichtEncrypted( f, byte );
  1066. fehler->setText( f );
  1067. delete[] f;
  1068. cs.unlock();
  1069. return -1;
  1070. }
  1071. cs.unlock();
  1072. return 0;
  1073. }
  1074. bool EditorKlient::getShopDaten( int &es, int &tp, int &vp ) // Läht die Shop Daten
  1075. {
  1076. cs.lock();
  1077. if( !verbunden )
  1078. {
  1079. cs.unlock();
  1080. return 0;
  1081. }
  1082. klient->sendeEncrypted( "\x7", 1 );
  1083. char ret = 0;
  1084. klient->getNachrichtEncrypted( &ret, 1 );
  1085. if( ret == 1 )
  1086. {
  1087. klient->sendeEncrypted( "\x9", 1 );
  1088. klient->getNachrichtEncrypted( &ret, 1 );
  1089. if( ret == 1 )
  1090. {
  1091. klient->getNachrichtEncrypted( (char*)&es, 4 );
  1092. klient->getNachrichtEncrypted( (char*)&tp, 4 );
  1093. klient->getNachrichtEncrypted( (char*)&vp, 4 );
  1094. cs.unlock();
  1095. return 1;
  1096. }
  1097. }
  1098. if( ret == 3 )
  1099. {
  1100. char byte = 0;
  1101. klient->getNachrichtEncrypted( &byte, 1 );
  1102. char *f = new char[ byte + 1 ];
  1103. f[ byte ] = 0;
  1104. klient->getNachrichtEncrypted( f, byte );
  1105. fehler->setText( f );
  1106. delete[] f;
  1107. cs.unlock();
  1108. return 0;
  1109. }
  1110. cs.unlock();
  1111. return 0;
  1112. }
  1113. bool EditorKlient::setShopDaten( int es, int tp, int vp ) // Setzt die Shop Daten
  1114. {
  1115. cs.lock();
  1116. if( !verbunden )
  1117. {
  1118. cs.unlock();
  1119. return 0;
  1120. }
  1121. klient->sendeEncrypted( "\x7", 1 );
  1122. char ret = 0;
  1123. klient->getNachrichtEncrypted( &ret, 1 );
  1124. if( ret == 1 )
  1125. {
  1126. klient->sendeEncrypted( "\xA", 1 );
  1127. klient->getNachrichtEncrypted( &ret, 1 );
  1128. if( ret == 1 )
  1129. {
  1130. klient->sendeEncrypted( (char*)&es, 4 );
  1131. klient->sendeEncrypted( (char*)&tp, 4 );
  1132. klient->sendeEncrypted( (char*)&vp, 4 );
  1133. klient->getNachrichtEncrypted( &ret, 1 );
  1134. if( ret == 1 )
  1135. {
  1136. cs.unlock();
  1137. return 1;
  1138. }
  1139. }
  1140. }
  1141. if( ret == 3 )
  1142. {
  1143. char byte = 0;
  1144. klient->getNachrichtEncrypted( &byte, 1 );
  1145. char *f = new char[ byte + 1 ];
  1146. f[ byte ] = 0;
  1147. klient->getNachrichtEncrypted( f, byte );
  1148. fehler->setText( f );
  1149. delete[] f;
  1150. cs.unlock();
  1151. return 0;
  1152. }
  1153. cs.unlock();
  1154. return 0;
  1155. }
  1156. Text *EditorKlient::beschreibungLaden() // läht die Kartenbeschreibung
  1157. {
  1158. cs.lock();
  1159. if( !verbunden )
  1160. {
  1161. cs.unlock();
  1162. return 0;
  1163. }
  1164. klient->sendeEncrypted( "\x7", 1 );
  1165. char ret = 0;
  1166. klient->getNachrichtEncrypted( &ret, 1 );
  1167. if( ret == 1 )
  1168. {
  1169. klient->sendeEncrypted( "\xB", 1 );
  1170. klient->getNachrichtEncrypted( &ret, 1 );
  1171. if( ret == 1 )
  1172. {
  1173. klient->sendeEncrypted( "\x1", 1 );
  1174. klient->getNachrichtEncrypted( &ret, 1 );
  1175. if( ret == 1 )
  1176. {
  1177. int län = 0;
  1178. klient->getNachrichtEncrypted( (char*)&län, 4 );
  1179. char *txt = new char[ län + 1 ];
  1180. txt[ län ] = 0;
  1181. for( int i = 0, l = län > 2048 ? 2048 : län; län > 0; i += l, län -= l, l = län > 2048 ? 2048 : län )
  1182. klient->getNachricht( &( txt[ i ] ), l );
  1183. klient->getNachrichtEncrypted( &ret, 1 );
  1184. if( ret == 1 )
  1185. {
  1186. Text *t = new Text( txt );
  1187. delete[] txt;
  1188. cs.unlock();
  1189. return t;
  1190. }
  1191. delete[] txt;
  1192. }
  1193. }
  1194. }
  1195. if( ret == 3 )
  1196. {
  1197. char byte = 0;
  1198. klient->getNachrichtEncrypted( &byte, 1 );
  1199. char *f = new char[ byte + 1 ];
  1200. f[ byte ] = 0;
  1201. klient->getNachrichtEncrypted( f, byte );
  1202. fehler->setText( f );
  1203. delete[] f;
  1204. cs.unlock();
  1205. return 0;
  1206. }
  1207. cs.unlock();
  1208. return 0;
  1209. }
  1210. Bild *EditorKlient::titelbildLaden() // läht das Titelbild
  1211. {
  1212. cs.lock();
  1213. if( !verbunden )
  1214. {
  1215. cs.unlock();
  1216. return 0;
  1217. }
  1218. klient->sendeEncrypted( "\x7", 1 );
  1219. char ret = 0;
  1220. klient->getNachrichtEncrypted( &ret, 1 );
  1221. if( ret == 1 )
  1222. {
  1223. klient->sendeEncrypted( "\xB", 1 );
  1224. klient->getNachrichtEncrypted( &ret, 1 );
  1225. if( ret == 1 )
  1226. {
  1227. klient->sendeEncrypted( "\x2", 1 );
  1228. klient->getNachrichtEncrypted( &ret, 1 );
  1229. if( ret == 1 )
  1230. {
  1231. Bild *ret = new Bild();
  1232. int br = 0;
  1233. int hö = 0;
  1234. klient->getNachrichtEncrypted( (char*)&br, 4 );
  1235. klient->getNachrichtEncrypted( (char*)&hö, 4 );
  1236. ret->neuBild( br, hö, 0 );
  1237. char *buffer = (char*)ret->getBuffer();
  1238. __int64 län = br * hö * 4;
  1239. for( int i = 0, l = län > 2048 ? 2048 : (int)län; län > 0; l = län > 2048 ? 2048 : (int)län )
  1240. {
  1241. klient->getNachricht( &( buffer[ i ] ), l );
  1242. i += l;
  1243. län -= l;
  1244. }
  1245. cs.unlock();
  1246. return ret;
  1247. }
  1248. }
  1249. }
  1250. if( ret == 3 )
  1251. {
  1252. char byte = 0;
  1253. klient->getNachrichtEncrypted( &byte, 1 );
  1254. char *f = new char[ byte + 1 ];
  1255. f[ byte ] = 0;
  1256. klient->getNachrichtEncrypted( f, byte );
  1257. fehler->setText( f );
  1258. delete[] f;
  1259. cs.unlock();
  1260. return 0;
  1261. }
  1262. cs.unlock();
  1263. return 0;
  1264. }
  1265. Bild *EditorKlient::minimapLaden() // läht das Minimapbild
  1266. {
  1267. cs.lock();
  1268. if( !verbunden )
  1269. {
  1270. cs.unlock();
  1271. return 0;
  1272. }
  1273. klient->sendeEncrypted( "\x7", 1 );
  1274. char ret = 0;
  1275. klient->getNachrichtEncrypted( &ret, 1 );
  1276. if( ret == 1 )
  1277. {
  1278. klient->sendeEncrypted( "\xB", 1 );
  1279. klient->getNachrichtEncrypted( &ret, 1 );
  1280. if( ret == 1 )
  1281. {
  1282. klient->sendeEncrypted( "\x3", 1 );
  1283. klient->getNachrichtEncrypted( &ret, 1 );
  1284. if( ret == 1 )
  1285. {
  1286. Bild *ret = new Bild();
  1287. int br = 0;
  1288. int hö = 0;
  1289. klient->getNachrichtEncrypted( (char*)&br, 4 );
  1290. klient->getNachrichtEncrypted( (char*)&hö, 4 );
  1291. ret->neuBild( br, hö, 0 );
  1292. char *buffer = (char*)ret->getBuffer();
  1293. __int64 län = br * hö * 4;
  1294. for( int i = 0, l = län > 2048 ? 2048 : (int)län; län > 0; l = län > 2048 ? 2048 : (int)län )
  1295. {
  1296. klient->getNachricht( &( buffer[ i ] ), l );
  1297. i += l;
  1298. län -= l;
  1299. }
  1300. cs.unlock();
  1301. return ret;
  1302. }
  1303. }
  1304. }
  1305. if( ret == 3 )
  1306. {
  1307. char byte = 0;
  1308. klient->getNachrichtEncrypted( &byte, 1 );
  1309. char *f = new char[ byte + 1 ];
  1310. f[ byte ] = 0;
  1311. klient->getNachrichtEncrypted( f, byte );
  1312. fehler->setText( f );
  1313. delete[] f;
  1314. cs.unlock();
  1315. return 0;
  1316. }
  1317. cs.unlock();
  1318. return 0;
  1319. }
  1320. Bild *EditorKlient::ladebildLaden() // läht das Ladebild
  1321. {
  1322. cs.lock();
  1323. if( !verbunden )
  1324. {
  1325. cs.unlock();
  1326. return 0;
  1327. }
  1328. klient->sendeEncrypted( "\x7", 1 );
  1329. char ret = 0;
  1330. klient->getNachrichtEncrypted( &ret, 1 );
  1331. if( ret == 1 )
  1332. {
  1333. klient->sendeEncrypted( "\xB", 1 );
  1334. klient->getNachrichtEncrypted( &ret, 1 );
  1335. if( ret == 1 )
  1336. {
  1337. klient->sendeEncrypted( "\x4", 1 );
  1338. klient->getNachrichtEncrypted( &ret, 1 );
  1339. if( ret == 1 )
  1340. {
  1341. Bild *ret = new Bild();
  1342. int br = 0;
  1343. int hö = 0;
  1344. klient->getNachrichtEncrypted( (char*)&br, 4 );
  1345. klient->getNachrichtEncrypted( (char*)&hö, 4 );
  1346. ret->neuBild( br, hö, 0 );
  1347. char *buffer = (char*)ret->getBuffer();
  1348. __int64 län = br * hö * 4;
  1349. for( int i = 0, l = län > 2048 ? 2048 : (int)län; län > 0; l = län > 2048 ? 2048 : (int)län )
  1350. {
  1351. klient->getNachricht( &( buffer[ i ] ), l );
  1352. i += l;
  1353. län -= l;
  1354. }
  1355. cs.unlock();
  1356. return ret;
  1357. }
  1358. }
  1359. }
  1360. if( ret == 3 )
  1361. {
  1362. char byte = 0;
  1363. klient->getNachrichtEncrypted( &byte, 1 );
  1364. char *f = new char[ byte + 1 ];
  1365. f[ byte ] = 0;
  1366. klient->getNachrichtEncrypted( f, byte );
  1367. fehler->setText( f );
  1368. delete[] f;
  1369. cs.unlock();
  1370. return 0;
  1371. }
  1372. cs.unlock();
  1373. return 0;
  1374. }
  1375. bool EditorKlient::beschreibungSpeichern( Text *zText ) // speichert die Kartenbeschreibung
  1376. {
  1377. cs.lock();
  1378. if( !verbunden )
  1379. {
  1380. cs.unlock();
  1381. return 0;
  1382. }
  1383. klient->sendeEncrypted( "\x7", 1 );
  1384. char ret = 0;
  1385. klient->getNachrichtEncrypted( &ret, 1 );
  1386. if( ret == 1 )
  1387. {
  1388. klient->sendeEncrypted( "\xB", 1 );
  1389. klient->getNachrichtEncrypted( &ret, 1 );
  1390. if( ret == 1 )
  1391. {
  1392. klient->sendeEncrypted( "\x5", 1 );
  1393. klient->getNachrichtEncrypted( &ret, 1 );
  1394. if( ret == 1 )
  1395. {
  1396. int län = zText->getLength();
  1397. klient->sendeEncrypted( (char*)&län, 4 );
  1398. for( int i = 0, l = län > 2048 ? 2048 : län; län > 0; i += l, län -= l, l = län > 2048 ? 2048 : län )
  1399. klient->sende( &( zText->getText()[ i ] ), l );
  1400. klient->getNachrichtEncrypted( &ret, 1 );
  1401. }
  1402. }
  1403. }
  1404. if( ret == 3 )
  1405. {
  1406. char byte = 0;
  1407. klient->getNachrichtEncrypted( &byte, 1 );
  1408. char *f = new char[ byte + 1 ];
  1409. f[ byte ] = 0;
  1410. klient->getNachrichtEncrypted( f, byte );
  1411. fehler->setText( f );
  1412. delete[] f;
  1413. cs.unlock();
  1414. return 0;
  1415. }
  1416. cs.unlock();
  1417. return ret == 1;
  1418. }
  1419. bool EditorKlient::titelbildSpeichern( Bild *zBild ) // speichert das Titelbild
  1420. {
  1421. cs.lock();
  1422. if( !verbunden )
  1423. {
  1424. cs.unlock();
  1425. return 0;
  1426. }
  1427. klient->sendeEncrypted( "\x7", 1 );
  1428. char ret = 0;
  1429. klient->getNachrichtEncrypted( &ret, 1 );
  1430. if( ret == 1 )
  1431. {
  1432. klient->sendeEncrypted( "\xB", 1 );
  1433. klient->getNachrichtEncrypted( &ret, 1 );
  1434. if( ret == 1 )
  1435. {
  1436. klient->sendeEncrypted( "\x6", 1 );
  1437. klient->getNachrichtEncrypted( &ret, 1 );
  1438. if( ret == 1 )
  1439. {
  1440. int br = zBild->getBreite();
  1441. int hö = zBild->getHeight();
  1442. klient->sendeEncrypted( (char*)&br, 4 );
  1443. klient->sendeEncrypted( (char*)&hö, 4 );
  1444. __int64 län = br * hö * 4;
  1445. char *buffer = (char*)zBild->getBuffer();
  1446. for( int i = 0, l = län > 2048 ? 2048 : (int)län; län > 0; i += l, län -= l, l = län > 2048 ? 2048 : (int)län )
  1447. klient->sende( &( buffer[ i ] ), l );
  1448. klient->getNachrichtEncrypted( &ret, 1 );
  1449. }
  1450. }
  1451. }
  1452. if( ret == 3 )
  1453. {
  1454. char byte = 0;
  1455. klient->getNachrichtEncrypted( &byte, 1 );
  1456. char *f = new char[ byte + 1 ];
  1457. f[ byte ] = 0;
  1458. klient->getNachrichtEncrypted( f, byte );
  1459. fehler->setText( f );
  1460. delete[] f;
  1461. cs.unlock();
  1462. return 0;
  1463. }
  1464. cs.unlock();
  1465. return ret == 1;
  1466. }
  1467. bool EditorKlient::minimapSpeichern( Bild *zBild ) // speichert das Minimapbild
  1468. {
  1469. cs.lock();
  1470. if( !verbunden )
  1471. {
  1472. cs.unlock();
  1473. return 0;
  1474. }
  1475. klient->sendeEncrypted( "\x7", 1 );
  1476. char ret = 0;
  1477. klient->getNachrichtEncrypted( &ret, 1 );
  1478. if( ret == 1 )
  1479. {
  1480. klient->sendeEncrypted( "\xB", 1 );
  1481. klient->getNachrichtEncrypted( &ret, 1 );
  1482. if( ret == 1 )
  1483. {
  1484. klient->sendeEncrypted( "\x7", 1 );
  1485. klient->getNachrichtEncrypted( &ret, 1 );
  1486. if( ret == 1 )
  1487. {
  1488. int br = zBild->getBreite();
  1489. int hö = zBild->getHeight();
  1490. klient->sendeEncrypted( (char*)&br, 4 );
  1491. klient->sendeEncrypted( (char*)&hö, 4 );
  1492. __int64 län = br * hö * 4;
  1493. char *buffer = (char*)zBild->getBuffer();
  1494. for( int i = 0, l = län > 2048 ? 2048 : (int)län; län > 0; i += l, län -= l, l = län > 2048 ? 2048 : (int)län )
  1495. klient->sende( &( buffer[ i ] ), l );
  1496. klient->getNachrichtEncrypted( &ret, 1 );
  1497. }
  1498. }
  1499. }
  1500. if( ret == 3 )
  1501. {
  1502. char byte = 0;
  1503. klient->getNachrichtEncrypted( &byte, 1 );
  1504. char *f = new char[ byte + 1 ];
  1505. f[ byte ] = 0;
  1506. klient->getNachrichtEncrypted( f, byte );
  1507. fehler->setText( f );
  1508. delete[] f;
  1509. cs.unlock();
  1510. return 0;
  1511. }
  1512. cs.unlock();
  1513. return ret == 1;
  1514. }
  1515. bool EditorKlient::ladebildSpeichern( Bild *zBild ) // speichert das Ladebild
  1516. {
  1517. cs.lock();
  1518. if( !verbunden )
  1519. {
  1520. cs.unlock();
  1521. return 0;
  1522. }
  1523. klient->sendeEncrypted( "\x7", 1 );
  1524. char ret = 0;
  1525. klient->getNachrichtEncrypted( &ret, 1 );
  1526. if( ret == 1 )
  1527. {
  1528. klient->sendeEncrypted( "\xB", 1 );
  1529. klient->getNachrichtEncrypted( &ret, 1 );
  1530. if( ret == 1 )
  1531. {
  1532. klient->sendeEncrypted( "\x8", 1 );
  1533. klient->getNachrichtEncrypted( &ret, 1 );
  1534. if( ret == 1 )
  1535. {
  1536. int br = zBild->getBreite();
  1537. int hö = zBild->getHeight();
  1538. klient->sendeEncrypted( (char*)&br, 4 );
  1539. klient->sendeEncrypted( (char*)&hö, 4 );
  1540. __int64 län = br * hö * 4;
  1541. char *buffer = (char*)zBild->getBuffer();
  1542. for( int i = 0, l = län > 2048 ? 2048 : (int)län; län > 0; i += l, län -= l, l = län > 2048 ? 2048 : (int)län )
  1543. klient->sende( &( buffer[ i ] ), l );
  1544. klient->getNachrichtEncrypted( &ret, 1 );
  1545. }
  1546. }
  1547. }
  1548. if( ret == 3 )
  1549. {
  1550. char byte = 0;
  1551. klient->getNachrichtEncrypted( &byte, 1 );
  1552. char *f = new char[ byte + 1 ];
  1553. f[ byte ] = 0;
  1554. klient->getNachrichtEncrypted( f, byte );
  1555. fehler->setText( f );
  1556. delete[] f;
  1557. cs.unlock();
  1558. return 0;
  1559. }
  1560. cs.unlock();
  1561. return ret == 1;
  1562. }
  1563. bool EditorKlient::ladeTeamDaten( SpielerTeamStruktur *sts ) // läht die Team Daten
  1564. {
  1565. cs.lock();
  1566. if( !verbunden )
  1567. {
  1568. cs.unlock();
  1569. return 0;
  1570. }
  1571. klient->sendeEncrypted( "\x7", 1 );
  1572. char ret = 0;
  1573. klient->getNachrichtEncrypted( &ret, 1 );
  1574. if( ret == 1 )
  1575. {
  1576. klient->sendeEncrypted( "\xC", 1 );
  1577. klient->getNachrichtEncrypted( &ret, 1 );
  1578. if( ret == 1 )
  1579. {
  1580. klient->sendeEncrypted( "\x1", 1 );
  1581. klient->getNachrichtEncrypted( &ret, 1 );
  1582. if( ret == 1 )
  1583. {
  1584. klient->getNachrichtEncrypted( (char*)&sts->spielerAnzahl, 4 );
  1585. klient->getNachrichtEncrypted( (char*)&sts->teamAnzahl, 4 );
  1586. for( int i = 0; i < sts->spielerAnzahl; i++ )
  1587. {
  1588. int f = 0;
  1589. klient->getNachrichtEncrypted( (char*)&f, 4 );
  1590. sts->spielerFarbe->set( f, i );
  1591. }
  1592. for( int i = 0; i < sts->teamAnzahl; i++ )
  1593. {
  1594. int f = 0;
  1595. klient->getNachrichtEncrypted( (char*)&f, 4 );
  1596. sts->teamFarbe->set( f, i );
  1597. }
  1598. for( int i = 0; i < sts->teamAnzahl; i++ )
  1599. {
  1600. char l = 0;
  1601. klient->getNachrichtEncrypted( &l, 1 );
  1602. char *n = new char[ l + 1 ];
  1603. n[ l ] = 0;
  1604. klient->getNachrichtEncrypted( n, l );
  1605. sts->teamName->set( new Text( n ), i );
  1606. delete[] n;
  1607. }
  1608. for( int i = 0; i < sts->teamAnzahl; i++ )
  1609. {
  1610. int g = 0;
  1611. klient->getNachrichtEncrypted( (char*)&g, 4 );
  1612. sts->teamGröße->set( g, i );
  1613. }
  1614. cs.unlock();
  1615. return 1;
  1616. }
  1617. }
  1618. }
  1619. if( ret == 3 )
  1620. {
  1621. char byte = 0;
  1622. klient->getNachrichtEncrypted( &byte, 1 );
  1623. char *f = new char[ byte + 1 ];
  1624. f[ byte ] = 0;
  1625. klient->getNachrichtEncrypted( f, byte );
  1626. fehler->setText( f );
  1627. delete[] f;
  1628. cs.unlock();
  1629. return 0;
  1630. }
  1631. cs.unlock();
  1632. return 0;
  1633. }
  1634. bool EditorKlient::speicherTeamDaten( SpielerTeamStruktur *sts ) // speichert die Team Daten
  1635. {
  1636. cs.lock();
  1637. if( !verbunden )
  1638. {
  1639. cs.unlock();
  1640. return 0;
  1641. }
  1642. klient->sendeEncrypted( "\x7", 1 );
  1643. char ret = 0;
  1644. klient->getNachrichtEncrypted( &ret, 1 );
  1645. if( ret == 1 )
  1646. {
  1647. klient->sendeEncrypted( "\xC", 1 );
  1648. klient->getNachrichtEncrypted( &ret, 1 );
  1649. if( ret == 1 )
  1650. {
  1651. klient->sendeEncrypted( "\x2", 1 );
  1652. klient->getNachrichtEncrypted( &ret, 1 );
  1653. if( ret == 1 )
  1654. {
  1655. klient->sendeEncrypted( (char*)&sts->spielerAnzahl, 4 );
  1656. klient->sendeEncrypted( (char*)&sts->teamAnzahl, 4 );
  1657. for( int i = 0; i < sts->spielerAnzahl; i++ )
  1658. {
  1659. int f = sts->spielerFarbe->get( i );
  1660. klient->sendeEncrypted( (char*)&f, 4 );
  1661. }
  1662. for( int i = 0; i < sts->teamAnzahl; i++ )
  1663. {
  1664. int f = sts->teamFarbe->get( i );
  1665. klient->sendeEncrypted( (char*)&f, 4 );
  1666. }
  1667. for( int i = 0; i < sts->teamAnzahl; i++ )
  1668. {
  1669. char l = (char)sts->teamName->z( i )->getLength();
  1670. klient->sendeEncrypted( &l, 1 );
  1671. klient->sendeEncrypted( sts->teamName->z( i )->getText(), l );
  1672. }
  1673. for( int i = 0; i < sts->teamAnzahl; i++ )
  1674. {
  1675. int g = sts->teamGröße->get( i );
  1676. klient->sendeEncrypted( (char*)&g, 4 );
  1677. }
  1678. cs.unlock();
  1679. return 1;
  1680. }
  1681. }
  1682. }
  1683. if( ret == 3 )
  1684. {
  1685. char byte = 0;
  1686. klient->getNachrichtEncrypted( &byte, 1 );
  1687. char *f = new char[ byte + 1 ];
  1688. f[ byte ] = 0;
  1689. klient->getNachrichtEncrypted( f, byte );
  1690. fehler->setText( f );
  1691. delete[] f;
  1692. cs.unlock();
  1693. return 0;
  1694. }
  1695. cs.unlock();
  1696. return 0;
  1697. }
  1698. bool EditorKlient::deNeueDatei( char typ, Text *zName ) // DateienEditor: Erstellt neue Datei (typ: 0=ordner 1=bild 2=modell2d 3=sound
  1699. {
  1700. cs.lock();
  1701. if( !verbunden )
  1702. {
  1703. cs.unlock();
  1704. return 0;
  1705. }
  1706. klient->sendeEncrypted( "\x7", 1 );
  1707. char ret = 0;
  1708. klient->getNachrichtEncrypted( &ret, 1 );
  1709. if( ret == 1 )
  1710. {
  1711. klient->sendeEncrypted( "\xD", 1 );
  1712. klient->getNachrichtEncrypted( &ret, 1 );
  1713. if( ret == 1 )
  1714. {
  1715. klient->sendeEncrypted( "\x1", 1 );
  1716. klient->getNachrichtEncrypted( &ret, 1 );
  1717. if( ret == 1 )
  1718. {
  1719. klient->sendeEncrypted( &typ, 1 );
  1720. char l = (char)zName->getLength();
  1721. klient->sendeEncrypted( &l, 1 );
  1722. if( l )
  1723. klient->sendeEncrypted( zName->getText(), l );
  1724. klient->getNachrichtEncrypted( &ret, 1 );
  1725. }
  1726. }
  1727. }
  1728. if( ret == 3 )
  1729. {
  1730. char byte = 0;
  1731. klient->getNachrichtEncrypted( &byte, 1 );
  1732. char *f = new char[ byte + 1 ];
  1733. f[ byte ] = 0;
  1734. klient->getNachrichtEncrypted( f, byte );
  1735. fehler->setText( f );
  1736. delete[] f;
  1737. cs.unlock();
  1738. return 0;
  1739. }
  1740. cs.unlock();
  1741. return ret == 1;
  1742. }
  1743. bool EditorKlient::deOrdnerÖffnen( Text *zName ) // DateienEditor: Öffnet Ordner
  1744. {
  1745. cs.lock();
  1746. if( !verbunden )
  1747. {
  1748. cs.unlock();
  1749. return 0;
  1750. }
  1751. klient->sendeEncrypted( "\x7", 1 );
  1752. char ret = 0;
  1753. klient->getNachrichtEncrypted( &ret, 1 );
  1754. if( ret == 1 )
  1755. {
  1756. klient->sendeEncrypted( "\xD", 1 );
  1757. klient->getNachrichtEncrypted( &ret, 1 );
  1758. if( ret == 1 )
  1759. {
  1760. klient->sendeEncrypted( "\x2", 1 );
  1761. klient->getNachrichtEncrypted( &ret, 1 );
  1762. if( ret == 1 )
  1763. {
  1764. char län = (char)zName->getLength();
  1765. klient->sendeEncrypted( &län, 1 );
  1766. if( län )
  1767. klient->sendeEncrypted( zName->getText(), län );
  1768. klient->getNachrichtEncrypted( &ret, 1 );
  1769. }
  1770. }
  1771. }
  1772. if( ret == 3 )
  1773. {
  1774. char byte = 0;
  1775. klient->getNachrichtEncrypted( &byte, 1 );
  1776. char *f = new char[ byte + 1 ];
  1777. f[ byte ] = 0;
  1778. klient->getNachrichtEncrypted( f, byte );
  1779. fehler->setText( f );
  1780. delete[] f;
  1781. cs.unlock();
  1782. return 0;
  1783. }
  1784. cs.unlock();
  1785. return ret == 1;
  1786. }
  1787. Bild *EditorKlient::deBildLaden( Text *zDatei, Text *zBild, FBalken *zF ) // DateienEditor: Bild laden
  1788. {
  1789. cs.lock();
  1790. if( !verbunden )
  1791. {
  1792. cs.unlock();
  1793. return 0;
  1794. }
  1795. Bild *retB = 0;
  1796. klient->sendeEncrypted( "\x7", 1 );
  1797. char ret = 0;
  1798. klient->getNachrichtEncrypted( &ret, 1 );
  1799. if( ret == 1 )
  1800. {
  1801. klient->sendeEncrypted( "\xD", 1 );
  1802. klient->getNachrichtEncrypted( &ret, 1 );
  1803. if( ret == 1 )
  1804. {
  1805. klient->sendeEncrypted( "\x3", 1 );
  1806. klient->getNachrichtEncrypted( &ret, 1 );
  1807. if( ret == 1 )
  1808. {
  1809. char län = (char)zDatei->getLength();
  1810. klient->sendeEncrypted( &län, 1 );
  1811. if( län )
  1812. klient->sendeEncrypted( zDatei->getText(), län );
  1813. län = (char)zBild->getLength();
  1814. klient->sendeEncrypted( &län, 1 );
  1815. if( län )
  1816. klient->sendeEncrypted( zBild->getText(), län );
  1817. klient->getNachrichtEncrypted( &ret, 1 );
  1818. if( ret == 1 )
  1819. {
  1820. int br = 0;
  1821. int hö = 0;
  1822. klient->getNachrichtEncrypted( (char*)&br, 4 );
  1823. klient->getNachrichtEncrypted( (char*)&hö, 4 );
  1824. retB = new Bild();
  1825. retB->neuBild( br, hö, 0 );
  1826. char *buffer = (char*)retB->getBuffer();
  1827. __int64 län = br * hö * 4;
  1828. zF->setAktionAnzahl( län );
  1829. for( int i = 0, l = län > 2048 ? 2048 : (int)län; län > 0; l = län > 2048 ? 2048 : (int)län )
  1830. {
  1831. klient->getNachricht( &( buffer[ i ] ), l );
  1832. i += l;
  1833. län -= l;
  1834. zF->aktionPlus( l );
  1835. }
  1836. }
  1837. }
  1838. }
  1839. }
  1840. if( ret == 3 )
  1841. {
  1842. char byte = 0;
  1843. klient->getNachrichtEncrypted( &byte, 1 );
  1844. char *f = new char[ byte + 1 ];
  1845. f[ byte ] = 0;
  1846. klient->getNachrichtEncrypted( f, byte );
  1847. fehler->setText( f );
  1848. delete[] f;
  1849. cs.unlock();
  1850. return 0;
  1851. }
  1852. cs.unlock();
  1853. if( !ret && retB )
  1854. retB = retB->release();
  1855. return retB;
  1856. }
  1857. bool EditorKlient::deDateiLöschen( Text *zName ) // DateienEditor: Löscht Datei
  1858. {
  1859. cs.lock();
  1860. if( !verbunden )
  1861. {
  1862. cs.unlock();
  1863. return 0;
  1864. }
  1865. klient->sendeEncrypted( "\x7", 1 );
  1866. char ret = 0;
  1867. klient->getNachrichtEncrypted( &ret, 1 );
  1868. if( ret == 1 )
  1869. {
  1870. klient->sendeEncrypted( "\xD", 1 );
  1871. klient->getNachrichtEncrypted( &ret, 1 );
  1872. if( ret == 1 )
  1873. {
  1874. klient->sendeEncrypted( "\x4", 1 );
  1875. klient->getNachrichtEncrypted( &ret, 1 );
  1876. if( ret == 1 )
  1877. {
  1878. char län = (char)zName->getLength();
  1879. klient->sendeEncrypted( &län, 1 );
  1880. if( län )
  1881. klient->sendeEncrypted( zName->getText(), län );
  1882. klient->getNachrichtEncrypted( &ret, 1 );
  1883. }
  1884. }
  1885. }
  1886. if( ret == 3 )
  1887. {
  1888. char byte = 0;
  1889. klient->getNachrichtEncrypted( &byte, 1 );
  1890. char *f = new char[ byte + 1 ];
  1891. f[ byte ] = 0;
  1892. klient->getNachrichtEncrypted( f, byte );
  1893. fehler->setText( f );
  1894. delete[] f;
  1895. cs.unlock();
  1896. return 0;
  1897. }
  1898. cs.unlock();
  1899. return ret == 1;
  1900. }
  1901. bool EditorKlient::deBildLöschen( Text *zDatei, Text *zBild ) // DateienEditor: Löscht Bild aus Datei
  1902. {
  1903. cs.lock();
  1904. if( !verbunden )
  1905. {
  1906. cs.unlock();
  1907. return 0;
  1908. }
  1909. klient->sendeEncrypted( "\x7", 1 );
  1910. char ret = 0;
  1911. klient->getNachrichtEncrypted( &ret, 1 );
  1912. if( ret == 1 )
  1913. {
  1914. klient->sendeEncrypted( "\xD", 1 );
  1915. klient->getNachrichtEncrypted( &ret, 1 );
  1916. if( ret == 1 )
  1917. {
  1918. klient->sendeEncrypted( "\x5", 1 );
  1919. klient->getNachrichtEncrypted( &ret, 1 );
  1920. if( ret == 1 )
  1921. {
  1922. char l = (char)zDatei->getLength();
  1923. klient->sendeEncrypted( &l, 1 );
  1924. if( l )
  1925. klient->sendeEncrypted( zDatei->getText(), l );
  1926. l = (char)zBild->getLength();
  1927. klient->sendeEncrypted( &l, 1 );
  1928. if( l )
  1929. klient->sendeEncrypted( zBild->getText(), l );
  1930. klient->getNachrichtEncrypted( &ret, 1 );
  1931. }
  1932. }
  1933. }
  1934. if( ret == 3 )
  1935. {
  1936. char byte = 0;
  1937. klient->getNachrichtEncrypted( &byte, 1 );
  1938. char *f = new char[ byte + 1 ];
  1939. f[ byte ] = 0;
  1940. klient->getNachrichtEncrypted( f, byte );
  1941. fehler->setText( f );
  1942. delete[] f;
  1943. cs.unlock();
  1944. return 0;
  1945. }
  1946. cs.unlock();
  1947. return ret == 1;
  1948. }
  1949. bool EditorKlient::deBildSpeichern( Text *zDatei, Text *zName, Bild *zBild, FBalken *zF ) // DateienEditor: Speichert Bild
  1950. {
  1951. cs.lock();
  1952. if( !verbunden )
  1953. {
  1954. cs.unlock();
  1955. return 0;
  1956. }
  1957. klient->sendeEncrypted( "\x7", 1 );
  1958. char ret = 0;
  1959. klient->getNachrichtEncrypted( &ret, 1 );
  1960. if( ret == 1 )
  1961. {
  1962. klient->sendeEncrypted( "\xD", 1 );
  1963. klient->getNachrichtEncrypted( &ret, 1 );
  1964. if( ret == 1 )
  1965. {
  1966. klient->sendeEncrypted( "\x6", 1 );
  1967. klient->getNachrichtEncrypted( &ret, 1 );
  1968. if( ret == 1 )
  1969. {
  1970. char län = (char)zDatei->getLength();
  1971. klient->sendeEncrypted( &län, 1 );
  1972. if( län )
  1973. klient->sendeEncrypted( zDatei->getText(), län );
  1974. län = (char)zName->getLength();
  1975. klient->sendeEncrypted( &län, 1 );
  1976. if( län )
  1977. klient->sendeEncrypted( zName->getText(), län );
  1978. klient->getNachrichtEncrypted( &ret, 1 );
  1979. if( ret == 1 )
  1980. {
  1981. int br = zBild->getBreite();
  1982. int hö = zBild->getHeight();
  1983. klient->sendeEncrypted( (char*)&br, 4 );
  1984. klient->sendeEncrypted( (char*)&hö, 4 );
  1985. char *buffer = (char*)zBild->getBuffer();
  1986. __int64 gr = br * hö * 4;
  1987. zF->setAktionAnzahl( gr );
  1988. for( int i = 0, l = gr > 2048 ? 2048 : (int)gr; gr > 0; i += l, gr -= l, l = gr > 2048 ? 2048 : (int)gr )
  1989. {
  1990. klient->sende( &( buffer[ i ] ), l );
  1991. zF->aktionPlus( l );
  1992. }
  1993. klient->getNachrichtEncrypted( &ret, 1 );
  1994. }
  1995. }
  1996. }
  1997. }
  1998. if( ret == 3 )
  1999. {
  2000. char byte = 0;
  2001. klient->getNachrichtEncrypted( &byte, 1 );
  2002. char *f = new char[ byte + 1 ];
  2003. f[ byte ] = 0;
  2004. klient->getNachrichtEncrypted( f, byte );
  2005. fehler->setText( f );
  2006. delete[] f;
  2007. cs.unlock();
  2008. return 0;
  2009. }
  2010. cs.unlock();
  2011. return ret == 1;
  2012. }
  2013. int EditorKlient::deGetDateiListe( RCArray< Text > *zNamen ) // DateienEditor: Datei Liste herunterladen
  2014. {
  2015. cs.lock();
  2016. if( !verbunden )
  2017. {
  2018. cs.unlock();
  2019. return 0;
  2020. }
  2021. klient->sendeEncrypted( "\x7", 1 );
  2022. char ret = 0;
  2023. klient->getNachrichtEncrypted( &ret, 1 );
  2024. if( ret == 1 )
  2025. {
  2026. klient->sendeEncrypted( "\xD", 1 );
  2027. klient->getNachrichtEncrypted( &ret, 1 );
  2028. if( ret == 1 )
  2029. {
  2030. klient->sendeEncrypted( "\x7", 1 );
  2031. klient->getNachrichtEncrypted( &ret, 1 );
  2032. if( ret == 1 )
  2033. {
  2034. int anz = 0;
  2035. klient->getNachrichtEncrypted( (char*)&anz, 4 );
  2036. for( int i = 0; i < anz; i++ )
  2037. {
  2038. char l = 0;
  2039. klient->getNachrichtEncrypted( &l, 1 );
  2040. char *n = new char[ l + 1 ];
  2041. n[ l ] = 0;
  2042. if( l )
  2043. klient->getNachrichtEncrypted( n, l );
  2044. zNamen->add( new Text( n ) );
  2045. delete[] n;
  2046. }
  2047. cs.unlock();
  2048. return anz;
  2049. }
  2050. }
  2051. }
  2052. if( ret == 3 )
  2053. {
  2054. char byte = 0;
  2055. klient->getNachrichtEncrypted( &byte, 1 );
  2056. char *f = new char[ byte + 1 ];
  2057. f[ byte ] = 0;
  2058. klient->getNachrichtEncrypted( f, byte );
  2059. fehler->setText( f );
  2060. delete[] f;
  2061. cs.unlock();
  2062. return -1;
  2063. }
  2064. cs.unlock();
  2065. return ret == 1;
  2066. }
  2067. int EditorKlient::deGetBildListe( Text *zDatei, RCArray< Text > *zNamen ) // DateienEditor: Liste mit in der Datei gespeicherten Bildern
  2068. {
  2069. cs.lock();
  2070. if( !verbunden )
  2071. {
  2072. cs.unlock();
  2073. return 0;
  2074. }
  2075. klient->sendeEncrypted( "\x7", 1 );
  2076. char ret = 0;
  2077. klient->getNachrichtEncrypted( &ret, 1 );
  2078. if( ret == 1 )
  2079. {
  2080. klient->sendeEncrypted( "\xD", 1 );
  2081. klient->getNachrichtEncrypted( &ret, 1 );
  2082. if( ret == 1 )
  2083. {
  2084. klient->sendeEncrypted( "\x8", 1 );
  2085. klient->getNachrichtEncrypted( &ret, 1 );
  2086. if( ret == 1 )
  2087. {
  2088. char l = (char)zDatei->getLength();
  2089. klient->sendeEncrypted( &l, 1 );
  2090. klient->sendeEncrypted( zDatei->getText(), l );
  2091. klient->getNachrichtEncrypted( &ret, 1 );
  2092. if( ret == 1 )
  2093. {
  2094. int anz = 0;
  2095. klient->getNachrichtEncrypted( (char*)&anz, 4 );
  2096. for( int i = 0; i < anz; i++ )
  2097. {
  2098. klient->getNachrichtEncrypted( &l, 1 );
  2099. char *n = new char[ l + 1 ];
  2100. n[ l ] = 0;
  2101. if( l )
  2102. klient->getNachrichtEncrypted( n, l );
  2103. zNamen->add( new Text( n ) );
  2104. delete[] n;
  2105. }
  2106. cs.unlock();
  2107. return anz;
  2108. }
  2109. }
  2110. }
  2111. }
  2112. if( ret == 3 )
  2113. {
  2114. char byte = 0;
  2115. klient->getNachrichtEncrypted( &byte, 1 );
  2116. char *f = new char[ byte + 1 ];
  2117. f[ byte ] = 0;
  2118. klient->getNachrichtEncrypted( f, byte );
  2119. fehler->setText( f );
  2120. delete[] f;
  2121. cs.unlock();
  2122. return 0;
  2123. }
  2124. cs.unlock();
  2125. return ret == 1;
  2126. }
  2127. int EditorKlient::deGetModelListe( Text *zDatei, RCArray< Text > *zNamen ) // DateienEditor Liste mit in der Datei gespeicherten Modellen
  2128. {
  2129. cs.lock();
  2130. if( !verbunden )
  2131. {
  2132. cs.unlock();
  2133. return 0;
  2134. }
  2135. klient->sendeEncrypted( "\x7", 1 );
  2136. char ret = 0;
  2137. klient->getNachrichtEncrypted( &ret, 1 );
  2138. if( ret == 1 )
  2139. {
  2140. klient->sendeEncrypted( "\xD", 1 );
  2141. klient->getNachrichtEncrypted( &ret, 1 );
  2142. if( ret == 1 )
  2143. {
  2144. klient->sendeEncrypted( "\x9", 1 );
  2145. klient->getNachrichtEncrypted( &ret, 1 );
  2146. if( ret == 1 )
  2147. {
  2148. char l = (char)zDatei->getLength();
  2149. klient->sendeEncrypted( &l, 1 );
  2150. klient->sendeEncrypted( zDatei->getText(), l );
  2151. klient->getNachrichtEncrypted( &ret, 1 );
  2152. if( ret == 1 )
  2153. {
  2154. int anz = 0;
  2155. klient->getNachrichtEncrypted( (char*)&anz, 4 );
  2156. for( int i = 0; i < anz; i++ )
  2157. {
  2158. klient->getNachrichtEncrypted( &l, 1 );
  2159. char *n = new char[ l + 1 ];
  2160. n[ l ] = 0;
  2161. if( l )
  2162. klient->getNachrichtEncrypted( n, l );
  2163. zNamen->add( new Text( n ) );
  2164. delete[] n;
  2165. }
  2166. cs.unlock();
  2167. return anz;
  2168. }
  2169. }
  2170. }
  2171. }
  2172. if( ret == 3 )
  2173. {
  2174. char byte = 0;
  2175. klient->getNachrichtEncrypted( &byte, 1 );
  2176. char *f = new char[ byte + 1 ];
  2177. f[ byte ] = 0;
  2178. klient->getNachrichtEncrypted( f, byte );
  2179. fehler->setText( f );
  2180. delete[] f;
  2181. cs.unlock();
  2182. return 0;
  2183. }
  2184. cs.unlock();
  2185. return ret == 1;
  2186. }
  2187. int EditorKlient::deGetSoundListe( Text *zDatei, RCArray< Text > *zNamen ) // DateienEditor: Liste mit in der Datei gespeicherten Tönen
  2188. {
  2189. cs.lock();
  2190. if( !verbunden )
  2191. {
  2192. cs.unlock();
  2193. return 0;
  2194. }
  2195. klient->sendeEncrypted( "\x7", 1 );
  2196. char ret = 0;
  2197. klient->getNachrichtEncrypted( &ret, 1 );
  2198. if( ret == 1 )
  2199. {
  2200. klient->sendeEncrypted( "\xD", 1 );
  2201. klient->getNachrichtEncrypted( &ret, 1 );
  2202. if( ret == 1 )
  2203. {
  2204. klient->sendeEncrypted( "\xA", 1 );
  2205. klient->getNachrichtEncrypted( &ret, 1 );
  2206. if( ret == 1 )
  2207. {
  2208. char l = (char)zDatei->getLength();
  2209. klient->sendeEncrypted( &l, 1 );
  2210. klient->sendeEncrypted( zDatei->getText(), l );
  2211. klient->getNachrichtEncrypted( &ret, 1 );
  2212. if( ret == 1 )
  2213. {
  2214. int anz = 0;
  2215. klient->getNachrichtEncrypted( (char*)&anz, 4 );
  2216. for( int i = 0; i < anz; i++ )
  2217. {
  2218. klient->getNachrichtEncrypted( &l, 1 );
  2219. char *n = new char[ l + 1 ];
  2220. n[ l ] = 0;
  2221. if( l )
  2222. klient->getNachrichtEncrypted( n, l );
  2223. zNamen->add( new Text( n ) );
  2224. delete[] n;
  2225. }
  2226. cs.unlock();
  2227. return anz;
  2228. }
  2229. }
  2230. }
  2231. }
  2232. if( ret == 3 )
  2233. {
  2234. char byte = 0;
  2235. klient->getNachrichtEncrypted( &byte, 1 );
  2236. char *f = new char[ byte + 1 ];
  2237. f[ byte ] = 0;
  2238. klient->getNachrichtEncrypted( f, byte );
  2239. fehler->setText( f );
  2240. delete[] f;
  2241. cs.unlock();
  2242. return 0;
  2243. }
  2244. cs.unlock();
  2245. return ret == 1;
  2246. }
  2247. bool EditorKlient::deModelLöschen( Text *zDatei, Text *zModel ) // DateienEditor: Löscht Modell
  2248. {
  2249. cs.lock();
  2250. if( !verbunden )
  2251. {
  2252. cs.unlock();
  2253. return 0;
  2254. }
  2255. klient->sendeEncrypted( "\x7", 1 );
  2256. char ret = 0;
  2257. klient->getNachrichtEncrypted( &ret, 1 );
  2258. if( ret == 1 )
  2259. {
  2260. klient->sendeEncrypted( "\xD", 1 );
  2261. klient->getNachrichtEncrypted( &ret, 1 );
  2262. if( ret == 1 )
  2263. {
  2264. klient->sendeEncrypted( "\xB", 1 );
  2265. klient->getNachrichtEncrypted( &ret, 1 );
  2266. if( ret == 1 )
  2267. {
  2268. char l = (char)zDatei->getLength();
  2269. klient->sendeEncrypted( &l, 1 );
  2270. klient->sendeEncrypted( zDatei->getText(), l );
  2271. klient->getNachrichtEncrypted( &ret, 1 );
  2272. if( ret == 1 )
  2273. {
  2274. l = (char)zModel->getLength();
  2275. klient->sendeEncrypted( &l, 1 );
  2276. klient->sendeEncrypted( zModel->getText(), l );
  2277. klient->getNachrichtEncrypted( &ret, 1 );
  2278. }
  2279. }
  2280. }
  2281. }
  2282. if( ret == 3 )
  2283. {
  2284. char byte = 0;
  2285. klient->getNachrichtEncrypted( &byte, 1 );
  2286. char *f = new char[ byte + 1 ];
  2287. f[ byte ] = 0;
  2288. klient->getNachrichtEncrypted( f, byte );
  2289. fehler->setText( f );
  2290. delete[] f;
  2291. cs.unlock();
  2292. return 0;
  2293. }
  2294. cs.unlock();
  2295. return ret == 1;
  2296. }
  2297. bool EditorKlient::deSoundLöschen( Text *zDatei, Text *zSound ) // DateienEditor: Löscht Ton
  2298. {
  2299. cs.lock();
  2300. if( !verbunden )
  2301. {
  2302. cs.unlock();
  2303. return 0;
  2304. }
  2305. klient->sendeEncrypted( "\x7", 1 );
  2306. char ret = 0;
  2307. klient->getNachrichtEncrypted( &ret, 1 );
  2308. if( ret == 1 )
  2309. {
  2310. klient->sendeEncrypted( "\xD", 1 );
  2311. klient->getNachrichtEncrypted( &ret, 1 );
  2312. if( ret == 1 )
  2313. {
  2314. klient->sendeEncrypted( "\xC", 1 );
  2315. klient->getNachrichtEncrypted( &ret, 1 );
  2316. if( ret == 1 )
  2317. {
  2318. char l = (char)zDatei->getLength();
  2319. klient->sendeEncrypted( &l, 1 );
  2320. klient->sendeEncrypted( zDatei->getText(), l );
  2321. klient->getNachrichtEncrypted( &ret, 1 );
  2322. if( ret == 1 )
  2323. {
  2324. l = (char)zSound->getLength();
  2325. klient->sendeEncrypted( &l, 1 );
  2326. klient->sendeEncrypted( zSound->getText(), l );
  2327. klient->getNachrichtEncrypted( &ret, 1 );
  2328. }
  2329. }
  2330. }
  2331. }
  2332. if( ret == 3 )
  2333. {
  2334. char byte = 0;
  2335. klient->getNachrichtEncrypted( &byte, 1 );
  2336. char *f = new char[ byte + 1 ];
  2337. f[ byte ] = 0;
  2338. klient->getNachrichtEncrypted( f, byte );
  2339. fehler->setText( f );
  2340. delete[] f;
  2341. cs.unlock();
  2342. return 0;
  2343. }
  2344. cs.unlock();
  2345. return ret == 1;
  2346. }
  2347. Model2DData *EditorKlient::deModelLaden( Text *zDatei, Text *zModel, FBalken *zF ) // DateienEditor: läd ein Model herunter
  2348. {
  2349. cs.lock();
  2350. if( !verbunden )
  2351. {
  2352. cs.unlock();
  2353. return 0;
  2354. }
  2355. klient->sendeEncrypted( "\x7", 1 );
  2356. char ret = 0;
  2357. klient->getNachrichtEncrypted( &ret, 1 );
  2358. if( ret == 1 )
  2359. {
  2360. klient->sendeEncrypted( "\xD", 1 );
  2361. klient->getNachrichtEncrypted( &ret, 1 );
  2362. if( ret == 1 )
  2363. {
  2364. klient->sendeEncrypted( "\xD", 1 );
  2365. klient->getNachrichtEncrypted( &ret, 1 );
  2366. if( ret == 1 )
  2367. {
  2368. char l = (char)zDatei->getLength();
  2369. klient->sendeEncrypted( &l, 1 );
  2370. klient->sendeEncrypted( zDatei->getText(), l );
  2371. klient->getNachrichtEncrypted( &ret, 1 );
  2372. if( ret == 1 )
  2373. {
  2374. l = (char)zModel->getLength();
  2375. klient->sendeEncrypted( &l, 1 );
  2376. klient->sendeEncrypted( zModel->getText(), l );
  2377. klient->getNachrichtEncrypted( &ret, 1 );
  2378. if( ret == 1 )
  2379. {
  2380. int anz = 0;
  2381. klient->getNachrichtEncrypted( (char*)&anz, 4 );
  2382. zF->setAktionAnzahl( anz );
  2383. Array< Polygon2D > *pol = new Array< Polygon2D >();
  2384. for( int i = 0; i < anz; i++ )
  2385. {
  2386. Polygon2D p;
  2387. p.schwerpunkt = new Vertex( 0, 0 );
  2388. p.vertex = new Array< Vertex >();
  2389. p.tKordinaten = new Array< Vertex >();
  2390. klient->getNachrichtEncrypted( (char*)&p.transparent, 1 );
  2391. char nLän = 0;
  2392. klient->getNachrichtEncrypted( &nLän, 1 );
  2393. char *txt = new char[ nLän + 1 ];
  2394. if( nLän )
  2395. klient->getNachrichtEncrypted( txt, nLän );
  2396. txt[ nLän ] = 0;
  2397. p.name = new Text( txt );
  2398. delete[] txt;
  2399. int anz2 = 0;
  2400. klient->getNachrichtEncrypted( (char*)&anz2, 4 );
  2401. for( int j = 0; j < anz2; j++ )
  2402. {
  2403. Vertex v;
  2404. klient->getNachrichtEncrypted( (char*)&v.x, 4 );
  2405. klient->getNachrichtEncrypted( (char*)&v.y, 4 );
  2406. *p.schwerpunkt += v * (float)( 1.0 / anz2 );
  2407. Vertex t;
  2408. klient->getNachrichtEncrypted( (char*)&t.x, 4 );
  2409. klient->getNachrichtEncrypted( (char*)&t.y, 4 );
  2410. p.vertex->add( v );
  2411. p.tKordinaten->add( t );
  2412. }
  2413. pol->add( p );
  2414. zF->aktionPlus();
  2415. }
  2416. Model2DData *data = new Model2DData();
  2417. data->erstelleModell( pol );
  2418. cs.unlock();
  2419. return data;
  2420. }
  2421. }
  2422. }
  2423. }
  2424. }
  2425. if( ret == 3 )
  2426. {
  2427. char byte = 0;
  2428. klient->getNachrichtEncrypted( &byte, 1 );
  2429. char *f = new char[ byte + 1 ];
  2430. f[ byte ] = 0;
  2431. klient->getNachrichtEncrypted( f, byte );
  2432. fehler->setText( f );
  2433. delete[] f;
  2434. cs.unlock();
  2435. return 0;
  2436. }
  2437. cs.unlock();
  2438. return 0;
  2439. }
  2440. GSL::GSLSoundV *EditorKlient::deSoundLaden( Text *zDatei, Text *zSound, FBalken *zF ) // DateienEditor: läd Sound herunter
  2441. {
  2442. HMODULE gslDll = dllDateien->ladeDLL( "GSL.dll", "data/bin/GSL.dll" );
  2443. if( !gslDll )
  2444. {
  2445. fehler->setText( "Die DLL Datei 'data/bin/GSL.dll' wurde nicht gefunden." );
  2446. return 0;
  2447. }
  2448. GetGSLDatei getGSLDatei = (GetGSLDatei)GetProcAddress( gslDll, "getGSLDatei" );
  2449. if( !getGSLDatei )
  2450. {
  2451. fehler->setText( "Der Einstiegspunkt 'getGSLDatei' wurde in der Datei 'data/bin/GSL.dll' nicht gefunden." );
  2452. return 0;
  2453. }
  2454. DateiRemove( "data/tmp/editor/dateien/sounds/tmp.gsl" );
  2455. DateiPfadErstellen( "data/tmp/editor/dateien/sounds/tmp.gsl" );
  2456. GSL::GSLDateiV *gslDatei = getGSLDatei();
  2457. gslDatei->setDatei( "data/tmp/editor/dateien/sounds/tmp.gsl" );
  2458. cs.lock();
  2459. if( !verbunden )
  2460. {
  2461. cs.unlock();
  2462. gslDatei->release();
  2463. dllDateien->releaseDLL( "GSL.dll" );
  2464. return 0;
  2465. }
  2466. klient->sendeEncrypted( "\x7", 1 );
  2467. char ret = 0;
  2468. klient->getNachrichtEncrypted( &ret, 1 );
  2469. if( ret == 1 )
  2470. {
  2471. klient->sendeEncrypted( "\xD", 1 );
  2472. klient->getNachrichtEncrypted( &ret, 1 );
  2473. if( ret == 1 )
  2474. {
  2475. klient->sendeEncrypted( "\xE", 1 );
  2476. klient->getNachrichtEncrypted( &ret, 1 );
  2477. if( ret == 1 )
  2478. {
  2479. char l = (char)zDatei->getLength();
  2480. klient->sendeEncrypted( &l, 1 );
  2481. klient->sendeEncrypted( zDatei->getText(), l );
  2482. klient->getNachrichtEncrypted( &ret, 1 );
  2483. if( ret == 1 )
  2484. {
  2485. l = (char)zSound->getLength();
  2486. klient->sendeEncrypted( &l, 1 );
  2487. klient->sendeEncrypted( zSound->getText(), l );
  2488. klient->getNachrichtEncrypted( &ret, 1 );
  2489. if( ret == 1 )
  2490. {
  2491. DownloadSound dws( klient, zF );
  2492. gslDatei->speicherSound( &dws, zSound->getText() );
  2493. GSL::GSLSoundV *s = gslDatei->getSound( zSound->getText() );
  2494. gslDatei->release();
  2495. dllDateien->releaseDLL( "GSL.dll" );
  2496. cs.unlock();
  2497. return s;
  2498. }
  2499. }
  2500. }
  2501. }
  2502. }
  2503. gslDatei->release();
  2504. dllDateien->releaseDLL( "GSL.dll" );
  2505. if( ret == 3 )
  2506. {
  2507. char byte = 0;
  2508. klient->getNachrichtEncrypted( &byte, 1 );
  2509. char *f = new char[ byte + 1 ];
  2510. f[ byte ] = 0;
  2511. klient->getNachrichtEncrypted( f, byte );
  2512. fehler->setText( f );
  2513. delete[] f;
  2514. cs.unlock();
  2515. return 0;
  2516. }
  2517. cs.unlock();
  2518. return 0;
  2519. }
  2520. bool EditorKlient::deModelSpeichern( Text *zDatei, Text *zModel, Model2DData *zData, FBalken *zF ) // DateienEditor: Speichert Modell
  2521. {
  2522. cs.lock();
  2523. if( !verbunden )
  2524. {
  2525. cs.unlock();
  2526. return 0;
  2527. }
  2528. klient->sendeEncrypted( "\x7", 1 );
  2529. char ret = 0;
  2530. klient->getNachrichtEncrypted( &ret, 1 );
  2531. if( ret == 1 )
  2532. {
  2533. klient->sendeEncrypted( "\xD", 1 );
  2534. klient->getNachrichtEncrypted( &ret, 1 );
  2535. if( ret == 1 )
  2536. {
  2537. klient->sendeEncrypted( "\xF", 1 );
  2538. klient->getNachrichtEncrypted( &ret, 1 );
  2539. if( ret == 1 )
  2540. {
  2541. char l = (char)zDatei->getLength();
  2542. klient->sendeEncrypted( &l, 1 );
  2543. klient->sendeEncrypted( zDatei->getText(), l );
  2544. klient->getNachrichtEncrypted( &ret, 1 );
  2545. if( ret == 1 )
  2546. {
  2547. l = (char)zModel->getLength();
  2548. klient->sendeEncrypted( &l, 1 );
  2549. klient->sendeEncrypted( zModel->getText(), l );
  2550. klient->getNachrichtEncrypted( &ret, 1 );
  2551. if( ret == 1 )
  2552. {
  2553. int anz = zData->polygons ? zData->polygons->getEintragAnzahl() : 0;
  2554. zF->setAktionAnzahl( anz );
  2555. klient->sendeEncrypted( (char*)&anz, 4 );
  2556. for( int i = 0; i < anz; i++ )
  2557. {
  2558. Polygon2D pol = zData->polygons->get( i );
  2559. klient->sendeEncrypted( (char*)&pol.transparent, 1 );
  2560. char nLän = pol.name->getLength();
  2561. klient->sendeEncrypted( &nLän, 1 );
  2562. if( nLän )
  2563. klient->sendeEncrypted( pol.name->getText(), nLän );
  2564. int anz2 = pol.vertex->getEintragAnzahl();
  2565. klient->sendeEncrypted( (char*)&anz2, 4 );
  2566. for( int j = 0; j < anz2; j++ )
  2567. {
  2568. Vertex v = pol.vertex->get( j );
  2569. Vertex p;
  2570. if( pol.tKordinaten )
  2571. p = pol.tKordinaten->hat( j ) ? pol.tKordinaten->get( j ) : Vertex( 0, 0 );
  2572. klient->sendeEncrypted( (char*)&v.x, 4 );
  2573. klient->sendeEncrypted( (char*)&v.y, 4 );
  2574. klient->sendeEncrypted( (char*)&p.x, 4 );
  2575. klient->sendeEncrypted( (char*)&p.y, 4 );
  2576. }
  2577. zF->aktionPlus();
  2578. }
  2579. klient->getNachrichtEncrypted( &ret, 1 );
  2580. }
  2581. }
  2582. }
  2583. }
  2584. }
  2585. if( ret == 3 )
  2586. {
  2587. char byte = 0;
  2588. klient->getNachrichtEncrypted( &byte, 1 );
  2589. char *f = new char[ byte + 1 ];
  2590. f[ byte ] = 0;
  2591. klient->getNachrichtEncrypted( f, byte );
  2592. fehler->setText( f );
  2593. delete[] f;
  2594. cs.unlock();
  2595. return 0;
  2596. }
  2597. cs.unlock();
  2598. return ret == 1;
  2599. }
  2600. bool EditorKlient::deSoundSpeichern( Text *zDatei, Text *zSound, GSL::GSLSoundV *zData, FBalken *zF ) // DateienEditor: Speichert Sound
  2601. {
  2602. cs.lock();
  2603. if( !verbunden )
  2604. {
  2605. cs.unlock();
  2606. return 0;
  2607. }
  2608. klient->sendeEncrypted( "\x7", 1 );
  2609. char ret = 0;
  2610. klient->getNachrichtEncrypted( &ret, 1 );
  2611. if( ret == 1 )
  2612. {
  2613. klient->sendeEncrypted( "\xD", 1 );
  2614. klient->getNachrichtEncrypted( &ret, 1 );
  2615. if( ret == 1 )
  2616. {
  2617. klient->sendeEncrypted( "\x10", 1 );
  2618. klient->getNachrichtEncrypted( &ret, 1 );
  2619. if( ret == 1 )
  2620. {
  2621. char l = (char)zDatei->getLength();
  2622. klient->sendeEncrypted( &l, 1 );
  2623. klient->sendeEncrypted( zDatei->getText(), l );
  2624. klient->getNachrichtEncrypted( &ret, 1 );
  2625. if( ret == 1 )
  2626. {
  2627. l = (char)zSound->getLength();
  2628. klient->sendeEncrypted( &l, 1 );
  2629. klient->sendeEncrypted( zSound->getText(), l );
  2630. klient->getNachrichtEncrypted( &ret, 1 );
  2631. if( ret == 1 )
  2632. {
  2633. char channels = zData->istMono() ? 1 : 2;
  2634. klient->sendeEncrypted( &channels, 1 );
  2635. int sample = zData->getSampleRate();
  2636. klient->sendeEncrypted( (char*)&sample, 4 );
  2637. __int64 slän = zData->getDatLength();
  2638. klient->sendeEncrypted( (char*)&slän, 8 );
  2639. zF->setAktionAnzahl( slän );
  2640. zData->open();
  2641. char *buffer = new char[ 2048 ];
  2642. while( slän > 0 )
  2643. {
  2644. int l = slän > 2048 ? 2048 : (int)slän;
  2645. zData->getDaten( buffer, l );
  2646. klient->sende( buffer, l );
  2647. slän -= l;
  2648. zF->aktionPlus( l );
  2649. }
  2650. delete[] buffer;
  2651. zData->close();
  2652. }
  2653. }
  2654. }
  2655. }
  2656. }
  2657. if( ret == 3 )
  2658. {
  2659. char byte = 0;
  2660. klient->getNachrichtEncrypted( &byte, 1 );
  2661. char *f = new char[ byte + 1 ];
  2662. f[ byte ] = 0;
  2663. klient->getNachrichtEncrypted( f, byte );
  2664. fehler->setText( f );
  2665. delete[] f;
  2666. cs.unlock();
  2667. return 0;
  2668. }
  2669. cs.unlock();
  2670. return ret == 1;
  2671. }
  2672. int EditorKlient::getVerkaufStatistik( Array< int > *verkauft, Array< int > *einkommen, Array< int > *gespielt ) // Gibt eine Verkaufsstatistik der letzten 30 Tage zurück
  2673. {
  2674. cs.lock();
  2675. if( !verbunden )
  2676. {
  2677. cs.unlock();
  2678. return 0;
  2679. }
  2680. klient->sendeEncrypted( "\x7", 1 );
  2681. char ret = 0;
  2682. klient->getNachrichtEncrypted( &ret, 1 );
  2683. if( ret == 1 )
  2684. {
  2685. klient->sendeEncrypted( "\x10", 1 );
  2686. klient->getNachrichtEncrypted( &ret, 1 );
  2687. if( ret == 1 )
  2688. {
  2689. int kaufAnz = 0;
  2690. klient->getNachrichtEncrypted( (char*)&kaufAnz, 4 );
  2691. char anz = 0;
  2692. klient->getNachrichtEncrypted( &anz, 1 );
  2693. for( int i = 0; i < anz; i++ )
  2694. {
  2695. int kupfer = 0;
  2696. int kauf = 0;
  2697. int games = 0;
  2698. klient->getNachrichtEncrypted( (char*)&kupfer, 4 );
  2699. klient->getNachrichtEncrypted( (char*)&kauf, 4 );
  2700. klient->getNachrichtEncrypted( (char*)&games, 4 );
  2701. einkommen->add( kupfer );
  2702. verkauft->add( kauf );
  2703. gespielt->add( games );
  2704. }
  2705. cs.unlock();
  2706. return kaufAnz;
  2707. }
  2708. }
  2709. if( ret == 3 )
  2710. {
  2711. char byte = 0;
  2712. klient->getNachrichtEncrypted( &byte, 1 );
  2713. char *f = new char[ byte + 1 ];
  2714. f[ byte ] = 0;
  2715. klient->getNachrichtEncrypted( f, byte );
  2716. fehler->setText( f );
  2717. delete[] f;
  2718. cs.unlock();
  2719. return 0;
  2720. }
  2721. cs.unlock();
  2722. return 0;
  2723. }
  2724. bool EditorKlient::initEditor() // Initialisiert den Editor auf Serverseite
  2725. {
  2726. cs.lock();
  2727. if( !verbunden )
  2728. {
  2729. cs.unlock();
  2730. return 0;
  2731. }
  2732. klient->sendeEncrypted( "\x7", 1 );
  2733. char ret = 0;
  2734. klient->getNachrichtEncrypted( &ret, 1 );
  2735. if( ret == 1 )
  2736. {
  2737. klient->sendeEncrypted( "\xE", 1 );
  2738. klient->getNachrichtEncrypted( &ret, 1 );
  2739. }
  2740. if( ret == 3 )
  2741. {
  2742. char byte = 0;
  2743. klient->getNachrichtEncrypted( &byte, 1 );
  2744. char *f = new char[ byte + 1 ];
  2745. f[ byte ] = 0;
  2746. klient->getNachrichtEncrypted( f, byte );
  2747. fehler->setText( f );
  2748. delete[] f;
  2749. cs.unlock();
  2750. return 0;
  2751. }
  2752. cs.unlock();
  2753. return ret == 1;
  2754. }
  2755. bool EditorKlient::keepAlive() // Erhält die Verbindung aufrecht
  2756. {
  2757. if( !cs.tryLock() )
  2758. return 1;
  2759. if( !verbunden || !klient )
  2760. {
  2761. cs.unlock();
  2762. return 0;
  2763. }
  2764. Framework::logLine( "Verbindungstest zum Editor Server..." );
  2765. char res = 0;
  2766. bool ok = klient->sendeEncrypted( "\x5", 1 );
  2767. ok &= klient->getNachrichtEncrypted( &res, 1 );
  2768. cs.unlock();
  2769. if( res != 1 || !ok )
  2770. {
  2771. Framework::logLine( "Verbindungsabbruch." );
  2772. trenne();
  2773. fehler->setText( "Verbindung unterbrochen: 'Keep Alive' nicht erfolgreich." );
  2774. }
  2775. else
  2776. Framework::logLine( "Verbindung besteht." );
  2777. return res == 1;
  2778. }
  2779. bool EditorKlient::trenne() // trennt sich von dem Editor Server
  2780. {
  2781. cs.lock();
  2782. if( !klient || !verbunden )
  2783. {
  2784. if( klient )
  2785. klient = klient->release();
  2786. cs.unlock();
  2787. return 1;
  2788. }
  2789. Framework::logLine( "Verbindung zum Editor Server wird getrennt..." );
  2790. char serverReturn;
  2791. klient->sendeEncrypted( "\4", 1 );
  2792. klient->getNachrichtEncrypted( &serverReturn, 1 );
  2793. if( serverReturn == 3 )
  2794. {
  2795. char län = 0;
  2796. klient->getNachrichtEncrypted( &län, 1 );
  2797. char *nachricht = new char[ län + 1 ];
  2798. nachricht[ län ] = 0;
  2799. klient->getNachrichtEncrypted( nachricht, län );
  2800. delete[]nachricht;
  2801. }
  2802. klient->sendeEncrypted( "\3", 1 );
  2803. klient->getNachrichtEncrypted( &serverReturn, 1 );
  2804. klient->trenne();
  2805. klient = klient->release();
  2806. verbunden = 0;
  2807. cs.unlock();
  2808. return 1;
  2809. }
  2810. void EditorKlient::lock()
  2811. {
  2812. cs.lock();
  2813. }
  2814. void EditorKlient::unlock()
  2815. {
  2816. cs.unlock();
  2817. }
  2818. Klient *EditorKlient::zKlient() // gibt den Klient zurück
  2819. {
  2820. if( cs.isLocked() && cs.zOwner() && cs.zOwner()->getThreadHandle() == GetCurrentThread() )
  2821. return klient;
  2822. return 0;
  2823. }
  2824. // constant
  2825. bool EditorKlient::istVerbunden() const // prüft, ob mit Editor Server verbunden
  2826. {
  2827. return verbunden;
  2828. }
  2829. char *EditorKlient::getLetzterFehler() const // gibt den Letzten Fehlertext zuück
  2830. {
  2831. return fehler->getText();
  2832. }
  2833. // Reference Counting
  2834. EditorKlientV *EditorKlient::getThis()
  2835. {
  2836. ref++;
  2837. return this;
  2838. }
  2839. EditorKlientV *EditorKlient::release()
  2840. {
  2841. ref--;
  2842. if( !ref )
  2843. delete this;
  2844. return 0;
  2845. }