EditorK.cpp 83 KB

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