pax_global_header00006660000000000000000000000064135216507530014521gustar00rootroot0000000000000052 comment=73b9687531eda45e23eabf4c7eeb29d5e6174db2 assaultcube-1.2.0.2.1/000077500000000000000000000000001352165075300143335ustar00rootroot00000000000000assaultcube-1.2.0.2.1/CHANGELOG000066400000000000000000000012511352165075300155440ustar00rootroot00000000000000changelog version: 1.2.0.2.1 (deb) ---------------------------------- * Added icon in PNG format. * source/src/stream.cpp: Temporarily disabled GCC warnings. * source/src/Makefile: Changed enet cleanup for recompilation. * source/enet/configure: Added runstatedir in the enet/configure file. * source/enet: autom4te.cache removal done. * source/enet/Makefile.am: Changed the old "INCLUDES" to "AM_CPPFLAGS". * Added disabling hardening PIE. * Use LDFLAGS for hardening policy and AC clean target. * The 'include', 'xcode', 'vcpp', 'lib', 'doxygen' and 'codeblocks' directories have been removed as they are useless files in GNU/Linux. * Outdated script file removed. assaultcube-1.2.0.2.1/README.md000066400000000000000000000037501352165075300156170ustar00rootroot00000000000000## What is AssaultCube? AssaultCube is a **FREE**, multiplayer, first-person shooter game, based on the [CUBE engine](http://cubeengine.com/cube.php4). Taking place in realistic environments, with fast, arcade gameplay, it's addictive and fun! With efficient bandwidth usage, it's low-latency and can even run over a 56 Kbps connection. It's tiny too, weighing in at a lightweight about 50 MB package available for Windows, Mac and Linux. On the correct settings, it can even run on old hardware (Pentium III and above). ## Features in a nutshell: * It's **FREE**. * Source code is available under a zlib-like open source license. * Low latency, it can even run across a 56 Kbps connection! * Lightweight size, only about 50 MB to download, plus additional maps average 20 KB each! * With the correct settings, it can run on old hardware (Pentium III and above). * Officially runs on most major systems (Windows: 2000/XP/Vista/7/8/10, Linux, Mac OS X: 10.6+ 64-bit), and maybe even some [non-major ones](http://assault.cubers.net/docs/getstarted.html)? * Has a built in, in-game map editor to help players create their own maps and allows for co-operative editmode in realtime with others! * Features a single-player bot system. * Supports recording of your game by the "demo" system. * Contains many multiplayer game modes, including: Deathmatch, Survivor, Capture the Flag, Hunt the Flag, Keep the Flag, Pistol Frenzy, Last Swiss Standing & One-Shot One-Kill (plus team versions of these modes). * Comes pre-packaged with several dozen different maps! ## More info: Most of this README was directly copied from the [AssaultCube Homepage](http://assault.cubers.net/), which should have everything you need in relation to AssaultCube. ## Redistribution: You may redistribute AssaultCube in any way the license permits, such as the free unmodified distribution of AssaultCube's source and binaries. If you have any doubts, you can look at the [license](http://assault.cubers.net/docs/license.html). assaultcube-1.2.0.2.1/assaultcube.png000066400000000000000000000566261352165075300173730ustar00rootroot00000000000000PNG  IHDRX]]IDATx] |չfwYc1"""r)UH""" ~ #CHy*zRJZ.hRZJ)EDĘɞ nBw\Μ !(R+"MHJ$R+J@R+RIJ$R+J@R+RIJ$R+RIJfG3_ȃWK gX ÓGǿ$OXR9V61D]\BFѻFeeBdi)rƯVK3:bE%D72~?JO$3r5ƦSn9H8 d!WR1h}Sx_kIR  hD9iD{C@{RZ soA`Cuj~ICzc 6IԼO{|܇or6X. nh ٍIn#괜hGHPB]0g"Xc`X@4ka^0?'jg)3еd 5 k5Wm-̮Vں*uj8$,/WHZCW D{J? Υ@GkܣH<)E_llGF16DlDb0C3&<A5祸f|@,M-=S| =vIaRրdbA[Us880 ¦@Y%6#i{rkq.3 bg'axKT+ ! #z ;!">HWYazfޫ`q^AopT "|ۉB@|n$#vY)3P0T6 bHscǛ3L/6CfcC<{%We^XdmP+b| HDa;O]&Q=񁒊c |Dn%3|fhTCҴ@R{tD*06 + ;c22<~ =44H}(}0],îT \c=I̴%Dl2 ԛC*jur9g݃id%j{3䞫,-BD܏A[@` mRd6eÑt^kz\{fԻ}ŒZL^tN;gmYUNk3N,¤ 3cb]OB]G;Irͺ*(QpuRB܀ V-&4Pd 3\b Cв/{Wp1xL{8ߟ<&{a^ǹFM!ZV Yȟ;>B 0Նͭ,5ݧ]GM6{n_,\qmhgG56I۰+}n*R2_KpHѴkCFBpF,"|)@fT>C#/E ͱ&?D7FCD`E:0M 3@U!kĵτMJE꺽r#;pR?R\װDS{WL!z%2UjսV h4d;mꅙ5aa^wN ^]̝Á\O!ML{DwyYz)]}`vrPxUܬaSm-ybt{\f&,,WL==R}õ. SVVX:וkLh[a-K#ZVUYC2^5=591/.R,܃nr[DKZ#%|`t*v MTsù?'ڬ|BHNtZ*TWm(4POʴR23o*VⳎ˦/dl~YZ~7x~_Se ?U%%隃UպY2F [bcn i6h{ U*ylxD@Gk# tA&tx߶V__V {2؄9X r#Zz+Lm\ > =}vQh+e*t@hmڤXnghfFݼHiDžZ.ك mM0lKq\fW\y`b,р 0Eaꈝ8AhJ0 d+ǰ7u٤Lk,P[ [)$xs}6qQLjvpGTq6n$Ϡ:ߤh _n̩=e ߙ]5m#46uV+A2bڴ>ټZ>(5JᖫVXP.(qu8 Xr>hLSs$dG4@DezMU8nl1CcU*j#xIL޸] 77RԜ_?/4uP;)TU{Um`njmbu qh}0v?A2Fh`c7AxAW};[rZ8sG1M[&ւ iK: $Q`DӼ`e-&2d}`)%׸E+M`Nt\9}\lu/ٗQ~8na0ϫxM[=:j6|F쌻Fs&̫HƊ'bM2b_##PZ˼oջ )o3ܥU$z,eiAжq m9`G߹@1T<)$0&3-U\~{*$؆:\S  #P\c!i*`RD'&IҷqUy |΋c|46IO4 3,~HW o]Ni"'jMWcjMwh)h@S/CpdQXIMpw&.^YוlE%=xf2[.) 9uTBm$%)|xcCă}y kZ3, m`xz=(i*`Iy'UBRˏ7B"UN>`%=+$7^M?7=Nأz@0v,~j2sR9C!ѻ!o^b:CuRyEꔏ#W->݃DqCiѢP;hν@t\ ǵ|B"WI|_NyM? ؽwE3\;}܅ 7_e9= b2n}s6&(n*rD͘6x7<4Ŕhl]1dӌ4<p7Gp`}H?l d/ 6 kR]r?߁i};+UD`o\#PA7 wjbxFi.-2M|J-&.O=d%Zڣ+2=%Z!^"Dl+ \Ё-t5 qYfѾ,0N̵ M]TRphAzt:zXܮrvx=  l&xmjZFҼ/&_Ț&$WPBÖ`=?ٟh8#FsQEa$K}2'үRbFxpA$Yn'G@{ >bUrRh/ry,7ꠌ$#=s9c !/S?F(~<&/]&خqPD"=֨]P{,(B]4S, a2MbQtupD5ul˞>˗x; Wp꽢%^.X}hco8^Ǽ5禯q#Jظ,jtir\usL*׈J6׻;wsBLlH,S%,6dz9m IA p+@DW~ubRi1b1Z<D/k$uw ؀`R-2DCW_E *PTh ]_̞-F0,PN2_dS#ٯUWw]&۴V"ӈ:WݯHZ.p# NPX b\dA^xTs3w: QX{O&O۷s`z-WzW(gB%1 Tn< g8ajeD&kRd8_iO49*?Q5288kY+Fej q=4x_ڴI̾9JHtBGp͖m{T yS`=c'g4afjipTPR% EMڲOKː}iFiMI!6 {K\DB. J,*S'RaؿD*H xO/yƬ o4lB<UD$ŗ u5۪S+>Ԅ"5S pg)IMj87,LP;$dFz{Iډ08"Fy}BZ}aZy%ɽȢGF5{i,}8_TŲ9=Y38qLDJ[aYv_dCTȷɞUj=Yf2H6nl!f̈"ٷ*6x͚*]*ӽL:܋>LKLkYD\ |2@ihtb+hIS@{h|_K'^{/,~eػw/6CmuԕKDkbǛЮ۶m3ߏh _5 ~8ֳdRI2QOg ITkEIW_-b3/LS7KLf,s Hѣ7n\EYUO .3-8̅ytQ^ALzD(vLs0i.{ީiՑ(Ue .&3 fĢa{bǎH_rTIꃓn:rxL0P,_^wfgcp/H6Y[>>SXGHVӡV윾?xdu$SC[3۴iX[1)|3m[1Jao@GFnUDeF}#5pA(qQD⋞F?RD z|-Zx$wO (>I-n)JKb& ? 0 >TF{n3aVI߆kKKڵK<3b?ϟkDd9-ruZaC'j`8BXRzFg\Yupɉ+^ySf? O?sIjtFǻG1 pW(7.! p55d`:0`1n)K>_U_ڊJ;}] @ء&uWܔܺ¡)a{]`:Y?Q +?I]Ԇת}ԭ1L|5Wt:cOMs.69LJbcMNvk $ju ٖU}X{!uN1տ'&gf[Vm=Q_ʆa#ι3~ߚAD"sU cO2D<{h8d1@p!QWtMtNx'H¹j Y˺ʥ$Ufb77Ujr}es⋮b o7O=}TdF(UMb3F{ uf'yjY(A3GhQ=YIQˀj닕c@XChDV%@bCXpkiiiE}uk +#h"g*pq\c+=[eT5@ Dh:|6=̬R5~ކ .i/ (նn݂.Dvxlh]u[QiŏYܘߢMJV_+!v*?"c(j3 ƙ[L{^V =-N,loINaZEtYko&f,HhkM{MsW9VFĂqx7bsS-oT'p"\dO&wEK%Ϊ(b ךV,Ð,0 |50}kUr #B$+P[WbzrbӀt؜GK(VR|xLLc$>u\Ot3D-2$MO8R@rqv9ʿwZwVi:W%/YDoUi&({0+K}͏Qʇ\ov@Dc'm6y2ѻ?ſ"sbǬxV9DDD{TI#D!Dͅ=:M4/Q9!7SJ\`A3;AZS骇y?$-e%Udȥ1+V0MH&mv֭btb&i`lVx|Y"oֆfljL0@nroRhB 2QN2s;CL hhQ.s$(w8;L^7ksiD+Nh0@|=qum'nzFaG6;gjB#D;uLðDžxSɦ9򗿘v1Z4ԑL O3~c1>xz@R}l4@~ާ:8C%Gd(BV5g>2m[A6H"9> g?3+?cLѲ& \8PL^ەqLh|; }ozݝHI 昁Z 7Ъu3(RE˳rsů_}U| Z`-} rw'Jcqeb"W*3-szh+997J`LILc*Ix9;̜ Rцl2ItIII58%epsBN:_65dWW~T]0^Z0`ٔNbI° xH"sR; \pxfKeZm9Dz-sXkOqɗ0͜)=垐@ǝRSGT1h#eo4<x#NN L)ܘf]. 9+n <`y)/7#jhtOur_|~&21_ r6l]Dt ]!TX?,]Hꃣ^뚃$18Nut&hT+:pLk)%*z-ImX+k`s}>}M X{;(螰*]g}(`쑉ӈ>כzd: @II^Yn %ua3M:@ڃOTkJ%i/\<%B=!r$K9D$Z(QWx( }(,}r_Jxh3K2j >k!3yfoUI>ݳӧ/U4/.G:J]u brl~yPbשȭ cW%' 9/;L; ZxZG+Zħf0}̛f2|=2 c&hCLK{@xRcƘ)H,B βsvm{]cqWַģ8%1Tze^gey#3k}DK *E\ nYh7gL8hpﻡ%jf%6LK*#a,Cvp/UQ.܄3\"_C|[CmڈGab-ĥY\WPO a]U??=6 fdhnc˞}kz*w)lZErs3Ѭze0SF&[.>!5/hW.wvYeNH(䟱#8ed1y tf/-oZi+Obἷ#c-6ӡz -TIW4[R=b2I<0&}o>+coݱro1p!kspO#qy+ 0VrgWzkH@c WsxGXxO|VdKEg`ȪpI6l9Dwы= Y=Ƒ` .ZէݻϢ⫯Mb EN3y{9 ~`c"Dt%#ɬke*hRZ@_j@TLmYN4ё;1C;OԓbEVrDKN8NW]%>L,~U7319! Ԩ*8yH`O/ZjӐRm(l/b&Gk&,Zip[I9 gCA%-1 Air0fñ[G'a Nk2f6b嗛 WiqU5 R+DqdQc"<MLZY^okrZ$#Ks4e'~CYLl q[jIrr;mIB <^;9 ǥE !_,&p&]8Asf) 1w[IN^ۨVw#5X]0܅}&#=ʿ4N Id$T8'SDټ٬) Ʊ|?:>=xp>N}3 C`>{9{ԑD; z c7h1jg/FL%T'82p8xjƳ5ao}k8D&TSB.X㕛0▟\FhB >)2$fVON}N (V磏ܿI <@gU~t5yD 'x`*{CZqV20 "zD}ՈsWwe`60(X5*! BX<5L~wfA,TqpS/PBF'dp80şD;M4GU,6HY{ɖv؛QmziX#p,}#kpa*%&:vS->V#&Ks 9$'YrS6&[_T%jj- {G*a5|AA1ڴDd6QfRu˭ıjVvdPw#($*rASp&MHlZ0D לGZLíkrК2_b1(JuF`Eޯ a 6,dfw!~ '3#vQxlŞX ƫሏ#C:a+SjT9u$0?n-gtFSsiT"[浆6-R$JUtcɸmll5 o8|Hxt  sSr:ΉF!*qv_#.7OuA< 6$ɕG}tW:z˓DƩ_Va/^"3& )Rq1w/# /L#C?2-T!,pXy8%mJ5 3oĬqSZƫEMv`q$)שּׁzɑU.&~SEr,PN IbWdgJ+T'bdbŌȄYQr''[_d^*NQ[MU5xv:qw#w}ߟs(Ua f;%,2@킙5Bi:`/.{9jRP)TPXp Rx}m[vR?43BnibrWie`q'Bk5$5)a9.5`5."ۖhOg @ و>h"nJMW$@Y8hHp`ח _o tړnA3&V,S·Є^ ĽcG\i|W',K,$1:sԺW(tAAQb9˕=>+ mǞڷx,Fȡ8 657眿{q{?xL1$7לqZc*Y4GpY?h1v$2 OB->d&tkbj5Q]Ly<ʍCYY⡛ooB@|dY;;I?8IUǧpB%91+$N & 1DׅYei 2{ě7CL"eny9⸆C<&_.Z'|[nHnbk|s2w%}zs=.m$[ .,f$ 0PThah[i:p s<8g۶myu}ĜqO.P5Z&UFT8D&{ ND[IR:y(57]oJEjEu";eJb9-yp+4R,pīqcq7Ll̝4r?u \Xjq+FziS01EU.(qd. :x3 2wDy*1><>1*#s 9WMOAj$ o`LtGX.s ͛ySh3QEƖ( ̏IH,{L 2(jxU8M I7ζv@W`?=C{D~aZ?HdT{kQ5;ɽa A_{4F ^L0Jjl;H8Uì5X0"%s!q޽{ɓ+bC}khP ILz\^ɯ_5g.]7CLxzG2 P5@{^&tyMNTb zȝUm FȪ^#'jC.Vi\S~WV7gQm駟?Gkhbm}M1&=b<ΩJI_:P]V_GEËx- #K ł.FD(ePkڀ70{?)דlRqWaaaYͳ/۷mnMg#hGv!XRlL$&;Ū7^I(Nv4{<(ڱO(pͬ& |UӦ?m6M_^|عc|bXZ4Tb*Y~N %#Qh:lFN_ 1EԺs0W!e;kN1k2P"#yҊ''86:TXIJޛ [l6u"YJo)~VZ*F剑ŞXǤ 0(h]ݤQk|J3M:Gv]EwPܨRG+4ZY&\kuL ۋmPxD ;23Űn#?,2LE6NqdTuFg=ưej FYJ,m l/N04M u}yAeNܜ#Rhx&cT6l]Ӱf2Gm I}>NG!W!dCNj *l%XD|44G2`Bj> [=*AP`橐|H"&V爨Q΀YQu}0ST!M׮HcIG\Yp$Yt#-d.|P-$P Z~Wm4-Qpj,?O>DU%c@tZüFU5.;iLYM2 *胐=Emܔ$9@E6TC0IX"%(rau d `L5D|l:7ԡ]SvzǪ9N!Mj &MnPE86PL=#jbTT QǸvJ4)Dt^೸]<[Lt.zYBtDN^*!b:фBMWsnb%eDk`.eDrRTz}:]i 3xp5JdlBlĀlPONƝl^A$B9w\#eͯ$9O4I8?l dŎA= #k$  6?uk÷WŽr(qeQjMgy-QEkP,~f2璳tXӦZrjV. Z7 HUmV_z{zWu-MTxzP 6~|V$<߰lAA+#8Y®}&SDm_MsϗR,)_6̚b 2e[B}TcWJ| 2/ `?]9g3 >Ue.km`n-@S1@R Ϗ`G4},Zٿ`Ɏ5;BJJ"fɴ(дU`B,7c;"AE 1x;~ Ԧ6ժdF%Mm s̋ŶrH4NuoMU+Gǎ] s!K=x@&L !7(C$6ZUaUk< 9연& s%P6N+15Ck=j{\x}}as1"9@o_VOqd6ʯNIղx"—jU&muI'ʱa6^L.'ADgqو~s5v;x`n!pl_(qC+Y+aELԄ F,0:Ejs&}eXw?U 2G TkWmVC n bm'A |Imh:WAYxC! 6Ce.@&⋶[Rl7վ\ z5>b@-mZr-ZصFGƵ2!U[-l'.|B+\o/9,Nz'S đ66ܐ9moLz{ KJ\:b]c33) qch <_;% ]Iv;|yFo@XOq,q1C&·M2UjQ*lhE21{L0TFJ] {.*q1RU5 ;T@#Źw.$iDk-R|c@Ac8alw :ʰa;CTvV*bИw>޿h*x@ydi6o!8w?lP+Ԣ8JfF8h?w`>1dHrH%LB[ p$L]<2d&$^W -SyZA m+B:/@P-Ql=pl1Hk ̟ӰY.);z*@-a}QW1uAyؼY+MUw+2 $T~w|$H2* ؆ E\I3[UʡTj\b/;jI:}'9qQkT^5Pe0 .c4[&:oPD[D!i]Hxc(ެT]k8[k$HNʼ)6V ;u;vSY4phC)w˙[5a}$Vll|v4USE:Q+\CjNh? ߆kzn?6*i\_➻nt)f:k)4c F ^[r1]3MKv$+4*}w$Z|?1vbFRvhI!3VKr`tNdg9/x8]WCl3G&vLY"GIq;(r5" mY6 JZpxa V#75T] ml@He,Lhs:H4&faP]MkIL4JCb357@Ru+J#E7U/T#pl{Wʴ1="RMĞS3|2+ pdr@%߰4䂭Đ1 eQxߪmGd̈́!#G֤JuQ֚ R+}QUHrkr 0l^it0+pL,[rO_ʹiQ#!)~YTs4CS oLijs)7ߍ=;UdCt(Dѓ l,y9NkSv־-knF&6Y>|2\e5p 9تe11S eE] ?pµҿ:&+yȝ{1=$4-MN%9SsŸQx\*&404Zk&BX~F][@:ɶʐN lr~A\R'UPc熥I/!k,mS*[98_Y&'Afi{yټQ(]fҏ|qsPapsؼC%+Rp88XN`m GG\(eYy(lOȲVF8pBNqpKHwqA~O'U@#=~ۈ_p ,@JQ '!?FQWʜMUL%<[T1#S~bm(5-J'=k c9kxz$Q 66Gs 3Xhz#IK7&8^}JfvV'[FgVF t\ sfWȡk 2N\Oc#af_Jj$X媼j*VŕOͿo,.x]+9**m;Ov  &U$DDv17Dka!l:3̒x,iɜr,zCtzhDI9wa`B9}D oL8[R*Y5n{^9 i_D憪r?pSU؄15ZUMBvGHi}`:֪W" 5+5+%C 6=-hby5-ݶ1b{Py6F&kwW#5ͬqEV`$ջuA6#by. z[=,' 11Hxo<%p{ō98s;S@<%6Z5@ 푳&+6ZvJȩ g`^74j R{xH˹0ԡ O@~[Sue-,Gβf ӟK6mg]C 3_h|LȠ&>[EfϴF]%sIE5$ ˴C%4S-9Ssa2Ef><)itQhx= wÉP@`Xab]$5H)8,ڬ2ˤ)]IL/O1IWu4tԞ}X3S0=ΗڛH@2&~[_Ms/L#8[3$@uQ~D9zk5\pl#`.SeeQ5sDZM$3z?@nƵx?0_/KջREfDPyʙG LUdoݴ:[k2:#^Q TQp_b|M z6NR 0Yd&-66I_% 醱 X ?008rsqjAlT=})lbo6 &z&]!K=Y|R|M|L+,gR9&nvJi̼@&# 쨾MYe1X9gztW>w!>HFkX /=t3PڪN7&\p)}Uwр)R@Y޳h:1fNRFY(i0&*jE6J%LQ@ȕY_بpbOeUI$Ψϩ|J?=yԆ?l@Ü > 3VUmcIka#Kx 4nD$~[pbQI$1ysy1 FuX.6@Q L*kL(0L&F-^6ZgHYOktHv)e2n5: 6d x'Ji۪J'~iؤC gHӨĠߓ)V*j-@RIj~HjV Z)VjZHjV ZHjM JIENDB`assaultcube-1.2.0.2.1/source/000077500000000000000000000000001352165075300156335ustar00rootroot00000000000000assaultcube-1.2.0.2.1/source/README.txt000066400000000000000000000025751352165075300173420ustar00rootroot00000000000000License ======= The AssaultCube source code is mainly based on the cube game/engine and uses the same license (z-lib like). See README_CUBEENGINE.txt In addition AssaultCube contains code from pCube (Cube pro mod) and Sauerbraten (Cube successor) and other sources. AssaultCube Authors ================== Adrian 'driAn' Henke drian at sprintf.org Andrew 'Arghvark' Davis arghvark at gmail.com Lee 'Eihrul' Salzman stef Cube Engine Authors =================== Wouter 'Aardappel' van Oortmerssen, Lee 'Eihrul' Salzman and others. See README_CUBEENGINE.txt and http://www.cubeengine.com pCube Authors ============= Adrian 'driAn' Henke and others. http://p.cubers.net Sauerbraten Authors =================== Wouter 'Aardappel' van Oortmerssen, Lee 'Eihrul' Salzman, Mike 'Gilt' Dysart and others. http://www.sauerbraten.org Cheat Protection ================ The cheat protection described in README_CUBEENGINE.txt is not used in AssaultCube. Binaries compiled from source are compatible with the official binaries. This means, the client can easily be hacked, on the other hand, you can compile AssaultCube for different platforms and fix bugs yourself. You MUST NOT connect to servers that are not yours with a modified client that contains changes that were not made for platform-compatibility or to fix bugs. This would be cheating. Thank you for supporting fair play gaming. assaultcube-1.2.0.2.1/source/README_CUBEENGINE.txt000066400000000000000000000144271352165075300210250ustar00rootroot00000000000000Cube source code license, usage, and documentation. You should read this file IN ITS ENTIRETY if you wish to do anything with the cube source code, even a mere build. Own builds are not necessarily compatible with the officially released binaries, read below. You may use the cube source code if you abide by the ZLIB license http://www.opensource.org/licenses/zlib-license.php (very similar to the BSD license) with the additional clause below: LICENSE ======= Cube game engine source code, 20 dec 2003 release. Copyright (C) 2001-2003 Wouter van Oortmerssen. This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. additional clause specific to Cube: 4. Source versions may not be "relicensed" under a different license without my explicitly written permission. LICENSE NOTES ============= The license covers the source code found in the "src" directory of this archive, the included enet network library which cube uses is covered by the "No problem Bugroff" license, which is however compatible with the above license for all practical purposes. Game media included in the cube game (maps, textures, sounds, models etc.) are not covered by this license, and may have individual copyrights and distribution restrictions (see individual readmes). USAGE ===== Compiling the sources should be straight forward. Unix users need to make sure to have the development version of all libs installed (OpenGL, SDL, SDL_Mixer, SDL_Image, zlib, libpng). The included makefiles can be used to build. Windows users can use the included visual studio .net 2003 project files, which references the lib/include directories for the external libraries and should thus be self contained. The project is set up assuming you have the normal cube binary distribution as a subdirectory "cube" of the root of this archive, so release mode builds will place executables in the bin dir ready for testing and distribution. Do not come ask me for help in compiling or modifying the sources, if you can't figure out how to do this yourself you probably shouldn't be touching the files anyway. The cube sources are very small, compact, and non redundant, so anyone wishing to modify the source code should be able to gain an overview of cube's inner workings by simply reading through the source code in its entirety. Small amounts of comments should guide you through the more tricky sections. When reading the source code and trying to understand cube's internal design, keep in mind the goal of cube: minimalism. I wanted to create a very complete game / game engine with absolutely minimal means, and made a sport out of it keeping the implementation small and simple. Cube is not a commercial product, it is merely the author's idea of a fun little programming project. OPEN SOURCE =========== Cube is open source (see ZLIB license above). This only means that you have great freedom using it for your own projects, but does NOT mean the main cube code is an "open source project" in the sense that everyone is invited to contribute to it. The main cube code will remain a one man project (me), as my minimalistic design is highly incompatible with the open source philosophy. If you add to the cube source code, you fork the code and it becomes your own project, do not ask for me to integrate your changes into the main branch, no matter how brilliant they are. CHEATING ======== If you want to use cube as a base for a game where the multiplayer aspect is important and used by a large community, you need to be aware that cube's thick client - thin server architecture is extremely cheat sensitive. If you release a cube based game with source code equivalent to the binaries, some minor changes can give anyone an aimbot or other cheats in online games. There are several ways to make this less easy, some of which are: 1. only distribute binaries (the ZLIB license allows this). Executables can still be hacked, but unless you have a really large online community, noone will probably bother. 2. write a network proxy, such as qizmo used with QuakeWorld (whose sources are also open source). The proxy is a small closed source program that checksums the executable, and maybe also some game media. You can then make servers or game admins request this information and ban cheaters. 3. release the sources with an incompatible network protocol or other changes compared to the binaries you release. 4. build serious cheat detection into the game. Since all clients are their own "servers", you can make them all keep track of stats for the other players, such as health etc. you can make all sorts of consistency checks on shots, movement speed and items. If the discrepancy for a certain client becomes too big, all clients but the cheater can send their "vote" to the server for having him banned. Even better, you can add server side stat checking. For the cube's own game I chose option 3, i.e. you can only play the official cube game using the binaries supplied by me, and you can't compile your own clients for multiplayer use (you can still make custom clients that work with matching custom servers, or play cube single player maps compatible with the real thing). This situation is not ideal, but there is no easy way around it. This scheme is probably very easy to defeat if you are capable of using disassemblers and packet sniffers, but please contrain yourself and don't ruin the fun of the cube multiplayer community. Thanks. AUTHOR ====== Wouter van Oortmerssen aka Aardappel wvo@fov120.com http://wouter.fov120.com For additional authors/contributors, see the cube binary distribution readme.html assaultcube-1.2.0.2.1/source/enet/000077500000000000000000000000001352165075300165665ustar00rootroot00000000000000assaultcube-1.2.0.2.1/source/enet/ChangeLog000066400000000000000000000126151352165075300203450ustar00rootroot00000000000000ENet 1.3.6 (December 11, 2012): * added support for intercept callback in ENetHost that can be used to process raw packets before ENet * added enet_socket_shutdown() for issuing shutdown on a socket * fixed enet_socket_connect() to not error on non-blocking connects * fixed bug in MTU negotiation during connections ENet 1.3.5 (July 31, 2012): * fixed bug in unreliable packet fragment queuing ENet 1.3.4 (May 29, 2012): * added enet_peer_ping_interval() for configuring per-peer ping intervals * added enet_peer_timeout() for configuring per-peer timeouts * added protocol packet size limits ENet 1.3.3 (June 28, 2011): * fixed bug with simultaneous disconnects not dispatching events ENet 1.3.2 (May 31, 2011): * added support for unreliable packet fragmenting via the packet flag ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT * fixed regression in unreliable packet queuing * added check against received port to limit some forms of IP-spoofing ENet 1.3.1 (February 10, 2011): * fixed bug in tracking of reliable data in transit * reliable data window size now scales with the throttle * fixed bug in fragment length calculation when checksums are used ENet 1.3.0 (June 5, 2010): * enet_host_create() now requires the channel limit to be specified as a parameter * enet_host_connect() now accepts a data parameter which is supplied to the receiving receiving host in the event data field for a connect event * added an adaptive order-2 PPM range coder as a built-in compressor option which can be set with enet_host_compress_with_range_coder() * added support for packet compression configurable with a callback * improved session number handling to not rely on the packet checksum field, saving 4 bytes per packet unless the checksum option is used * removed the dependence on the rand callback for session number handling Caveats: This version is not protocol compatible with the 1.2 series or earlier. The enet_host_connect and enet_host_create API functions require supplying additional parameters. ENet 1.2.5 (June 28, 2011): * fixed bug with simultaneous disconnects not dispatching events ENet 1.2.4 (May 31, 2011): * fixed regression in unreliable packet queuing * added check against received port to limit some forms of IP-spoofing ENet 1.2.3 (February 10, 2011): * fixed bug in tracking reliable data in transit ENet 1.2.2 (June 5, 2010): * checksum functionality is now enabled by setting a checksum callback inside ENetHost instead of being a configure script option * added totalSentData, totalSentPackets, totalReceivedData, and totalReceivedPackets counters inside ENetHost for getting usage statistics * added enet_host_channel_limit() for limiting the maximum number of channels allowed by connected peers * now uses dispatch queues for event dispatch rather than potentially unscalable array walking * added no_memory callback that is called when a malloc attempt fails, such that if no_memory returns rather than aborts (the default behavior), then the error is propagated to the return value of the API calls * now uses packed attribute for protocol structures on platforms with strange alignment rules * improved autoconf build system contributed by Nathan Brink allowing for easier building as a shared library Caveats: If you were using the compile-time option that enabled checksums, make sure to set the checksum callback inside ENetHost to enet_crc32 to regain the old behavior. The ENetCallbacks structure has added new fields, so make sure to clear the structure to zero before use if using enet_initialize_with_callbacks(). ENet 1.2.1 (November 12, 2009): * fixed bug that could cause disconnect events to be dropped * added thin wrapper around select() for portable usage * added ENET_SOCKOPT_REUSEADDR socket option * factored enet_socket_bind()/enet_socket_listen() out of enet_socket_create() * added contributed Code::Blocks build file ENet 1.2 (February 12, 2008): * fixed bug in VERIFY_CONNECT acknowledgement that could cause connect attempts to occasionally timeout * fixed acknowledgements to check both the outgoing and sent queues when removing acknowledged packets * fixed accidental bit rot in the MSVC project file * revised sequence number overflow handling to address some possible disconnect bugs * added enet_host_check_events() for getting only local queued events * factored out socket option setting into enet_socket_set_option() so that socket options are now set separately from enet_socket_create() Caveats: While this release is superficially protocol compatible with 1.1, differences in the sequence number overflow handling can potentially cause random disconnects. ENet 1.1 (June 6, 2007): * optional CRC32 just in case someone needs a stronger checksum than UDP provides (--enable-crc32 configure option) * the size of packet headers are half the size they used to be (so less overhead when sending small packets) * enet_peer_disconnect_later() that waits till all queued outgoing packets get sent before issuing an actual disconnect * freeCallback field in individual packets for notification of when a packet is about to be freed * ENET_PACKET_FLAG_NO_ALLOCATE for supplying pre-allocated data to a packet (can be used in concert with freeCallback to support some custom allocation schemes that the normal memory allocation callbacks would normally not allow) * enet_address_get_host_ip() for printing address numbers * promoted the enet_socket_*() functions to be part of the API now * a few stability/crash fixes assaultcube-1.2.0.2.1/source/enet/Doxyfile000077500000000000000000001150331352165075300203020ustar00rootroot00000000000000# Doxyfile 1.2.18 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project # # All text after a hash (#) is considered a comment and will be ignored # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- # General configuration options #--------------------------------------------------------------------------- # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = enet # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = docs # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, # Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en # (Japanese with english messages), Korean, Norwegian, Polish, Portuguese, # Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish and Ukrainian. OUTPUT_LANGUAGE = English # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = NO # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these class will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = NO # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited # members of a class in the documentation of that class as if those members were # ordinary class members. Constructors, destructors and assignment operators of # the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = NO # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. It is allowed to use relative paths in the argument list. STRIP_FROM_PATH = # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower case letters. If set to YES upper case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # users are adviced to set this option to NO. CASE_SENSE_NAMES = YES # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful is your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like the Qt-style comments (thus requiring an # explict @brief command for a brief description. JAVADOC_AUTOBRIEF = YES # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the DETAILS_AT_TOP tag is set to YES then Doxygen # will output the detailed description near the top, like JavaDoc. # If set to NO, the detailed description appears after the member # documentation. DETAILS_AT_TOP = YES # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # reimplements. INHERIT_DOCS = YES # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 8 # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or define consist of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and defines in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. # For instance some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = YES # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources # only. Doxygen will then generate output that is more tailored for Java. # For instance namespaces will be presented as packages, qualified scopes # will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = . include/enet docs # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp # *.h++ *.idl *.odl FILE_PATTERNS = *.c *.h *.dox # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = Tests # The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories # that are symbolic links (a Unix filesystem feature) are excluded from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. EXCLUDE_PATTERNS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. INPUT_FILTER = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. SOURCE_BROWSER = NO # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # If the REFERENCED_BY_RELATION tag is set to YES (the default) # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES # If the REFERENCES_RELATION tag is set to YES (the default) # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = YES # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet HTML_STYLESHEET = # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compressed HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output dir. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non empty doxygen will try to run # the html help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the Html help documentation and to the tree view. TOC_EXPAND = NO # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 4 # If the GENERATE_TREEVIEW tag is set to YES, a side panel will be # generated containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript and frames is required (for instance Mozilla, Netscape 4.0+, # or Internet explorer 4.0+). Note that for large projects the tree generation # can take a very long time. In such cases it is better to disable this feature. # Windows users are probably better off using the HTML help feature. GENERATE_TREEVIEW = NO # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be invoked. If left blank `latex' will be used as the default command name. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = NO # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = NO # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimised for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assigments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_XML = NO # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_PREDEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. PREDEFINED = FORCE_DOXYGEN # If the MACRO_EXPANSION and EXPAND_PREDEF_ONLY tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all function-like macros that are alone # on a line, have an all uppercase name, and do not end with a semicolon. Such # function macros are typically used for boiler-plate code, and will confuse the # parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::addtions related to external references #--------------------------------------------------------------------------- # The TAGFILES tag can be used to specify one or more tagfiles. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in Html, RTF and LaTeX) for classes with base or # super classes. Setting the tag to NO turns the diagrams off. Note that this # option is superceded by the HAVE_DOT option below. This is only a fallback. It is # recommended to install and use dot, since it yield more powerful graphs. CLASS_DIAGRAMS = YES # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = NO # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, jpg, or gif # If left blank png will be used. DOT_IMAGE_FORMAT = png # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found on the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width # (in pixels) of the graphs generated by dot. If a graph becomes larger than # this value, doxygen will try to truncate the graph, so that it fits within # the specified constraint. Beware that most browsers cannot cope with very # large images. MAX_DOT_GRAPH_WIDTH = 1024 # The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height # (in pixels) of the graphs generated by dot. If a graph becomes larger than # this value, doxygen will try to truncate the graph, so that it fits within # the specified constraint. Beware that most browsers cannot cope with very # large images. MAX_DOT_GRAPH_HEIGHT = 1024 # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermedate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Configuration::addtions related to the search engine #--------------------------------------------------------------------------- # The SEARCHENGINE tag specifies whether or not a search engine should be # used. If set to NO the values of all tags below this one will be ignored. SEARCHENGINE = NO # The CGI_NAME tag should be the name of the CGI script that # starts the search engine (doxysearch) with the correct parameters. # A script with this name will be generated by doxygen. CGI_NAME = search.cgi # The CGI_URL tag should be the absolute URL to the directory where the # cgi binaries are located. See the documentation of your http daemon for # details. CGI_URL = # The DOC_URL tag should be the absolute URL to the directory where the # documentation is located. If left blank the absolute path to the # documentation, with file:// prepended to it, will be used. DOC_URL = # The DOC_ABSPATH tag should be the absolute path to the directory where the # documentation is located. If left blank the directory on the local machine # will be used. DOC_ABSPATH = # The BIN_ABSPATH tag must point to the directory where the doxysearch binary # is installed. BIN_ABSPATH = /usr/local/bin/ # The EXT_DOC_PATHS tag can be used to specify one or more paths to # documentation generated for other projects. This allows doxysearch to search # the documentation for these projects as well. EXT_DOC_PATHS = assaultcube-1.2.0.2.1/source/enet/LICENSE000077500000000000000000000020441352165075300175760ustar00rootroot00000000000000Copyright (c) 2002-2012 Lee Salzman Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. assaultcube-1.2.0.2.1/source/enet/Makefile.am000077500000000000000000000012301352165075300206210ustar00rootroot00000000000000pkgconfigdir = $(libdir)/pkgconfig nodist_pkgconfig_DATA = libenet.pc enetincludedir=$(includedir)/enet enetinclude_HEADERS = \ include/enet/callbacks.h \ include/enet/enet.h \ include/enet/list.h \ include/enet/protocol.h \ include/enet/time.h \ include/enet/types.h \ include/enet/unix.h \ include/enet/utility.h \ include/enet/win32.h lib_LTLIBRARIES = libenet.la libenet_la_SOURCES = callbacks.c compress.c host.c list.c packet.c peer.c protocol.c unix.c win32.c # see info '(libtool) Updating version info' before making a release libenet_la_LDFLAGS = $(AM_LDFLAGS) -version-info 3:0:1 AM_CPPFLAGS = -I$(top_srcdir)/include ACLOCAL_AMFLAGS = -Im4 assaultcube-1.2.0.2.1/source/enet/Makefile.in000066400000000000000000000747651352165075300206560ustar00rootroot00000000000000# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ $(am__configure_deps) $(enetinclude_HEADERS) \ $(am__DIST_COMMON) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = libenet.pc CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)" \ "$(DESTDIR)$(enetincludedir)" LTLIBRARIES = $(lib_LTLIBRARIES) libenet_la_LIBADD = am_libenet_la_OBJECTS = callbacks.lo compress.lo host.lo list.lo \ packet.lo peer.lo protocol.lo unix.lo win32.lo libenet_la_OBJECTS = $(am_libenet_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = libenet_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(libenet_la_LDFLAGS) $(LDFLAGS) -o $@ AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/callbacks.Plo \ ./$(DEPDIR)/compress.Plo ./$(DEPDIR)/host.Plo \ ./$(DEPDIR)/list.Plo ./$(DEPDIR)/packet.Plo \ ./$(DEPDIR)/peer.Plo ./$(DEPDIR)/protocol.Plo \ ./$(DEPDIR)/unix.Plo ./$(DEPDIR)/win32.Plo am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libenet_la_SOURCES) DIST_SOURCES = $(libenet_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac DATA = $(nodist_pkgconfig_DATA) HEADERS = $(enetinclude_HEADERS) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags CSCOPE = cscope AM_RECURSIVE_TARGETS = cscope am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/libenet.pc.in \ ChangeLog README compile config.guess config.sub depcomp \ install-sh ltmain.sh missing DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -rf "$(distdir)" \ || { sleep 5 && rm -rf "$(distdir)"; }; \ else :; fi am__post_remove_distdir = $(am__remove_distdir) DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best DIST_TARGETS = dist-gzip distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ pkgconfigdir = $(libdir)/pkgconfig nodist_pkgconfig_DATA = libenet.pc enetincludedir = $(includedir)/enet enetinclude_HEADERS = \ include/enet/callbacks.h \ include/enet/enet.h \ include/enet/list.h \ include/enet/protocol.h \ include/enet/time.h \ include/enet/types.h \ include/enet/unix.h \ include/enet/utility.h \ include/enet/win32.h lib_LTLIBRARIES = libenet.la libenet_la_SOURCES = callbacks.c compress.c host.c list.c packet.c peer.c protocol.c unix.c win32.c # see info '(libtool) Updating version info' before making a release libenet_la_LDFLAGS = $(AM_LDFLAGS) -version-info 3:0:1 AM_CPPFLAGS = -I$(top_srcdir)/include ACLOCAL_AMFLAGS = -Im4 all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj am--refresh: Makefile @: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): libenet.pc: $(top_builddir)/config.status $(srcdir)/libenet.pc.in cd $(top_builddir) && $(SHELL) ./config.status $@ install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libenet.la: $(libenet_la_OBJECTS) $(libenet_la_DEPENDENCIES) $(EXTRA_libenet_la_DEPENDENCIES) $(AM_V_CCLD)$(libenet_la_LINK) -rpath $(libdir) $(libenet_la_OBJECTS) $(libenet_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/callbacks.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compress.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/host.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/packet.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/peer.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unix.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/win32.Plo@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool config.lt install-nodist_pkgconfigDATA: $(nodist_pkgconfig_DATA) @$(NORMAL_INSTALL) @list='$(nodist_pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \ done uninstall-nodist_pkgconfigDATA: @$(NORMAL_UNINSTALL) @list='$(nodist_pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir) install-enetincludeHEADERS: $(enetinclude_HEADERS) @$(NORMAL_INSTALL) @list='$(enetinclude_HEADERS)'; test -n "$(enetincludedir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(enetincludedir)'"; \ $(MKDIR_P) "$(DESTDIR)$(enetincludedir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(enetincludedir)'"; \ $(INSTALL_HEADER) $$files "$(DESTDIR)$(enetincludedir)" || exit $$?; \ done uninstall-enetincludeHEADERS: @$(NORMAL_UNINSTALL) @list='$(enetinclude_HEADERS)'; test -n "$(enetincludedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(enetincludedir)'; $(am__uninstall_files_from_dir) ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscope: cscope.files test ! -s cscope.files \ || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) clean-cscope: -rm -f cscope.files cscope.files: clean-cscope cscopelist cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -rm -f cscope.out cscope.in.out cscope.po.out cscope.files distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz $(am__post_remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__post_remove_distdir) dist-lzip: distdir tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz $(am__post_remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) dist-tarZ: distdir @echo WARNING: "Support for distribution archives compressed with" \ "legacy program 'compress' is deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) dist-shar: distdir @echo WARNING: "Support for shar distribution archives is" \ "deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz $(am__post_remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__post_remove_distdir) dist dist-all: $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' $(am__post_remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lz*) \ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build/sub \ && ../../configure \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ --srcdir=../.. --prefix="$$dc_install_base" \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__post_remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @test -n '$(distuninstallcheck_dir)' || { \ echo 'ERROR: trying to run $@ with an empty' \ '$$(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ $(am__cd) '$(distuninstallcheck_dir)' || { \ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) $(DATA) $(HEADERS) installdirs: for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(enetincludedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -f ./$(DEPDIR)/callbacks.Plo -rm -f ./$(DEPDIR)/compress.Plo -rm -f ./$(DEPDIR)/host.Plo -rm -f ./$(DEPDIR)/list.Plo -rm -f ./$(DEPDIR)/packet.Plo -rm -f ./$(DEPDIR)/peer.Plo -rm -f ./$(DEPDIR)/protocol.Plo -rm -f ./$(DEPDIR)/unix.Plo -rm -f ./$(DEPDIR)/win32.Plo -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-libtool distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-enetincludeHEADERS \ install-nodist_pkgconfigDATA install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -f ./$(DEPDIR)/callbacks.Plo -rm -f ./$(DEPDIR)/compress.Plo -rm -f ./$(DEPDIR)/host.Plo -rm -f ./$(DEPDIR)/list.Plo -rm -f ./$(DEPDIR)/packet.Plo -rm -f ./$(DEPDIR)/peer.Plo -rm -f ./$(DEPDIR)/protocol.Plo -rm -f ./$(DEPDIR)/unix.Plo -rm -f ./$(DEPDIR)/win32.Plo -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-enetincludeHEADERS uninstall-libLTLIBRARIES \ uninstall-nodist_pkgconfigDATA .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles am--refresh check \ check-am clean clean-cscope clean-generic clean-libLTLIBRARIES \ clean-libtool cscope cscopelist-am ctags ctags-am dist \ dist-all dist-bzip2 dist-gzip dist-lzip dist-shar dist-tarZ \ dist-xz dist-zip distcheck distclean distclean-compile \ distclean-generic distclean-libtool distclean-tags \ distcleancheck distdir distuninstallcheck dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am \ install-enetincludeHEADERS install-exec install-exec-am \ install-html install-html-am install-info install-info-am \ install-libLTLIBRARIES install-man \ install-nodist_pkgconfigDATA install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am \ uninstall-enetincludeHEADERS uninstall-libLTLIBRARIES \ uninstall-nodist_pkgconfigDATA .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: assaultcube-1.2.0.2.1/source/enet/README000077500000000000000000000004561352165075300174560ustar00rootroot00000000000000Please visit the ENet homepage at http://enet.bespin.org for installation and usage instructions. If you obtained this package from CVS, the quick description on how to build is: # Generate the build system. autoreconf -vfi # Compile and install the library. ./configure && make && make install assaultcube-1.2.0.2.1/source/enet/aclocal.m4000066400000000000000000001252551352165075300204400ustar00rootroot00000000000000# generated automatically by aclocal 1.16.1 -*- Autoconf -*- # Copyright (C) 1996-2018 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, [m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) # Copyright (C) 2002-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.16' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.16.1], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.16.1])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to # '$srcdir', '$srcdir/..', or '$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is '.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl # Expand $ac_aux_dir to an absolute path. am_aux_dir=`cd "$ac_aux_dir" && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ([2.52])dnl m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], [$1], [CXX], [depcc="$CXX" am_compiler_list=], [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], [$1], [UPC], [depcc="$UPC" am_compiler_list=], [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES. AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE([dependency-tracking], [dnl AS_HELP_STRING( [--enable-dependency-tracking], [do not reject slow dependency extractors]) AS_HELP_STRING( [--disable-dependency-tracking], [speeds up one-time build])]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. # TODO: see whether this extra hack can be removed once we start # requiring Autoconf 2.70 or later. AS_CASE([$CONFIG_FILES], [*\'*], [eval set x "$CONFIG_FILES"], [*], [set x $CONFIG_FILES]) shift # Used to flag and report bootstrapping failures. am_rc=0 for am_mf do # Strip MF so we end up with the name of the file. am_mf=`AS_ECHO(["$am_mf"]) | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile which includes # dependency-tracking related rules and includes. # Grep'ing the whole file directly is not great: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ || continue am_dirpart=`AS_DIRNAME(["$am_mf"])` am_filepart=`AS_BASENAME(["$am_mf"])` AM_RUN_LOG([cd "$am_dirpart" \ && sed -e '/# am--include-marker/d' "$am_filepart" \ | $MAKE -f - am--depfiles]) || am_rc=$? done if test $am_rc -ne 0; then AC_MSG_FAILURE([Something went wrong bootstrapping makefile fragments for automatic dependency tracking. Try re-running configure with the '--disable-dependency-tracking' option to at least be able to build the package (albeit without support for automatic dependency tracking).]) fi AS_UNSET([am_dirpart]) AS_UNSET([am_filepart]) AS_UNSET([am_mf]) AS_UNSET([am_rc]) rm -f conftest-deps.mk } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking is enabled. # This creates each '.Po' and '.Plo' makefile fragment that we'll need in # order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}"])]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC]) [_AM_PROG_CC_C_O ]) # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.65])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [AC_DIAGNOSE([obsolete], [$0: two- and three-arguments forms are deprecated.]) m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if( m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), [ok:ok],, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) AM_MISSING_PROG([AUTOCONF], [autoconf]) AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) AM_MISSING_PROG([AUTOHEADER], [autoheader]) AM_MISSING_PROG([MAKEINFO], [makeinfo]) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # AC_SUBST([mkdir_p], ['$(MKDIR_P)']) # We need awk for the "check" target (and possibly the TAP driver). The # system "awk" is bad on some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES([CC])], [m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES([CXX])], [m4_define([AC_PROG_CXX], m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES([OBJC])], [m4_define([AC_PROG_OBJC], m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], [_AM_DEPENDENCIES([OBJCXX])], [m4_define([AC_PROG_OBJCXX], m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl ]) AC_REQUIRE([AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) fi fi dnl The trailing newline in this macro's definition is deliberate, for dnl backward compatibility and to allow trailing 'dnl'-style comments dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. ]) dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST([install_sh])]) # Copyright (C) 2003-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Add --enable-maintainer-mode option to configure. -*- Autoconf -*- # From Jim Meyering # Copyright (C) 1996-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MAINTAINER_MODE([DEFAULT-MODE]) # ---------------------------------- # Control maintainer-specific portions of Makefiles. # Default is to disable them, unless 'enable' is passed literally. # For symmetry, 'disable' may be passed as well. Anyway, the user # can override the default with the --enable/--disable switch. AC_DEFUN([AM_MAINTAINER_MODE], [m4_case(m4_default([$1], [disable]), [enable], [m4_define([am_maintainer_other], [disable])], [disable], [m4_define([am_maintainer_other], [enable])], [m4_define([am_maintainer_other], [enable]) m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) dnl maintainer-mode's default is 'disable' unless 'enable' is passed AC_ARG_ENABLE([maintainer-mode], [AS_HELP_STRING([--]am_maintainer_other[-maintainer-mode], am_maintainer_other[ make rules and dependencies not useful (and sometimes confusing) to the casual installer])], [USE_MAINTAINER_MODE=$enableval], [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) AC_MSG_RESULT([$USE_MAINTAINER_MODE]) AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) MAINT=$MAINTAINER_MODE_TRUE AC_SUBST([MAINT])dnl ] ) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MAKE_INCLUDE() # ----------------- # Check whether make has an 'include' directive that can support all # the idioms we need for our automatic dependency tracking code. AC_DEFUN([AM_MAKE_INCLUDE], [AC_MSG_CHECKING([whether ${MAKE-make} supports the include directive]) cat > confinc.mk << 'END' am__doit: @echo this is the am__doit target >confinc.out .PHONY: am__doit END am__include="#" am__quote= # BSD make does it like this. echo '.include "confinc.mk" # ignored' > confmf.BSD # Other make implementations (GNU, Solaris 10, AIX) do it like this. echo 'include confinc.mk # ignored' > confmf.GNU _am_result=no for s in GNU BSD; do AM_RUN_LOG([${MAKE-make} -f confmf.$s && cat confinc.out]) AS_CASE([$?:`cat confinc.out 2>/dev/null`], ['0:this is the am__doit target'], [AS_CASE([$s], [BSD], [am__include='.include' am__quote='"'], [am__include='include' am__quote=''])]) if test "$am__include" != "#"; then _am_result="yes ($s style)" break fi done rm -f confinc.* confmf.* AC_MSG_RESULT([${_am_result}]) AC_SUBST([am__include])]) AC_SUBST([am__quote])]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it is modern enough. # If it is, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= AC_MSG_WARN(['missing' script is too old or missing]) fi ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), [1])]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Copyright (C) 1999-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_CC_C_O # --------------- # Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC # to automatically call this. AC_DEFUN([_AM_PROG_CC_C_O], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl AC_LANG_PUSH([C])dnl AC_CACHE_CHECK( [whether $CC understands -c and -o together], [am_cv_prog_cc_c_o], [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i]) if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) # Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_RUN_LOG(COMMAND) # ------------------- # Run COMMAND, save the exit status in ac_status, and log it. # (This has been adapted from Autoconf's _AC_RUN_LOG macro.) AC_DEFUN([AM_RUN_LOG], [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi if test "$[2]" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT([yes]) # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi AC_CONFIG_COMMANDS_PRE( [AC_MSG_CHECKING([that generated files are newer than configure]) if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi AC_MSG_RESULT([done])]) rm -f conftest.file ]) # Copyright (C) 2009-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SILENT_RULES([DEFAULT]) # -------------------------- # Enable less verbose build rules; with the default set to DEFAULT # ("yes" being less verbose, "no" or empty being verbose). AC_DEFUN([AM_SILENT_RULES], [AC_ARG_ENABLE([silent-rules], [dnl AS_HELP_STRING( [--enable-silent-rules], [less verbose build output (undo: "make V=1")]) AS_HELP_STRING( [--disable-silent-rules], [verbose build output (undo: "make V=0")])dnl ]) case $enable_silent_rules in @%:@ ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; esac dnl dnl A few 'make' implementations (e.g., NonStop OS and NextStep) dnl do not support nested variable expansions. dnl See automake bug#9928 and bug#10237. am_make=${MAKE-make} AC_CACHE_CHECK([whether $am_make supports nested variables], [am_cv_make_support_nested_variables], [if AS_ECHO([['TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi]) if test $am_cv_make_support_nested_variables = yes; then dnl Using '$V' instead of '$(V)' breaks IRIX make. AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AC_SUBST([AM_V])dnl AM_SUBST_NOTMAKE([AM_V])dnl AC_SUBST([AM_DEFAULT_V])dnl AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) # Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor 'install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in "make install-strip", and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of 'v7', 'ustar', or 'pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar # AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar], [# The POSIX 1988 'ustar' format is defined with fixed-size fields. # There is notably a 21 bits limit for the UID and the GID. In fact, # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 # and bug#13588). am_max_uid=2097151 # 2^21 - 1 am_max_gid=$am_max_uid # The $UID and $GID variables are not portable, so we need to resort # to the POSIX-mandated id(1) utility. Errors in the 'id' calls # below are definitely unexpected, so allow the users to see them # (that is, avoid stderr redirection). am_uid=`id -u || echo unknown` am_gid=`id -g || echo unknown` AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) if test $am_uid -le $am_max_uid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) if test $am_gid -le $am_max_gid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi], [pax], [], [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Go ahead even if we have the value already cached. We do so because we # need to set the values for the 'am__tar' and 'am__untar' variables. _am_tools=${am_cv_prog_tar_$1-$_am_tools} for _am_tool in $_am_tools; do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works. rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([m4/libtool.m4]) m4_include([m4/ltoptions.m4]) m4_include([m4/ltsugar.m4]) m4_include([m4/ltversion.m4]) m4_include([m4/lt~obsolete.m4]) assaultcube-1.2.0.2.1/source/enet/callbacks.c000066400000000000000000000015641352165075300206570ustar00rootroot00000000000000/** @file callbacks.c @brief ENet callback functions */ #define ENET_BUILDING_LIB 1 #include "enet/enet.h" static ENetCallbacks callbacks = { malloc, free, abort }; int enet_initialize_with_callbacks (ENetVersion version, const ENetCallbacks * inits) { if (version < ENET_VERSION_CREATE (1, 3, 0)) return -1; if (inits -> malloc != NULL || inits -> free != NULL) { if (inits -> malloc == NULL || inits -> free == NULL) return -1; callbacks.malloc = inits -> malloc; callbacks.free = inits -> free; } if (inits -> no_memory != NULL) callbacks.no_memory = inits -> no_memory; return enet_initialize (); } void * enet_malloc (size_t size) { void * memory = callbacks.malloc (size); if (memory == NULL) callbacks.no_memory (); return memory; } void enet_free (void * memory) { callbacks.free (memory); } assaultcube-1.2.0.2.1/source/enet/compile000077500000000000000000000163271352165075300201550ustar00rootroot00000000000000#! /bin/sh # Wrapper for compilers which do not understand '-c -o'. scriptversion=2018-03-07.03; # UTC # Copyright (C) 1999-2018 Free Software Foundation, Inc. # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . nl=' ' # We need space, tab and new line, in precisely that order. Quoting is # there to prevent tools from complaining about whitespace usage. IFS=" "" $nl" file_conv= # func_file_conv build_file lazy # Convert a $build file to $host form and store it in $file # Currently only supports Windows hosts. If the determined conversion # type is listed in (the comma separated) LAZY, no conversion will # take place. func_file_conv () { file=$1 case $file in / | /[!/]*) # absolute file, and not a UNC file if test -z "$file_conv"; then # lazily determine how to convert abs files case `uname -s` in MINGW*) file_conv=mingw ;; CYGWIN*) file_conv=cygwin ;; *) file_conv=wine ;; esac fi case $file_conv/,$2, in *,$file_conv,*) ;; mingw/*) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; cygwin/*) file=`cygpath -m "$file" || echo "$file"` ;; wine/*) file=`winepath -w "$file" || echo "$file"` ;; esac ;; esac } # func_cl_dashL linkdir # Make cl look for libraries in LINKDIR func_cl_dashL () { func_file_conv "$1" if test -z "$lib_path"; then lib_path=$file else lib_path="$lib_path;$file" fi linker_opts="$linker_opts -LIBPATH:$file" } # func_cl_dashl library # Do a library search-path lookup for cl func_cl_dashl () { lib=$1 found=no save_IFS=$IFS IFS=';' for dir in $lib_path $LIB do IFS=$save_IFS if $shared && test -f "$dir/$lib.dll.lib"; then found=yes lib=$dir/$lib.dll.lib break fi if test -f "$dir/$lib.lib"; then found=yes lib=$dir/$lib.lib break fi if test -f "$dir/lib$lib.a"; then found=yes lib=$dir/lib$lib.a break fi done IFS=$save_IFS if test "$found" != yes; then lib=$lib.lib fi } # func_cl_wrapper cl arg... # Adjust compile command to suit cl func_cl_wrapper () { # Assume a capable shell lib_path= shared=: linker_opts= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. eat=1 case $2 in *.o | *.[oO][bB][jJ]) func_file_conv "$2" set x "$@" -Fo"$file" shift ;; *) func_file_conv "$2" set x "$@" -Fe"$file" shift ;; esac ;; -I) eat=1 func_file_conv "$2" mingw set x "$@" -I"$file" shift ;; -I*) func_file_conv "${1#-I}" mingw set x "$@" -I"$file" shift ;; -l) eat=1 func_cl_dashl "$2" set x "$@" "$lib" shift ;; -l*) func_cl_dashl "${1#-l}" set x "$@" "$lib" shift ;; -L) eat=1 func_cl_dashL "$2" ;; -L*) func_cl_dashL "${1#-L}" ;; -static) shared=false ;; -Wl,*) arg=${1#-Wl,} save_ifs="$IFS"; IFS=',' for flag in $arg; do IFS="$save_ifs" linker_opts="$linker_opts $flag" done IFS="$save_ifs" ;; -Xlinker) eat=1 linker_opts="$linker_opts $2" ;; -*) set x "$@" "$1" shift ;; *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) func_file_conv "$1" set x "$@" -Tp"$file" shift ;; *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) func_file_conv "$1" mingw set x "$@" "$file" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -n "$linker_opts"; then linker_opts="-link$linker_opts" fi exec "$@" $linker_opts exit 1 } eat= case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: compile [--help] [--version] PROGRAM [ARGS] Wrapper for compilers which do not understand '-c -o'. Remove '-o dest.o' from ARGS, run PROGRAM with the remaining arguments, and rename the output as expected. If you are trying to build a whole package this is not the right script to run: please start by reading the file 'INSTALL'. Report bugs to . EOF exit $? ;; -v | --v*) echo "compile $scriptversion" exit $? ;; cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \ icl | *[/\\]icl | icl.exe | *[/\\]icl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac ofile= cfile= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. # So we strip '-o arg' only if arg is an object. eat=1 case $2 in *.o | *.obj) ofile=$2 ;; *) set x "$@" -o "$2" shift ;; esac ;; *.c) cfile=$1 set x "$@" "$1" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -z "$ofile" || test -z "$cfile"; then # If no '-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no # '.c' file was seen then we are probably linking. That is also # ok. exec "$@" fi # Name of file we expect compiler to create. cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` # Create the lock directory. # Note: use '[/\\:.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d while true; do if mkdir "$lockdir" >/dev/null 2>&1; then break fi sleep 1 done # FIXME: race condition here if user kills between mkdir and trap. trap "rmdir '$lockdir'; exit 1" 1 2 15 # Run the compile. "$@" ret=$? if test -f "$cofile"; then test "$cofile" = "$ofile" || mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" fi rmdir "$lockdir" exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: assaultcube-1.2.0.2.1/source/enet/compress.c000066400000000000000000000513431352165075300205730ustar00rootroot00000000000000/** @file compress.c @brief An adaptive order-2 PPM range coder */ #define ENET_BUILDING_LIB 1 #include #include "enet/enet.h" typedef struct _ENetSymbol { /* binary indexed tree of symbols */ enet_uint8 value; enet_uint8 count; enet_uint16 under; enet_uint16 left, right; /* context defined by this symbol */ enet_uint16 symbols; enet_uint16 escapes; enet_uint16 total; enet_uint16 parent; } ENetSymbol; /* adaptation constants tuned aggressively for small packet sizes rather than large file compression */ enum { ENET_RANGE_CODER_TOP = 1<<24, ENET_RANGE_CODER_BOTTOM = 1<<16, ENET_CONTEXT_SYMBOL_DELTA = 3, ENET_CONTEXT_SYMBOL_MINIMUM = 1, ENET_CONTEXT_ESCAPE_MINIMUM = 1, ENET_SUBCONTEXT_ORDER = 2, ENET_SUBCONTEXT_SYMBOL_DELTA = 2, ENET_SUBCONTEXT_ESCAPE_DELTA = 5 }; /* context exclusion roughly halves compression speed, so disable for now */ #undef ENET_CONTEXT_EXCLUSION typedef struct _ENetRangeCoder { /* only allocate enough symbols for reasonable MTUs, would need to be larger for large file compression */ ENetSymbol symbols[4096]; } ENetRangeCoder; void * enet_range_coder_create (void) { ENetRangeCoder * rangeCoder = (ENetRangeCoder *) enet_malloc (sizeof (ENetRangeCoder)); if (rangeCoder == NULL) return NULL; return rangeCoder; } void enet_range_coder_destroy (void * context) { ENetRangeCoder * rangeCoder = (ENetRangeCoder *) context; if (rangeCoder == NULL) return; enet_free (rangeCoder); } #define ENET_SYMBOL_CREATE(symbol, value_, count_) \ { \ symbol = & rangeCoder -> symbols [nextSymbol ++]; \ symbol -> value = value_; \ symbol -> count = count_; \ symbol -> under = count_; \ symbol -> left = 0; \ symbol -> right = 0; \ symbol -> symbols = 0; \ symbol -> escapes = 0; \ symbol -> total = 0; \ symbol -> parent = 0; \ } #define ENET_CONTEXT_CREATE(context, escapes_, minimum) \ { \ ENET_SYMBOL_CREATE (context, 0, 0); \ (context) -> escapes = escapes_; \ (context) -> total = escapes_ + 256*minimum; \ (context) -> symbols = 0; \ } static enet_uint16 enet_symbol_rescale (ENetSymbol * symbol) { enet_uint16 total = 0; for (;;) { symbol -> count -= symbol->count >> 1; symbol -> under = symbol -> count; if (symbol -> left) symbol -> under += enet_symbol_rescale (symbol + symbol -> left); total += symbol -> under; if (! symbol -> right) break; symbol += symbol -> right; } return total; } #define ENET_CONTEXT_RESCALE(context, minimum) \ { \ (context) -> total = (context) -> symbols ? enet_symbol_rescale ((context) + (context) -> symbols) : 0; \ (context) -> escapes -= (context) -> escapes >> 1; \ (context) -> total += (context) -> escapes + 256*minimum; \ } #define ENET_RANGE_CODER_OUTPUT(value) \ { \ if (outData >= outEnd) \ return 0; \ * outData ++ = value; \ } #define ENET_RANGE_CODER_ENCODE(under, count, total) \ { \ encodeRange /= (total); \ encodeLow += (under) * encodeRange; \ encodeRange *= (count); \ for (;;) \ { \ if((encodeLow ^ (encodeLow + encodeRange)) >= ENET_RANGE_CODER_TOP) \ { \ if(encodeRange >= ENET_RANGE_CODER_BOTTOM) break; \ encodeRange = -encodeLow & (ENET_RANGE_CODER_BOTTOM - 1); \ } \ ENET_RANGE_CODER_OUTPUT (encodeLow >> 24); \ encodeRange <<= 8; \ encodeLow <<= 8; \ } \ } #define ENET_RANGE_CODER_FLUSH \ { \ while (encodeLow) \ { \ ENET_RANGE_CODER_OUTPUT (encodeLow >> 24); \ encodeLow <<= 8; \ } \ } #define ENET_RANGE_CODER_FREE_SYMBOLS \ { \ if (nextSymbol >= sizeof (rangeCoder -> symbols) / sizeof (ENetSymbol) - ENET_SUBCONTEXT_ORDER ) \ { \ nextSymbol = 0; \ ENET_CONTEXT_CREATE (root, ENET_CONTEXT_ESCAPE_MINIMUM, ENET_CONTEXT_SYMBOL_MINIMUM); \ predicted = 0; \ order = 0; \ } \ } #define ENET_CONTEXT_ENCODE(context, symbol_, value_, under_, count_, update, minimum) \ { \ under_ = value*minimum; \ count_ = minimum; \ if (! (context) -> symbols) \ { \ ENET_SYMBOL_CREATE (symbol_, value_, update); \ (context) -> symbols = symbol_ - (context); \ } \ else \ { \ ENetSymbol * node = (context) + (context) -> symbols; \ for (;;) \ { \ if (value_ < node -> value) \ { \ node -> under += update; \ if (node -> left) { node += node -> left; continue; } \ ENET_SYMBOL_CREATE (symbol_, value_, update); \ node -> left = symbol_ - node; \ } \ else \ if (value_ > node -> value) \ { \ under_ += node -> under; \ if (node -> right) { node += node -> right; continue; } \ ENET_SYMBOL_CREATE (symbol_, value_, update); \ node -> right = symbol_ - node; \ } \ else \ { \ count_ += node -> count; \ under_ += node -> under - node -> count; \ node -> under += update; \ node -> count += update; \ symbol_ = node; \ } \ break; \ } \ } \ } #ifdef ENET_CONTEXT_EXCLUSION static const ENetSymbol emptyContext = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; #define ENET_CONTEXT_WALK(context, body) \ { \ const ENetSymbol * node = (context) + (context) -> symbols; \ const ENetSymbol * stack [256]; \ size_t stackSize = 0; \ while (node -> left) \ { \ stack [stackSize ++] = node; \ node += node -> left; \ } \ for (;;) \ { \ body; \ if (node -> right) \ { \ node += node -> right; \ while (node -> left) \ { \ stack [stackSize ++] = node; \ node += node -> left; \ } \ } \ else \ if (stackSize <= 0) \ break; \ else \ node = stack [-- stackSize]; \ } \ } #define ENET_CONTEXT_ENCODE_EXCLUDE(context, value_, under, total, minimum) \ ENET_CONTEXT_WALK(context, { \ if (node -> value != value_) \ { \ enet_uint16 parentCount = rangeCoder -> symbols [node -> parent].count + minimum; \ if (node -> value < value_) \ under -= parentCount; \ total -= parentCount; \ } \ }) #endif size_t enet_range_coder_compress (void * context, const ENetBuffer * inBuffers, size_t inBufferCount, size_t inLimit, enet_uint8 * outData, size_t outLimit) { ENetRangeCoder * rangeCoder = (ENetRangeCoder *) context; enet_uint8 * outStart = outData, * outEnd = & outData [outLimit]; const enet_uint8 * inData, * inEnd; enet_uint32 encodeLow = 0, encodeRange = ~0; ENetSymbol * root; enet_uint16 predicted = 0; size_t order = 0, nextSymbol = 0; if (rangeCoder == NULL || inBufferCount <= 0 || inLimit <= 0) return 0; inData = (const enet_uint8 *) inBuffers -> data; inEnd = & inData [inBuffers -> dataLength]; inBuffers ++; inBufferCount --; ENET_CONTEXT_CREATE (root, ENET_CONTEXT_ESCAPE_MINIMUM, ENET_CONTEXT_SYMBOL_MINIMUM); for (;;) { ENetSymbol * subcontext, * symbol; #ifdef ENET_CONTEXT_EXCLUSION const ENetSymbol * childContext = & emptyContext; #endif enet_uint8 value; enet_uint16 count, under, * parent = & predicted, total; if (inData >= inEnd) { if (inBufferCount <= 0) break; inData = (const enet_uint8 *) inBuffers -> data; inEnd = & inData [inBuffers -> dataLength]; inBuffers ++; inBufferCount --; } value = * inData ++; for (subcontext = & rangeCoder -> symbols [predicted]; subcontext != root; #ifdef ENET_CONTEXT_EXCLUSION childContext = subcontext, #endif subcontext = & rangeCoder -> symbols [subcontext -> parent]) { ENET_CONTEXT_ENCODE (subcontext, symbol, value, under, count, ENET_SUBCONTEXT_SYMBOL_DELTA, 0); * parent = symbol - rangeCoder -> symbols; parent = & symbol -> parent; total = subcontext -> total; #ifdef ENET_CONTEXT_EXCLUSION if (childContext -> total > ENET_SUBCONTEXT_SYMBOL_DELTA + ENET_SUBCONTEXT_ESCAPE_DELTA) ENET_CONTEXT_ENCODE_EXCLUDE (childContext, value, under, total, 0); #endif if (count > 0) { ENET_RANGE_CODER_ENCODE (subcontext -> escapes + under, count, total); } else { if (subcontext -> escapes > 0 && subcontext -> escapes < total) ENET_RANGE_CODER_ENCODE (0, subcontext -> escapes, total); subcontext -> escapes += ENET_SUBCONTEXT_ESCAPE_DELTA; subcontext -> total += ENET_SUBCONTEXT_ESCAPE_DELTA; } subcontext -> total += ENET_SUBCONTEXT_SYMBOL_DELTA; if (count > 0xFF - 2*ENET_SUBCONTEXT_SYMBOL_DELTA || subcontext -> total > ENET_RANGE_CODER_BOTTOM - 0x100) ENET_CONTEXT_RESCALE (subcontext, 0); if (count > 0) goto nextInput; } ENET_CONTEXT_ENCODE (root, symbol, value, under, count, ENET_CONTEXT_SYMBOL_DELTA, ENET_CONTEXT_SYMBOL_MINIMUM); * parent = symbol - rangeCoder -> symbols; parent = & symbol -> parent; total = root -> total; #ifdef ENET_CONTEXT_EXCLUSION if (childContext -> total > ENET_SUBCONTEXT_SYMBOL_DELTA + ENET_SUBCONTEXT_ESCAPE_DELTA) ENET_CONTEXT_ENCODE_EXCLUDE (childContext, value, under, total, ENET_CONTEXT_SYMBOL_MINIMUM); #endif ENET_RANGE_CODER_ENCODE (root -> escapes + under, count, total); root -> total += ENET_CONTEXT_SYMBOL_DELTA; if (count > 0xFF - 2*ENET_CONTEXT_SYMBOL_DELTA + ENET_CONTEXT_SYMBOL_MINIMUM || root -> total > ENET_RANGE_CODER_BOTTOM - 0x100) ENET_CONTEXT_RESCALE (root, ENET_CONTEXT_SYMBOL_MINIMUM); nextInput: if (order >= ENET_SUBCONTEXT_ORDER) predicted = rangeCoder -> symbols [predicted].parent; else order ++; ENET_RANGE_CODER_FREE_SYMBOLS; } ENET_RANGE_CODER_FLUSH; return (size_t) (outData - outStart); } #define ENET_RANGE_CODER_SEED \ { \ if (inData < inEnd) decodeCode |= * inData ++ << 24; \ if (inData < inEnd) decodeCode |= * inData ++ << 16; \ if (inData < inEnd) decodeCode |= * inData ++ << 8; \ if (inData < inEnd) decodeCode |= * inData ++; \ } #define ENET_RANGE_CODER_READ(total) ((decodeCode - decodeLow) / (decodeRange /= (total))) #define ENET_RANGE_CODER_DECODE(under, count, total) \ { \ decodeLow += (under) * decodeRange; \ decodeRange *= (count); \ for (;;) \ { \ if((decodeLow ^ (decodeLow + decodeRange)) >= ENET_RANGE_CODER_TOP) \ { \ if(decodeRange >= ENET_RANGE_CODER_BOTTOM) break; \ decodeRange = -decodeLow & (ENET_RANGE_CODER_BOTTOM - 1); \ } \ decodeCode <<= 8; \ if (inData < inEnd) \ decodeCode |= * inData ++; \ decodeRange <<= 8; \ decodeLow <<= 8; \ } \ } #define ENET_CONTEXT_DECODE(context, symbol_, code, value_, under_, count_, update, minimum, createRoot, visitNode, createRight, createLeft) \ { \ under_ = 0; \ count_ = minimum; \ if (! (context) -> symbols) \ { \ createRoot; \ } \ else \ { \ ENetSymbol * node = (context) + (context) -> symbols; \ for (;;) \ { \ enet_uint16 after = under_ + node -> under + (node -> value + 1)*minimum, before = node -> count + minimum; \ visitNode; \ if (code >= after) \ { \ under_ += node -> under; \ if (node -> right) { node += node -> right; continue; } \ createRight; \ } \ else \ if (code < after - before) \ { \ node -> under += update; \ if (node -> left) { node += node -> left; continue; } \ createLeft; \ } \ else \ { \ value_ = node -> value; \ count_ += node -> count; \ under_ = after - before; \ node -> under += update; \ node -> count += update; \ symbol_ = node; \ } \ break; \ } \ } \ } #define ENET_CONTEXT_TRY_DECODE(context, symbol_, code, value_, under_, count_, update, minimum, exclude) \ ENET_CONTEXT_DECODE (context, symbol_, code, value_, under_, count_, update, minimum, return 0, exclude (node -> value, after, before), return 0, return 0) #define ENET_CONTEXT_ROOT_DECODE(context, symbol_, code, value_, under_, count_, update, minimum, exclude) \ ENET_CONTEXT_DECODE (context, symbol_, code, value_, under_, count_, update, minimum, \ { \ value_ = code / minimum; \ under_ = code - code%minimum; \ ENET_SYMBOL_CREATE (symbol_, value_, update); \ (context) -> symbols = symbol_ - (context); \ }, \ exclude (node -> value, after, before), \ { \ value_ = node->value + 1 + (code - after)/minimum; \ under_ = code - (code - after)%minimum; \ ENET_SYMBOL_CREATE (symbol_, value_, update); \ node -> right = symbol_ - node; \ }, \ { \ value_ = node->value - 1 - (after - before - code - 1)/minimum; \ under_ = code - (after - before - code - 1)%minimum; \ ENET_SYMBOL_CREATE (symbol_, value_, update); \ node -> left = symbol_ - node; \ }) \ #ifdef ENET_CONTEXT_EXCLUSION typedef struct _ENetExclude { enet_uint8 value; enet_uint16 under; } ENetExclude; #define ENET_CONTEXT_DECODE_EXCLUDE(context, total, minimum) \ { \ enet_uint16 under = 0; \ nextExclude = excludes; \ ENET_CONTEXT_WALK (context, { \ under += rangeCoder -> symbols [node -> parent].count + minimum; \ nextExclude -> value = node -> value; \ nextExclude -> under = under; \ nextExclude ++; \ }); \ total -= under; \ } #define ENET_CONTEXT_EXCLUDED(value_, after, before) \ { \ size_t low = 0, high = nextExclude - excludes; \ for(;;) \ { \ size_t mid = (low + high) >> 1; \ const ENetExclude * exclude = & excludes [mid]; \ if (value_ < exclude -> value) \ { \ if (low + 1 < high) \ { \ high = mid; \ continue; \ } \ if (exclude > excludes) \ after -= exclude [-1].under; \ } \ else \ { \ if (value_ > exclude -> value) \ { \ if (low + 1 < high) \ { \ low = mid; \ continue; \ } \ } \ else \ before = 0; \ after -= exclude -> under; \ } \ break; \ } \ } #endif #define ENET_CONTEXT_NOT_EXCLUDED(value_, after, before) size_t enet_range_coder_decompress (void * context, const enet_uint8 * inData, size_t inLimit, enet_uint8 * outData, size_t outLimit) { ENetRangeCoder * rangeCoder = (ENetRangeCoder *) context; enet_uint8 * outStart = outData, * outEnd = & outData [outLimit]; const enet_uint8 * inEnd = & inData [inLimit]; enet_uint32 decodeLow = 0, decodeCode = 0, decodeRange = ~0; ENetSymbol * root; enet_uint16 predicted = 0; size_t order = 0, nextSymbol = 0; #ifdef ENET_CONTEXT_EXCLUSION ENetExclude excludes [256]; ENetExclude * nextExclude = excludes; #endif if (rangeCoder == NULL || inLimit <= 0) return 0; ENET_CONTEXT_CREATE (root, ENET_CONTEXT_ESCAPE_MINIMUM, ENET_CONTEXT_SYMBOL_MINIMUM); ENET_RANGE_CODER_SEED; for (;;) { ENetSymbol * subcontext, * symbol, * patch; #ifdef ENET_CONTEXT_EXCLUSION const ENetSymbol * childContext = & emptyContext; #endif enet_uint8 value = 0; enet_uint16 code, under, count, bottom, * parent = & predicted, total; for (subcontext = & rangeCoder -> symbols [predicted]; subcontext != root; #ifdef ENET_CONTEXT_EXCLUSION childContext = subcontext, #endif subcontext = & rangeCoder -> symbols [subcontext -> parent]) { if (subcontext -> escapes <= 0) continue; total = subcontext -> total; #ifdef ENET_CONTEXT_EXCLUSION if (childContext -> total > 0) ENET_CONTEXT_DECODE_EXCLUDE (childContext, total, 0); #endif if (subcontext -> escapes >= total) continue; code = ENET_RANGE_CODER_READ (total); if (code < subcontext -> escapes) { ENET_RANGE_CODER_DECODE (0, subcontext -> escapes, total); continue; } code -= subcontext -> escapes; #ifdef ENET_CONTEXT_EXCLUSION if (childContext -> total > 0) { ENET_CONTEXT_TRY_DECODE (subcontext, symbol, code, value, under, count, ENET_SUBCONTEXT_SYMBOL_DELTA, 0, ENET_CONTEXT_EXCLUDED); } else #endif { ENET_CONTEXT_TRY_DECODE (subcontext, symbol, code, value, under, count, ENET_SUBCONTEXT_SYMBOL_DELTA, 0, ENET_CONTEXT_NOT_EXCLUDED); } bottom = symbol - rangeCoder -> symbols; ENET_RANGE_CODER_DECODE (subcontext -> escapes + under, count, total); subcontext -> total += ENET_SUBCONTEXT_SYMBOL_DELTA; if (count > 0xFF - 2*ENET_SUBCONTEXT_SYMBOL_DELTA || subcontext -> total > ENET_RANGE_CODER_BOTTOM - 0x100) ENET_CONTEXT_RESCALE (subcontext, 0); goto patchContexts; } total = root -> total; #ifdef ENET_CONTEXT_EXCLUSION if (childContext -> total > 0) ENET_CONTEXT_DECODE_EXCLUDE (childContext, total, ENET_CONTEXT_SYMBOL_MINIMUM); #endif code = ENET_RANGE_CODER_READ (total); if (code < root -> escapes) { ENET_RANGE_CODER_DECODE (0, root -> escapes, total); break; } code -= root -> escapes; #ifdef ENET_CONTEXT_EXCLUSION if (childContext -> total > 0) { ENET_CONTEXT_ROOT_DECODE (root, symbol, code, value, under, count, ENET_CONTEXT_SYMBOL_DELTA, ENET_CONTEXT_SYMBOL_MINIMUM, ENET_CONTEXT_EXCLUDED); } else #endif { ENET_CONTEXT_ROOT_DECODE (root, symbol, code, value, under, count, ENET_CONTEXT_SYMBOL_DELTA, ENET_CONTEXT_SYMBOL_MINIMUM, ENET_CONTEXT_NOT_EXCLUDED); } bottom = symbol - rangeCoder -> symbols; ENET_RANGE_CODER_DECODE (root -> escapes + under, count, total); root -> total += ENET_CONTEXT_SYMBOL_DELTA; if (count > 0xFF - 2*ENET_CONTEXT_SYMBOL_DELTA + ENET_CONTEXT_SYMBOL_MINIMUM || root -> total > ENET_RANGE_CODER_BOTTOM - 0x100) ENET_CONTEXT_RESCALE (root, ENET_CONTEXT_SYMBOL_MINIMUM); patchContexts: for (patch = & rangeCoder -> symbols [predicted]; patch != subcontext; patch = & rangeCoder -> symbols [patch -> parent]) { ENET_CONTEXT_ENCODE (patch, symbol, value, under, count, ENET_SUBCONTEXT_SYMBOL_DELTA, 0); * parent = symbol - rangeCoder -> symbols; parent = & symbol -> parent; if (count <= 0) { patch -> escapes += ENET_SUBCONTEXT_ESCAPE_DELTA; patch -> total += ENET_SUBCONTEXT_ESCAPE_DELTA; } patch -> total += ENET_SUBCONTEXT_SYMBOL_DELTA; if (count > 0xFF - 2*ENET_SUBCONTEXT_SYMBOL_DELTA || patch -> total > ENET_RANGE_CODER_BOTTOM - 0x100) ENET_CONTEXT_RESCALE (patch, 0); } * parent = bottom; ENET_RANGE_CODER_OUTPUT (value); if (order >= ENET_SUBCONTEXT_ORDER) predicted = rangeCoder -> symbols [predicted].parent; else order ++; ENET_RANGE_CODER_FREE_SYMBOLS; } return (size_t) (outData - outStart); } /** @defgroup host ENet host functions @{ */ /** Sets the packet compressor the host should use to the default range coder. @param host host to enable the range coder for @returns 0 on success, < 0 on failure */ int enet_host_compress_with_range_coder (ENetHost * host) { ENetCompressor compressor; memset (& compressor, 0, sizeof (compressor)); compressor.context = enet_range_coder_create(); if (compressor.context == NULL) return -1; compressor.compress = enet_range_coder_compress; compressor.decompress = enet_range_coder_decompress; compressor.destroy = enet_range_coder_destroy; enet_host_compress (host, & compressor); return 0; } /** @} */ assaultcube-1.2.0.2.1/source/enet/config.guess000077500000000000000000001263731352165075300211220ustar00rootroot00000000000000#! /bin/sh # Attempt to guess a canonical system name. # Copyright 1992-2018 Free Software Foundation, Inc. timestamp='2018-02-24' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: # https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess # # Please send patches to . me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright 1992-2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > "$dummy.c" ; for c in cc gcc c89 c99 ; do if ($c -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "$UNAME_SYSTEM" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu eval "$set_cc_for_build" cat <<-EOF > "$dummy.c" #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #else LIBC=gnu #endif EOF eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`" # If ldd exists, use it to detect musl libc. if command -v ldd >/dev/null && \ ldd --version 2>&1 | grep -q ^musl then LIBC=musl fi ;; esac # Note: order is significant - the case branches are not exclusive. case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ "/sbin/$sysctl" 2>/dev/null || \ "/usr/sbin/$sysctl" 2>/dev/null || \ echo unknown)` case "$UNAME_MACHINE_ARCH" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` machine="${arch}${endian}"-unknown ;; *) machine="$UNAME_MACHINE_ARCH"-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently (or will in the future) and ABI. case "$UNAME_MACHINE_ARCH" in earm*) os=netbsdelf ;; arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval "$set_cc_for_build" if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # Determine ABI tags. case "$UNAME_MACHINE_ARCH" in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "$UNAME_VERSION" in Debian*) release='-gnu' ;; *) release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "$machine-${os}${release}${abi}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" exit ;; *:LibertyBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" exit ;; *:MidnightBSD:*:*) echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" exit ;; *:ekkoBSD:*:*) echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" exit ;; *:SolidBSD:*:*) echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:MirBSD:*:*) echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:Sortix:*:*) echo "$UNAME_MACHINE"-unknown-sortix exit ;; *:Redox:*:*) echo "$UNAME_MACHINE"-unknown-redox exit ;; mips:OSF1:*.*) echo mips-dec-osf1 exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE=alpha ;; "EV4.5 (21064)") UNAME_MACHINE=alpha ;; "LCA4 (21066/21068)") UNAME_MACHINE=alpha ;; "EV5 (21164)") UNAME_MACHINE=alphaev5 ;; "EV5.6 (21164A)") UNAME_MACHINE=alphaev56 ;; "EV5.6 (21164PC)") UNAME_MACHINE=alphapca56 ;; "EV5.7 (21164PC)") UNAME_MACHINE=alphapca57 ;; "EV6 (21264)") UNAME_MACHINE=alphaev6 ;; "EV6.7 (21264A)") UNAME_MACHINE=alphaev67 ;; "EV6.8CB (21264C)") UNAME_MACHINE=alphaev68 ;; "EV6.8AL (21264B)") UNAME_MACHINE=alphaev68 ;; "EV6.8CX (21264D)") UNAME_MACHINE=alphaev68 ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE=alphaev69 ;; "EV7 (21364)") UNAME_MACHINE=alphaev7 ;; "EV7.9 (21364A)") UNAME_MACHINE=alphaev79 ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`" # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo "$UNAME_MACHINE"-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo "$UNAME_MACHINE"-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix"$UNAME_RELEASE" exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux"$UNAME_RELEASE" exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval "$set_cc_for_build" SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH=x86_64 fi fi echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`" exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos"$UNAME_RELEASE" exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos"$UNAME_RELEASE" ;; sun4) echo sparc-sun-sunos"$UNAME_RELEASE" ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos"$UNAME_RELEASE" exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint"$UNAME_RELEASE" exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint"$UNAME_RELEASE" exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint"$UNAME_RELEASE" exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint"$UNAME_RELEASE" exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint"$UNAME_RELEASE" exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint"$UNAME_RELEASE" exit ;; m68k:machten:*:*) echo m68k-apple-machten"$UNAME_RELEASE" exit ;; powerpc:machten:*:*) echo powerpc-apple-machten"$UNAME_RELEASE" exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix"$UNAME_RELEASE" exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix"$UNAME_RELEASE" exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix"$UNAME_RELEASE" exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval "$set_cc_for_build" sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" && dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`"$dummy" "$dummyarg"` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos"$UNAME_RELEASE" exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ] then if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \ [ "$TARGET_BINARY_INTERFACE"x = x ] then echo m88k-dg-dgux"$UNAME_RELEASE" else echo m88k-dg-dguxbcs"$UNAME_RELEASE" fi else echo i586-dg-dgux"$UNAME_RELEASE" fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`" exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval "$set_cc_for_build" sed 's/^ //' << EOF > "$dummy.c" #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/lslpp ] ; then IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi echo "$IBM_ARCH"-ibm-aix"$IBM_REV" exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` case "$UNAME_MACHINE" in 9000/31?) HP_ARCH=m68000 ;; 9000/[34]??) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "$sc_cpu_version" in 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "$sc_kernel_bits" in 32) HP_ARCH=hppa2.0n ;; 64) HP_ARCH=hppa2.0w ;; '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi if [ "$HP_ARCH" = "" ]; then eval "$set_cc_for_build" sed 's/^ //' << EOF > "$dummy.c" #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ "$HP_ARCH" = hppa2.0w ] then eval "$set_cc_for_build" # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH=hppa2.0w else HP_ARCH=hppa64 fi fi echo "$HP_ARCH"-hp-hpux"$HPUX_REV" exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux"$HPUX_REV" exit ;; 3050*:HI-UX:*:*) eval "$set_cc_for_build" sed 's/^ //' << EOF > "$dummy.c" #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo "$UNAME_MACHINE"-unknown-osf1mk else echo "$UNAME_MACHINE"-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi"$UNAME_RELEASE" exit ;; *:BSD/OS:*:*) echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case "$UNAME_PROCESSOR" in amd64) UNAME_PROCESSOR=x86_64 ;; i386) UNAME_PROCESSOR=i586 ;; esac echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; i*:CYGWIN*:*) echo "$UNAME_MACHINE"-pc-cygwin exit ;; *:MINGW64*:*) echo "$UNAME_MACHINE"-pc-mingw64 exit ;; *:MINGW*:*) echo "$UNAME_MACHINE"-pc-mingw32 exit ;; *:MSYS*:*) echo "$UNAME_MACHINE"-pc-msys exit ;; i*:PW*:*) echo "$UNAME_MACHINE"-pc-pw32 exit ;; *:Interix*:*) case "$UNAME_MACHINE" in x86) echo i586-pc-interix"$UNAME_RELEASE" exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix"$UNAME_RELEASE" exit ;; IA64) echo ia64-unknown-interix"$UNAME_RELEASE" exit ;; esac ;; i*:UWIN*:*) echo "$UNAME_MACHINE"-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; *:GNU:*:*) # the GNU system echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`" exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC" exit ;; i*86:Minix:*:*) echo "$UNAME_MACHINE"-pc-minix exit ;; aarch64:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC=gnulibc1 ; fi echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arc:Linux:*:* | arceb:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arm*:Linux:*:*) eval "$set_cc_for_build" if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi else echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf fi fi exit ;; avr32*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; cris:Linux:*:*) echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; crisv32:Linux:*:*) echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; e2k:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; frv:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; hexagon:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:Linux:*:*) echo "$UNAME_MACHINE"-pc-linux-"$LIBC" exit ;; ia64:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; k1om:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m32r*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m68*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval "$set_cc_for_build" sed 's/^ //' << EOF > "$dummy.c" #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`" test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; } ;; mips64el:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; openrisc*:Linux:*:*) echo or1k-unknown-linux-"$LIBC" exit ;; or32:Linux:*:* | or1k*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; padre:Linux:*:*) echo sparc-unknown-linux-"$LIBC" exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-"$LIBC" exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; *) echo hppa-unknown-linux-"$LIBC" ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-"$LIBC" exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-"$LIBC" exit ;; ppc64le:Linux:*:*) echo powerpc64le-unknown-linux-"$LIBC" exit ;; ppcle:Linux:*:*) echo powerpcle-unknown-linux-"$LIBC" exit ;; riscv32:Linux:*:* | riscv64:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" exit ;; sh64*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sh*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; tile*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; vax:Linux:*:*) echo "$UNAME_MACHINE"-dec-linux-"$LIBC" exit ;; x86_64:Linux:*:*) if objdump -f /bin/sh | grep -q elf32-x86-64; then echo "$UNAME_MACHINE"-pc-linux-"$LIBC"x32 else echo "$UNAME_MACHINE"-pc-linux-"$LIBC" fi exit ;; xtensa*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo "$UNAME_MACHINE"-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo "$UNAME_MACHINE"-unknown-stop exit ;; i*86:atheos:*:*) echo "$UNAME_MACHINE"-unknown-atheos exit ;; i*86:syllable:*:*) echo "$UNAME_MACHINE"-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos"$UNAME_RELEASE" exit ;; i*86:*DOS:*:*) echo "$UNAME_MACHINE"-pc-msdosdjgpp exit ;; i*86:*:4.*:*) UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" else echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}" exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" else echo "$UNAME_MACHINE"-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos"$UNAME_RELEASE" exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos"$UNAME_RELEASE" exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos"$UNAME_RELEASE" exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos"$UNAME_RELEASE" exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv"$UNAME_RELEASE" exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo "$UNAME_MACHINE"-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo "$UNAME_MACHINE"-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux"$UNAME_RELEASE" exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv"$UNAME_RELEASE" else echo mips-unknown-sysv"$UNAME_RELEASE" fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; x86_64:Haiku:*:*) echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux"$UNAME_RELEASE" exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux"$UNAME_RELEASE" exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux"$UNAME_RELEASE" exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux"$UNAME_RELEASE" exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux"$UNAME_RELEASE" exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux"$UNAME_RELEASE" exit ;; SX-ACE:SUPER-UX:*:*) echo sxace-nec-superux"$UNAME_RELEASE" exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Rhapsody:*:*) echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown eval "$set_cc_for_build" if test "$UNAME_PROCESSOR" = unknown ; then UNAME_PROCESSOR=powerpc fi if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_PPC >/dev/null then UNAME_PROCESSOR=powerpc fi fi elif test "$UNAME_PROCESSOR" = i386 ; then # Avoid executing cc on OS X 10.9, as it ships with a stub # that puts up a graphical alert prompting to install # developer tools. Any system running Mac OS X 10.7 or # later (Darwin 11 and later) is required to have a 64-bit # processor. This is not true of the ARM version of Darwin # that Apple uses in portable devices. UNAME_PROCESSOR=x86_64 fi echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-*:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk"$UNAME_RELEASE" exit ;; NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk"$UNAME_RELEASE" exit ;; NSR-*:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk"$UNAME_RELEASE" exit ;; NSV-*:NONSTOP_KERNEL:*:*) echo nsv-tandem-nsk"$UNAME_RELEASE" exit ;; NSX-*:NONSTOP_KERNEL:*:*) echo nsx-tandem-nsk"$UNAME_RELEASE" exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = 386; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo "$UNAME_MACHINE"-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux"$UNAME_RELEASE" exit ;; *:DragonFly:*:*) echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "$UNAME_MACHINE" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`" exit ;; i*86:rdos:*:*) echo "$UNAME_MACHINE"-pc-rdos exit ;; i*86:AROS:*:*) echo "$UNAME_MACHINE"-pc-aros exit ;; x86_64:VMkernel:*:*) echo "$UNAME_MACHINE"-unknown-esx exit ;; amd64:Isilon\ OneFS:*:*) echo x86_64-unknown-onefs exit ;; esac echo "$0: unable to guess system type" >&2 case "$UNAME_MACHINE:$UNAME_SYSTEM" in mips:Linux | mips64:Linux) # If we got here on MIPS GNU/Linux, output extra information. cat >&2 <&2 </dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = "$UNAME_MACHINE" UNAME_RELEASE = "$UNAME_RELEASE" UNAME_SYSTEM = "$UNAME_SYSTEM" UNAME_VERSION = "$UNAME_VERSION" EOF exit 1 # Local variables: # eval: (add-hook 'write-file-functions 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: assaultcube-1.2.0.2.1/source/enet/config.sub000077500000000000000000001064501352165075300205570ustar00rootroot00000000000000#! /bin/sh # Configuration validation subroutine script. # Copyright 1992-2018 Free Software Foundation, Inc. timestamp='2018-02-22' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # Please send patches to . # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS Canonicalize a configuration name. Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright 1992-2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo "$1" exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ kopensolaris*-gnu* | cloudabi*-eabi* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) basic_machine=`echo "$1" | sed 's/-[^-]*$//'` if [ "$basic_machine" != "$1" ] then os=`echo "$1" | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -lynx*178) os=-lynxos178 ;; -lynx*5) os=-lynxos5 ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo "$1" | sed -e 's/86-.*/86-sequent/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arceb \ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | avr | avr32 \ | ba \ | be32 | be64 \ | bfin \ | c4x | c8051 | clipper \ | d10v | d30v | dlx | dsp16xx \ | e2k | epiphany \ | fido | fr30 | frv | ft32 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia16 | ia64 \ | ip2k | iq2000 \ | k1om \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa32r6 | mipsisa32r6el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64r6 | mipsisa64r6el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ | open8 | or1k | or1knd | or32 \ | pdp10 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pru \ | pyramid \ | riscv32 | riscv64 \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | visium \ | wasm32 \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; leon|leon[3-9]) basic_machine=sparc-$basic_machine ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown os=-none ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | ba-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | c8051-* | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | e2k-* | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ | ip2k-* | iq2000-* \ | k1om-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa32r6-* | mipsisa32r6el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64r6-* | mipsisa64r6el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | or1k*-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pru-* \ | pyramid-* \ | riscv32-* | riscv64-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | visium-* \ | wasm32-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-pc os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; asmjs) basic_machine=asmjs-unknown ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo "$basic_machine" | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2*) basic_machine=m68k-bull os=-sysv3 ;; e500v[12]) basic_machine=powerpc-unknown os=$os"spe" ;; e500v[12]-*) basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` os=$os"spe" ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; leon-*|leon[3-9]-*) basic_machine=sparc-`echo "$basic_machine" | sed 's/-.*//'` ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo "$basic_machine" | sed 's/^[^-]*-//'` os=-linux ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze*) basic_machine=microblaze-xilinx ;; mingw64) basic_machine=x86_64-pc os=-mingw64 ;; mingw32) basic_machine=i686-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; moxiebox) basic_machine=moxie-unknown os=-moxiebox ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo "$basic_machine" | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i686-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; nsv-tandem) basic_machine=nsv-tandem ;; nsx-tandem) basic_machine=nsx-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo "$basic_machine" | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos | rdos64) basic_machine=x86_64-pc os=-rdos ;; rdos32) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh5el) basic_machine=sh5le-unknown ;; simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; x64) basic_machine=x86_64-pc ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo "$basic_machine" | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases that might get confused # with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # es1800 is here to avoid being matched by es* (a different OS) -es1800*) os=-ose ;; # Now accept the basic system types. # The portable systems comes first. # Each alternative MUST end in a * to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* | -cloudabi* | -sortix* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -knetbsd* | -mirbsd* | -netbsd* \ | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox* | -bme* \ | -midnightbsd*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -xray | -os68k* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo "$os" | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo "$os" | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo "$os" | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4*) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -pikeos*) # Until real need of OS specific support for # particular features comes up, bare metal # configurations are quite functional. case $basic_machine in arm*) os=-eabi ;; *) os=-elf ;; esac ;; -nacl*) ;; -ios) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; c8051-*) os=-elf ;; hexagon-*) os=-elf ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; pru-*) os=-elf ;; *-be) os=-beos ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo "$basic_machine" | sed "s/unknown/$vendor/"` ;; esac echo "$basic_machine$os" exit # Local variables: # eval: (add-hook 'write-file-functions 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: assaultcube-1.2.0.2.1/source/enet/configure000077500000000000000000015012401352165075300205000ustar00rootroot00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for libenet 1.3.6. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" SHELL=${CONFIG_SHELL-/bin/sh} test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='libenet' PACKAGE_TARNAME='libenet' PACKAGE_VERSION='1.3.6' PACKAGE_STRING='libenet 1.3.6' PACKAGE_BUGREPORT='' PACKAGE_URL='' ac_unique_file="include/enet/enet.h" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS CPP LT_SYS_LIBRARY_PATH OTOOL64 OTOOL LIPO NMEDIT DSYMUTIL MANIFEST_TOOL RANLIB ac_ct_AR AR DLLTOOL OBJDUMP LN_S NM ac_ct_DUMPBIN DUMPBIN LD FGREP EGREP GREP SED host_os host_vendor host_cpu host build_os build_vendor build_cpu build LIBTOOL am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC MAINT MAINTAINER_MODE_FALSE MAINTAINER_MODE_TRUE AM_BACKSLASH AM_DEFAULT_VERBOSITY AM_DEFAULT_V AM_V am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir runstatedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL am__quote' ac_subst_files='' ac_user_opts=' enable_option_checking enable_silent_rules enable_maintainer_mode enable_dependency_tracking enable_shared enable_static with_pic enable_fast_install with_aix_soname with_gnu_ld with_sysroot enable_libtool_lock ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS LT_SYS_LIBRARY_PATH CPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -runstatedir | --runstatedir | --runstatedi | --runstated \ | --runstate | --runstat | --runsta | --runst | --runs \ | --run | --ru | --r) ac_prev=runstatedir ;; -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ | --run=* | --ru=* | --r=*) runstatedir=$ac_optarg ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures libenet 1.3.6 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/libenet] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of libenet 1.3.6:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-silent-rules less verbose build output (undo: "make V=1") --disable-silent-rules verbose build output (undo: "make V=0") --disable-maintainer-mode disable make rules and dependencies not useful (and sometimes confusing) to the casual installer --enable-dependency-tracking do not reject slow dependency extractors --disable-dependency-tracking speeds up one-time build --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] build static libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use both] --with-aix-soname=aix|svr4|both shared library versioning (aka "SONAME") variant to provide on AIX, [default=aix]. --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-sysroot[=DIR] Search for dependent libraries within DIR (or the compiler's sysroot if not specified). Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory LT_SYS_LIBRARY_PATH User-defined run-time library search path. CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to the package provider. _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF libenet configure 1.3.6 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func # ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES # ---------------------------------------------------- # Tries to find if the field MEMBER exists in type AGGR, after including # INCLUDES, setting cache variable VAR accordingly. ac_fn_c_check_member () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 $as_echo_n "checking for $2.$3... " >&6; } if eval \${$4+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $5 int main () { static $2 ac_aggr; if (ac_aggr.$3) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$4=yes" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $5 int main () { static $2 ac_aggr; if (sizeof ac_aggr.$3) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$4=yes" else eval "$4=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$4 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_member # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by libenet $as_me 1.3.6, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu am__api_version='1.16' ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi if test "$2" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi rm -f conftest.file test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # Expand $ac_aux_dir to an absolute path. am_aux_dir=`cd "$ac_aux_dir" && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} fi if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null # Check whether --enable-silent-rules was given. if test "${enable_silent_rules+set}" = set; then : enableval=$enable_silent_rules; fi case $enable_silent_rules in # ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=1;; esac am_make=${MAKE-make} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 $as_echo_n "checking whether $am_make supports nested variables... " >&6; } if ${am_cv_make_support_nested_variables+:} false; then : $as_echo_n "(cached) " >&6 else if $as_echo 'TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 $as_echo "$am_cv_make_support_nested_variables" >&6; } if test $am_cv_make_support_nested_variables = yes; then AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AM_BACKSLASH='\' if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='libenet' VERSION='1.3.6' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # mkdir_p='$(MKDIR_P)' # We need awk for the "check" target (and possibly the TAP driver). The # system "awk" is bad on some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar pax cpio none' am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } # Check whether --enable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then : enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval else USE_MAINTAINER_MODE=yes fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5 $as_echo "$USE_MAINTAINER_MODE" >&6; } if test $USE_MAINTAINER_MODE = yes; then MAINTAINER_MODE_TRUE= MAINTAINER_MODE_FALSE='#' else MAINTAINER_MODE_TRUE='#' MAINTAINER_MODE_FALSE= fi MAINT=$MAINTAINER_MODE_TRUE ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 $as_echo_n "checking whether $CC understands -c and -o together... " >&6; } if ${am_cv_prog_cc_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 $as_echo "$am_cv_prog_cc_c_o" >&6; } if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} supports the include directive" >&5 $as_echo_n "checking whether ${MAKE-make} supports the include directive... " >&6; } cat > confinc.mk << 'END' am__doit: @echo this is the am__doit target >confinc.out .PHONY: am__doit END am__include="#" am__quote= # BSD make does it like this. echo '.include "confinc.mk" # ignored' > confmf.BSD # Other make implementations (GNU, Solaris 10, AIX) do it like this. echo 'include confinc.mk # ignored' > confmf.GNU _am_result=no for s in GNU BSD; do { echo "$as_me:$LINENO: ${MAKE-make} -f confmf.$s && cat confinc.out" >&5 (${MAKE-make} -f confmf.$s && cat confinc.out) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } case $?:`cat confinc.out 2>/dev/null` in #( '0:this is the am__doit target') : case $s in #( BSD) : am__include='.include' am__quote='"' ;; #( *) : am__include='include' am__quote='' ;; esac ;; #( *) : ;; esac if test "$am__include" != "#"; then _am_result="yes ($s style)" break fi done rm -f confinc.* confmf.* { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${_am_result}" >&5 $as_echo "${_am_result}" >&6; } # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi case `pwd` in *\ * | *\ *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 $as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; esac macro_version='2.4.6' macro_revision='2.4.6' ltmain=$ac_aux_dir/ltmain.sh # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac # Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\(["`$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 $as_echo_n "checking how to print strings... " >&6; } # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "" } case $ECHO in printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 $as_echo "printf" >&6; } ;; print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 $as_echo "print -r" >&6; } ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 $as_echo "cat" >&6; } ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_SED" || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } if ${ac_cv_path_FGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 then ac_cv_path_FGREP="$GREP -F" else if test -z "$FGREP"; then ac_path_FGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_FGREP" || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in *GNU*) ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'FGREP' >> "conftest.nl" "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_FGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_FGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_FGREP"; then as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_FGREP=$FGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 $as_echo "$ac_cv_path_FGREP" >&6; } FGREP="$ac_cv_path_FGREP" test -z "$GREP" && GREP=grep # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld if test yes = "$GCC"; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return, which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD=$ac_prog ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test yes = "$with_gnu_ld"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if ${lt_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD=$ac_dir/$ac_prog # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if ${lt_cv_prog_gnu_ld+:} false; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 $as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } if ${lt_cv_path_NM+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM=$NM else lt_nm_to_check=${ac_tool_prefix}nm if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. tmp_nm=$ac_dir/$lt_tmp_nm if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then # Check to see if the nm accepts a BSD-compat flag. # Adding the 'sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty case $build_os in mingw*) lt_bad_file=conftest.nm/nofile ;; *) lt_bad_file=/dev/null ;; esac case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in *$lt_bad_file* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break 2 ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break 2 ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS=$lt_save_ifs done : ${lt_cv_path_NM=no} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 $as_echo "$lt_cv_path_NM" >&6; } if test no != "$lt_cv_path_NM"; then NM=$lt_cv_path_NM else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else if test -n "$ac_tool_prefix"; then for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DUMPBIN=$ac_cv_prog_DUMPBIN if test -n "$DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 $as_echo "$DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$DUMPBIN" && break done fi if test -z "$DUMPBIN"; then ac_ct_DUMPBIN=$DUMPBIN for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DUMPBIN"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN if test -n "$ac_ct_DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 $as_echo "$ac_ct_DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_DUMPBIN" && break done if test "x$ac_ct_DUMPBIN" = x; then DUMPBIN=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DUMPBIN=$ac_ct_DUMPBIN fi fi case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols -headers" ;; *) DUMPBIN=: ;; esac fi if test : != "$DUMPBIN"; then NM=$DUMPBIN fi fi test -z "$NM" && NM=nm { $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 $as_echo_n "checking the name lister ($NM) interface... " >&6; } if ${lt_cv_nm_interface+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 $as_echo "$lt_cv_nm_interface" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 $as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 $as_echo "no, using $LN_S" >&6; } fi # find the maximum length of command line arguments { $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 $as_echo_n "checking the maximum length of command line arguments... " >&6; } if ${lt_cv_sys_max_cmd_len+:} false; then : $as_echo_n "(cached) " >&6 else i=0 teststring=ABCD case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len" && \ test undefined != "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test X`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test 17 != "$i" # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac fi if test -n "$lt_cv_sys_max_cmd_len"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 $as_echo "$lt_cv_sys_max_cmd_len" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 $as_echo "none" >&6; } fi max_cmd_len=$lt_cv_sys_max_cmd_len : ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 $as_echo_n "checking how to convert $build file names to $host format... " >&6; } if ${lt_cv_to_host_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac fi to_host_file_cmd=$lt_cv_to_host_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 $as_echo "$lt_cv_to_host_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 $as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } if ${lt_cv_to_tool_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else #assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac fi to_tool_file_cmd=$lt_cv_to_tool_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 $as_echo "$lt_cv_to_tool_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 $as_echo_n "checking for $LD option to reload object files... " >&6; } if ${lt_cv_ld_reload_flag+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_reload_flag='-r' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 $as_echo "$lt_cv_ld_reload_flag" >&6; } reload_flag=$lt_cv_ld_reload_flag case $reload_flag in "" | " "*) ;; *) reload_flag=" $reload_flag" ;; esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in cygwin* | mingw* | pw32* | cegcc*) if test yes != "$GCC"; then reload_cmds=false fi ;; darwin*) if test yes = "$GCC"; then reload_cmds='$LTCC $LTCFLAGS -nostdlib $wl-r -o $output$reload_objs' else reload_cmds='$LD$reload_flag -o $output$reload_objs' fi ;; esac if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 $as_echo "$OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 $as_echo "$ac_ct_OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then OBJDUMP="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP fi else OBJDUMP="$ac_cv_prog_OBJDUMP" fi test -z "$OBJDUMP" && OBJDUMP=objdump { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 $as_echo_n "checking how to recognize dependent libraries... " >&6; } if ${lt_cv_deplibs_check_method+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # 'unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # that responds to the $file_magic_cmd with a given extended regex. # If you have 'file' or equivalent on your system and you're not sure # whether 'pass_all' will *always* work, you probably want this one. case $host_os in aix[4-9]*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi[45]*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin*) # func_win32_libid is a shell function defined in ltmain.sh lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' ;; mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. if ( file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[3-9]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) lt_cv_deplibs_check_method=pass_all ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd* | bitrig*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; os2*) lt_cv_deplibs_check_method=pass_all ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 $as_echo "$lt_cv_deplibs_check_method" >&6; } file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 $as_echo "$DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 $as_echo "$ac_ct_DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then DLLTOOL="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL fi else DLLTOOL="$ac_cv_prog_DLLTOOL" fi test -z "$DLLTOOL" && DLLTOOL=dlltool { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 $as_echo_n "checking how to associate runtime and link libraries... " >&6; } if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh; # decide which one to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd=$ECHO ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 $as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO if test -n "$ac_tool_prefix"; then for ac_prog in ar do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AR="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AR" && break done fi if test -z "$AR"; then ac_ct_AR=$AR for ac_prog in ar do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_AR" && break done if test "x$ac_ct_AR" = x; then AR="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi fi : ${AR=ar} : ${AR_FLAGS=cru} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 $as_echo_n "checking for archiver @FILE support... " >&6; } if ${lt_cv_ar_at_file+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ar_at_file=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test 0 -eq "$ac_status"; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test 0 -ne "$ac_status"; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 $as_echo "$lt_cv_ar_at_file" >&6; } if test no = "$lt_cv_ar_at_file"; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi test -z "$STRIP" && STRIP=: if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi test -z "$RANLIB" && RANLIB=: # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in bitrig* | openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Check for command to grab the raw symbol name followed by C symbol from nm. { $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 $as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } if ${lt_cv_sys_global_symbol_pipe+:} false; then : $as_echo_n "(cached) " >&6 else # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[BCDEGRST]' # Regexp to match symbols that can be accessed directly from C. sympat='\([_A-Za-z][_A-Za-z0-9]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[BCDT]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[ABCDGISTW]' ;; hpux*) if test ia64 = "$host_cpu"; then symcode='[ABCDEGRST]' fi ;; irix* | nonstopux*) symcode='[BCDEGRST]' ;; osf*) symcode='[BCDEGQRST]' ;; solaris*) symcode='[BDRT]' ;; sco3.2v5*) symcode='[DT]' ;; sysv4.2uw2*) symcode='[DT]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[ABDT]' ;; sysv4) symcode='[DFNSTU]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[ABCDGIRSTW]' ;; esac if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Gets list of data symbols to import. lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'" # Adjust the below global symbol transforms to fixup imported variables. lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" lt_c_name_lib_hook="\ -e 's/^I .* \(lib.*\)$/ {\"\1\", (void *) 0},/p'\ -e 's/^I .* \(.*\)$/ {\"lib\1\", (void *) 0},/p'" else # Disable hooks by default. lt_cv_sys_global_symbol_to_import= lt_cdecl_hook= lt_c_name_hook= lt_c_name_lib_hook= fi # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n"\ $lt_cdecl_hook\ " -e 's/^T .* \(.*\)$/extern int \1();/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n"\ $lt_c_name_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" # Transform an extracted symbol line into symbol name with lib prefix and # symbol address. lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\ $lt_c_name_lib_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"lib\1\", (void *) \&\1},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function, # D for any global variable and I for any imported variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\ " /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\ " /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\ " {split(\$ 0,a,/\||\r/); split(a[2],s)};"\ " s[1]~/^[@?]/{print f,s[1],s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm $ECHO "$as_me:$LINENO: $NM conftest.$ac_objext | $lt_cv_sys_global_symbol_pipe > $nlist" >&5 if eval "$NM" conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist 2>&5 && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE /* DATA imports from DLLs on WIN32 can't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined __osf__ /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS=conftstm.$ac_objext CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest$ac_exeext; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&5 fi else echo "cannot find nm_test_var in $nlist" >&5 fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 fi else echo "$progname: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test yes = "$pipe_works"; then break else lt_cv_sys_global_symbol_pipe= fi done fi if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 $as_echo "failed" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then nm_file_list_spec='@' fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 $as_echo_n "checking for sysroot... " >&6; } # Check whether --with-sysroot was given. if test "${with_sysroot+set}" = set; then : withval=$with_sysroot; else with_sysroot=no fi lt_sysroot= case $with_sysroot in #( yes) if test yes = "$GCC"; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_sysroot" >&5 $as_echo "$with_sysroot" >&6; } as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 $as_echo "${lt_sysroot:-no}" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a working dd" >&5 $as_echo_n "checking for a working dd... " >&6; } if ${ac_cv_path_lt_DD+:} false; then : $as_echo_n "(cached) " >&6 else printf 0123456789abcdef0123456789abcdef >conftest.i cat conftest.i conftest.i >conftest2.i : ${lt_DD:=$DD} if test -z "$lt_DD"; then ac_path_lt_DD_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in dd; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_lt_DD="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_lt_DD" || continue if "$ac_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then cmp -s conftest.i conftest.out \ && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=: fi $ac_path_lt_DD_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_lt_DD"; then : fi else ac_cv_path_lt_DD=$lt_DD fi rm -f conftest.i conftest2.i conftest.out fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_lt_DD" >&5 $as_echo "$ac_cv_path_lt_DD" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to truncate binary pipes" >&5 $as_echo_n "checking how to truncate binary pipes... " >&6; } if ${lt_cv_truncate_bin+:} false; then : $as_echo_n "(cached) " >&6 else printf 0123456789abcdef0123456789abcdef >conftest.i cat conftest.i conftest.i >conftest2.i lt_cv_truncate_bin= if "$ac_cv_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then cmp -s conftest.i conftest.out \ && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1" fi rm -f conftest.i conftest2.i conftest.out test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_truncate_bin" >&5 $as_echo "$lt_cv_truncate_bin" >&6; } # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. func_cc_basename () { for cc_temp in $*""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` } # Check whether --enable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then : enableval=$enable_libtool_lock; fi test no = "$enable_libtool_lock" || enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out what ABI is being produced by ac_compile, and set mode # options accordingly. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE=32 ;; *ELF-64*) HPUX_IA64_MODE=64 ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then if test yes = "$lt_cv_prog_gnu_ld"; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; mips64*-*linux*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then emul=elf case `/usr/bin/file conftest.$ac_objext` in *32-bit*) emul="${emul}32" ;; *64-bit*) emul="${emul}64" ;; esac case `/usr/bin/file conftest.$ac_objext` in *MSB*) emul="${emul}btsmip" ;; *LSB*) emul="${emul}ltsmip" ;; esac case `/usr/bin/file conftest.$ac_objext` in *N32*) emul="${emul}n32" ;; esac LD="${LD-ld} -m $emul" fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. Note that the listed cases only cover the # situations where additional linker options are needed (such as when # doing 32-bit compilation for a host where ld defaults to 64-bit, or # vice versa); the common cases where no linker options are needed do # not appear in the list. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) case `/usr/bin/file conftest.o` in *x86-64*) LD="${LD-ld} -m elf32_x86_64" ;; *) LD="${LD-ld} -m elf_i386" ;; esac ;; powerpc64le-*linux*) LD="${LD-ld} -m elf32lppclinux" ;; powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; powerpcle-*linux*) LD="${LD-ld} -m elf64lppc" ;; powerpc-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS=$CFLAGS CFLAGS="$CFLAGS -belf" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 $as_echo_n "checking whether the C compiler needs -belf... " >&6; } if ${lt_cv_cc_needs_belf+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_cc_needs_belf=yes else lt_cv_cc_needs_belf=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 $as_echo "$lt_cv_cc_needs_belf" >&6; } if test yes != "$lt_cv_cc_needs_belf"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS=$SAVE_CFLAGS fi ;; *-*solaris*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*|x86_64-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD=${LD-ld}_sol2 fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks=$enable_libtool_lock if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. set dummy ${ac_tool_prefix}mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$MANIFEST_TOOL"; then ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL if test -n "$MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 $as_echo "$MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_MANIFEST_TOOL"; then ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL # Extract the first word of "mt", so it can be a program name with args. set dummy mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_MANIFEST_TOOL"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL if test -n "$ac_ct_MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 $as_echo "$ac_ct_MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_MANIFEST_TOOL" = x; then MANIFEST_TOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL fi else MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" fi test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 $as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } if ${lt_cv_path_mainfest_tool+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&5 if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 $as_echo "$lt_cv_path_mainfest_tool" >&6; } if test yes != "$lt_cv_path_mainfest_tool"; then MANIFEST_TOOL=: fi case $host_os in rhapsody* | darwin*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DSYMUTIL"; then ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DSYMUTIL=$ac_cv_prog_DSYMUTIL if test -n "$DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 $as_echo "$DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DSYMUTIL"; then ac_ct_DSYMUTIL=$DSYMUTIL # Extract the first word of "dsymutil", so it can be a program name with args. set dummy dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DSYMUTIL"; then ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL if test -n "$ac_ct_DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 $as_echo "$ac_ct_DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DSYMUTIL" = x; then DSYMUTIL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DSYMUTIL=$ac_ct_DSYMUTIL fi else DSYMUTIL="$ac_cv_prog_DSYMUTIL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. set dummy ${ac_tool_prefix}nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NMEDIT"; then ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi NMEDIT=$ac_cv_prog_NMEDIT if test -n "$NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 $as_echo "$NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_NMEDIT"; then ac_ct_NMEDIT=$NMEDIT # Extract the first word of "nmedit", so it can be a program name with args. set dummy nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NMEDIT"; then ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_NMEDIT="nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT if test -n "$ac_ct_NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 $as_echo "$ac_ct_NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_NMEDIT" = x; then NMEDIT=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac NMEDIT=$ac_ct_NMEDIT fi else NMEDIT="$ac_cv_prog_NMEDIT" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. set dummy ${ac_tool_prefix}lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$LIPO"; then ac_cv_prog_LIPO="$LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LIPO=$ac_cv_prog_LIPO if test -n "$LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 $as_echo "$LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_LIPO"; then ac_ct_LIPO=$LIPO # Extract the first word of "lipo", so it can be a program name with args. set dummy lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_LIPO"; then ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_LIPO="lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO if test -n "$ac_ct_LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 $as_echo "$ac_ct_LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_LIPO" = x; then LIPO=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac LIPO=$ac_ct_LIPO fi else LIPO="$ac_cv_prog_LIPO" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. set dummy ${ac_tool_prefix}otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL"; then ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL=$ac_cv_prog_OTOOL if test -n "$OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 $as_echo "$OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL"; then ac_ct_OTOOL=$OTOOL # Extract the first word of "otool", so it can be a program name with args. set dummy otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL"; then ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL="otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL if test -n "$ac_ct_OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 $as_echo "$ac_ct_OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL" = x; then OTOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL=$ac_ct_OTOOL fi else OTOOL="$ac_cv_prog_OTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. set dummy ${ac_tool_prefix}otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL64"; then ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL64=$ac_cv_prog_OTOOL64 if test -n "$OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 $as_echo "$OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL64"; then ac_ct_OTOOL64=$OTOOL64 # Extract the first word of "otool64", so it can be a program name with args. set dummy otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL64"; then ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL64="otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 if test -n "$ac_ct_OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 $as_echo "$ac_ct_OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL64" = x; then OTOOL64=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL64=$ac_ct_OTOOL64 fi else OTOOL64="$ac_cv_prog_OTOOL64" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 $as_echo_n "checking for -single_module linker flag... " >&6; } if ${lt_cv_apple_cc_single_mod+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_apple_cc_single_mod=no if test -z "$LT_MULTI_MODULE"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&5 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&5 # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test 0 = "$_lt_result"; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&5 fi rm -rf libconftest.dylib* rm -f conftest.* fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 $as_echo "$lt_cv_apple_cc_single_mod" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } if ${lt_cv_ld_exported_symbols_list+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_ld_exported_symbols_list=yes else lt_cv_ld_exported_symbols_list=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 $as_echo "$lt_cv_ld_exported_symbols_list" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 $as_echo_n "checking for -force_load linker flag... " >&6; } if ${lt_cv_ld_force_load+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 echo "$AR cru libconftest.a conftest.o" >&5 $AR cru libconftest.a conftest.o 2>&5 echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&5 elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then lt_cv_ld_force_load=yes else cat conftest.err >&5 fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 $as_echo "$lt_cv_ld_force_load" >&6; } case $host_os in rhapsody* | darwin1.[012]) _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[91]*) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; 10.[012][,.]*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test yes = "$lt_cv_apple_cc_single_mod"; then _lt_dar_single_mod='$single_module' fi if test yes = "$lt_cv_ld_exported_symbols_list"; then _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib' fi if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac # func_munge_path_list VARIABLE PATH # ----------------------------------- # VARIABLE is name of variable containing _space_ separated list of # directories to be munged by the contents of PATH, which is string # having a format: # "DIR[:DIR]:" # string "DIR[ DIR]" will be prepended to VARIABLE # ":DIR[:DIR]" # string "DIR[ DIR]" will be appended to VARIABLE # "DIRP[:DIRP]::[DIRA:]DIRA" # string "DIRP[ DIRP]" will be prepended to VARIABLE and string # "DIRA[ DIRA]" will be appended to VARIABLE # "DIR[:DIR]" # VARIABLE will be replaced by "DIR[ DIR]" func_munge_path_list () { case x$2 in x) ;; *:) eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\" ;; x:*) eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\" ;; *::*) eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\" ;; *) eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\" ;; esac } ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in dlfcn.h do : ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default " if test "x$ac_cv_header_dlfcn_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLFCN_H 1 _ACEOF fi done # Set options enable_dlopen=no enable_win32_dll=no # Check whether --enable-shared was given. if test "${enable_shared+set}" = set; then : enableval=$enable_shared; p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS=$lt_save_ifs ;; esac else enable_shared=yes fi # Check whether --enable-static was given. if test "${enable_static+set}" = set; then : enableval=$enable_static; p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS=$lt_save_ifs ;; esac else enable_static=yes fi # Check whether --with-pic was given. if test "${with_pic+set}" = set; then : withval=$with_pic; lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for lt_pkg in $withval; do IFS=$lt_save_ifs if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS=$lt_save_ifs ;; esac else pic_mode=default fi # Check whether --enable-fast-install was given. if test "${enable_fast_install+set}" = set; then : enableval=$enable_fast_install; p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS=$lt_save_ifs ;; esac else enable_fast_install=yes fi shared_archive_member_spec= case $host,$enable_shared in power*-*-aix[5-9]*,yes) { $as_echo "$as_me:${as_lineno-$LINENO}: checking which variant of shared library versioning to provide" >&5 $as_echo_n "checking which variant of shared library versioning to provide... " >&6; } # Check whether --with-aix-soname was given. if test "${with_aix_soname+set}" = set; then : withval=$with_aix_soname; case $withval in aix|svr4|both) ;; *) as_fn_error $? "Unknown argument to --with-aix-soname" "$LINENO" 5 ;; esac lt_cv_with_aix_soname=$with_aix_soname else if ${lt_cv_with_aix_soname+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_with_aix_soname=aix fi with_aix_soname=$lt_cv_with_aix_soname fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_aix_soname" >&5 $as_echo "$with_aix_soname" >&6; } if test aix != "$with_aix_soname"; then # For the AIX way of multilib, we name the shared archive member # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o', # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File. # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag, # the AIX toolchain works better with OBJECT_MODE set (default 32). if test 64 = "${OBJECT_MODE-32}"; then shared_archive_member_spec=shr_64 else shared_archive_member_spec=shr fi fi ;; *) with_aix_soname=aix ;; esac # This can be used to rebuild libtool when needed LIBTOOL_DEPS=$ltmain # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' test -z "$LN_S" && LN_S="ln -s" if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 $as_echo_n "checking for objdir... " >&6; } if ${lt_cv_objdir+:} false; then : $as_echo_n "(cached) " >&6 else rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 $as_echo "$lt_cv_objdir" >&6; } objdir=$lt_cv_objdir cat >>confdefs.h <<_ACEOF #define LT_OBJDIR "$lt_cv_objdir/" _ACEOF case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a '.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld=$lt_cv_prog_gnu_ld old_CC=$CC old_CFLAGS=$CFLAGS # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o func_cc_basename $compiler cc_basename=$func_cc_basename_result # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 $as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD=$MAGIC_CMD lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/${ac_tool_prefix}file"; then lt_cv_path_MAGIC_CMD=$ac_dir/"${ac_tool_prefix}file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD=$lt_cv_path_MAGIC_CMD if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS=$lt_save_ifs MAGIC_CMD=$lt_save_MAGIC_CMD ;; esac fi MAGIC_CMD=$lt_cv_path_MAGIC_CMD if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 $as_echo_n "checking for file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD=$MAGIC_CMD lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/file"; then lt_cv_path_MAGIC_CMD=$ac_dir/"file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD=$lt_cv_path_MAGIC_CMD if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS=$lt_save_ifs MAGIC_CMD=$lt_save_MAGIC_CMD ;; esac fi MAGIC_CMD=$lt_cv_path_MAGIC_CMD if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi else MAGIC_CMD=: fi fi fi ;; esac # Use C for the default configuration in the libtool script lt_save_CC=$CC ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o objext=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then lt_prog_compiler_no_builtin_flag= if test yes = "$GCC"; then case $cc_basename in nvcc*) lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; *) lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 $as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-fno-rtti -fno-exceptions" ## exclude from sc_useless_quotes_in_assignment # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_rtti_exceptions=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } if test yes = "$lt_cv_prog_compiler_rtti_exceptions"; then lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" else : fi fi lt_prog_compiler_wl= lt_prog_compiler_pic= lt_prog_compiler_static= if test yes = "$GCC"; then lt_prog_compiler_wl='-Wl,' lt_prog_compiler_static='-static' case $host_os in aix*) # All AIX code is PIC. if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' fi lt_prog_compiler_pic='-fPIC' ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the '-m68020' flag to GCC prevents building anything better, # like '-m68040'. lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic='-DDLL_EXPORT' case $host_os in os2*) lt_prog_compiler_static='$wl-static' ;; esac ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. lt_prog_compiler_static= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) lt_prog_compiler_pic='-fPIC' ;; esac ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. lt_prog_compiler_can_build_shared=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic=-Kconform_pic fi ;; *) lt_prog_compiler_pic='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 lt_prog_compiler_wl='-Xlinker ' if test -n "$lt_prog_compiler_pic"; then lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) lt_prog_compiler_wl='-Wl,' if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' else lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' fi ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' case $cc_basename in nagfor*) # NAG Fortran compiler lt_prog_compiler_wl='-Wl,-Wl,,' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; esac ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic='-DDLL_EXPORT' case $host_os in os2*) lt_prog_compiler_static='$wl-static' ;; esac ;; hpux9* | hpux10* | hpux11*) lt_prog_compiler_wl='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? lt_prog_compiler_static='$wl-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) lt_prog_compiler_wl='-Wl,' # PIC (with -KPIC) is the default. lt_prog_compiler_static='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in # old Intel for x86_64, which still supported -KPIC. ecc*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; # Lahey Fortran 8.1. lf95*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='--shared' lt_prog_compiler_static='--static' ;; nagfor*) # NAG Fortran compiler lt_prog_compiler_wl='-Wl,-Wl,,' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; tcc*) # Fabrice Bellard et al's Tiny C Compiler lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; ccc*) lt_prog_compiler_wl='-Wl,' # All Alpha code is PIC. lt_prog_compiler_static='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-qpic' lt_prog_compiler_static='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='' ;; *Sun\ F* | *Sun*Fortran*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; *Intel*\ [CF]*Compiler*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; *Portland\ Group*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; esac ;; esac ;; newsos6) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; osf3* | osf4* | osf5*) lt_prog_compiler_wl='-Wl,' # All OSF/1 code is PIC. lt_prog_compiler_static='-non_shared' ;; rdos*) lt_prog_compiler_static='-non_shared' ;; solaris*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) lt_prog_compiler_wl='-Qoption ld ';; *) lt_prog_compiler_wl='-Wl,';; esac ;; sunos4*) lt_prog_compiler_wl='-Qoption ld ' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic='-Kconform_pic' lt_prog_compiler_static='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; unicos*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_can_build_shared=no ;; uts4*) lt_prog_compiler_pic='-pic' lt_prog_compiler_static='-Bstatic' ;; *) lt_prog_compiler_can_build_shared=no ;; esac fi case $host_os in # For platforms that do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic= ;; *) lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 $as_echo_n "checking for $compiler option to produce PIC... " >&6; } if ${lt_cv_prog_compiler_pic+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic=$lt_prog_compiler_pic fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 $as_echo "$lt_cv_prog_compiler_pic" >&6; } lt_prog_compiler_pic=$lt_cv_prog_compiler_pic # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } if ${lt_cv_prog_compiler_pic_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic -DPIC" ## exclude from sc_useless_quotes_in_assignment # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; } if test yes = "$lt_cv_prog_compiler_pic_works"; then case $lt_prog_compiler_pic in "" | " "*) ;; *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; esac else lt_prog_compiler_pic= lt_prog_compiler_can_build_shared=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } if ${lt_cv_prog_compiler_static_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works=no save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works=yes fi else lt_cv_prog_compiler_static_works=yes fi fi $RM -r conftest* LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 $as_echo "$lt_cv_prog_compiler_static_works" >&6; } if test yes = "$lt_cv_prog_compiler_static_works"; then : else lt_prog_compiler_static= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } hard_links=nottested if test no = "$lt_cv_prog_compiler_c_o" && test no != "$need_locks"; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } if test no = "$hard_links"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5 $as_echo "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } runpath_var= allow_undefined_flag= always_export_symbols=no archive_cmds= archive_expsym_cmds= compiler_needs_object=no enable_shared_with_static_runtimes=no export_dynamic_flag_spec= export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' hardcode_automatic=no hardcode_direct=no hardcode_direct_absolute=no hardcode_libdir_flag_spec= hardcode_libdir_separator= hardcode_minus_L=no hardcode_shlibpath_var=unsupported inherit_rpath=no link_all_deplibs=unknown module_cmds= module_expsym_cmds= old_archive_from_new_cmds= old_archive_from_expsyms_cmds= thread_safe_flag_spec= whole_archive_flag_spec= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list include_expsyms= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ' (' and ')$', so one must not match beginning or # end of line. Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc', # as well as any symbol that contains 'd'. exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test yes != "$GCC"; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd* | bitrig*) with_gnu_ld=no ;; linux* | k*bsd*-gnu | gnu*) link_all_deplibs=no ;; esac ld_shlibs=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test yes = "$with_gnu_ld"; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; *\ \(GNU\ Binutils\)\ [3-9]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test yes = "$lt_use_gnu_ld_interface"; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='$wl' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' export_dynamic_flag_spec='$wl--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' else whole_archive_flag_spec= fi supports_anon_versioning=no case `$LD -v | $SED -e 's/(^)\+)\s\+//' 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[3-9]*) # On AIX/PPC, the GNU linker is very broken if test ia64 != "$host_cpu"; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' else ld_shlibs=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' export_dynamic_flag_spec='$wl--export-all-symbols' allow_undefined_flag=unsupported always_export_symbols=no enable_shared_with_static_runtimes=yes export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file, use it as # is; otherwise, prepend EXPORTS... archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs=no fi ;; haiku*) archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' link_all_deplibs=yes ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported shrext_cmds=.dll archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ prefix_cmds="$SED"~ if test EXPORTS = "`$SED 1q $export_symbols`"; then prefix_cmds="$prefix_cmds -e 1d"; fi~ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' enable_shared_with_static_runtimes=yes ;; interix[3-9]*) hardcode_direct=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='$wl-rpath,$libdir' export_dynamic_flag_spec='$wl-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test linux-dietlibc = "$host_os"; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test no = "$tmp_diet" then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 whole_archive_flag_spec= tmp_sharedflag='--shared' ;; nagfor*) # NAGFOR 5.3 tmp_sharedflag='-Wl,-shared' ;; xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' compiler_needs_object=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 whole_archive_flag_spec='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' compiler_needs_object=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' if test yes = "$supports_anon_versioning"; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi case $cc_basename in tcc*) export_dynamic_flag_spec='-rdynamic' ;; xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test yes = "$supports_anon_versioning"; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else ld_shlibs=no fi ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac ;; sunos4*) archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= hardcode_direct=yes hardcode_shlibpath_var=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac if test no = "$ld_shlibs"; then runpath_var= hardcode_libdir_flag_spec= export_dynamic_flag_spec= whole_archive_flag_spec= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) allow_undefined_flag=unsupported always_export_symbols=yes archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported fi ;; aix[4-9]*) if test ia64 = "$host_cpu"; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag= else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to GNU nm, but means don't demangle to AIX nm. # Without the "-l" option, or with the "-B" option, AIX nm treats # weak defined symbols like other global defined symbols, whereas # GNU nm marks them as "W". # While the 'weak' keyword is ignored in the Export File, we need # it in the Import File for the 'aix-soname' feature, so we have # to replace the "-B" option with "-P" for AIX nm. if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # have runtime linking enabled, and use it for executables. # For shared libraries, we enable/disable runtime linking # depending on the kind of the shared library created - # when "with_aix_soname,aix_use_runtimelinking" is: # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables # "aix,yes" lib.so shared, rtl:yes, for executables # lib.a static archive # "both,no" lib.so.V(shr.o) shared, rtl:yes # lib.a(lib.so.V) shared, rtl:no, for executables # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a(lib.so.V) shared, rtl:no # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a static archive case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then aix_use_runtimelinking=yes break fi done if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then # With aix-soname=svr4, we create the lib.so.V shared archives only, # so we don't have lib.a shared libs to link our executables. # We have to force runtime linking in this case. aix_use_runtimelinking=yes LDFLAGS="$LDFLAGS -Wl,-brtl" fi ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds='' hardcode_direct=yes hardcode_direct_absolute=yes hardcode_libdir_separator=':' link_all_deplibs=yes file_list_spec='$wl-f,' case $with_aix_soname,$aix_use_runtimelinking in aix,*) ;; # traditional, no import file svr4,* | *,yes) # use import file # The Import File defines what to hardcode. hardcode_direct=no hardcode_direct_absolute=no ;; esac if test yes = "$GCC"; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`$CC -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi ;; esac shared_flag='-shared' if test yes = "$aix_use_runtimelinking"; then shared_flag="$shared_flag "'$wl-G' fi # Need to ensure runtime linking is disabled for the traditional # shared library, or the linker may eventually find shared libraries # /with/ Import File - we do not want to mix them. shared_flag_aix='-shared' shared_flag_svr4='-shared $wl-G' else # not using gcc if test ia64 = "$host_cpu"; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test yes = "$aix_use_runtimelinking"; then shared_flag='$wl-G' else shared_flag='$wl-bM:SRE' fi shared_flag_aix='$wl-bM:SRE' shared_flag_svr4='$wl-G' fi fi export_dynamic_flag_spec='$wl-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. always_export_symbols=yes if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an # empty executable. if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=/usr/lib:/lib fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag else if test ia64 = "$host_cpu"; then hardcode_libdir_flag_spec='$wl-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=/usr/lib:/lib fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag=' $wl-bernotok' allow_undefined_flag=' $wl-berok' if test yes = "$with_gnu_ld"; then # We only use this code for GNU lds that support --whole-archive. whole_archive_flag_spec='$wl--whole-archive$convenience $wl--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec='$convenience' fi archive_cmds_need_lc=yes archive_expsym_cmds='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' # -brtl affects multiple linker settings, -berok does not and is overridden later compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([, ]\\)%-berok\\1%g"`' if test svr4 != "$with_aix_soname"; then # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' fi if test aix != "$with_aix_soname"; then archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' else # used by -dlpreopen to get the symbols archive_expsym_cmds="$archive_expsym_cmds"'~$MV $output_objdir/$realname.d/$soname $output_objdir' fi archive_expsym_cmds="$archive_expsym_cmds"'~$RM -r $output_objdir/$realname.d' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; bsdi[45]*) export_dynamic_flag_spec=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported always_export_symbols=yes file_list_spec='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then cp "$export_symbols" "$output_objdir/$soname.def"; echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; else $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, )='true' enable_shared_with_static_runtimes=yes exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib old_postinstall_cmds='chmod 644 $oldlib' postlink_cmds='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile=$lt_outputfile.exe lt_tool_outputfile=$lt_tool_outputfile.exe ;; esac~ if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. old_archive_from_new_cmds='true' # FIXME: Should let the user specify the lib program. old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' enable_shared_with_static_runtimes=yes ;; esac ;; darwin* | rhapsody*) archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported if test yes = "$lt_cv_ld_force_load"; then whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec='' fi link_all_deplibs=yes allow_undefined_flag=$_lt_dar_allow_undefined case $cc_basename in ifort*|nagfor*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test yes = "$_lt_dar_can_shared"; then output_verbose_link_cmd=func_echo_all archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" archive_expsym_cmds="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" module_expsym_cmds="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" else ld_shlibs=no fi ;; dgux*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; hpux9*) if test yes = "$GCC"; then archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' else archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' fi hardcode_libdir_flag_spec='$wl+b $wl$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes export_dynamic_flag_spec='$wl-E' ;; hpux10*) if test yes,no = "$GCC,$with_gnu_ld"; then archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test no = "$with_gnu_ld"; then hardcode_libdir_flag_spec='$wl+b $wl$libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes fi ;; hpux11*) if test yes,no = "$GCC,$with_gnu_ld"; then case $host_cpu in hppa*64*) archive_cmds='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) archive_cmds='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 $as_echo_n "checking if $CC understands -b... " >&6; } if ${lt_cv_prog_compiler__b+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler__b=no save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -b" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler__b=yes fi else lt_cv_prog_compiler__b=yes fi fi $RM -r conftest* LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 $as_echo "$lt_cv_prog_compiler__b" >&6; } if test yes = "$lt_cv_prog_compiler__b"; then archive_cmds='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi ;; esac fi if test no = "$with_gnu_ld"; then hardcode_libdir_flag_spec='$wl+b $wl$libdir' hardcode_libdir_separator=: case $host_cpu in hppa*64*|ia64*) hardcode_direct=no hardcode_shlibpath_var=no ;; *) hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test yes = "$GCC"; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 $as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } if ${lt_cv_irix_exported_symbol+:} false; then : $as_echo_n "(cached) " >&6 else save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int foo (void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_irix_exported_symbol=yes else lt_cv_irix_exported_symbol=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 $as_echo "$lt_cv_irix_exported_symbol" >&6; } if test yes = "$lt_cv_irix_exported_symbol"; then archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' fi link_all_deplibs=no else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' hardcode_libdir_separator=: inherit_rpath=yes link_all_deplibs=yes ;; linux*) case $cc_basename in tcc*) # Fabrice Bellard et al's Tiny C Compiler ld_shlibs=yes archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' hardcode_libdir_separator=: hardcode_shlibpath_var=no ;; *nto* | *qnx*) ;; openbsd* | bitrig*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes hardcode_shlibpath_var=no hardcode_direct_absolute=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols' hardcode_libdir_flag_spec='$wl-rpath,$libdir' export_dynamic_flag_spec='$wl-E' else archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='$wl-rpath,$libdir' fi else ld_shlibs=no fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported shrext_cmds=.dll archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ prefix_cmds="$SED"~ if test EXPORTS = "`$SED 1q $export_symbols`"; then prefix_cmds="$prefix_cmds -e 1d"; fi~ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' enable_shared_with_static_runtimes=yes ;; osf3*) if test yes = "$GCC"; then allow_undefined_flag=' $wl-expect_unresolved $wl\*' archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test yes = "$GCC"; then allow_undefined_flag=' $wl-expect_unresolved $wl\*' archive_cmds='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi archive_cmds_need_lc='no' hardcode_libdir_separator=: ;; solaris*) no_undefined_flag=' -z defs' if test yes = "$GCC"; then wlarc='$wl' archive_cmds='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' archive_cmds='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='$wl' archive_cmds='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi hardcode_libdir_flag_spec='-R$libdir' hardcode_shlibpath_var=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands '-z linker_flag'. GCC discards it without '$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test yes = "$GCC"; then whole_archive_flag_spec='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' else whole_archive_flag_spec='-z allextract$convenience -z defaultextract' fi ;; esac link_all_deplibs=yes ;; sunos4*) if test sequent = "$host_vendor"; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. archive_cmds='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; sysv4) case $host_vendor in sni) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' reload_cmds='$CC -r -o $output$reload_objs' hardcode_direct=no ;; motorola) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' hardcode_shlibpath_var=no ;; sysv4.3*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no export_dynamic_flag_spec='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes ld_shlibs=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag='$wl-z,text' archive_cmds_need_lc=no hardcode_shlibpath_var=no runpath_var='LD_RUN_PATH' if test yes = "$GCC"; then archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We CANNOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag='$wl-z,text' allow_undefined_flag='$wl-z,nodefs' archive_cmds_need_lc=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='$wl-R,$libdir' hardcode_libdir_separator=':' link_all_deplibs=yes export_dynamic_flag_spec='$wl-Bexport' runpath_var='LD_RUN_PATH' if test yes = "$GCC"; then archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; *) ld_shlibs=no ;; esac if test sni = "$host_vendor"; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) export_dynamic_flag_spec='$wl-Blargedynsym' ;; esac fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 $as_echo "$ld_shlibs" >&6; } test no = "$ld_shlibs" && can_build_shared=no with_gnu_ld=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc" in x|xyes) # Assume -lc should be added archive_cmds_need_lc=yes if test yes,yes = "$GCC,$enable_shared"; then case $archive_cmds in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } if ${lt_cv_archive_cmds_need_lc+:} false; then : $as_echo_n "(cached) " >&6 else $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl pic_flag=$lt_prog_compiler_pic compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag allow_undefined_flag= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc=no else lt_cv_archive_cmds_need_lc=yes fi allow_undefined_flag=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 $as_echo "$lt_cv_archive_cmds_need_lc" >&6; } archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc ;; esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } if test yes = "$GCC"; then case $host_os in darwin*) lt_awk_arg='/^libraries:/,/LR/' ;; *) lt_awk_arg='/^libraries:/' ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq='s|=\([A-Za-z]:\)|\1|g' ;; *) lt_sed_strip_eq='s|=/|/|g' ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary... lt_tmp_lt_search_path_spec= lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` # ...but if some path component already ends with the multilib dir we assume # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer). case "$lt_multi_os_dir; $lt_search_path_spec " in "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*) lt_multi_os_dir= ;; esac for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir" elif test -n "$lt_multi_os_dir"; then test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS = " "; FS = "/|\n";} { lt_foo = ""; lt_count = 0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo = "/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[lt_foo]++; } if (lt_freq[lt_foo] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's|/\([A-Za-z]:\)|\1|g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=.so postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='$libname$release$shared_ext$major' ;; aix[4-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test ia64 = "$host_cpu"; then # AIX 5 supports IA64 library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line '#! .'. This would cause the generated library to # depend on '.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # Using Import Files as archive members, it is possible to support # filename-based versioning of shared library archives on AIX. While # this would work for both with and without runtime linking, it will # prevent static linking of such archives. So we do filename-based # shared library versioning with .so extension only, which is used # when both runtime linking and shared linking is enabled. # Unfortunately, runtime linking may impact performance, so we do # not want this to be the default eventually. Also, we use the # versioned .so libs for executables only if there is the -brtl # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only. # To allow for filename-based versioning support, we need to create # libNAME.so.V as an archive file, containing: # *) an Import File, referring to the versioned filename of the # archive as well as the shared archive member, telling the # bitwidth (32 or 64) of that shared object, and providing the # list of exported symbols of that shared object, eventually # decorated with the 'weak' keyword # *) the shared object with the F_LOADONLY flag set, to really avoid # it being seen by the linker. # At run time we better use the real file rather than another symlink, # but for link time we create the symlink libNAME.so -> libNAME.so.V case $with_aix_soname,$aix_use_runtimelinking in # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. aix,yes) # traditional libtool dynamic_linker='AIX unversionable lib.so' # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; aix,no) # traditional AIX only dynamic_linker='AIX lib.a(lib.so.V)' # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='$libname$release.a $libname.a' soname_spec='$libname$release$shared_ext$major' ;; svr4,*) # full svr4 only dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o)" library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' # We do not specify a path in Import Files, so LIBPATH fires. shlibpath_overrides_runpath=yes ;; *,yes) # both, prefer svr4 dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o), lib.a(lib.so.V)" library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' # unpreferred sharedlib libNAME.a needs extra handling postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"' postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"' # We do not specify a path in Import Files, so LIBPATH fires. shlibpath_overrides_runpath=yes ;; *,no) # both, prefer aix dynamic_linker="AIX lib.a(lib.so.V), lib.so.V($shared_archive_member_spec.o)" library_names_spec='$libname$release.a $libname.a' soname_spec='$libname$release$shared_ext$major' # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)' postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"' ;; esac shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='$libname$shared_ext' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=.dll need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' library_names_spec='$libname.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec=$LIB if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' soname_spec='$libname$release$major$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[23].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=no sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' if test 32 = "$HPUX_IA64_MODE"; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" sys_lib_dlsearch_path_spec=/usr/lib/hpux32 else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" sys_lib_dlsearch_path_spec=/usr/lib/hpux64 fi ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[3-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test yes = "$lt_cv_prog_gnu_ld"; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='$libname$release$shared_ext$major' library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff" sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; linux*android*) version_type=none # Android doesn't support versioned libraries. need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext' soname_spec='$libname$release$shared_ext' finish_cmds= shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes dynamic_linker='Android linker' # Don't embed -rpath directories since the linker doesn't support them. hardcode_libdir_flag_spec='-L$libdir' ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH if ${lt_cv_shlibpath_overrides_runpath+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : lt_cv_shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir fi shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Ideally, we could use ldconfig to report *all* directores which are # searched for libraries, however this is still not possible. Aside from not # being certain /sbin/ldconfig is available, command # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64, # even though it is searched at run-time. Try to do the best guess by # appending ld.so.conf contents (and includes) to the search path. if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsdelf*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='NetBSD ld.elf_so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd* | bitrig*) version_type=sunos sys_lib_dlsearch_path_spec=/usr/lib need_lib_prefix=no if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then need_version=no else need_version=yes fi library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; os2*) libname_spec='$name' version_type=windows shrext_cmds=.dll need_version=no need_lib_prefix=no # OS/2 can only load a DLL with a base name of 8 characters or less. soname_spec='`test -n "$os2dllname" && libname="$os2dllname"; v=$($ECHO $release$versuffix | tr -d .-); n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _); $ECHO $n$v`$shared_ext' library_names_spec='${libname}_dll.$libext' dynamic_linker='OS/2 ld.exe' shlibpath_var=BEGINLIBPATH sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='$libname$release$shared_ext$major' library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test yes = "$with_gnu_ld"; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec; then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext' soname_spec='$libname$shared_ext.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=sco need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test yes = "$with_gnu_ld"; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } test no = "$dynamic_linker" && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test yes = "$GCC"; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec fi if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec fi # remember unaugmented sys_lib_dlsearch_path content for libtool script decls... configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec # ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH" # to be used as default LT_SYS_LIBRARY_PATH value in generated libtool configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action= if test -n "$hardcode_libdir_flag_spec" || test -n "$runpath_var" || test yes = "$hardcode_automatic"; then # We can hardcode non-existent directories. if test no != "$hardcode_direct" && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, )" && test no != "$hardcode_minus_L"; then # Linking always hardcodes the temporary library directory. hardcode_action=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action=unsupported fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 $as_echo "$hardcode_action" >&6; } if test relink = "$hardcode_action" || test yes = "$inherit_rpath"; then # Fast installation is not supported enable_fast_install=no elif test yes = "$shlibpath_overrides_runpath" || test no = "$enable_shared"; then # Fast installation is not necessary enable_fast_install=needless fi if test yes != "$enable_dlopen"; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen=load_add_on lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen=LoadLibrary lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen=dlopen lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl else lt_cv_dlopen=dyld lt_cv_dlopen_libs= lt_cv_dlopen_self=yes fi ;; tpf*) # Don't try to run any link tests for TPF. We know it's impossible # because TPF is a cross-compiler, and we know how we open DSOs. lt_cv_dlopen=dlopen lt_cv_dlopen_libs= lt_cv_dlopen_self=no ;; *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" if test "x$ac_cv_func_shl_load" = xyes; then : lt_cv_dlopen=shl_load else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 $as_echo_n "checking for shl_load in -ldld... " >&6; } if ${ac_cv_lib_dld_shl_load+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char shl_load (); int main () { return shl_load (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_shl_load=yes else ac_cv_lib_dld_shl_load=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 $as_echo "$ac_cv_lib_dld_shl_load" >&6; } if test "x$ac_cv_lib_dld_shl_load" = xyes; then : lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld else ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" if test "x$ac_cv_func_dlopen" = xyes; then : lt_cv_dlopen=dlopen else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 $as_echo_n "checking for dlopen in -lsvld... " >&6; } if ${ac_cv_lib_svld_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_svld_dlopen=yes else ac_cv_lib_svld_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 $as_echo "$ac_cv_lib_svld_dlopen" >&6; } if test "x$ac_cv_lib_svld_dlopen" = xyes; then : lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 $as_echo_n "checking for dld_link in -ldld... " >&6; } if ${ac_cv_lib_dld_dld_link+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dld_link (); int main () { return dld_link (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_dld_link=yes else ac_cv_lib_dld_dld_link=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 $as_echo "$ac_cv_lib_dld_dld_link" >&6; } if test "x$ac_cv_lib_dld_dld_link" = xyes; then : lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld fi fi fi fi fi fi ;; esac if test no = "$lt_cv_dlopen"; then enable_dlopen=no else enable_dlopen=yes fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS=$CPPFLAGS test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS=$LDFLAGS wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS=$LIBS LIBS="$lt_cv_dlopen_libs $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 $as_echo_n "checking whether a program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self+:} false; then : $as_echo_n "(cached) " >&6 else if test yes = "$cross_compiling"; then : lt_cv_dlopen_self=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisibility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; esac else : # compilation failed lt_cv_dlopen_self=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 $as_echo "$lt_cv_dlopen_self" >&6; } if test yes = "$lt_cv_dlopen_self"; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self_static+:} false; then : $as_echo_n "(cached) " >&6 else if test yes = "$cross_compiling"; then : lt_cv_dlopen_self_static=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisibility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; esac else : # compilation failed lt_cv_dlopen_self_static=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 $as_echo "$lt_cv_dlopen_self_static" >&6; } fi CPPFLAGS=$save_CPPFLAGS LDFLAGS=$save_LDFLAGS LIBS=$save_LIBS ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi striplib= old_striplib= { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 $as_echo_n "checking whether stripping libraries is possible... " >&6; } if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP"; then striplib="$STRIP -x" old_striplib="$STRIP -S" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ;; esac fi # Report what library types will actually be built { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 $as_echo_n "checking if libtool supports shared libraries... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 $as_echo "$can_build_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 $as_echo_n "checking whether to build shared libraries... " >&6; } test no = "$can_build_shared" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test yes = "$enable_shared" && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[4-9]*) if test ia64 != "$host_cpu"; then case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in yes,aix,yes) ;; # shared object as lib.so file only yes,svr4,*) ;; # shared object as lib.so archive member only yes,*) enable_static=no ;; # shared object in lib.a archive as well esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 $as_echo "$enable_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 $as_echo_n "checking whether to build static libraries... " >&6; } # Make sure either enable_shared or enable_static is yes. test yes = "$enable_shared" || enable_static=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 $as_echo "$enable_static" >&6; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC=$lt_save_CC ac_config_commands="$ac_config_commands libtool" # Only expand once: ac_fn_c_check_func "$LINENO" "gethostbyaddr_r" "ac_cv_func_gethostbyaddr_r" if test "x$ac_cv_func_gethostbyaddr_r" = xyes; then : $as_echo "#define HAS_GETHOSTBYADDR_R 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "gethostbyname_r" "ac_cv_func_gethostbyname_r" if test "x$ac_cv_func_gethostbyname_r" = xyes; then : $as_echo "#define HAS_GETHOSTBYNAME_R 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "poll" "ac_cv_func_poll" if test "x$ac_cv_func_poll" = xyes; then : $as_echo "#define HAS_POLL 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "fcntl" "ac_cv_func_fcntl" if test "x$ac_cv_func_fcntl" = xyes; then : $as_echo "#define HAS_FCNTL 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "inet_pton" "ac_cv_func_inet_pton" if test "x$ac_cv_func_inet_pton" = xyes; then : $as_echo "#define HAS_INET_PTON 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "inet_ntop" "ac_cv_func_inet_ntop" if test "x$ac_cv_func_inet_ntop" = xyes; then : $as_echo "#define HAS_INET_NTOP 1" >>confdefs.h fi ac_fn_c_check_member "$LINENO" "struct msghdr" "msg_flags" "ac_cv_member_struct_msghdr_msg_flags" "#include " if test "x$ac_cv_member_struct_msghdr_msg_flags" = xyes; then : $as_echo "#define HAS_MSGHDR_FLAGS 1" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" "#include #include " if test "x$ac_cv_type_socklen_t" = xyes; then : $as_echo "#define HAS_SOCKLEN_T 1" >>confdefs.h fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "MSG_MAXIOVLEN" >/dev/null 2>&1; then : $as_echo "#define ENET_BUFFER_MAXIMUM MSG_MAXIOVLEN" >>confdefs.h fi rm -f conftest* cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "MSG_MAXIOVLEN" >/dev/null 2>&1; then : $as_echo "#define ENET_BUFFER_MAXIMUM MSG_MAXIOVLEN" >>confdefs.h fi rm -f conftest* ac_config_files="$ac_config_files Makefile libenet.pc" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # Transform confdefs.h into DEFS. # Protect against shell expansion while executing Makefile rules. # Protect against Makefile macro expansion. # # If the first sed substitution is executed (which looks for macros that # take arguments), then branch to the quote section. Otherwise, # look for a macro that doesn't take arguments. ac_script=' :mline /\\$/{ N s,\\\n,, b mline } t clear :clear s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g t quote s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g t quote b any :quote s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g s/\[/\\&/g s/\]/\\&/g s/\$/$$/g H :any ${ g s/^\n// s/\n/ /g p } ' DEFS=`sed -n "$ac_script" confdefs.h` ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs { $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 $as_echo_n "checking that generated files are newer than configure... " >&6; } if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 $as_echo "done" >&6; } if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by libenet $as_me 1.3.6, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE Configuration files: $config_files Configuration commands: $config_commands Report bugs to the package provider." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ libenet config.status 1.3.6 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --he | --h | --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' shared_archive_member_spec='`$ECHO "$shared_archive_member_spec" | $SED "$delay_single_quote_subst"`' SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_import='`$ECHO "$lt_cv_sys_global_symbol_to_import" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' lt_cv_nm_interface='`$ECHO "$lt_cv_nm_interface" | $SED "$delay_single_quote_subst"`' nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' lt_cv_truncate_bin='`$ECHO "$lt_cv_truncate_bin" | $SED "$delay_single_quote_subst"`' objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' configure_time_dlsearch_path='`$ECHO "$configure_time_dlsearch_path" | $SED "$delay_single_quote_subst"`' configure_time_lt_sys_library_path='`$ECHO "$configure_time_lt_sys_library_path" | $SED "$delay_single_quote_subst"`' hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } # Quote evaled strings. for var in SHELL \ ECHO \ PATH_SEPARATOR \ SED \ GREP \ EGREP \ FGREP \ LD \ NM \ LN_S \ lt_SP2NL \ lt_NL2SP \ reload_flag \ OBJDUMP \ deplibs_check_method \ file_magic_cmd \ file_magic_glob \ want_nocaseglob \ DLLTOOL \ sharedlib_from_linklib_cmd \ AR \ AR_FLAGS \ archiver_list_spec \ STRIP \ RANLIB \ CC \ CFLAGS \ compiler \ lt_cv_sys_global_symbol_pipe \ lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_import \ lt_cv_sys_global_symbol_to_c_name_address \ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ lt_cv_nm_interface \ nm_file_list_spec \ lt_cv_truncate_bin \ lt_prog_compiler_no_builtin_flag \ lt_prog_compiler_pic \ lt_prog_compiler_wl \ lt_prog_compiler_static \ lt_cv_prog_compiler_c_o \ need_locks \ MANIFEST_TOOL \ DSYMUTIL \ NMEDIT \ LIPO \ OTOOL \ OTOOL64 \ shrext_cmds \ export_dynamic_flag_spec \ whole_archive_flag_spec \ compiler_needs_object \ with_gnu_ld \ allow_undefined_flag \ no_undefined_flag \ hardcode_libdir_flag_spec \ hardcode_libdir_separator \ exclude_expsyms \ include_expsyms \ file_list_spec \ variables_saved_for_relink \ libname_spec \ library_names_spec \ soname_spec \ install_override_mode \ finish_eval \ old_striplib \ striplib; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in reload_cmds \ old_postinstall_cmds \ old_postuninstall_cmds \ old_archive_cmds \ extract_expsyms_cmds \ old_archive_from_new_cmds \ old_archive_from_expsyms_cmds \ archive_cmds \ archive_expsym_cmds \ module_cmds \ module_expsym_cmds \ export_symbols_cmds \ prelink_cmds \ postlink_cmds \ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ configure_time_dlsearch_path \ configure_time_lt_sys_library_path; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done ac_aux_dir='$ac_aux_dir' # See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi PACKAGE='$PACKAGE' VERSION='$VERSION' RM='$RM' ofile='$ofile' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "libenet.pc") CONFIG_FILES="$CONFIG_FILES libenet.pc" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" eval set X " :F $CONFIG_FILES :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. # TODO: see whether this extra hack can be removed once we start # requiring Autoconf 2.70 or later. case $CONFIG_FILES in #( *\'*) : eval set x "$CONFIG_FILES" ;; #( *) : set x $CONFIG_FILES ;; #( *) : ;; esac shift # Used to flag and report bootstrapping failures. am_rc=0 for am_mf do # Strip MF so we end up with the name of the file. am_mf=`$as_echo "$am_mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile which includes # dependency-tracking related rules and includes. # Grep'ing the whole file directly is not great: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ || continue am_dirpart=`$as_dirname -- "$am_mf" || $as_expr X"$am_mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$am_mf" : 'X\(//\)[^/]' \| \ X"$am_mf" : 'X\(//\)$' \| \ X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$am_mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` am_filepart=`$as_basename -- "$am_mf" || $as_expr X/"$am_mf" : '.*/\([^/][^/]*\)/*$' \| \ X"$am_mf" : 'X\(//\)$' \| \ X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$am_mf" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` { echo "$as_me:$LINENO: cd "$am_dirpart" \ && sed -e '/# am--include-marker/d' "$am_filepart" \ | $MAKE -f - am--depfiles" >&5 (cd "$am_dirpart" \ && sed -e '/# am--include-marker/d' "$am_filepart" \ | $MAKE -f - am--depfiles) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } || am_rc=$? done if test $am_rc -ne 0; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "Something went wrong bootstrapping makefile fragments for automatic dependency tracking. Try re-running configure with the '--disable-dependency-tracking' option to at least be able to build the package (albeit without support for automatic dependency tracking). See \`config.log' for more details" "$LINENO" 5; } fi { am_dirpart=; unset am_dirpart;} { am_filepart=; unset am_filepart;} { am_mf=; unset am_mf;} { am_rc=; unset am_rc;} rm -f conftest-deps.mk } ;; "libtool":C) # See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi cfgfile=${ofile}T trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # Generated automatically by $as_me ($PACKAGE) $VERSION # NOTE: Changes made to this file will be lost: look at ltmain.sh. # Provide generalized library-building support services. # Written by Gordon Matzigkeit, 1996 # Copyright (C) 2014 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of of the License, or # (at your option) any later version. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program or library that is built # using GNU Libtool, you may include this file under the same # distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # The names of the tagged configurations supported by this script. available_tags='' # Configured defaults for sys_lib_dlsearch_path munging. : \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"} # ### BEGIN LIBTOOL CONFIG # Which release of libtool.m4 was used? macro_version=$macro_version macro_revision=$macro_revision # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # Whether or not to build static libraries. build_old_libs=$enable_static # What type of objects to build. pic_mode=$pic_mode # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # Shared archive member basename,for filename based shared library versioning on AIX. shared_archive_member_spec=$shared_archive_member_spec # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # An echo program that protects backslashes. ECHO=$lt_ECHO # The PATH separator for the build system. PATH_SEPARATOR=$lt_PATH_SEPARATOR # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # A sed program that does not truncate output. SED=$lt_SED # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="\$SED -e 1s/^X//" # A grep program that handles long lines. GREP=$lt_GREP # An ERE matcher. EGREP=$lt_EGREP # A literal string matcher. FGREP=$lt_FGREP # A BSD- or MS-compatible name lister. NM=$lt_NM # Whether we need soft or hard links. LN_S=$lt_LN_S # What is the maximum length of a command? max_cmd_len=$max_cmd_len # Object file suffix (normally "o"). objext=$ac_objext # Executable file suffix (normally ""). exeext=$exeext # whether the shell understands "unset". lt_unset=$lt_unset # turn spaces into newlines. SP2NL=$lt_lt_SP2NL # turn newlines into spaces. NL2SP=$lt_lt_NL2SP # convert \$build file names to \$host format. to_host_file_cmd=$lt_cv_to_host_file_cmd # convert \$build files to toolchain format. to_tool_file_cmd=$lt_cv_to_tool_file_cmd # An object symbol dumper. OBJDUMP=$lt_OBJDUMP # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method = "file_magic". file_magic_cmd=$lt_file_magic_cmd # How to find potential files when deplibs_check_method = "file_magic". file_magic_glob=$lt_file_magic_glob # Find potential files using nocaseglob when deplibs_check_method = "file_magic". want_nocaseglob=$lt_want_nocaseglob # DLL creation program. DLLTOOL=$lt_DLLTOOL # Command to associate shared and link libraries. sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd # The archiver. AR=$lt_AR # Flags to create an archive. AR_FLAGS=$lt_AR_FLAGS # How to feed a file listing to the archiver. archiver_list_spec=$lt_archiver_list_spec # A symbol stripping program. STRIP=$lt_STRIP # Commands used to install an old-style archive. RANLIB=$lt_RANLIB old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Whether to use a lock for old archive extraction. lock_old_archive_extraction=$lock_old_archive_extraction # A C compiler. LTCC=$lt_CC # LTCC compiler flags. LTCFLAGS=$lt_CFLAGS # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration. global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm into a list of symbols to manually relocate. global_symbol_to_import=$lt_lt_cv_sys_global_symbol_to_import # Transform the output of nm in a C name address pair. global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # Transform the output of nm in a C name address pair when lib prefix is needed. global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix # The name lister interface. nm_interface=$lt_lt_cv_nm_interface # Specify filename containing input files for \$NM. nm_file_list_spec=$lt_nm_file_list_spec # The root where to search for dependent libraries,and where our libraries should be installed. lt_sysroot=$lt_sysroot # Command to truncate a binary pipe. lt_truncate_bin=$lt_lt_cv_truncate_bin # The name of the directory that contains temporary libtool files. objdir=$objdir # Used to examine libraries when file_magic_cmd begins with "file". MAGIC_CMD=$MAGIC_CMD # Must we lock files when doing compilation? need_locks=$lt_need_locks # Manifest tool. MANIFEST_TOOL=$lt_MANIFEST_TOOL # Tool to manipulate archived DWARF debug symbol files on Mac OS X. DSYMUTIL=$lt_DSYMUTIL # Tool to change global to local symbols on Mac OS X. NMEDIT=$lt_NMEDIT # Tool to manipulate fat objects and archives on Mac OS X. LIPO=$lt_LIPO # ldd/readelf like tool for Mach-O binaries on Mac OS X. OTOOL=$lt_OTOOL # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. OTOOL64=$lt_OTOOL64 # Old archive suffix (normally "a"). libext=$libext # Shared library suffix (normally ".so"). shrext_cmds=$lt_shrext_cmds # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Variables whose values should be saved in libtool wrapper scripts and # restored at link time. variables_saved_for_relink=$lt_variables_saved_for_relink # Do we need the "lib" prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Library versioning type. version_type=$version_type # Shared library runtime path variable. runpath_var=$runpath_var # Shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Permission mode override for installation of shared libraries. install_override_mode=$lt_install_override_mode # Command to use after installation of a shared archive. postinstall_cmds=$lt_postinstall_cmds # Command to use after uninstallation of a shared archive. postuninstall_cmds=$lt_postuninstall_cmds # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # As "finish_cmds", except a single script fragment to be evaled but # not shown. finish_eval=$lt_finish_eval # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Compile-time system search path for libraries. sys_lib_search_path_spec=$lt_sys_lib_search_path_spec # Detected run-time system search path for libraries. sys_lib_dlsearch_path_spec=$lt_configure_time_dlsearch_path # Explicit LT_SYS_LIBRARY_PATH set during ./configure time. configure_time_lt_sys_library_path=$lt_configure_time_lt_sys_library_path # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # The linker used to build libraries. LD=$lt_LD # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds # A language specific compiler. CC=$lt_compiler # Is the compiler the GNU compiler? with_gcc=$GCC # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds archive_expsym_cmds=$lt_archive_expsym_cmds # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds module_expsym_cmds=$lt_module_expsym_cmds # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator # Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct # Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \$shlibpath_var if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms # Symbols that must always be exported. include_expsyms=$lt_include_expsyms # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds # Commands necessary for finishing linking programs. postlink_cmds=$lt_postlink_cmds # Specify filename containing input files. file_list_spec=$lt_file_list_spec # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action # ### END LIBTOOL CONFIG _LT_EOF cat <<'_LT_EOF' >> "$cfgfile" # ### BEGIN FUNCTIONS SHARED WITH CONFIGURE # func_munge_path_list VARIABLE PATH # ----------------------------------- # VARIABLE is name of variable containing _space_ separated list of # directories to be munged by the contents of PATH, which is string # having a format: # "DIR[:DIR]:" # string "DIR[ DIR]" will be prepended to VARIABLE # ":DIR[:DIR]" # string "DIR[ DIR]" will be appended to VARIABLE # "DIRP[:DIRP]::[DIRA:]DIRA" # string "DIRP[ DIRP]" will be prepended to VARIABLE and string # "DIRA[ DIRA]" will be appended to VARIABLE # "DIR[:DIR]" # VARIABLE will be replaced by "DIR[ DIR]" func_munge_path_list () { case x$2 in x) ;; *:) eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\" ;; x:*) eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\" ;; *::*) eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\" ;; *) eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\" ;; esac } # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. func_cc_basename () { for cc_temp in $*""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` } # ### END FUNCTIONS SHARED WITH CONFIGURE _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac ltmain=$ac_aux_dir/ltmain.sh # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi assaultcube-1.2.0.2.1/source/enet/configure.ac000066400000000000000000000017361352165075300210630ustar00rootroot00000000000000AC_INIT([libenet], [1.3.6]) AC_CONFIG_SRCDIR([include/enet/enet.h]) AM_INIT_AUTOMAKE([foreign]) AM_MAINTAINER_MODE([enable]) AC_CONFIG_MACRO_DIR([m4]) AC_PROG_CC AC_PROG_LIBTOOL AC_CHECK_FUNC(gethostbyaddr_r, [AC_DEFINE(HAS_GETHOSTBYADDR_R)]) AC_CHECK_FUNC(gethostbyname_r, [AC_DEFINE(HAS_GETHOSTBYNAME_R)]) AC_CHECK_FUNC(poll, [AC_DEFINE(HAS_POLL)]) AC_CHECK_FUNC(fcntl, [AC_DEFINE(HAS_FCNTL)]) AC_CHECK_FUNC(inet_pton, [AC_DEFINE(HAS_INET_PTON)]) AC_CHECK_FUNC(inet_ntop, [AC_DEFINE(HAS_INET_NTOP)]) AC_CHECK_MEMBER(struct msghdr.msg_flags, [AC_DEFINE(HAS_MSGHDR_FLAGS)], , [#include ]) AC_CHECK_TYPE(socklen_t, [AC_DEFINE(HAS_SOCKLEN_T)], , #include #include ) AC_EGREP_HEADER(MSG_MAXIOVLEN, /usr/include/sys/socket.h, AC_DEFINE(ENET_BUFFER_MAXIMUM, [MSG_MAXIOVLEN])) AC_EGREP_HEADER(MSG_MAXIOVLEN, socket.h, AC_DEFINE(ENET_BUFFER_MAXIMUM, [MSG_MAXIOVLEN])) AC_CONFIG_FILES([Makefile libenet.pc]) AC_OUTPUT assaultcube-1.2.0.2.1/source/enet/depcomp000077500000000000000000000560201352165075300201460ustar00rootroot00000000000000#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2018-03-07.03; # UTC # Copyright (C) 1999-2018 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by 'PROGRAMS ARGS'. object Object file output by 'PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputting dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac # Get the directory component of the given path, and save it in the # global variables '$dir'. Note that this directory component will # be either empty or ending with a '/' character. This is deliberate. set_dir_from () { case $1 in */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; *) dir=;; esac } # Get the suffix-stripped basename of the given path, and save it the # global variable '$base'. set_base_from () { base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` } # If no dependency file was actually created by the compiler invocation, # we still have to create a dummy depfile, to avoid errors with the # Makefile "include basename.Plo" scheme. make_dummy_depfile () { echo "#dummy" > "$depfile" } # Factor out some common post-processing of the generated depfile. # Requires the auxiliary global variable '$tmpdepfile' to be set. aix_post_process_depfile () { # If the compiler actually managed to produce a dependency file, # post-process it. if test -f "$tmpdepfile"; then # Each line is of the form 'foo.o: dependency.h'. # Do two passes, one to just change these to # $object: dependency.h # and one to simply output # dependency.h: # which is needed to avoid the deleted-header problem. { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" } > "$depfile" rm -f "$tmpdepfile" else make_dummy_depfile fi } # A tabulation character. tab=' ' # A newline character. nl=' ' # Character ranges might be problematic outside the C locale. # These definitions help. upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ lower=abcdefghijklmnopqrstuvwxyz digits=0123456789 alpha=${upper}${lower} if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Avoid interferences from the environment. gccflag= dashmflag= # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvisualcpp fi if test "$depmode" = msvc7msys; then # This is just like msvc7 but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvc7 fi if test "$depmode" = xlc; then # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. gccflag=-qmakedep=gcc,-MF depmode=gcc fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. ## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. ## (see the conditional assignment to $gccflag above). ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). Also, it might not be ## supported by the other compilers which use the 'gcc' depmode. ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The second -e expression handles DOS-style file names with drive # letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the "deleted header file" problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. ## Some versions of gcc put a space before the ':'. On the theory ## that the space means something, we add a space to the output as ## well. hp depmode also adds that space, but also prefixes the VPATH ## to the object. Take care to not repeat it in the output. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like '#:fec' to the end of the # dependency line. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ | tr "$nl" ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" ;; xlc) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts '$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done aix_post_process_depfile ;; tcc) # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 # FIXME: That version still under development at the moment of writing. # Make that this statement remains true also for stable, released # versions. # It will wrap lines (doesn't matter whether long or short) with a # trailing '\', as in: # # foo.o : \ # foo.c \ # foo.h \ # # It will put a trailing '\' even on the last line, and will use leading # spaces rather than leading tabs (at least since its commit 0394caf7 # "Emit spaces for -MD"). "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. # We have to change lines of the first kind to '$object: \'. sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" # And for each line of the second kind, we have to emit a 'dep.h:' # dummy dependency, to avoid the deleted-header problem. sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" rm -f "$tmpdepfile" ;; ## The order of this option in the case statement is important, since the ## shell code in configure will try each of these formats in the order ## listed in this file. A plain '-MD' option would be understood by many ## compilers, so we must ensure this comes after the gcc and icc options. pgcc) # Portland's C compiler understands '-MD'. # Will always output deps to 'file.d' where file is the root name of the # source file under compilation, even if file resides in a subdirectory. # The object file name does not affect the name of the '.d' file. # pgcc 10.2 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using '\' : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... set_dir_from "$object" # Use the source, not the object, to determine the base name, since # that's sadly what pgcc will do too. set_base_from "$source" tmpdepfile=$base.d # For projects that build the same source file twice into different object # files, the pgcc approach of using the *source* file root name can cause # problems in parallel builds. Use a locking strategy to avoid stomping on # the same $tmpdepfile. lockdir=$base.d-lock trap " echo '$0: caught signal, cleaning up...' >&2 rmdir '$lockdir' exit 1 " 1 2 13 15 numtries=100 i=$numtries while test $i -gt 0; do # mkdir is a portable test-and-set. if mkdir "$lockdir" 2>/dev/null; then # This process acquired the lock. "$@" -MD stat=$? # Release the lock. rmdir "$lockdir" break else # If the lock is being held by a different process, wait # until the winning process is done or we timeout. while test -d "$lockdir" && test $i -gt 0; do sleep 1 i=`expr $i - 1` done fi i=`expr $i - 1` done trap - 1 2 13 15 if test $i -le 0; then echo "$0: failed to acquire lock after $numtries attempts" >&2 echo "$0: check lockdir '$lockdir'" >&2 exit 1 fi if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" # Add 'dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in 'foo.d' instead, so we check for that too. # Subdirectories are respected. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then # Libtool generates 2 separate objects for the 2 libraries. These # two compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir$base.o.d # libtool 1.5 tmpdepfile2=$dir.libs/$base.o.d # Likewise. tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d "$@" -MD fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done # Same post-processing that is required for AIX mode. aix_post_process_depfile ;; msvc7) if test "$libtool" = yes; then showIncludes=-Wc,-showIncludes else showIncludes=-showIncludes fi "$@" $showIncludes > "$tmpdepfile" stat=$? grep -v '^Note: including file: ' "$tmpdepfile" if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The first sed program below extracts the file names and escapes # backslashes for cygpath. The second sed program outputs the file # name when reading, but also accumulates all include files in the # hold buffer in order to output them again at the end. This only # works with sed implementations that can handle large buffers. sed < "$tmpdepfile" -n ' /^Note: including file: *\(.*\)/ { s//\1/ s/\\/\\\\/g p }' | $cygpath_u | sort -u | sed -n ' s/ /\\ /g s/\(.*\)/'"$tab"'\1 \\/p s/.\(.*\) \\/\1:/ H $ { s/.*/'"$tab"'/ G p }' >> "$depfile" echo >> "$depfile" # make sure the fragment doesn't end with a backslash rm -f "$tmpdepfile" ;; msvc7msys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for ':' # in the target name. This is to cope with DOS-style filenames: # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. "$@" $dashmflag | sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this sed invocation # correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" # makedepend may prepend the VPATH from the source file name to the object. # No need to regex-escape $object, excess matching of '.' is harmless. sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process the last invocation # correctly. Breaking it into two sed invocations is a workaround. sed '1,2d' "$tmpdepfile" \ | tr ' ' "$nl" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E \ | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" echo "$tab" >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: assaultcube-1.2.0.2.1/source/enet/docs/000077500000000000000000000000001352165075300175165ustar00rootroot00000000000000assaultcube-1.2.0.2.1/source/enet/docs/FAQ.dox000077500000000000000000000016161352165075300206500ustar00rootroot00000000000000/** @page FAQ Frequently Answered Questions @section Q1 Is ENet thread safe? ENet does not use any significant global variables, the vast majority of state is encapsulated in the ENetHost structure. As such, as long as the application guards access to this structure, then ENet should operate fine in a multithreaded environment. @section Q2 Isn't ENet just re-inventing TCP?! What's the point? In a perfect world, that would be true. But as many have found, using TCP either in lieu of or in conjunction with UDP can lead to all kinds of nightmares. TCP is a good, solid protocol, however it simply isn't up to the task of real-time games. Too much of TCP's implementation dictates a policy that isn't practical for games. If you want to use TCP, then do so -- this library is for people that either don't want to use TCP or have tried and ended up being discouraged with the performance. */ assaultcube-1.2.0.2.1/source/enet/docs/design.dox000077500000000000000000000135631352165075300215160ustar00rootroot00000000000000/** @page Features Features and Architecture ENet evolved specifically as a UDP networking layer for the multiplayer first person shooter Cube. Cube necessitated low latency communcation with data sent out very frequently, so TCP was an unsuitable choice due to its high latency and stream orientation. UDP, however, lacks many sometimes necessary features from TCP such as reliability, sequencing, unrestricted packet sizes, and connection management. So UDP by itself was not suitable as a network protocol either. No suitable freely available networking libraries existed at the time of ENet's creation to fill this niche. UDP and TCP could have been used together in Cube to benefit somewhat from both of their features, however, the resulting combinations of protocols still leaves much to be desired. TCP lacks multiple streams of communication without resorting to opening many sockets and complicates delineation of packets due to its buffering behavior. UDP lacks sequencing, connection management, management of bandwidth resources, and imposes limitations on the size of packets. A significant investment is required to integrate these two protocols, and the end result is worse off in features and performance than the uniform protocol presented by ENet. ENet thus attempts to address these issues and provide a single, uniform protocol layered over UDP to the developer with the best features of UDP and TCP as well as some useful features neither provide, with a much cleaner integration than any resulting from a mixture of UDP and TCP. @section CM Connection Management ENet provides a simple connection interface over which to communicate with a foreign host. The liveness of the connection is actively monitored by pinging the foreign host at frequent intervals, and also monitors the network conditions from the local host to the foreign host such as the mean round trip time and packet loss in this fashion. @section Sequencing Sequencing Rather than a single byte stream that complicates the delineation of packets, ENet presents connections as multiple, properly sequenced packet streams that simplify the transfer of various types of data. ENet provides sequencing for all packets by assigning to each sent packet a sequence number that is incremented as packets are sent. ENet guarentees that no packet with a higher sequence number will be delivered before a packet with a lower sequence number, thus ensuring packets are delivered exactly in the order they are sent. For unreliable packets, ENet will simply discard the lower sequence number packet if a packet with a higher sequence number has already been delivered. This allows the packets to be dispatched immediately as they arrive, and reduce latency of unreliable packets to an absolute minimum. For reliable packets, if a higher sequence number packet arrives, but the preceding packets in the sequence have not yet arrived, ENet will stall delivery of the higher sequence number packets until its predecessors have arrived. @section Channels Channels Since ENet will stall delivery of reliable packets to ensure proper sequencing, and consequently any packets of higher sequence number whether reliable or unreliable, in the event the reliable packet's predecessors have not yet arrived, this can introduce latency into the delivery of other packets which may not need to be as strictly ordered with respect to the packet that stalled their delivery. To combat this latency and reduce the ordering restrictions on packets, ENet provides multiple channels of communication over a given connection. Each channel is independently sequenced, and so the delivery status of a packet in one channel will not stall the delivery of other packets in another channel. @section Reliability Reliability ENet provides optional reliability of packet delivery by ensuring the foreign host acknowledges receipt of all reliable packets. ENet will attempt to resend the packet up to a reasonable amount of times, if no acknowledgement of the packet's receipt happens within a specified timeout. Retry timeouts are progressive and become more lenient with every failed attempt to allow for temporary turbulence in network conditions. @section FaR Fragmentation and Reassembly ENet will send and deliver packets regardless of size. Large packets are fragmented into many smaller packets of suitable size, and reassembled on the foreign host to recover the original packet for delivery. The process is entirely transparent to the developer. @section Aggregation Aggregation ENet aggregates all protocol commands, including acknowledgements and packet transfer, into larger protocol packets to ensure the proper utilization of the connection and to limit the opportunities for packet loss that might otherwise result in further delivery latency. @section Adaptability Adaptability ENet provides an in-flight data window for reliable packets to ensure connections are not overwhelmed by volumes of packets. It also provides a static bandwidth allocation mechanism to ensure the total volume of packets sent and received to a host don't exceed the host's capabilities. Further, ENet also provides a dynamic throttle that responds to deviations from normal network connections to rectify various types of network congestion by further limiting the volume of packets sent. @section Portability Portability ENet works on Windows and any other Unix or Unix-like platform providing a BSD sockets interface. The library has a small and stable code base that can easily be extended to support other platforms and integrates easily. ENet makes no assumptions about the underlying platform's endianess or word size. @section Freedom Freedom ENet demands no royalties and doesn't carry a viral license that would restrict you in how you might use it in your programs. ENet is licensed under a short-and-sweet MIT-style license, which gives you the freedom to do anything you want with it (well, almost anything). */ assaultcube-1.2.0.2.1/source/enet/docs/install.dox000077500000000000000000000043671352165075300217150ustar00rootroot00000000000000/** @page Installation Installation ENet should be trivially simple to integrate with most applications. First, make sure you download the latest source distribution here @ref SourceDistro. @section Unix Unix-like Operating Systems If you are using an ENet release, then you should simply be able to build it by doing the following: ./configure && make && make install If you obtained the package from github, you must have automake and autoconf available to generate the build system first by doing the following command before using the above mentioned build procedure: autoreconf -vfi @subsection SolarisBSD Solaris and BSD When building ENet under Solaris, you must specify the -lsocket and -lnsl parameters to your compiler to ensure that the sockets library is linked in. @section Windows Microsoft Windows You may simply use the included "enet.lib" or "enet64.lib" static libraries. However, if you wish to build the library yourself, then the following instructions apply: There is an included MSVC 6 project (enet.dsp) which you may use to build a suitable library file. Alternatively, you may simply drag all the ENet source files into your main project. You will have to link to the Winsock2 libraries, so make sure to add ws2_32.lib and winmm.lib to your library list (Project Settings | Link | Object/library modules). @subsection enet.dsp Building with the included enet.dsp Load the included enet.dsp. MSVC may ask you to convert it if you are on a newer version of MSVC - just allow the conversion and save the resulting project as "enet" or similar. After you build this project, it will output an "enet.lib" file to either the "Debug/" or "Release/" directory, depending on which configuration you have selected to build. By default, it should produce "Debug/enet.lib". You may then copy the resulting "enet.lib" file and the header files found in the "include/" directory to your other projects and add it to their library lists. Make sure to also link against "ws2_32.lib" and "winmm.lib" as described above. @subsection DLL DLL If you wish to build ENet as a DLL you must first define ENET_DLL within the project (Project Settings | C/C++ | Preprocessor | Preprocessor definitions) or, more invasively, simply define ENET_DLL at the top of enet.h. */ assaultcube-1.2.0.2.1/source/enet/docs/license.dox000077500000000000000000000021061352165075300216560ustar00rootroot00000000000000/** @page License License Copyright (c) 2002-2012 Lee Salzman Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ assaultcube-1.2.0.2.1/source/enet/docs/mainpage.dox000077500000000000000000000031371352165075300220220ustar00rootroot00000000000000/** @mainpage enet
http://enet.bespin.org

ENet's purpose is to provide a relatively thin, simple and robust network communication layer on top of UDP (User Datagram Protocol). The primary feature it provides is optional reliable, in-order delivery of packets. ENet omits certain higher level networking features such as authentication, lobbying, server discovery, encryption, or other similar tasks that are particularly application specific so that the library remains flexible, portable, and easily embeddable. @ref Features @ref SourceDistro @ref Installation @ref Tutorial @ref MailingList @ref IRCChannel @ref FAQ @ref License */ /** @page SourceDistro Source Distribution You can retrieve the source to ENet by downloading it in either .tar.gz form or accessing the github distribution directly. The most recent stable release (1.3.6) can be downloaded here. The last release that is protocol compatible with the 1.2 series or earlier (1.2.5) can be downloaded here You can find the most recent ENet source at the github repository. */ /** @page MailingList ENet Mailing List The enet-discuss list is for discussion of ENet, including bug reports or feature requests. */ /** @page IRCChannel ENet IRC Channel Join the \#enet channel on the freenode IRC network (irc.freenode.net) for real-time discussion about the ENet library. */ assaultcube-1.2.0.2.1/source/enet/docs/tutorial.dox000077500000000000000000000300231352165075300220760ustar00rootroot00000000000000/** @page Tutorial Tutorial @ref Initialization @ref CreateServer @ref CreateClient @ref ManageHost @ref SendingPacket @ref Disconnecting @ref Connecting @section Initialization Initialization You should include the file when using ENet. Do not include without the directory prefix, as this may cause file name conflicts on some systems. Before using ENet, you must call enet_initialize() to initialize the library. Upon program exit, you should call enet_deinitialize() so that the library may clean up any used resources. @code #include int main (int argc, char ** argv) { if (enet_initialize () != 0) { fprintf (stderr, "An error occurred while initializing ENet.\n"); return EXIT_FAILURE; } atexit (enet_deinitialize); ... ... ... } @endcode @section CreateServer Creating an ENet server Servers in ENet are constructed with enet_host_create(). You must specify an address on which to receive data and new connections, as well as the maximum allowable numbers of connected peers. You may optionally specify the incoming and outgoing bandwidth of the server in bytes per second so that ENet may try to statically manage bandwidth resources among connected peers in addition to its dynamic throttling algorithm; specifying 0 for these two options will cause ENet to rely entirely upon its dynamic throttling algorithm to manage bandwidth. When done with a host, the host may be destroyed with enet_host_destroy(). All connected peers to the host will be reset, and the resources used by the host will be freed. @code ENetAddress address; ENetHost * server; /* Bind the server to the default localhost. */ /* A specific host address can be specified by */ /* enet_address_set_host (& address, "x.x.x.x"); */ address.host = ENET_HOST_ANY; /* Bind the server to port 1234. */ address.port = 1234; server = enet_host_create (& address /* the address to bind the server host to */, 32 /* allow up to 32 clients and/or outgoing connections */, 2 /* allow up to 2 channels to be used, 0 and 1 */, 0 /* assume any amount of incoming bandwidth */, 0 /* assume any amount of outgoing bandwidth */); if (server == NULL) { fprintf (stderr, "An error occurred while trying to create an ENet server host.\n"); exit (EXIT_FAILURE); } ... ... ... enet_host_destroy(server); @endcode @section CreateClient Creating an ENet client Clients in ENet are similarly constructed with enet_host_create() when no address is specified to bind the host to. Bandwidth may be specified for the client host as in the above example. The peer count controls the maximum number of connections to other server hosts that may be simultaneously open. @code ENetHost * client; client = enet_host_create (NULL /* create a client host */, 1 /* only allow 1 outgoing connection */, 2 /* allow up 2 channels to be used, 0 and 1 */, 57600 / 8 /* 56K modem with 56 Kbps downstream bandwidth */, 14400 / 8 /* 56K modem with 14 Kbps upstream bandwidth */); if (client == NULL) { fprintf (stderr, "An error occurred while trying to create an ENet client host.\n"); exit (EXIT_FAILURE); } ... ... ... enet_host_destroy(client); @endcode @section ManageHost Managing an ENet host ENet uses a polled event model to notify the programmer of significant events. ENet hosts are polled for events with enet_host_service(), where an optional timeout value in milliseconds may be specified to control how long ENet will poll; if a timeout of 0 is specified, enet_host_service() will return immediately if there are no events to dispatch. enet_host_service() will return 1 if an event was dispatched within the specified timeout. Currently there are only four types of significant events in ENet: An event of type ENET_EVENT_TYPE_NONE is returned if no event occurred within the specified time limit. enet_host_service() will return 0 with this event. An event of type ENET_EVENT_TYPE_CONNECT is returned when either a new client host has connected to the server host or when an attempt to establish a connection with a foreign host has succeeded. Only the "peer" field of the event structure is valid for this event and contains the newly connected peer. An event of type ENET_EVENT_TYPE_RECEIVE is returned when a packet is received from a connected peer. The "peer" field contains the peer the packet was received from, "channelID" is the channel on which the packet was sent, and "packet" is the packet that was sent. The packet contained in the "packet" field must be destroyed with enet_packet_destroy() when you are done inspecting its contents. An event of type ENET_EVENT_TYPE_DISCONNECT is returned when a connected peer has either explicitly disconnected or timed out. Only the "peer" field of the event structure is valid for this event and contains the peer that disconnected. Only the "data" field of the peer is still valid on a disconnect event and must be explicitly reset. @code ENetEvent event; /* Wait up to 1000 milliseconds for an event. */ while (enet_host_service (client, & event, 1000) > 0) { switch (event.type) { case ENET_EVENT_TYPE_CONNECT: printf ("A new client connected from %x:%u.\n", event.peer -> address.host, event.peer -> address.port); /* Store any relevant client information here. */ event.peer -> data = "Client information"; break; case ENET_EVENT_TYPE_RECEIVE: printf ("A packet of length %u containing %s was received from %s on channel %u.\n", event.packet -> dataLength, event.packet -> data, event.peer -> data, event.channelID); /* Clean up the packet now that we're done using it. */ enet_packet_destroy (event.packet); break; case ENET_EVENT_TYPE_DISCONNECT: printf ("%s disconected.\n", event.peer -> data); /* Reset the peer's client information. */ event.peer -> data = NULL; } } ... ... ... @endcode @section SendingPacket Sending a packet to an ENet peer Packets in ENet are created with enet_packet_create(), where the size of the packet must be specified. Optionally, initial data may be specified to copy into the packet. Certain flags may also be supplied to enet_packet_create() to control various packet features: ENET_PACKET_FLAG_RELIABLE specifies that the packet must use reliable delivery. A reliable packet is guarenteed to be delivered, and a number of retry attempts will be made until an acknowledgement is received from the foreign host the packet is sent to. If a certain number of retry attempts is reached without any acknowledgement, ENet will assume the peer has disconnected and forcefully reset the connection. If this flag is not specified, the packet is assumed an unreliable packet, and no retry attempts will be made nor acknowledgements generated. A packet may be resized (extended or truncated) with enet_packet_resize(). A packet is sent to a foreign host with enet_peer_send(). enet_peer_send() accepts a channel id over which to send the packet to a given peer. Once the packet is handed over to ENet with enet_peer_send(), ENet will handle its deallocation and enet_packet_destroy() should not be used upon it. One may also use enet_host_broadcast() to send a packet to all connected peers on a given host over a specified channel id, as with enet_peer_send(). Queued packets will be sent on a call to enet_host_service(). Alternatively, enet_host_flush() will send out queued packets without dispatching any events. @code /* Create a reliable packet of size 7 containing "packet\0" */ ENetPacket * packet = enet_packet_create ("packet", strlen ("packet") + 1, ENET_PACKET_FLAG_RELIABLE); /* Extend the packet so and append the string "foo", so it now */ /* contains "packetfoo\0" */ enet_packet_resize (packet, strlen ("packetfoo") + 1); strcpy (& packet -> data [strlen ("packet")], "foo"); /* Send the packet to the peer over channel id 0. */ /* One could also broadcast the packet by */ /* enet_host_broadcast (host, 0, packet); */ enet_peer_send (peer, 0, packet); ... ... ... /* One could just use enet_host_service() instead. */ enet_host_flush (host); @endcode @section Disconnecting Disconnecting an ENet peer Peers may be gently disconnected with enet_peer_disconnect(). A disconnect request will be sent to the foreign host, and ENet will wait for an acknowledgement from the foreign host before finally disconnecting. An event of type ENET_EVENT_TYPE_DISCONNECT will be generated once the disconnection succeeds. Normally timeouts apply to the disconnect acknowledgement, and so if no acknowledgement is received after a length of time the peer will be forcefully disconnected. enet_peer_reset() will forcefully disconnect a peer. The foreign host will get no notification of a disconnect and will time out on the foreign host. No event is generated. @code ENetEvent event; enet_peer_disconnect (peer, 0); /* Allow up to 3 seconds for the disconnect to succeed * and drop any packets received packets. */ while (enet_host_service (client, & event, 3000) > 0) { switch (event.type) { case ENET_EVENT_TYPE_RECEIVE: enet_packet_destroy (event.packet); break; case ENET_EVENT_TYPE_DISCONNECT: puts ("Disconnection succeeded."); return; ... ... ... } } /* We've arrived here, so the disconnect attempt didn't */ /* succeed yet. Force the connection down. */ enet_peer_reset (peer); ... ... ... @endcode @section Connecting Connecting to an ENet host A connection to a foreign host is initiated with enet_host_connect(). It accepts the address of a foreign host to connect to, and the number of channels that should be allocated for communication. If N channels are allocated for use, their channel ids will be numbered 0 through N-1. A peer representing the connection attempt is returned, or NULL if there were no available peers over which to initiate the connection. When the connection attempt succeeds, an event of type ENET_EVENT_TYPE_CONNECT will be generated. If the connection attempt times out or otherwise fails, an event of type ENET_EVENT_TYPE_DISCONNECT will be generated. @code ENetAddress address; ENetEvent event; ENetPeer *peer; /* Connect to some.server.net:1234. */ enet_address_set_host (& address, "some.server.net"); address.port = 1234; /* Initiate the connection, allocating the two channels 0 and 1. */ peer = enet_host_connect (client, & address, 2, 0); if (peer == NULL) { fprintf (stderr, "No available peers for initiating an ENet connection.\n"); exit (EXIT_FAILURE); } /* Wait up to 5 seconds for the connection attempt to succeed. */ if (enet_host_service (client, & event, 5000) > 0 && event.type == ENET_EVENT_TYPE_CONNECT) { puts ("Connection to some.server.net:1234 succeeded."); ... ... ... } else { /* Either the 5 seconds are up or a disconnect event was */ /* received. Reset the peer in the event the 5 seconds */ /* had run out without any significant event. */ enet_peer_reset (peer); puts ("Connection to some.server.net:1234 failed."); } ... ... ... @endcode */ assaultcube-1.2.0.2.1/source/enet/enet.dsp000077500000000000000000000074371352165075300202470ustar00rootroot00000000000000# Microsoft Developer Studio Project File - Name="enet" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Static Library" 0x0104 CFG=enet - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "enet.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "enet.mak" CFG="enet - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "enet - Win32 Release" (based on "Win32 (x86) Static Library") !MESSAGE "enet - Win32 Debug" (based on "Win32 (x86) Static Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "enet - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Target_Dir "" MTL=midl.exe # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # ADD CPP /nologo /W3 /O2 /I "include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo !ELSEIF "$(CFG)" == "enet - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" MTL=midl.exe # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c # ADD CPP /nologo /G6 /MTd /W3 /ZI /Od /I "include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo !ENDIF # Begin Target # Name "enet - Win32 Release" # Name "enet - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\host.c # End Source File # Begin Source File SOURCE=.\list.c # End Source File # Begin Source File SOURCE=.\callbacks.c # End Source File # Begin Source File SOURCE=.\compress.c # End Source File # Begin Source File SOURCE=.\packet.c # End Source File # Begin Source File SOURCE=.\peer.c # End Source File # Begin Source File SOURCE=.\protocol.c # End Source File # Begin Source File SOURCE=.\unix.c # End Source File # Begin Source File SOURCE=.\win32.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\include\enet\enet.h # End Source File # Begin Source File SOURCE=.\include\enet\list.h # End Source File # Begin Source File SOURCE=.\include\enet\callbacks.h # End Source File # Begin Source File SOURCE=.\include\enet\protocol.h # End Source File # Begin Source File SOURCE=.\include\enet\time.h # End Source File # Begin Source File SOURCE=.\include\enet\types.h # End Source File # Begin Source File SOURCE=.\include\enet\unix.h # End Source File # Begin Source File SOURCE=.\include\enet\utility.h # End Source File # Begin Source File SOURCE=.\include\enet\win32.h # End Source File # End Group # End Target # End Project assaultcube-1.2.0.2.1/source/enet/enet_dll.cbp000066400000000000000000000051271352165075300210470ustar00rootroot00000000000000 assaultcube-1.2.0.2.1/source/enet/host.c000066400000000000000000000422341352165075300177140ustar00rootroot00000000000000/** @file host.c @brief ENet host management functions */ #define ENET_BUILDING_LIB 1 #include #include #include "enet/enet.h" /** @defgroup host ENet host functions @{ */ /** Creates a host for communicating to peers. @param address the address at which other peers may connect to this host. If NULL, then no peers may connect to the host. @param peerCount the maximum number of peers that should be allocated for the host. @param channelLimit the maximum number of channels allowed; if 0, then this is equivalent to ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT @param incomingBandwidth downstream bandwidth of the host in bytes/second; if 0, ENet will assume unlimited bandwidth. @param outgoingBandwidth upstream bandwidth of the host in bytes/second; if 0, ENet will assume unlimited bandwidth. @returns the host on success and NULL on failure @remarks ENet will strategically drop packets on specific sides of a connection between hosts to ensure the host's bandwidth is not overwhelmed. The bandwidth parameters also determine the window size of a connection which limits the amount of reliable packets that may be in transit at any given time. */ ENetHost * enet_host_create (const ENetAddress * address, size_t peerCount, size_t channelLimit, enet_uint32 incomingBandwidth, enet_uint32 outgoingBandwidth) { ENetHost * host; ENetPeer * currentPeer; if (peerCount > ENET_PROTOCOL_MAXIMUM_PEER_ID) return NULL; host = (ENetHost *) enet_malloc (sizeof (ENetHost)); if (host == NULL) return NULL; memset (host, 0, sizeof (ENetHost)); host -> peers = (ENetPeer *) enet_malloc (peerCount * sizeof (ENetPeer)); if (host -> peers == NULL) { enet_free (host); return NULL; } memset (host -> peers, 0, peerCount * sizeof (ENetPeer)); host -> socket = enet_socket_create (ENET_SOCKET_TYPE_DATAGRAM); if (host -> socket == ENET_SOCKET_NULL || (address != NULL && enet_socket_bind (host -> socket, address) < 0)) { if (host -> socket != ENET_SOCKET_NULL) enet_socket_destroy (host -> socket); enet_free (host -> peers); enet_free (host); return NULL; } enet_socket_set_option (host -> socket, ENET_SOCKOPT_NONBLOCK, 1); enet_socket_set_option (host -> socket, ENET_SOCKOPT_BROADCAST, 1); enet_socket_set_option (host -> socket, ENET_SOCKOPT_RCVBUF, ENET_HOST_RECEIVE_BUFFER_SIZE); enet_socket_set_option (host -> socket, ENET_SOCKOPT_SNDBUF, ENET_HOST_SEND_BUFFER_SIZE); if (address != NULL) host -> address = * address; if (! channelLimit || channelLimit > ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT) channelLimit = ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT; else if (channelLimit < ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT) channelLimit = ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT; host -> randomSeed = (enet_uint32) (size_t) host; #ifdef WIN32 host -> randomSeed += (enet_uint32) timeGetTime(); #else host -> randomSeed += (enet_uint32) time(NULL); #endif host -> randomSeed = (host -> randomSeed << 16) | (host -> randomSeed >> 16); host -> channelLimit = channelLimit; host -> incomingBandwidth = incomingBandwidth; host -> outgoingBandwidth = outgoingBandwidth; host -> bandwidthThrottleEpoch = 0; host -> recalculateBandwidthLimits = 0; host -> mtu = ENET_HOST_DEFAULT_MTU; host -> peerCount = peerCount; host -> commandCount = 0; host -> bufferCount = 0; host -> checksum = NULL; host -> receivedAddress.host = ENET_HOST_ANY; host -> receivedAddress.port = 0; host -> receivedData = NULL; host -> receivedDataLength = 0; host -> totalSentData = 0; host -> totalSentPackets = 0; host -> totalReceivedData = 0; host -> totalReceivedPackets = 0; host -> compressor.context = NULL; host -> compressor.compress = NULL; host -> compressor.decompress = NULL; host -> compressor.destroy = NULL; host -> intercept = NULL; enet_list_clear (& host -> dispatchQueue); for (currentPeer = host -> peers; currentPeer < & host -> peers [host -> peerCount]; ++ currentPeer) { currentPeer -> host = host; currentPeer -> incomingPeerID = currentPeer - host -> peers; currentPeer -> outgoingSessionID = currentPeer -> incomingSessionID = 0xFF; currentPeer -> data = NULL; enet_list_clear (& currentPeer -> acknowledgements); enet_list_clear (& currentPeer -> sentReliableCommands); enet_list_clear (& currentPeer -> sentUnreliableCommands); enet_list_clear (& currentPeer -> outgoingReliableCommands); enet_list_clear (& currentPeer -> outgoingUnreliableCommands); enet_list_clear (& currentPeer -> dispatchedCommands); enet_peer_reset (currentPeer); } return host; } /** Destroys the host and all resources associated with it. @param host pointer to the host to destroy */ void enet_host_destroy (ENetHost * host) { ENetPeer * currentPeer; if (host == NULL) return; enet_socket_destroy (host -> socket); for (currentPeer = host -> peers; currentPeer < & host -> peers [host -> peerCount]; ++ currentPeer) { enet_peer_reset (currentPeer); } if (host -> compressor.context != NULL && host -> compressor.destroy) (* host -> compressor.destroy) (host -> compressor.context); enet_free (host -> peers); enet_free (host); } /** Initiates a connection to a foreign host. @param host host seeking the connection @param address destination for the connection @param channelCount number of channels to allocate @param data user data supplied to the receiving host @returns a peer representing the foreign host on success, NULL on failure @remarks The peer returned will have not completed the connection until enet_host_service() notifies of an ENET_EVENT_TYPE_CONNECT event for the peer. */ ENetPeer * enet_host_connect (ENetHost * host, const ENetAddress * address, size_t channelCount, enet_uint32 data) { ENetPeer * currentPeer; ENetChannel * channel; ENetProtocol command; if (channelCount < ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT) channelCount = ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT; else if (channelCount > ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT) channelCount = ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT; for (currentPeer = host -> peers; currentPeer < & host -> peers [host -> peerCount]; ++ currentPeer) { if (currentPeer -> state == ENET_PEER_STATE_DISCONNECTED) break; } if (currentPeer >= & host -> peers [host -> peerCount]) return NULL; currentPeer -> channels = (ENetChannel *) enet_malloc (channelCount * sizeof (ENetChannel)); if (currentPeer -> channels == NULL) return NULL; currentPeer -> channelCount = channelCount; currentPeer -> state = ENET_PEER_STATE_CONNECTING; currentPeer -> address = * address; currentPeer -> connectID = ++ host -> randomSeed; if (host -> outgoingBandwidth == 0) currentPeer -> windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE; else currentPeer -> windowSize = (host -> outgoingBandwidth / ENET_PEER_WINDOW_SIZE_SCALE) * ENET_PROTOCOL_MINIMUM_WINDOW_SIZE; if (currentPeer -> windowSize < ENET_PROTOCOL_MINIMUM_WINDOW_SIZE) currentPeer -> windowSize = ENET_PROTOCOL_MINIMUM_WINDOW_SIZE; else if (currentPeer -> windowSize > ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE) currentPeer -> windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE; for (channel = currentPeer -> channels; channel < & currentPeer -> channels [channelCount]; ++ channel) { channel -> outgoingReliableSequenceNumber = 0; channel -> outgoingUnreliableSequenceNumber = 0; channel -> incomingReliableSequenceNumber = 0; channel -> incomingUnreliableSequenceNumber = 0; enet_list_clear (& channel -> incomingReliableCommands); enet_list_clear (& channel -> incomingUnreliableCommands); channel -> usedReliableWindows = 0; memset (channel -> reliableWindows, 0, sizeof (channel -> reliableWindows)); } command.header.command = ENET_PROTOCOL_COMMAND_CONNECT | ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE; command.header.channelID = 0xFF; command.connect.outgoingPeerID = ENET_HOST_TO_NET_16 (currentPeer -> incomingPeerID); command.connect.incomingSessionID = currentPeer -> incomingSessionID; command.connect.outgoingSessionID = currentPeer -> outgoingSessionID; command.connect.mtu = ENET_HOST_TO_NET_32 (currentPeer -> mtu); command.connect.windowSize = ENET_HOST_TO_NET_32 (currentPeer -> windowSize); command.connect.channelCount = ENET_HOST_TO_NET_32 (channelCount); command.connect.incomingBandwidth = ENET_HOST_TO_NET_32 (host -> incomingBandwidth); command.connect.outgoingBandwidth = ENET_HOST_TO_NET_32 (host -> outgoingBandwidth); command.connect.packetThrottleInterval = ENET_HOST_TO_NET_32 (currentPeer -> packetThrottleInterval); command.connect.packetThrottleAcceleration = ENET_HOST_TO_NET_32 (currentPeer -> packetThrottleAcceleration); command.connect.packetThrottleDeceleration = ENET_HOST_TO_NET_32 (currentPeer -> packetThrottleDeceleration); command.connect.connectID = currentPeer -> connectID; command.connect.data = ENET_HOST_TO_NET_32 (data); enet_peer_queue_outgoing_command (currentPeer, & command, NULL, 0, 0); return currentPeer; } /** Queues a packet to be sent to all peers associated with the host. @param host host on which to broadcast the packet @param channelID channel on which to broadcast @param packet packet to broadcast */ void enet_host_broadcast (ENetHost * host, enet_uint8 channelID, ENetPacket * packet) { ENetPeer * currentPeer; for (currentPeer = host -> peers; currentPeer < & host -> peers [host -> peerCount]; ++ currentPeer) { if (currentPeer -> state != ENET_PEER_STATE_CONNECTED) continue; enet_peer_send (currentPeer, channelID, packet); } if (packet -> referenceCount == 0) enet_packet_destroy (packet); } /** Sets the packet compressor the host should use to compress and decompress packets. @param host host to enable or disable compression for @param compressor callbacks for for the packet compressor; if NULL, then compression is disabled */ void enet_host_compress (ENetHost * host, const ENetCompressor * compressor) { if (host -> compressor.context != NULL && host -> compressor.destroy) (* host -> compressor.destroy) (host -> compressor.context); if (compressor) host -> compressor = * compressor; else host -> compressor.context = NULL; } /** Limits the maximum allowed channels of future incoming connections. @param host host to limit @param channelLimit the maximum number of channels allowed; if 0, then this is equivalent to ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT */ void enet_host_channel_limit (ENetHost * host, size_t channelLimit) { if (! channelLimit || channelLimit > ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT) channelLimit = ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT; else if (channelLimit < ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT) channelLimit = ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT; host -> channelLimit = channelLimit; } /** Adjusts the bandwidth limits of a host. @param host host to adjust @param incomingBandwidth new incoming bandwidth @param outgoingBandwidth new outgoing bandwidth @remarks the incoming and outgoing bandwidth parameters are identical in function to those specified in enet_host_create(). */ void enet_host_bandwidth_limit (ENetHost * host, enet_uint32 incomingBandwidth, enet_uint32 outgoingBandwidth) { host -> incomingBandwidth = incomingBandwidth; host -> outgoingBandwidth = outgoingBandwidth; host -> recalculateBandwidthLimits = 1; } void enet_host_bandwidth_throttle (ENetHost * host) { enet_uint32 timeCurrent = enet_time_get (), elapsedTime = timeCurrent - host -> bandwidthThrottleEpoch, peersTotal = 0, dataTotal = 0, peersRemaining, bandwidth, throttle = 0, bandwidthLimit = 0; int needsAdjustment; ENetPeer * peer; ENetProtocol command; if (elapsedTime < ENET_HOST_BANDWIDTH_THROTTLE_INTERVAL) return; for (peer = host -> peers; peer < & host -> peers [host -> peerCount]; ++ peer) { if (peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER) continue; ++ peersTotal; dataTotal += peer -> outgoingDataTotal; } if (peersTotal == 0) return; peersRemaining = peersTotal; needsAdjustment = 1; if (host -> outgoingBandwidth == 0) bandwidth = ~0; else bandwidth = (host -> outgoingBandwidth * elapsedTime) / 1000; while (peersRemaining > 0 && needsAdjustment != 0) { needsAdjustment = 0; if (dataTotal < bandwidth) throttle = ENET_PEER_PACKET_THROTTLE_SCALE; else throttle = (bandwidth * ENET_PEER_PACKET_THROTTLE_SCALE) / dataTotal; for (peer = host -> peers; peer < & host -> peers [host -> peerCount]; ++ peer) { enet_uint32 peerBandwidth; if ((peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER) || peer -> incomingBandwidth == 0 || peer -> outgoingBandwidthThrottleEpoch == timeCurrent) continue; peerBandwidth = (peer -> incomingBandwidth * elapsedTime) / 1000; if ((throttle * peer -> outgoingDataTotal) / ENET_PEER_PACKET_THROTTLE_SCALE <= peerBandwidth) continue; peer -> packetThrottleLimit = (peerBandwidth * ENET_PEER_PACKET_THROTTLE_SCALE) / peer -> outgoingDataTotal; if (peer -> packetThrottleLimit == 0) peer -> packetThrottleLimit = 1; if (peer -> packetThrottle > peer -> packetThrottleLimit) peer -> packetThrottle = peer -> packetThrottleLimit; peer -> outgoingBandwidthThrottleEpoch = timeCurrent; needsAdjustment = 1; -- peersRemaining; bandwidth -= peerBandwidth; dataTotal -= peerBandwidth; } } if (peersRemaining > 0) for (peer = host -> peers; peer < & host -> peers [host -> peerCount]; ++ peer) { if ((peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER) || peer -> outgoingBandwidthThrottleEpoch == timeCurrent) continue; peer -> packetThrottleLimit = throttle; if (peer -> packetThrottle > peer -> packetThrottleLimit) peer -> packetThrottle = peer -> packetThrottleLimit; } if (host -> recalculateBandwidthLimits) { host -> recalculateBandwidthLimits = 0; peersRemaining = peersTotal; bandwidth = host -> incomingBandwidth; needsAdjustment = 1; if (bandwidth == 0) bandwidthLimit = 0; else while (peersRemaining > 0 && needsAdjustment != 0) { needsAdjustment = 0; bandwidthLimit = bandwidth / peersRemaining; for (peer = host -> peers; peer < & host -> peers [host -> peerCount]; ++ peer) { if ((peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER) || peer -> incomingBandwidthThrottleEpoch == timeCurrent) continue; if (peer -> outgoingBandwidth > 0 && peer -> outgoingBandwidth >= bandwidthLimit) continue; peer -> incomingBandwidthThrottleEpoch = timeCurrent; needsAdjustment = 1; -- peersRemaining; bandwidth -= peer -> outgoingBandwidth; } } for (peer = host -> peers; peer < & host -> peers [host -> peerCount]; ++ peer) { if (peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER) continue; command.header.command = ENET_PROTOCOL_COMMAND_BANDWIDTH_LIMIT | ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE; command.header.channelID = 0xFF; command.bandwidthLimit.outgoingBandwidth = ENET_HOST_TO_NET_32 (host -> outgoingBandwidth); if (peer -> incomingBandwidthThrottleEpoch == timeCurrent) command.bandwidthLimit.incomingBandwidth = ENET_HOST_TO_NET_32 (peer -> outgoingBandwidth); else command.bandwidthLimit.incomingBandwidth = ENET_HOST_TO_NET_32 (bandwidthLimit); enet_peer_queue_outgoing_command (peer, & command, NULL, 0, 0); } } host -> bandwidthThrottleEpoch = timeCurrent; for (peer = host -> peers; peer < & host -> peers [host -> peerCount]; ++ peer) { peer -> incomingDataTotal = 0; peer -> outgoingDataTotal = 0; } } /** @} */ assaultcube-1.2.0.2.1/source/enet/include/000077500000000000000000000000001352165075300202115ustar00rootroot00000000000000assaultcube-1.2.0.2.1/source/enet/include/enet/000077500000000000000000000000001352165075300211445ustar00rootroot00000000000000assaultcube-1.2.0.2.1/source/enet/include/enet/callbacks.h000066400000000000000000000010111352165075300232250ustar00rootroot00000000000000/** @file callbacks.h @brief ENet callbacks */ #ifndef __ENET_CALLBACKS_H__ #define __ENET_CALLBACKS_H__ #include typedef struct _ENetCallbacks { void * (ENET_CALLBACK * malloc) (size_t size); void (ENET_CALLBACK * free) (void * memory); void (ENET_CALLBACK * no_memory) (void); } ENetCallbacks; /** @defgroup callbacks ENet internal callbacks @{ @ingroup private */ extern void * enet_malloc (size_t); extern void enet_free (void *); /** @} */ #endif /* __ENET_CALLBACKS_H__ */ assaultcube-1.2.0.2.1/source/enet/include/enet/enet.h000066400000000000000000000562571352165075300222670ustar00rootroot00000000000000/** @file enet.h @brief ENet public header file */ #ifndef __ENET_ENET_H__ #define __ENET_ENET_H__ #ifdef __cplusplus extern "C" { #endif #include #ifdef WIN32 #include "enet/win32.h" #else #include "enet/unix.h" #endif #include "enet/types.h" #include "enet/protocol.h" #include "enet/list.h" #include "enet/callbacks.h" #define ENET_VERSION_MAJOR 1 #define ENET_VERSION_MINOR 3 #define ENET_VERSION_PATCH 6 #define ENET_VERSION_CREATE(major, minor, patch) (((major)<<16) | ((minor)<<8) | (patch)) #define ENET_VERSION ENET_VERSION_CREATE(ENET_VERSION_MAJOR, ENET_VERSION_MINOR, ENET_VERSION_PATCH) typedef enet_uint32 ENetVersion; struct _ENetHost; struct _ENetEvent; struct _ENetPacket; typedef enum _ENetSocketType { ENET_SOCKET_TYPE_STREAM = 1, ENET_SOCKET_TYPE_DATAGRAM = 2 } ENetSocketType; typedef enum _ENetSocketWait { ENET_SOCKET_WAIT_NONE = 0, ENET_SOCKET_WAIT_SEND = (1 << 0), ENET_SOCKET_WAIT_RECEIVE = (1 << 1) } ENetSocketWait; typedef enum _ENetSocketOption { ENET_SOCKOPT_NONBLOCK = 1, ENET_SOCKOPT_BROADCAST = 2, ENET_SOCKOPT_RCVBUF = 3, ENET_SOCKOPT_SNDBUF = 4, ENET_SOCKOPT_REUSEADDR = 5, ENET_SOCKOPT_RCVTIMEO = 6, ENET_SOCKOPT_SNDTIMEO = 7 } ENetSocketOption; typedef enum _ENetSocketShutdown { ENET_SOCKET_SHUTDOWN_READ = 0, ENET_SOCKET_SHUTDOWN_WRITE = 1, ENET_SOCKET_SHUTDOWN_READ_WRITE = 2 } ENetSocketShutdown; enum { ENET_HOST_ANY = 0, /**< specifies the default server host */ ENET_HOST_BROADCAST = 0xFFFFFFFF, /**< specifies a subnet-wide broadcast */ ENET_PORT_ANY = 0 /**< specifies that a port should be automatically chosen */ }; /** * Portable internet address structure. * * The host must be specified in network byte-order, and the port must be in host * byte-order. The constant ENET_HOST_ANY may be used to specify the default * server host. The constant ENET_HOST_BROADCAST may be used to specify the * broadcast address (255.255.255.255). This makes sense for enet_host_connect, * but not for enet_host_create. Once a server responds to a broadcast, the * address is updated from ENET_HOST_BROADCAST to the server's actual IP address. */ typedef struct _ENetAddress { enet_uint32 host; enet_uint16 port; } ENetAddress; /** * Packet flag bit constants. * * The host must be specified in network byte-order, and the port must be in * host byte-order. The constant ENET_HOST_ANY may be used to specify the * default server host. @sa ENetPacket */ typedef enum _ENetPacketFlag { /** packet must be received by the target peer and resend attempts should be * made until the packet is delivered */ ENET_PACKET_FLAG_RELIABLE = (1 << 0), /** packet will not be sequenced with other packets * not supported for reliable packets */ ENET_PACKET_FLAG_UNSEQUENCED = (1 << 1), /** packet will not allocate data, and user must supply it instead */ ENET_PACKET_FLAG_NO_ALLOCATE = (1 << 2), /** packet will be fragmented using unreliable (instead of reliable) sends * if it exceeds the MTU */ ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT = (1 << 3) } ENetPacketFlag; typedef void (ENET_CALLBACK * ENetPacketFreeCallback) (struct _ENetPacket *); /** * ENet packet structure. * * An ENet data packet that may be sent to or received from a peer. The shown * fields should only be read and never modified. The data field contains the * allocated data for the packet. The dataLength fields specifies the length * of the allocated data. The flags field is either 0 (specifying no flags), * or a bitwise-or of any combination of the following flags: * * ENET_PACKET_FLAG_RELIABLE - packet must be received by the target peer * and resend attempts should be made until the packet is delivered * * ENET_PACKET_FLAG_UNSEQUENCED - packet will not be sequenced with other packets * (not supported for reliable packets) * * ENET_PACKET_FLAG_NO_ALLOCATE - packet will not allocate data, and user must supply it instead @sa ENetPacketFlag */ typedef struct _ENetPacket { size_t referenceCount; /**< internal use only */ enet_uint32 flags; /**< bitwise-or of ENetPacketFlag constants */ enet_uint8 * data; /**< allocated data for packet */ size_t dataLength; /**< length of data */ ENetPacketFreeCallback freeCallback; /**< function to be called when the packet is no longer in use */ } ENetPacket; typedef struct _ENetAcknowledgement { ENetListNode acknowledgementList; enet_uint32 sentTime; ENetProtocol command; } ENetAcknowledgement; typedef struct _ENetOutgoingCommand { ENetListNode outgoingCommandList; enet_uint16 reliableSequenceNumber; enet_uint16 unreliableSequenceNumber; enet_uint32 sentTime; enet_uint32 roundTripTimeout; enet_uint32 roundTripTimeoutLimit; enet_uint32 fragmentOffset; enet_uint16 fragmentLength; enet_uint16 sendAttempts; ENetProtocol command; ENetPacket * packet; } ENetOutgoingCommand; typedef struct _ENetIncomingCommand { ENetListNode incomingCommandList; enet_uint16 reliableSequenceNumber; enet_uint16 unreliableSequenceNumber; ENetProtocol command; enet_uint32 fragmentCount; enet_uint32 fragmentsRemaining; enet_uint32 * fragments; ENetPacket * packet; } ENetIncomingCommand; typedef enum _ENetPeerState { ENET_PEER_STATE_DISCONNECTED = 0, ENET_PEER_STATE_CONNECTING = 1, ENET_PEER_STATE_ACKNOWLEDGING_CONNECT = 2, ENET_PEER_STATE_CONNECTION_PENDING = 3, ENET_PEER_STATE_CONNECTION_SUCCEEDED = 4, ENET_PEER_STATE_CONNECTED = 5, ENET_PEER_STATE_DISCONNECT_LATER = 6, ENET_PEER_STATE_DISCONNECTING = 7, ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT = 8, ENET_PEER_STATE_ZOMBIE = 9 } ENetPeerState; #ifndef ENET_BUFFER_MAXIMUM #define ENET_BUFFER_MAXIMUM (1 + 2 * ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS) #endif enum { ENET_HOST_RECEIVE_BUFFER_SIZE = 256 * 1024, ENET_HOST_SEND_BUFFER_SIZE = 256 * 1024, ENET_HOST_BANDWIDTH_THROTTLE_INTERVAL = 1000, ENET_HOST_DEFAULT_MTU = 1400, ENET_PEER_DEFAULT_ROUND_TRIP_TIME = 500, ENET_PEER_DEFAULT_PACKET_THROTTLE = 32, ENET_PEER_PACKET_THROTTLE_SCALE = 32, ENET_PEER_PACKET_THROTTLE_COUNTER = 7, ENET_PEER_PACKET_THROTTLE_ACCELERATION = 2, ENET_PEER_PACKET_THROTTLE_DECELERATION = 2, ENET_PEER_PACKET_THROTTLE_INTERVAL = 5000, ENET_PEER_PACKET_LOSS_SCALE = (1 << 16), ENET_PEER_PACKET_LOSS_INTERVAL = 10000, ENET_PEER_WINDOW_SIZE_SCALE = 64 * 1024, ENET_PEER_TIMEOUT_LIMIT = 32, ENET_PEER_TIMEOUT_MINIMUM = 5000, ENET_PEER_TIMEOUT_MAXIMUM = 30000, ENET_PEER_PING_INTERVAL = 500, ENET_PEER_UNSEQUENCED_WINDOWS = 64, ENET_PEER_UNSEQUENCED_WINDOW_SIZE = 1024, ENET_PEER_FREE_UNSEQUENCED_WINDOWS = 32, ENET_PEER_RELIABLE_WINDOWS = 16, ENET_PEER_RELIABLE_WINDOW_SIZE = 0x1000, ENET_PEER_FREE_RELIABLE_WINDOWS = 8 }; typedef struct _ENetChannel { enet_uint16 outgoingReliableSequenceNumber; enet_uint16 outgoingUnreliableSequenceNumber; enet_uint16 usedReliableWindows; enet_uint16 reliableWindows [ENET_PEER_RELIABLE_WINDOWS]; enet_uint16 incomingReliableSequenceNumber; enet_uint16 incomingUnreliableSequenceNumber; ENetList incomingReliableCommands; ENetList incomingUnreliableCommands; } ENetChannel; /** * An ENet peer which data packets may be sent or received from. * * No fields should be modified unless otherwise specified. */ typedef struct _ENetPeer { ENetListNode dispatchList; struct _ENetHost * host; enet_uint16 outgoingPeerID; enet_uint16 incomingPeerID; enet_uint32 connectID; enet_uint8 outgoingSessionID; enet_uint8 incomingSessionID; ENetAddress address; /**< Internet address of the peer */ void * data; /**< Application private data, may be freely modified */ ENetPeerState state; ENetChannel * channels; size_t channelCount; /**< Number of channels allocated for communication with peer */ enet_uint32 incomingBandwidth; /**< Downstream bandwidth of the client in bytes/second */ enet_uint32 outgoingBandwidth; /**< Upstream bandwidth of the client in bytes/second */ enet_uint32 incomingBandwidthThrottleEpoch; enet_uint32 outgoingBandwidthThrottleEpoch; enet_uint32 incomingDataTotal; enet_uint32 outgoingDataTotal; enet_uint32 lastSendTime; enet_uint32 lastReceiveTime; enet_uint32 nextTimeout; enet_uint32 earliestTimeout; enet_uint32 packetLossEpoch; enet_uint32 packetsSent; enet_uint32 packetsLost; enet_uint32 packetLoss; /**< mean packet loss of reliable packets as a ratio with respect to the constant ENET_PEER_PACKET_LOSS_SCALE */ enet_uint32 packetLossVariance; enet_uint32 packetThrottle; enet_uint32 packetThrottleLimit; enet_uint32 packetThrottleCounter; enet_uint32 packetThrottleEpoch; enet_uint32 packetThrottleAcceleration; enet_uint32 packetThrottleDeceleration; enet_uint32 packetThrottleInterval; enet_uint32 pingInterval; enet_uint32 timeoutLimit; enet_uint32 timeoutMinimum; enet_uint32 timeoutMaximum; enet_uint32 lastRoundTripTime; enet_uint32 lowestRoundTripTime; enet_uint32 lastRoundTripTimeVariance; enet_uint32 highestRoundTripTimeVariance; enet_uint32 roundTripTime; /**< mean round trip time (RTT), in milliseconds, between sending a reliable packet and receiving its acknowledgement */ enet_uint32 roundTripTimeVariance; enet_uint32 mtu; enet_uint32 windowSize; enet_uint32 reliableDataInTransit; enet_uint16 outgoingReliableSequenceNumber; ENetList acknowledgements; ENetList sentReliableCommands; ENetList sentUnreliableCommands; ENetList outgoingReliableCommands; ENetList outgoingUnreliableCommands; ENetList dispatchedCommands; int needsDispatch; enet_uint16 incomingUnsequencedGroup; enet_uint16 outgoingUnsequencedGroup; enet_uint32 unsequencedWindow [ENET_PEER_UNSEQUENCED_WINDOW_SIZE / 32]; enet_uint32 eventData; } ENetPeer; /** An ENet packet compressor for compressing UDP packets before socket sends or receives. */ typedef struct _ENetCompressor { /** Context data for the compressor. Must be non-NULL. */ void * context; /** Compresses from inBuffers[0:inBufferCount-1], containing inLimit bytes, to outData, outputting at most outLimit bytes. Should return 0 on failure. */ size_t (ENET_CALLBACK * compress) (void * context, const ENetBuffer * inBuffers, size_t inBufferCount, size_t inLimit, enet_uint8 * outData, size_t outLimit); /** Decompresses from inData, containing inLimit bytes, to outData, outputting at most outLimit bytes. Should return 0 on failure. */ size_t (ENET_CALLBACK * decompress) (void * context, const enet_uint8 * inData, size_t inLimit, enet_uint8 * outData, size_t outLimit); /** Destroys the context when compression is disabled or the host is destroyed. May be NULL. */ void (ENET_CALLBACK * destroy) (void * context); } ENetCompressor; /** Callback that computes the checksum of the data held in buffers[0:bufferCount-1] */ typedef enet_uint32 (ENET_CALLBACK * ENetChecksumCallback) (const ENetBuffer * buffers, size_t bufferCount); /** Callback for intercepting received raw UDP packets. Should return 1 to intercept, 0 to ignore, or -1 to propagate an error. */ typedef int (ENET_CALLBACK * ENetInterceptCallback) (struct _ENetHost * host, struct _ENetEvent * event); /** An ENet host for communicating with peers. * * No fields should be modified unless otherwise stated. @sa enet_host_create() @sa enet_host_destroy() @sa enet_host_connect() @sa enet_host_service() @sa enet_host_flush() @sa enet_host_broadcast() @sa enet_host_compress() @sa enet_host_compress_with_range_coder() @sa enet_host_channel_limit() @sa enet_host_bandwidth_limit() @sa enet_host_bandwidth_throttle() */ typedef struct _ENetHost { ENetSocket socket; ENetAddress address; /**< Internet address of the host */ enet_uint32 incomingBandwidth; /**< downstream bandwidth of the host */ enet_uint32 outgoingBandwidth; /**< upstream bandwidth of the host */ enet_uint32 bandwidthThrottleEpoch; enet_uint32 mtu; enet_uint32 randomSeed; int recalculateBandwidthLimits; ENetPeer * peers; /**< array of peers allocated for this host */ size_t peerCount; /**< number of peers allocated for this host */ size_t channelLimit; /**< maximum number of channels allowed for connected peers */ enet_uint32 serviceTime; ENetList dispatchQueue; int continueSending; size_t packetSize; enet_uint16 headerFlags; ENetProtocol commands [ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS]; size_t commandCount; ENetBuffer buffers [ENET_BUFFER_MAXIMUM]; size_t bufferCount; ENetChecksumCallback checksum; /**< callback the user can set to enable packet checksums for this host */ ENetCompressor compressor; enet_uint8 packetData [2][ENET_PROTOCOL_MAXIMUM_MTU]; ENetAddress receivedAddress; enet_uint8 * receivedData; size_t receivedDataLength; enet_uint32 totalSentData; /**< total data sent, user should reset to 0 as needed to prevent overflow */ enet_uint32 totalSentPackets; /**< total UDP packets sent, user should reset to 0 as needed to prevent overflow */ enet_uint32 totalReceivedData; /**< total data received, user should reset to 0 as needed to prevent overflow */ enet_uint32 totalReceivedPackets; /**< total UDP packets received, user should reset to 0 as needed to prevent overflow */ ENetInterceptCallback intercept; /**< callback the user can set to intercept received raw UDP packets */ } ENetHost; /** * An ENet event type, as specified in @ref ENetEvent. */ typedef enum _ENetEventType { /** no event occurred within the specified time limit */ ENET_EVENT_TYPE_NONE = 0, /** a connection request initiated by enet_host_connect has completed. * The peer field contains the peer which successfully connected. */ ENET_EVENT_TYPE_CONNECT = 1, /** a peer has disconnected. This event is generated on a successful * completion of a disconnect initiated by enet_pper_disconnect, if * a peer has timed out, or if a connection request intialized by * enet_host_connect has timed out. The peer field contains the peer * which disconnected. The data field contains user supplied data * describing the disconnection, or 0, if none is available. */ ENET_EVENT_TYPE_DISCONNECT = 2, /** a packet has been received from a peer. The peer field specifies the * peer which sent the packet. The channelID field specifies the channel * number upon which the packet was received. The packet field contains * the packet that was received; this packet must be destroyed with * enet_packet_destroy after use. */ ENET_EVENT_TYPE_RECEIVE = 3 } ENetEventType; /** * An ENet event as returned by enet_host_service(). @sa enet_host_service */ typedef struct _ENetEvent { ENetEventType type; /**< type of the event */ ENetPeer * peer; /**< peer that generated a connect, disconnect or receive event */ enet_uint8 channelID; /**< channel on the peer that generated the event, if appropriate */ enet_uint32 data; /**< data associated with the event, if appropriate */ ENetPacket * packet; /**< packet associated with the event, if appropriate */ } ENetEvent; /** @defgroup global ENet global functions @{ */ /** Initializes ENet globally. Must be called prior to using any functions in ENet. @returns 0 on success, < 0 on failure */ ENET_API int enet_initialize (void); /** Initializes ENet globally and supplies user-overridden callbacks. Must be called prior to using any functions in ENet. Do not use enet_initialize() if you use this variant. Make sure the ENetCallbacks structure is zeroed out so that any additional callbacks added in future versions will be properly ignored. @param version the constant ENET_VERSION should be supplied so ENet knows which version of ENetCallbacks struct to use @param inits user-overriden callbacks where any NULL callbacks will use ENet's defaults @returns 0 on success, < 0 on failure */ ENET_API int enet_initialize_with_callbacks (ENetVersion version, const ENetCallbacks * inits); /** Shuts down ENet globally. Should be called when a program that has initialized ENet exits. */ ENET_API void enet_deinitialize (void); /** @} */ /** @defgroup private ENet private implementation functions */ /** Returns the wall-time in milliseconds. Its initial value is unspecified unless otherwise set. */ ENET_API enet_uint32 enet_time_get (void); /** Sets the current wall-time in milliseconds. */ ENET_API void enet_time_set (enet_uint32); /** @defgroup socket ENet socket functions @{ */ ENET_API ENetSocket enet_socket_create (ENetSocketType); ENET_API int enet_socket_bind (ENetSocket, const ENetAddress *); ENET_API int enet_socket_listen (ENetSocket, int); ENET_API ENetSocket enet_socket_accept (ENetSocket, ENetAddress *); ENET_API int enet_socket_connect (ENetSocket, const ENetAddress *); ENET_API int enet_socket_send (ENetSocket, const ENetAddress *, const ENetBuffer *, size_t); ENET_API int enet_socket_receive (ENetSocket, ENetAddress *, ENetBuffer *, size_t); ENET_API int enet_socket_wait (ENetSocket, enet_uint32 *, enet_uint32); ENET_API int enet_socket_set_option (ENetSocket, ENetSocketOption, int); ENET_API int enet_socket_shutdown (ENetSocket, ENetSocketShutdown); ENET_API void enet_socket_destroy (ENetSocket); ENET_API int enet_socketset_select (ENetSocket, ENetSocketSet *, ENetSocketSet *, enet_uint32); /** @} */ /** @defgroup Address ENet address functions @{ */ /** Attempts to resolve the host named by the parameter hostName and sets the host field in the address parameter if successful. @param address destination to store resolved address @param hostName host name to lookup @retval 0 on success @retval < 0 on failure @returns the address of the given hostName in address on success */ ENET_API int enet_address_set_host (ENetAddress * address, const char * hostName); /** Gives the printable form of the ip address specified in the address parameter. @param address address printed @param hostName destination for name, must not be NULL @param nameLength maximum length of hostName. @returns the null-terminated name of the host in hostName on success @retval 0 on success @retval < 0 on failure */ ENET_API int enet_address_get_host_ip (const ENetAddress * address, char * hostName, size_t nameLength); /** Attempts to do a reverse lookup of the host field in the address parameter. @param address address used for reverse lookup @param hostName destination for name, must not be NULL @param nameLength maximum length of hostName. @returns the null-terminated name of the host in hostName on success @retval 0 on success @retval < 0 on failure */ ENET_API int enet_address_get_host (const ENetAddress * address, char * hostName, size_t nameLength); /** @} */ ENET_API ENetPacket * enet_packet_create (const void *, size_t, enet_uint32); ENET_API void enet_packet_destroy (ENetPacket *); ENET_API int enet_packet_resize (ENetPacket *, size_t); ENET_API enet_uint32 enet_crc32 (const ENetBuffer *, size_t); ENET_API void enet_crc32_inc (enet_uint32 *crc, enet_uint8 byte); ENET_API ENetHost * enet_host_create (const ENetAddress *, size_t, size_t, enet_uint32, enet_uint32); ENET_API void enet_host_destroy (ENetHost *); ENET_API ENetPeer * enet_host_connect (ENetHost *, const ENetAddress *, size_t, enet_uint32); ENET_API int enet_host_check_events (ENetHost *, ENetEvent *); ENET_API int enet_host_service (ENetHost *, ENetEvent *, enet_uint32); ENET_API void enet_host_flush (ENetHost *); ENET_API void enet_host_broadcast (ENetHost *, enet_uint8, ENetPacket *); ENET_API void enet_host_compress (ENetHost *, const ENetCompressor *); ENET_API int enet_host_compress_with_range_coder (ENetHost * host); ENET_API void enet_host_channel_limit (ENetHost *, size_t); ENET_API void enet_host_bandwidth_limit (ENetHost *, enet_uint32, enet_uint32); extern void enet_host_bandwidth_throttle (ENetHost *); ENET_API int enet_peer_send (ENetPeer *, enet_uint8, ENetPacket *); ENET_API ENetPacket * enet_peer_receive (ENetPeer *, enet_uint8 * channelID); ENET_API void enet_peer_ping (ENetPeer *); ENET_API void enet_peer_ping_interval (ENetPeer *, enet_uint32); ENET_API void enet_peer_timeout (ENetPeer *, enet_uint32, enet_uint32, enet_uint32); ENET_API void enet_peer_reset (ENetPeer *); ENET_API void enet_peer_disconnect (ENetPeer *, enet_uint32); ENET_API void enet_peer_disconnect_now (ENetPeer *, enet_uint32); ENET_API void enet_peer_disconnect_later (ENetPeer *, enet_uint32); ENET_API void enet_peer_throttle_configure (ENetPeer *, enet_uint32, enet_uint32, enet_uint32); extern int enet_peer_throttle (ENetPeer *, enet_uint32); extern void enet_peer_reset_queues (ENetPeer *); extern void enet_peer_setup_outgoing_command (ENetPeer *, ENetOutgoingCommand *); extern ENetOutgoingCommand * enet_peer_queue_outgoing_command (ENetPeer *, const ENetProtocol *, ENetPacket *, enet_uint32, enet_uint16); extern ENetIncomingCommand * enet_peer_queue_incoming_command (ENetPeer *, const ENetProtocol *, ENetPacket *, enet_uint32); extern ENetAcknowledgement * enet_peer_queue_acknowledgement (ENetPeer *, const ENetProtocol *, enet_uint16); extern void enet_peer_dispatch_incoming_unreliable_commands (ENetPeer *, ENetChannel *); extern void enet_peer_dispatch_incoming_reliable_commands (ENetPeer *, ENetChannel *); ENET_API void * enet_range_coder_create (void); ENET_API void enet_range_coder_destroy (void *); ENET_API size_t enet_range_coder_compress (void *, const ENetBuffer *, size_t, size_t, enet_uint8 *, size_t); ENET_API size_t enet_range_coder_decompress (void *, const enet_uint8 *, size_t, enet_uint8 *, size_t); extern size_t enet_protocol_command_size (enet_uint8); #ifdef __cplusplus } #endif #endif /* __ENET_ENET_H__ */ assaultcube-1.2.0.2.1/source/enet/include/enet/list.h000066400000000000000000000021111352165075300222630ustar00rootroot00000000000000/** @file list.h @brief ENet list management */ #ifndef __ENET_LIST_H__ #define __ENET_LIST_H__ #include typedef struct _ENetListNode { struct _ENetListNode * next; struct _ENetListNode * previous; } ENetListNode; typedef ENetListNode * ENetListIterator; typedef struct _ENetList { ENetListNode sentinel; } ENetList; extern void enet_list_clear (ENetList *); extern ENetListIterator enet_list_insert (ENetListIterator, void *); extern void * enet_list_remove (ENetListIterator); extern ENetListIterator enet_list_move (ENetListIterator, void *, void *); extern size_t enet_list_size (ENetList *); #define enet_list_begin(list) ((list) -> sentinel.next) #define enet_list_end(list) (& (list) -> sentinel) #define enet_list_empty(list) (enet_list_begin (list) == enet_list_end (list)) #define enet_list_next(iterator) ((iterator) -> next) #define enet_list_previous(iterator) ((iterator) -> previous) #define enet_list_front(list) ((void *) (list) -> sentinel.next) #define enet_list_back(list) ((void *) (list) -> sentinel.previous) #endif /* __ENET_LIST_H__ */ assaultcube-1.2.0.2.1/source/enet/include/enet/protocol.h000066400000000000000000000132361352165075300231630ustar00rootroot00000000000000/** @file protocol.h @brief ENet protocol */ #ifndef __ENET_PROTOCOL_H__ #define __ENET_PROTOCOL_H__ #include "enet/types.h" enum { ENET_PROTOCOL_MINIMUM_MTU = 576, ENET_PROTOCOL_MAXIMUM_MTU = 4096, ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS = 32, ENET_PROTOCOL_MINIMUM_WINDOW_SIZE = 4096, ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE = 32768, ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT = 1, ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT = 255, ENET_PROTOCOL_MAXIMUM_PEER_ID = 0xFFF, ENET_PROTOCOL_MAXIMUM_PACKET_SIZE = 1024 * 1024 * 1024, ENET_PROTOCOL_MAXIMUM_FRAGMENT_COUNT = 1024 * 1024 }; typedef enum _ENetProtocolCommand { ENET_PROTOCOL_COMMAND_NONE = 0, ENET_PROTOCOL_COMMAND_ACKNOWLEDGE = 1, ENET_PROTOCOL_COMMAND_CONNECT = 2, ENET_PROTOCOL_COMMAND_VERIFY_CONNECT = 3, ENET_PROTOCOL_COMMAND_DISCONNECT = 4, ENET_PROTOCOL_COMMAND_PING = 5, ENET_PROTOCOL_COMMAND_SEND_RELIABLE = 6, ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE = 7, ENET_PROTOCOL_COMMAND_SEND_FRAGMENT = 8, ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED = 9, ENET_PROTOCOL_COMMAND_BANDWIDTH_LIMIT = 10, ENET_PROTOCOL_COMMAND_THROTTLE_CONFIGURE = 11, ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE_FRAGMENT = 12, ENET_PROTOCOL_COMMAND_COUNT = 13, ENET_PROTOCOL_COMMAND_MASK = 0x0F } ENetProtocolCommand; typedef enum _ENetProtocolFlag { ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE = (1 << 7), ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED = (1 << 6), ENET_PROTOCOL_HEADER_FLAG_COMPRESSED = (1 << 14), ENET_PROTOCOL_HEADER_FLAG_SENT_TIME = (1 << 15), ENET_PROTOCOL_HEADER_FLAG_MASK = ENET_PROTOCOL_HEADER_FLAG_COMPRESSED | ENET_PROTOCOL_HEADER_FLAG_SENT_TIME, ENET_PROTOCOL_HEADER_SESSION_MASK = (3 << 12), ENET_PROTOCOL_HEADER_SESSION_SHIFT = 12 } ENetProtocolFlag; #ifdef _MSC_VER_ #pragma pack(push, 1) #define ENET_PACKED #elif defined(__GNUC__) #define ENET_PACKED __attribute__ ((packed)) #else #define ENET_PACKED #endif typedef struct _ENetProtocolHeader { enet_uint16 peerID; enet_uint16 sentTime; } ENET_PACKED ENetProtocolHeader; typedef struct _ENetProtocolCommandHeader { enet_uint8 command; enet_uint8 channelID; enet_uint16 reliableSequenceNumber; } ENET_PACKED ENetProtocolCommandHeader; typedef struct _ENetProtocolAcknowledge { ENetProtocolCommandHeader header; enet_uint16 receivedReliableSequenceNumber; enet_uint16 receivedSentTime; } ENET_PACKED ENetProtocolAcknowledge; typedef struct _ENetProtocolConnect { ENetProtocolCommandHeader header; enet_uint16 outgoingPeerID; enet_uint8 incomingSessionID; enet_uint8 outgoingSessionID; enet_uint32 mtu; enet_uint32 windowSize; enet_uint32 channelCount; enet_uint32 incomingBandwidth; enet_uint32 outgoingBandwidth; enet_uint32 packetThrottleInterval; enet_uint32 packetThrottleAcceleration; enet_uint32 packetThrottleDeceleration; enet_uint32 connectID; enet_uint32 data; } ENET_PACKED ENetProtocolConnect; typedef struct _ENetProtocolVerifyConnect { ENetProtocolCommandHeader header; enet_uint16 outgoingPeerID; enet_uint8 incomingSessionID; enet_uint8 outgoingSessionID; enet_uint32 mtu; enet_uint32 windowSize; enet_uint32 channelCount; enet_uint32 incomingBandwidth; enet_uint32 outgoingBandwidth; enet_uint32 packetThrottleInterval; enet_uint32 packetThrottleAcceleration; enet_uint32 packetThrottleDeceleration; enet_uint32 connectID; } ENET_PACKED ENetProtocolVerifyConnect; typedef struct _ENetProtocolBandwidthLimit { ENetProtocolCommandHeader header; enet_uint32 incomingBandwidth; enet_uint32 outgoingBandwidth; } ENET_PACKED ENetProtocolBandwidthLimit; typedef struct _ENetProtocolThrottleConfigure { ENetProtocolCommandHeader header; enet_uint32 packetThrottleInterval; enet_uint32 packetThrottleAcceleration; enet_uint32 packetThrottleDeceleration; } ENET_PACKED ENetProtocolThrottleConfigure; typedef struct _ENetProtocolDisconnect { ENetProtocolCommandHeader header; enet_uint32 data; } ENET_PACKED ENetProtocolDisconnect; typedef struct _ENetProtocolPing { ENetProtocolCommandHeader header; } ENET_PACKED ENetProtocolPing; typedef struct _ENetProtocolSendReliable { ENetProtocolCommandHeader header; enet_uint16 dataLength; } ENET_PACKED ENetProtocolSendReliable; typedef struct _ENetProtocolSendUnreliable { ENetProtocolCommandHeader header; enet_uint16 unreliableSequenceNumber; enet_uint16 dataLength; } ENET_PACKED ENetProtocolSendUnreliable; typedef struct _ENetProtocolSendUnsequenced { ENetProtocolCommandHeader header; enet_uint16 unsequencedGroup; enet_uint16 dataLength; } ENET_PACKED ENetProtocolSendUnsequenced; typedef struct _ENetProtocolSendFragment { ENetProtocolCommandHeader header; enet_uint16 startSequenceNumber; enet_uint16 dataLength; enet_uint32 fragmentCount; enet_uint32 fragmentNumber; enet_uint32 totalLength; enet_uint32 fragmentOffset; } ENET_PACKED ENetProtocolSendFragment; typedef union _ENetProtocol { ENetProtocolCommandHeader header; ENetProtocolAcknowledge acknowledge; ENetProtocolConnect connect; ENetProtocolVerifyConnect verifyConnect; ENetProtocolDisconnect disconnect; ENetProtocolPing ping; ENetProtocolSendReliable sendReliable; ENetProtocolSendUnreliable sendUnreliable; ENetProtocolSendUnsequenced sendUnsequenced; ENetProtocolSendFragment sendFragment; ENetProtocolBandwidthLimit bandwidthLimit; ENetProtocolThrottleConfigure throttleConfigure; } ENET_PACKED ENetProtocol; #ifdef _MSC_VER_ #pragma pack(pop) #endif #endif /* __ENET_PROTOCOL_H__ */ assaultcube-1.2.0.2.1/source/enet/include/enet/time.h000066400000000000000000000010211352165075300222450ustar00rootroot00000000000000/** @file time.h @brief ENet time constants and macros */ #ifndef __ENET_TIME_H__ #define __ENET_TIME_H__ #define ENET_TIME_OVERFLOW 86400000 #define ENET_TIME_LESS(a, b) ((a) - (b) >= ENET_TIME_OVERFLOW) #define ENET_TIME_GREATER(a, b) ((b) - (a) >= ENET_TIME_OVERFLOW) #define ENET_TIME_LESS_EQUAL(a, b) (! ENET_TIME_GREATER (a, b)) #define ENET_TIME_GREATER_EQUAL(a, b) (! ENET_TIME_LESS (a, b)) #define ENET_TIME_DIFFERENCE(a, b) ((a) - (b) >= ENET_TIME_OVERFLOW ? (b) - (a) : (a) - (b)) #endif /* __ENET_TIME_H__ */ assaultcube-1.2.0.2.1/source/enet/include/enet/types.h000066400000000000000000000005321352165075300224610ustar00rootroot00000000000000/** @file types.h @brief type definitions for ENet */ #ifndef __ENET_TYPES_H__ #define __ENET_TYPES_H__ typedef unsigned char enet_uint8; /**< unsigned 8-bit type */ typedef unsigned short enet_uint16; /**< unsigned 16-bit type */ typedef unsigned int enet_uint32; /**< unsigned 32-bit type */ #endif /* __ENET_TYPES_H__ */ assaultcube-1.2.0.2.1/source/enet/include/enet/unix.h000066400000000000000000000023211352165075300222760ustar00rootroot00000000000000/** @file unix.h @brief ENet Unix header */ #ifndef __ENET_UNIX_H__ #define __ENET_UNIX_H__ #include #include #include #include #include typedef int ENetSocket; enum { ENET_SOCKET_NULL = -1 }; #define ENET_HOST_TO_NET_16(value) (htons (value)) /**< macro that converts host to net byte-order of a 16-bit value */ #define ENET_HOST_TO_NET_32(value) (htonl (value)) /**< macro that converts host to net byte-order of a 32-bit value */ #define ENET_NET_TO_HOST_16(value) (ntohs (value)) /**< macro that converts net to host byte-order of a 16-bit value */ #define ENET_NET_TO_HOST_32(value) (ntohl (value)) /**< macro that converts net to host byte-order of a 32-bit value */ typedef struct { void * data; size_t dataLength; } ENetBuffer; #define ENET_CALLBACK #define ENET_API extern typedef fd_set ENetSocketSet; #define ENET_SOCKETSET_EMPTY(sockset) FD_ZERO (& (sockset)) #define ENET_SOCKETSET_ADD(sockset, socket) FD_SET (socket, & (sockset)) #define ENET_SOCKETSET_REMOVE(sockset, socket) FD_CLEAR (socket, & (sockset)) #define ENET_SOCKETSET_CHECK(sockset, socket) FD_ISSET (socket, & (sockset)) #endif /* __ENET_UNIX_H__ */ assaultcube-1.2.0.2.1/source/enet/include/enet/utility.h000066400000000000000000000003541352165075300230220ustar00rootroot00000000000000/** @file utility.h @brief ENet utility header */ #ifndef __ENET_UTILITY_H__ #define __ENET_UTILITY_H__ #define ENET_MAX(x, y) ((x) > (y) ? (x) : (y)) #define ENET_MIN(x, y) ((x) < (y) ? (x) : (y)) #endif /* __ENET_UTILITY_H__ */ assaultcube-1.2.0.2.1/source/enet/include/enet/win32.h000066400000000000000000000026011352165075300222560ustar00rootroot00000000000000/** @file win32.h @brief ENet Win32 header */ #ifndef __ENET_WIN32_H__ #define __ENET_WIN32_H__ #ifdef ENET_BUILDING_LIB #pragma warning (disable: 4996) // 'strncpy' was declared deprecated #pragma warning (disable: 4267) // size_t to int conversion #pragma warning (disable: 4244) // 64bit to 32bit int #pragma warning (disable: 4018) // signed/unsigned mismatch #endif #include #include typedef SOCKET ENetSocket; enum { ENET_SOCKET_NULL = INVALID_SOCKET }; #define ENET_HOST_TO_NET_16(value) (htons (value)) #define ENET_HOST_TO_NET_32(value) (htonl (value)) #define ENET_NET_TO_HOST_16(value) (ntohs (value)) #define ENET_NET_TO_HOST_32(value) (ntohl (value)) typedef struct { size_t dataLength; void * data; } ENetBuffer; #define ENET_CALLBACK __cdecl #if defined ENET_DLL #if defined ENET_BUILDING_LIB #define ENET_API __declspec( dllexport ) #else #define ENET_API __declspec( dllimport ) #endif /* ENET_BUILDING_LIB */ #else /* !ENET_DLL */ #define ENET_API extern #endif /* ENET_DLL */ typedef fd_set ENetSocketSet; #define ENET_SOCKETSET_EMPTY(sockset) FD_ZERO (& (sockset)) #define ENET_SOCKETSET_ADD(sockset, socket) FD_SET (socket, & (sockset)) #define ENET_SOCKETSET_REMOVE(sockset, socket) FD_CLEAR (socket, & (sockset)) #define ENET_SOCKETSET_CHECK(sockset, socket) FD_ISSET (socket, & (sockset)) #endif /* __ENET_WIN32_H__ */ assaultcube-1.2.0.2.1/source/enet/install-sh000077500000000000000000000360101352165075300205720ustar00rootroot00000000000000#!/bin/sh # install - install a program, script, or datafile scriptversion=2018-03-11.20; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. tab=' ' nl=' ' IFS=" $tab$nl" # Set DOITPROG to "echo" to test this script. doit=${DOITPROG-} doit_exec=${doit:-exec} # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false is_target_a_directory=possibly usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) is_target_a_directory=always dst_arg=$2 # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) is_target_a_directory=never;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done # We allow the use of options -d and -T together, by making -d # take the precedence; this is for compatibility with GNU install. if test -n "$dir_arg"; then if test -n "$dst_arg"; then echo "$0: target directory not allowed when installing a directory." >&2 exit 1 fi fi if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call 'install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then if test $# -gt 1 || test "$is_target_a_directory" = always; then if test ! -d "$dst_arg"; then echo "$0: $dst_arg: Is not a directory." >&2 exit 1 fi fi fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for 'test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename. if test -d "$dst"; then if test "$is_target_a_directory" = never; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dstbase=`basename "$src"` case $dst in */) dst=$dst$dstbase;; *) dst=$dst/$dstbase;; esac dstdir_status=0 else dstdir=`dirname "$dst"` test -d "$dstdir" dstdir_status=$? fi fi case $dstdir in */) dstdirslash=$dstdir;; *) dstdirslash=$dstdir/;; esac obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) # Note that $RANDOM variable is not portable (e.g. dash); Use it # here however when possible just to lower collision chance. tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0 # Because "mkdir -p" follows existing symlinks and we likely work # directly in world-writeable /tmp, make sure that the '$tmpdir' # directory is successfully created first before we actually test # 'mkdir -p' feature. if (umask $mkdir_umask && $mkdirprog $mkdir_mode "$tmpdir" && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. test_tmpdir="$tmpdir/a" ls_ld_tmpdir=`ls -ld "$test_tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; [-=\(\)!]*) prefix='./';; *) prefix='';; esac oIFS=$IFS IFS=/ set -f set fnord $dstdir shift set +f IFS=$oIFS prefixes= for d do test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=${dstdirslash}_inst.$$_ rmtmp=${dstdirslash}_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: assaultcube-1.2.0.2.1/source/enet/libenet.pc.in000066400000000000000000000004041352165075300211370ustar00rootroot00000000000000prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: @PACKAGE_NAME@ Description: Low-latency UDP networking library supporting optional reliability Version: @PACKAGE_VERSION@ Cflags: -I${includedir} Libs: -L${libdir} -lenet assaultcube-1.2.0.2.1/source/enet/list.c000066400000000000000000000030421352165075300177040ustar00rootroot00000000000000/** @file list.c @brief ENet linked list functions */ #define ENET_BUILDING_LIB 1 #include "enet/enet.h" /** @defgroup list ENet linked list utility functions @ingroup private @{ */ void enet_list_clear (ENetList * list) { list -> sentinel.next = & list -> sentinel; list -> sentinel.previous = & list -> sentinel; } ENetListIterator enet_list_insert (ENetListIterator position, void * data) { ENetListIterator result = (ENetListIterator) data; result -> previous = position -> previous; result -> next = position; result -> previous -> next = result; position -> previous = result; return result; } void * enet_list_remove (ENetListIterator position) { position -> previous -> next = position -> next; position -> next -> previous = position -> previous; return position; } ENetListIterator enet_list_move (ENetListIterator position, void * dataFirst, void * dataLast) { ENetListIterator first = (ENetListIterator) dataFirst, last = (ENetListIterator) dataLast; first -> previous -> next = last -> next; last -> next -> previous = first -> previous; first -> previous = position -> previous; last -> next = position; first -> previous -> next = first; position -> previous = last; return first; } size_t enet_list_size (ENetList * list) { size_t size = 0; ENetListIterator position; for (position = enet_list_begin (list); position != enet_list_end (list); position = enet_list_next (position)) ++ size; return size; } /** @} */ assaultcube-1.2.0.2.1/source/enet/ltmain.sh000066400000000000000000011767121352165075300204250ustar00rootroot00000000000000#! /bin/sh ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in ## by inline-source v2014-01-03.01 # libtool (GNU libtool) 2.4.6 # Provide generalized library-building support services. # Written by Gordon Matzigkeit , 1996 # Copyright (C) 1996-2015 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . PROGRAM=libtool PACKAGE=libtool VERSION="2.4.6 Debian-2.4.6-9" package_revision=2.4.6 ## ------ ## ## Usage. ## ## ------ ## # Run './libtool --help' for help with using this script from the # command line. ## ------------------------------- ## ## User overridable command paths. ## ## ------------------------------- ## # After configure completes, it has a better idea of some of the # shell tools we need than the defaults used by the functions shared # with bootstrap, so set those here where they can still be over- # ridden by the user, but otherwise take precedence. : ${AUTOCONF="autoconf"} : ${AUTOMAKE="automake"} ## -------------------------- ## ## Source external libraries. ## ## -------------------------- ## # Much of our low-level functionality needs to be sourced from external # libraries, which are installed to $pkgauxdir. # Set a version string for this script. scriptversion=2015-01-20.17; # UTC # General shell script boiler plate, and helper functions. # Written by Gary V. Vaughan, 2004 # Copyright (C) 2004-2015 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # As a special exception to the GNU General Public License, if you distribute # this file as part of a program or library that is built using GNU Libtool, # you may include this file under the same distribution terms that you use # for the rest of that program. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # Please report bugs or propose patches to gary@gnu.org. ## ------ ## ## Usage. ## ## ------ ## # Evaluate this file near the top of your script to gain access to # the functions and variables defined here: # # . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh # # If you need to override any of the default environment variable # settings, do that before evaluating this file. ## -------------------- ## ## Shell normalisation. ## ## -------------------- ## # Some shells need a little help to be as Bourne compatible as possible. # Before doing anything else, make sure all that help has been provided! DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi # NLS nuisances: We save the old values in case they are required later. _G_user_locale= _G_safe_locale= for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test set = \"\${$_G_var+set}\"; then save_$_G_var=\$$_G_var $_G_var=C export $_G_var _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" fi" done # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Make sure IFS has a sensible default sp=' ' nl=' ' IFS="$sp $nl" # There are apparently some retarded systems that use ';' as a PATH separator! if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi ## ------------------------- ## ## Locate command utilities. ## ## ------------------------- ## # func_executable_p FILE # ---------------------- # Check that FILE is an executable regular file. func_executable_p () { test -f "$1" && test -x "$1" } # func_path_progs PROGS_LIST CHECK_FUNC [PATH] # -------------------------------------------- # Search for either a program that responds to --version with output # containing "GNU", or else returned by CHECK_FUNC otherwise, by # trying all the directories in PATH with each of the elements of # PROGS_LIST. # # CHECK_FUNC should accept the path to a candidate program, and # set $func_check_prog_result if it truncates its output less than # $_G_path_prog_max characters. func_path_progs () { _G_progs_list=$1 _G_check_func=$2 _G_PATH=${3-"$PATH"} _G_path_prog_max=0 _G_path_prog_found=false _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} for _G_dir in $_G_PATH; do IFS=$_G_save_IFS test -z "$_G_dir" && _G_dir=. for _G_prog_name in $_G_progs_list; do for _exeext in '' .EXE; do _G_path_prog=$_G_dir/$_G_prog_name$_exeext func_executable_p "$_G_path_prog" || continue case `"$_G_path_prog" --version 2>&1` in *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; *) $_G_check_func $_G_path_prog func_path_progs_result=$func_check_prog_result ;; esac $_G_path_prog_found && break 3 done done done IFS=$_G_save_IFS test -z "$func_path_progs_result" && { echo "no acceptable sed could be found in \$PATH" >&2 exit 1 } } # We want to be able to use the functions in this file before configure # has figured out where the best binaries are kept, which means we have # to search for them ourselves - except when the results are already set # where we skip the searches. # Unless the user overrides by setting SED, search the path for either GNU # sed, or the sed that truncates its output the least. test -z "$SED" && { _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for _G_i in 1 2 3 4 5 6 7; do _G_sed_script=$_G_sed_script$nl$_G_sed_script done echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed _G_sed_script= func_check_prog_sed () { _G_path_prog=$1 _G_count=0 printf 0123456789 >conftest.in while : do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo '' >> conftest.nl "$_G_path_prog" -f conftest.sed conftest.out 2>/dev/null || break diff conftest.out conftest.nl >/dev/null 2>&1 || break _G_count=`expr $_G_count + 1` if test "$_G_count" -gt "$_G_path_prog_max"; then # Best one so far, save it but keep looking for a better one func_check_prog_result=$_G_path_prog _G_path_prog_max=$_G_count fi # 10*(2^10) chars as input seems more than enough test 10 -lt "$_G_count" && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out } func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin rm -f conftest.sed SED=$func_path_progs_result } # Unless the user overrides by setting GREP, search the path for either GNU # grep, or the grep that truncates its output the least. test -z "$GREP" && { func_check_prog_grep () { _G_path_prog=$1 _G_count=0 _G_path_prog_max=0 printf 0123456789 >conftest.in while : do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo 'GREP' >> conftest.nl "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' conftest.out 2>/dev/null || break diff conftest.out conftest.nl >/dev/null 2>&1 || break _G_count=`expr $_G_count + 1` if test "$_G_count" -gt "$_G_path_prog_max"; then # Best one so far, save it but keep looking for a better one func_check_prog_result=$_G_path_prog _G_path_prog_max=$_G_count fi # 10*(2^10) chars as input seems more than enough test 10 -lt "$_G_count" && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out } func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin GREP=$func_path_progs_result } ## ------------------------------- ## ## User overridable command paths. ## ## ------------------------------- ## # All uppercase variable names are used for environment variables. These # variables can be overridden by the user before calling a script that # uses them if a suitable command of that name is not already available # in the command search PATH. : ${CP="cp -f"} : ${ECHO="printf %s\n"} : ${EGREP="$GREP -E"} : ${FGREP="$GREP -F"} : ${LN_S="ln -s"} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} : ${SHELL="${CONFIG_SHELL-/bin/sh}"} ## -------------------- ## ## Useful sed snippets. ## ## -------------------- ## sed_dirname='s|/[^/]*$||' sed_basename='s|^.*/||' # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='s|\([`"$\\]\)|\\\1|g' # Same as above, but do not quote variable references. sed_double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution that turns a string into a regex matching for the # string literally. sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' # Sed substitution that converts a w32 file name or path # that contains forward slashes, into one that contains # (escaped) backslashes. A very naive implementation. sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' # Re-'\' parameter expansions in output of sed_double_quote_subst that # were '\'-ed in input to the same. If an odd number of '\' preceded a # '$' in input to sed_double_quote_subst, that '$' was protected from # expansion. Since each input '\' is now two '\'s, look for any number # of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. _G_bs='\\' _G_bs2='\\\\' _G_bs4='\\\\\\\\' _G_dollar='\$' sed_double_backslash="\ s/$_G_bs4/&\\ /g s/^$_G_bs2$_G_dollar/$_G_bs&/ s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g s/\n//g" ## ----------------- ## ## Global variables. ## ## ----------------- ## # Except for the global variables explicitly listed below, the following # functions in the '^func_' namespace, and the '^require_' namespace # variables initialised in the 'Resource management' section, sourcing # this file will not pollute your global namespace with anything # else. There's no portable way to scope variables in Bourne shell # though, so actually running these functions will sometimes place # results into a variable named after the function, and often use # temporary variables in the '^_G_' namespace. If you are careful to # avoid using those namespaces casually in your sourcing script, things # should continue to work as you expect. And, of course, you can freely # overwrite any of the functions or variables defined here before # calling anything to customize them. EXIT_SUCCESS=0 EXIT_FAILURE=1 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. # Allow overriding, eg assuming that you follow the convention of # putting '$debug_cmd' at the start of all your functions, you can get # bash to show function call trace with: # # debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name debug_cmd=${debug_cmd-":"} exit_cmd=: # By convention, finish your script with: # # exit $exit_status # # so that you can set exit_status to non-zero if you want to indicate # something went wrong during execution without actually bailing out at # the point of failure. exit_status=$EXIT_SUCCESS # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh # is ksh but when the shell is invoked as "sh" and the current value of # the _XPG environment variable is not equal to 1 (one), the special # positional parameter $0, within a function call, is the name of the # function. progpath=$0 # The name of this program. progname=`$ECHO "$progpath" |$SED "$sed_basename"` # Make sure we have an absolute progpath for reexecution: case $progpath in [\\/]*|[A-Za-z]:\\*) ;; *[\\/]*) progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` progdir=`cd "$progdir" && pwd` progpath=$progdir/$progname ;; *) _G_IFS=$IFS IFS=${PATH_SEPARATOR-:} for progdir in $PATH; do IFS=$_G_IFS test -x "$progdir/$progname" && break done IFS=$_G_IFS test -n "$progdir" || progdir=`pwd` progpath=$progdir/$progname ;; esac ## ----------------- ## ## Standard options. ## ## ----------------- ## # The following options affect the operation of the functions defined # below, and should be set appropriately depending on run-time para- # meters passed on the command line. opt_dry_run=false opt_quiet=false opt_verbose=false # Categories 'all' and 'none' are always available. Append any others # you will pass as the first argument to func_warning from your own # code. warning_categories= # By default, display warnings according to 'opt_warning_types'. Set # 'warning_func' to ':' to elide all warnings, or func_fatal_error to # treat the next displayed warning as a fatal error. warning_func=func_warn_and_continue # Set to 'all' to display all warnings, 'none' to suppress all # warnings, or a space delimited list of some subset of # 'warning_categories' to display only the listed warnings. opt_warning_types=all ## -------------------- ## ## Resource management. ## ## -------------------- ## # This section contains definitions for functions that each ensure a # particular resource (a file, or a non-empty configuration variable for # example) is available, and if appropriate to extract default values # from pertinent package files. Call them using their associated # 'require_*' variable to ensure that they are executed, at most, once. # # It's entirely deliberate that calling these functions can set # variables that don't obey the namespace limitations obeyed by the rest # of this file, in order that that they be as useful as possible to # callers. # require_term_colors # ------------------- # Allow display of bold text on terminals that support it. require_term_colors=func_require_term_colors func_require_term_colors () { $debug_cmd test -t 1 && { # COLORTERM and USE_ANSI_COLORS environment variables take # precedence, because most terminfo databases neglect to describe # whether color sequences are supported. test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} if test 1 = "$USE_ANSI_COLORS"; then # Standard ANSI escape sequences tc_reset='' tc_bold=''; tc_standout='' tc_red=''; tc_green='' tc_blue=''; tc_cyan='' else # Otherwise trust the terminfo database after all. test -n "`tput sgr0 2>/dev/null`" && { tc_reset=`tput sgr0` test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` tc_standout=$tc_bold test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` } fi } require_term_colors=: } ## ----------------- ## ## Function library. ## ## ----------------- ## # This section contains a variety of useful functions to call in your # scripts. Take note of the portable wrappers for features provided by # some modern shells, which will fall back to slower equivalents on # less featureful shells. # func_append VAR VALUE # --------------------- # Append VALUE onto the existing contents of VAR. # We should try to minimise forks, especially on Windows where they are # unreasonably slow, so skip the feature probes when bash or zsh are # being used: if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then : ${_G_HAVE_ARITH_OP="yes"} : ${_G_HAVE_XSI_OPS="yes"} # The += operator was introduced in bash 3.1 case $BASH_VERSION in [12].* | 3.0 | 3.0*) ;; *) : ${_G_HAVE_PLUSEQ_OP="yes"} ;; esac fi # _G_HAVE_PLUSEQ_OP # Can be empty, in which case the shell is probed, "yes" if += is # useable or anything else if it does not work. test -z "$_G_HAVE_PLUSEQ_OP" \ && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ && _G_HAVE_PLUSEQ_OP=yes if test yes = "$_G_HAVE_PLUSEQ_OP" then # This is an XSI compatible shell, allowing a faster implementation... eval 'func_append () { $debug_cmd eval "$1+=\$2" }' else # ...otherwise fall back to using expr, which is often a shell builtin. func_append () { $debug_cmd eval "$1=\$$1\$2" } fi # func_append_quoted VAR VALUE # ---------------------------- # Quote VALUE and append to the end of shell variable VAR, separated # by a space. if test yes = "$_G_HAVE_PLUSEQ_OP"; then eval 'func_append_quoted () { $debug_cmd func_quote_for_eval "$2" eval "$1+=\\ \$func_quote_for_eval_result" }' else func_append_quoted () { $debug_cmd func_quote_for_eval "$2" eval "$1=\$$1\\ \$func_quote_for_eval_result" } fi # func_append_uniq VAR VALUE # -------------------------- # Append unique VALUE onto the existing contents of VAR, assuming # entries are delimited by the first character of VALUE. For example: # # func_append_uniq options " --another-option option-argument" # # will only append to $options if " --another-option option-argument " # is not already present somewhere in $options already (note spaces at # each end implied by leading space in second argument). func_append_uniq () { $debug_cmd eval _G_current_value='`$ECHO $'$1'`' _G_delim=`expr "$2" : '\(.\)'` case $_G_delim$_G_current_value$_G_delim in *"$2$_G_delim"*) ;; *) func_append "$@" ;; esac } # func_arith TERM... # ------------------ # Set func_arith_result to the result of evaluating TERMs. test -z "$_G_HAVE_ARITH_OP" \ && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ && _G_HAVE_ARITH_OP=yes if test yes = "$_G_HAVE_ARITH_OP"; then eval 'func_arith () { $debug_cmd func_arith_result=$(( $* )) }' else func_arith () { $debug_cmd func_arith_result=`expr "$@"` } fi # func_basename FILE # ------------------ # Set func_basename_result to FILE with everything up to and including # the last / stripped. if test yes = "$_G_HAVE_XSI_OPS"; then # If this shell supports suffix pattern removal, then use it to avoid # forking. Hide the definitions single quotes in case the shell chokes # on unsupported syntax... _b='func_basename_result=${1##*/}' _d='case $1 in */*) func_dirname_result=${1%/*}$2 ;; * ) func_dirname_result=$3 ;; esac' else # ...otherwise fall back to using sed. _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` if test "X$func_dirname_result" = "X$1"; then func_dirname_result=$3 else func_append func_dirname_result "$2" fi' fi eval 'func_basename () { $debug_cmd '"$_b"' }' # func_dirname FILE APPEND NONDIR_REPLACEMENT # ------------------------------------------- # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. eval 'func_dirname () { $debug_cmd '"$_d"' }' # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT # -------------------------------------------------------- # Perform func_basename and func_dirname in a single function # call: # dirname: Compute the dirname of FILE. If nonempty, # add APPEND to the result, otherwise set result # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. # value retuned in "$func_basename_result" # For efficiency, we do not delegate to the functions above but instead # duplicate the functionality here. eval 'func_dirname_and_basename () { $debug_cmd '"$_b"' '"$_d"' }' # func_echo ARG... # ---------------- # Echo program name prefixed message. func_echo () { $debug_cmd _G_message=$* func_echo_IFS=$IFS IFS=$nl for _G_line in $_G_message; do IFS=$func_echo_IFS $ECHO "$progname: $_G_line" done IFS=$func_echo_IFS } # func_echo_all ARG... # -------------------- # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } # func_echo_infix_1 INFIX ARG... # ------------------------------ # Echo program name, followed by INFIX on the first line, with any # additional lines not showing INFIX. func_echo_infix_1 () { $debug_cmd $require_term_colors _G_infix=$1; shift _G_indent=$_G_infix _G_prefix="$progname: $_G_infix: " _G_message=$* # Strip color escape sequences before counting printable length for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" do test -n "$_G_tc" && { _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` } done _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes func_echo_infix_1_IFS=$IFS IFS=$nl for _G_line in $_G_message; do IFS=$func_echo_infix_1_IFS $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 _G_prefix=$_G_indent done IFS=$func_echo_infix_1_IFS } # func_error ARG... # ----------------- # Echo program name prefixed message to standard error. func_error () { $debug_cmd $require_term_colors func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 } # func_fatal_error ARG... # ----------------------- # Echo program name prefixed message to standard error, and exit. func_fatal_error () { $debug_cmd func_error "$*" exit $EXIT_FAILURE } # func_grep EXPRESSION FILENAME # ----------------------------- # Check whether EXPRESSION matches any line of FILENAME, without output. func_grep () { $debug_cmd $GREP "$1" "$2" >/dev/null 2>&1 } # func_len STRING # --------------- # Set func_len_result to the length of STRING. STRING may not # start with a hyphen. test -z "$_G_HAVE_XSI_OPS" \ && (eval 'x=a/b/c; test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ && _G_HAVE_XSI_OPS=yes if test yes = "$_G_HAVE_XSI_OPS"; then eval 'func_len () { $debug_cmd func_len_result=${#1} }' else func_len () { $debug_cmd func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` } fi # func_mkdir_p DIRECTORY-PATH # --------------------------- # Make sure the entire path to DIRECTORY-PATH is available. func_mkdir_p () { $debug_cmd _G_directory_path=$1 _G_dir_list= if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then # Protect directory names starting with '-' case $_G_directory_path in -*) _G_directory_path=./$_G_directory_path ;; esac # While some portion of DIR does not yet exist... while test ! -d "$_G_directory_path"; do # ...make a list in topmost first order. Use a colon delimited # list incase some portion of path contains whitespace. _G_dir_list=$_G_directory_path:$_G_dir_list # If the last portion added has no slash in it, the list is done case $_G_directory_path in */*) ;; *) break ;; esac # ...otherwise throw away the child directory and loop _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` done _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` func_mkdir_p_IFS=$IFS; IFS=: for _G_dir in $_G_dir_list; do IFS=$func_mkdir_p_IFS # mkdir can fail with a 'File exist' error if two processes # try to create one of the directories concurrently. Don't # stop in that case! $MKDIR "$_G_dir" 2>/dev/null || : done IFS=$func_mkdir_p_IFS # Bail out if we (or some other process) failed to create a directory. test -d "$_G_directory_path" || \ func_fatal_error "Failed to create '$1'" fi } # func_mktempdir [BASENAME] # ------------------------- # Make a temporary directory that won't clash with other running # libtool processes, and avoids race conditions if possible. If # given, BASENAME is the basename for that directory. func_mktempdir () { $debug_cmd _G_template=${TMPDIR-/tmp}/${1-$progname} if test : = "$opt_dry_run"; then # Return a directory name, but don't create it in dry-run mode _G_tmpdir=$_G_template-$$ else # If mktemp works, use that first and foremost _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` if test ! -d "$_G_tmpdir"; then # Failing that, at least try and use $RANDOM to avoid a race _G_tmpdir=$_G_template-${RANDOM-0}$$ func_mktempdir_umask=`umask` umask 0077 $MKDIR "$_G_tmpdir" umask $func_mktempdir_umask fi # If we're not in dry-run mode, bomb out on failure test -d "$_G_tmpdir" || \ func_fatal_error "cannot create temporary directory '$_G_tmpdir'" fi $ECHO "$_G_tmpdir" } # func_normal_abspath PATH # ------------------------ # Remove doubled-up and trailing slashes, "." path components, # and cancel out any ".." path components in PATH after making # it an absolute path. func_normal_abspath () { $debug_cmd # These SED scripts presuppose an absolute path with a trailing slash. _G_pathcar='s|^/\([^/]*\).*$|\1|' _G_pathcdr='s|^/[^/]*||' _G_removedotparts=':dotsl s|/\./|/|g t dotsl s|/\.$|/|' _G_collapseslashes='s|/\{1,\}|/|g' _G_finalslash='s|/*$|/|' # Start from root dir and reassemble the path. func_normal_abspath_result= func_normal_abspath_tpath=$1 func_normal_abspath_altnamespace= case $func_normal_abspath_tpath in "") # Empty path, that just means $cwd. func_stripname '' '/' "`pwd`" func_normal_abspath_result=$func_stripname_result return ;; # The next three entries are used to spot a run of precisely # two leading slashes without using negated character classes; # we take advantage of case's first-match behaviour. ///*) # Unusual form of absolute path, do nothing. ;; //*) # Not necessarily an ordinary path; POSIX reserves leading '//' # and for example Cygwin uses it to access remote file shares # over CIFS/SMB, so we conserve a leading double slash if found. func_normal_abspath_altnamespace=/ ;; /*) # Absolute path, do nothing. ;; *) # Relative path, prepend $cwd. func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath ;; esac # Cancel out all the simple stuff to save iterations. We also want # the path to end with a slash for ease of parsing, so make sure # there is one (and only one) here. func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` while :; do # Processed it all yet? if test / = "$func_normal_abspath_tpath"; then # If we ascended to the root using ".." the result may be empty now. if test -z "$func_normal_abspath_result"; then func_normal_abspath_result=/ fi break fi func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$_G_pathcar"` func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$_G_pathcdr"` # Figure out what to do with it case $func_normal_abspath_tcomponent in "") # Trailing empty path component, ignore it. ;; ..) # Parent dir; strip last assembled component from result. func_dirname "$func_normal_abspath_result" func_normal_abspath_result=$func_dirname_result ;; *) # Actual path component, append it. func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" ;; esac done # Restore leading double-slash if one was found on entry. func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result } # func_notquiet ARG... # -------------------- # Echo program name prefixed message only when not in quiet mode. func_notquiet () { $debug_cmd $opt_quiet || func_echo ${1+"$@"} # A bug in bash halts the script if the last line of a function # fails when set -e is in force, so we need another command to # work around that: : } # func_relative_path SRCDIR DSTDIR # -------------------------------- # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. func_relative_path () { $debug_cmd func_relative_path_result= func_normal_abspath "$1" func_relative_path_tlibdir=$func_normal_abspath_result func_normal_abspath "$2" func_relative_path_tbindir=$func_normal_abspath_result # Ascend the tree starting from libdir while :; do # check if we have found a prefix of bindir case $func_relative_path_tbindir in $func_relative_path_tlibdir) # found an exact match func_relative_path_tcancelled= break ;; $func_relative_path_tlibdir*) # found a matching prefix func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" func_relative_path_tcancelled=$func_stripname_result if test -z "$func_relative_path_result"; then func_relative_path_result=. fi break ;; *) func_dirname $func_relative_path_tlibdir func_relative_path_tlibdir=$func_dirname_result if test -z "$func_relative_path_tlibdir"; then # Have to descend all the way to the root! func_relative_path_result=../$func_relative_path_result func_relative_path_tcancelled=$func_relative_path_tbindir break fi func_relative_path_result=../$func_relative_path_result ;; esac done # Now calculate path; take care to avoid doubling-up slashes. func_stripname '' '/' "$func_relative_path_result" func_relative_path_result=$func_stripname_result func_stripname '/' '/' "$func_relative_path_tcancelled" if test -n "$func_stripname_result"; then func_append func_relative_path_result "/$func_stripname_result" fi # Normalisation. If bindir is libdir, return '.' else relative path. if test -n "$func_relative_path_result"; then func_stripname './' '' "$func_relative_path_result" func_relative_path_result=$func_stripname_result fi test -n "$func_relative_path_result" || func_relative_path_result=. : } # func_quote_for_eval ARG... # -------------------------- # Aesthetically quote ARGs to be evaled later. # This function returns two values: # i) func_quote_for_eval_result # double-quoted, suitable for a subsequent eval # ii) func_quote_for_eval_unquoted_result # has all characters that are still active within double # quotes backslashified. func_quote_for_eval () { $debug_cmd func_quote_for_eval_unquoted_result= func_quote_for_eval_result= while test 0 -lt $#; do case $1 in *[\\\`\"\$]*) _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; *) _G_unquoted_arg=$1 ;; esac if test -n "$func_quote_for_eval_unquoted_result"; then func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" else func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" fi case $_G_unquoted_arg in # Double-quote args containing shell metacharacters to delay # word splitting, command substitution and variable expansion # for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") _G_quoted_arg=\"$_G_unquoted_arg\" ;; *) _G_quoted_arg=$_G_unquoted_arg ;; esac if test -n "$func_quote_for_eval_result"; then func_append func_quote_for_eval_result " $_G_quoted_arg" else func_append func_quote_for_eval_result "$_G_quoted_arg" fi shift done } # func_quote_for_expand ARG # ------------------------- # Aesthetically quote ARG to be evaled later; same as above, # but do not quote variable references. func_quote_for_expand () { $debug_cmd case $1 in *[\\\`\"]*) _G_arg=`$ECHO "$1" | $SED \ -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; *) _G_arg=$1 ;; esac case $_G_arg in # Double-quote args containing shell metacharacters to delay # word splitting and command substitution for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") _G_arg=\"$_G_arg\" ;; esac func_quote_for_expand_result=$_G_arg } # func_stripname PREFIX SUFFIX NAME # --------------------------------- # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). if test yes = "$_G_HAVE_XSI_OPS"; then eval 'func_stripname () { $debug_cmd # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are # positional parameters, so assign one to ordinary variable first. func_stripname_result=$3 func_stripname_result=${func_stripname_result#"$1"} func_stripname_result=${func_stripname_result%"$2"} }' else func_stripname () { $debug_cmd case $2 in .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; esac } fi # func_show_eval CMD [FAIL_EXP] # ----------------------------- # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. func_show_eval () { $debug_cmd _G_cmd=$1 _G_fail_exp=${2-':'} func_quote_for_expand "$_G_cmd" eval "func_notquiet $func_quote_for_expand_result" $opt_dry_run || { eval "$_G_cmd" _G_status=$? if test 0 -ne "$_G_status"; then eval "(exit $_G_status); $_G_fail_exp" fi } } # func_show_eval_locale CMD [FAIL_EXP] # ------------------------------------ # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. Use the saved locale for evaluation. func_show_eval_locale () { $debug_cmd _G_cmd=$1 _G_fail_exp=${2-':'} $opt_quiet || { func_quote_for_expand "$_G_cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || { eval "$_G_user_locale $_G_cmd" _G_status=$? eval "$_G_safe_locale" if test 0 -ne "$_G_status"; then eval "(exit $_G_status); $_G_fail_exp" fi } } # func_tr_sh # ---------- # Turn $1 into a string suitable for a shell variable name. # Result is stored in $func_tr_sh_result. All characters # not in the set a-zA-Z0-9_ are replaced with '_'. Further, # if $1 begins with a digit, a '_' is prepended as well. func_tr_sh () { $debug_cmd case $1 in [0-9]* | *[!a-zA-Z0-9_]*) func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` ;; * ) func_tr_sh_result=$1 ;; esac } # func_verbose ARG... # ------------------- # Echo program name prefixed message in verbose mode only. func_verbose () { $debug_cmd $opt_verbose && func_echo "$*" : } # func_warn_and_continue ARG... # ----------------------------- # Echo program name prefixed warning message to standard error. func_warn_and_continue () { $debug_cmd $require_term_colors func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 } # func_warning CATEGORY ARG... # ---------------------------- # Echo program name prefixed warning message to standard error. Warning # messages can be filtered according to CATEGORY, where this function # elides messages where CATEGORY is not listed in the global variable # 'opt_warning_types'. func_warning () { $debug_cmd # CATEGORY must be in the warning_categories list! case " $warning_categories " in *" $1 "*) ;; *) func_internal_error "invalid warning category '$1'" ;; esac _G_category=$1 shift case " $opt_warning_types " in *" $_G_category "*) $warning_func ${1+"$@"} ;; esac } # func_sort_ver VER1 VER2 # ----------------------- # 'sort -V' is not generally available. # Note this deviates from the version comparison in automake # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a # but this should suffice as we won't be specifying old # version formats or redundant trailing .0 in bootstrap.conf. # If we did want full compatibility then we should probably # use m4_version_compare from autoconf. func_sort_ver () { $debug_cmd printf '%s\n%s\n' "$1" "$2" \ | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n } # func_lt_ver PREV CURR # --------------------- # Return true if PREV and CURR are in the correct order according to # func_sort_ver, otherwise false. Use it like this: # # func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." func_lt_ver () { $debug_cmd test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` } # Local variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" # time-stamp-time-zone: "UTC" # End: #! /bin/sh # Set a version string for this script. scriptversion=2015-10-07.11; # UTC # A portable, pluggable option parser for Bourne shell. # Written by Gary V. Vaughan, 2010 # Copyright (C) 2010-2015 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # Please report bugs or propose patches to gary@gnu.org. ## ------ ## ## Usage. ## ## ------ ## # This file is a library for parsing options in your shell scripts along # with assorted other useful supporting features that you can make use # of too. # # For the simplest scripts you might need only: # # #!/bin/sh # . relative/path/to/funclib.sh # . relative/path/to/options-parser # scriptversion=1.0 # func_options ${1+"$@"} # eval set dummy "$func_options_result"; shift # ...rest of your script... # # In order for the '--version' option to work, you will need to have a # suitably formatted comment like the one at the top of this file # starting with '# Written by ' and ending with '# warranty; '. # # For '-h' and '--help' to work, you will also need a one line # description of your script's purpose in a comment directly above the # '# Written by ' line, like the one at the top of this file. # # The default options also support '--debug', which will turn on shell # execution tracing (see the comment above debug_cmd below for another # use), and '--verbose' and the func_verbose function to allow your script # to display verbose messages only when your user has specified # '--verbose'. # # After sourcing this file, you can plug processing for additional # options by amending the variables from the 'Configuration' section # below, and following the instructions in the 'Option parsing' # section further down. ## -------------- ## ## Configuration. ## ## -------------- ## # You should override these variables in your script after sourcing this # file so that they reflect the customisations you have added to the # option parser. # The usage line for option parsing errors and the start of '-h' and # '--help' output messages. You can embed shell variables for delayed # expansion at the time the message is displayed, but you will need to # quote other shell meta-characters carefully to prevent them being # expanded when the contents are evaled. usage='$progpath [OPTION]...' # Short help message in response to '-h' and '--help'. Add to this or # override it after sourcing this library to reflect the full set of # options your script accepts. usage_message="\ --debug enable verbose shell tracing -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] -v, --verbose verbosely report processing --version print version information and exit -h, --help print short or long help message and exit " # Additional text appended to 'usage_message' in response to '--help'. long_help_message=" Warning categories include: 'all' show all warnings 'none' turn off all the warnings 'error' warnings are treated as fatal errors" # Help message printed before fatal option parsing errors. fatal_help="Try '\$progname --help' for more information." ## ------------------------- ## ## Hook function management. ## ## ------------------------- ## # This section contains functions for adding, removing, and running hooks # to the main code. A hook is just a named list of of function, that can # be run in order later on. # func_hookable FUNC_NAME # ----------------------- # Declare that FUNC_NAME will run hooks added with # 'func_add_hook FUNC_NAME ...'. func_hookable () { $debug_cmd func_append hookable_fns " $1" } # func_add_hook FUNC_NAME HOOK_FUNC # --------------------------------- # Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must # first have been declared "hookable" by a call to 'func_hookable'. func_add_hook () { $debug_cmd case " $hookable_fns " in *" $1 "*) ;; *) func_fatal_error "'$1' does not accept hook functions." ;; esac eval func_append ${1}_hooks '" $2"' } # func_remove_hook FUNC_NAME HOOK_FUNC # ------------------------------------ # Remove HOOK_FUNC from the list of functions called by FUNC_NAME. func_remove_hook () { $debug_cmd eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' } # func_run_hooks FUNC_NAME [ARG]... # --------------------------------- # Run all hook functions registered to FUNC_NAME. # It is assumed that the list of hook functions contains nothing more # than a whitespace-delimited list of legal shell function names, and # no effort is wasted trying to catch shell meta-characters or preserve # whitespace. func_run_hooks () { $debug_cmd _G_rc_run_hooks=false case " $hookable_fns " in *" $1 "*) ;; *) func_fatal_error "'$1' does not support hook funcions.n" ;; esac eval _G_hook_fns=\$$1_hooks; shift for _G_hook in $_G_hook_fns; do if eval $_G_hook '"$@"'; then # store returned options list back into positional # parameters for next 'cmd' execution. eval _G_hook_result=\$${_G_hook}_result eval set dummy "$_G_hook_result"; shift _G_rc_run_hooks=: fi done $_G_rc_run_hooks && func_run_hooks_result=$_G_hook_result } ## --------------- ## ## Option parsing. ## ## --------------- ## # In order to add your own option parsing hooks, you must accept the # full positional parameter list in your hook function, you may remove/edit # any options that you action, and then pass back the remaining unprocessed # options in '_result', escaped suitably for # 'eval'. In this case you also must return $EXIT_SUCCESS to let the # hook's caller know that it should pay attention to # '_result'. Returning $EXIT_FAILURE signalizes that # arguments are left untouched by the hook and therefore caller will ignore the # result variable. # # Like this: # # my_options_prep () # { # $debug_cmd # # # Extend the existing usage message. # usage_message=$usage_message' # -s, --silent don'\''t print informational messages # ' # # No change in '$@' (ignored completely by this hook). There is # # no need to do the equivalent (but slower) action: # # func_quote_for_eval ${1+"$@"} # # my_options_prep_result=$func_quote_for_eval_result # false # } # func_add_hook func_options_prep my_options_prep # # # my_silent_option () # { # $debug_cmd # # args_changed=false # # # Note that for efficiency, we parse as many options as we can # # recognise in a loop before passing the remainder back to the # # caller on the first unrecognised argument we encounter. # while test $# -gt 0; do # opt=$1; shift # case $opt in # --silent|-s) opt_silent=: # args_changed=: # ;; # # Separate non-argument short options: # -s*) func_split_short_opt "$_G_opt" # set dummy "$func_split_short_opt_name" \ # "-$func_split_short_opt_arg" ${1+"$@"} # shift # args_changed=: # ;; # *) # Make sure the first unrecognised option "$_G_opt" # # is added back to "$@", we could need that later # # if $args_changed is true. # set dummy "$_G_opt" ${1+"$@"}; shift; break ;; # esac # done # # if $args_changed; then # func_quote_for_eval ${1+"$@"} # my_silent_option_result=$func_quote_for_eval_result # fi # # $args_changed # } # func_add_hook func_parse_options my_silent_option # # # my_option_validation () # { # $debug_cmd # # $opt_silent && $opt_verbose && func_fatal_help "\ # '--silent' and '--verbose' options are mutually exclusive." # # false # } # func_add_hook func_validate_options my_option_validation # # You'll also need to manually amend $usage_message to reflect the extra # options you parse. It's preferable to append if you can, so that # multiple option parsing hooks can be added safely. # func_options_finish [ARG]... # ---------------------------- # Finishing the option parse loop (call 'func_options' hooks ATM). func_options_finish () { $debug_cmd _G_func_options_finish_exit=false if func_run_hooks func_options ${1+"$@"}; then func_options_finish_result=$func_run_hooks_result _G_func_options_finish_exit=: fi $_G_func_options_finish_exit } # func_options [ARG]... # --------------------- # All the functions called inside func_options are hookable. See the # individual implementations for details. func_hookable func_options func_options () { $debug_cmd _G_rc_options=false for my_func in options_prep parse_options validate_options options_finish do if eval func_$my_func '${1+"$@"}'; then eval _G_res_var='$'"func_${my_func}_result" eval set dummy "$_G_res_var" ; shift _G_rc_options=: fi done # Save modified positional parameters for caller. As a top-level # options-parser function we always need to set the 'func_options_result' # variable (regardless the $_G_rc_options value). if $_G_rc_options; then func_options_result=$_G_res_var else func_quote_for_eval ${1+"$@"} func_options_result=$func_quote_for_eval_result fi $_G_rc_options } # func_options_prep [ARG]... # -------------------------- # All initialisations required before starting the option parse loop. # Note that when calling hook functions, we pass through the list of # positional parameters. If a hook function modifies that list, and # needs to propagate that back to rest of this script, then the complete # modified list must be put in 'func_run_hooks_result' before # returning $EXIT_SUCCESS (otherwise $EXIT_FAILURE is returned). func_hookable func_options_prep func_options_prep () { $debug_cmd # Option defaults: opt_verbose=false opt_warning_types= _G_rc_options_prep=false if func_run_hooks func_options_prep ${1+"$@"}; then _G_rc_options_prep=: # save modified positional parameters for caller func_options_prep_result=$func_run_hooks_result fi $_G_rc_options_prep } # func_parse_options [ARG]... # --------------------------- # The main option parsing loop. func_hookable func_parse_options func_parse_options () { $debug_cmd func_parse_options_result= _G_rc_parse_options=false # this just eases exit handling while test $# -gt 0; do # Defer to hook functions for initial option parsing, so they # get priority in the event of reusing an option name. if func_run_hooks func_parse_options ${1+"$@"}; then eval set dummy "$func_run_hooks_result"; shift _G_rc_parse_options=: fi # Break out of the loop if we already parsed every option. test $# -gt 0 || break _G_match_parse_options=: _G_opt=$1 shift case $_G_opt in --debug|-x) debug_cmd='set -x' func_echo "enabling shell trace mode" $debug_cmd ;; --no-warnings|--no-warning|--no-warn) set dummy --warnings none ${1+"$@"} shift ;; --warnings|--warning|-W) if test $# = 0 && func_missing_arg $_G_opt; then _G_rc_parse_options=: break fi case " $warning_categories $1" in *" $1 "*) # trailing space prevents matching last $1 above func_append_uniq opt_warning_types " $1" ;; *all) opt_warning_types=$warning_categories ;; *none) opt_warning_types=none warning_func=: ;; *error) opt_warning_types=$warning_categories warning_func=func_fatal_error ;; *) func_fatal_error \ "unsupported warning category: '$1'" ;; esac shift ;; --verbose|-v) opt_verbose=: ;; --version) func_version ;; -\?|-h) func_usage ;; --help) func_help ;; # Separate optargs to long options (plugins may need this): --*=*) func_split_equals "$_G_opt" set dummy "$func_split_equals_lhs" \ "$func_split_equals_rhs" ${1+"$@"} shift ;; # Separate optargs to short options: -W*) func_split_short_opt "$_G_opt" set dummy "$func_split_short_opt_name" \ "$func_split_short_opt_arg" ${1+"$@"} shift ;; # Separate non-argument short options: -\?*|-h*|-v*|-x*) func_split_short_opt "$_G_opt" set dummy "$func_split_short_opt_name" \ "-$func_split_short_opt_arg" ${1+"$@"} shift ;; --) _G_rc_parse_options=: ; break ;; -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; *) set dummy "$_G_opt" ${1+"$@"}; shift _G_match_parse_options=false break ;; esac $_G_match_parse_options && _G_rc_parse_options=: done if $_G_rc_parse_options; then # save modified positional parameters for caller func_quote_for_eval ${1+"$@"} func_parse_options_result=$func_quote_for_eval_result fi $_G_rc_parse_options } # func_validate_options [ARG]... # ------------------------------ # Perform any sanity checks on option settings and/or unconsumed # arguments. func_hookable func_validate_options func_validate_options () { $debug_cmd _G_rc_validate_options=false # Display all warnings if -W was not given. test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" if func_run_hooks func_validate_options ${1+"$@"}; then # save modified positional parameters for caller func_validate_options_result=$func_run_hooks_result _G_rc_validate_options=: fi # Bail if the options were screwed! $exit_cmd $EXIT_FAILURE $_G_rc_validate_options } ## ----------------- ## ## Helper functions. ## ## ----------------- ## # This section contains the helper functions used by the rest of the # hookable option parser framework in ascii-betical order. # func_fatal_help ARG... # ---------------------- # Echo program name prefixed message to standard error, followed by # a help hint, and exit. func_fatal_help () { $debug_cmd eval \$ECHO \""Usage: $usage"\" eval \$ECHO \""$fatal_help"\" func_error ${1+"$@"} exit $EXIT_FAILURE } # func_help # --------- # Echo long help message to standard output and exit. func_help () { $debug_cmd func_usage_message $ECHO "$long_help_message" exit 0 } # func_missing_arg ARGNAME # ------------------------ # Echo program name prefixed message to standard error and set global # exit_cmd. func_missing_arg () { $debug_cmd func_error "Missing argument for '$1'." exit_cmd=exit } # func_split_equals STRING # ------------------------ # Set func_split_equals_lhs and func_split_equals_rhs shell variables after # splitting STRING at the '=' sign. test -z "$_G_HAVE_XSI_OPS" \ && (eval 'x=a/b/c; test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ && _G_HAVE_XSI_OPS=yes if test yes = "$_G_HAVE_XSI_OPS" then # This is an XSI compatible shell, allowing a faster implementation... eval 'func_split_equals () { $debug_cmd func_split_equals_lhs=${1%%=*} func_split_equals_rhs=${1#*=} test "x$func_split_equals_lhs" = "x$1" \ && func_split_equals_rhs= }' else # ...otherwise fall back to using expr, which is often a shell builtin. func_split_equals () { $debug_cmd func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` func_split_equals_rhs= test "x$func_split_equals_lhs" = "x$1" \ || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` } fi #func_split_equals # func_split_short_opt SHORTOPT # ----------------------------- # Set func_split_short_opt_name and func_split_short_opt_arg shell # variables after splitting SHORTOPT after the 2nd character. if test yes = "$_G_HAVE_XSI_OPS" then # This is an XSI compatible shell, allowing a faster implementation... eval 'func_split_short_opt () { $debug_cmd func_split_short_opt_arg=${1#??} func_split_short_opt_name=${1%"$func_split_short_opt_arg"} }' else # ...otherwise fall back to using expr, which is often a shell builtin. func_split_short_opt () { $debug_cmd func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` } fi #func_split_short_opt # func_usage # ---------- # Echo short help message to standard output and exit. func_usage () { $debug_cmd func_usage_message $ECHO "Run '$progname --help |${PAGER-more}' for full usage" exit 0 } # func_usage_message # ------------------ # Echo short help message to standard output. func_usage_message () { $debug_cmd eval \$ECHO \""Usage: $usage"\" echo $SED -n 's|^# || /^Written by/{ x;p;x } h /^Written by/q' < "$progpath" echo eval \$ECHO \""$usage_message"\" } # func_version # ------------ # Echo version message to standard output and exit. func_version () { $debug_cmd printf '%s\n' "$progname $scriptversion" $SED -n ' /(C)/!b go :more /\./!{ N s|\n# | | b more } :go /^# Written by /,/# warranty; / { s|^# || s|^# *$|| s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| p } /^# Written by / { s|^# || p } /^warranty; /q' < "$progpath" exit $? } # Local variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" # time-stamp-time-zone: "UTC" # End: # Set a version string. scriptversion='(GNU libtool) 2.4.6' # func_echo ARG... # ---------------- # Libtool also displays the current mode in messages, so override # funclib.sh func_echo with this custom definition. func_echo () { $debug_cmd _G_message=$* func_echo_IFS=$IFS IFS=$nl for _G_line in $_G_message; do IFS=$func_echo_IFS $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" done IFS=$func_echo_IFS } # func_warning ARG... # ------------------- # Libtool warnings are not categorized, so override funclib.sh # func_warning with this simpler definition. func_warning () { $debug_cmd $warning_func ${1+"$@"} } ## ---------------- ## ## Options parsing. ## ## ---------------- ## # Hook in the functions to make sure our own options are parsed during # the option parsing loop. usage='$progpath [OPTION]... [MODE-ARG]...' # Short help message in response to '-h'. usage_message="Options: --config show all configuration variables --debug enable verbose shell tracing -n, --dry-run display commands without modifying any files --features display basic configuration information and exit --mode=MODE use operation mode MODE --no-warnings equivalent to '-Wnone' --preserve-dup-deps don't remove duplicate dependency libraries --quiet, --silent don't print informational messages --tag=TAG use configuration variables from tag TAG -v, --verbose print more informational messages than default --version print version information -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] -h, --help, --help-all print short, long, or detailed help message " # Additional text appended to 'usage_message' in response to '--help'. func_help () { $debug_cmd func_usage_message $ECHO "$long_help_message MODE must be one of the following: clean remove files from the build directory compile compile a source file into a libtool object execute automatically set library path, then run a program finish complete the installation of libtool libraries install install libraries or executables link create a library or an executable uninstall remove libraries from an installed directory MODE-ARGS vary depending on the MODE. When passed as first option, '--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. Try '$progname --help --mode=MODE' for a more detailed description of MODE. When reporting a bug, please describe a test case to reproduce it and include the following information: host-triplet: $host shell: $SHELL compiler: $LTCC compiler flags: $LTCFLAGS linker: $LD (gnu? $with_gnu_ld) version: $progname $scriptversion Debian-2.4.6-9 automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` Report bugs to . GNU libtool home page: . General help using GNU software: ." exit 0 } # func_lo2o OBJECT-NAME # --------------------- # Transform OBJECT-NAME from a '.lo' suffix to the platform specific # object suffix. lo2o=s/\\.lo\$/.$objext/ o2lo=s/\\.$objext\$/.lo/ if test yes = "$_G_HAVE_XSI_OPS"; then eval 'func_lo2o () { case $1 in *.lo) func_lo2o_result=${1%.lo}.$objext ;; * ) func_lo2o_result=$1 ;; esac }' # func_xform LIBOBJ-OR-SOURCE # --------------------------- # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) # suffix to a '.lo' libtool-object suffix. eval 'func_xform () { func_xform_result=${1%.*}.lo }' else # ...otherwise fall back to using sed. func_lo2o () { func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` } func_xform () { func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` } fi # func_fatal_configuration ARG... # ------------------------------- # Echo program name prefixed message to standard error, followed by # a configuration failure hint, and exit. func_fatal_configuration () { func__fatal_error ${1+"$@"} \ "See the $PACKAGE documentation for more information." \ "Fatal configuration error." } # func_config # ----------- # Display the configuration for all the tags in this script. func_config () { re_begincf='^# ### BEGIN LIBTOOL' re_endcf='^# ### END LIBTOOL' # Default configuration. $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" # Now print the configurations for the tags. for tagname in $taglist; do $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" done exit $? } # func_features # ------------- # Display the features supported by this script. func_features () { echo "host: $host" if test yes = "$build_libtool_libs"; then echo "enable shared libraries" else echo "disable shared libraries" fi if test yes = "$build_old_libs"; then echo "enable static libraries" else echo "disable static libraries" fi exit $? } # func_enable_tag TAGNAME # ----------------------- # Verify that TAGNAME is valid, and either flag an error and exit, or # enable the TAGNAME tag. We also add TAGNAME to the global $taglist # variable here. func_enable_tag () { # Global variable: tagname=$1 re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" sed_extractcf=/$re_begincf/,/$re_endcf/p # Validate tagname. case $tagname in *[!-_A-Za-z0-9,/]*) func_fatal_error "invalid tag name: $tagname" ;; esac # Don't test for the "default" C tag, as we know it's # there but not specially marked. case $tagname in CC) ;; *) if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then taglist="$taglist $tagname" # Evaluate the configuration. Be careful to quote the path # and the sed script, to avoid splitting on whitespace, but # also don't use non-portable quotes within backquotes within # quotes we have to do it in 2 steps: extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` eval "$extractedcf" else func_error "ignoring unknown tag $tagname" fi ;; esac } # func_check_version_match # ------------------------ # Ensure that we are using m4 macros, and libtool script from the same # release of libtool. func_check_version_match () { if test "$package_revision" != "$macro_revision"; then if test "$VERSION" != "$macro_version"; then if test -z "$macro_version"; then cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from an older release. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from $PACKAGE $macro_version. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF fi else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, $progname: but the definition of this LT_INIT comes from revision $macro_revision. $progname: You should recreate aclocal.m4 with macros from revision $package_revision $progname: of $PACKAGE $VERSION and run autoconf again. _LT_EOF fi exit $EXIT_MISMATCH fi } # libtool_options_prep [ARG]... # ----------------------------- # Preparation for options parsed by libtool. libtool_options_prep () { $debug_mode # Option defaults: opt_config=false opt_dlopen= opt_dry_run=false opt_help=false opt_mode= opt_preserve_dup_deps=false opt_quiet=false nonopt= preserve_args= _G_rc_lt_options_prep=: # Shorthand for --mode=foo, only valid as the first argument case $1 in clean|clea|cle|cl) shift; set dummy --mode clean ${1+"$@"}; shift ;; compile|compil|compi|comp|com|co|c) shift; set dummy --mode compile ${1+"$@"}; shift ;; execute|execut|execu|exec|exe|ex|e) shift; set dummy --mode execute ${1+"$@"}; shift ;; finish|finis|fini|fin|fi|f) shift; set dummy --mode finish ${1+"$@"}; shift ;; install|instal|insta|inst|ins|in|i) shift; set dummy --mode install ${1+"$@"}; shift ;; link|lin|li|l) shift; set dummy --mode link ${1+"$@"}; shift ;; uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) shift; set dummy --mode uninstall ${1+"$@"}; shift ;; *) _G_rc_lt_options_prep=false ;; esac if $_G_rc_lt_options_prep; then # Pass back the list of options. func_quote_for_eval ${1+"$@"} libtool_options_prep_result=$func_quote_for_eval_result fi $_G_rc_lt_options_prep } func_add_hook func_options_prep libtool_options_prep # libtool_parse_options [ARG]... # --------------------------------- # Provide handling for libtool specific options. libtool_parse_options () { $debug_cmd _G_rc_lt_parse_options=false # Perform our own loop to consume as many options as possible in # each iteration. while test $# -gt 0; do _G_match_lt_parse_options=: _G_opt=$1 shift case $_G_opt in --dry-run|--dryrun|-n) opt_dry_run=: ;; --config) func_config ;; --dlopen|-dlopen) opt_dlopen="${opt_dlopen+$opt_dlopen }$1" shift ;; --preserve-dup-deps) opt_preserve_dup_deps=: ;; --features) func_features ;; --finish) set dummy --mode finish ${1+"$@"}; shift ;; --help) opt_help=: ;; --help-all) opt_help=': help-all' ;; --mode) test $# = 0 && func_missing_arg $_G_opt && break opt_mode=$1 case $1 in # Valid mode arguments: clean|compile|execute|finish|install|link|relink|uninstall) ;; # Catch anything else as an error *) func_error "invalid argument for $_G_opt" exit_cmd=exit break ;; esac shift ;; --no-silent|--no-quiet) opt_quiet=false func_append preserve_args " $_G_opt" ;; --no-warnings|--no-warning|--no-warn) opt_warning=false func_append preserve_args " $_G_opt" ;; --no-verbose) opt_verbose=false func_append preserve_args " $_G_opt" ;; --silent|--quiet) opt_quiet=: opt_verbose=false func_append preserve_args " $_G_opt" ;; --tag) test $# = 0 && func_missing_arg $_G_opt && break opt_tag=$1 func_append preserve_args " $_G_opt $1" func_enable_tag "$1" shift ;; --verbose|-v) opt_quiet=false opt_verbose=: func_append preserve_args " $_G_opt" ;; # An option not handled by this hook function: *) set dummy "$_G_opt" ${1+"$@"} ; shift _G_match_lt_parse_options=false break ;; esac $_G_match_lt_parse_options && _G_rc_lt_parse_options=: done if $_G_rc_lt_parse_options; then # save modified positional parameters for caller func_quote_for_eval ${1+"$@"} libtool_parse_options_result=$func_quote_for_eval_result fi $_G_rc_lt_parse_options } func_add_hook func_parse_options libtool_parse_options # libtool_validate_options [ARG]... # --------------------------------- # Perform any sanity checks on option settings and/or unconsumed # arguments. libtool_validate_options () { # save first non-option argument if test 0 -lt $#; then nonopt=$1 shift fi # preserve --debug test : = "$debug_cmd" || func_append preserve_args " --debug" case $host in # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) # don't eliminate duplications in $postdeps and $predeps opt_duplicate_compiler_generated_deps=: ;; *) opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps ;; esac $opt_help || { # Sanity checks first: func_check_version_match test yes != "$build_libtool_libs" \ && test yes != "$build_old_libs" \ && func_fatal_configuration "not configured to build any kind of library" # Darwin sucks eval std_shrext=\"$shrext_cmds\" # Only execute mode is allowed to have -dlopen flags. if test -n "$opt_dlopen" && test execute != "$opt_mode"; then func_error "unrecognized option '-dlopen'" $ECHO "$help" 1>&2 exit $EXIT_FAILURE fi # Change the help message to a mode-specific one. generic_help=$help help="Try '$progname --help --mode=$opt_mode' for more information." } # Pass back the unparsed argument list func_quote_for_eval ${1+"$@"} libtool_validate_options_result=$func_quote_for_eval_result } func_add_hook func_validate_options libtool_validate_options # Process options as early as possible so that --help and --version # can return quickly. func_options ${1+"$@"} eval set dummy "$func_options_result"; shift ## ----------- ## ## Main. ## ## ----------- ## magic='%%%MAGIC variable%%%' magic_exe='%%%MAGIC EXE variable%%%' # Global variables. extracted_archives= extracted_serial=0 # If this variable is set in any of the actions, the command in it # will be execed at the end. This prevents here-documents from being # left over by shells. exec_cmd= # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } # func_generated_by_libtool # True iff stdin has been generated by Libtool. This function is only # a basic sanity check; it will hardly flush out determined imposters. func_generated_by_libtool_p () { $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 } # func_lalib_p file # True iff FILE is a libtool '.la' library or '.lo' object file. # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_lalib_p () { test -f "$1" && $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p } # func_lalib_unsafe_p file # True iff FILE is a libtool '.la' library or '.lo' object file. # This function implements the same check as func_lalib_p without # resorting to external programs. To this end, it redirects stdin and # closes it afterwards, without saving the original file descriptor. # As a safety measure, use it only where a negative result would be # fatal anyway. Works if 'file' does not exist. func_lalib_unsafe_p () { lalib_p=no if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then for lalib_p_l in 1 2 3 4 do read lalib_p_line case $lalib_p_line in \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; esac done exec 0<&5 5<&- fi test yes = "$lalib_p" } # func_ltwrapper_script_p file # True iff FILE is a libtool wrapper script # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_script_p () { test -f "$1" && $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p } # func_ltwrapper_executable_p file # True iff FILE is a libtool wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_executable_p () { func_ltwrapper_exec_suffix= case $1 in *.exe) ;; *) func_ltwrapper_exec_suffix=.exe ;; esac $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 } # func_ltwrapper_scriptname file # Assumes file is an ltwrapper_executable # uses $file to determine the appropriate filename for a # temporary ltwrapper_script. func_ltwrapper_scriptname () { func_dirname_and_basename "$1" "" "." func_stripname '' '.exe' "$func_basename_result" func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper } # func_ltwrapper_p file # True iff FILE is a libtool wrapper script or wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_p () { func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" } # func_execute_cmds commands fail_cmd # Execute tilde-delimited COMMANDS. # If FAIL_CMD is given, eval that upon failure. # FAIL_CMD may read-access the current command in variable CMD! func_execute_cmds () { $debug_cmd save_ifs=$IFS; IFS='~' for cmd in $1; do IFS=$sp$nl eval cmd=\"$cmd\" IFS=$save_ifs func_show_eval "$cmd" "${2-:}" done IFS=$save_ifs } # func_source file # Source FILE, adding directory component if necessary. # Note that it is not necessary on cygwin/mingw to append a dot to # FILE even if both FILE and FILE.exe exist: automatic-append-.exe # behavior happens only for exec(3), not for open(2)! Also, sourcing # 'FILE.' does not work on cygwin managed mounts. func_source () { $debug_cmd case $1 in */* | *\\*) . "$1" ;; *) . "./$1" ;; esac } # func_resolve_sysroot PATH # Replace a leading = in PATH with a sysroot. Store the result into # func_resolve_sysroot_result func_resolve_sysroot () { func_resolve_sysroot_result=$1 case $func_resolve_sysroot_result in =*) func_stripname '=' '' "$func_resolve_sysroot_result" func_resolve_sysroot_result=$lt_sysroot$func_stripname_result ;; esac } # func_replace_sysroot PATH # If PATH begins with the sysroot, replace it with = and # store the result into func_replace_sysroot_result. func_replace_sysroot () { case $lt_sysroot:$1 in ?*:"$lt_sysroot"*) func_stripname "$lt_sysroot" '' "$1" func_replace_sysroot_result='='$func_stripname_result ;; *) # Including no sysroot. func_replace_sysroot_result=$1 ;; esac } # func_infer_tag arg # Infer tagged configuration to use if any are available and # if one wasn't chosen via the "--tag" command line option. # Only attempt this if the compiler in the base compile # command doesn't match the default compiler. # arg is usually of the form 'gcc ...' func_infer_tag () { $debug_cmd if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case $@ in # Blanks in the command may have been stripped by the calling shell, # but not from the CC environment variable when configure was run. " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; # Blanks at the start of $base_compile will cause this to fail # if we don't check for them as well. *) for z in $available_tags; do if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then # Evaluate the configuration. eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" CC_quoted= for arg in $CC; do # Double-quote args containing other shell metacharacters. func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case "$@ " in " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) # The compiler in the base compile command matches # the one in the tagged configuration. # Assume this is the tagged configuration we want. tagname=$z break ;; esac fi done # If $tagname still isn't set, then no tagged configuration # was found and let the user know that the "--tag" command # line option must be used. if test -z "$tagname"; then func_echo "unable to infer tagged configuration" func_fatal_error "specify a tag with '--tag'" # else # func_verbose "using $tagname tagged configuration" fi ;; esac fi } # func_write_libtool_object output_name pic_name nonpic_name # Create a libtool object file (analogous to a ".la" file), # but don't create it if we're doing a dry run. func_write_libtool_object () { write_libobj=$1 if test yes = "$build_libtool_libs"; then write_lobj=\'$2\' else write_lobj=none fi if test yes = "$build_old_libs"; then write_oldobj=\'$3\' else write_oldobj=none fi $opt_dry_run || { cat >${write_libobj}T </dev/null` if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | $SED -e "$sed_naive_backslashify"` else func_convert_core_file_wine_to_w32_result= fi fi } # end: func_convert_core_file_wine_to_w32 # func_convert_core_path_wine_to_w32 ARG # Helper function used by path conversion functions when $build is *nix, and # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly # configured wine environment available, with the winepath program in $build's # $PATH. Assumes ARG has no leading or trailing path separator characters. # # ARG is path to be converted from $build format to win32. # Result is available in $func_convert_core_path_wine_to_w32_result. # Unconvertible file (directory) names in ARG are skipped; if no directory names # are convertible, then the result may be empty. func_convert_core_path_wine_to_w32 () { $debug_cmd # unfortunately, winepath doesn't convert paths, only file names func_convert_core_path_wine_to_w32_result= if test -n "$1"; then oldIFS=$IFS IFS=: for func_convert_core_path_wine_to_w32_f in $1; do IFS=$oldIFS func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" if test -n "$func_convert_core_file_wine_to_w32_result"; then if test -z "$func_convert_core_path_wine_to_w32_result"; then func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result else func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" fi fi done IFS=$oldIFS fi } # end: func_convert_core_path_wine_to_w32 # func_cygpath ARGS... # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or # (2), returns the Cygwin file name or path in func_cygpath_result (input # file name or path is assumed to be in w32 format, as previously converted # from $build's *nix or MSYS format). In case (3), returns the w32 file name # or path in func_cygpath_result (input file name or path is assumed to be in # Cygwin format). Returns an empty string on error. # # ARGS are passed to cygpath, with the last one being the file name or path to # be converted. # # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH # environment variable; do not put it in $PATH. func_cygpath () { $debug_cmd if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` if test "$?" -ne 0; then # on failure, ensure result is empty func_cygpath_result= fi else func_cygpath_result= func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" fi } #end: func_cygpath # func_convert_core_msys_to_w32 ARG # Convert file name or path ARG from MSYS format to w32 format. Return # result in func_convert_core_msys_to_w32_result. func_convert_core_msys_to_w32 () { $debug_cmd # awkward: cmd appends spaces to result func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` } #end: func_convert_core_msys_to_w32 # func_convert_file_check ARG1 ARG2 # Verify that ARG1 (a file name in $build format) was converted to $host # format in ARG2. Otherwise, emit an error message, but continue (resetting # func_to_host_file_result to ARG1). func_convert_file_check () { $debug_cmd if test -z "$2" && test -n "$1"; then func_error "Could not determine host file name corresponding to" func_error " '$1'" func_error "Continuing, but uninstalled executables may not work." # Fallback: func_to_host_file_result=$1 fi } # end func_convert_file_check # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH # Verify that FROM_PATH (a path in $build format) was converted to $host # format in TO_PATH. Otherwise, emit an error message, but continue, resetting # func_to_host_file_result to a simplistic fallback value (see below). func_convert_path_check () { $debug_cmd if test -z "$4" && test -n "$3"; then func_error "Could not determine the host path corresponding to" func_error " '$3'" func_error "Continuing, but uninstalled executables may not work." # Fallback. This is a deliberately simplistic "conversion" and # should not be "improved". See libtool.info. if test "x$1" != "x$2"; then lt_replace_pathsep_chars="s|$1|$2|g" func_to_host_path_result=`echo "$3" | $SED -e "$lt_replace_pathsep_chars"` else func_to_host_path_result=$3 fi fi } # end func_convert_path_check # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT # and appending REPL if ORIG matches BACKPAT. func_convert_path_front_back_pathsep () { $debug_cmd case $4 in $1 ) func_to_host_path_result=$3$func_to_host_path_result ;; esac case $4 in $2 ) func_append func_to_host_path_result "$3" ;; esac } # end func_convert_path_front_back_pathsep ################################################## # $build to $host FILE NAME CONVERSION FUNCTIONS # ################################################## # invoked via '$to_host_file_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # Result will be available in $func_to_host_file_result. # func_to_host_file ARG # Converts the file name ARG from $build format to $host format. Return result # in func_to_host_file_result. func_to_host_file () { $debug_cmd $to_host_file_cmd "$1" } # end func_to_host_file # func_to_tool_file ARG LAZY # converts the file name ARG from $build format to toolchain format. Return # result in func_to_tool_file_result. If the conversion in use is listed # in (the comma separated) LAZY, no conversion takes place. func_to_tool_file () { $debug_cmd case ,$2, in *,"$to_tool_file_cmd",*) func_to_tool_file_result=$1 ;; *) $to_tool_file_cmd "$1" func_to_tool_file_result=$func_to_host_file_result ;; esac } # end func_to_tool_file # func_convert_file_noop ARG # Copy ARG to func_to_host_file_result. func_convert_file_noop () { func_to_host_file_result=$1 } # end func_convert_file_noop # func_convert_file_msys_to_w32 ARG # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_file_result. func_convert_file_msys_to_w32 () { $debug_cmd func_to_host_file_result=$1 if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_to_host_file_result=$func_convert_core_msys_to_w32_result fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_w32 # func_convert_file_cygwin_to_w32 ARG # Convert file name ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_file_cygwin_to_w32 () { $debug_cmd func_to_host_file_result=$1 if test -n "$1"; then # because $build is cygwin, we call "the" cygpath in $PATH; no need to use # LT_CYGPATH in this case. func_to_host_file_result=`cygpath -m "$1"` fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_cygwin_to_w32 # func_convert_file_nix_to_w32 ARG # Convert file name ARG from *nix to w32 format. Requires a wine environment # and a working winepath. Returns result in func_to_host_file_result. func_convert_file_nix_to_w32 () { $debug_cmd func_to_host_file_result=$1 if test -n "$1"; then func_convert_core_file_wine_to_w32 "$1" func_to_host_file_result=$func_convert_core_file_wine_to_w32_result fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_w32 # func_convert_file_msys_to_cygwin ARG # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_file_msys_to_cygwin () { $debug_cmd func_to_host_file_result=$1 if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_cygpath -u "$func_convert_core_msys_to_w32_result" func_to_host_file_result=$func_cygpath_result fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_cygwin # func_convert_file_nix_to_cygwin ARG # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed # in a wine environment, working winepath, and LT_CYGPATH set. Returns result # in func_to_host_file_result. func_convert_file_nix_to_cygwin () { $debug_cmd func_to_host_file_result=$1 if test -n "$1"; then # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. func_convert_core_file_wine_to_w32 "$1" func_cygpath -u "$func_convert_core_file_wine_to_w32_result" func_to_host_file_result=$func_cygpath_result fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_cygwin ############################################# # $build to $host PATH CONVERSION FUNCTIONS # ############################################# # invoked via '$to_host_path_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # The result will be available in $func_to_host_path_result. # # Path separators are also converted from $build format to $host format. If # ARG begins or ends with a path separator character, it is preserved (but # converted to $host format) on output. # # All path conversion functions are named using the following convention: # file name conversion function : func_convert_file_X_to_Y () # path conversion function : func_convert_path_X_to_Y () # where, for any given $build/$host combination the 'X_to_Y' value is the # same. If conversion functions are added for new $build/$host combinations, # the two new functions must follow this pattern, or func_init_to_host_path_cmd # will break. # func_init_to_host_path_cmd # Ensures that function "pointer" variable $to_host_path_cmd is set to the # appropriate value, based on the value of $to_host_file_cmd. to_host_path_cmd= func_init_to_host_path_cmd () { $debug_cmd if test -z "$to_host_path_cmd"; then func_stripname 'func_convert_file_' '' "$to_host_file_cmd" to_host_path_cmd=func_convert_path_$func_stripname_result fi } # func_to_host_path ARG # Converts the path ARG from $build format to $host format. Return result # in func_to_host_path_result. func_to_host_path () { $debug_cmd func_init_to_host_path_cmd $to_host_path_cmd "$1" } # end func_to_host_path # func_convert_path_noop ARG # Copy ARG to func_to_host_path_result. func_convert_path_noop () { func_to_host_path_result=$1 } # end func_convert_path_noop # func_convert_path_msys_to_w32 ARG # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_path_result. func_convert_path_msys_to_w32 () { $debug_cmd func_to_host_path_result=$1 if test -n "$1"; then # Remove leading and trailing path separator characters from ARG. MSYS # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; # and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result=$func_convert_core_msys_to_w32_result func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_msys_to_w32 # func_convert_path_cygwin_to_w32 ARG # Convert path ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_path_cygwin_to_w32 () { $debug_cmd func_to_host_path_result=$1 if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_cygwin_to_w32 # func_convert_path_nix_to_w32 ARG # Convert path ARG from *nix to w32 format. Requires a wine environment and # a working winepath. Returns result in func_to_host_file_result. func_convert_path_nix_to_w32 () { $debug_cmd func_to_host_path_result=$1 if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result=$func_convert_core_path_wine_to_w32_result func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_nix_to_w32 # func_convert_path_msys_to_cygwin ARG # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_path_msys_to_cygwin () { $debug_cmd func_to_host_path_result=$1 if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_msys_to_w32_result" func_to_host_path_result=$func_cygpath_result func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_msys_to_cygwin # func_convert_path_nix_to_cygwin ARG # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a # a wine environment, working winepath, and LT_CYGPATH set. Returns result in # func_to_host_file_result. func_convert_path_nix_to_cygwin () { $debug_cmd func_to_host_path_result=$1 if test -n "$1"; then # Remove leading and trailing path separator characters from # ARG. msys behavior is inconsistent here, cygpath turns them # into '.;' and ';.', and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" func_to_host_path_result=$func_cygpath_result func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_nix_to_cygwin # func_dll_def_p FILE # True iff FILE is a Windows DLL '.def' file. # Keep in sync with _LT_DLL_DEF_P in libtool.m4 func_dll_def_p () { $debug_cmd func_dll_def_p_tmp=`$SED -n \ -e 's/^[ ]*//' \ -e '/^\(;.*\)*$/d' \ -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ -e q \ "$1"` test DEF = "$func_dll_def_p_tmp" } # func_mode_compile arg... func_mode_compile () { $debug_cmd # Get the compilation command and the source file. base_compile= srcfile=$nonopt # always keep a non-empty value in "srcfile" suppress_opt=yes suppress_output= arg_mode=normal libobj= later= pie_flag= for arg do case $arg_mode in arg ) # do not "continue". Instead, add this to base_compile lastarg=$arg arg_mode=normal ;; target ) libobj=$arg arg_mode=normal continue ;; normal ) # Accept any command-line options. case $arg in -o) test -n "$libobj" && \ func_fatal_error "you cannot specify '-o' more than once" arg_mode=target continue ;; -pie | -fpie | -fPIE) func_append pie_flag " $arg" continue ;; -shared | -static | -prefer-pic | -prefer-non-pic) func_append later " $arg" continue ;; -no-suppress) suppress_opt=no continue ;; -Xcompiler) arg_mode=arg # the next one goes into the "base_compile" arg list continue # The current "srcfile" will either be retained or ;; # replaced later. I would guess that would be a bug. -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result lastarg= save_ifs=$IFS; IFS=, for arg in $args; do IFS=$save_ifs func_append_quoted lastarg "$arg" done IFS=$save_ifs func_stripname ' ' '' "$lastarg" lastarg=$func_stripname_result # Add the arguments to base_compile. func_append base_compile " $lastarg" continue ;; *) # Accept the current argument as the source file. # The previous "srcfile" becomes the current argument. # lastarg=$srcfile srcfile=$arg ;; esac # case $arg ;; esac # case $arg_mode # Aesthetically quote the previous argument. func_append_quoted base_compile "$lastarg" done # for arg case $arg_mode in arg) func_fatal_error "you must specify an argument for -Xcompile" ;; target) func_fatal_error "you must specify a target with '-o'" ;; *) # Get the name of the library object. test -z "$libobj" && { func_basename "$srcfile" libobj=$func_basename_result } ;; esac # Recognize several different file suffixes. # If the user specifies -o file.o, it is replaced with file.lo case $libobj in *.[cCFSifmso] | \ *.ada | *.adb | *.ads | *.asm | \ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) func_xform "$libobj" libobj=$func_xform_result ;; esac case $libobj in *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; *) func_fatal_error "cannot determine name of library object from '$libobj'" ;; esac func_infer_tag $base_compile for arg in $later; do case $arg in -shared) test yes = "$build_libtool_libs" \ || func_fatal_configuration "cannot build a shared library" build_old_libs=no continue ;; -static) build_libtool_libs=no build_old_libs=yes continue ;; -prefer-pic) pic_mode=yes continue ;; -prefer-non-pic) pic_mode=no continue ;; esac done func_quote_for_eval "$libobj" test "X$libobj" != "X$func_quote_for_eval_result" \ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ && func_warning "libobj name '$libobj' may not contain shell special characters." func_dirname_and_basename "$obj" "/" "" objname=$func_basename_result xdir=$func_dirname_result lobj=$xdir$objdir/$objname test -z "$base_compile" && \ func_fatal_help "you must specify a compilation command" # Delete any leftover library objects. if test yes = "$build_old_libs"; then removelist="$obj $lobj $libobj ${libobj}T" else removelist="$lobj $libobj ${libobj}T" fi # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in cygwin* | mingw* | pw32* | os2* | cegcc*) pic_mode=default ;; esac if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then # non-PIC code in shared libraries is not supported pic_mode=default fi # Calculate the filename of the output object if compiler does # not support -o with -c if test no = "$compiler_c_o"; then output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext lockfile=$output_obj.lock else output_obj= need_locks=no lockfile= fi # Lock this critical section if it is needed # We use this script file to make the link, it avoids creating a new file if test yes = "$need_locks"; then until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done elif test warn = "$need_locks"; then if test -f "$lockfile"; then $ECHO "\ *** ERROR, $lockfile exists and contains: `cat $lockfile 2>/dev/null` This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support '-c' and '-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi func_append removelist " $output_obj" $ECHO "$srcfile" > "$lockfile" fi $opt_dry_run || $RM $removelist func_append removelist " $lockfile" trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 srcfile=$func_to_tool_file_result func_quote_for_eval "$srcfile" qsrcfile=$func_quote_for_eval_result # Only build a PIC object if we are building libtool libraries. if test yes = "$build_libtool_libs"; then # Without this assignment, base_compile gets emptied. fbsd_hideous_sh_bug=$base_compile if test no != "$pic_mode"; then command="$base_compile $qsrcfile $pic_flag" else # Don't build PIC code command="$base_compile $qsrcfile" fi func_mkdir_p "$xdir$objdir" if test -z "$output_obj"; then # Place PIC objects in $objdir func_append command " -o $lobj" fi func_show_eval_locale "$command" \ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' if test warn = "$need_locks" && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support '-c' and '-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed, then go on to compile the next one if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then func_show_eval '$MV "$output_obj" "$lobj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi # Allow error messages only from the first compilation. if test yes = "$suppress_opt"; then suppress_output=' >/dev/null 2>&1' fi fi # Only build a position-dependent object if we build old libraries. if test yes = "$build_old_libs"; then if test yes != "$pic_mode"; then # Don't build PIC code command="$base_compile $qsrcfile$pie_flag" else command="$base_compile $qsrcfile $pic_flag" fi if test yes = "$compiler_c_o"; then func_append command " -o $obj" fi # Suppress compiler output if we already did a PIC compilation. func_append command "$suppress_output" func_show_eval_locale "$command" \ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' if test warn = "$need_locks" && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support '-c' and '-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then func_show_eval '$MV "$output_obj" "$obj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi fi $opt_dry_run || { func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" # Unlock the critical section if it was locked if test no != "$need_locks"; then removelist=$lockfile $RM "$lockfile" fi } exit $EXIT_SUCCESS } $opt_help || { test compile = "$opt_mode" && func_mode_compile ${1+"$@"} } func_mode_help () { # We need to display help for each of the modes. case $opt_mode in "") # Generic help is extracted from the usage comments # at the start of this file. func_help ;; clean) $ECHO \ "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... Remove files from the build directory. RM is the name of the program to use to delete files associated with each FILE (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed to RM. If FILE is a libtool library, object or program, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; compile) $ECHO \ "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE Compile a source file into a libtool library object. This mode accepts the following additional options: -o OUTPUT-FILE set the output file name to OUTPUT-FILE -no-suppress do not suppress compiler output for multiple passes -prefer-pic try to build PIC objects only -prefer-non-pic try to build non-PIC objects only -shared do not build a '.o' file suitable for static linking -static only build a '.o' file suitable for static linking -Wc,FLAG pass FLAG directly to the compiler COMPILE-COMMAND is a command to be used in creating a 'standard' object file from the given SOURCEFILE. The output file name is determined by removing the directory component from SOURCEFILE, then substituting the C source code suffix '.c' with the library object suffix, '.lo'." ;; execute) $ECHO \ "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... Automatically set library path, then run a program. This mode accepts the following additional options: -dlopen FILE add the directory containing FILE to the library path This mode sets the library path environment variable according to '-dlopen' flags. If any of the ARGS are libtool executable wrappers, then they are translated into their corresponding uninstalled binary, and any of their required library directories are added to the library path. Then, COMMAND is executed, with ARGS as arguments." ;; finish) $ECHO \ "Usage: $progname [OPTION]... --mode=finish [LIBDIR]... Complete the installation of libtool libraries. Each LIBDIR is a directory that contains libtool libraries. The commands that this mode executes may require superuser privileges. Use the '--dry-run' option if you just want to see what would be executed." ;; install) $ECHO \ "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... Install executables or libraries. INSTALL-COMMAND is the installation command. The first component should be either the 'install' or 'cp' program. The following components of INSTALL-COMMAND are treated specially: -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation The rest of the components are interpreted as arguments to that command (only BSD-compatible install options are recognized)." ;; link) $ECHO \ "Usage: $progname [OPTION]... --mode=link LINK-COMMAND... Link object files or libraries together to form another library, or to create an executable program. LINK-COMMAND is a command using the C compiler that you would use to create a program from several object files. The following components of LINK-COMMAND are treated specially: -all-static do not do any dynamic linking at all -avoid-version do not add a version suffix if possible -bindir BINDIR specify path to binaries directory (for systems where libraries must be found in the PATH setting at runtime) -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -export-symbols SYMFILE try to export only the symbols listed in SYMFILE -export-symbols-regex REGEX try to export only the symbols matching REGEX -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME -module build a library that can dlopened -no-fast-install disable the fast-install mode -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -objectlist FILE use a list of object files found in FILE to specify objects -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) -precious-files-regex REGEX don't remove output files matching REGEX -release RELEASE specify package release information -rpath LIBDIR the created library will eventually be installed in LIBDIR -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries -shared only do dynamic linking of libtool libraries -shrext SUFFIX override the standard shared library file extension -static do not do any dynamic linking of uninstalled libtool libraries -static-libtool-libs do not do any dynamic linking of libtool libraries -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] -weak LIBNAME declare that the target provides the LIBNAME interface -Wc,FLAG -Xcompiler FLAG pass linker-specific FLAG directly to the compiler -Wl,FLAG -Xlinker FLAG pass linker-specific FLAG directly to the linker -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) All other options (arguments beginning with '-') are ignored. Every other argument is treated as a filename. Files ending in '.la' are treated as uninstalled libtool libraries, other files are standard or library object files. If the OUTPUT-FILE ends in '.la', then a libtool library is created, only library objects ('.lo' files) may be specified, and '-rpath' is required, except when creating a convenience library. If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created using 'ar' and 'ranlib', or on Windows using 'lib'. If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file is created, otherwise an executable program is created." ;; uninstall) $ECHO \ "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... Remove libraries from an installation directory. RM is the name of the program to use to delete files associated with each FILE (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed to RM. If FILE is a libtool library, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; *) func_fatal_help "invalid operation mode '$opt_mode'" ;; esac echo $ECHO "Try '$progname --help' for more information about other modes." } # Now that we've collected a possible --mode arg, show help if necessary if $opt_help; then if test : = "$opt_help"; then func_mode_help else { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do func_mode_help done } | $SED -n '1p; 2,$s/^Usage:/ or: /p' { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do echo func_mode_help done } | $SED '1d /^When reporting/,/^Report/{ H d } $x /information about other modes/d /more detailed .*MODE/d s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' fi exit $? fi # func_mode_execute arg... func_mode_execute () { $debug_cmd # The first argument is the command name. cmd=$nonopt test -z "$cmd" && \ func_fatal_help "you must specify a COMMAND" # Handle -dlopen flags immediately. for file in $opt_dlopen; do test -f "$file" \ || func_fatal_help "'$file' is not a file" dir= case $file in *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "'$lib' is not a valid libtool archive" # Read the libtool library. dlname= library_names= func_source "$file" # Skip this library if it cannot be dlopened. if test -z "$dlname"; then # Warn if it was a shared library. test -n "$library_names" && \ func_warning "'$file' was not linked with '-export-dynamic'" continue fi func_dirname "$file" "" "." dir=$func_dirname_result if test -f "$dir/$objdir/$dlname"; then func_append dir "/$objdir" else if test ! -f "$dir/$dlname"; then func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" fi fi ;; *.lo) # Just add the directory containing the .lo file. func_dirname "$file" "" "." dir=$func_dirname_result ;; *) func_warning "'-dlopen' is ignored for non-libtool libraries and objects" continue ;; esac # Get the absolute pathname. absdir=`cd "$dir" && pwd` test -n "$absdir" && dir=$absdir # Now add the directory to shlibpath_var. if eval "test -z \"\$$shlibpath_var\""; then eval "$shlibpath_var=\"\$dir\"" else eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" fi done # This variable tells wrapper scripts just to set shlibpath_var # rather than running their programs. libtool_execute_magic=$magic # Check if any of the arguments is a wrapper script. args= for file do case $file in -* | *.la | *.lo ) ;; *) # Do a test to see if this is really a libtool program. if func_ltwrapper_script_p "$file"; then func_source "$file" # Transform arg to wrapped name. file=$progdir/$program elif func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" func_source "$func_ltwrapper_scriptname_result" # Transform arg to wrapped name. file=$progdir/$program fi ;; esac # Quote arguments (to preserve shell metacharacters). func_append_quoted args "$file" done if $opt_dry_run; then # Display what would be done. if test -n "$shlibpath_var"; then eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" echo "export $shlibpath_var" fi $ECHO "$cmd$args" exit $EXIT_SUCCESS else if test -n "$shlibpath_var"; then # Export the shlibpath_var. eval "export $shlibpath_var" fi # Restore saved environment variables for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${save_$lt_var+set}\" = set; then $lt_var=\$save_$lt_var; export $lt_var else $lt_unset $lt_var fi" done # Now prepare to actually exec the command. exec_cmd=\$cmd$args fi } test execute = "$opt_mode" && func_mode_execute ${1+"$@"} # func_mode_finish arg... func_mode_finish () { $debug_cmd libs= libdirs= admincmds= for opt in "$nonopt" ${1+"$@"} do if test -d "$opt"; then func_append libdirs " $opt" elif test -f "$opt"; then if func_lalib_unsafe_p "$opt"; then func_append libs " $opt" else func_warning "'$opt' is not a valid libtool archive" fi else func_fatal_error "invalid argument '$opt'" fi done if test -n "$libs"; then if test -n "$lt_sysroot"; then sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" else sysroot_cmd= fi # Remove sysroot references if $opt_dry_run; then for lib in $libs; do echo "removing references to $lt_sysroot and '=' prefixes from $lib" done else tmpdir=`func_mktempdir` for lib in $libs; do $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ > $tmpdir/tmp-la mv -f $tmpdir/tmp-la $lib done ${RM}r "$tmpdir" fi fi if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. func_execute_cmds "$finish_cmds" 'admincmds="$admincmds '"$cmd"'"' fi if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" $opt_dry_run || eval "$cmds" || func_append admincmds " $cmds" fi done fi # Exit here if they wanted silent mode. $opt_quiet && exit $EXIT_SUCCESS if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then echo "----------------------------------------------------------------------" echo "Libraries have been installed in:" for libdir in $libdirs; do $ECHO " $libdir" done echo echo "If you ever happen to want to link against installed libraries" echo "in a given directory, LIBDIR, you must either use libtool, and" echo "specify the full pathname of the library, or use the '-LLIBDIR'" echo "flag during linking and do at least one of the following:" if test -n "$shlibpath_var"; then echo " - add LIBDIR to the '$shlibpath_var' environment variable" echo " during execution" fi if test -n "$runpath_var"; then echo " - add LIBDIR to the '$runpath_var' environment variable" echo " during linking" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR eval flag=\"$hardcode_libdir_flag_spec\" $ECHO " - use the '$flag' linker flag" fi if test -n "$admincmds"; then $ECHO " - have your system administrator run these commands:$admincmds" fi if test -f /etc/ld.so.conf; then echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" fi echo echo "See any operating system documentation about shared libraries for" case $host in solaris2.[6789]|solaris2.1[0-9]) echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" echo "pages." ;; *) echo "more information, such as the ld(1) and ld.so(8) manual pages." ;; esac echo "----------------------------------------------------------------------" fi exit $EXIT_SUCCESS } test finish = "$opt_mode" && func_mode_finish ${1+"$@"} # func_mode_install arg... func_mode_install () { $debug_cmd # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || # Allow the use of GNU shtool's install command. case $nonopt in *shtool*) :;; *) false;; esac then # Aesthetically quote it. func_quote_for_eval "$nonopt" install_prog="$func_quote_for_eval_result " arg=$1 shift else install_prog= arg=$nonopt fi # The real first argument should be the name of the installation program. # Aesthetically quote it. func_quote_for_eval "$arg" func_append install_prog "$func_quote_for_eval_result" install_shared_prog=$install_prog case " $install_prog " in *[\\\ /]cp\ *) install_cp=: ;; *) install_cp=false ;; esac # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=false stripme= no_mode=: for arg do arg2= if test -n "$dest"; then func_append files " $dest" dest=$arg continue fi case $arg in -d) isdir=: ;; -f) if $install_cp; then :; else prev=$arg fi ;; -g | -m | -o) prev=$arg ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then if test X-m = "X$prev" && test -n "$install_override_mode"; then arg2=$install_override_mode no_mode=false fi prev= else dest=$arg continue fi ;; esac # Aesthetically quote the argument. func_quote_for_eval "$arg" func_append install_prog " $func_quote_for_eval_result" if test -n "$arg2"; then func_quote_for_eval "$arg2" fi func_append install_shared_prog " $func_quote_for_eval_result" done test -z "$install_prog" && \ func_fatal_help "you must specify an install program" test -n "$prev" && \ func_fatal_help "the '$prev' option requires an argument" if test -n "$install_override_mode" && $no_mode; then if $install_cp; then :; else func_quote_for_eval "$install_override_mode" func_append install_shared_prog " -m $func_quote_for_eval_result" fi fi if test -z "$files"; then if test -z "$dest"; then func_fatal_help "no file or destination specified" else func_fatal_help "you must specify a destination" fi fi # Strip any trailing slash from the destination. func_stripname '' '/' "$dest" dest=$func_stripname_result # Check to see that the destination is a directory. test -d "$dest" && isdir=: if $isdir; then destdir=$dest destname= else func_dirname_and_basename "$dest" "" "." destdir=$func_dirname_result destname=$func_basename_result # Not a directory, so check to see that there is only one file specified. set dummy $files; shift test "$#" -gt 1 && \ func_fatal_help "'$dest' is not a directory" fi case $destdir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) for file in $files; do case $file in *.lo) ;; *) func_fatal_help "'$destdir' must be an absolute directory name" ;; esac done ;; esac # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic=$magic staticlibs= future_libdirs= current_libdirs= for file in $files; do # Do each installation. case $file in *.$libext) # Do the static libraries later. func_append staticlibs " $file" ;; *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "'$file' is not a valid libtool archive" library_names= old_library= relink_command= func_source "$file" # Add the libdir to current_libdirs if it is the destination. if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) func_append current_libdirs " $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) func_append future_libdirs " $libdir" ;; esac fi func_dirname "$file" "/" "" dir=$func_dirname_result func_append dir "$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` # Don't allow the user to place us outside of our expected # location b/c this prevents finding dependent libraries that # are installed to the same prefix. # At present, this check doesn't affect windows .dll's that # are installed into $libdir/../bin (currently, that works fine) # but it's something to keep an eye on. test "$inst_prefix_dir" = "$destdir" && \ func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" if test -n "$inst_prefix_dir"; then # Stick the inst_prefix_dir data into the link command. relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` else relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` fi func_warning "relinking '$file'" func_show_eval "$relink_command" \ 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' fi # See the names of the shared library. set dummy $library_names; shift if test -n "$1"; then realname=$1 shift srcname=$realname test -n "$relink_command" && srcname=${realname}T # Install the shared library and build the symlinks. func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 'exit $?' tstripme=$stripme case $host_os in cygwin* | mingw* | pw32* | cegcc*) case $realname in *.dll.a) tstripme= ;; esac ;; os2*) case $realname in *_dll.a) tstripme= ;; esac ;; esac if test -n "$tstripme" && test -n "$striplib"; then func_show_eval "$striplib $destdir/$realname" 'exit $?' fi if test "$#" -gt 0; then # Delete the old symlinks, and create new ones. # Try 'ln -sf' first, because the 'ln' binary might depend on # the symlink we replace! Solaris /bin/ln does not understand -f, # so we also need to try rm && ln -s. for linkname do test "$linkname" != "$realname" \ && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" done fi # Do each command in the postinstall commands. lib=$destdir/$realname func_execute_cmds "$postinstall_cmds" 'exit $?' fi # Install the pseudo-library for information purposes. func_basename "$file" name=$func_basename_result instname=$dir/${name}i func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' # Maybe install the static library, too. test -n "$old_library" && func_append staticlibs " $dir/$old_library" ;; *.lo) # Install (i.e. copy) a libtool object. # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile=$destdir/$destname else func_basename "$file" destfile=$func_basename_result destfile=$destdir/$destfile fi # Deduce the name of the destination old-style object file. case $destfile in *.lo) func_lo2o "$destfile" staticdest=$func_lo2o_result ;; *.$objext) staticdest=$destfile destfile= ;; *) func_fatal_help "cannot copy a libtool object to '$destfile'" ;; esac # Install the libtool object if requested. test -n "$destfile" && \ func_show_eval "$install_prog $file $destfile" 'exit $?' # Install the old object if enabled. if test yes = "$build_old_libs"; then # Deduce the name of the old-style object file. func_lo2o "$file" staticobj=$func_lo2o_result func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' fi exit $EXIT_SUCCESS ;; *) # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile=$destdir/$destname else func_basename "$file" destfile=$func_basename_result destfile=$destdir/$destfile fi # If the file is missing, and there is a .exe on the end, strip it # because it is most likely a libtool script we actually want to # install stripped_ext= case $file in *.exe) if test ! -f "$file"; then func_stripname '' '.exe' "$file" file=$func_stripname_result stripped_ext=.exe fi ;; esac # Do a test to see if this is really a libtool program. case $host in *cygwin* | *mingw*) if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" wrapper=$func_ltwrapper_scriptname_result else func_stripname '' '.exe' "$file" wrapper=$func_stripname_result fi ;; *) wrapper=$file ;; esac if func_ltwrapper_script_p "$wrapper"; then notinst_deplibs= relink_command= func_source "$wrapper" # Check the variables that should have been set. test -z "$generated_by_libtool_version" && \ func_fatal_error "invalid libtool wrapper script '$wrapper'" finalize=: for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then func_source "$lib" fi libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` if test -n "$libdir" && test ! -f "$libfile"; then func_warning "'$lib' has not been installed in '$libdir'" finalize=false fi done relink_command= func_source "$wrapper" outputname= if test no = "$fast_install" && test -n "$relink_command"; then $opt_dry_run || { if $finalize; then tmpdir=`func_mktempdir` func_basename "$file$stripped_ext" file=$func_basename_result outputname=$tmpdir/$file # Replace the output file specification. relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` $opt_quiet || { func_quote_for_expand "$relink_command" eval "func_echo $func_quote_for_expand_result" } if eval "$relink_command"; then : else func_error "error: relink '$file' with the above command before installing it" $opt_dry_run || ${RM}r "$tmpdir" continue fi file=$outputname else func_warning "cannot relink '$file'" fi } else # Install the binary that we compiled earlier. file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` fi fi # remove .exe since cygwin /usr/bin/install will append another # one anyway case $install_prog,$host in */usr/bin/install*,*cygwin*) case $file:$destfile in *.exe:*.exe) # this is ok ;; *.exe:*) destfile=$destfile.exe ;; *:*.exe) func_stripname '' '.exe' "$destfile" destfile=$func_stripname_result ;; esac ;; esac func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' $opt_dry_run || if test -n "$outputname"; then ${RM}r "$tmpdir" fi ;; esac done for file in $staticlibs; do func_basename "$file" name=$func_basename_result # Set up the ranlib parameters. oldlib=$destdir/$name func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result func_show_eval "$install_prog \$file \$oldlib" 'exit $?' if test -n "$stripme" && test -n "$old_striplib"; then func_show_eval "$old_striplib $tool_oldlib" 'exit $?' fi # Do each command in the postinstall commands. func_execute_cmds "$old_postinstall_cmds" 'exit $?' done test -n "$future_libdirs" && \ func_warning "remember to run '$progname --finish$future_libdirs'" if test -n "$current_libdirs"; then # Maybe just do a dry run. $opt_dry_run && current_libdirs=" -n$current_libdirs" exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' else exit $EXIT_SUCCESS fi } test install = "$opt_mode" && func_mode_install ${1+"$@"} # func_generate_dlsyms outputname originator pic_p # Extract symbols from dlprefiles and create ${outputname}S.o with # a dlpreopen symbol table. func_generate_dlsyms () { $debug_cmd my_outputname=$1 my_originator=$2 my_pic_p=${3-false} my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` my_dlsyms= if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then if test -n "$NM" && test -n "$global_symbol_pipe"; then my_dlsyms=${my_outputname}S.c else func_error "not configured to extract global symbols from dlpreopened files" fi fi if test -n "$my_dlsyms"; then case $my_dlsyms in "") ;; *.c) # Discover the nlist of each of the dlfiles. nlist=$output_objdir/$my_outputname.nm func_show_eval "$RM $nlist ${nlist}S ${nlist}T" # Parse the name list into a source file. func_verbose "creating $output_objdir/$my_dlsyms" $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ /* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ /* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ #ifdef __cplusplus extern \"C\" { #endif #if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" #endif /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE /* DATA imports from DLLs on WIN32 can't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined __osf__ /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) /* External symbol declarations for the compiler. */\ " if test yes = "$dlself"; then func_verbose "generating symbol list for '$output'" $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" # Add our own program objects to the symbol list. progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` for progfile in $progfiles; do func_to_tool_file "$progfile" func_convert_file_msys_to_w32 func_verbose "extracting global C symbols from '$func_to_tool_file_result'" $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then $opt_dry_run || { eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi if test -n "$export_symbols_regex"; then $opt_dry_run || { eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi # Prepare the list of exported symbols if test -z "$export_symbols"; then export_symbols=$output_objdir/$outputname.exp $opt_dry_run || { $RM $export_symbols eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' ;; esac } else $opt_dry_run || { eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; esac } fi fi for dlprefile in $dlprefiles; do func_verbose "extracting global C symbols from '$dlprefile'" func_basename "$dlprefile" name=$func_basename_result case $host in *cygwin* | *mingw* | *cegcc* ) # if an import library, we need to obtain dlname if func_win32_import_lib_p "$dlprefile"; then func_tr_sh "$dlprefile" eval "curr_lafile=\$libfile_$func_tr_sh_result" dlprefile_dlbasename= if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then # Use subshell, to avoid clobbering current variable values dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` if test -n "$dlprefile_dlname"; then func_basename "$dlprefile_dlname" dlprefile_dlbasename=$func_basename_result else # no lafile. user explicitly requested -dlpreopen . $sharedlib_from_linklib_cmd "$dlprefile" dlprefile_dlbasename=$sharedlib_from_linklib_result fi fi $opt_dry_run || { if test -n "$dlprefile_dlbasename"; then eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' else func_warning "Could not compute DLL name from $name" eval '$ECHO ": $name " >> "$nlist"' fi func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" } else # not an import lib $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } fi ;; *) $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } ;; esac done $opt_dry_run || { # Make sure we have at least an empty file. test -f "$nlist" || : > "$nlist" if test -n "$exclude_expsyms"; then $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T $MV "$nlist"T "$nlist" fi # Try sorting and uniquifying the output. if $GREP -v "^: " < "$nlist" | if sort -k 3 /dev/null 2>&1; then sort -k 3 else sort +2 fi | uniq > "$nlist"S; then : else $GREP -v "^: " < "$nlist" > "$nlist"S fi if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' else echo '/* NONE */' >> "$output_objdir/$my_dlsyms" fi func_show_eval '$RM "${nlist}I"' if test -n "$global_symbol_to_import"; then eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' fi echo >> "$output_objdir/$my_dlsyms" "\ /* The mapping between symbol names and symbols. */ typedef struct { const char *name; void *address; } lt_dlsymlist; extern LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[];\ " if test -s "$nlist"I; then echo >> "$output_objdir/$my_dlsyms" "\ static void lt_syminit(void) { LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; for (; symbol->name; ++symbol) {" $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" echo >> "$output_objdir/$my_dlsyms" "\ } }" fi echo >> "$output_objdir/$my_dlsyms" "\ LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = { {\"$my_originator\", (void *) 0}," if test -s "$nlist"I; then echo >> "$output_objdir/$my_dlsyms" "\ {\"@INIT@\", (void *) <_syminit}," fi case $need_lib_prefix in no) eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; *) eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; esac echo >> "$output_objdir/$my_dlsyms" "\ {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt_${my_prefix}_LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif\ " } # !$opt_dry_run pic_flag_for_symtable= case "$compile_command " in *" -static "*) ;; *) case $host in # compiling the symbol table file with pic_flag works around # a FreeBSD bug that causes programs to crash when -lm is # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; *-*-hpux*) pic_flag_for_symtable=" $pic_flag" ;; *) $my_pic_p && pic_flag_for_symtable=" $pic_flag" ;; esac ;; esac symtab_cflags= for arg in $LTCFLAGS; do case $arg in -pie | -fpie | -fPIE) ;; *) func_append symtab_cflags " $arg" ;; esac done # Now compile the dynamic symbol file. func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' # Clean up the generated files. func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' # Transform the symbol file into the correct name. symfileobj=$output_objdir/${my_outputname}S.$objext case $host in *cygwin* | *mingw* | *cegcc* ) if test -f "$output_objdir/$my_outputname.def"; then compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` else compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` fi ;; *) compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` ;; esac ;; *) func_fatal_error "unknown suffix for '$my_dlsyms'" ;; esac else # We keep going just in case the user didn't refer to # lt_preloaded_symbols. The linker will fail if global_symbol_pipe # really was required. # Nullify the symbol file. compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` fi } # func_cygming_gnu_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is a GNU/binutils-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_gnu_implib_p () { $debug_cmd func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` test -n "$func_cygming_gnu_implib_tmp" } # func_cygming_ms_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is an MS-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_ms_implib_p () { $debug_cmd func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` test -n "$func_cygming_ms_implib_tmp" } # func_win32_libid arg # return the library type of file 'arg' # # Need a lot of goo to handle *both* DLLs and import libs # Has to be a shell function in order to 'eat' the argument # that is supplied when $file_magic_command is called. # Despite the name, also deal with 64 bit binaries. func_win32_libid () { $debug_cmd win32_libid_type=unknown win32_fileres=`file -L $1 2>/dev/null` case $win32_fileres in *ar\ archive\ import\ library*) # definitely import win32_libid_type="x86 archive import" ;; *ar\ archive*) # could be an import, or static # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then case $nm_interface in "MS dumpbin") if func_cygming_ms_implib_p "$1" || func_cygming_gnu_implib_p "$1" then win32_nmres=import else win32_nmres= fi ;; *) func_to_tool_file "$1" func_convert_file_msys_to_w32 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | $SED -n -e ' 1,100{ / I /{ s|.*|import| p q } }'` ;; esac case $win32_nmres in import*) win32_libid_type="x86 archive import";; *) win32_libid_type="x86 archive static";; esac fi ;; *DLL*) win32_libid_type="x86 DLL" ;; *executable*) # but shell scripts are "executable" too... case $win32_fileres in *MS\ Windows\ PE\ Intel*) win32_libid_type="x86 DLL" ;; esac ;; esac $ECHO "$win32_libid_type" } # func_cygming_dll_for_implib ARG # # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib () { $debug_cmd sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` } # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs # # The is the core of a fallback implementation of a # platform-specific function to extract the name of the # DLL associated with the specified import library LIBNAME. # # SECTION_NAME is either .idata$6 or .idata$7, depending # on the platform and compiler that created the implib. # # Echos the name of the DLL associated with the # specified import library. func_cygming_dll_for_implib_fallback_core () { $debug_cmd match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` $OBJDUMP -s --section "$1" "$2" 2>/dev/null | $SED '/^Contents of section '"$match_literal"':/{ # Place marker at beginning of archive member dllname section s/.*/====MARK====/ p d } # These lines can sometimes be longer than 43 characters, but # are always uninteresting /:[ ]*file format pe[i]\{,1\}-/d /^In archive [^:]*:/d # Ensure marker is printed /^====MARK====/p # Remove all lines with less than 43 characters /^.\{43\}/!d # From remaining lines, remove first 43 characters s/^.\{43\}//' | $SED -n ' # Join marker and all lines until next marker into a single line /^====MARK====/ b para H $ b para b :para x s/\n//g # Remove the marker s/^====MARK====// # Remove trailing dots and whitespace s/[\. \t]*$// # Print /./p' | # we now have a list, one entry per line, of the stringified # contents of the appropriate section of all members of the # archive that possess that section. Heuristic: eliminate # all those that have a first or second character that is # a '.' (that is, objdump's representation of an unprintable # character.) This should work for all archives with less than # 0x302f exports -- but will fail for DLLs whose name actually # begins with a literal '.' or a single character followed by # a '.'. # # Of those that remain, print the first one. $SED -e '/^\./d;/^.\./d;q' } # func_cygming_dll_for_implib_fallback ARG # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # # This fallback implementation is for use when $DLLTOOL # does not support the --identify-strict option. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib_fallback () { $debug_cmd if func_cygming_gnu_implib_p "$1"; then # binutils import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` elif func_cygming_ms_implib_p "$1"; then # ms-generated import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` else # unknown sharedlib_from_linklib_result= fi } # func_extract_an_archive dir oldlib func_extract_an_archive () { $debug_cmd f_ex_an_ar_dir=$1; shift f_ex_an_ar_oldlib=$1 if test yes = "$lock_old_archive_extraction"; then lockfile=$f_ex_an_ar_oldlib.lock until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done fi func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 'stat=$?; rm -f "$lockfile"; exit $stat' if test yes = "$lock_old_archive_extraction"; then $opt_dry_run || rm -f "$lockfile" fi if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then : else func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" fi } # func_extract_archives gentop oldlib ... func_extract_archives () { $debug_cmd my_gentop=$1; shift my_oldlibs=${1+"$@"} my_oldobjs= my_xlib= my_xabs= my_xdir= for my_xlib in $my_oldlibs; do # Extract the objects. case $my_xlib in [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; *) my_xabs=`pwd`"/$my_xlib" ;; esac func_basename "$my_xlib" my_xlib=$func_basename_result my_xlib_u=$my_xlib while :; do case " $extracted_archives " in *" $my_xlib_u "*) func_arith $extracted_serial + 1 extracted_serial=$func_arith_result my_xlib_u=lt$extracted_serial-$my_xlib ;; *) break ;; esac done extracted_archives="$extracted_archives $my_xlib_u" my_xdir=$my_gentop/$my_xlib_u func_mkdir_p "$my_xdir" case $host in *-darwin*) func_verbose "Extracting $my_xabs" # Do not bother doing anything if just a dry run $opt_dry_run || { darwin_orig_dir=`pwd` cd $my_xdir || exit $? darwin_archive=$my_xabs darwin_curdir=`pwd` func_basename "$darwin_archive" darwin_base_archive=$func_basename_result darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` if test -n "$darwin_arches"; then darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` darwin_arch= func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" for darwin_arch in $darwin_arches; do func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" cd "unfat-$$/$darwin_base_archive-$darwin_arch" func_extract_an_archive "`pwd`" "$darwin_base_archive" cd "$darwin_curdir" $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" done # $darwin_arches ## Okay now we've a bunch of thin objects, gotta fatten them up :) darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` darwin_file= darwin_files= for darwin_file in $darwin_filelist; do darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` $LIPO -create -output "$darwin_file" $darwin_files done # $darwin_filelist $RM -rf unfat-$$ cd "$darwin_orig_dir" else cd $darwin_orig_dir func_extract_an_archive "$my_xdir" "$my_xabs" fi # $darwin_arches } # !$opt_dry_run ;; *) func_extract_an_archive "$my_xdir" "$my_xabs" ;; esac my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` done func_extract_archives_result=$my_oldobjs } # func_emit_wrapper [arg=no] # # Emit a libtool wrapper script on stdout. # Don't directly open a file because we may want to # incorporate the script contents within a cygwin/mingw # wrapper executable. Must ONLY be called from within # func_mode_link because it depends on a number of variables # set therein. # # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR # variable will take. If 'yes', then the emitted script # will assume that the directory where it is stored is # the $objdir directory. This is a cygwin/mingw-specific # behavior. func_emit_wrapper () { func_emit_wrapper_arg1=${1-no} $ECHO "\ #! $SHELL # $output - temporary wrapper script for $objdir/$outputname # Generated by $PROGRAM (GNU $PACKAGE) $VERSION # # The $output program cannot be directly executed until all the libtool # libraries that it depends on are installed. # # This wrapper script should never be moved out of the build directory. # If it is, it will not operate correctly. # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='$sed_quote_subst' # Be Bourne compatible if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH relink_command=\"$relink_command\" # This environment variable determines our operation mode. if test \"\$libtool_install_magic\" = \"$magic\"; then # install mode needs the following variables: generated_by_libtool_version='$macro_version' notinst_deplibs='$notinst_deplibs' else # When we are sourced in execute mode, \$file and \$ECHO are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then file=\"\$0\"" qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` $ECHO "\ # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } ECHO=\"$qECHO\" fi # Very basic option parsing. These options are (a) specific to # the libtool wrapper, (b) are identical between the wrapper # /script/ and the wrapper /executable/ that is used only on # windows platforms, and (c) all begin with the string "--lt-" # (application programs are unlikely to have options that match # this pattern). # # There are only two supported options: --lt-debug and # --lt-dump-script. There is, deliberately, no --lt-help. # # The first argument to this parsing function should be the # script's $0 value, followed by "$@". lt_option_debug= func_parse_lt_options () { lt_script_arg0=\$0 shift for lt_opt do case \"\$lt_opt\" in --lt-debug) lt_option_debug=1 ;; --lt-dump-script) lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` cat \"\$lt_dump_D/\$lt_dump_F\" exit 0 ;; --lt-*) \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 exit 1 ;; esac done # Print the debug banner immediately: if test -n \"\$lt_option_debug\"; then echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 fi } # Used when --lt-debug. Prints its arguments to stdout # (redirection is the responsibility of the caller) func_lt_dump_args () { lt_dump_args_N=1; for lt_arg do \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` done } # Core function for launching the target application func_exec_program_core () { " case $host in # Backslashes separate directories on plain windows *-*-mingw | *-*-os2* | *-cegcc*) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} " ;; *) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir/\$program\" \${1+\"\$@\"} " ;; esac $ECHO "\ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 exit 1 } # A function to encapsulate launching the target application # Strips options in the --lt-* namespace from \$@ and # launches target application with the remaining arguments. func_exec_program () { case \" \$* \" in *\\ --lt-*) for lt_wr_arg do case \$lt_wr_arg in --lt-*) ;; *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; esac shift done ;; esac func_exec_program_core \${1+\"\$@\"} } # Parse options func_parse_lt_options \"\$0\" \${1+\"\$@\"} # Find the directory that this script lives in. thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` test \"x\$thisdir\" = \"x\$file\" && thisdir=. # Follow symbolic links until we get to the real thisdir. file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` while test -n \"\$file\"; do destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` # If there was a directory component, then change thisdir. if test \"x\$destdir\" != \"x\$file\"; then case \"\$destdir\" in [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; *) thisdir=\"\$thisdir/\$destdir\" ;; esac fi file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` done # Usually 'no', except on cygwin/mingw when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then # special case for '.' if test \"\$thisdir\" = \".\"; then thisdir=\`pwd\` fi # remove .libs from thisdir case \"\$thisdir\" in *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; $objdir ) thisdir=. ;; esac fi # Try to get the absolute directory name. absdir=\`cd \"\$thisdir\" && pwd\` test -n \"\$absdir\" && thisdir=\"\$absdir\" " if test yes = "$fast_install"; then $ECHO "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" if test ! -d \"\$progdir\"; then $MKDIR \"\$progdir\" else $RM \"\$progdir/\$file\" fi" $ECHO "\ # relink executable if necessary if test -n \"\$relink_command\"; then if relink_command_output=\`eval \$relink_command 2>&1\`; then : else \$ECHO \"\$relink_command_output\" >&2 $RM \"\$progdir/\$file\" exit 1 fi fi $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || { $RM \"\$progdir/\$program\"; $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } $RM \"\$progdir/\$file\" fi" else $ECHO "\ program='$outputname' progdir=\"\$thisdir/$objdir\" " fi $ECHO "\ if test -f \"\$progdir/\$program\"; then" # fixup the dll searchpath if we need to. # # Fix the DLL searchpath if we need to. Do this before prepending # to shlibpath, because on Windows, both are PATH and uninstalled # libraries must come first. if test -n "$dllsearchpath"; then $ECHO "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi # Export our shlibpath_var if we have one. if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $ECHO "\ # Add our own library path to $shlibpath_var $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" # Some systems cannot cope with colon-terminated $shlibpath_var # The second colon is a workaround for a bug in BeOS R4 sed $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` export $shlibpath_var " fi $ECHO "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. func_exec_program \${1+\"\$@\"} fi else # The program doesn't exist. \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 exit 1 fi fi\ " } # func_emit_cwrapperexe_src # emit the source code for a wrapper executable on stdout # Must ONLY be called from within func_mode_link because # it depends on a number of variable set therein. func_emit_cwrapperexe_src () { cat < #include #ifdef _MSC_VER # include # include # include #else # include # include # ifdef __CYGWIN__ # include # endif #endif #include #include #include #include #include #include #include #include #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) /* declarations of non-ANSI functions */ #if defined __MINGW32__ # ifdef __STRICT_ANSI__ int _putenv (const char *); # endif #elif defined __CYGWIN__ # ifdef __STRICT_ANSI__ char *realpath (const char *, char *); int putenv (char *); int setenv (const char *, const char *, int); # endif /* #elif defined other_platform || defined ... */ #endif /* portability defines, excluding path handling macros */ #if defined _MSC_VER # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv # define S_IXUSR _S_IEXEC #elif defined __MINGW32__ # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv #elif defined __CYGWIN__ # define HAVE_SETENV # define FOPEN_WB "wb" /* #elif defined other platforms ... */ #endif #if defined PATH_MAX # define LT_PATHMAX PATH_MAX #elif defined MAXPATHLEN # define LT_PATHMAX MAXPATHLEN #else # define LT_PATHMAX 1024 #endif #ifndef S_IXOTH # define S_IXOTH 0 #endif #ifndef S_IXGRP # define S_IXGRP 0 #endif /* path handling portability macros */ #ifndef DIR_SEPARATOR # define DIR_SEPARATOR '/' # define PATH_SEPARATOR ':' #endif #if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ defined __OS2__ # define HAVE_DOS_BASED_FILE_SYSTEM # define FOPEN_WB "wb" # ifndef DIR_SEPARATOR_2 # define DIR_SEPARATOR_2 '\\' # endif # ifndef PATH_SEPARATOR_2 # define PATH_SEPARATOR_2 ';' # endif #endif #ifndef DIR_SEPARATOR_2 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) #else /* DIR_SEPARATOR_2 */ # define IS_DIR_SEPARATOR(ch) \ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) #endif /* DIR_SEPARATOR_2 */ #ifndef PATH_SEPARATOR_2 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) #else /* PATH_SEPARATOR_2 */ # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) #endif /* PATH_SEPARATOR_2 */ #ifndef FOPEN_WB # define FOPEN_WB "w" #endif #ifndef _O_BINARY # define _O_BINARY 0 #endif #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) #define XFREE(stale) do { \ if (stale) { free (stale); stale = 0; } \ } while (0) #if defined LT_DEBUGWRAPPER static int lt_debug = 1; #else static int lt_debug = 0; #endif const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ void *xmalloc (size_t num); char *xstrdup (const char *string); const char *base_name (const char *name); char *find_executable (const char *wrapper); char *chase_symlinks (const char *pathspec); int make_executable (const char *path); int check_executable (const char *path); char *strendzap (char *str, const char *pat); void lt_debugprintf (const char *file, int line, const char *fmt, ...); void lt_fatal (const char *file, int line, const char *message, ...); static const char *nonnull (const char *s); static const char *nonempty (const char *s); void lt_setenv (const char *name, const char *value); char *lt_extend_str (const char *orig_value, const char *add, int to_end); void lt_update_exe_path (const char *name, const char *value); void lt_update_lib_path (const char *name, const char *value); char **prepare_spawn (char **argv); void lt_dump_script (FILE *f); EOF cat <= 0) && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) return 1; else return 0; } int make_executable (const char *path) { int rval = 0; struct stat st; lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", nonempty (path)); if ((!path) || (!*path)) return 0; if (stat (path, &st) >= 0) { rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); } return rval; } /* Searches for the full path of the wrapper. Returns newly allocated full path name if found, NULL otherwise Does not chase symlinks, even on platforms that support them. */ char * find_executable (const char *wrapper) { int has_slash = 0; const char *p; const char *p_next; /* static buffer for getcwd */ char tmp[LT_PATHMAX + 1]; size_t tmp_len; char *concat_name; lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", nonempty (wrapper)); if ((wrapper == NULL) || (*wrapper == '\0')) return NULL; /* Absolute path? */ #if defined HAVE_DOS_BASED_FILE_SYSTEM if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } else { #endif if (IS_DIR_SEPARATOR (wrapper[0])) { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } #if defined HAVE_DOS_BASED_FILE_SYSTEM } #endif for (p = wrapper; *p; p++) if (*p == '/') { has_slash = 1; break; } if (!has_slash) { /* no slashes; search PATH */ const char *path = getenv ("PATH"); if (path != NULL) { for (p = path; *p; p = p_next) { const char *q; size_t p_len; for (q = p; *q; q++) if (IS_PATH_SEPARATOR (*q)) break; p_len = (size_t) (q - p); p_next = (*q == '\0' ? q : q + 1); if (p_len == 0) { /* empty path: current directory */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); } else { concat_name = XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, p, p_len); concat_name[p_len] = '/'; strcpy (concat_name + p_len + 1, wrapper); } if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } } /* not found in PATH; assume curdir */ } /* Relative path | not found in path: prepend cwd */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); return NULL; } char * chase_symlinks (const char *pathspec) { #ifndef S_ISLNK return xstrdup (pathspec); #else char buf[LT_PATHMAX]; struct stat s; char *tmp_pathspec = xstrdup (pathspec); char *p; int has_symlinks = 0; while (strlen (tmp_pathspec) && !has_symlinks) { lt_debugprintf (__FILE__, __LINE__, "checking path component for symlinks: %s\n", tmp_pathspec); if (lstat (tmp_pathspec, &s) == 0) { if (S_ISLNK (s.st_mode) != 0) { has_symlinks = 1; break; } /* search backwards for last DIR_SEPARATOR */ p = tmp_pathspec + strlen (tmp_pathspec) - 1; while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) p--; if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) { /* no more DIR_SEPARATORS left */ break; } *p = '\0'; } else { lt_fatal (__FILE__, __LINE__, "error accessing file \"%s\": %s", tmp_pathspec, nonnull (strerror (errno))); } } XFREE (tmp_pathspec); if (!has_symlinks) { return xstrdup (pathspec); } tmp_pathspec = realpath (pathspec, buf); if (tmp_pathspec == 0) { lt_fatal (__FILE__, __LINE__, "could not follow symlinks for %s", pathspec); } return xstrdup (tmp_pathspec); #endif } char * strendzap (char *str, const char *pat) { size_t len, patlen; assert (str != NULL); assert (pat != NULL); len = strlen (str); patlen = strlen (pat); if (patlen <= len) { str += len - patlen; if (STREQ (str, pat)) *str = '\0'; } return str; } void lt_debugprintf (const char *file, int line, const char *fmt, ...) { va_list args; if (lt_debug) { (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); va_start (args, fmt); (void) vfprintf (stderr, fmt, args); va_end (args); } } static void lt_error_core (int exit_status, const char *file, int line, const char *mode, const char *message, va_list ap) { fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); vfprintf (stderr, message, ap); fprintf (stderr, ".\n"); if (exit_status >= 0) exit (exit_status); } void lt_fatal (const char *file, int line, const char *message, ...) { va_list ap; va_start (ap, message); lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); va_end (ap); } static const char * nonnull (const char *s) { return s ? s : "(null)"; } static const char * nonempty (const char *s) { return (s && !*s) ? "(empty)" : nonnull (s); } void lt_setenv (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_setenv) setting '%s' to '%s'\n", nonnull (name), nonnull (value)); { #ifdef HAVE_SETENV /* always make a copy, for consistency with !HAVE_SETENV */ char *str = xstrdup (value); setenv (name, str, 1); #else size_t len = strlen (name) + 1 + strlen (value) + 1; char *str = XMALLOC (char, len); sprintf (str, "%s=%s", name, value); if (putenv (str) != EXIT_SUCCESS) { XFREE (str); } #endif } } char * lt_extend_str (const char *orig_value, const char *add, int to_end) { char *new_value; if (orig_value && *orig_value) { size_t orig_value_len = strlen (orig_value); size_t add_len = strlen (add); new_value = XMALLOC (char, add_len + orig_value_len + 1); if (to_end) { strcpy (new_value, orig_value); strcpy (new_value + orig_value_len, add); } else { strcpy (new_value, add); strcpy (new_value + add_len, orig_value); } } else { new_value = xstrdup (add); } return new_value; } void lt_update_exe_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); /* some systems can't cope with a ':'-terminated path #' */ size_t len = strlen (new_value); while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) { new_value[--len] = '\0'; } lt_setenv (name, new_value); XFREE (new_value); } } void lt_update_lib_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); lt_setenv (name, new_value); XFREE (new_value); } } EOF case $host_os in mingw*) cat <<"EOF" /* Prepares an argument vector before calling spawn(). Note that spawn() does not by itself call the command interpreter (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&v); v.dwPlatformId == VER_PLATFORM_WIN32_NT; }) ? "cmd.exe" : "command.com"). Instead it simply concatenates the arguments, separated by ' ', and calls CreateProcess(). We must quote the arguments since Win32 CreateProcess() interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a special way: - Space and tab are interpreted as delimiters. They are not treated as delimiters if they are surrounded by double quotes: "...". - Unescaped double quotes are removed from the input. Their only effect is that within double quotes, space and tab are treated like normal characters. - Backslashes not followed by double quotes are not special. - But 2*n+1 backslashes followed by a double quote become n backslashes followed by a double quote (n >= 0): \" -> " \\\" -> \" \\\\\" -> \\" */ #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" char ** prepare_spawn (char **argv) { size_t argc; char **new_argv; size_t i; /* Count number of arguments. */ for (argc = 0; argv[argc] != NULL; argc++) ; /* Allocate new argument vector. */ new_argv = XMALLOC (char *, argc + 1); /* Put quoted arguments into the new argument vector. */ for (i = 0; i < argc; i++) { const char *string = argv[i]; if (string[0] == '\0') new_argv[i] = xstrdup ("\"\""); else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) { int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); size_t length; unsigned int backslashes; const char *s; char *quoted_string; char *p; length = 0; backslashes = 0; if (quote_around) length++; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') length += backslashes + 1; length++; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) length += backslashes + 1; quoted_string = XMALLOC (char, length + 1); p = quoted_string; backslashes = 0; if (quote_around) *p++ = '"'; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') { unsigned int j; for (j = backslashes + 1; j > 0; j--) *p++ = '\\'; } *p++ = c; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) { unsigned int j; for (j = backslashes; j > 0; j--) *p++ = '\\'; *p++ = '"'; } *p = '\0'; new_argv[i] = quoted_string; } else new_argv[i] = (char *) string; } new_argv[argc] = NULL; return new_argv; } EOF ;; esac cat <<"EOF" void lt_dump_script (FILE* f) { EOF func_emit_wrapper yes | $SED -n -e ' s/^\(.\{79\}\)\(..*\)/\1\ \2/ h s/\([\\"]\)/\\\1/g s/$/\\n/ s/\([^\n]*\).*/ fputs ("\1", f);/p g D' cat <<"EOF" } EOF } # end: func_emit_cwrapperexe_src # func_win32_import_lib_p ARG # True if ARG is an import lib, as indicated by $file_magic_cmd func_win32_import_lib_p () { $debug_cmd case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in *import*) : ;; *) false ;; esac } # func_suncc_cstd_abi # !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! # Several compiler flags select an ABI that is incompatible with the # Cstd library. Avoid specifying it if any are in CXXFLAGS. func_suncc_cstd_abi () { $debug_cmd case " $compile_command " in *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) suncc_use_cstd_abi=no ;; *) suncc_use_cstd_abi=yes ;; esac } # func_mode_link arg... func_mode_link () { $debug_cmd case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) # It is impossible to link a dll without this setting, and # we shouldn't force the makefile maintainer to figure out # what system we are compiling for in order to pass an extra # flag for every libtool invocation. # allow_undefined=no # FIXME: Unfortunately, there are problems with the above when trying # to make a dll that has undefined symbols, in which case not # even a static library is built. For now, we need to specify # -no-undefined on the libtool link line when we can be certain # that all symbols are satisfied, otherwise we get a static library. allow_undefined=yes ;; *) allow_undefined=yes ;; esac libtool_args=$nonopt base_compile="$nonopt $@" compile_command=$nonopt finalize_command=$nonopt compile_rpath= finalize_rpath= compile_shlibpath= finalize_shlibpath= convenience= old_convenience= deplibs= old_deplibs= compiler_flags= linker_flags= dllsearchpath= lib_search_path=`pwd` inst_prefix_dir= new_inherited_linker_flags= avoid_version=no bindir= dlfiles= dlprefiles= dlself=no export_dynamic=no export_symbols= export_symbols_regex= generated= libobjs= ltlibs= module=no no_install=no objs= os2dllname= non_pic_objects= precious_files_regex= prefer_static_libs=no preload=false prev= prevarg= release= rpath= xrpath= perm_rpath= temp_rpath= thread_safe=no vinfo= vinfo_number=no weak_libs= single_module=$wl-single_module func_infer_tag $base_compile # We need to know -static, to get the right output filenames. for arg do case $arg in -shared) test yes != "$build_libtool_libs" \ && func_fatal_configuration "cannot build a shared library" build_old_libs=no break ;; -all-static | -static | -static-libtool-libs) case $arg in -all-static) if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then func_warning "complete static linking is impossible in this configuration" fi if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; -static) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=built ;; -static-libtool-libs) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; esac build_libtool_libs=no build_old_libs=yes break ;; esac done # See if our shared archives depend on static archives. test -n "$old_archive_from_new_cmds" && build_old_libs=yes # Go through the arguments, transforming them on the way. while test "$#" -gt 0; do arg=$1 shift func_quote_for_eval "$arg" qarg=$func_quote_for_eval_unquoted_result func_append libtool_args " $func_quote_for_eval_result" # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in output) func_append compile_command " @OUTPUT@" func_append finalize_command " @OUTPUT@" ;; esac case $prev in bindir) bindir=$arg prev= continue ;; dlfiles|dlprefiles) $preload || { # Add the symbol object into the linking commands. func_append compile_command " @SYMFILE@" func_append finalize_command " @SYMFILE@" preload=: } case $arg in *.la | *.lo) ;; # We handle these cases below. force) if test no = "$dlself"; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test dlprefiles = "$prev"; then dlself=yes elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test dlfiles = "$prev"; then func_append dlfiles " $arg" else func_append dlprefiles " $arg" fi prev= continue ;; esac ;; expsyms) export_symbols=$arg test -f "$arg" \ || func_fatal_error "symbol file '$arg' does not exist" prev= continue ;; expsyms_regex) export_symbols_regex=$arg prev= continue ;; framework) case $host in *-*-darwin*) case "$deplibs " in *" $qarg.ltframework "*) ;; *) func_append deplibs " $qarg.ltframework" # this is fixed later ;; esac ;; esac prev= continue ;; inst_prefix) inst_prefix_dir=$arg prev= continue ;; mllvm) # Clang does not use LLVM to link, so we can simply discard any # '-mllvm $arg' options when doing the link step. prev= continue ;; objectlist) if test -f "$arg"; then save_arg=$arg moreargs= for fil in `cat "$save_arg"` do # func_append moreargs " $fil" arg=$fil # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test none = "$pic_object" && test none = "$non_pic_object"; then func_fatal_error "cannot find name of object for '$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir=$func_dirname_result if test none != "$pic_object"; then # Prepend the subdirectory the object is found in. pic_object=$xdir$pic_object if test dlfiles = "$prev"; then if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test dlprefiles = "$prev"; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg=$pic_object fi # Non-PIC object. if test none != "$non_pic_object"; then # Prepend the subdirectory the object is found in. non_pic_object=$xdir$non_pic_object # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test none = "$pic_object"; then arg=$non_pic_object fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object=$pic_object func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir=$func_dirname_result func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "'$arg' is not a valid libtool object" fi fi done else func_fatal_error "link input file '$arg' does not exist" fi arg=$save_arg prev= continue ;; os2dllname) os2dllname=$arg prev= continue ;; precious_regex) precious_files_regex=$arg prev= continue ;; release) release=-$arg prev= continue ;; rpath | xrpath) # We need an absolute path. case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac if test rpath = "$prev"; then case "$rpath " in *" $arg "*) ;; *) func_append rpath " $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) func_append xrpath " $arg" ;; esac fi prev= continue ;; shrext) shrext_cmds=$arg prev= continue ;; weak) func_append weak_libs " $arg" prev= continue ;; xcclinker) func_append linker_flags " $qarg" func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xcompiler) func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xlinker) func_append linker_flags " $qarg" func_append compiler_flags " $wl$qarg" prev= func_append compile_command " $wl$qarg" func_append finalize_command " $wl$qarg" continue ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac fi # test -n "$prev" prevarg=$arg case $arg in -all-static) if test -n "$link_static_flag"; then # See comment for -static flag below, for more details. func_append compile_command " $link_static_flag" func_append finalize_command " $link_static_flag" fi continue ;; -allow-undefined) # FIXME: remove this flag sometime in the future. func_fatal_error "'-allow-undefined' must not be used because it is the default" ;; -avoid-version) avoid_version=yes continue ;; -bindir) prev=bindir continue ;; -dlopen) prev=dlfiles continue ;; -dlpreopen) prev=dlprefiles continue ;; -export-dynamic) export_dynamic=yes continue ;; -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then func_fatal_error "more than one -exported-symbols argument is not allowed" fi if test X-export-symbols = "X$arg"; then prev=expsyms else prev=expsyms_regex fi continue ;; -framework) prev=framework continue ;; -inst-prefix-dir) prev=inst_prefix continue ;; # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) case $with_gcc/$host in no/*-*-irix* | /*-*-irix*) func_append compile_command " $arg" func_append finalize_command " $arg" ;; esac continue ;; -L*) func_stripname "-L" '' "$arg" if test -z "$func_stripname_result"; then if test "$#" -gt 0; then func_fatal_error "require no space between '-L' and '$1'" else func_fatal_error "need path for '-L' option" fi fi func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) absdir=`cd "$dir" && pwd` test -z "$absdir" && \ func_fatal_error "cannot determine absolute directory name of '$dir'" dir=$absdir ;; esac case "$deplibs " in *" -L$dir "* | *" $arg "*) # Will only happen for absolute or sysroot arguments ;; *) # Preserve sysroot, but never include relative directories case $dir in [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; *) func_append deplibs " -L$dir" ;; esac func_append lib_search_path " $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; ::) dllsearchpath=$dir;; *) func_append dllsearchpath ":$dir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac continue ;; -l*) if test X-lc = "X$arg" || test X-lm = "X$arg"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) # These systems don't actually have a C or math library (as such) continue ;; *-*-os2*) # These systems don't actually have a C library (as such) test X-lc = "X$arg" && continue ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) # Do not include libc due to us having libc/libc_r. test X-lc = "X$arg" && continue ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C and math libraries are in the System framework func_append deplibs " System.ltframework" continue ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype test X-lc = "X$arg" && continue ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work test X-lc = "X$arg" && continue ;; esac elif test X-lc_r = "X$arg"; then case $host in *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) # Do not include libc_r directly, use -pthread flag. continue ;; esac fi func_append deplibs " $arg" continue ;; -mllvm) prev=mllvm continue ;; -module) module=yes continue ;; # Tru64 UNIX uses -model [arg] to determine the layout of C++ # classes, name mangling, and exception handling. # Darwin uses the -arch flag to determine output architecture. -model|-arch|-isysroot|--sysroot) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" prev=xcompiler continue ;; -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case "$new_inherited_linker_flags " in *" $arg "*) ;; * ) func_append new_inherited_linker_flags " $arg" ;; esac continue ;; -multi_module) single_module=$wl-multi_module continue ;; -no-fast-install) fast_install=no continue ;; -no-install) case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) # The PATH hackery in wrapper scripts is required on Windows # and Darwin in order for the loader to find any dlls it needs. func_warning "'-no-install' is ignored for $host" func_warning "assuming '-no-fast-install' instead" fast_install=no ;; *) no_install=yes ;; esac continue ;; -no-undefined) allow_undefined=no continue ;; -objectlist) prev=objectlist continue ;; -os2dllname) prev=os2dllname continue ;; -o) prev=output ;; -precious-files-regex) prev=precious_regex continue ;; -release) prev=release continue ;; -rpath) prev=rpath continue ;; -R) prev=xrpath continue ;; -R*) func_stripname '-R' '' "$arg" dir=$func_stripname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; =*) func_stripname '=' '' "$dir" dir=$lt_sysroot$func_stripname_result ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac continue ;; -shared) # The effects of -shared are defined in a previous loop. continue ;; -shrext) prev=shrext continue ;; -static | -static-libtool-libs) # The effects of -static are defined in a previous loop. # We used to do the same as -all-static on platforms that # didn't have a PIC flag, but the assumption that the effects # would be equivalent was wrong. It would break on at least # Digital Unix and AIX. continue ;; -thread-safe) thread_safe=yes continue ;; -version-info) prev=vinfo continue ;; -version-number) prev=vinfo vinfo_number=yes continue ;; -weak) prev=weak continue ;; -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result arg= save_ifs=$IFS; IFS=, for flag in $args; do IFS=$save_ifs func_quote_for_eval "$flag" func_append arg " $func_quote_for_eval_result" func_append compiler_flags " $func_quote_for_eval_result" done IFS=$save_ifs func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Wl,*) func_stripname '-Wl,' '' "$arg" args=$func_stripname_result arg= save_ifs=$IFS; IFS=, for flag in $args; do IFS=$save_ifs func_quote_for_eval "$flag" func_append arg " $wl$func_quote_for_eval_result" func_append compiler_flags " $wl$func_quote_for_eval_result" func_append linker_flags " $func_quote_for_eval_result" done IFS=$save_ifs func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Xcompiler) prev=xcompiler continue ;; -Xlinker) prev=xlinker continue ;; -XCClinker) prev=xcclinker continue ;; # -msg_* for osf cc -msg_*) func_quote_for_eval "$arg" arg=$func_quote_for_eval_result ;; # Flags to be passed through unchanged, with rationale: # -64, -mips[0-9] enable 64-bit mode for the SGI compiler # -r[0-9][0-9]* specify processor for the SGI compiler # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler # +DA*, +DD* enable 64-bit mode for the HP compiler # -q* compiler args for the IBM compiler # -m*, -t[45]*, -txscale* architecture-specific flags for GCC # -F/path path to uninstalled frameworks, gcc on darwin # -p, -pg, --coverage, -fprofile-* profiling flags for GCC # -fstack-protector* stack protector flags for GCC # @file GCC response files # -tp=* Portland pgcc target processor selection # --sysroot=* for sysroot support # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization # -specs=* GCC specs files # -stdlib=* select c++ std lib with clang # -fsanitize=* Clang/GCC memory and address sanitizer # -fuse-ld=* Linker select flags for GCC -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ -specs=*|-fsanitize=*|-fuse-ld=*) func_quote_for_eval "$arg" arg=$func_quote_for_eval_result func_append compile_command " $arg" func_append finalize_command " $arg" func_append compiler_flags " $arg" continue ;; -Z*) if test os2 = "`expr $host : '.*\(os2\)'`"; then # OS/2 uses -Zxxx to specify OS/2-specific options compiler_flags="$compiler_flags $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case $arg in -Zlinker | -Zstack) prev=xcompiler ;; esac continue else # Otherwise treat like 'Some other compiler flag' below func_quote_for_eval "$arg" arg=$func_quote_for_eval_result fi ;; # Some other compiler flag. -* | +*) func_quote_for_eval "$arg" arg=$func_quote_for_eval_result ;; *.$objext) # A standard object. func_append objs " $arg" ;; *.lo) # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test none = "$pic_object" && test none = "$non_pic_object"; then func_fatal_error "cannot find name of object for '$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir=$func_dirname_result test none = "$pic_object" || { # Prepend the subdirectory the object is found in. pic_object=$xdir$pic_object if test dlfiles = "$prev"; then if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test dlprefiles = "$prev"; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg=$pic_object } # Non-PIC object. if test none != "$non_pic_object"; then # Prepend the subdirectory the object is found in. non_pic_object=$xdir$non_pic_object # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test none = "$pic_object"; then arg=$non_pic_object fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object=$pic_object func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir=$func_dirname_result func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "'$arg' is not a valid libtool object" fi fi ;; *.$libext) # An archive. func_append deplibs " $arg" func_append old_deplibs " $arg" continue ;; *.la) # A libtool-controlled library. func_resolve_sysroot "$arg" if test dlfiles = "$prev"; then # This library was specified with -dlopen. func_append dlfiles " $func_resolve_sysroot_result" prev= elif test dlprefiles = "$prev"; then # The library was specified with -dlpreopen. func_append dlprefiles " $func_resolve_sysroot_result" prev= else func_append deplibs " $func_resolve_sysroot_result" fi continue ;; # Some other compiler argument. *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. func_quote_for_eval "$arg" arg=$func_quote_for_eval_result ;; esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then func_append compile_command " $arg" func_append finalize_command " $arg" fi done # argument parsing loop test -n "$prev" && \ func_fatal_help "the '$prevarg' option requires an argument" if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" func_append compile_command " $arg" func_append finalize_command " $arg" fi oldlibs= # calculate the name of the file, without its directory func_basename "$output" outputname=$func_basename_result libobjs_save=$libobjs if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` else shlib_search_path= fi eval sys_lib_search_path=\"$sys_lib_search_path_spec\" eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" # Definition is injected by LT_CONFIG during libtool generation. func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" func_dirname "$output" "/" "" output_objdir=$func_dirname_result$objdir func_to_tool_file "$output_objdir/" tool_output_objdir=$func_to_tool_file_result # Create the object directory. func_mkdir_p "$output_objdir" # Determine the type of output case $output in "") func_fatal_help "you must specify an output file" ;; *.$libext) linkmode=oldlib ;; *.lo | *.$objext) linkmode=obj ;; *.la) linkmode=lib ;; *) linkmode=prog ;; # Anything else should be a program. esac specialdeplibs= libs= # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do if $opt_preserve_dup_deps; then case "$libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append libs " $deplib" done if test lib = "$linkmode"; then libs="$predeps $libs $compiler_lib_search_path $postdeps" # Compute libraries that are listed more than once in $predeps # $postdeps and mark them as special (i.e., whose duplicates are # not to be eliminated). pre_post_deps= if $opt_duplicate_compiler_generated_deps; then for pre_post_dep in $predeps $postdeps; do case "$pre_post_deps " in *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; esac func_append pre_post_deps " $pre_post_dep" done fi pre_post_deps= fi deplibs= newdependency_libs= newlib_search_path= need_relink=no # whether we're linking any uninstalled libtool libraries notinst_deplibs= # not-installed libtool libraries notinst_path= # paths that contain not-installed libtool libraries case $linkmode in lib) passes="conv dlpreopen link" for file in $dlfiles $dlprefiles; do case $file in *.la) ;; *) func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" ;; esac done ;; prog) compile_deplibs= finalize_deplibs= alldeplibs=false newdlfiles= newdlprefiles= passes="conv scan dlopen dlpreopen link" ;; *) passes="conv" ;; esac for pass in $passes; do # The preopen pass in lib mode reverses $deplibs; put it back here # so that -L comes before libs that need it for instance... if test lib,link = "$linkmode,$pass"; then ## FIXME: Find the place where the list is rebuilt in the wrong ## order, and fix it there properly tmp_deplibs= for deplib in $deplibs; do tmp_deplibs="$deplib $tmp_deplibs" done deplibs=$tmp_deplibs fi if test lib,link = "$linkmode,$pass" || test prog,scan = "$linkmode,$pass"; then libs=$deplibs deplibs= fi if test prog = "$linkmode"; then case $pass in dlopen) libs=$dlfiles ;; dlpreopen) libs=$dlprefiles ;; link) libs="$deplibs %DEPLIBS%" test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" ;; esac fi if test lib,dlpreopen = "$linkmode,$pass"; then # Collect and forward deplibs of preopened libtool libs for lib in $dlprefiles; do # Ignore non-libtool-libs dependency_libs= func_resolve_sysroot "$lib" case $lib in *.la) func_source "$func_resolve_sysroot_result" ;; esac # Collect preopened libtool deplibs, except any this library # has declared as weak libs for deplib in $dependency_libs; do func_basename "$deplib" deplib_base=$func_basename_result case " $weak_libs " in *" $deplib_base "*) ;; *) func_append deplibs " $deplib" ;; esac done done libs=$dlprefiles fi if test dlopen = "$pass"; then # Collect dlpreopened libraries save_deplibs=$deplibs deplibs= fi for deplib in $libs; do lib= found=false case $deplib in -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append compiler_flags " $deplib" if test lib = "$linkmode"; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -l*) if test lib != "$linkmode" && test prog != "$linkmode"; then func_warning "'-l' is ignored for archives/objects" continue fi func_stripname '-l' '' "$deplib" name=$func_stripname_result if test lib = "$linkmode"; then searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" else searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" fi for searchdir in $searchdirs; do for search_ext in .la $std_shrext .so .a; do # Search the libtool library lib=$searchdir/lib$name$search_ext if test -f "$lib"; then if test .la = "$search_ext"; then found=: else found=false fi break 2 fi done done if $found; then # deplib is a libtool library # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, # We need to do some special things here, and not later. if test yes = "$allow_libtool_libs_with_static_runtimes"; then case " $predeps $postdeps " in *" $deplib "*) if func_lalib_p "$lib"; then library_names= old_library= func_source "$lib" for l in $old_library $library_names; do ll=$l done if test "X$ll" = "X$old_library"; then # only static version available found=false func_dirname "$lib" "" "." ladir=$func_dirname_result lib=$ladir/$old_library if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" fi continue fi fi ;; *) ;; esac fi else # deplib doesn't seem to be a libtool library if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" fi continue fi ;; # -l *.ltframework) if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" if test lib = "$linkmode"; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -L*) case $linkmode in lib) deplibs="$deplib $deplibs" test conv = "$pass" && continue newdependency_libs="$deplib $newdependency_libs" func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; prog) if test conv = "$pass"; then deplibs="$deplib $deplibs" continue fi if test scan = "$pass"; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; *) func_warning "'-L' is ignored for archives/objects" ;; esac # linkmode continue ;; # -L -R*) if test link = "$pass"; then func_stripname '-R' '' "$deplib" func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) func_resolve_sysroot "$deplib" lib=$func_resolve_sysroot_result ;; *.$libext) if test conv = "$pass"; then deplibs="$deplib $deplibs" continue fi case $linkmode in lib) # Linking convenience modules into shared libraries is allowed, # but linking other static libraries is non-portable. case " $dlpreconveniencelibs " in *" $deplib "*) ;; *) valid_a_lib=false case $deplibs_check_method in match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then valid_a_lib=: fi ;; pass_all) valid_a_lib=: ;; esac if $valid_a_lib; then echo $ECHO "*** Warning: Linking the shared library $output against the" $ECHO "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" else echo $ECHO "*** Warning: Trying to link with static lib archive $deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because the file extensions .$libext of this argument makes me believe" echo "*** that it is just a static archive that I should not use here." fi ;; esac continue ;; prog) if test link != "$pass"; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test conv = "$pass"; then deplibs="$deplib $deplibs" elif test prog = "$linkmode"; then if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then # If there is no dlopen support or we're linking statically, # we need to preload. func_append newdlprefiles " $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append newdlfiles " $deplib" fi fi continue ;; %DEPLIBS%) alldeplibs=: continue ;; esac # case $deplib $found || test -f "$lib" \ || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$lib" \ || func_fatal_error "'$lib' is not a valid libtool archive" func_dirname "$lib" "" "." ladir=$func_dirname_result dlname= dlopen= dlpreopen= libdir= library_names= old_library= inherited_linker_flags= # If the library was installed with an old release of libtool, # it will not redefine variables installed, or shouldnotlink installed=yes shouldnotlink=no avoidtemprpath= # Read the .la file func_source "$lib" # Convert "-framework foo" to "foo.ltframework" if test -n "$inherited_linker_flags"; then tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do case " $new_inherited_linker_flags " in *" $tmp_inherited_linker_flag "*) ;; *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; esac done fi dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` if test lib,link = "$linkmode,$pass" || test prog,scan = "$linkmode,$pass" || { test prog != "$linkmode" && test lib != "$linkmode"; }; then test -n "$dlopen" && func_append dlfiles " $dlopen" test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" fi if test conv = "$pass"; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then func_fatal_error "cannot find name of link library for '$lib'" fi # It is a libtool convenience library, so add in its objects. func_append convenience " $ladir/$objdir/$old_library" func_append old_convenience " $ladir/$objdir/$old_library" tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if $opt_preserve_dup_deps; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done elif test prog != "$linkmode" && test lib != "$linkmode"; then func_fatal_error "'$lib' is not a convenience library" fi continue fi # $pass = conv # Get the name of the library we link against. linklib= if test -n "$old_library" && { test yes = "$prefer_static_libs" || test built,no = "$prefer_static_libs,$installed"; }; then linklib=$old_library else for l in $old_library $library_names; do linklib=$l done fi if test -z "$linklib"; then func_fatal_error "cannot find name of link library for '$lib'" fi # This library was specified with -dlopen. if test dlopen = "$pass"; then test -z "$libdir" \ && func_fatal_error "cannot -dlopen a convenience library: '$lib'" if test -z "$dlname" || test yes != "$dlopen_support" || test no = "$build_libtool_libs" then # If there is no dlname, no dlopen support or we're linking # statically, we need to preload. We also need to preload any # dependent libraries so libltdl's deplib preloader doesn't # bomb out in the load deplibs phase. func_append dlprefiles " $lib $dependency_libs" else func_append newdlfiles " $lib" fi continue fi # $pass = dlopen # We need an absolute path. case $ladir in [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; *) abs_ladir=`cd "$ladir" && pwd` if test -z "$abs_ladir"; then func_warning "cannot determine absolute directory name of '$ladir'" func_warning "passing it literally to the linker, although it might fail" abs_ladir=$ladir fi ;; esac func_basename "$lib" laname=$func_basename_result # Find the relevant object directory and library name. if test yes = "$installed"; then if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then func_warning "library '$lib' was moved." dir=$ladir absdir=$abs_ladir libdir=$abs_ladir else dir=$lt_sysroot$libdir absdir=$lt_sysroot$libdir fi test yes = "$hardcode_automatic" && avoidtemprpath=yes else if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then dir=$ladir absdir=$abs_ladir # Remove this search path later func_append notinst_path " $abs_ladir" else dir=$ladir/$objdir absdir=$abs_ladir/$objdir # Remove this search path later func_append notinst_path " $abs_ladir" fi fi # $installed = yes func_stripname 'lib' '.la' "$laname" name=$func_stripname_result # This library was specified with -dlpreopen. if test dlpreopen = "$pass"; then if test -z "$libdir" && test prog = "$linkmode"; then func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" fi case $host in # special handling for platforms with PE-DLLs. *cygwin* | *mingw* | *cegcc* ) # Linker will automatically link against shared library if both # static and shared are present. Therefore, ensure we extract # symbols from the import library if a shared library is present # (otherwise, the dlopen module name will be incorrect). We do # this by putting the import library name into $newdlprefiles. # We recover the dlopen module name by 'saving' the la file # name in a special purpose variable, and (later) extracting the # dlname from the la file. if test -n "$dlname"; then func_tr_sh "$dir/$linklib" eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" func_append newdlprefiles " $dir/$linklib" else func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" fi ;; * ) # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then func_append newdlprefiles " $dir/$dlname" else func_append newdlprefiles " $dir/$linklib" fi ;; esac fi # $pass = dlpreopen if test -z "$libdir"; then # Link the convenience library if test lib = "$linkmode"; then deplibs="$dir/$old_library $deplibs" elif test prog,link = "$linkmode,$pass"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else deplibs="$lib $deplibs" # used for prog,scan pass fi continue fi if test prog = "$linkmode" && test link != "$pass"; then func_append newlib_search_path " $ladir" deplibs="$lib $deplibs" linkalldeplibs=false if test no != "$link_all_deplibs" || test -z "$library_names" || test no = "$build_libtool_libs"; then linkalldeplibs=: fi tmp_libs= for deplib in $dependency_libs; do case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; esac # Need to link against all dependency_libs? if $linkalldeplibs; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi if $opt_preserve_dup_deps; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done # for deplib continue fi # $linkmode = prog... if test prog,link = "$linkmode,$pass"; then if test -n "$library_names" && { { test no = "$prefer_static_libs" || test built,yes = "$prefer_static_libs,$installed"; } || test -z "$old_library"; }; then # We need to hardcode the library path if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then # Make sure the rpath contains only unique directories. case $temp_rpath: in *"$absdir:"*) ;; *) func_append temp_rpath "$absdir:" ;; esac fi # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi # $linkmode,$pass = prog,link... if $alldeplibs && { test pass_all = "$deplibs_check_method" || { test yes = "$build_libtool_libs" && test -n "$library_names"; }; }; then # We only need to search for static libraries continue fi fi link_static=no # Whether the deplib will be linked statically use_static_libs=$prefer_static_libs if test built = "$use_static_libs" && test yes = "$installed"; then use_static_libs=no fi if test -n "$library_names" && { test no = "$use_static_libs" || test -z "$old_library"; }; then case $host in *cygwin* | *mingw* | *cegcc* | *os2*) # No point in relinking DLLs because paths are not encoded func_append notinst_deplibs " $lib" need_relink=no ;; *) if test no = "$installed"; then func_append notinst_deplibs " $lib" need_relink=yes fi ;; esac # This is a shared library # Warn about portability, can't link against -module's on some # systems (darwin). Don't bleat about dlopened modules though! dlopenmodule= for dlpremoduletest in $dlprefiles; do if test "X$dlpremoduletest" = "X$lib"; then dlopenmodule=$dlpremoduletest break fi done if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then echo if test prog = "$linkmode"; then $ECHO "*** Warning: Linking the executable $output against the loadable module" else $ECHO "*** Warning: Linking the shared library $output against the loadable module" fi $ECHO "*** $linklib is not portable!" fi if test lib = "$linkmode" && test yes = "$hardcode_into_libs"; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname set dummy $library_names shift realname=$1 shift libname=`eval "\\$ECHO \"$libname_spec\""` # use dlname if we got it. it's perfectly good, no? if test -n "$dlname"; then soname=$dlname elif test -n "$soname_spec"; then # bleh windows case $host in *cygwin* | mingw* | *cegcc* | *os2*) func_arith $current - $age major=$func_arith_result versuffix=-$major ;; esac eval soname=\"$soname_spec\" else soname=$realname fi # Make a new name for the extract_expsyms_cmds to use soroot=$soname func_basename "$soroot" soname=$func_basename_result func_stripname 'lib' '.dll' "$soname" newlib=libimp-$func_stripname_result.a # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : else func_verbose "extracting exported symbol list from '$soname'" func_execute_cmds "$extract_expsyms_cmds" 'exit $?' fi # Create $newlib if test -f "$output_objdir/$newlib"; then :; else func_verbose "generating import library for '$soname'" func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' fi # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib fi # test -n "$old_archive_from_expsyms_cmds" if test prog = "$linkmode" || test relink != "$opt_mode"; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test no = "$hardcode_direct"; then add=$dir/$linklib case $host in *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; *-*-sysv4*uw2*) add_dir=-L$dir ;; *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ *-*-unixware7*) add_dir=-L$dir ;; *-*-darwin* ) # if the lib is a (non-dlopened) module then we cannot # link against it, someone is ignoring the earlier warnings if /usr/bin/file -L $add 2> /dev/null | $GREP ": [^:]* bundle" >/dev/null; then if test "X$dlopenmodule" != "X$lib"; then $ECHO "*** Warning: lib $linklib is a module, not a shared library" if test -z "$old_library"; then echo echo "*** And there doesn't seem to be a static archive available" echo "*** The link will probably fail, sorry" else add=$dir/$old_library fi elif test -n "$old_library"; then add=$dir/$old_library fi fi esac elif test no = "$hardcode_minus_L"; then case $host in *-*-sunos*) add_shlibpath=$dir ;; esac add_dir=-L$dir add=-l$name elif test no = "$hardcode_shlibpath_var"; then add_shlibpath=$dir add=-l$name else lib_linked=no fi ;; relink) if test yes = "$hardcode_direct" && test no = "$hardcode_direct_absolute"; then add=$dir/$linklib elif test yes = "$hardcode_minus_L"; then add_dir=-L$absdir # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add=-l$name elif test yes = "$hardcode_shlibpath_var"; then add_shlibpath=$dir add=-l$name else lib_linked=no fi ;; *) lib_linked=no ;; esac if test yes != "$lib_linked"; then func_fatal_configuration "unsupported hardcode properties" fi if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; *) func_append compile_shlibpath "$add_shlibpath:" ;; esac fi if test prog = "$linkmode"; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" if test yes != "$hardcode_direct" && test yes != "$hardcode_minus_L" && test yes = "$hardcode_shlibpath_var"; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac fi fi fi if test prog = "$linkmode" || test relink = "$opt_mode"; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test yes = "$hardcode_direct" && test no = "$hardcode_direct_absolute"; then add=$libdir/$linklib elif test yes = "$hardcode_minus_L"; then add_dir=-L$libdir add=-l$name elif test yes = "$hardcode_shlibpath_var"; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac add=-l$name elif test yes = "$hardcode_automatic"; then if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib"; then add=$inst_prefix_dir$libdir/$linklib else add=$libdir/$linklib fi else # We cannot seem to hardcode it, guess we'll fake it. add_dir=-L$libdir # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add=-l$name fi if test prog = "$linkmode"; then test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" test -n "$add" && finalize_deplibs="$add $finalize_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" fi fi elif test prog = "$linkmode"; then # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. if test unsupported != "$hardcode_direct"; then test -n "$old_library" && linklib=$old_library compile_deplibs="$dir/$linklib $compile_deplibs" finalize_deplibs="$dir/$linklib $finalize_deplibs" else compile_deplibs="-l$name -L$dir $compile_deplibs" finalize_deplibs="-l$name -L$dir $finalize_deplibs" fi elif test yes = "$build_libtool_libs"; then # Not a shared library if test pass_all != "$deplibs_check_method"; then # We're trying link a shared library against a static one # but the system doesn't support it. # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. echo $ECHO "*** Warning: This system cannot link to static lib archive $lib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have." if test yes = "$module"; then echo "*** But as you try to build a module library, libtool will still create " echo "*** a static module, that should work as long as the dlopening application" echo "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using 'nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** 'nm' from GNU binutils and a full rebuild may help." fi if test no = "$build_old_libs"; then build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi else deplibs="$dir/$old_library $deplibs" link_static=yes fi fi # link shared/static library? if test lib = "$linkmode"; then if test -n "$dependency_libs" && { test yes != "$hardcode_into_libs" || test yes = "$build_old_libs" || test yes = "$link_static"; }; then # Extract -R from dependency_libs temp_deplibs= for libdir in $dependency_libs; do case $libdir in -R*) func_stripname '-R' '' "$libdir" temp_xrpath=$func_stripname_result case " $xrpath " in *" $temp_xrpath "*) ;; *) func_append xrpath " $temp_xrpath";; esac;; *) func_append temp_deplibs " $libdir";; esac done dependency_libs=$temp_deplibs fi func_append newlib_search_path " $absdir" # Link against this library test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result";; *) func_resolve_sysroot "$deplib" ;; esac if $opt_preserve_dup_deps; then case "$tmp_libs " in *" $func_resolve_sysroot_result "*) func_append specialdeplibs " $func_resolve_sysroot_result" ;; esac fi func_append tmp_libs " $func_resolve_sysroot_result" done if test no != "$link_all_deplibs"; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do path= case $deplib in -L*) path=$deplib ;; *.la) func_resolve_sysroot "$deplib" deplib=$func_resolve_sysroot_result func_dirname "$deplib" "" "." dir=$func_dirname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then func_warning "cannot determine absolute directory name of '$dir'" absdir=$dir fi ;; esac if $GREP "^installed=no" $deplib > /dev/null; then case $host in *-*-darwin*) depdepl= eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` if test -n "$deplibrary_names"; then for tmp in $deplibrary_names; do depdepl=$tmp done if test -f "$absdir/$objdir/$depdepl"; then depdepl=$absdir/$objdir/$depdepl darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` if test -z "$darwin_install_name"; then darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` fi func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" path= fi fi ;; *) path=-L$absdir/$objdir ;; esac else eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "'$deplib' is not a valid libtool archive" test "$absdir" != "$libdir" && \ func_warning "'$deplib' seems to be moved" path=-L$absdir fi ;; esac case " $deplibs " in *" $path "*) ;; *) deplibs="$path $deplibs" ;; esac done fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs if test link = "$pass"; then if test prog = "$linkmode"; then compile_deplibs="$new_inherited_linker_flags $compile_deplibs" finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" else compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` fi fi dependency_libs=$newdependency_libs if test dlpreopen = "$pass"; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi if test dlopen != "$pass"; then test conv = "$pass" || { # Make sure lib_search_path contains only unique directories. lib_search_path= for dir in $newlib_search_path; do case "$lib_search_path " in *" $dir "*) ;; *) func_append lib_search_path " $dir" ;; esac done newlib_search_path= } if test prog,link = "$linkmode,$pass"; then vars="compile_deplibs finalize_deplibs" else vars=deplibs fi for var in $vars dependency_libs; do # Add libraries to $var in reverse order eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do # FIXME: Pedantically, this is the right thing to do, so # that some nasty dependency loop isn't accidentally # broken: #new_libs="$deplib $new_libs" # Pragmatically, this seems to cause very few problems in # practice: case $deplib in -L*) new_libs="$deplib $new_libs" ;; -R*) ;; *) # And here is the reason: when a library appears more # than once as an explicit dependence of a library, or # is implicitly linked in more than once by the # compiler, it is considered special, and multiple # occurrences thereof are not removed. Compare this # with having the same library being listed as a # dependency of multiple other libraries: in this case, # we know (pedantically, we assume) the library does not # need to be listed more than once, so we keep only the # last copy. This is not always right, but it is rare # enough that we require users that really mean to play # such unportable linking tricks to link the library # using -Wl,-lname, so that libtool does not consider it # for duplicate removal. case " $specialdeplibs " in *" $deplib "*) new_libs="$deplib $new_libs" ;; *) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$deplib $new_libs" ;; esac ;; esac ;; esac done tmp_libs= for deplib in $new_libs; do case $deplib in -L*) case " $tmp_libs " in *" $deplib "*) ;; *) func_append tmp_libs " $deplib" ;; esac ;; *) func_append tmp_libs " $deplib" ;; esac done eval $var=\"$tmp_libs\" done # for var fi # Add Sun CC postdeps if required: test CXX = "$tagname" && { case $host_os in linux*) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 func_suncc_cstd_abi if test no != "$suncc_use_cstd_abi"; then func_append postdeps ' -library=Cstd -library=Crun' fi ;; esac ;; solaris*) func_cc_basename "$CC" case $func_cc_basename_result in CC* | sunCC*) func_suncc_cstd_abi if test no != "$suncc_use_cstd_abi"; then func_append postdeps ' -library=Cstd -library=Crun' fi ;; esac ;; esac } # Last step: remove runtime libs from dependency_libs # (they stay in deplibs) tmp_libs= for i in $dependency_libs; do case " $predeps $postdeps $compiler_lib_search_path " in *" $i "*) i= ;; esac if test -n "$i"; then func_append tmp_libs " $i" fi done dependency_libs=$tmp_libs done # for pass if test prog = "$linkmode"; then dlfiles=$newdlfiles fi if test prog = "$linkmode" || test lib = "$linkmode"; then dlprefiles=$newdlprefiles fi case $linkmode in oldlib) if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then func_warning "'-dlopen' is ignored for archives" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "'-l' and '-L' are ignored for archives" ;; esac test -n "$rpath" && \ func_warning "'-rpath' is ignored for archives" test -n "$xrpath" && \ func_warning "'-R' is ignored for archives" test -n "$vinfo" && \ func_warning "'-version-info/-version-number' is ignored for archives" test -n "$release" && \ func_warning "'-release' is ignored for archives" test -n "$export_symbols$export_symbols_regex" && \ func_warning "'-export-symbols' is ignored for archives" # Now set the variables for building old libraries. build_libtool_libs=no oldlibs=$output func_append objs "$old_deplibs" ;; lib) # Make sure we only generate libraries of the form 'libNAME.la'. case $outputname in lib*) func_stripname 'lib' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" ;; *) test no = "$module" \ && func_fatal_help "libtool library '$output' must begin with 'lib'" if test no != "$need_lib_prefix"; then # Add the "lib" prefix for modules if required func_stripname '' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" else func_stripname '' '.la' "$outputname" libname=$func_stripname_result fi ;; esac if test -n "$objs"; then if test pass_all != "$deplibs_check_method"; then func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" else echo $ECHO "*** Warning: Linking the shared library $output against the non-libtool" $ECHO "*** objects $objs is not portable!" func_append libobjs " $objs" fi fi test no = "$dlself" \ || func_warning "'-dlopen self' is ignored for libtool libraries" set dummy $rpath shift test 1 -lt "$#" \ && func_warning "ignoring multiple '-rpath's for a libtool library" install_libdir=$1 oldlibs= if test -z "$rpath"; then if test yes = "$build_libtool_libs"; then # Building a libtool convenience library. # Some compilers have problems with a '.al' extension so # convenience libraries should have the same extension an # archive normally would. oldlibs="$output_objdir/$libname.$libext $oldlibs" build_libtool_libs=convenience build_old_libs=yes fi test -n "$vinfo" && \ func_warning "'-version-info/-version-number' is ignored for convenience libraries" test -n "$release" && \ func_warning "'-release' is ignored for convenience libraries" else # Parse the version information argument. save_ifs=$IFS; IFS=: set dummy $vinfo 0 0 0 shift IFS=$save_ifs test -n "$7" && \ func_fatal_help "too many parameters to '-version-info'" # convert absolute version numbers to libtool ages # this retains compatibility with .la files and attempts # to make the code below a bit more comprehensible case $vinfo_number in yes) number_major=$1 number_minor=$2 number_revision=$3 # # There are really only two kinds -- those that # use the current revision as the major version # and those that subtract age and use age as # a minor version. But, then there is irix # that has an extra 1 added just for fun # case $version_type in # correct linux to gnu/linux during the next big refactor darwin|freebsd-elf|linux|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result age=$number_minor revision=$number_revision ;; freebsd-aout|qnx|sunos) current=$number_major revision=$number_minor age=0 ;; irix|nonstopux) func_arith $number_major + $number_minor current=$func_arith_result age=$number_minor revision=$number_minor lt_irix_increment=no ;; *) func_fatal_configuration "$modename: unknown library version type '$version_type'" ;; esac ;; no) current=$1 revision=$2 age=$3 ;; esac # Check that each of the things are valid numbers. case $current in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "CURRENT '$current' must be a nonnegative integer" func_fatal_error "'$vinfo' is not valid version information" ;; esac case $revision in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "REVISION '$revision' must be a nonnegative integer" func_fatal_error "'$vinfo' is not valid version information" ;; esac case $age in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "AGE '$age' must be a nonnegative integer" func_fatal_error "'$vinfo' is not valid version information" ;; esac if test "$age" -gt "$current"; then func_error "AGE '$age' is greater than the current interface number '$current'" func_fatal_error "'$vinfo' is not valid version information" fi # Calculate the version variables. major= versuffix= verstring= case $version_type in none) ;; darwin) # Like Linux, but with the current version available in # verstring for coding it into the library header func_arith $current - $age major=.$func_arith_result versuffix=$major.$age.$revision # Darwin ld doesn't like 0 for these options... func_arith $current + 1 minor_current=$func_arith_result xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" # On Darwin other compilers case $CC in nagfor*) verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" ;; *) verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" ;; esac ;; freebsd-aout) major=.$current versuffix=.$current.$revision ;; freebsd-elf) func_arith $current - $age major=.$func_arith_result versuffix=$major.$age.$revision ;; irix | nonstopux) if test no = "$lt_irix_increment"; then func_arith $current - $age else func_arith $current - $age + 1 fi major=$func_arith_result case $version_type in nonstopux) verstring_prefix=nonstopux ;; *) verstring_prefix=sgi ;; esac verstring=$verstring_prefix$major.$revision # Add in all the interfaces that we are compatible with. loop=$revision while test 0 -ne "$loop"; do func_arith $revision - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring=$verstring_prefix$major.$iface:$verstring done # Before this point, $major must not contain '.'. major=.$major versuffix=$major.$revision ;; linux) # correct to gnu/linux during the next big refactor func_arith $current - $age major=.$func_arith_result versuffix=$major.$age.$revision ;; osf) func_arith $current - $age major=.$func_arith_result versuffix=.$current.$age.$revision verstring=$current.$age.$revision # Add in all the interfaces that we are compatible with. loop=$age while test 0 -ne "$loop"; do func_arith $current - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring=$verstring:$iface.0 done # Make executables depend on our current version. func_append verstring ":$current.0" ;; qnx) major=.$current versuffix=.$current ;; sco) major=.$current versuffix=.$current ;; sunos) major=.$current versuffix=.$current.$revision ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 file systems. func_arith $current - $age major=$func_arith_result versuffix=-$major ;; *) func_fatal_configuration "unknown library version type '$version_type'" ;; esac # Clear the version info if we defaulted, and they specified a release. if test -z "$vinfo" && test -n "$release"; then major= case $version_type in darwin) # we can't check for "0.0" in archive_cmds due to quoting # problems, so we reset it completely verstring= ;; *) verstring=0.0 ;; esac if test no = "$need_version"; then versuffix= else versuffix=.0.0 fi fi # Remove version info from name if versioning should be avoided if test yes,no = "$avoid_version,$need_version"; then major= versuffix= verstring= fi # Check to see if the archive will have undefined symbols. if test yes = "$allow_undefined"; then if test unsupported = "$allow_undefined_flag"; then if test yes = "$build_old_libs"; then func_warning "undefined symbols not allowed in $host shared libraries; building static only" build_libtool_libs=no else func_fatal_error "can't build $host shared library unless -no-undefined is specified" fi fi else # Don't allow undefined symbols. allow_undefined_flag=$no_undefined_flag fi fi func_generate_dlsyms "$libname" "$libname" : func_append libobjs " $symfileobj" test " " = "$libobjs" && libobjs= if test relink != "$opt_mode"; then # Remove our outputs, but don't remove object files since they # may have been created when compiling PIC objects. removelist= tempremovelist=`$ECHO "$output_objdir/*"` for p in $tempremovelist; do case $p in *.$objext | *.gcno) ;; $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) if test -n "$precious_files_regex"; then if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 then continue fi fi func_append removelist " $p" ;; *) ;; esac done test -n "$removelist" && \ func_show_eval "${RM}r \$removelist" fi # Now set the variables for building old libraries. if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then func_append oldlibs " $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` fi # Eliminate all temporary directories. #for path in $notinst_path; do # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` #done if test -n "$xrpath"; then # If the user specified any rpath flags, then add them. temp_xrpath= for libdir in $xrpath; do func_replace_sysroot "$libdir" func_append temp_xrpath " -R$func_replace_sysroot_result" case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then dependency_libs="$temp_xrpath $dependency_libs" fi fi # Make sure dlfiles contains only unique files that won't be dlpreopened old_dlfiles=$dlfiles dlfiles= for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in *" $lib "*) ;; *) func_append dlfiles " $lib" ;; esac done # Make sure dlprefiles contains only unique files old_dlprefiles=$dlprefiles dlprefiles= for lib in $old_dlprefiles; do case "$dlprefiles " in *" $lib "*) ;; *) func_append dlprefiles " $lib" ;; esac done if test yes = "$build_libtool_libs"; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework func_append deplibs " System.ltframework" ;; *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work ;; *) # Add libc to deplibs on all other systems if necessary. if test yes = "$build_libtool_need_lc"; then func_append deplibs " -lc" fi ;; esac fi # Transform deplibs into only deplibs that can be linked in shared. name_save=$name libname_save=$libname release_save=$release versuffix_save=$versuffix major_save=$major # I'm not sure if I'm treating the release correctly. I think # release should show up in the -l (ie -lgmp5) so we don't want to # add it in twice. Is that correct? release= versuffix= major= newdeplibs= droppeddeps=no case $deplibs_check_method in pass_all) # Don't check for shared/static. Everything works. # This might be a little naive. We might want to check # whether the library exists or not. But this is on # osf3 & osf4 and I'm not really sure... Just # implementing what was already the behavior. newdeplibs=$deplibs ;; test_compile) # This code stresses the "libraries are programs" paradigm to its # limits. Maybe even breaks it. We compile a program, linking it # against the deplibs as a proxy for the library. Then we can check # whether they linked in statically or dynamically with ldd. $opt_dry_run || $RM conftest.c cat > conftest.c </dev/null` $nocaseglob else potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` fi for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null | $GREP " -> " >/dev/null; then continue fi # The statement above tries to avoid entering an # endless loop below, in case of cyclic links. # We might still enter an endless loop, since a link # loop can be closed while we follow links, # but so what? potlib=$potent_lib while test -h "$potlib" 2>/dev/null; do potliblink=`ls -ld $potlib | $SED 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | $SED -e 10q | $EGREP "$file_magic_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib= break 2 fi done done fi if test -n "$a_deplib"; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib"; then $ECHO "*** with $libname but no candidates were found. (...for file magic test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a file magic. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` for a_deplib in $deplibs; do case $a_deplib in -l*) func_stripname -l '' "$a_deplib" name=$func_stripname_result if test yes = "$allow_libtool_libs_with_static_runtimes"; then case " $predeps $postdeps " in *" $a_deplib "*) func_append newdeplibs " $a_deplib" a_deplib= ;; esac fi if test -n "$a_deplib"; then libname=`eval "\\$ECHO \"$libname_spec\""` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do potlib=$potent_lib # see symlink-check above in file_magic test if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ $EGREP "$match_pattern_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib= break 2 fi done done fi if test -n "$a_deplib"; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib"; then $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a regex pattern. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; none | unknown | *) newdeplibs= tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` if test yes = "$allow_libtool_libs_with_static_runtimes"; then for i in $predeps $postdeps; do # can't use Xsed below, because $i might contain '/' tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` done fi case $tmp_deplibs in *[!\ \ ]*) echo if test none = "$deplibs_check_method"; then echo "*** Warning: inter-library dependencies are not supported in this platform." else echo "*** Warning: inter-library dependencies are not known to be supported." fi echo "*** All declared inter-library dependencies are being dropped." droppeddeps=yes ;; esac ;; esac versuffix=$versuffix_save major=$major_save release=$release_save libname=$libname_save name=$name_save case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library with the System framework newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac if test yes = "$droppeddeps"; then if test yes = "$module"; then echo echo "*** Warning: libtool could not satisfy all declared inter-library" $ECHO "*** dependencies of module $libname. Therefore, libtool will create" echo "*** a static module, that should work as long as the dlopening" echo "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using 'nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** 'nm' from GNU binutils and a full rebuild may help." fi if test no = "$build_old_libs"; then oldlibs=$output_objdir/$libname.$libext build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi else echo "*** The inter-library dependencies that have been dropped here will be" echo "*** automatically added whenever a program is linked with this library" echo "*** or is declared to -dlopen it." if test no = "$allow_undefined"; then echo echo "*** Since this library must not contain undefined symbols," echo "*** because either the platform does not support them or" echo "*** it was explicitly requested with -no-undefined," echo "*** libtool will only create a static version of it." if test no = "$build_old_libs"; then oldlibs=$output_objdir/$libname.$libext build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi fi fi # Done checking deplibs! deplibs=$newdeplibs fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" case $host in *-*-darwin*) newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done deplibs=$new_libs # All the library-specific variables (install_libdir is set above). library_names= old_library= dlname= # Test again, we may have decided not to build it any more if test yes = "$build_libtool_libs"; then # Remove $wl instances when linking with ld. # FIXME: should test the right _cmds variable. case $archive_cmds in *\$LD\ *) wl= ;; esac if test yes = "$hardcode_into_libs"; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath=$finalize_rpath test relink = "$opt_mode" || rpath=$compile_rpath$rpath for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then func_replace_sysroot "$libdir" libdir=$func_replace_sysroot_result if test -z "$hardcode_libdirs"; then hardcode_libdirs=$libdir else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append dep_rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir=$hardcode_libdirs eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" fi shlibpath=$finalize_shlibpath test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi # Get the real and link names of the library. eval shared_ext=\"$shrext_cmds\" eval library_names=\"$library_names_spec\" set dummy $library_names shift realname=$1 shift if test -n "$soname_spec"; then eval soname=\"$soname_spec\" else soname=$realname fi if test -z "$dlname"; then dlname=$soname fi lib=$output_objdir/$realname linknames= for link do func_append linknames " $link" done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` test "X$libobjs" = "X " && libobjs= delfiles= if test -n "$export_symbols" && test -n "$include_expsyms"; then $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" export_symbols=$output_objdir/$libname.uexp func_append delfiles " $export_symbols" fi orig_export_symbols= case $host_os in cygwin* | mingw* | cegcc*) if test -n "$export_symbols" && test -z "$export_symbols_regex"; then # exporting using user supplied symfile func_dll_def_p "$export_symbols" || { # and it's NOT already a .def file. Must figure out # which of the given symbols are data symbols and tag # them as such. So, trigger use of export_symbols_cmds. # export_symbols gets reassigned inside the "prepare # the list of exported symbols" if statement, so the # include_expsyms logic still works. orig_export_symbols=$export_symbols export_symbols= always_export_symbols=yes } fi ;; esac # Prepare the list of exported symbols if test -z "$export_symbols"; then if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then func_verbose "generating symbol list for '$libname.la'" export_symbols=$output_objdir/$libname.exp $opt_dry_run || $RM $export_symbols cmds=$export_symbols_cmds save_ifs=$IFS; IFS='~' for cmd1 in $cmds; do IFS=$save_ifs # Take the normal branch if the nm_file_list_spec branch # doesn't work or if tool conversion is not needed. case $nm_file_list_spec~$to_tool_file_cmd in *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) try_normal_branch=yes eval cmd=\"$cmd1\" func_len " $cmd" len=$func_len_result ;; *) try_normal_branch=no ;; esac if test yes = "$try_normal_branch" \ && { test "$len" -lt "$max_cmd_len" \ || test "$max_cmd_len" -le -1; } then func_show_eval "$cmd" 'exit $?' skipped_export=false elif test -n "$nm_file_list_spec"; then func_basename "$output" output_la=$func_basename_result save_libobjs=$libobjs save_output=$output output=$output_objdir/$output_la.nm func_to_tool_file "$output" libobjs=$nm_file_list_spec$func_to_tool_file_result func_append delfiles " $output" func_verbose "creating $NM input file list: $output" for obj in $save_libobjs; do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > "$output" eval cmd=\"$cmd1\" func_show_eval "$cmd" 'exit $?' output=$save_output libobjs=$save_libobjs skipped_export=false else # The command line is too long to execute in one step. func_verbose "using reloadable object file for export list..." skipped_export=: # Break out early, otherwise skipped_export may be # set to false by a later but shorter cmd. break fi done IFS=$save_ifs if test -n "$export_symbols_regex" && test : != "$skipped_export"; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi fi if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols=$export_symbols test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test : != "$skipped_export" && test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for '$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands, which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi tmp_deplibs= for test_deplib in $deplibs; do case " $convenience " in *" $test_deplib "*) ;; *) func_append tmp_deplibs " $test_deplib" ;; esac done deplibs=$tmp_deplibs if test -n "$convenience"; then if test -n "$whole_archive_flag_spec" && test yes = "$compiler_needs_object" && test -z "$libobjs"; then # extract the archives, so we have objects to list. # TODO: could optimize this to just extract one archive. whole_archive_flag_spec= fi if test -n "$whole_archive_flag_spec"; then save_libobjs=$libobjs eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= else gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_extract_archives $gentop $convenience func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi fi if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" func_append linker_flags " $flag" fi # Make a backup of the uninstalled library when relinking if test relink = "$opt_mode"; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? fi # Do each of the archive commands. if test yes = "$module" && test -n "$module_cmds"; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then eval test_cmds=\"$module_expsym_cmds\" cmds=$module_expsym_cmds else eval test_cmds=\"$module_cmds\" cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval test_cmds=\"$archive_expsym_cmds\" cmds=$archive_expsym_cmds else eval test_cmds=\"$archive_cmds\" cmds=$archive_cmds fi fi if test : != "$skipped_export" && func_len " $test_cmds" && len=$func_len_result && test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then : else # The command line is too long to link in one step, link piecewise # or, if using GNU ld and skipped_export is not :, use a linker # script. # Save the value of $output and $libobjs because we want to # use them later. If we have whole_archive_flag_spec, we # want to use save_libobjs as it was before # whole_archive_flag_spec was expanded, because we can't # assume the linker understands whole_archive_flag_spec. # This may have to be revisited, in case too many # convenience libraries get linked in and end up exceeding # the spec. if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then save_libobjs=$libobjs fi save_output=$output func_basename "$output" output_la=$func_basename_result # Clear the reloadable object creation command queue and # initialize k to one. test_cmds= concat_cmds= objlist= last_robj= k=1 if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then output=$output_objdir/$output_la.lnkscript func_verbose "creating GNU ld script: $output" echo 'INPUT (' > $output for obj in $save_libobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done echo ')' >> $output func_append delfiles " $output" func_to_tool_file "$output" output=$func_to_tool_file_result elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then output=$output_objdir/$output_la.lnk func_verbose "creating linker input file list: $output" : > $output set x $save_libobjs shift firstobj= if test yes = "$compiler_needs_object"; then firstobj="$1 " shift fi for obj do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done func_append delfiles " $output" func_to_tool_file "$output" output=$firstobj\"$file_list_spec$func_to_tool_file_result\" else if test -n "$save_libobjs"; then func_verbose "creating reloadable object files..." output=$output_objdir/$output_la-$k.$objext eval test_cmds=\"$reload_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 # Loop over the list of objects to be linked. for obj in $save_libobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result if test -z "$objlist" || test "$len" -lt "$max_cmd_len"; then func_append objlist " $obj" else # The command $test_cmds is almost too long, add a # command to the queue. if test 1 -eq "$k"; then # The first file doesn't have a previous command to add. reload_objs=$objlist eval concat_cmds=\"$reload_cmds\" else # All subsequent reloadable object files will link in # the last one created. reload_objs="$objlist $last_robj" eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" fi last_robj=$output_objdir/$output_la-$k.$objext func_arith $k + 1 k=$func_arith_result output=$output_objdir/$output_la-$k.$objext objlist=" $obj" func_len " $last_robj" func_arith $len0 + $func_len_result len=$func_arith_result fi done # Handle the remaining objects by creating one last # reloadable object file. All subsequent reloadable object # files will link in the last one created. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ reload_objs="$objlist $last_robj" eval concat_cmds=\"\$concat_cmds$reload_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi func_append delfiles " $output" else output= fi ${skipped_export-false} && { func_verbose "generating symbol list for '$libname.la'" export_symbols=$output_objdir/$libname.exp $opt_dry_run || $RM $export_symbols libobjs=$output # Append the command to create the export file. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi } test -n "$save_libobjs" && func_verbose "creating a temporary reloadable object file: $output" # Loop through the commands generated above and execute them. save_ifs=$IFS; IFS='~' for cmd in $concat_cmds; do IFS=$save_ifs $opt_quiet || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test relink = "$opt_mode"; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS=$save_ifs if test -n "$export_symbols_regex" && ${skipped_export-false}; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi ${skipped_export-false} && { if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols=$export_symbols test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for '$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands, which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi } libobjs=$output # Restore the value of output. output=$save_output if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= fi # Expand the library linking commands again to reset the # value of $libobjs for piecewise linking. # Do each of the archive commands. if test yes = "$module" && test -n "$module_cmds"; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then cmds=$module_expsym_cmds else cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then cmds=$archive_expsym_cmds else cmds=$archive_cmds fi fi fi if test -n "$delfiles"; then # Append the command to remove temporary files to $cmds. eval cmds=\"\$cmds~\$RM $delfiles\" fi # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi save_ifs=$IFS; IFS='~' for cmd in $cmds; do IFS=$sp$nl eval cmd=\"$cmd\" IFS=$save_ifs $opt_quiet || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test relink = "$opt_mode"; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS=$save_ifs # Restore the uninstalled library and exit if test relink = "$opt_mode"; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? if test -n "$convenience"; then if test -z "$whole_archive_flag_spec"; then func_show_eval '${RM}r "$gentop"' fi fi exit $EXIT_SUCCESS fi # Create links to the real library. for linkname in $linknames; do if test "$realname" != "$linkname"; then func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' fi done # If -module or -export-dynamic was specified, set the dlname. if test yes = "$module" || test yes = "$export_dynamic"; then # On all known operating systems, these are identical. dlname=$soname fi fi ;; obj) if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then func_warning "'-dlopen' is ignored for objects" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "'-l' and '-L' are ignored for objects" ;; esac test -n "$rpath" && \ func_warning "'-rpath' is ignored for objects" test -n "$xrpath" && \ func_warning "'-R' is ignored for objects" test -n "$vinfo" && \ func_warning "'-version-info' is ignored for objects" test -n "$release" && \ func_warning "'-release' is ignored for objects" case $output in *.lo) test -n "$objs$old_deplibs" && \ func_fatal_error "cannot build library object '$output' from non-libtool objects" libobj=$output func_lo2o "$libobj" obj=$func_lo2o_result ;; *) libobj= obj=$output ;; esac # Delete the old objects. $opt_dry_run || $RM $obj $libobj # Objects from convenience libraries. This assumes # single-version convenience libraries. Whenever we create # different ones for PIC/non-PIC, this we'll have to duplicate # the extraction. reload_conv_objs= gentop= # if reload_cmds runs $LD directly, get rid of -Wl from # whole_archive_flag_spec and hope we can get by with turning comma # into space. case $reload_cmds in *\$LD[\ \$]*) wl= ;; esac if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags else gentop=$output_objdir/${obj}x func_append generated " $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi # If we're not building shared, we need to use non_pic_objs test yes = "$build_libtool_libs" || libobjs=$non_pic_objects # Create the old-style object. reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs output=$obj func_execute_cmds "$reload_cmds" 'exit $?' # Exit if we aren't doing a library object file. if test -z "$libobj"; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS fi test yes = "$build_libtool_libs" || { if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi # Create an invalid libtool object if no PIC, so that we don't # accidentally link it into a program. # $show "echo timestamp > $libobj" # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? exit $EXIT_SUCCESS } if test -n "$pic_flag" || test default != "$pic_mode"; then # Only do commands if we really have different PIC objects. reload_objs="$libobjs $reload_conv_objs" output=$libobj func_execute_cmds "$reload_cmds" 'exit $?' fi if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS ;; prog) case $host in *cygwin*) func_stripname '' '.exe' "$output" output=$func_stripname_result.exe;; esac test -n "$vinfo" && \ func_warning "'-version-info' is ignored for programs" test -n "$release" && \ func_warning "'-release' is ignored for programs" $preload \ && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac case $host in *-*-darwin*) # Don't allow lazy linking, it breaks C++ global constructors # But is supposedly fixed on 10.4 or later (yay!). if test CXX = "$tagname"; then case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10.[0123]) func_append compile_command " $wl-bind_at_load" func_append finalize_command " $wl-bind_at_load" ;; esac fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $compile_deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $compile_deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done compile_deplibs=$new_libs func_append compile_command " $compile_deplibs" func_append finalize_command " $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done fi # Now hardcode the library paths rpath= hardcode_libdirs= for libdir in $compile_rpath $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs=$libdir else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$libdir:"*) ;; ::) dllsearchpath=$libdir;; *) func_append dllsearchpath ":$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir=$hardcode_libdirs eval rpath=\" $hardcode_libdir_flag_spec\" fi compile_rpath=$rpath rpath= hardcode_libdirs= for libdir in $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs=$libdir else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) func_append finalize_perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir=$hardcode_libdirs eval rpath=\" $hardcode_libdir_flag_spec\" fi finalize_rpath=$rpath if test -n "$libobjs" && test yes = "$build_old_libs"; then # Transform all the library objects into standard objects. compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` fi func_generate_dlsyms "$outputname" "@PROGRAM@" false # template prelinking step if test -n "$prelink_cmds"; then func_execute_cmds "$prelink_cmds" 'exit $?' fi wrappers_required=: case $host in *cegcc* | *mingw32ce*) # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. wrappers_required=false ;; *cygwin* | *mingw* ) test yes = "$build_libtool_libs" || wrappers_required=false ;; *) if test no = "$need_relink" || test yes != "$build_libtool_libs"; then wrappers_required=false fi ;; esac $wrappers_required || { # Replace the output file specification. compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` link_command=$compile_command$compile_rpath # We have no uninstalled library dependencies, so finalize right now. exit_status=0 func_show_eval "$link_command" 'exit_status=$?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Delete the generated files. if test -f "$output_objdir/${outputname}S.$objext"; then func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' fi exit $exit_status } if test -n "$compile_shlibpath$finalize_shlibpath"; then compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" fi if test -n "$finalize_shlibpath"; then finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" fi compile_var= finalize_var= if test -n "$runpath_var"; then if test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done compile_var="$runpath_var=\"$rpath\$$runpath_var\" " fi if test -n "$finalize_perm_rpath"; then # We should set the runpath_var. rpath= for dir in $finalize_perm_rpath; do func_append rpath "$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi fi if test yes = "$no_install"; then # We don't need to create a wrapper script. link_command=$compile_var$compile_command$compile_rpath # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. $opt_dry_run || $RM $output # Link the executable and exit func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi exit $EXIT_SUCCESS fi case $hardcode_action,$fast_install in relink,*) # Fast installation is not supported link_command=$compile_var$compile_command$compile_rpath relink_command=$finalize_var$finalize_command$finalize_rpath func_warning "this platform does not like uninstalled shared libraries" func_warning "'$output' will be relinked during installation" ;; *,yes) link_command=$finalize_var$compile_command$finalize_rpath relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` ;; *,no) link_command=$compile_var$compile_command$compile_rpath relink_command=$finalize_var$finalize_command$finalize_rpath ;; *,needless) link_command=$finalize_var$compile_command$finalize_rpath relink_command= ;; esac # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` # Delete the old output files. $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output_objdir/$outputname" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Now create the wrapper script. func_verbose "creating $output" # Quote the relink command for shipping. if test -n "$relink_command"; then # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done relink_command="(cd `pwd`; $relink_command)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` fi # Only actually do things if not in dry run mode. $opt_dry_run || { # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in *.exe) func_stripname '' '.exe' "$output" output=$func_stripname_result ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in *cygwin*) exeext=.exe func_stripname '' '.exe' "$outputname" outputname=$func_stripname_result ;; *) exeext= ;; esac case $host in *cygwin* | *mingw* ) func_dirname_and_basename "$output" "" "." output_name=$func_basename_result output_path=$func_dirname_result cwrappersource=$output_path/$objdir/lt-$output_name.c cwrapper=$output_path/$output_name.exe $RM $cwrappersource $cwrapper trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 func_emit_cwrapperexe_src > $cwrappersource # The wrapper executable is built using the $host compiler, # because it contains $host paths and files. If cross- # compiling, it, like the target executable, must be # executed on the $host or under an emulation environment. $opt_dry_run || { $LTCC $LTCFLAGS -o $cwrapper $cwrappersource $STRIP $cwrapper } # Now, create the wrapper script for func_source use: func_ltwrapper_scriptname $cwrapper $RM $func_ltwrapper_scriptname_result trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 $opt_dry_run || { # note: this script will not be executed, so do not chmod. if test "x$build" = "x$host"; then $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result else func_emit_wrapper no > $func_ltwrapper_scriptname_result fi } ;; * ) $RM $output trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 func_emit_wrapper no > $output chmod +x $output ;; esac } exit $EXIT_SUCCESS ;; esac # See if we need to build an old-fashioned archive. for oldlib in $oldlibs; do case $build_libtool_libs in convenience) oldobjs="$libobjs_save $symfileobj" addlibs=$convenience build_libtool_libs=no ;; module) oldobjs=$libobjs_save addlibs=$old_convenience build_libtool_libs=no ;; *) oldobjs="$old_deplibs $non_pic_objects" $preload && test -f "$symfileobj" \ && func_append oldobjs " $symfileobj" addlibs=$old_convenience ;; esac if test -n "$addlibs"; then gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_extract_archives $gentop $addlibs func_append oldobjs " $func_extract_archives_result" fi # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then cmds=$old_archive_from_new_cmds else # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append oldobjs " $func_extract_archives_result" fi # POSIX demands no paths to be encoded in archives. We have # to avoid creating archives with duplicate basenames if we # might have to extract them afterwards, e.g., when creating a # static archive out of a convenience library, or when linking # the entirety of a libtool archive into another (currently # not supported by libtool). if (for obj in $oldobjs do func_basename "$obj" $ECHO "$func_basename_result" done | sort | sort -uc >/dev/null 2>&1); then : else echo "copying selected object files to avoid basename conflicts..." gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_mkdir_p "$gentop" save_oldobjs=$oldobjs oldobjs= counter=1 for obj in $save_oldobjs do func_basename "$obj" objbase=$func_basename_result case " $oldobjs " in " ") oldobjs=$obj ;; *[\ /]"$objbase "*) while :; do # Make sure we don't pick an alternate name that also # overlaps. newobj=lt$counter-$objbase func_arith $counter + 1 counter=$func_arith_result case " $oldobjs " in *[\ /]"$newobj "*) ;; *) if test ! -f "$gentop/$newobj"; then break; fi ;; esac done func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" func_append oldobjs " $gentop/$newobj" ;; *) func_append oldobjs " $obj" ;; esac done fi func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result eval cmds=\"$old_archive_cmds\" func_len " $cmds" len=$func_len_result if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds elif test -n "$archiver_list_spec"; then func_verbose "using command file archive linking..." for obj in $oldobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > $output_objdir/$libname.libcmd func_to_tool_file "$output_objdir/$libname.libcmd" oldobjs=" $archiver_list_spec$func_to_tool_file_result" cmds=$old_archive_cmds else # the command line is too long to link in one step, link in parts func_verbose "using piecewise archive linking..." save_RANLIB=$RANLIB RANLIB=: objlist= concat_cmds= save_oldobjs=$oldobjs oldobjs= # Is there a better way of finding the last object in the list? for obj in $save_oldobjs do last_oldobj=$obj done eval test_cmds=\"$old_archive_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 for obj in $save_oldobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result func_append objlist " $obj" if test "$len" -lt "$max_cmd_len"; then : else # the above command should be used before it gets too long oldobjs=$objlist if test "$obj" = "$last_oldobj"; then RANLIB=$save_RANLIB fi test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" objlist= len=$len0 fi done RANLIB=$save_RANLIB oldobjs=$objlist if test -z "$oldobjs"; then eval cmds=\"\$concat_cmds\" else eval cmds=\"\$concat_cmds~\$old_archive_cmds\" fi fi fi func_execute_cmds "$cmds" 'exit $?' done test -n "$generated" && \ func_show_eval "${RM}r$generated" # Now create the libtool archive. case $output in *.la) old_library= test yes = "$build_old_libs" && old_library=$libname.$libext func_verbose "creating $output" # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done # Quote the link command for shipping. relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` if test yes = "$hardcode_automatic"; then relink_command= fi # Only create the output if not a dry run. $opt_dry_run || { for installed in no yes; do if test yes = "$installed"; then if test -z "$install_libdir"; then break fi output=$output_objdir/${outputname}i # Replace all uninstalled libtool libraries with the installed ones newdependency_libs= for deplib in $dependency_libs; do case $deplib in *.la) func_basename "$deplib" name=$func_basename_result func_resolve_sysroot "$deplib" eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` test -z "$libdir" && \ func_fatal_error "'$deplib' is not a valid libtool archive" func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" ;; -L*) func_stripname -L '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -L$func_replace_sysroot_result" ;; -R*) func_stripname -R '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -R$func_replace_sysroot_result" ;; *) func_append newdependency_libs " $deplib" ;; esac done dependency_libs=$newdependency_libs newdlfiles= for lib in $dlfiles; do case $lib in *.la) func_basename "$lib" name=$func_basename_result eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "'$lib' is not a valid libtool archive" func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" ;; *) func_append newdlfiles " $lib" ;; esac done dlfiles=$newdlfiles newdlprefiles= for lib in $dlprefiles; do case $lib in *.la) # Only pass preopened files to the pseudo-archive (for # eventual linking with the app. that links it) if we # didn't already link the preopened objects directly into # the library: func_basename "$lib" name=$func_basename_result eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "'$lib' is not a valid libtool archive" func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" ;; esac done dlprefiles=$newdlprefiles else newdlfiles= for lib in $dlfiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlfiles " $abs" done dlfiles=$newdlfiles newdlprefiles= for lib in $dlprefiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlprefiles " $abs" done dlprefiles=$newdlprefiles fi $RM $output # place dlname in correct position for cygwin # In fact, it would be nice if we could use this code for all target # systems that can't hard-code library paths into their executables # and that have no shared library path variable independent of PATH, # but it turns out we can't easily determine that from inspecting # libtool variables, so we have to hard-code the OSs to which it # applies here; at the moment, that means platforms that use the PE # object format with DLL files. See the long comment at the top of # tests/bindir.at for full details. tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) # If a -bindir argument was supplied, place the dll there. if test -n "$bindir"; then func_relative_path "$install_libdir" "$bindir" tdlname=$func_relative_path_result/$dlname else # Otherwise fall back on heuristic. tdlname=../bin/$dlname fi ;; esac $ECHO > $output "\ # $outputname - a libtool library file # Generated by $PROGRAM (GNU $PACKAGE) $VERSION # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='$tdlname' # Names of this library. library_names='$library_names' # The name of the static archive. old_library='$old_library' # Linker flags that cannot go in dependency_libs. inherited_linker_flags='$new_inherited_linker_flags' # Libraries that this one depends upon. dependency_libs='$dependency_libs' # Names of additional weak libraries provided by this library weak_library_names='$weak_libs' # Version information for $libname. current=$current age=$age revision=$revision # Is this an already installed library? installed=$installed # Should we warn about portability when linking against -modules? shouldnotlink=$module # Files to dlopen/dlpreopen dlopen='$dlfiles' dlpreopen='$dlprefiles' # Directory that this library needs to be installed in: libdir='$install_libdir'" if test no,yes = "$installed,$need_relink"; then $ECHO >> $output "\ relink_command=\"$relink_command\"" fi done } # Do a symbolic link so that the libtool archive can be found in # LD_LIBRARY_PATH before the program is installed. func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' ;; esac exit $EXIT_SUCCESS } if test link = "$opt_mode" || test relink = "$opt_mode"; then func_mode_link ${1+"$@"} fi # func_mode_uninstall arg... func_mode_uninstall () { $debug_cmd RM=$nonopt files= rmforce=false exit_status=0 # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic=$magic for arg do case $arg in -f) func_append RM " $arg"; rmforce=: ;; -*) func_append RM " $arg" ;; *) func_append files " $arg" ;; esac done test -z "$RM" && \ func_fatal_help "you must specify an RM program" rmdirs= for file in $files; do func_dirname "$file" "" "." dir=$func_dirname_result if test . = "$dir"; then odir=$objdir else odir=$dir/$objdir fi func_basename "$file" name=$func_basename_result test uninstall = "$opt_mode" && odir=$dir # Remember odir for removal later, being careful to avoid duplicates if test clean = "$opt_mode"; then case " $rmdirs " in *" $odir "*) ;; *) func_append rmdirs " $odir" ;; esac fi # Don't error if the file doesn't exist and rm -f was used. if { test -L "$file"; } >/dev/null 2>&1 || { test -h "$file"; } >/dev/null 2>&1 || test -f "$file"; then : elif test -d "$file"; then exit_status=1 continue elif $rmforce; then continue fi rmfiles=$file case $name in *.la) # Possibly a libtool archive, so verify it. if func_lalib_p "$file"; then func_source $dir/$name # Delete the libtool libraries and symlinks. for n in $library_names; do func_append rmfiles " $odir/$n" done test -n "$old_library" && func_append rmfiles " $odir/$old_library" case $opt_mode in clean) case " $library_names " in *" $dlname "*) ;; *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; esac test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" ;; uninstall) if test -n "$library_names"; then # Do each command in the postuninstall commands. func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' fi # FIXME: should reinstall the best remaining shared library. ;; esac fi ;; *.lo) # Possibly a libtool object, so verify it. if func_lalib_p "$file"; then # Read the .lo file func_source $dir/$name # Add PIC object to the list of files to remove. if test -n "$pic_object" && test none != "$pic_object"; then func_append rmfiles " $dir/$pic_object" fi # Add non-PIC object to the list of files to remove. if test -n "$non_pic_object" && test none != "$non_pic_object"; then func_append rmfiles " $dir/$non_pic_object" fi fi ;; *) if test clean = "$opt_mode"; then noexename=$name case $file in *.exe) func_stripname '' '.exe' "$file" file=$func_stripname_result func_stripname '' '.exe' "$name" noexename=$func_stripname_result # $file with .exe has already been added to rmfiles, # add $file without .exe func_append rmfiles " $file" ;; esac # Do a test to see if this is a libtool program. if func_ltwrapper_p "$file"; then if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" relink_command= func_source $func_ltwrapper_scriptname_result func_append rmfiles " $func_ltwrapper_scriptname_result" else relink_command= func_source $dir/$noexename fi # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles func_append rmfiles " $odir/$name $odir/${name}S.$objext" if test yes = "$fast_install" && test -n "$relink_command"; then func_append rmfiles " $odir/lt-$name" fi if test "X$noexename" != "X$name"; then func_append rmfiles " $odir/lt-$noexename.c" fi fi fi ;; esac func_show_eval "$RM $rmfiles" 'exit_status=1' done # Try to remove the $objdir's in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then func_show_eval "rmdir $dir >/dev/null 2>&1" fi done exit $exit_status } if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then func_mode_uninstall ${1+"$@"} fi test -z "$opt_mode" && { help=$generic_help func_fatal_help "you must specify a MODE" } test -z "$exec_cmd" && \ func_fatal_help "invalid operation mode '$opt_mode'" if test -n "$exec_cmd"; then eval exec "$exec_cmd" exit $EXIT_FAILURE fi exit $exit_status # The TAGs below are defined such that we never get into a situation # where we disable both kinds of libraries. Given conflicting # choices, we go for a static library, that is the most portable, # since we can't tell whether shared libraries were disabled because # the user asked for that or because the platform doesn't support # them. This is particularly important on AIX, because we don't # support having both static and shared libraries enabled at the same # time on that platform, so we default to a shared-only configuration. # If a disable-shared tag is given, we'll fallback to a static-only # configuration. But we'll never go from static-only to shared-only. # ### BEGIN LIBTOOL TAG CONFIG: disable-shared build_libtool_libs=no build_old_libs=yes # ### END LIBTOOL TAG CONFIG: disable-shared # ### BEGIN LIBTOOL TAG CONFIG: disable-static build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` # ### END LIBTOOL TAG CONFIG: disable-static # Local Variables: # mode:shell-script # sh-indentation:2 # End: assaultcube-1.2.0.2.1/source/enet/m4/000077500000000000000000000000001352165075300171065ustar00rootroot00000000000000assaultcube-1.2.0.2.1/source/enet/m4/.keep000066400000000000000000000000001352165075300200210ustar00rootroot00000000000000assaultcube-1.2.0.2.1/source/enet/m4/libtool.m4000066400000000000000000011264001352165075300210200ustar00rootroot00000000000000# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # # Copyright (C) 1996-2001, 2003-2015 Free Software Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. m4_define([_LT_COPYING], [dnl # Copyright (C) 2014 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of of the License, or # (at your option) any later version. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program or library that is built # using GNU Libtool, you may include this file under the same # distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . ]) # serial 58 LT_INIT # LT_PREREQ(VERSION) # ------------------ # Complain and exit if this libtool version is less that VERSION. m4_defun([LT_PREREQ], [m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, [m4_default([$3], [m4_fatal([Libtool version $1 or higher is required], 63)])], [$2])]) # _LT_CHECK_BUILDDIR # ------------------ # Complain if the absolute build directory name contains unusual characters m4_defun([_LT_CHECK_BUILDDIR], [case `pwd` in *\ * | *\ *) AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; esac ]) # LT_INIT([OPTIONS]) # ------------------ AC_DEFUN([LT_INIT], [AC_PREREQ([2.62])dnl We use AC_PATH_PROGS_FEATURE_CHECK AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl AC_BEFORE([$0], [LT_LANG])dnl AC_BEFORE([$0], [LT_OUTPUT])dnl AC_BEFORE([$0], [LTDL_INIT])dnl m4_require([_LT_CHECK_BUILDDIR])dnl dnl Autoconf doesn't catch unexpanded LT_ macros by default: m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 dnl unless we require an AC_DEFUNed macro: AC_REQUIRE([LTOPTIONS_VERSION])dnl AC_REQUIRE([LTSUGAR_VERSION])dnl AC_REQUIRE([LTVERSION_VERSION])dnl AC_REQUIRE([LTOBSOLETE_VERSION])dnl m4_require([_LT_PROG_LTMAIN])dnl _LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) dnl Parse OPTIONS _LT_SET_OPTIONS([$0], [$1]) # This can be used to rebuild libtool when needed LIBTOOL_DEPS=$ltmain # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' AC_SUBST(LIBTOOL)dnl _LT_SETUP # Only expand once: m4_define([LT_INIT]) ])# LT_INIT # Old names: AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PROG_LIBTOOL], []) dnl AC_DEFUN([AM_PROG_LIBTOOL], []) # _LT_PREPARE_CC_BASENAME # ----------------------- m4_defun([_LT_PREPARE_CC_BASENAME], [ # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. func_cc_basename () { for cc_temp in @S|@*""; do case $cc_temp in compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; \-*) ;; *) break;; esac done func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` } ])# _LT_PREPARE_CC_BASENAME # _LT_CC_BASENAME(CC) # ------------------- # It would be clearer to call AC_REQUIREs from _LT_PREPARE_CC_BASENAME, # but that macro is also expanded into generated libtool script, which # arranges for $SED and $ECHO to be set by different means. m4_defun([_LT_CC_BASENAME], [m4_require([_LT_PREPARE_CC_BASENAME])dnl AC_REQUIRE([_LT_DECL_SED])dnl AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl func_cc_basename $1 cc_basename=$func_cc_basename_result ]) # _LT_FILEUTILS_DEFAULTS # ---------------------- # It is okay to use these file commands and assume they have been set # sensibly after 'm4_require([_LT_FILEUTILS_DEFAULTS])'. m4_defun([_LT_FILEUTILS_DEFAULTS], [: ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} ])# _LT_FILEUTILS_DEFAULTS # _LT_SETUP # --------- m4_defun([_LT_SETUP], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl _LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl dnl _LT_DECL([], [host_alias], [0], [The host system])dnl _LT_DECL([], [host], [0])dnl _LT_DECL([], [host_os], [0])dnl dnl _LT_DECL([], [build_alias], [0], [The build system])dnl _LT_DECL([], [build], [0])dnl _LT_DECL([], [build_os], [0])dnl dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl dnl AC_REQUIRE([AC_PROG_LN_S])dnl test -z "$LN_S" && LN_S="ln -s" _LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl dnl AC_REQUIRE([LT_CMD_MAX_LEN])dnl _LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl _LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl m4_require([_LT_CMD_RELOAD])dnl m4_require([_LT_CHECK_MAGIC_METHOD])dnl m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl m4_require([_LT_CMD_OLD_ARCHIVE])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_WITH_SYSROOT])dnl m4_require([_LT_CMD_TRUNCATE])dnl _LT_CONFIG_LIBTOOL_INIT([ # See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi ]) if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi _LT_CHECK_OBJDIR m4_require([_LT_TAG_COMPILER])dnl case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a '.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld=$lt_cv_prog_gnu_ld old_CC=$CC old_CFLAGS=$CFLAGS # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o _LT_CC_BASENAME([$compiler]) # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then _LT_PATH_MAGIC fi ;; esac # Use C for the default configuration in the libtool script LT_SUPPORTED_TAG([CC]) _LT_LANG_C_CONFIG _LT_LANG_DEFAULT_CONFIG _LT_CONFIG_COMMANDS ])# _LT_SETUP # _LT_PREPARE_SED_QUOTE_VARS # -------------------------- # Define a few sed substitution that help us do robust quoting. m4_defun([_LT_PREPARE_SED_QUOTE_VARS], [# Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\([["`\\]]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ]) # _LT_PROG_LTMAIN # --------------- # Note that this code is called both from 'configure', and 'config.status' # now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, # 'config.status' has no value for ac_aux_dir unless we are using Automake, # so we pass a copy along to make sure it has a sensible value anyway. m4_defun([_LT_PROG_LTMAIN], [m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl _LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) ltmain=$ac_aux_dir/ltmain.sh ])# _LT_PROG_LTMAIN ## ------------------------------------- ## ## Accumulate code for creating libtool. ## ## ------------------------------------- ## # So that we can recreate a full libtool script including additional # tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS # in macros and then make a single call at the end using the 'libtool' # label. # _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) # ---------------------------------------- # Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL_INIT], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_INIT], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_INIT]) # _LT_CONFIG_LIBTOOL([COMMANDS]) # ------------------------------ # Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) # _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) # ----------------------------------------------------- m4_defun([_LT_CONFIG_SAVE_COMMANDS], [_LT_CONFIG_LIBTOOL([$1]) _LT_CONFIG_LIBTOOL_INIT([$2]) ]) # _LT_FORMAT_COMMENT([COMMENT]) # ----------------------------- # Add leading comment marks to the start of each line, and a trailing # full-stop to the whole comment if one is not present already. m4_define([_LT_FORMAT_COMMENT], [m4_ifval([$1], [ m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) )]) ## ------------------------ ## ## FIXME: Eliminate VARNAME ## ## ------------------------ ## # _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) # ------------------------------------------------------------------- # CONFIGNAME is the name given to the value in the libtool script. # VARNAME is the (base) name used in the configure script. # VALUE may be 0, 1 or 2 for a computed quote escaped value based on # VARNAME. Any other value will be used directly. m4_define([_LT_DECL], [lt_if_append_uniq([lt_decl_varnames], [$2], [, ], [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], [m4_ifval([$1], [$1], [$2])]) lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) m4_ifval([$4], [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) lt_dict_add_subkey([lt_decl_dict], [$2], [tagged?], [m4_ifval([$5], [yes], [no])])]) ]) # _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) # -------------------------------------------------------- m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) # lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_tag_varnames], [_lt_decl_filter([tagged?], [yes], $@)]) # _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) # --------------------------------------------------------- m4_define([_lt_decl_filter], [m4_case([$#], [0], [m4_fatal([$0: too few arguments: $#])], [1], [m4_fatal([$0: too few arguments: $#: $1])], [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], [lt_dict_filter([lt_decl_dict], $@)])[]dnl ]) # lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) # -------------------------------------------------- m4_define([lt_decl_quote_varnames], [_lt_decl_filter([value], [1], $@)]) # lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_dquote_varnames], [_lt_decl_filter([value], [2], $@)]) # lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_varnames_tagged], [m4_assert([$# <= 2])dnl _$0(m4_quote(m4_default([$1], [[, ]])), m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) m4_define([_lt_decl_varnames_tagged], [m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) # lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_all_varnames], [_$0(m4_quote(m4_default([$1], [[, ]])), m4_if([$2], [], m4_quote(lt_decl_varnames), m4_quote(m4_shift($@))))[]dnl ]) m4_define([_lt_decl_all_varnames], [lt_join($@, lt_decl_varnames_tagged([$1], lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl ]) # _LT_CONFIG_STATUS_DECLARE([VARNAME]) # ------------------------------------ # Quote a variable value, and forward it to 'config.status' so that its # declaration there will have the same value as in 'configure'. VARNAME # must have a single quote delimited value for this to work. m4_define([_LT_CONFIG_STATUS_DECLARE], [$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`']) # _LT_CONFIG_STATUS_DECLARATIONS # ------------------------------ # We delimit libtool config variables with single quotes, so when # we write them to config.status, we have to be sure to quote all # embedded single quotes properly. In configure, this macro expands # each variable declared with _LT_DECL (and _LT_TAGDECL) into: # # ='`$ECHO "$" | $SED "$delay_single_quote_subst"`' m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], [m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAGS # ---------------- # Output comment and list of tags supported by the script m4_defun([_LT_LIBTOOL_TAGS], [_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl available_tags='_LT_TAGS'dnl ]) # _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) # ----------------------------------- # Extract the dictionary values for VARNAME (optionally with TAG) and # expand to a commented shell variable setting: # # # Some comment about what VAR is for. # visible_name=$lt_internal_name m4_define([_LT_LIBTOOL_DECLARE], [_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [description])))[]dnl m4_pushdef([_libtool_name], m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), [0], [_libtool_name=[$]$1], [1], [_libtool_name=$lt_[]$1], [2], [_libtool_name=$lt_[]$1], [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl ]) # _LT_LIBTOOL_CONFIG_VARS # ----------------------- # Produce commented declarations of non-tagged libtool config variables # suitable for insertion in the LIBTOOL CONFIG section of the 'libtool' # script. Tagged libtool config variables (even for the LIBTOOL CONFIG # section) are produced by _LT_LIBTOOL_TAG_VARS. m4_defun([_LT_LIBTOOL_CONFIG_VARS], [m4_foreach([_lt_var], m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAG_VARS(TAG) # ------------------------- m4_define([_LT_LIBTOOL_TAG_VARS], [m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) # _LT_TAGVAR(VARNAME, [TAGNAME]) # ------------------------------ m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) # _LT_CONFIG_COMMANDS # ------------------- # Send accumulated output to $CONFIG_STATUS. Thanks to the lists of # variables for single and double quote escaping we saved from calls # to _LT_DECL, we can put quote escaped variables declarations # into 'config.status', and then the shell code to quote escape them in # for loops in 'config.status'. Finally, any additional code accumulated # from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. m4_defun([_LT_CONFIG_COMMANDS], [AC_PROVIDE_IFELSE([LT_OUTPUT], dnl If the libtool generation code has been placed in $CONFIG_LT, dnl instead of duplicating it all over again into config.status, dnl then we will have config.status run $CONFIG_LT later, so it dnl needs to know what name is stored there: [AC_CONFIG_COMMANDS([libtool], [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], dnl If the libtool generation code is destined for config.status, dnl expand the accumulated commands and init code now: [AC_CONFIG_COMMANDS([libtool], [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) ])#_LT_CONFIG_COMMANDS # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], [ # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' _LT_CONFIG_STATUS_DECLARATIONS LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$[]1 _LTECHO_EOF' } # Quote evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_quote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_dquote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done _LT_OUTPUT_LIBTOOL_INIT ]) # _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) # ------------------------------------ # Generate a child script FILE with all initialization necessary to # reuse the environment learned by the parent script, and make the # file executable. If COMMENT is supplied, it is inserted after the # '#!' sequence but before initialization text begins. After this # macro, additional text can be appended to FILE to form the body of # the child script. The macro ends with non-zero status if the # file could not be fully written (such as if the disk is full). m4_ifdef([AS_INIT_GENERATED], [m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], [m4_defun([_LT_GENERATED_FILE_INIT], [m4_require([AS_PREPARE])]dnl [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl [lt_write_fail=0 cat >$1 <<_ASEOF || lt_write_fail=1 #! $SHELL # Generated by $as_me. $2 SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$1 <<\_ASEOF || lt_write_fail=1 AS_SHELL_SANITIZE _AS_PREPARE exec AS_MESSAGE_FD>&1 _ASEOF test 0 = "$lt_write_fail" && chmod +x $1[]dnl m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT # LT_OUTPUT # --------- # This macro allows early generation of the libtool script (before # AC_OUTPUT is called), incase it is used in configure for compilation # tests. AC_DEFUN([LT_OUTPUT], [: ${CONFIG_LT=./config.lt} AC_MSG_NOTICE([creating $CONFIG_LT]) _LT_GENERATED_FILE_INIT(["$CONFIG_LT"], [# Run this file to recreate a libtool stub with the current configuration.]) cat >>"$CONFIG_LT" <<\_LTEOF lt_cl_silent=false exec AS_MESSAGE_LOG_FD>>config.log { echo AS_BOX([Running $as_me.]) } >&AS_MESSAGE_LOG_FD lt_cl_help="\ '$as_me' creates a local libtool stub from the current configuration, for use in further configure time tests before the real libtool is generated. Usage: $[0] [[OPTIONS]] -h, --help print this help, then exit -V, --version print version number, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files Report bugs to ." lt_cl_version="\ m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) configured by $[0], generated by m4_PACKAGE_STRING. Copyright (C) 2011 Free Software Foundation, Inc. This config.lt script is free software; the Free Software Foundation gives unlimited permision to copy, distribute and modify it." while test 0 != $[#] do case $[1] in --version | --v* | -V ) echo "$lt_cl_version"; exit 0 ;; --help | --h* | -h ) echo "$lt_cl_help"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --quiet | --q* | --silent | --s* | -q ) lt_cl_silent=: ;; -*) AC_MSG_ERROR([unrecognized option: $[1] Try '$[0] --help' for more information.]) ;; *) AC_MSG_ERROR([unrecognized argument: $[1] Try '$[0] --help' for more information.]) ;; esac shift done if $lt_cl_silent; then exec AS_MESSAGE_FD>/dev/null fi _LTEOF cat >>"$CONFIG_LT" <<_LTEOF _LT_OUTPUT_LIBTOOL_COMMANDS_INIT _LTEOF cat >>"$CONFIG_LT" <<\_LTEOF AC_MSG_NOTICE([creating $ofile]) _LT_OUTPUT_LIBTOOL_COMMANDS AS_EXIT(0) _LTEOF chmod +x "$CONFIG_LT" # configure is writing to config.log, but config.lt does its own redirection, # appending to config.log, which fails on DOS, as config.log is still kept # open by configure. Here we exec the FD to /dev/null, effectively closing # config.log, so it can be properly (re)opened and appended to by config.lt. lt_cl_success=: test yes = "$silent" && lt_config_lt_args="$lt_config_lt_args --quiet" exec AS_MESSAGE_LOG_FD>/dev/null $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false exec AS_MESSAGE_LOG_FD>>config.log $lt_cl_success || AS_EXIT(1) ])# LT_OUTPUT # _LT_CONFIG(TAG) # --------------- # If TAG is the built-in tag, create an initial libtool script with a # default configuration from the untagged config vars. Otherwise add code # to config.status for appending the configuration named by TAG from the # matching tagged config vars. m4_defun([_LT_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_CONFIG_SAVE_COMMANDS([ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl m4_if(_LT_TAG, [C], [ # See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi cfgfile=${ofile}T trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # Generated automatically by $as_me ($PACKAGE) $VERSION # NOTE: Changes made to this file will be lost: look at ltmain.sh. # Provide generalized library-building support services. # Written by Gordon Matzigkeit, 1996 _LT_COPYING _LT_LIBTOOL_TAGS # Configured defaults for sys_lib_dlsearch_path munging. : \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"} # ### BEGIN LIBTOOL CONFIG _LT_LIBTOOL_CONFIG_VARS _LT_LIBTOOL_TAG_VARS # ### END LIBTOOL CONFIG _LT_EOF cat <<'_LT_EOF' >> "$cfgfile" # ### BEGIN FUNCTIONS SHARED WITH CONFIGURE _LT_PREPARE_MUNGE_PATH_LIST _LT_PREPARE_CC_BASENAME # ### END FUNCTIONS SHARED WITH CONFIGURE _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac _LT_PROG_LTMAIN # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ], [cat <<_LT_EOF >> "$ofile" dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded dnl in a comment (ie after a #). # ### BEGIN LIBTOOL TAG CONFIG: $1 _LT_LIBTOOL_TAG_VARS(_LT_TAG) # ### END LIBTOOL TAG CONFIG: $1 _LT_EOF ])dnl /m4_if ], [m4_if([$1], [], [ PACKAGE='$PACKAGE' VERSION='$VERSION' RM='$RM' ofile='$ofile'], []) ])dnl /_LT_CONFIG_SAVE_COMMANDS ])# _LT_CONFIG # LT_SUPPORTED_TAG(TAG) # --------------------- # Trace this macro to discover what tags are supported by the libtool # --tag option, using: # autoconf --trace 'LT_SUPPORTED_TAG:$1' AC_DEFUN([LT_SUPPORTED_TAG], []) # C support is built-in for now m4_define([_LT_LANG_C_enabled], []) m4_define([_LT_TAGS], []) # LT_LANG(LANG) # ------------- # Enable libtool support for the given language if not already enabled. AC_DEFUN([LT_LANG], [AC_BEFORE([$0], [LT_OUTPUT])dnl m4_case([$1], [C], [_LT_LANG(C)], [C++], [_LT_LANG(CXX)], [Go], [_LT_LANG(GO)], [Java], [_LT_LANG(GCJ)], [Fortran 77], [_LT_LANG(F77)], [Fortran], [_LT_LANG(FC)], [Windows Resource], [_LT_LANG(RC)], [m4_ifdef([_LT_LANG_]$1[_CONFIG], [_LT_LANG($1)], [m4_fatal([$0: unsupported language: "$1"])])])dnl ])# LT_LANG # _LT_LANG(LANGNAME) # ------------------ m4_defun([_LT_LANG], [m4_ifdef([_LT_LANG_]$1[_enabled], [], [LT_SUPPORTED_TAG([$1])dnl m4_append([_LT_TAGS], [$1 ])dnl m4_define([_LT_LANG_]$1[_enabled], [])dnl _LT_LANG_$1_CONFIG($1)])dnl ])# _LT_LANG m4_ifndef([AC_PROG_GO], [ ############################################################ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_GO. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # ############################################################ m4_defun([AC_PROG_GO], [AC_LANG_PUSH(Go)dnl AC_ARG_VAR([GOC], [Go compiler command])dnl AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl _AC_ARG_VAR_LDFLAGS()dnl AC_CHECK_TOOL(GOC, gccgo) if test -z "$GOC"; then if test -n "$ac_tool_prefix"; then AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) fi fi if test -z "$GOC"; then AC_CHECK_PROG(GOC, gccgo, gccgo, false) fi ])#m4_defun ])#m4_ifndef # _LT_LANG_DEFAULT_CONFIG # ----------------------- m4_defun([_LT_LANG_DEFAULT_CONFIG], [AC_PROVIDE_IFELSE([AC_PROG_CXX], [LT_LANG(CXX)], [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) AC_PROVIDE_IFELSE([AC_PROG_F77], [LT_LANG(F77)], [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) AC_PROVIDE_IFELSE([AC_PROG_FC], [LT_LANG(FC)], [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal dnl pulling things in needlessly. AC_PROVIDE_IFELSE([AC_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([LT_PROG_GCJ], [LT_LANG(GCJ)], [m4_ifdef([AC_PROG_GCJ], [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([A][M_PROG_GCJ], [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([LT_PROG_GCJ], [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) AC_PROVIDE_IFELSE([AC_PROG_GO], [LT_LANG(GO)], [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) AC_PROVIDE_IFELSE([LT_PROG_RC], [LT_LANG(RC)], [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) ])# _LT_LANG_DEFAULT_CONFIG # Obsolete macros: AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_CXX], []) dnl AC_DEFUN([AC_LIBTOOL_F77], []) dnl AC_DEFUN([AC_LIBTOOL_FC], []) dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) dnl AC_DEFUN([AC_LIBTOOL_RC], []) # _LT_TAG_COMPILER # ---------------- m4_defun([_LT_TAG_COMPILER], [AC_REQUIRE([AC_PROG_CC])dnl _LT_DECL([LTCC], [CC], [1], [A C compiler])dnl _LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl _LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl _LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC ])# _LT_TAG_COMPILER # _LT_COMPILER_BOILERPLATE # ------------------------ # Check for compiler boilerplate output or warnings with # the simple compiler test code. m4_defun([_LT_COMPILER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ])# _LT_COMPILER_BOILERPLATE # _LT_LINKER_BOILERPLATE # ---------------------- # Check for linker boilerplate output or warnings with # the simple link test code. m4_defun([_LT_LINKER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ])# _LT_LINKER_BOILERPLATE # _LT_REQUIRED_DARWIN_CHECKS # ------------------------- m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ case $host_os in rhapsody* | darwin*) AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) AC_CHECK_TOOL([LIPO], [lipo], [:]) AC_CHECK_TOOL([OTOOL], [otool], [:]) AC_CHECK_TOOL([OTOOL64], [otool64], [:]) _LT_DECL([], [DSYMUTIL], [1], [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) _LT_DECL([], [NMEDIT], [1], [Tool to change global to local symbols on Mac OS X]) _LT_DECL([], [LIPO], [1], [Tool to manipulate fat objects and archives on Mac OS X]) _LT_DECL([], [OTOOL], [1], [ldd/readelf like tool for Mach-O binaries on Mac OS X]) _LT_DECL([], [OTOOL64], [1], [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], [lt_cv_apple_cc_single_mod=no if test -z "$LT_MULTI_MODULE"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test 0 = "$_lt_result"; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -rf libconftest.dylib* rm -f conftest.* fi]) AC_CACHE_CHECK([for -exported_symbols_list linker flag], [lt_cv_ld_exported_symbols_list], [lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [lt_cv_ld_exported_symbols_list=yes], [lt_cv_ld_exported_symbols_list=no]) LDFLAGS=$save_LDFLAGS ]) AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], [lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then lt_cv_ld_force_load=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM ]) case $host_os in rhapsody* | darwin1.[[012]]) _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; 10.[[012]][[,.]]*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test yes = "$lt_cv_apple_cc_single_mod"; then _lt_dar_single_mod='$single_module' fi if test yes = "$lt_cv_ld_exported_symbols_list"; then _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib' fi if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ]) # _LT_DARWIN_LINKER_FEATURES([TAG]) # --------------------------------- # Checks for linker and compiler features on darwin m4_defun([_LT_DARWIN_LINKER_FEATURES], [ m4_require([_LT_REQUIRED_DARWIN_CHECKS]) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported if test yes = "$lt_cv_ld_force_load"; then _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) else _LT_TAGVAR(whole_archive_flag_spec, $1)='' fi _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=$_lt_dar_allow_undefined case $cc_basename in ifort*|nagfor*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test yes = "$_lt_dar_can_shared"; then output_verbose_link_cmd=func_echo_all _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" m4_if([$1], [CXX], [ if test yes != "$lt_cv_apple_cc_single_mod"; then _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil" fi ],[]) else _LT_TAGVAR(ld_shlibs, $1)=no fi ]) # _LT_SYS_MODULE_PATH_AIX([TAGNAME]) # ---------------------------------- # Links a minimal program and checks the executable # for the system default hardcoded library path. In most cases, # this is /usr/lib:/lib, but when the MPI compilers are used # the location of the communication and MPI libs are included too. # If we don't find anything, use the default library path according # to the aix ld manual. # Store the results from the different compilers for each TAGNAME. # Allow to override them for all tags through lt_cv_aix_libpath. m4_defun([_LT_SYS_MODULE_PATH_AIX], [m4_require([_LT_DECL_SED])dnl if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ lt_aix_libpath_sed='[ /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }]' _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi],[]) if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=/usr/lib:/lib fi ]) aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) fi ])# _LT_SYS_MODULE_PATH_AIX # _LT_SHELL_INIT(ARG) # ------------------- m4_define([_LT_SHELL_INIT], [m4_divert_text([M4SH-INIT], [$1 ])])# _LT_SHELL_INIT # _LT_PROG_ECHO_BACKSLASH # ----------------------- # Find how we can fake an echo command that does not interpret backslash. # In particular, with Autoconf 2.60 or later we add some code to the start # of the generated configure script that will find a shell with a builtin # printf (that we can use as an echo command). m4_defun([_LT_PROG_ECHO_BACKSLASH], [ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO AC_MSG_CHECKING([how to print strings]) # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $[]1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } case $ECHO in printf*) AC_MSG_RESULT([printf]) ;; print*) AC_MSG_RESULT([print -r]) ;; *) AC_MSG_RESULT([cat]) ;; esac m4_ifdef([_AS_DETECT_SUGGESTED], [_AS_DETECT_SUGGESTED([ test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test "X`printf %s $ECHO`" = "X$ECHO" \ || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) _LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) ])# _LT_PROG_ECHO_BACKSLASH # _LT_WITH_SYSROOT # ---------------- AC_DEFUN([_LT_WITH_SYSROOT], [AC_MSG_CHECKING([for sysroot]) AC_ARG_WITH([sysroot], [AS_HELP_STRING([--with-sysroot@<:@=DIR@:>@], [Search for dependent libraries within DIR (or the compiler's sysroot if not specified).])], [], [with_sysroot=no]) dnl lt_sysroot will always be passed unquoted. We quote it here dnl in case the user passed a directory name. lt_sysroot= case $with_sysroot in #( yes) if test yes = "$GCC"; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) AC_MSG_RESULT([$with_sysroot]) AC_MSG_ERROR([The sysroot must be an absolute path.]) ;; esac AC_MSG_RESULT([${lt_sysroot:-no}]) _LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl [dependent libraries, and where our libraries should be installed.])]) # _LT_ENABLE_LOCK # --------------- m4_defun([_LT_ENABLE_LOCK], [AC_ARG_ENABLE([libtool-lock], [AS_HELP_STRING([--disable-libtool-lock], [avoid locking (might break parallel builds)])]) test no = "$enable_libtool_lock" || enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out what ABI is being produced by ac_compile, and set mode # options accordingly. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE=32 ;; *ELF-64*) HPUX_IA64_MODE=64 ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then if test yes = "$lt_cv_prog_gnu_ld"; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; mips64*-*linux*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then emul=elf case `/usr/bin/file conftest.$ac_objext` in *32-bit*) emul="${emul}32" ;; *64-bit*) emul="${emul}64" ;; esac case `/usr/bin/file conftest.$ac_objext` in *MSB*) emul="${emul}btsmip" ;; *LSB*) emul="${emul}ltsmip" ;; esac case `/usr/bin/file conftest.$ac_objext` in *N32*) emul="${emul}n32" ;; esac LD="${LD-ld} -m $emul" fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. Note that the listed cases only cover the # situations where additional linker options are needed (such as when # doing 32-bit compilation for a host where ld defaults to 64-bit, or # vice versa); the common cases where no linker options are needed do # not appear in the list. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) case `/usr/bin/file conftest.o` in *x86-64*) LD="${LD-ld} -m elf32_x86_64" ;; *) LD="${LD-ld} -m elf_i386" ;; esac ;; powerpc64le-*linux*) LD="${LD-ld} -m elf32lppclinux" ;; powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; powerpcle-*linux*) LD="${LD-ld} -m elf64lppc" ;; powerpc-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS=$CFLAGS CFLAGS="$CFLAGS -belf" AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, [AC_LANG_PUSH(C) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) AC_LANG_POP]) if test yes != "$lt_cv_cc_needs_belf"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS=$SAVE_CFLAGS fi ;; *-*solaris*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*|x86_64-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD=${LD-ld}_sol2 fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks=$enable_libtool_lock ])# _LT_ENABLE_LOCK # _LT_PROG_AR # ----------- m4_defun([_LT_PROG_AR], [AC_CHECK_TOOLS(AR, [ar], false) : ${AR=ar} : ${AR_FLAGS=cru} _LT_DECL([], [AR], [1], [The archiver]) _LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], [lt_cv_ar_at_file=no AC_COMPILE_IFELSE([AC_LANG_PROGRAM], [echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' AC_TRY_EVAL([lt_ar_try]) if test 0 -eq "$ac_status"; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a AC_TRY_EVAL([lt_ar_try]) if test 0 -ne "$ac_status"; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a ]) ]) if test no = "$lt_cv_ar_at_file"; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi _LT_DECL([], [archiver_list_spec], [1], [How to feed a file listing to the archiver]) ])# _LT_PROG_AR # _LT_CMD_OLD_ARCHIVE # ------------------- m4_defun([_LT_CMD_OLD_ARCHIVE], [_LT_PROG_AR AC_CHECK_TOOL(STRIP, strip, :) test -z "$STRIP" && STRIP=: _LT_DECL([], [STRIP], [1], [A symbol stripping program]) AC_CHECK_TOOL(RANLIB, ranlib, :) test -z "$RANLIB" && RANLIB=: _LT_DECL([], [RANLIB], [1], [Commands used to install an old-style archive]) # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in bitrig* | openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac _LT_DECL([], [old_postinstall_cmds], [2]) _LT_DECL([], [old_postuninstall_cmds], [2]) _LT_TAGDECL([], [old_archive_cmds], [2], [Commands used to build an old-style archive]) _LT_DECL([], [lock_old_archive_extraction], [0], [Whether to use a lock for old archive extraction]) ])# _LT_CMD_OLD_ARCHIVE # _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------------------- # Check whether the given compiler option works AC_DEFUN([_LT_COMPILER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$3" ## exclude from sc_useless_quotes_in_assignment # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi fi $RM conftest* ]) if test yes = "[$]$2"; then m4_if([$5], , :, [$5]) else m4_if([$6], , :, [$6]) fi ])# _LT_COMPILER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) # _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------- # Check whether the given linker option works AC_DEFUN([_LT_LINKER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS $3" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&AS_MESSAGE_LOG_FD $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi else $2=yes fi fi $RM -r conftest* LDFLAGS=$save_LDFLAGS ]) if test yes = "[$]$2"; then m4_if([$4], , :, [$4]) else m4_if([$5], , :, [$5]) fi ])# _LT_LINKER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) # LT_CMD_MAX_LEN #--------------- AC_DEFUN([LT_CMD_MAX_LEN], [AC_REQUIRE([AC_CANONICAL_HOST])dnl # find the maximum length of command line arguments AC_MSG_CHECKING([the maximum length of command line arguments]) AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl i=0 teststring=ABCD case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len" && \ test undefined != "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test X`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test 17 != "$i" # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac ]) if test -n "$lt_cv_sys_max_cmd_len"; then AC_MSG_RESULT($lt_cv_sys_max_cmd_len) else AC_MSG_RESULT(none) fi max_cmd_len=$lt_cv_sys_max_cmd_len _LT_DECL([], [max_cmd_len], [0], [What is the maximum length of a command?]) ])# LT_CMD_MAX_LEN # Old name: AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) # _LT_HEADER_DLFCN # ---------------- m4_defun([_LT_HEADER_DLFCN], [AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl ])# _LT_HEADER_DLFCN # _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, # ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) # ---------------------------------------------------------------- m4_defun([_LT_TRY_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test yes = "$cross_compiling"; then : [$4] else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF [#line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisibility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; }] _LT_EOF if AC_TRY_EVAL(ac_link) && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) $1 ;; x$lt_dlneed_uscore) $2 ;; x$lt_dlunknown|x*) $3 ;; esac else : # compilation failed $3 fi fi rm -fr conftest* ])# _LT_TRY_DLOPEN_SELF # LT_SYS_DLOPEN_SELF # ------------------ AC_DEFUN([LT_SYS_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test yes != "$enable_dlopen"; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen=load_add_on lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen=LoadLibrary lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen=dlopen lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl],[ lt_cv_dlopen=dyld lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ]) ;; tpf*) # Don't try to run any link tests for TPF. We know it's impossible # because TPF is a cross-compiler, and we know how we open DSOs. lt_cv_dlopen=dlopen lt_cv_dlopen_libs= lt_cv_dlopen_self=no ;; *) AC_CHECK_FUNC([shl_load], [lt_cv_dlopen=shl_load], [AC_CHECK_LIB([dld], [shl_load], [lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld], [AC_CHECK_FUNC([dlopen], [lt_cv_dlopen=dlopen], [AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl], [AC_CHECK_LIB([svld], [dlopen], [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld], [AC_CHECK_LIB([dld], [dld_link], [lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld]) ]) ]) ]) ]) ]) ;; esac if test no = "$lt_cv_dlopen"; then enable_dlopen=no else enable_dlopen=yes fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS=$CPPFLAGS test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS=$LDFLAGS wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS=$LIBS LIBS="$lt_cv_dlopen_libs $LIBS" AC_CACHE_CHECK([whether a program can dlopen itself], lt_cv_dlopen_self, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) ]) if test yes = "$lt_cv_dlopen_self"; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" AC_CACHE_CHECK([whether a statically linked program can dlopen itself], lt_cv_dlopen_self_static, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) ]) fi CPPFLAGS=$save_CPPFLAGS LDFLAGS=$save_LDFLAGS LIBS=$save_LIBS ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi _LT_DECL([dlopen_support], [enable_dlopen], [0], [Whether dlopen is supported]) _LT_DECL([dlopen_self], [enable_dlopen_self], [0], [Whether dlopen of programs is supported]) _LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], [Whether dlopen of statically linked programs is supported]) ])# LT_SYS_DLOPEN_SELF # Old name: AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) # _LT_COMPILER_C_O([TAGNAME]) # --------------------------- # Check to see if options -c and -o are simultaneously supported by compiler. # This macro does not hard code the compiler like AC_PROG_CC_C_O. m4_defun([_LT_COMPILER_C_O], [m4_require([_LT_DECL_SED])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes fi fi chmod u+w . 2>&AS_MESSAGE_LOG_FD $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* ]) _LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], [Does compiler simultaneously support -c and -o options?]) ])# _LT_COMPILER_C_O # _LT_COMPILER_FILE_LOCKS([TAGNAME]) # ---------------------------------- # Check to see if we can do hard links to lock some files if needed m4_defun([_LT_COMPILER_FILE_LOCKS], [m4_require([_LT_ENABLE_LOCK])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_COMPILER_C_O([$1]) hard_links=nottested if test no = "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" && test no != "$need_locks"; then # do not overwrite the value of need_locks provided by the user AC_MSG_CHECKING([if we can lock with hard links]) hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no AC_MSG_RESULT([$hard_links]) if test no = "$hard_links"; then AC_MSG_WARN(['$CC' does not support '-c -o', so 'make -j' may be unsafe]) need_locks=warn fi else need_locks=no fi _LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) ])# _LT_COMPILER_FILE_LOCKS # _LT_CHECK_OBJDIR # ---------------- m4_defun([_LT_CHECK_OBJDIR], [AC_CACHE_CHECK([for objdir], [lt_cv_objdir], [rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null]) objdir=$lt_cv_objdir _LT_DECL([], [objdir], [0], [The name of the directory that contains temporary libtool files])dnl m4_pattern_allow([LT_OBJDIR])dnl AC_DEFINE_UNQUOTED([LT_OBJDIR], "$lt_cv_objdir/", [Define to the sub-directory where libtool stores uninstalled libraries.]) ])# _LT_CHECK_OBJDIR # _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) # -------------------------------------- # Check hardcoding attributes. m4_defun([_LT_LINKER_HARDCODE_LIBPATH], [AC_MSG_CHECKING([how to hardcode library paths into programs]) _LT_TAGVAR(hardcode_action, $1)= if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || test -n "$_LT_TAGVAR(runpath_var, $1)" || test yes = "$_LT_TAGVAR(hardcode_automatic, $1)"; then # We can hardcode non-existent directories. if test no != "$_LT_TAGVAR(hardcode_direct, $1)" && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" && test no != "$_LT_TAGVAR(hardcode_minus_L, $1)"; then # Linking always hardcodes the temporary library directory. _LT_TAGVAR(hardcode_action, $1)=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. _LT_TAGVAR(hardcode_action, $1)=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. _LT_TAGVAR(hardcode_action, $1)=unsupported fi AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) if test relink = "$_LT_TAGVAR(hardcode_action, $1)" || test yes = "$_LT_TAGVAR(inherit_rpath, $1)"; then # Fast installation is not supported enable_fast_install=no elif test yes = "$shlibpath_overrides_runpath" || test no = "$enable_shared"; then # Fast installation is not necessary enable_fast_install=needless fi _LT_TAGDECL([], [hardcode_action], [0], [How to hardcode a shared library path into an executable]) ])# _LT_LINKER_HARDCODE_LIBPATH # _LT_CMD_STRIPLIB # ---------------- m4_defun([_LT_CMD_STRIPLIB], [m4_require([_LT_DECL_EGREP]) striplib= old_striplib= AC_MSG_CHECKING([whether stripping libraries is possible]) if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" AC_MSG_RESULT([yes]) else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP"; then striplib="$STRIP -x" old_striplib="$STRIP -S" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi ;; *) AC_MSG_RESULT([no]) ;; esac fi _LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) _LT_DECL([], [striplib], [1]) ])# _LT_CMD_STRIPLIB # _LT_PREPARE_MUNGE_PATH_LIST # --------------------------- # Make sure func_munge_path_list() is defined correctly. m4_defun([_LT_PREPARE_MUNGE_PATH_LIST], [[# func_munge_path_list VARIABLE PATH # ----------------------------------- # VARIABLE is name of variable containing _space_ separated list of # directories to be munged by the contents of PATH, which is string # having a format: # "DIR[:DIR]:" # string "DIR[ DIR]" will be prepended to VARIABLE # ":DIR[:DIR]" # string "DIR[ DIR]" will be appended to VARIABLE # "DIRP[:DIRP]::[DIRA:]DIRA" # string "DIRP[ DIRP]" will be prepended to VARIABLE and string # "DIRA[ DIRA]" will be appended to VARIABLE # "DIR[:DIR]" # VARIABLE will be replaced by "DIR[ DIR]" func_munge_path_list () { case x@S|@2 in x) ;; *:) eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'` \@S|@@S|@1\" ;; x:*) eval @S|@1=\"\@S|@@S|@1 `$ECHO @S|@2 | $SED 's/:/ /g'`\" ;; *::*) eval @S|@1=\"\@S|@@S|@1\ `$ECHO @S|@2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" eval @S|@1=\"`$ECHO @S|@2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \@S|@@S|@1\" ;; *) eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'`\" ;; esac } ]])# _LT_PREPARE_PATH_LIST # _LT_SYS_DYNAMIC_LINKER([TAG]) # ----------------------------- # PORTME Fill in your ld.so characteristics m4_defun([_LT_SYS_DYNAMIC_LINKER], [AC_REQUIRE([AC_CANONICAL_HOST])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_OBJDUMP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl m4_require([_LT_PREPARE_MUNGE_PATH_LIST])dnl AC_MSG_CHECKING([dynamic linker characteristics]) m4_if([$1], [], [ if test yes = "$GCC"; then case $host_os in darwin*) lt_awk_arg='/^libraries:/,/LR/' ;; *) lt_awk_arg='/^libraries:/' ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq='s|=\([[A-Za-z]]:\)|\1|g' ;; *) lt_sed_strip_eq='s|=/|/|g' ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary... lt_tmp_lt_search_path_spec= lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` # ...but if some path component already ends with the multilib dir we assume # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer). case "$lt_multi_os_dir; $lt_search_path_spec " in "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*) lt_multi_os_dir= ;; esac for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir" elif test -n "$lt_multi_os_dir"; then test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS = " "; FS = "/|\n";} { lt_foo = ""; lt_count = 0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo = "/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[[lt_foo]]++; } if (lt_freq[[lt_foo]] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's|/\([[A-Za-z]]:\)|\1|g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi]) library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=.so postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown AC_ARG_VAR([LT_SYS_LIBRARY_PATH], [User-defined run-time library search path.]) case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='$libname$release$shared_ext$major' ;; aix[[4-9]]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test ia64 = "$host_cpu"; then # AIX 5 supports IA64 library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line '#! .'. This would cause the generated library to # depend on '.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[[01]] | aix4.[[01]].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # Using Import Files as archive members, it is possible to support # filename-based versioning of shared library archives on AIX. While # this would work for both with and without runtime linking, it will # prevent static linking of such archives. So we do filename-based # shared library versioning with .so extension only, which is used # when both runtime linking and shared linking is enabled. # Unfortunately, runtime linking may impact performance, so we do # not want this to be the default eventually. Also, we use the # versioned .so libs for executables only if there is the -brtl # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only. # To allow for filename-based versioning support, we need to create # libNAME.so.V as an archive file, containing: # *) an Import File, referring to the versioned filename of the # archive as well as the shared archive member, telling the # bitwidth (32 or 64) of that shared object, and providing the # list of exported symbols of that shared object, eventually # decorated with the 'weak' keyword # *) the shared object with the F_LOADONLY flag set, to really avoid # it being seen by the linker. # At run time we better use the real file rather than another symlink, # but for link time we create the symlink libNAME.so -> libNAME.so.V case $with_aix_soname,$aix_use_runtimelinking in # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. aix,yes) # traditional libtool dynamic_linker='AIX unversionable lib.so' # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; aix,no) # traditional AIX only dynamic_linker='AIX lib.a[(]lib.so.V[)]' # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='$libname$release.a $libname.a' soname_spec='$libname$release$shared_ext$major' ;; svr4,*) # full svr4 only dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)]" library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' # We do not specify a path in Import Files, so LIBPATH fires. shlibpath_overrides_runpath=yes ;; *,yes) # both, prefer svr4 dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)], lib.a[(]lib.so.V[)]" library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' # unpreferred sharedlib libNAME.a needs extra handling postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"' postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"' # We do not specify a path in Import Files, so LIBPATH fires. shlibpath_overrides_runpath=yes ;; *,no) # both, prefer aix dynamic_linker="AIX lib.a[(]lib.so.V[)], lib.so.V[(]$shared_archive_member_spec.o[)]" library_names_spec='$libname$release.a $libname.a' soname_spec='$libname$release$shared_ext$major' # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)' postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"' ;; esac shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='$libname$shared_ext' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[[45]]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=.dll need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' library_names_spec='$libname.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec=$LIB if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' soname_spec='$libname$release$major$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[[23]].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[[01]]* | freebsdelf3.[[01]]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=no sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' if test 32 = "$HPUX_IA64_MODE"; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" sys_lib_dlsearch_path_spec=/usr/lib/hpux32 else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" sys_lib_dlsearch_path_spec=/usr/lib/hpux64 fi ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[[3-9]]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test yes = "$lt_cv_prog_gnu_ld"; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='$libname$release$shared_ext$major' library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff" sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; linux*android*) version_type=none # Android doesn't support versioned libraries. need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext' soname_spec='$libname$release$shared_ext' finish_cmds= shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes dynamic_linker='Android linker' # Don't embed -rpath directories since the linker doesn't support them. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], [lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], [lt_cv_shlibpath_overrides_runpath=yes])]) LDFLAGS=$save_LDFLAGS libdir=$save_libdir ]) shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Ideally, we could use ldconfig to report *all* directores which are # searched for libraries, however this is still not possible. Aside from not # being certain /sbin/ldconfig is available, command # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64, # even though it is searched at run-time. Try to do the best guess by # appending ld.so.conf contents (and includes) to the search path. if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsdelf*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='NetBSD ld.elf_so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd* | bitrig*) version_type=sunos sys_lib_dlsearch_path_spec=/usr/lib need_lib_prefix=no if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then need_version=no else need_version=yes fi library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; os2*) libname_spec='$name' version_type=windows shrext_cmds=.dll need_version=no need_lib_prefix=no # OS/2 can only load a DLL with a base name of 8 characters or less. soname_spec='`test -n "$os2dllname" && libname="$os2dllname"; v=$($ECHO $release$versuffix | tr -d .-); n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _); $ECHO $n$v`$shared_ext' library_names_spec='${libname}_dll.$libext' dynamic_linker='OS/2 ld.exe' shlibpath_var=BEGINLIBPATH sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='$libname$release$shared_ext$major' library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test yes = "$with_gnu_ld"; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec; then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext' soname_spec='$libname$shared_ext.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=sco need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test yes = "$with_gnu_ld"; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac AC_MSG_RESULT([$dynamic_linker]) test no = "$dynamic_linker" && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test yes = "$GCC"; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec fi if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec fi # remember unaugmented sys_lib_dlsearch_path content for libtool script decls... configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec # ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH" # to be used as default LT_SYS_LIBRARY_PATH value in generated libtool configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH _LT_DECL([], [variables_saved_for_relink], [1], [Variables whose values should be saved in libtool wrapper scripts and restored at link time]) _LT_DECL([], [need_lib_prefix], [0], [Do we need the "lib" prefix for modules?]) _LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) _LT_DECL([], [version_type], [0], [Library versioning type]) _LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) _LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) _LT_DECL([], [shlibpath_overrides_runpath], [0], [Is shlibpath searched before the hard-coded library search path?]) _LT_DECL([], [libname_spec], [1], [Format of library name prefix]) _LT_DECL([], [library_names_spec], [1], [[List of archive names. First name is the real one, the rest are links. The last name is the one that the linker finds with -lNAME]]) _LT_DECL([], [soname_spec], [1], [[The coded name of the library, if different from the real name]]) _LT_DECL([], [install_override_mode], [1], [Permission mode override for installation of shared libraries]) _LT_DECL([], [postinstall_cmds], [2], [Command to use after installation of a shared archive]) _LT_DECL([], [postuninstall_cmds], [2], [Command to use after uninstallation of a shared archive]) _LT_DECL([], [finish_cmds], [2], [Commands used to finish a libtool library installation in a directory]) _LT_DECL([], [finish_eval], [1], [[As "finish_cmds", except a single script fragment to be evaled but not shown]]) _LT_DECL([], [hardcode_into_libs], [0], [Whether we should hardcode library paths into libraries]) _LT_DECL([], [sys_lib_search_path_spec], [2], [Compile-time system search path for libraries]) _LT_DECL([sys_lib_dlsearch_path_spec], [configure_time_dlsearch_path], [2], [Detected run-time system search path for libraries]) _LT_DECL([], [configure_time_lt_sys_library_path], [2], [Explicit LT_SYS_LIBRARY_PATH set during ./configure time]) ])# _LT_SYS_DYNAMIC_LINKER # _LT_PATH_TOOL_PREFIX(TOOL) # -------------------------- # find a file program that can recognize shared library AC_DEFUN([_LT_PATH_TOOL_PREFIX], [m4_require([_LT_DECL_EGREP])dnl AC_MSG_CHECKING([for $1]) AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, [case $MAGIC_CMD in [[\\/*] | ?:[\\/]*]) lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD=$MAGIC_CMD lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR dnl $ac_dummy forces splitting on constant user-supplied paths. dnl POSIX.2 word splitting is done only on the output of word expansions, dnl not every word. This closes a longstanding sh security hole. ac_dummy="m4_if([$2], , $PATH, [$2])" for ac_dir in $ac_dummy; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$1"; then lt_cv_path_MAGIC_CMD=$ac_dir/"$1" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD=$lt_cv_path_MAGIC_CMD if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS=$lt_save_ifs MAGIC_CMD=$lt_save_MAGIC_CMD ;; esac]) MAGIC_CMD=$lt_cv_path_MAGIC_CMD if test -n "$MAGIC_CMD"; then AC_MSG_RESULT($MAGIC_CMD) else AC_MSG_RESULT(no) fi _LT_DECL([], [MAGIC_CMD], [0], [Used to examine libraries when file_magic_cmd begins with "file"])dnl ])# _LT_PATH_TOOL_PREFIX # Old name: AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) # _LT_PATH_MAGIC # -------------- # find a file program that can recognize a shared library m4_defun([_LT_PATH_MAGIC], [_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) else MAGIC_CMD=: fi fi ])# _LT_PATH_MAGIC # LT_PATH_LD # ---------- # find the pathname to the GNU or non-GNU linker AC_DEFUN([LT_PATH_LD], [AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PROG_ECHO_BACKSLASH])dnl AC_ARG_WITH([gnu-ld], [AS_HELP_STRING([--with-gnu-ld], [assume the C compiler uses GNU ld @<:@default=no@:>@])], [test no = "$withval" || with_gnu_ld=yes], [with_gnu_ld=no])dnl ac_prog=ld if test yes = "$GCC"; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by $CC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return, which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [[\\/]]* | ?:[[\\/]]*) re_direlt='/[[^/]][[^/]]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD=$ac_prog ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test yes = "$with_gnu_ld"; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL(lt_cv_path_LD, [if test -z "$LD"; then lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD=$ac_dir/$ac_prog # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &1 conftest.i cat conftest.i conftest.i >conftest2.i : ${lt_DD:=$DD} AC_PATH_PROGS_FEATURE_CHECK([lt_DD], [dd], [if "$ac_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then cmp -s conftest.i conftest.out \ && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=: fi]) rm -f conftest.i conftest2.i conftest.out]) ])# _LT_PATH_DD # _LT_CMD_TRUNCATE # ---------------- # find command to truncate a binary pipe m4_defun([_LT_CMD_TRUNCATE], [m4_require([_LT_PATH_DD]) AC_CACHE_CHECK([how to truncate binary pipes], [lt_cv_truncate_bin], [printf 0123456789abcdef0123456789abcdef >conftest.i cat conftest.i conftest.i >conftest2.i lt_cv_truncate_bin= if "$ac_cv_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then cmp -s conftest.i conftest.out \ && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1" fi rm -f conftest.i conftest2.i conftest.out test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q"]) _LT_DECL([lt_truncate_bin], [lt_cv_truncate_bin], [1], [Command to truncate a binary pipe]) ])# _LT_CMD_TRUNCATE # _LT_CHECK_MAGIC_METHOD # ---------------------- # how to check for library dependencies # -- PORTME fill in with the dynamic library characteristics m4_defun([_LT_CHECK_MAGIC_METHOD], [m4_require([_LT_DECL_EGREP]) m4_require([_LT_DECL_OBJDUMP]) AC_CACHE_CHECK([how to recognize dependent libraries], lt_cv_deplibs_check_method, [lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # 'unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # that responds to the $file_magic_cmd with a given extended regex. # If you have 'file' or equivalent on your system and you're not sure # whether 'pass_all' will *always* work, you probably want this one. case $host_os in aix[[4-9]]*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi[[45]]*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin*) # func_win32_libid is a shell function defined in ltmain.sh lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' ;; mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. if ( file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'] lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[[3-9]]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) lt_cv_deplibs_check_method=pass_all ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd* | bitrig*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; os2*) lt_cv_deplibs_check_method=pass_all ;; esac ]) file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown _LT_DECL([], [deplibs_check_method], [1], [Method to check whether dependent libraries are shared objects]) _LT_DECL([], [file_magic_cmd], [1], [Command to use when deplibs_check_method = "file_magic"]) _LT_DECL([], [file_magic_glob], [1], [How to find potential files when deplibs_check_method = "file_magic"]) _LT_DECL([], [want_nocaseglob], [1], [Find potential files using nocaseglob when deplibs_check_method = "file_magic"]) ])# _LT_CHECK_MAGIC_METHOD # LT_PATH_NM # ---------- # find the pathname to a BSD- or MS-compatible name lister AC_DEFUN([LT_PATH_NM], [AC_REQUIRE([AC_PROG_CC])dnl AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, [if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM=$NM else lt_nm_to_check=${ac_tool_prefix}nm if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. tmp_nm=$ac_dir/$lt_tmp_nm if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then # Check to see if the nm accepts a BSD-compat flag. # Adding the 'sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty case $build_os in mingw*) lt_bad_file=conftest.nm/nofile ;; *) lt_bad_file=/dev/null ;; esac case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in *$lt_bad_file* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break 2 ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break 2 ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS=$lt_save_ifs done : ${lt_cv_path_NM=no} fi]) if test no != "$lt_cv_path_NM"; then NM=$lt_cv_path_NM else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols -headers" ;; *) DUMPBIN=: ;; esac fi AC_SUBST([DUMPBIN]) if test : != "$DUMPBIN"; then NM=$DUMPBIN fi fi test -z "$NM" && NM=nm AC_SUBST([NM]) _LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], [lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD) cat conftest.out >&AS_MESSAGE_LOG_FD if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest*]) ])# LT_PATH_NM # Old names: AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_PROG_NM], []) dnl AC_DEFUN([AC_PROG_NM], []) # _LT_CHECK_SHAREDLIB_FROM_LINKLIB # -------------------------------- # how to determine the name of the shared library # associated with a specific link library. # -- PORTME fill in with the dynamic library characteristics m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], [m4_require([_LT_DECL_EGREP]) m4_require([_LT_DECL_OBJDUMP]) m4_require([_LT_DECL_DLLTOOL]) AC_CACHE_CHECK([how to associate runtime and link libraries], lt_cv_sharedlib_from_linklib_cmd, [lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh; # decide which one to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd=$ECHO ;; esac ]) sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO _LT_DECL([], [sharedlib_from_linklib_cmd], [1], [Command to associate shared and link libraries]) ])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB # _LT_PATH_MANIFEST_TOOL # ---------------------- # locate the manifest tool m4_defun([_LT_PATH_MANIFEST_TOOL], [AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], [lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&AS_MESSAGE_LOG_FD if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest*]) if test yes != "$lt_cv_path_mainfest_tool"; then MANIFEST_TOOL=: fi _LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl ])# _LT_PATH_MANIFEST_TOOL # _LT_DLL_DEF_P([FILE]) # --------------------- # True iff FILE is a Windows DLL '.def' file. # Keep in sync with func_dll_def_p in the libtool script AC_DEFUN([_LT_DLL_DEF_P], [dnl test DEF = "`$SED -n dnl -e '\''s/^[[ ]]*//'\'' dnl Strip leading whitespace -e '\''/^\(;.*\)*$/d'\'' dnl Delete empty lines and comments -e '\''s/^\(EXPORTS\|LIBRARY\)\([[ ]].*\)*$/DEF/p'\'' dnl -e q dnl Only consider the first "real" line $1`" dnl ])# _LT_DLL_DEF_P # LT_LIB_M # -------- # check for math library AC_DEFUN([LT_LIB_M], [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= case $host in *-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) # These system don't have libm, or don't need it ;; *-ncr-sysv4.3*) AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM=-lmw) AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") ;; *) AC_CHECK_LIB(m, cos, LIBM=-lm) ;; esac AC_SUBST([LIBM]) ])# LT_LIB_M # Old name: AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_CHECK_LIBM], []) # _LT_COMPILER_NO_RTTI([TAGNAME]) # ------------------------------- m4_defun([_LT_COMPILER_NO_RTTI], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= if test yes = "$GCC"; then case $cc_basename in nvcc*) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; *) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; esac _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], lt_cv_prog_compiler_rtti_exceptions, [-fno-rtti -fno-exceptions], [], [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) fi _LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], [Compiler flag to turn off builtin functions]) ])# _LT_COMPILER_NO_RTTI # _LT_CMD_GLOBAL_SYMBOLS # ---------------------- m4_defun([_LT_CMD_GLOBAL_SYMBOLS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([LT_PATH_NM])dnl AC_REQUIRE([LT_PATH_LD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_TAG_COMPILER])dnl # Check for command to grab the raw symbol name followed by C symbol from nm. AC_MSG_CHECKING([command to parse $NM output from $compiler object]) AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], [ # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[[BCDEGRST]]' # Regexp to match symbols that can be accessed directly from C. sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[[BCDT]]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[[ABCDGISTW]]' ;; hpux*) if test ia64 = "$host_cpu"; then symcode='[[ABCDEGRST]]' fi ;; irix* | nonstopux*) symcode='[[BCDEGRST]]' ;; osf*) symcode='[[BCDEGQRST]]' ;; solaris*) symcode='[[BDRT]]' ;; sco3.2v5*) symcode='[[DT]]' ;; sysv4.2uw2*) symcode='[[DT]]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[[ABDT]]' ;; sysv4) symcode='[[DFNSTU]]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[[ABCDGIRSTW]]' ;; esac if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Gets list of data symbols to import. lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'" # Adjust the below global symbol transforms to fixup imported variables. lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" lt_c_name_lib_hook="\ -e 's/^I .* \(lib.*\)$/ {\"\1\", (void *) 0},/p'\ -e 's/^I .* \(.*\)$/ {\"lib\1\", (void *) 0},/p'" else # Disable hooks by default. lt_cv_sys_global_symbol_to_import= lt_cdecl_hook= lt_c_name_hook= lt_c_name_lib_hook= fi # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n"\ $lt_cdecl_hook\ " -e 's/^T .* \(.*\)$/extern int \1();/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n"\ $lt_c_name_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" # Transform an extracted symbol line into symbol name with lib prefix and # symbol address. lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\ $lt_c_name_lib_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"lib\1\", (void *) \&\1},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function, # D for any global variable and I for any imported variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK ['"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\ " /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\ " /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\ " {split(\$ 0,a,/\||\r/); split(a[2],s)};"\ " s[1]~/^[@?]/{print f,s[1],s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx]" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if AC_TRY_EVAL(ac_compile); then # Now try to grab the symbols. nlist=conftest.nm $ECHO "$as_me:$LINENO: $NM conftest.$ac_objext | $lt_cv_sys_global_symbol_pipe > $nlist" >&AS_MESSAGE_LOG_FD if eval "$NM" conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist 2>&AS_MESSAGE_LOG_FD && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE /* DATA imports from DLLs on WIN32 can't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT@&t@_DLSYM_CONST #elif defined __osf__ /* This system does not cope well with relocations in const data. */ # define LT@&t@_DLSYM_CONST #else # define LT@&t@_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT@&t@_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[[]] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS=conftstm.$ac_objext CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" if AC_TRY_EVAL(ac_link) && test -s conftest$ac_exeext; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD fi else echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test yes = "$pipe_works"; then break else lt_cv_sys_global_symbol_pipe= fi done ]) if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then AC_MSG_RESULT(failed) else AC_MSG_RESULT(ok) fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then nm_file_list_spec='@' fi _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], [Take the output of nm and produce a listing of raw symbols and C names]) _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], [Transform the output of nm in a proper C declaration]) _LT_DECL([global_symbol_to_import], [lt_cv_sys_global_symbol_to_import], [1], [Transform the output of nm into a list of symbols to manually relocate]) _LT_DECL([global_symbol_to_c_name_address], [lt_cv_sys_global_symbol_to_c_name_address], [1], [Transform the output of nm in a C name address pair]) _LT_DECL([global_symbol_to_c_name_address_lib_prefix], [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], [Transform the output of nm in a C name address pair when lib prefix is needed]) _LT_DECL([nm_interface], [lt_cv_nm_interface], [1], [The name lister interface]) _LT_DECL([], [nm_file_list_spec], [1], [Specify filename containing input files for $NM]) ]) # _LT_CMD_GLOBAL_SYMBOLS # _LT_COMPILER_PIC([TAGNAME]) # --------------------------- m4_defun([_LT_COMPILER_PIC], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_wl, $1)= _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)= m4_if([$1], [CXX], [ # C++ specific cases for pic, static, wl, etc. if test yes = "$GXX"; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the '-m68020' flag to GCC prevents building anything better, # like '-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) case $host_os in os2*) _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' ;; esac ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac else case $host_os in aix[[4-9]]*) # All AIX code is PIC. if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" ;; esac ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; dgux*) case $cc_basename in ec++*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; ghcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; freebsd* | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' if test ia64 != "$host_cpu"; then _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' fi ;; aCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac ;; *) ;; esac ;; interix*) # This is c89, which is MS Visual C++ (no shared libs) # Anyone wants to do a port? ;; irix5* | irix6* | nonstopux*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' # CC pic flag -KPIC is the default. ;; *) ;; esac ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in KCC*) # KAI C++ Compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; ecpc* ) # old Intel C++ for x86_64, which still supported -KPIC. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; icpc* ) # Intel C++, used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; pgCC* | pgcpp*) # Portland Group C++ compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; cxx*) # Compaq C++ # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL 8.0, 9.0 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; esac ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' ;; *) ;; esac ;; netbsd* | netbsdelf*-gnu) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; cxx*) # Digital/Compaq C++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; lcc*) # Lucid _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; *) ;; esac ;; vxworks*) ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ], [ if test yes = "$GCC"; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the '-m68020' flag to GCC prevents building anything better, # like '-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) case $host_os in os2*) _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' ;; esac ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' case $cc_basename in nagfor*) # NAG Fortran compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) case $host_os in os2*) _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' ;; esac ;; hpux9* | hpux10* | hpux11*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC (with -KPIC) is the default. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in # old Intel for x86_64, which still supported -KPIC. ecc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # Lahey Fortran 8.1. lf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' ;; nagfor*) # NAG Fortran compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; tcc*) # Fabrice Bellard et al's Tiny C Compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; ccc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All Alpha code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='' ;; *Sun\ F* | *Sun*Fortran*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' ;; *Intel*\ [[CF]]*Compiler*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; *Portland\ Group*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; esac ;; newsos6) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All OSF/1 code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; rdos*) _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; solaris*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; *) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; esac ;; sunos4*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; unicos*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; uts4*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ]) case $host_os in # For platforms that do not support PIC, -DPIC is meaningless: *djgpp*) _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" ;; esac AC_CACHE_CHECK([for $compiler option to produce PIC], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) _LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) # # Check to make sure the PIC flag actually works. # if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in "" | " "*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; esac], [_LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) fi _LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], [Additional compiler flags for building library objects]) _LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], [How to pass a linker flag through the compiler]) # # Check to make sure the static flag actually works. # wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" _LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), $lt_tmp_static_flag, [], [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) _LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], [Compiler flag to prevent dynamic linking]) ])# _LT_COMPILER_PIC # _LT_LINKER_SHLIBS([TAGNAME]) # ---------------------------- # See if the linker supports building shared libraries. m4_defun([_LT_LINKER_SHLIBS], [AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) m4_if([$1], [CXX], [ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] case $host_os in aix[[4-9]]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to GNU nm, but means don't demangle to AIX nm. # Without the "-l" option, or with the "-B" option, AIX nm treats # weak defined symbols like other global defined symbols, whereas # GNU nm marks them as "W". # While the 'weak' keyword is ignored in the Export File, we need # it in the Import File for the 'aix-soname' feature, so we have # to replace the "-B" option with "-P" for AIX nm. if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi ;; pw32*) _LT_TAGVAR(export_symbols_cmds, $1)=$ltdll_cmds ;; cygwin* | mingw* | cegcc*) case $cc_basename in cl*) _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] ;; esac ;; linux* | k*bsd*-gnu | gnu*) _LT_TAGVAR(link_all_deplibs, $1)=no ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac ], [ runpath_var= _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_cmds, $1)= _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(old_archive_from_new_cmds, $1)= _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= _LT_TAGVAR(thread_safe_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list _LT_TAGVAR(include_expsyms, $1)= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ' (' and ')$', so one must not match beginning or # end of line. Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc', # as well as any symbol that contains 'd'. _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. dnl Note also adjust exclude_expsyms for C++ above. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test yes != "$GCC"; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd* | bitrig*) with_gnu_ld=no ;; linux* | k*bsd*-gnu | gnu*) _LT_TAGVAR(link_all_deplibs, $1)=no ;; esac _LT_TAGVAR(ld_shlibs, $1)=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test yes = "$with_gnu_ld"; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test yes = "$lt_use_gnu_ld_interface"; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='$wl' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi supports_anon_versioning=no case `$LD -v | $SED -e 's/([^)]\+)\s\+//' 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[[3-9]]*) # On AIX/PPC, the GNU linker is very broken if test ia64 != "$host_cpu"; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file, use it as # is; otherwise, prepend EXPORTS... _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; os2*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported shrext_cmds=.dll _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ prefix_cmds="$SED"~ if test EXPORTS = "`$SED 1q $export_symbols`"; then prefix_cmds="$prefix_cmds -e 1d"; fi~ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test linux-dietlibc = "$host_os"; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test no = "$tmp_diet" then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 _LT_TAGVAR(whole_archive_flag_spec, $1)= tmp_sharedflag='--shared' ;; nagfor*) # NAGFOR 5.3 tmp_sharedflag='-Wl,-shared' ;; xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' if test yes = "$supports_anon_versioning"; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi case $cc_basename in tcc*) _LT_TAGVAR(export_dynamic_flag_spec, $1)='-rdynamic' ;; xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test yes = "$supports_anon_versioning"; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; sunos4*) _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac if test no = "$_LT_TAGVAR(ld_shlibs, $1)"; then runpath_var= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. _LT_TAGVAR(hardcode_minus_L, $1)=yes if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. _LT_TAGVAR(hardcode_direct, $1)=unsupported fi ;; aix[[4-9]]*) if test ia64 = "$host_cpu"; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag= else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to GNU nm, but means don't demangle to AIX nm. # Without the "-l" option, or with the "-B" option, AIX nm treats # weak defined symbols like other global defined symbols, whereas # GNU nm marks them as "W". # While the 'weak' keyword is ignored in the Export File, we need # it in the Import File for the 'aix-soname' feature, so we have # to replace the "-B" option with "-P" for AIX nm. if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # have runtime linking enabled, and use it for executables. # For shared libraries, we enable/disable runtime linking # depending on the kind of the shared library created - # when "with_aix_soname,aix_use_runtimelinking" is: # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables # "aix,yes" lib.so shared, rtl:yes, for executables # lib.a static archive # "both,no" lib.so.V(shr.o) shared, rtl:yes # lib.a(lib.so.V) shared, rtl:no, for executables # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a(lib.so.V) shared, rtl:no # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a static archive case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then aix_use_runtimelinking=yes break fi done if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then # With aix-soname=svr4, we create the lib.so.V shared archives only, # so we don't have lib.a shared libs to link our executables. # We have to force runtime linking in this case. aix_use_runtimelinking=yes LDFLAGS="$LDFLAGS -Wl,-brtl" fi ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='$wl-f,' case $with_aix_soname,$aix_use_runtimelinking in aix,*) ;; # traditional, no import file svr4,* | *,yes) # use import file # The Import File defines what to hardcode. _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no ;; esac if test yes = "$GCC"; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`$CC -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi ;; esac shared_flag='-shared' if test yes = "$aix_use_runtimelinking"; then shared_flag="$shared_flag "'$wl-G' fi # Need to ensure runtime linking is disabled for the traditional # shared library, or the linker may eventually find shared libraries # /with/ Import File - we do not want to mix them. shared_flag_aix='-shared' shared_flag_svr4='-shared $wl-G' else # not using gcc if test ia64 = "$host_cpu"; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test yes = "$aix_use_runtimelinking"; then shared_flag='$wl-G' else shared_flag='$wl-bM:SRE' fi shared_flag_aix='$wl-bM:SRE' shared_flag_svr4='$wl-G' fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. _LT_TAGVAR(always_export_symbols, $1)=yes if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag else if test ia64 = "$host_cpu"; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok' if test yes = "$with_gnu_ld"; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' # -brtl affects multiple linker settings, -berok does not and is overridden later compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`' if test svr4 != "$with_aix_soname"; then # This is similar to how AIX traditionally builds its shared libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' fi if test aix != "$with_aix_soname"; then _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' else # used by -dlpreopen to get the symbols _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV $output_objdir/$realname.d/$soname $output_objdir' fi _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; bsdi[[45]]*) _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then cp "$export_symbols" "$output_objdir/$soname.def"; echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; else $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile=$lt_outputfile.exe lt_tool_outputfile=$lt_tool_outputfile.exe ;; esac~ if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' # FIXME: Should let the user specify the lib program. _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; hpux9*) if test yes = "$GCC"; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' else _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' ;; hpux10*) if test yes,no = "$GCC,$with_gnu_ld"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test no = "$with_gnu_ld"; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes fi ;; hpux11*) if test yes,no = "$GCC,$with_gnu_ld"; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) m4_if($1, [], [ # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) _LT_LINKER_OPTION([if $CC understands -b], _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) ;; esac fi if test no = "$with_gnu_ld"; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test yes = "$GCC"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], [lt_cv_irix_exported_symbol], [save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null" AC_LINK_IFELSE( [AC_LANG_SOURCE( [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], [C++], [[int foo (void) { return 0; }]], [Fortran 77], [[ subroutine foo end]], [Fortran], [[ subroutine foo end]])])], [lt_cv_irix_exported_symbol=yes], [lt_cv_irix_exported_symbol=no]) LDFLAGS=$save_LDFLAGS]) if test yes = "$lt_cv_irix_exported_symbol"; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' fi _LT_TAGVAR(link_all_deplibs, $1)=no else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes _LT_TAGVAR(link_all_deplibs, $1)=yes ;; linux*) case $cc_basename in tcc*) # Fabrice Bellard et al's Tiny C Compiler _LT_TAGVAR(ld_shlibs, $1)=yes _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; newsos6) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *nto* | *qnx*) ;; openbsd* | bitrig*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' fi else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; os2*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported shrext_cmds=.dll _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ prefix_cmds="$SED"~ if test EXPORTS = "`$SED 1q $export_symbols`"; then prefix_cmds="$prefix_cmds -e 1d"; fi~ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; osf3*) if test yes = "$GCC"; then _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test yes = "$GCC"; then _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; solaris*) _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' if test yes = "$GCC"; then wlarc='$wl' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' _LT_TAGVAR(archive_cmds, $1)='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='$wl' _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands '-z linker_flag'. GCC discards it without '$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test yes = "$GCC"; then _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' else _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' fi ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes ;; sunos4*) if test sequent = "$host_vendor"; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4) case $host_vendor in sni) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' _LT_TAGVAR(hardcode_direct, $1)=no ;; motorola) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4.3*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes _LT_TAGVAR(ld_shlibs, $1)=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' if test yes = "$GCC"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We CANNOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport' runpath_var='LD_RUN_PATH' if test yes = "$GCC"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(ld_shlibs, $1)=no ;; esac if test sni = "$host_vendor"; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Blargedynsym' ;; esac fi fi ]) AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no _LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld _LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl _LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl _LT_DECL([], [extract_expsyms_cmds], [2], [The commands to extract the exported symbol list from a shared archive]) # # Do we need to explicitly link libc? # case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in x|xyes) # Assume -lc should be added _LT_TAGVAR(archive_cmds_need_lc, $1)=yes if test yes,yes = "$GCC,$enable_shared"; then case $_LT_TAGVAR(archive_cmds, $1) in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. AC_CACHE_CHECK([whether -lc should be explicitly linked in], [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), [$RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if AC_TRY_EVAL(ac_compile) 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) _LT_TAGVAR(allow_undefined_flag, $1)= if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) then lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no else lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes fi _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* ]) _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1) ;; esac fi ;; esac _LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], [Whether or not to add -lc for building shared libraries]) _LT_TAGDECL([allow_libtool_libs_with_static_runtimes], [enable_shared_with_static_runtimes], [0], [Whether or not to disallow shared libs when runtime libs are static]) _LT_TAGDECL([], [export_dynamic_flag_spec], [1], [Compiler flag to allow reflexive dlopens]) _LT_TAGDECL([], [whole_archive_flag_spec], [1], [Compiler flag to generate shared objects directly from archives]) _LT_TAGDECL([], [compiler_needs_object], [1], [Whether the compiler copes with passing no objects directly]) _LT_TAGDECL([], [old_archive_from_new_cmds], [2], [Create an old-style archive from a shared archive]) _LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], [Create a temporary old-style archive to link instead of a shared archive]) _LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) _LT_TAGDECL([], [archive_expsym_cmds], [2]) _LT_TAGDECL([], [module_cmds], [2], [Commands used to build a loadable module if different from building a shared archive.]) _LT_TAGDECL([], [module_expsym_cmds], [2]) _LT_TAGDECL([], [with_gnu_ld], [1], [Whether we are building with GNU ld or not]) _LT_TAGDECL([], [allow_undefined_flag], [1], [Flag that allows shared libraries with undefined symbols to be built]) _LT_TAGDECL([], [no_undefined_flag], [1], [Flag that enforces no undefined symbols]) _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], [Flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]) _LT_TAGDECL([], [hardcode_libdir_separator], [1], [Whether we need a single "-rpath" flag with a separated argument]) _LT_TAGDECL([], [hardcode_direct], [0], [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_direct_absolute], [0], [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes DIR into the resulting binary and the resulting library dependency is "absolute", i.e impossible to change by setting $shlibpath_var if the library is relocated]) _LT_TAGDECL([], [hardcode_minus_L], [0], [Set to "yes" if using the -LDIR flag during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_shlibpath_var], [0], [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_automatic], [0], [Set to "yes" if building a shared library automatically hardcodes DIR into the library and all subsequent libraries and executables linked against it]) _LT_TAGDECL([], [inherit_rpath], [0], [Set to yes if linker adds runtime paths of dependent libraries to runtime path list]) _LT_TAGDECL([], [link_all_deplibs], [0], [Whether libtool must link a program against all its dependency libraries]) _LT_TAGDECL([], [always_export_symbols], [0], [Set to "yes" if exported symbols are required]) _LT_TAGDECL([], [export_symbols_cmds], [2], [The commands to list exported symbols]) _LT_TAGDECL([], [exclude_expsyms], [1], [Symbols that should not be listed in the preloaded symbols]) _LT_TAGDECL([], [include_expsyms], [1], [Symbols that must always be exported]) _LT_TAGDECL([], [prelink_cmds], [2], [Commands necessary for linking programs (against libraries) with templates]) _LT_TAGDECL([], [postlink_cmds], [2], [Commands necessary for finishing linking programs]) _LT_TAGDECL([], [file_list_spec], [1], [Specify filename containing input files]) dnl FIXME: Not yet implemented dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], dnl [Compiler flag to generate thread safe objects]) ])# _LT_LINKER_SHLIBS # _LT_LANG_C_CONFIG([TAG]) # ------------------------ # Ensure that the configuration variables for a C compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to 'libtool'. m4_defun([_LT_LANG_C_CONFIG], [m4_require([_LT_DECL_EGREP])dnl lt_save_CC=$CC AC_LANG_PUSH(C) # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' _LT_TAG_COMPILER # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) LT_SYS_DLOPEN_SELF _LT_CMD_STRIPLIB # Report what library types will actually be built AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test no = "$can_build_shared" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test yes = "$enable_shared" && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test ia64 != "$host_cpu"; then case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in yes,aix,yes) ;; # shared object as lib.so file only yes,svr4,*) ;; # shared object as lib.so archive member only yes,*) enable_static=no ;; # shared object in lib.a archive as well esac fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test yes = "$enable_shared" || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_CONFIG($1) fi AC_LANG_POP CC=$lt_save_CC ])# _LT_LANG_C_CONFIG # _LT_LANG_CXX_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a C++ compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to 'libtool'. m4_defun([_LT_LANG_CXX_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl if test -n "$CXX" && ( test no != "$CXX" && ( (test g++ = "$CXX" && `g++ -v >/dev/null 2>&1` ) || (test g++ != "$CXX"))); then AC_PROG_CXXCPP else _lt_caught_CXX_error=yes fi AC_LANG_PUSH(C++) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the CXX compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test yes != "$_lt_caught_CXX_error"; then # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX lt_save_with_gnu_ld=$with_gnu_ld lt_save_path_LD=$lt_cv_path_LD if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx else $as_unset lt_cv_prog_gnu_ld fi if test -n "${lt_cv_path_LDCXX+set}"; then lt_cv_path_LD=$lt_cv_path_LDCXX else $as_unset lt_cv_path_LD fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} CFLAGS=$CXXFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then # We don't want -fno-exception when compiling C++ code, so set the # no_builtin_flag separately if test yes = "$GXX"; then _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' else _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= fi if test yes = "$GXX"; then # Set up default GNU C++ configuration LT_PATH_LD # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test yes = "$with_gnu_ld"; then _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) wlarc='$wl' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else with_gnu_ld=no wlarc= # A generic and very simple default shared library creation # command for GNU C++ for the case where it uses the native # linker, instead of GNU ld. If possible, this setting should # overridden to take advantage of the native linker features on # the platform it is being used on. _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' else GXX=no with_gnu_ld=no wlarc= fi # PORTME: fill in a description of your system's C++ link characteristics AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) _LT_TAGVAR(ld_shlibs, $1)=yes case $host_os in aix3*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aix[[4-9]]*) if test ia64 = "$host_cpu"; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag= else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # have runtime linking enabled, and use it for executables. # For shared libraries, we enable/disable runtime linking # depending on the kind of the shared library created - # when "with_aix_soname,aix_use_runtimelinking" is: # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables # "aix,yes" lib.so shared, rtl:yes, for executables # lib.a static archive # "both,no" lib.so.V(shr.o) shared, rtl:yes # lib.a(lib.so.V) shared, rtl:no, for executables # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a(lib.so.V) shared, rtl:no # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a static archive case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) aix_use_runtimelinking=yes break ;; esac done if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then # With aix-soname=svr4, we create the lib.so.V shared archives only, # so we don't have lib.a shared libs to link our executables. # We have to force runtime linking in this case. aix_use_runtimelinking=yes LDFLAGS="$LDFLAGS -Wl,-brtl" fi ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='$wl-f,' case $with_aix_soname,$aix_use_runtimelinking in aix,*) ;; # no import file svr4,* | *,yes) # use import file # The Import File defines what to hardcode. _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no ;; esac if test yes = "$GXX"; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`$CC -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi esac shared_flag='-shared' if test yes = "$aix_use_runtimelinking"; then shared_flag=$shared_flag' $wl-G' fi # Need to ensure runtime linking is disabled for the traditional # shared library, or the linker may eventually find shared libraries # /with/ Import File - we do not want to mix them. shared_flag_aix='-shared' shared_flag_svr4='-shared $wl-G' else # not using gcc if test ia64 = "$host_cpu"; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test yes = "$aix_use_runtimelinking"; then shared_flag='$wl-G' else shared_flag='$wl-bM:SRE' fi shared_flag_aix='$wl-bM:SRE' shared_flag_svr4='$wl-G' fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to # export. _LT_TAGVAR(always_export_symbols, $1)=yes if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. # The "-G" linker flag allows undefined symbols. _LT_TAGVAR(no_undefined_flag, $1)='-bernotok' # Determine the default libpath from the value encoded in an empty # executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag else if test ia64 = "$host_cpu"; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok' if test yes = "$with_gnu_ld"; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' # -brtl affects multiple linker settings, -berok does not and is overridden later compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`' if test svr4 != "$with_aix_soname"; then # This is similar to how AIX traditionally builds its shared # libraries. Need -bnortl late, we may have -brtl in LDFLAGS. _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' fi if test aix != "$with_aix_soname"; then _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' else # used by -dlpreopen to get the symbols _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV $output_objdir/$realname.d/$soname $output_objdir' fi _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d' fi fi ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; cygwin* | mingw* | pw32* | cegcc*) case $GXX,$cc_basename in ,cl* | no,cl*) # Native MSVC # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then cp "$export_symbols" "$output_objdir/$soname.def"; echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; else $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile=$lt_outputfile.exe lt_tool_outputfile=$lt_tool_outputfile.exe ;; esac~ func_to_tool_file "$lt_outputfile"~ if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # g++ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file, use it as # is; otherwise, prepend EXPORTS... _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; os2*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported shrext_cmds=.dll _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ prefix_cmds="$SED"~ if test EXPORTS = "`$SED 1q $export_symbols`"; then prefix_cmds="$prefix_cmds -e 1d"; fi~ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; freebsd2.*) # C++ shared libraries reported to be fairly broken before # switch to ELF _LT_TAGVAR(ld_shlibs, $1)=no ;; freebsd-elf*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; freebsd* | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions _LT_TAGVAR(ld_shlibs, $1)=yes ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; hpux9*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes = "$GXX"; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; hpux10*|hpux11*) if test no = "$with_gnu_ld"; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) ;; *) _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. ;; esac case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes = "$GXX"; then if test no = "$with_gnu_ld"; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test yes = "$GXX"; then if test no = "$with_gnu_ld"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` -o $lib' fi fi _LT_TAGVAR(link_all_deplibs, $1)=yes ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib $wl-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; icpc* | ecpc* ) # Intel C++ with_gnu_ld=yes # version 8.0 and above of icpc choke on multiply defined symbols # if we add $predep_objects and $postdep_objects, however 7.1 and # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; esac _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ $RANLIB $oldlib' _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 6 and above use weak symbols _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl--rpath $wl$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' ;; cxx*) # Compaq C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib $wl-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' ;; xl* | mpixl* | bgxl*) # IBM XL 8.0 on PPC, with GNU ld _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' if test yes = "$supports_anon_versioning"; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file $wl$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes # Not sure whether something based on # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 # would be better. output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; esac ;; esac ;; lynxos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; m88k*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no fi # Workaround some broken pre-1.5 toolchains output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' ;; *nto* | *qnx*) _LT_TAGVAR(ld_shlibs, $1)=yes ;; openbsd* | bitrig*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`"; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file,$export_symbols -o $lib' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' fi output_verbose_link_cmd=func_echo_all else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Archives containing C++ object files must be created using # the KAI C++ compiler. case $host in osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; esac ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; cxx*) case $host in osf3*) _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $soname `test -n "$verstring" && func_echo_all "$wl-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' ;; *) _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname $wl-input $wl$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~ $RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' ;; esac _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes,no = "$GXX,$with_gnu_ld"; then _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' case $host in osf3*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G$allow_undefined_flag $wl-M $wl$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands '-z linker_flag'. # Supported since Solaris 2.6 (maybe 2.5.1?) _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test yes,no = "$GXX,$with_gnu_ld"; then _LT_TAGVAR(no_undefined_flag, $1)=' $wl-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' else # g++ 2.7 appears to require '-G' NOT '-shared' on this # platform. _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $wl$libdir' case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' ;; esac fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We CANNOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ '"$_LT_TAGVAR(old_archive_cmds, $1)" _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ '"$_LT_TAGVAR(reload_cmds, $1)" ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no _LT_TAGVAR(GCC, $1)=$GXX _LT_TAGVAR(LD, $1)=$LD ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC with_gnu_ld=$lt_save_with_gnu_ld lt_cv_path_LDCXX=$lt_cv_path_LD lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld fi # test yes != "$_lt_caught_CXX_error" AC_LANG_POP ])# _LT_LANG_CXX_CONFIG # _LT_FUNC_STRIPNAME_CNF # ---------------------- # func_stripname_cnf prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # # This function is identical to the (non-XSI) version of func_stripname, # except this one can be used by m4 code that may be executed by configure, # rather than the libtool script. m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl AC_REQUIRE([_LT_DECL_SED]) AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) func_stripname_cnf () { case @S|@2 in .*) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%\\\\@S|@2\$%%"`;; *) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%@S|@2\$%%"`;; esac } # func_stripname_cnf ])# _LT_FUNC_STRIPNAME_CNF # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) # --------------------------------- # Figure out "hidden" library dependencies from verbose # compiler output when linking a shared library. # Parse the compiler output and extract the necessary # objects, libraries and library flags. m4_defun([_LT_SYS_HIDDEN_LIBDEPS], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl # Dependencies to place before and after the object being linked: _LT_TAGVAR(predep_objects, $1)= _LT_TAGVAR(postdep_objects, $1)= _LT_TAGVAR(predeps, $1)= _LT_TAGVAR(postdeps, $1)= _LT_TAGVAR(compiler_lib_search_path, $1)= dnl we can't use the lt_simple_compile_test_code here, dnl because it contains code intended for an executable, dnl not a library. It's possible we should let each dnl tag define a new lt_????_link_test_code variable, dnl but it's only used here... m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF int a; void foo (void) { a = 0; } _LT_EOF ], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF class Foo { public: Foo (void) { a = 0; } private: int a; }; _LT_EOF ], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer*4 a a=0 return end _LT_EOF ], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer a a=0 return end _LT_EOF ], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF public class foo { private int a; public void bar (void) { a = 0; } }; _LT_EOF ], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF package foo func foo() { } _LT_EOF ]) _lt_libdeps_save_CFLAGS=$CFLAGS case "$CC $CFLAGS " in #( *\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; *\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; *\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; esac dnl Parse the compiler output and extract the necessary dnl objects, libraries and library flags. if AC_TRY_EVAL(ac_compile); then # Parse the compiler output and extract the necessary # objects, libraries and library flags. # Sentinel used to keep track of whether or not we are before # the conftest object file. pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do case $prev$p in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test x-L = "$p" || test x-R = "$p"; then prev=$p continue fi # Expand the sysroot to ease extracting the directories later. if test -z "$prev"; then case $p in -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; esac fi case $p in =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; esac if test no = "$pre_test_object_deps_done"; then case $prev in -L | -R) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then _LT_TAGVAR(compiler_lib_search_path, $1)=$prev$p else _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} $prev$p" fi ;; # The "-l" case would never come before the object being # linked, so don't bother handling this case. esac else if test -z "$_LT_TAGVAR(postdeps, $1)"; then _LT_TAGVAR(postdeps, $1)=$prev$p else _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} $prev$p" fi fi prev= ;; *.lto.$objext) ;; # Ignore GCC LTO objects *.$objext) # This assumes that the test object file only shows up # once in the compiler output. if test "$p" = "conftest.$objext"; then pre_test_object_deps_done=yes continue fi if test no = "$pre_test_object_deps_done"; then if test -z "$_LT_TAGVAR(predep_objects, $1)"; then _LT_TAGVAR(predep_objects, $1)=$p else _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" fi else if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then _LT_TAGVAR(postdep_objects, $1)=$p else _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" fi fi ;; *) ;; # Ignore the rest. esac done # Clean up. rm -f a.out a.exe else echo "libtool.m4: error: problem compiling $1 test program" fi $RM -f confest.$objext CFLAGS=$_lt_libdeps_save_CFLAGS # PORTME: override above test on systems where it is broken m4_if([$1], [CXX], [case $host_os in interix[[3-9]]*) # Interix 3.5 installs completely hosed .la files for C++, so rather than # hack all around it, let's just trust "g++" to DTRT. _LT_TAGVAR(predep_objects,$1)= _LT_TAGVAR(postdep_objects,$1)= _LT_TAGVAR(postdeps,$1)= ;; esac ]) case " $_LT_TAGVAR(postdeps, $1) " in *" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; esac _LT_TAGVAR(compiler_lib_search_dirs, $1)= if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | $SED -e 's! -L! !g' -e 's!^ !!'` fi _LT_TAGDECL([], [compiler_lib_search_dirs], [1], [The directories searched by this compiler when creating a shared library]) _LT_TAGDECL([], [predep_objects], [1], [Dependencies to place before and after the objects being linked to create a shared library]) _LT_TAGDECL([], [postdep_objects], [1]) _LT_TAGDECL([], [predeps], [1]) _LT_TAGDECL([], [postdeps], [1]) _LT_TAGDECL([], [compiler_lib_search_path], [1], [The library search path used internally by the compiler when linking a shared library]) ])# _LT_SYS_HIDDEN_LIBDEPS # _LT_LANG_F77_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a Fortran 77 compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to 'libtool'. m4_defun([_LT_LANG_F77_CONFIG], [AC_LANG_PUSH(Fortran 77) if test -z "$F77" || test no = "$F77"; then _lt_disable_F77=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for f77 test sources. ac_ext=f # Object file extension for compiled f77 test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the F77 compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test yes != "$_lt_disable_F77"; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${F77-"f77"} CFLAGS=$FFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) GCC=$G77 if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test no = "$can_build_shared" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test yes = "$enable_shared" && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test ia64 != "$host_cpu"; then case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in yes,aix,yes) ;; # shared object as lib.so file only yes,svr4,*) ;; # shared object as lib.so archive member only yes,*) enable_static=no ;; # shared object in lib.a archive as well esac fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test yes = "$enable_shared" || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)=$G77 _LT_TAGVAR(LD, $1)=$LD ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS fi # test yes != "$_lt_disable_F77" AC_LANG_POP ])# _LT_LANG_F77_CONFIG # _LT_LANG_FC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for a Fortran compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to 'libtool'. m4_defun([_LT_LANG_FC_CONFIG], [AC_LANG_PUSH(Fortran) if test -z "$FC" || test no = "$FC"; then _lt_disable_FC=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for fc test sources. ac_ext=${ac_fc_srcext-f} # Object file extension for compiled fc test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the FC compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test yes != "$_lt_disable_FC"; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${FC-"f95"} CFLAGS=$FCFLAGS compiler=$CC GCC=$ac_cv_fc_compiler_gnu _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test no = "$can_build_shared" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test yes = "$enable_shared" && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test ia64 != "$host_cpu"; then case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in yes,aix,yes) ;; # shared object as lib.so file only yes,svr4,*) ;; # shared object as lib.so archive member only yes,*) enable_static=no ;; # shared object in lib.a archive as well esac fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test yes = "$enable_shared" || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)=$ac_cv_fc_compiler_gnu _LT_TAGVAR(LD, $1)=$LD ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS fi # test yes != "$_lt_disable_FC" AC_LANG_POP ])# _LT_LANG_FC_CONFIG # _LT_LANG_GCJ_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Java Compiler compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to 'libtool'. m4_defun([_LT_LANG_GCJ_CONFIG], [AC_REQUIRE([LT_PROG_GCJ])dnl AC_LANG_SAVE # Source file extension for Java test sources. ac_ext=java # Object file extension for compiled Java test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="class foo {}" # Code to be used in simple link tests lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GCJ-"gcj"} CFLAGS=$GCJFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)=$LD _LT_CC_BASENAME([$compiler]) # GCJ did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GCJ_CONFIG # _LT_LANG_GO_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Go compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to 'libtool'. m4_defun([_LT_LANG_GO_CONFIG], [AC_REQUIRE([LT_PROG_GO])dnl AC_LANG_SAVE # Source file extension for Go test sources. ac_ext=go # Object file extension for compiled Go test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="package main; func main() { }" # Code to be used in simple link tests lt_simple_link_test_code='package main; func main() { }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GOC-"gccgo"} CFLAGS=$GOFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)=$LD _LT_CC_BASENAME([$compiler]) # Go did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GO_CONFIG # _LT_LANG_RC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for the Windows resource compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to 'libtool'. m4_defun([_LT_LANG_RC_CONFIG], [AC_REQUIRE([LT_PROG_RC])dnl AC_LANG_SAVE # Source file extension for RC test sources. ac_ext=rc # Object file extension for compiled RC test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' # Code to be used in simple link tests lt_simple_link_test_code=$lt_simple_compile_test_code # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC= CC=${RC-"windres"} CFLAGS= compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes if test -n "$compiler"; then : _LT_CONFIG($1) fi GCC=$lt_save_GCC AC_LANG_RESTORE CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_RC_CONFIG # LT_PROG_GCJ # ----------- AC_DEFUN([LT_PROG_GCJ], [m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], [AC_CHECK_TOOL(GCJ, gcj,) test set = "${GCJFLAGS+set}" || GCJFLAGS="-g -O2" AC_SUBST(GCJFLAGS)])])[]dnl ]) # Old name: AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_GCJ], []) # LT_PROG_GO # ---------- AC_DEFUN([LT_PROG_GO], [AC_CHECK_TOOL(GOC, gccgo,) ]) # LT_PROG_RC # ---------- AC_DEFUN([LT_PROG_RC], [AC_CHECK_TOOL(RC, windres,) ]) # Old name: AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_RC], []) # _LT_DECL_EGREP # -------------- # If we don't have a new enough Autoconf to choose the best grep # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_EGREP], [AC_REQUIRE([AC_PROG_EGREP])dnl AC_REQUIRE([AC_PROG_FGREP])dnl test -z "$GREP" && GREP=grep _LT_DECL([], [GREP], [1], [A grep program that handles long lines]) _LT_DECL([], [EGREP], [1], [An ERE matcher]) _LT_DECL([], [FGREP], [1], [A literal string matcher]) dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too AC_SUBST([GREP]) ]) # _LT_DECL_OBJDUMP # -------------- # If we don't have a new enough Autoconf to choose the best objdump # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_OBJDUMP], [AC_CHECK_TOOL(OBJDUMP, objdump, false) test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) AC_SUBST([OBJDUMP]) ]) # _LT_DECL_DLLTOOL # ---------------- # Ensure DLLTOOL variable is set. m4_defun([_LT_DECL_DLLTOOL], [AC_CHECK_TOOL(DLLTOOL, dlltool, false) test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program]) AC_SUBST([DLLTOOL]) ]) # _LT_DECL_SED # ------------ # Check for a fully-functional sed program, that truncates # as few characters as possible. Prefer GNU sed if found. m4_defun([_LT_DECL_SED], [AC_PROG_SED test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" _LT_DECL([], [SED], [1], [A sed program that does not truncate output]) _LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], [Sed that helps us avoid accidentally triggering echo(1) options like -n]) ])# _LT_DECL_SED m4_ifndef([AC_PROG_SED], [ ############################################################ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_SED. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # ############################################################ m4_defun([AC_PROG_SED], [AC_MSG_CHECKING([for a sed that does not truncate output]) AC_CACHE_VAL(lt_cv_path_SED, [# Loop through the user's path and test for sed and gsed. # Then use that list of sed's as ones to test for truncation. as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for lt_ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" fi done done done IFS=$as_save_IFS lt_ac_max=0 lt_ac_count=0 # Add /usr/xpg4/bin/sed as it is typically found on Solaris # along with /bin/sed that truncates output. for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do test ! -f "$lt_ac_sed" && continue cat /dev/null > conftest.in lt_ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >conftest.in # Check for GNU sed and select it if it is found. if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then lt_cv_path_SED=$lt_ac_sed break fi while true; do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo >>conftest.nl $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break cmp -s conftest.out conftest.nl || break # 10000 chars as input seems more than enough test 10 -lt "$lt_ac_count" && break lt_ac_count=`expr $lt_ac_count + 1` if test "$lt_ac_count" -gt "$lt_ac_max"; then lt_ac_max=$lt_ac_count lt_cv_path_SED=$lt_ac_sed fi done done ]) SED=$lt_cv_path_SED AC_SUBST([SED]) AC_MSG_RESULT([$SED]) ])#AC_PROG_SED ])#m4_ifndef # Old name: AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_SED], []) # _LT_CHECK_SHELL_FEATURES # ------------------------ # Find out whether the shell is Bourne or XSI compatible, # or has some other useful features. m4_defun([_LT_CHECK_SHELL_FEATURES], [if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi _LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac _LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl ])# _LT_CHECK_SHELL_FEATURES # _LT_PATH_CONVERSION_FUNCTIONS # ----------------------------- # Determine what file name conversion functions should be used by # func_to_host_file (and, implicitly, by func_to_host_path). These are needed # for certain cross-compile configurations and native mingw. m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_MSG_CHECKING([how to convert $build file names to $host format]) AC_CACHE_VAL(lt_cv_to_host_file_cmd, [case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac ]) to_host_file_cmd=$lt_cv_to_host_file_cmd AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) _LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], [0], [convert $build file names to $host format])dnl AC_MSG_CHECKING([how to convert $build file names to toolchain format]) AC_CACHE_VAL(lt_cv_to_tool_file_cmd, [#assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac ]) to_tool_file_cmd=$lt_cv_to_tool_file_cmd AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) _LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], [0], [convert $build files to toolchain format])dnl ])# _LT_PATH_CONVERSION_FUNCTIONS assaultcube-1.2.0.2.1/source/enet/m4/ltoptions.m4000066400000000000000000000342621352165075300214120ustar00rootroot00000000000000# Helper functions for option handling. -*- Autoconf -*- # # Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software # Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 8 ltoptions.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) # _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) # ------------------------------------------ m4_define([_LT_MANGLE_OPTION], [[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) # _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) # --------------------------------------- # Set option OPTION-NAME for macro MACRO-NAME, and if there is a # matching handler defined, dispatch to it. Other OPTION-NAMEs are # saved as a flag. m4_define([_LT_SET_OPTION], [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), _LT_MANGLE_DEFUN([$1], [$2]), [m4_warning([Unknown $1 option '$2'])])[]dnl ]) # _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) # ------------------------------------------------------------ # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. m4_define([_LT_IF_OPTION], [m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) # _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) # ------------------------------------------------------- # Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME # are set. m4_define([_LT_UNLESS_OPTIONS], [m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), [m4_define([$0_found])])])[]dnl m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 ])[]dnl ]) # _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) # ---------------------------------------- # OPTION-LIST is a space-separated list of Libtool options associated # with MACRO-NAME. If any OPTION has a matching handler declared with # LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about # the unknown option and exit. m4_defun([_LT_SET_OPTIONS], [# Set options m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [_LT_SET_OPTION([$1], _LT_Option)]) m4_if([$1],[LT_INIT],[ dnl dnl Simply set some default values (i.e off) if boolean options were not dnl specified: _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no ]) _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no ]) dnl dnl If no reference was made to various pairs of opposing options, then dnl we run the default mode handler for the pair. For example, if neither dnl 'shared' nor 'disable-shared' was passed, we enable building of shared dnl archives by default: _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], [_LT_ENABLE_FAST_INSTALL]) _LT_UNLESS_OPTIONS([LT_INIT], [aix-soname=aix aix-soname=both aix-soname=svr4], [_LT_WITH_AIX_SONAME([aix])]) ]) ])# _LT_SET_OPTIONS ## --------------------------------- ## ## Macros to handle LT_INIT options. ## ## --------------------------------- ## # _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) # ----------------------------------------- m4_define([_LT_MANGLE_DEFUN], [[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) # LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) # ----------------------------------------------- m4_define([LT_OPTION_DEFINE], [m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl ])# LT_OPTION_DEFINE # dlopen # ------ LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes ]) AU_DEFUN([AC_LIBTOOL_DLOPEN], [_LT_SET_OPTION([LT_INIT], [dlopen]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the 'dlopen' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) # win32-dll # --------- # Declare package support for building win32 dll's. LT_OPTION_DEFINE([LT_INIT], [win32-dll], [enable_win32_dll=yes case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) AC_CHECK_TOOL(AS, as, false) AC_CHECK_TOOL(DLLTOOL, dlltool, false) AC_CHECK_TOOL(OBJDUMP, objdump, false) ;; esac test -z "$AS" && AS=as _LT_DECL([], [AS], [1], [Assembler program])dnl test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl ])# win32-dll AU_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_REQUIRE([AC_CANONICAL_HOST])dnl _LT_SET_OPTION([LT_INIT], [win32-dll]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the 'win32-dll' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) # _LT_ENABLE_SHARED([DEFAULT]) # ---------------------------- # implement the --enable-shared flag, and supports the 'shared' and # 'disable-shared' LT_INIT options. # DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. m4_define([_LT_ENABLE_SHARED], [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([shared], [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS=$lt_save_ifs ;; esac], [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) _LT_DECL([build_libtool_libs], [enable_shared], [0], [Whether or not to build shared libraries]) ])# _LT_ENABLE_SHARED LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) # Old names: AC_DEFUN([AC_ENABLE_SHARED], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) ]) AC_DEFUN([AC_DISABLE_SHARED], [_LT_SET_OPTION([LT_INIT], [disable-shared]) ]) AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_SHARED], []) dnl AC_DEFUN([AM_DISABLE_SHARED], []) # _LT_ENABLE_STATIC([DEFAULT]) # ---------------------------- # implement the --enable-static flag, and support the 'static' and # 'disable-static' LT_INIT options. # DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. m4_define([_LT_ENABLE_STATIC], [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([static], [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS=$lt_save_ifs ;; esac], [enable_static=]_LT_ENABLE_STATIC_DEFAULT) _LT_DECL([build_old_libs], [enable_static], [0], [Whether or not to build static libraries]) ])# _LT_ENABLE_STATIC LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) # Old names: AC_DEFUN([AC_ENABLE_STATIC], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) ]) AC_DEFUN([AC_DISABLE_STATIC], [_LT_SET_OPTION([LT_INIT], [disable-static]) ]) AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_STATIC], []) dnl AC_DEFUN([AM_DISABLE_STATIC], []) # _LT_ENABLE_FAST_INSTALL([DEFAULT]) # ---------------------------------- # implement the --enable-fast-install flag, and support the 'fast-install' # and 'disable-fast-install' LT_INIT options. # DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. m4_define([_LT_ENABLE_FAST_INSTALL], [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([fast-install], [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS=$lt_save_ifs ;; esac], [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) _LT_DECL([fast_install], [enable_fast_install], [0], [Whether or not to optimize for fast installation])dnl ])# _LT_ENABLE_FAST_INSTALL LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) # Old names: AU_DEFUN([AC_ENABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the 'fast-install' option into LT_INIT's first parameter.]) ]) AU_DEFUN([AC_DISABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], [disable-fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the 'disable-fast-install' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) # _LT_WITH_AIX_SONAME([DEFAULT]) # ---------------------------------- # implement the --with-aix-soname flag, and support the `aix-soname=aix' # and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT # is either `aix', `both' or `svr4'. If omitted, it defaults to `aix'. m4_define([_LT_WITH_AIX_SONAME], [m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl shared_archive_member_spec= case $host,$enable_shared in power*-*-aix[[5-9]]*,yes) AC_MSG_CHECKING([which variant of shared library versioning to provide]) AC_ARG_WITH([aix-soname], [AS_HELP_STRING([--with-aix-soname=aix|svr4|both], [shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])], [case $withval in aix|svr4|both) ;; *) AC_MSG_ERROR([Unknown argument to --with-aix-soname]) ;; esac lt_cv_with_aix_soname=$with_aix_soname], [AC_CACHE_VAL([lt_cv_with_aix_soname], [lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT) with_aix_soname=$lt_cv_with_aix_soname]) AC_MSG_RESULT([$with_aix_soname]) if test aix != "$with_aix_soname"; then # For the AIX way of multilib, we name the shared archive member # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o', # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File. # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag, # the AIX toolchain works better with OBJECT_MODE set (default 32). if test 64 = "${OBJECT_MODE-32}"; then shared_archive_member_spec=shr_64 else shared_archive_member_spec=shr fi fi ;; *) with_aix_soname=aix ;; esac _LT_DECL([], [shared_archive_member_spec], [0], [Shared archive member basename, for filename based shared library versioning on AIX])dnl ])# _LT_WITH_AIX_SONAME LT_OPTION_DEFINE([LT_INIT], [aix-soname=aix], [_LT_WITH_AIX_SONAME([aix])]) LT_OPTION_DEFINE([LT_INIT], [aix-soname=both], [_LT_WITH_AIX_SONAME([both])]) LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])]) # _LT_WITH_PIC([MODE]) # -------------------- # implement the --with-pic flag, and support the 'pic-only' and 'no-pic' # LT_INIT options. # MODE is either 'yes' or 'no'. If omitted, it defaults to 'both'. m4_define([_LT_WITH_PIC], [AC_ARG_WITH([pic], [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], [lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for lt_pkg in $withval; do IFS=$lt_save_ifs if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS=$lt_save_ifs ;; esac], [pic_mode=m4_default([$1], [default])]) _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl ])# _LT_WITH_PIC LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) # Old name: AU_DEFUN([AC_LIBTOOL_PICMODE], [_LT_SET_OPTION([LT_INIT], [pic-only]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the 'pic-only' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) ## ----------------- ## ## LTDL_INIT Options ## ## ----------------- ## m4_define([_LTDL_MODE], []) LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], [m4_define([_LTDL_MODE], [nonrecursive])]) LT_OPTION_DEFINE([LTDL_INIT], [recursive], [m4_define([_LTDL_MODE], [recursive])]) LT_OPTION_DEFINE([LTDL_INIT], [subproject], [m4_define([_LTDL_MODE], [subproject])]) m4_define([_LTDL_TYPE], []) LT_OPTION_DEFINE([LTDL_INIT], [installable], [m4_define([_LTDL_TYPE], [installable])]) LT_OPTION_DEFINE([LTDL_INIT], [convenience], [m4_define([_LTDL_TYPE], [convenience])]) assaultcube-1.2.0.2.1/source/enet/m4/ltsugar.m4000066400000000000000000000104401352165075300210300ustar00rootroot00000000000000# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- # # Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software # Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 6 ltsugar.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) # lt_join(SEP, ARG1, [ARG2...]) # ----------------------------- # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their # associated separator. # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier # versions in m4sugar had bugs. m4_define([lt_join], [m4_if([$#], [1], [], [$#], [2], [[$2]], [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) m4_define([_lt_join], [m4_if([$#$2], [2], [], [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) # lt_car(LIST) # lt_cdr(LIST) # ------------ # Manipulate m4 lists. # These macros are necessary as long as will still need to support # Autoconf-2.59, which quotes differently. m4_define([lt_car], [[$1]]) m4_define([lt_cdr], [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], [$#], 1, [], [m4_dquote(m4_shift($@))])]) m4_define([lt_unquote], $1) # lt_append(MACRO-NAME, STRING, [SEPARATOR]) # ------------------------------------------ # Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'. # Note that neither SEPARATOR nor STRING are expanded; they are appended # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). # No SEPARATOR is output if MACRO-NAME was previously undefined (different # than defined and empty). # # This macro is needed until we can rely on Autoconf 2.62, since earlier # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. m4_define([lt_append], [m4_define([$1], m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) # ---------------------------------------------------------- # Produce a SEP delimited list of all paired combinations of elements of # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list # has the form PREFIXmINFIXSUFFIXn. # Needed until we can rely on m4_combine added in Autoconf 2.62. m4_define([lt_combine], [m4_if(m4_eval([$# > 3]), [1], [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl [[m4_foreach([_Lt_prefix], [$2], [m4_foreach([_Lt_suffix], ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) # ----------------------------------------------------------------------- # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. m4_define([lt_if_append_uniq], [m4_ifdef([$1], [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], [lt_append([$1], [$2], [$3])$4], [$5])], [lt_append([$1], [$2], [$3])$4])]) # lt_dict_add(DICT, KEY, VALUE) # ----------------------------- m4_define([lt_dict_add], [m4_define([$1($2)], [$3])]) # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) # -------------------------------------------- m4_define([lt_dict_add_subkey], [m4_define([$1($2:$3)], [$4])]) # lt_dict_fetch(DICT, KEY, [SUBKEY]) # ---------------------------------- m4_define([lt_dict_fetch], [m4_ifval([$3], m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) # ----------------------------------------------------------------- m4_define([lt_if_dict_fetch], [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], [$5], [$6])]) # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) # -------------------------------------------------------------- m4_define([lt_dict_filter], [m4_if([$5], [], [], [lt_join(m4_quote(m4_default([$4], [[, ]])), lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl ]) assaultcube-1.2.0.2.1/source/enet/m4/ltversion.m4000066400000000000000000000012731352165075300214000ustar00rootroot00000000000000# ltversion.m4 -- version numbers -*- Autoconf -*- # # Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # @configure_input@ # serial 4179 ltversion.m4 # This file is part of GNU Libtool m4_define([LT_PACKAGE_VERSION], [2.4.6]) m4_define([LT_PACKAGE_REVISION], [2.4.6]) AC_DEFUN([LTVERSION_VERSION], [macro_version='2.4.6' macro_revision='2.4.6' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) assaultcube-1.2.0.2.1/source/enet/m4/lt~obsolete.m4000066400000000000000000000137741352165075300217360ustar00rootroot00000000000000# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- # # Copyright (C) 2004-2005, 2007, 2009, 2011-2015 Free Software # Foundation, Inc. # Written by Scott James Remnant, 2004. # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 5 lt~obsolete.m4 # These exist entirely to fool aclocal when bootstrapping libtool. # # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN), # which have later been changed to m4_define as they aren't part of the # exported API, or moved to Autoconf or Automake where they belong. # # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us # using a macro with the same name in our local m4/libtool.m4 it'll # pull the old libtool.m4 in (it doesn't see our shiny new m4_define # and doesn't know about Autoconf macros at all.) # # So we provide this file, which has a silly filename so it's always # included after everything else. This provides aclocal with the # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything # because those macros already exist, or will be overwritten later. # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. # # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. # Yes, that means every name once taken will need to remain here until # we give up compatibility with versions before 1.7, at which point # we need to keep only those names which we still refer to. # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) assaultcube-1.2.0.2.1/source/enet/missing000077500000000000000000000153361352165075300201750ustar00rootroot00000000000000#! /bin/sh # Common wrapper for a few potentially missing GNU programs. scriptversion=2018-03-07.03; # UTC # Copyright (C) 1996-2018 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try '$0 --help' for more information" exit 1 fi case $1 in --is-lightweight) # Used by our autoconf macros to check whether the available missing # script is modern enough. exit 0 ;; --run) # Back-compat with the calling convention used by older automake. shift ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due to PROGRAM being missing or too old. Options: -h, --help display this help and exit -v, --version output version information and exit Supported PROGRAM values: aclocal autoconf autoheader autom4te automake makeinfo bison yacc flex lex help2man Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 'g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: unknown '$1' option" echo 1>&2 "Try '$0 --help' for more information" exit 1 ;; esac # Run the given program, remember its exit status. "$@"; st=$? # If it succeeded, we are done. test $st -eq 0 && exit 0 # Also exit now if we it failed (or wasn't found), and '--version' was # passed; such an option is passed most likely to detect whether the # program is present and works. case $2 in --version|--help) exit $st;; esac # Exit code 63 means version mismatch. This often happens when the user # tries to use an ancient version of a tool on a file that requires a # minimum version. if test $st -eq 63; then msg="probably too old" elif test $st -eq 127; then # Program was missing. msg="missing on your system" else # Program was found and executed, but failed. Give up. exit $st fi perl_URL=https://www.perl.org/ flex_URL=https://github.com/westes/flex gnu_software_URL=https://www.gnu.org/software program_details () { case $1 in aclocal|automake) echo "The '$1' program is part of the GNU Automake package:" echo "<$gnu_software_URL/automake>" echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/autoconf>" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; autoconf|autom4te|autoheader) echo "The '$1' program is part of the GNU Autoconf package:" echo "<$gnu_software_URL/autoconf/>" echo "It also requires GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; esac } give_advice () { # Normalize program name to check for. normalized_program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` printf '%s\n' "'$1' is $msg." configure_deps="'configure.ac' or m4 files included by 'configure.ac'" case $normalized_program in autoconf*) echo "You should only need it if you modified 'configure.ac'," echo "or m4 files included by it." program_details 'autoconf' ;; autoheader*) echo "You should only need it if you modified 'acconfig.h' or" echo "$configure_deps." program_details 'autoheader' ;; automake*) echo "You should only need it if you modified 'Makefile.am' or" echo "$configure_deps." program_details 'automake' ;; aclocal*) echo "You should only need it if you modified 'acinclude.m4' or" echo "$configure_deps." program_details 'aclocal' ;; autom4te*) echo "You might have modified some maintainer files that require" echo "the 'autom4te' program to be rebuilt." program_details 'autom4te' ;; bison*|yacc*) echo "You should only need it if you modified a '.y' file." echo "You may want to install the GNU Bison package:" echo "<$gnu_software_URL/bison/>" ;; lex*|flex*) echo "You should only need it if you modified a '.l' file." echo "You may want to install the Fast Lexical Analyzer package:" echo "<$flex_URL>" ;; help2man*) echo "You should only need it if you modified a dependency" \ "of a man page." echo "You may want to install the GNU Help2man package:" echo "<$gnu_software_URL/help2man/>" ;; makeinfo*) echo "You should only need it if you modified a '.texi' file, or" echo "any other file indirectly affecting the aspect of the manual." echo "You might want to install the Texinfo package:" echo "<$gnu_software_URL/texinfo/>" echo "The spurious makeinfo call might also be the consequence of" echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" echo "want to install GNU make:" echo "<$gnu_software_URL/make/>" ;; *) echo "You might have modified some files without having the proper" echo "tools for further handling them. Check the 'README' file, it" echo "often tells you about the needed prerequisites for installing" echo "this package. You may also peek at any GNU archive site, in" echo "case some other package contains this missing '$1' program." ;; esac } give_advice "$1" | sed -e '1s/^/WARNING: /' \ -e '2,$s/^/ /' >&2 # Propagate the correct exit status (expected to be 127 for a program # not found, 63 for a program that failed due to version mismatch). exit $st # Local variables: # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: assaultcube-1.2.0.2.1/source/enet/packet.c000066400000000000000000000076571352165075300202200ustar00rootroot00000000000000/** @file packet.c @brief ENet packet management functions */ #include #define ENET_BUILDING_LIB 1 #include "enet/enet.h" /** @defgroup Packet ENet packet functions @{ */ /** Creates a packet that may be sent to a peer. @param dataContents initial contents of the packet's data; the packet's data will remain uninitialized if dataContents is NULL. @param dataLength size of the data allocated for this packet @param flags flags for this packet as described for the ENetPacket structure. @returns the packet on success, NULL on failure */ ENetPacket * enet_packet_create (const void * data, size_t dataLength, enet_uint32 flags) { ENetPacket * packet = (ENetPacket *) enet_malloc (sizeof (ENetPacket)); if (packet == NULL) return NULL; if (flags & ENET_PACKET_FLAG_NO_ALLOCATE) packet -> data = (enet_uint8 *) data; else if (dataLength <= 0) packet -> data = NULL; else { packet -> data = (enet_uint8 *) enet_malloc (dataLength); if (packet -> data == NULL) { enet_free (packet); return NULL; } if (data != NULL) memcpy (packet -> data, data, dataLength); } packet -> referenceCount = 0; packet -> flags = flags; packet -> dataLength = dataLength; packet -> freeCallback = NULL; return packet; } /** Destroys the packet and deallocates its data. @param packet packet to be destroyed */ void enet_packet_destroy (ENetPacket * packet) { if (packet == NULL) return; if (packet -> freeCallback != NULL) (* packet -> freeCallback) (packet); if (! (packet -> flags & ENET_PACKET_FLAG_NO_ALLOCATE) && packet -> data != NULL) enet_free (packet -> data); enet_free (packet); } /** Attempts to resize the data in the packet to length specified in the dataLength parameter @param packet packet to resize @param dataLength new size for the packet data @returns 0 on success, < 0 on failure */ int enet_packet_resize (ENetPacket * packet, size_t dataLength) { enet_uint8 * newData; if (dataLength <= packet -> dataLength || (packet -> flags & ENET_PACKET_FLAG_NO_ALLOCATE)) { packet -> dataLength = dataLength; return 0; } newData = (enet_uint8 *) enet_malloc (dataLength); if (newData == NULL) return -1; memcpy (newData, packet -> data, packet -> dataLength); enet_free (packet -> data); packet -> data = newData; packet -> dataLength = dataLength; return 0; } static int initializedCRC32 = 0; static enet_uint32 crcTable [256]; static enet_uint32 reflect_crc (int val, int bits) { int result = 0, bit; for (bit = 0; bit < bits; bit ++) { if(val & 1) result |= 1 << (bits - 1 - bit); val >>= 1; } return result; } static void initialize_crc32 () { int byte; for (byte = 0; byte < 256; ++ byte) { enet_uint32 crc = reflect_crc (byte, 8) << 24; int offset; for(offset = 0; offset < 8; ++ offset) { if (crc & 0x80000000) crc = (crc << 1) ^ 0x04c11db7; else crc <<= 1; } crcTable [byte] = reflect_crc (crc, 32); } initializedCRC32 = 1; } enet_uint32 enet_crc32 (const ENetBuffer * buffers, size_t bufferCount) { enet_uint32 crc = 0xFFFFFFFF; if (! initializedCRC32) initialize_crc32 (); while (bufferCount -- > 0) { const enet_uint8 * data = (const enet_uint8 *) buffers -> data, * dataEnd = & data [buffers -> dataLength]; while (data < dataEnd) { crc = (crc >> 8) ^ crcTable [(crc & 0xFF) ^ *data++]; } ++ buffers; } return ENET_HOST_TO_NET_32 (~ crc); } void enet_crc32_inc (enet_uint32 *crc, enet_uint8 byte) { if (! initializedCRC32) initialize_crc32 (); *crc = (*crc >> 8) ^ crcTable [(*crc & 0xFF) ^ byte]; } /** @} */ assaultcube-1.2.0.2.1/source/enet/peer.c000066400000000000000000001072561352165075300177000ustar00rootroot00000000000000/** @file peer.c @brief ENet peer management functions */ #include #define ENET_BUILDING_LIB 1 #include "enet/enet.h" /** @defgroup peer ENet peer functions @{ */ /** Configures throttle parameter for a peer. Unreliable packets are dropped by ENet in response to the varying conditions of the Internet connection to the peer. The throttle represents a probability that an unreliable packet should not be dropped and thus sent by ENet to the peer. The lowest mean round trip time from the sending of a reliable packet to the receipt of its acknowledgement is measured over an amount of time specified by the interval parameter in milliseconds. If a measured round trip time happens to be significantly less than the mean round trip time measured over the interval, then the throttle probability is increased to allow more traffic by an amount specified in the acceleration parameter, which is a ratio to the ENET_PEER_PACKET_THROTTLE_SCALE constant. If a measured round trip time happens to be significantly greater than the mean round trip time measured over the interval, then the throttle probability is decreased to limit traffic by an amount specified in the deceleration parameter, which is a ratio to the ENET_PEER_PACKET_THROTTLE_SCALE constant. When the throttle has a value of ENET_PEER_PACKET_THROTTLE_SCALE, no unreliable packets are dropped by ENet, and so 100% of all unreliable packets will be sent. When the throttle has a value of 0, all unreliable packets are dropped by ENet, and so 0% of all unreliable packets will be sent. Intermediate values for the throttle represent intermediate probabilities between 0% and 100% of unreliable packets being sent. The bandwidth limits of the local and foreign hosts are taken into account to determine a sensible limit for the throttle probability above which it should not raise even in the best of conditions. @param peer peer to configure @param interval interval, in milliseconds, over which to measure lowest mean RTT; the default value is ENET_PEER_PACKET_THROTTLE_INTERVAL. @param acceleration rate at which to increase the throttle probability as mean RTT declines @param deceleration rate at which to decrease the throttle probability as mean RTT increases */ void enet_peer_throttle_configure (ENetPeer * peer, enet_uint32 interval, enet_uint32 acceleration, enet_uint32 deceleration) { ENetProtocol command; peer -> packetThrottleInterval = interval; peer -> packetThrottleAcceleration = acceleration; peer -> packetThrottleDeceleration = deceleration; command.header.command = ENET_PROTOCOL_COMMAND_THROTTLE_CONFIGURE | ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE; command.header.channelID = 0xFF; command.throttleConfigure.packetThrottleInterval = ENET_HOST_TO_NET_32 (interval); command.throttleConfigure.packetThrottleAcceleration = ENET_HOST_TO_NET_32 (acceleration); command.throttleConfigure.packetThrottleDeceleration = ENET_HOST_TO_NET_32 (deceleration); enet_peer_queue_outgoing_command (peer, & command, NULL, 0, 0); } int enet_peer_throttle (ENetPeer * peer, enet_uint32 rtt) { if (peer -> lastRoundTripTime <= peer -> lastRoundTripTimeVariance) { peer -> packetThrottle = peer -> packetThrottleLimit; } else if (rtt < peer -> lastRoundTripTime) { peer -> packetThrottle += peer -> packetThrottleAcceleration; if (peer -> packetThrottle > peer -> packetThrottleLimit) peer -> packetThrottle = peer -> packetThrottleLimit; return 1; } else if (rtt > peer -> lastRoundTripTime + 2 * peer -> lastRoundTripTimeVariance) { if (peer -> packetThrottle > peer -> packetThrottleDeceleration) peer -> packetThrottle -= peer -> packetThrottleDeceleration; else peer -> packetThrottle = 0; return -1; } return 0; } /** Queues a packet to be sent. @param peer destination for the packet @param channelID channel on which to send @param packet packet to send @retval 0 on success @retval < 0 on failure */ int enet_peer_send (ENetPeer * peer, enet_uint8 channelID, ENetPacket * packet) { ENetChannel * channel = & peer -> channels [channelID]; ENetProtocol command; size_t fragmentLength; if (peer -> state != ENET_PEER_STATE_CONNECTED || channelID >= peer -> channelCount || packet -> dataLength > ENET_PROTOCOL_MAXIMUM_PACKET_SIZE) return -1; fragmentLength = peer -> mtu - sizeof (ENetProtocolHeader) - sizeof (ENetProtocolSendFragment); if (peer -> host -> checksum != NULL) fragmentLength -= sizeof(enet_uint32); if (packet -> dataLength > fragmentLength) { enet_uint32 fragmentCount = (packet -> dataLength + fragmentLength - 1) / fragmentLength, fragmentNumber, fragmentOffset; enet_uint8 commandNumber; enet_uint16 startSequenceNumber; ENetList fragments; ENetOutgoingCommand * fragment; if (fragmentCount > ENET_PROTOCOL_MAXIMUM_FRAGMENT_COUNT) return -1; if ((packet -> flags & (ENET_PACKET_FLAG_RELIABLE | ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT)) == ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT && channel -> outgoingUnreliableSequenceNumber < 0xFFFF) { commandNumber = ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE_FRAGMENT; startSequenceNumber = ENET_HOST_TO_NET_16 (channel -> outgoingUnreliableSequenceNumber + 1); } else { commandNumber = ENET_PROTOCOL_COMMAND_SEND_FRAGMENT | ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE; startSequenceNumber = ENET_HOST_TO_NET_16 (channel -> outgoingReliableSequenceNumber + 1); } enet_list_clear (& fragments); for (fragmentNumber = 0, fragmentOffset = 0; fragmentOffset < packet -> dataLength; ++ fragmentNumber, fragmentOffset += fragmentLength) { if (packet -> dataLength - fragmentOffset < fragmentLength) fragmentLength = packet -> dataLength - fragmentOffset; fragment = (ENetOutgoingCommand *) enet_malloc (sizeof (ENetOutgoingCommand)); if (fragment == NULL) { while (! enet_list_empty (& fragments)) { fragment = (ENetOutgoingCommand *) enet_list_remove (enet_list_begin (& fragments)); enet_free (fragment); } return -1; } fragment -> fragmentOffset = fragmentOffset; fragment -> fragmentLength = fragmentLength; fragment -> packet = packet; fragment -> command.header.command = commandNumber; fragment -> command.header.channelID = channelID; fragment -> command.sendFragment.startSequenceNumber = startSequenceNumber; fragment -> command.sendFragment.dataLength = ENET_HOST_TO_NET_16 (fragmentLength); fragment -> command.sendFragment.fragmentCount = ENET_HOST_TO_NET_32 (fragmentCount); fragment -> command.sendFragment.fragmentNumber = ENET_HOST_TO_NET_32 (fragmentNumber); fragment -> command.sendFragment.totalLength = ENET_HOST_TO_NET_32 (packet -> dataLength); fragment -> command.sendFragment.fragmentOffset = ENET_NET_TO_HOST_32 (fragmentOffset); enet_list_insert (enet_list_end (& fragments), fragment); } packet -> referenceCount += fragmentNumber; while (! enet_list_empty (& fragments)) { fragment = (ENetOutgoingCommand *) enet_list_remove (enet_list_begin (& fragments)); enet_peer_setup_outgoing_command (peer, fragment); } return 0; } command.header.channelID = channelID; if ((packet -> flags & (ENET_PACKET_FLAG_RELIABLE | ENET_PACKET_FLAG_UNSEQUENCED)) == ENET_PACKET_FLAG_UNSEQUENCED) { command.header.command = ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED | ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED; command.sendUnsequenced.dataLength = ENET_HOST_TO_NET_16 (packet -> dataLength); } else if (packet -> flags & ENET_PACKET_FLAG_RELIABLE || channel -> outgoingUnreliableSequenceNumber >= 0xFFFF) { command.header.command = ENET_PROTOCOL_COMMAND_SEND_RELIABLE | ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE; command.sendReliable.dataLength = ENET_HOST_TO_NET_16 (packet -> dataLength); } else { command.header.command = ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE; command.sendUnreliable.dataLength = ENET_HOST_TO_NET_16 (packet -> dataLength); } if (enet_peer_queue_outgoing_command (peer, & command, packet, 0, packet -> dataLength) == NULL) return -1; return 0; } /** Attempts to dequeue any incoming queued packet. @param peer peer to dequeue packets from @param channelID holds the channel ID of the channel the packet was received on success @returns a pointer to the packet, or NULL if there are no available incoming queued packets */ ENetPacket * enet_peer_receive (ENetPeer * peer, enet_uint8 * channelID) { ENetIncomingCommand * incomingCommand; ENetPacket * packet; if (enet_list_empty (& peer -> dispatchedCommands)) return NULL; incomingCommand = (ENetIncomingCommand *) enet_list_remove (enet_list_begin (& peer -> dispatchedCommands)); if (channelID != NULL) * channelID = incomingCommand -> command.header.channelID; packet = incomingCommand -> packet; -- packet -> referenceCount; if (incomingCommand -> fragments != NULL) enet_free (incomingCommand -> fragments); enet_free (incomingCommand); return packet; } static void enet_peer_reset_outgoing_commands (ENetList * queue) { ENetOutgoingCommand * outgoingCommand; while (! enet_list_empty (queue)) { outgoingCommand = (ENetOutgoingCommand *) enet_list_remove (enet_list_begin (queue)); if (outgoingCommand -> packet != NULL) { -- outgoingCommand -> packet -> referenceCount; if (outgoingCommand -> packet -> referenceCount == 0) enet_packet_destroy (outgoingCommand -> packet); } enet_free (outgoingCommand); } } static void enet_peer_remove_incoming_commands (ENetList * queue, ENetListIterator startCommand, ENetListIterator endCommand) { ENetListIterator currentCommand; for (currentCommand = startCommand; currentCommand != endCommand; ) { ENetIncomingCommand * incomingCommand = (ENetIncomingCommand *) currentCommand; currentCommand = enet_list_next (currentCommand); enet_list_remove (& incomingCommand -> incomingCommandList); if (incomingCommand -> packet != NULL) { -- incomingCommand -> packet -> referenceCount; if (incomingCommand -> packet -> referenceCount == 0) enet_packet_destroy (incomingCommand -> packet); } if (incomingCommand -> fragments != NULL) enet_free (incomingCommand -> fragments); enet_free (incomingCommand); } } static void enet_peer_reset_incoming_commands (ENetList * queue) { enet_peer_remove_incoming_commands(queue, enet_list_begin (queue), enet_list_end (queue)); } void enet_peer_reset_queues (ENetPeer * peer) { ENetChannel * channel; if (peer -> needsDispatch) { enet_list_remove (& peer -> dispatchList); peer -> needsDispatch = 0; } while (! enet_list_empty (& peer -> acknowledgements)) enet_free (enet_list_remove (enet_list_begin (& peer -> acknowledgements))); enet_peer_reset_outgoing_commands (& peer -> sentReliableCommands); enet_peer_reset_outgoing_commands (& peer -> sentUnreliableCommands); enet_peer_reset_outgoing_commands (& peer -> outgoingReliableCommands); enet_peer_reset_outgoing_commands (& peer -> outgoingUnreliableCommands); enet_peer_reset_incoming_commands (& peer -> dispatchedCommands); if (peer -> channels != NULL && peer -> channelCount > 0) { for (channel = peer -> channels; channel < & peer -> channels [peer -> channelCount]; ++ channel) { enet_peer_reset_incoming_commands (& channel -> incomingReliableCommands); enet_peer_reset_incoming_commands (& channel -> incomingUnreliableCommands); } enet_free (peer -> channels); } peer -> channels = NULL; peer -> channelCount = 0; } /** Forcefully disconnects a peer. @param peer peer to forcefully disconnect @remarks The foreign host represented by the peer is not notified of the disconnection and will timeout on its connection to the local host. */ void enet_peer_reset (ENetPeer * peer) { peer -> outgoingPeerID = ENET_PROTOCOL_MAXIMUM_PEER_ID; peer -> connectID = 0; peer -> state = ENET_PEER_STATE_DISCONNECTED; peer -> incomingBandwidth = 0; peer -> outgoingBandwidth = 0; peer -> incomingBandwidthThrottleEpoch = 0; peer -> outgoingBandwidthThrottleEpoch = 0; peer -> incomingDataTotal = 0; peer -> outgoingDataTotal = 0; peer -> lastSendTime = 0; peer -> lastReceiveTime = 0; peer -> nextTimeout = 0; peer -> earliestTimeout = 0; peer -> packetLossEpoch = 0; peer -> packetsSent = 0; peer -> packetsLost = 0; peer -> packetLoss = 0; peer -> packetLossVariance = 0; peer -> packetThrottle = ENET_PEER_DEFAULT_PACKET_THROTTLE; peer -> packetThrottleLimit = ENET_PEER_PACKET_THROTTLE_SCALE; peer -> packetThrottleCounter = 0; peer -> packetThrottleEpoch = 0; peer -> packetThrottleAcceleration = ENET_PEER_PACKET_THROTTLE_ACCELERATION; peer -> packetThrottleDeceleration = ENET_PEER_PACKET_THROTTLE_DECELERATION; peer -> packetThrottleInterval = ENET_PEER_PACKET_THROTTLE_INTERVAL; peer -> pingInterval = ENET_PEER_PING_INTERVAL; peer -> timeoutLimit = ENET_PEER_TIMEOUT_LIMIT; peer -> timeoutMinimum = ENET_PEER_TIMEOUT_MINIMUM; peer -> timeoutMaximum = ENET_PEER_TIMEOUT_MAXIMUM; peer -> lastRoundTripTime = ENET_PEER_DEFAULT_ROUND_TRIP_TIME; peer -> lowestRoundTripTime = ENET_PEER_DEFAULT_ROUND_TRIP_TIME; peer -> lastRoundTripTimeVariance = 0; peer -> highestRoundTripTimeVariance = 0; peer -> roundTripTime = ENET_PEER_DEFAULT_ROUND_TRIP_TIME; peer -> roundTripTimeVariance = 0; peer -> mtu = peer -> host -> mtu; peer -> reliableDataInTransit = 0; peer -> outgoingReliableSequenceNumber = 0; peer -> windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE; peer -> incomingUnsequencedGroup = 0; peer -> outgoingUnsequencedGroup = 0; peer -> eventData = 0; memset (peer -> unsequencedWindow, 0, sizeof (peer -> unsequencedWindow)); enet_peer_reset_queues (peer); } /** Sends a ping request to a peer. @param peer destination for the ping request @remarks ping requests factor into the mean round trip time as designated by the roundTripTime field in the ENetPeer structure. Enet automatically pings all connected peers at regular intervals, however, this function may be called to ensure more frequent ping requests. */ void enet_peer_ping (ENetPeer * peer) { ENetProtocol command; if (peer -> state != ENET_PEER_STATE_CONNECTED) return; command.header.command = ENET_PROTOCOL_COMMAND_PING | ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE; command.header.channelID = 0xFF; enet_peer_queue_outgoing_command (peer, & command, NULL, 0, 0); } /** Sets the interval at which pings will be sent to a peer. Pings are used both to monitor the liveness of the connection and also to dynamically adjust the throttle during periods of low traffic so that the throttle has reasonable responsiveness during traffic spikes. @param peer the peer to adjust @param pingInterval the interval at which to send pings; defaults to ENET_PEER_PING_INTERVAL if 0 */ void enet_peer_ping_interval (ENetPeer * peer, enet_uint32 pingInterval) { peer -> pingInterval = pingInterval ? pingInterval : ENET_PEER_PING_INTERVAL; } /** Sets the timeout parameters for a peer. The timeout parameter control how and when a peer will timeout from a failure to acknowledge reliable traffic. Timeout values use an exponential backoff mechanism, where if a reliable packet is not acknowledge within some multiple of the average RTT plus a variance tolerance, the timeout will be doubled until it reaches a set limit. If the timeout is thus at this limit and reliable packets have been sent but not acknowledged within a certain minimum time period, the peer will be disconnected. Alternatively, if reliable packets have been sent but not acknowledged for a certain maximum time period, the peer will be disconnected regardless of the current timeout limit value. @param peer the peer to adjust @param timeoutLimit the timeout limit; defaults to ENET_PEER_TIMEOUT_LIMIT if 0 @param timeoutMinimum the timeout minimum; defaults to ENET_PEER_TIMEOUT_MINIMUM if 0 @param timeoutMaximum the timeout maximum; defaults to ENET_PEER_TIMEOUT_MAXIMUM if 0 */ void enet_peer_timeout (ENetPeer * peer, enet_uint32 timeoutLimit, enet_uint32 timeoutMinimum, enet_uint32 timeoutMaximum) { peer -> timeoutLimit = timeoutLimit ? timeoutLimit : ENET_PEER_TIMEOUT_LIMIT; peer -> timeoutMinimum = timeoutMinimum ? timeoutMinimum : ENET_PEER_TIMEOUT_MINIMUM; peer -> timeoutMaximum = timeoutMaximum ? timeoutMaximum : ENET_PEER_TIMEOUT_MAXIMUM; } /** Force an immediate disconnection from a peer. @param peer peer to disconnect @param data data describing the disconnection @remarks No ENET_EVENT_DISCONNECT event will be generated. The foreign peer is not guarenteed to receive the disconnect notification, and is reset immediately upon return from this function. */ void enet_peer_disconnect_now (ENetPeer * peer, enet_uint32 data) { ENetProtocol command; if (peer -> state == ENET_PEER_STATE_DISCONNECTED) return; if (peer -> state != ENET_PEER_STATE_ZOMBIE && peer -> state != ENET_PEER_STATE_DISCONNECTING) { enet_peer_reset_queues (peer); command.header.command = ENET_PROTOCOL_COMMAND_DISCONNECT | ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED; command.header.channelID = 0xFF; command.disconnect.data = ENET_HOST_TO_NET_32 (data); enet_peer_queue_outgoing_command (peer, & command, NULL, 0, 0); enet_host_flush (peer -> host); } enet_peer_reset (peer); } /** Request a disconnection from a peer. @param peer peer to request a disconnection @param data data describing the disconnection @remarks An ENET_EVENT_DISCONNECT event will be generated by enet_host_service() once the disconnection is complete. */ void enet_peer_disconnect (ENetPeer * peer, enet_uint32 data) { ENetProtocol command; if (peer -> state == ENET_PEER_STATE_DISCONNECTING || peer -> state == ENET_PEER_STATE_DISCONNECTED || peer -> state == ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT || peer -> state == ENET_PEER_STATE_ZOMBIE) return; enet_peer_reset_queues (peer); command.header.command = ENET_PROTOCOL_COMMAND_DISCONNECT; command.header.channelID = 0xFF; command.disconnect.data = ENET_HOST_TO_NET_32 (data); if (peer -> state == ENET_PEER_STATE_CONNECTED || peer -> state == ENET_PEER_STATE_DISCONNECT_LATER) command.header.command |= ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE; else command.header.command |= ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED; enet_peer_queue_outgoing_command (peer, & command, NULL, 0, 0); if (peer -> state == ENET_PEER_STATE_CONNECTED || peer -> state == ENET_PEER_STATE_DISCONNECT_LATER) peer -> state = ENET_PEER_STATE_DISCONNECTING; else { enet_host_flush (peer -> host); enet_peer_reset (peer); } } /** Request a disconnection from a peer, but only after all queued outgoing packets are sent. @param peer peer to request a disconnection @param data data describing the disconnection @remarks An ENET_EVENT_DISCONNECT event will be generated by enet_host_service() once the disconnection is complete. */ void enet_peer_disconnect_later (ENetPeer * peer, enet_uint32 data) { if ((peer -> state == ENET_PEER_STATE_CONNECTED || peer -> state == ENET_PEER_STATE_DISCONNECT_LATER) && ! (enet_list_empty (& peer -> outgoingReliableCommands) && enet_list_empty (& peer -> outgoingUnreliableCommands) && enet_list_empty (& peer -> sentReliableCommands))) { peer -> state = ENET_PEER_STATE_DISCONNECT_LATER; peer -> eventData = data; } else enet_peer_disconnect (peer, data); } ENetAcknowledgement * enet_peer_queue_acknowledgement (ENetPeer * peer, const ENetProtocol * command, enet_uint16 sentTime) { ENetAcknowledgement * acknowledgement; if (command -> header.channelID < peer -> channelCount) { ENetChannel * channel = & peer -> channels [command -> header.channelID]; enet_uint16 reliableWindow = command -> header.reliableSequenceNumber / ENET_PEER_RELIABLE_WINDOW_SIZE, currentWindow = channel -> incomingReliableSequenceNumber / ENET_PEER_RELIABLE_WINDOW_SIZE; if (command -> header.reliableSequenceNumber < channel -> incomingReliableSequenceNumber) reliableWindow += ENET_PEER_RELIABLE_WINDOWS; if (reliableWindow >= currentWindow + ENET_PEER_FREE_RELIABLE_WINDOWS - 1 && reliableWindow <= currentWindow + ENET_PEER_FREE_RELIABLE_WINDOWS) return NULL; } acknowledgement = (ENetAcknowledgement *) enet_malloc (sizeof (ENetAcknowledgement)); if (acknowledgement == NULL) return NULL; peer -> outgoingDataTotal += sizeof (ENetProtocolAcknowledge); acknowledgement -> sentTime = sentTime; acknowledgement -> command = * command; enet_list_insert (enet_list_end (& peer -> acknowledgements), acknowledgement); return acknowledgement; } void enet_peer_setup_outgoing_command (ENetPeer * peer, ENetOutgoingCommand * outgoingCommand) { ENetChannel * channel = & peer -> channels [outgoingCommand -> command.header.channelID]; peer -> outgoingDataTotal += enet_protocol_command_size (outgoingCommand -> command.header.command) + outgoingCommand -> fragmentLength; if (outgoingCommand -> command.header.channelID == 0xFF) { ++ peer -> outgoingReliableSequenceNumber; outgoingCommand -> reliableSequenceNumber = peer -> outgoingReliableSequenceNumber; outgoingCommand -> unreliableSequenceNumber = 0; } else if (outgoingCommand -> command.header.command & ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE) { ++ channel -> outgoingReliableSequenceNumber; channel -> outgoingUnreliableSequenceNumber = 0; outgoingCommand -> reliableSequenceNumber = channel -> outgoingReliableSequenceNumber; outgoingCommand -> unreliableSequenceNumber = 0; } else if (outgoingCommand -> command.header.command & ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED) { ++ peer -> outgoingUnsequencedGroup; outgoingCommand -> reliableSequenceNumber = 0; outgoingCommand -> unreliableSequenceNumber = 0; } else { if (outgoingCommand -> fragmentOffset == 0) ++ channel -> outgoingUnreliableSequenceNumber; outgoingCommand -> reliableSequenceNumber = channel -> outgoingReliableSequenceNumber; outgoingCommand -> unreliableSequenceNumber = channel -> outgoingUnreliableSequenceNumber; } outgoingCommand -> sendAttempts = 0; outgoingCommand -> sentTime = 0; outgoingCommand -> roundTripTimeout = 0; outgoingCommand -> roundTripTimeoutLimit = 0; outgoingCommand -> command.header.reliableSequenceNumber = ENET_HOST_TO_NET_16 (outgoingCommand -> reliableSequenceNumber); switch (outgoingCommand -> command.header.command & ENET_PROTOCOL_COMMAND_MASK) { case ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE: outgoingCommand -> command.sendUnreliable.unreliableSequenceNumber = ENET_HOST_TO_NET_16 (outgoingCommand -> unreliableSequenceNumber); break; case ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED: outgoingCommand -> command.sendUnsequenced.unsequencedGroup = ENET_HOST_TO_NET_16 (peer -> outgoingUnsequencedGroup); break; default: break; } if (outgoingCommand -> command.header.command & ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE) enet_list_insert (enet_list_end (& peer -> outgoingReliableCommands), outgoingCommand); else enet_list_insert (enet_list_end (& peer -> outgoingUnreliableCommands), outgoingCommand); } ENetOutgoingCommand * enet_peer_queue_outgoing_command (ENetPeer * peer, const ENetProtocol * command, ENetPacket * packet, enet_uint32 offset, enet_uint16 length) { ENetOutgoingCommand * outgoingCommand = (ENetOutgoingCommand *) enet_malloc (sizeof (ENetOutgoingCommand)); if (outgoingCommand == NULL) return NULL; outgoingCommand -> command = * command; outgoingCommand -> fragmentOffset = offset; outgoingCommand -> fragmentLength = length; outgoingCommand -> packet = packet; if (packet != NULL) ++ packet -> referenceCount; enet_peer_setup_outgoing_command (peer, outgoingCommand); return outgoingCommand; } void enet_peer_dispatch_incoming_unreliable_commands (ENetPeer * peer, ENetChannel * channel) { ENetListIterator droppedCommand, startCommand, currentCommand; for (droppedCommand = startCommand = currentCommand = enet_list_begin (& channel -> incomingUnreliableCommands); currentCommand != enet_list_end (& channel -> incomingUnreliableCommands); currentCommand = enet_list_next (currentCommand)) { ENetIncomingCommand * incomingCommand = (ENetIncomingCommand *) currentCommand; if ((incomingCommand -> command.header.command & ENET_PROTOCOL_COMMAND_MASK) == ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED) continue; if (incomingCommand -> reliableSequenceNumber == channel -> incomingReliableSequenceNumber) { if (incomingCommand -> fragmentsRemaining <= 0) { channel -> incomingUnreliableSequenceNumber = incomingCommand -> unreliableSequenceNumber; continue; } if (startCommand != currentCommand) { enet_list_move (enet_list_end (& peer -> dispatchedCommands), startCommand, enet_list_previous (currentCommand)); if (! peer -> needsDispatch) { enet_list_insert (enet_list_end (& peer -> host -> dispatchQueue), & peer -> dispatchList); peer -> needsDispatch = 1; } droppedCommand = currentCommand; } else if (droppedCommand != currentCommand) droppedCommand = enet_list_previous (currentCommand); } else { enet_uint16 reliableWindow = incomingCommand -> reliableSequenceNumber / ENET_PEER_RELIABLE_WINDOW_SIZE, currentWindow = channel -> incomingReliableSequenceNumber / ENET_PEER_RELIABLE_WINDOW_SIZE; if (incomingCommand -> reliableSequenceNumber < channel -> incomingReliableSequenceNumber) reliableWindow += ENET_PEER_RELIABLE_WINDOWS; if (reliableWindow >= currentWindow && reliableWindow < currentWindow + ENET_PEER_FREE_RELIABLE_WINDOWS - 1) break; droppedCommand = enet_list_next (currentCommand); if (startCommand != currentCommand) { enet_list_move (enet_list_end (& peer -> dispatchedCommands), startCommand, enet_list_previous (currentCommand)); if (! peer -> needsDispatch) { enet_list_insert (enet_list_end (& peer -> host -> dispatchQueue), & peer -> dispatchList); peer -> needsDispatch = 1; } } } startCommand = enet_list_next (currentCommand); } if (startCommand != currentCommand) { enet_list_move (enet_list_end (& peer -> dispatchedCommands), startCommand, enet_list_previous (currentCommand)); if (! peer -> needsDispatch) { enet_list_insert (enet_list_end (& peer -> host -> dispatchQueue), & peer -> dispatchList); peer -> needsDispatch = 1; } droppedCommand = currentCommand; } enet_peer_remove_incoming_commands (& channel -> incomingUnreliableCommands, enet_list_begin (& channel -> incomingUnreliableCommands), droppedCommand); } void enet_peer_dispatch_incoming_reliable_commands (ENetPeer * peer, ENetChannel * channel) { ENetListIterator currentCommand; for (currentCommand = enet_list_begin (& channel -> incomingReliableCommands); currentCommand != enet_list_end (& channel -> incomingReliableCommands); currentCommand = enet_list_next (currentCommand)) { ENetIncomingCommand * incomingCommand = (ENetIncomingCommand *) currentCommand; if (incomingCommand -> fragmentsRemaining > 0 || incomingCommand -> reliableSequenceNumber != (enet_uint16) (channel -> incomingReliableSequenceNumber + 1)) break; channel -> incomingReliableSequenceNumber = incomingCommand -> reliableSequenceNumber; if (incomingCommand -> fragmentCount > 0) channel -> incomingReliableSequenceNumber += incomingCommand -> fragmentCount - 1; } if (currentCommand == enet_list_begin (& channel -> incomingReliableCommands)) return; channel -> incomingUnreliableSequenceNumber = 0; enet_list_move (enet_list_end (& peer -> dispatchedCommands), enet_list_begin (& channel -> incomingReliableCommands), enet_list_previous (currentCommand)); if (! peer -> needsDispatch) { enet_list_insert (enet_list_end (& peer -> host -> dispatchQueue), & peer -> dispatchList); peer -> needsDispatch = 1; } if (! enet_list_empty (& channel -> incomingUnreliableCommands)) enet_peer_dispatch_incoming_unreliable_commands (peer, channel); } ENetIncomingCommand * enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command, ENetPacket * packet, enet_uint32 fragmentCount) { static ENetIncomingCommand dummyCommand; ENetChannel * channel = & peer -> channels [command -> header.channelID]; enet_uint32 unreliableSequenceNumber = 0, reliableSequenceNumber = 0; enet_uint16 reliableWindow, currentWindow; ENetIncomingCommand * incomingCommand; ENetListIterator currentCommand; if (peer -> state == ENET_PEER_STATE_DISCONNECT_LATER) goto freePacket; if ((command -> header.command & ENET_PROTOCOL_COMMAND_MASK) != ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED) { reliableSequenceNumber = command -> header.reliableSequenceNumber; reliableWindow = reliableSequenceNumber / ENET_PEER_RELIABLE_WINDOW_SIZE; currentWindow = channel -> incomingReliableSequenceNumber / ENET_PEER_RELIABLE_WINDOW_SIZE; if (reliableSequenceNumber < channel -> incomingReliableSequenceNumber) reliableWindow += ENET_PEER_RELIABLE_WINDOWS; if (reliableWindow < currentWindow || reliableWindow >= currentWindow + ENET_PEER_FREE_RELIABLE_WINDOWS - 1) goto freePacket; } switch (command -> header.command & ENET_PROTOCOL_COMMAND_MASK) { case ENET_PROTOCOL_COMMAND_SEND_FRAGMENT: case ENET_PROTOCOL_COMMAND_SEND_RELIABLE: if (reliableSequenceNumber == channel -> incomingReliableSequenceNumber) goto freePacket; for (currentCommand = enet_list_previous (enet_list_end (& channel -> incomingReliableCommands)); currentCommand != enet_list_end (& channel -> incomingReliableCommands); currentCommand = enet_list_previous (currentCommand)) { incomingCommand = (ENetIncomingCommand *) currentCommand; if (reliableSequenceNumber >= channel -> incomingReliableSequenceNumber) { if (incomingCommand -> reliableSequenceNumber < channel -> incomingReliableSequenceNumber) continue; } else if (incomingCommand -> reliableSequenceNumber >= channel -> incomingReliableSequenceNumber) break; if (incomingCommand -> reliableSequenceNumber <= reliableSequenceNumber) { if (incomingCommand -> reliableSequenceNumber < reliableSequenceNumber) break; goto freePacket; } } break; case ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE: case ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE_FRAGMENT: unreliableSequenceNumber = ENET_NET_TO_HOST_16 (command -> sendUnreliable.unreliableSequenceNumber); if (reliableSequenceNumber == channel -> incomingReliableSequenceNumber && unreliableSequenceNumber <= channel -> incomingUnreliableSequenceNumber) goto freePacket; for (currentCommand = enet_list_previous (enet_list_end (& channel -> incomingUnreliableCommands)); currentCommand != enet_list_end (& channel -> incomingUnreliableCommands); currentCommand = enet_list_previous (currentCommand)) { incomingCommand = (ENetIncomingCommand *) currentCommand; if ((command -> header.command & ENET_PROTOCOL_COMMAND_MASK) == ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED) continue; if (reliableSequenceNumber >= channel -> incomingReliableSequenceNumber) { if (incomingCommand -> reliableSequenceNumber < channel -> incomingReliableSequenceNumber) continue; } else if (incomingCommand -> reliableSequenceNumber >= channel -> incomingReliableSequenceNumber) break; if (incomingCommand -> reliableSequenceNumber < reliableSequenceNumber) break; if (incomingCommand -> reliableSequenceNumber > reliableSequenceNumber) continue; if (incomingCommand -> unreliableSequenceNumber <= unreliableSequenceNumber) { if (incomingCommand -> unreliableSequenceNumber < unreliableSequenceNumber) break; goto freePacket; } } break; case ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED: currentCommand = enet_list_end (& channel -> incomingUnreliableCommands); break; default: goto freePacket; } incomingCommand = (ENetIncomingCommand *) enet_malloc (sizeof (ENetIncomingCommand)); if (incomingCommand == NULL) goto notifyError; incomingCommand -> reliableSequenceNumber = command -> header.reliableSequenceNumber; incomingCommand -> unreliableSequenceNumber = unreliableSequenceNumber & 0xFFFF; incomingCommand -> command = * command; incomingCommand -> fragmentCount = fragmentCount; incomingCommand -> fragmentsRemaining = fragmentCount; incomingCommand -> packet = packet; incomingCommand -> fragments = NULL; if (fragmentCount > 0) { if (fragmentCount <= ENET_PROTOCOL_MAXIMUM_FRAGMENT_COUNT) incomingCommand -> fragments = (enet_uint32 *) enet_malloc ((fragmentCount + 31) / 32 * sizeof (enet_uint32)); if (incomingCommand -> fragments == NULL) { enet_free (incomingCommand); goto notifyError; } memset (incomingCommand -> fragments, 0, (fragmentCount + 31) / 32 * sizeof (enet_uint32)); } if (packet != NULL) ++ packet -> referenceCount; enet_list_insert (enet_list_next (currentCommand), incomingCommand); switch (command -> header.command & ENET_PROTOCOL_COMMAND_MASK) { case ENET_PROTOCOL_COMMAND_SEND_FRAGMENT: case ENET_PROTOCOL_COMMAND_SEND_RELIABLE: enet_peer_dispatch_incoming_reliable_commands (peer, channel); break; default: enet_peer_dispatch_incoming_unreliable_commands (peer, channel); break; } return incomingCommand; freePacket: if (fragmentCount > 0) goto notifyError; if (packet != NULL && packet -> referenceCount == 0) enet_packet_destroy (packet); return & dummyCommand; notifyError: if (packet != NULL && packet -> referenceCount == 0) enet_packet_destroy (packet); return NULL; } /** @} */ assaultcube-1.2.0.2.1/source/enet/protocol.c000066400000000000000000002070421352165075300206000ustar00rootroot00000000000000/** @file protocol.c @brief ENet protocol functions */ #include #include #define ENET_BUILDING_LIB 1 #include "enet/utility.h" #include "enet/time.h" #include "enet/enet.h" static size_t commandSizes [ENET_PROTOCOL_COMMAND_COUNT] = { 0, sizeof (ENetProtocolAcknowledge), sizeof (ENetProtocolConnect), sizeof (ENetProtocolVerifyConnect), sizeof (ENetProtocolDisconnect), sizeof (ENetProtocolPing), sizeof (ENetProtocolSendReliable), sizeof (ENetProtocolSendUnreliable), sizeof (ENetProtocolSendFragment), sizeof (ENetProtocolSendUnsequenced), sizeof (ENetProtocolBandwidthLimit), sizeof (ENetProtocolThrottleConfigure), sizeof (ENetProtocolSendFragment) }; size_t enet_protocol_command_size (enet_uint8 commandNumber) { return commandSizes [commandNumber & ENET_PROTOCOL_COMMAND_MASK]; } static int enet_protocol_dispatch_incoming_commands (ENetHost * host, ENetEvent * event) { while (! enet_list_empty (& host -> dispatchQueue)) { ENetPeer * peer = (ENetPeer *) enet_list_remove (enet_list_begin (& host -> dispatchQueue)); peer -> needsDispatch = 0; switch (peer -> state) { case ENET_PEER_STATE_CONNECTION_PENDING: case ENET_PEER_STATE_CONNECTION_SUCCEEDED: peer -> state = ENET_PEER_STATE_CONNECTED; event -> type = ENET_EVENT_TYPE_CONNECT; event -> peer = peer; event -> data = peer -> eventData; return 1; case ENET_PEER_STATE_ZOMBIE: host -> recalculateBandwidthLimits = 1; event -> type = ENET_EVENT_TYPE_DISCONNECT; event -> peer = peer; event -> data = peer -> eventData; enet_peer_reset (peer); return 1; case ENET_PEER_STATE_CONNECTED: if (enet_list_empty (& peer -> dispatchedCommands)) continue; event -> packet = enet_peer_receive (peer, & event -> channelID); if (event -> packet == NULL) continue; event -> type = ENET_EVENT_TYPE_RECEIVE; event -> peer = peer; if (! enet_list_empty (& peer -> dispatchedCommands)) { peer -> needsDispatch = 1; enet_list_insert (enet_list_end (& host -> dispatchQueue), & peer -> dispatchList); } return 1; default: break; } } return 0; } static void enet_protocol_dispatch_state (ENetHost * host, ENetPeer * peer, ENetPeerState state) { peer -> state = state; if (! peer -> needsDispatch) { enet_list_insert (enet_list_end (& host -> dispatchQueue), & peer -> dispatchList); peer -> needsDispatch = 1; } } static void enet_protocol_notify_connect (ENetHost * host, ENetPeer * peer, ENetEvent * event) { host -> recalculateBandwidthLimits = 1; if (event != NULL) { peer -> state = ENET_PEER_STATE_CONNECTED; event -> type = ENET_EVENT_TYPE_CONNECT; event -> peer = peer; event -> data = peer -> eventData; } else enet_protocol_dispatch_state (host, peer, peer -> state == ENET_PEER_STATE_CONNECTING ? ENET_PEER_STATE_CONNECTION_SUCCEEDED : ENET_PEER_STATE_CONNECTION_PENDING); } static void enet_protocol_notify_disconnect (ENetHost * host, ENetPeer * peer, ENetEvent * event) { if (peer -> state >= ENET_PEER_STATE_CONNECTION_PENDING) host -> recalculateBandwidthLimits = 1; if (peer -> state != ENET_PEER_STATE_CONNECTING && peer -> state < ENET_PEER_STATE_CONNECTION_SUCCEEDED) enet_peer_reset (peer); else if (event != NULL) { event -> type = ENET_EVENT_TYPE_DISCONNECT; event -> peer = peer; event -> data = 0; enet_peer_reset (peer); } else { peer -> eventData = 0; enet_protocol_dispatch_state (host, peer, ENET_PEER_STATE_ZOMBIE); } } static void enet_protocol_remove_sent_unreliable_commands (ENetPeer * peer) { ENetOutgoingCommand * outgoingCommand; while (! enet_list_empty (& peer -> sentUnreliableCommands)) { outgoingCommand = (ENetOutgoingCommand *) enet_list_front (& peer -> sentUnreliableCommands); enet_list_remove (& outgoingCommand -> outgoingCommandList); if (outgoingCommand -> packet != NULL) { -- outgoingCommand -> packet -> referenceCount; if (outgoingCommand -> packet -> referenceCount == 0) enet_packet_destroy (outgoingCommand -> packet); } enet_free (outgoingCommand); } } static ENetProtocolCommand enet_protocol_remove_sent_reliable_command (ENetPeer * peer, enet_uint16 reliableSequenceNumber, enet_uint8 channelID) { ENetOutgoingCommand * outgoingCommand = NULL; ENetListIterator currentCommand; ENetProtocolCommand commandNumber; int wasSent = 1; for (currentCommand = enet_list_begin (& peer -> sentReliableCommands); currentCommand != enet_list_end (& peer -> sentReliableCommands); currentCommand = enet_list_next (currentCommand)) { outgoingCommand = (ENetOutgoingCommand *) currentCommand; if (outgoingCommand -> reliableSequenceNumber == reliableSequenceNumber && outgoingCommand -> command.header.channelID == channelID) break; } if (currentCommand == enet_list_end (& peer -> sentReliableCommands)) { for (currentCommand = enet_list_begin (& peer -> outgoingReliableCommands); currentCommand != enet_list_end (& peer -> outgoingReliableCommands); currentCommand = enet_list_next (currentCommand)) { outgoingCommand = (ENetOutgoingCommand *) currentCommand; if (outgoingCommand -> sendAttempts < 1) return ENET_PROTOCOL_COMMAND_NONE; if (outgoingCommand -> reliableSequenceNumber == reliableSequenceNumber && outgoingCommand -> command.header.channelID == channelID) break; } if (currentCommand == enet_list_end (& peer -> outgoingReliableCommands)) return ENET_PROTOCOL_COMMAND_NONE; wasSent = 0; } if (outgoingCommand == NULL) return ENET_PROTOCOL_COMMAND_NONE; if (channelID < peer -> channelCount) { ENetChannel * channel = & peer -> channels [channelID]; enet_uint16 reliableWindow = reliableSequenceNumber / ENET_PEER_RELIABLE_WINDOW_SIZE; if (channel -> reliableWindows [reliableWindow] > 0) { -- channel -> reliableWindows [reliableWindow]; if (! channel -> reliableWindows [reliableWindow]) channel -> usedReliableWindows &= ~ (1 << reliableWindow); } } commandNumber = (ENetProtocolCommand) (outgoingCommand -> command.header.command & ENET_PROTOCOL_COMMAND_MASK); enet_list_remove (& outgoingCommand -> outgoingCommandList); if (outgoingCommand -> packet != NULL) { if (wasSent) peer -> reliableDataInTransit -= outgoingCommand -> fragmentLength; -- outgoingCommand -> packet -> referenceCount; if (outgoingCommand -> packet -> referenceCount == 0) enet_packet_destroy (outgoingCommand -> packet); } enet_free (outgoingCommand); if (enet_list_empty (& peer -> sentReliableCommands)) return commandNumber; outgoingCommand = (ENetOutgoingCommand *) enet_list_front (& peer -> sentReliableCommands); peer -> nextTimeout = outgoingCommand -> sentTime + outgoingCommand -> roundTripTimeout; return commandNumber; } static ENetPeer * enet_protocol_handle_connect (ENetHost * host, ENetProtocolHeader * header, ENetProtocol * command) { enet_uint8 incomingSessionID, outgoingSessionID; enet_uint32 mtu, windowSize; ENetChannel * channel; size_t channelCount; ENetPeer * currentPeer; ENetProtocol verifyCommand; channelCount = ENET_NET_TO_HOST_32 (command -> connect.channelCount); if (channelCount < ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT || channelCount > ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT) return NULL; for (currentPeer = host -> peers; currentPeer < & host -> peers [host -> peerCount]; ++ currentPeer) { if (currentPeer -> state != ENET_PEER_STATE_DISCONNECTED && currentPeer -> address.host == host -> receivedAddress.host && currentPeer -> address.port == host -> receivedAddress.port && currentPeer -> connectID == command -> connect.connectID) return NULL; } for (currentPeer = host -> peers; currentPeer < & host -> peers [host -> peerCount]; ++ currentPeer) { if (currentPeer -> state == ENET_PEER_STATE_DISCONNECTED) break; } if (currentPeer >= & host -> peers [host -> peerCount]) return NULL; if (channelCount > host -> channelLimit) channelCount = host -> channelLimit; currentPeer -> channels = (ENetChannel *) enet_malloc (channelCount * sizeof (ENetChannel)); if (currentPeer -> channels == NULL) return NULL; currentPeer -> channelCount = channelCount; currentPeer -> state = ENET_PEER_STATE_ACKNOWLEDGING_CONNECT; currentPeer -> connectID = command -> connect.connectID; currentPeer -> address = host -> receivedAddress; currentPeer -> outgoingPeerID = ENET_NET_TO_HOST_16 (command -> connect.outgoingPeerID); currentPeer -> incomingBandwidth = ENET_NET_TO_HOST_32 (command -> connect.incomingBandwidth); currentPeer -> outgoingBandwidth = ENET_NET_TO_HOST_32 (command -> connect.outgoingBandwidth); currentPeer -> packetThrottleInterval = ENET_NET_TO_HOST_32 (command -> connect.packetThrottleInterval); currentPeer -> packetThrottleAcceleration = ENET_NET_TO_HOST_32 (command -> connect.packetThrottleAcceleration); currentPeer -> packetThrottleDeceleration = ENET_NET_TO_HOST_32 (command -> connect.packetThrottleDeceleration); currentPeer -> eventData = ENET_NET_TO_HOST_32 (command -> connect.data); incomingSessionID = command -> connect.incomingSessionID == 0xFF ? currentPeer -> outgoingSessionID : command -> connect.incomingSessionID; incomingSessionID = (incomingSessionID + 1) & (ENET_PROTOCOL_HEADER_SESSION_MASK >> ENET_PROTOCOL_HEADER_SESSION_SHIFT); if (incomingSessionID == currentPeer -> outgoingSessionID) incomingSessionID = (incomingSessionID + 1) & (ENET_PROTOCOL_HEADER_SESSION_MASK >> ENET_PROTOCOL_HEADER_SESSION_SHIFT); currentPeer -> outgoingSessionID = incomingSessionID; outgoingSessionID = command -> connect.outgoingSessionID == 0xFF ? currentPeer -> incomingSessionID : command -> connect.outgoingSessionID; outgoingSessionID = (outgoingSessionID + 1) & (ENET_PROTOCOL_HEADER_SESSION_MASK >> ENET_PROTOCOL_HEADER_SESSION_SHIFT); if (outgoingSessionID == currentPeer -> incomingSessionID) outgoingSessionID = (outgoingSessionID + 1) & (ENET_PROTOCOL_HEADER_SESSION_MASK >> ENET_PROTOCOL_HEADER_SESSION_SHIFT); currentPeer -> incomingSessionID = outgoingSessionID; for (channel = currentPeer -> channels; channel < & currentPeer -> channels [channelCount]; ++ channel) { channel -> outgoingReliableSequenceNumber = 0; channel -> outgoingUnreliableSequenceNumber = 0; channel -> incomingReliableSequenceNumber = 0; channel -> incomingUnreliableSequenceNumber = 0; enet_list_clear (& channel -> incomingReliableCommands); enet_list_clear (& channel -> incomingUnreliableCommands); channel -> usedReliableWindows = 0; memset (channel -> reliableWindows, 0, sizeof (channel -> reliableWindows)); } mtu = ENET_NET_TO_HOST_32 (command -> connect.mtu); if (mtu < ENET_PROTOCOL_MINIMUM_MTU) mtu = ENET_PROTOCOL_MINIMUM_MTU; else if (mtu > ENET_PROTOCOL_MAXIMUM_MTU) mtu = ENET_PROTOCOL_MAXIMUM_MTU; currentPeer -> mtu = mtu; if (host -> outgoingBandwidth == 0 && currentPeer -> incomingBandwidth == 0) currentPeer -> windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE; else if (host -> outgoingBandwidth == 0 || currentPeer -> incomingBandwidth == 0) currentPeer -> windowSize = (ENET_MAX (host -> outgoingBandwidth, currentPeer -> incomingBandwidth) / ENET_PEER_WINDOW_SIZE_SCALE) * ENET_PROTOCOL_MINIMUM_WINDOW_SIZE; else currentPeer -> windowSize = (ENET_MIN (host -> outgoingBandwidth, currentPeer -> incomingBandwidth) / ENET_PEER_WINDOW_SIZE_SCALE) * ENET_PROTOCOL_MINIMUM_WINDOW_SIZE; if (currentPeer -> windowSize < ENET_PROTOCOL_MINIMUM_WINDOW_SIZE) currentPeer -> windowSize = ENET_PROTOCOL_MINIMUM_WINDOW_SIZE; else if (currentPeer -> windowSize > ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE) currentPeer -> windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE; if (host -> incomingBandwidth == 0) windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE; else windowSize = (host -> incomingBandwidth / ENET_PEER_WINDOW_SIZE_SCALE) * ENET_PROTOCOL_MINIMUM_WINDOW_SIZE; if (windowSize > ENET_NET_TO_HOST_32 (command -> connect.windowSize)) windowSize = ENET_NET_TO_HOST_32 (command -> connect.windowSize); if (windowSize < ENET_PROTOCOL_MINIMUM_WINDOW_SIZE) windowSize = ENET_PROTOCOL_MINIMUM_WINDOW_SIZE; else if (windowSize > ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE) windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE; verifyCommand.header.command = ENET_PROTOCOL_COMMAND_VERIFY_CONNECT | ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE; verifyCommand.header.channelID = 0xFF; verifyCommand.verifyConnect.outgoingPeerID = ENET_HOST_TO_NET_16 (currentPeer -> incomingPeerID); verifyCommand.verifyConnect.incomingSessionID = incomingSessionID; verifyCommand.verifyConnect.outgoingSessionID = outgoingSessionID; verifyCommand.verifyConnect.mtu = ENET_HOST_TO_NET_32 (currentPeer -> mtu); verifyCommand.verifyConnect.windowSize = ENET_HOST_TO_NET_32 (windowSize); verifyCommand.verifyConnect.channelCount = ENET_HOST_TO_NET_32 (channelCount); verifyCommand.verifyConnect.incomingBandwidth = ENET_HOST_TO_NET_32 (host -> incomingBandwidth); verifyCommand.verifyConnect.outgoingBandwidth = ENET_HOST_TO_NET_32 (host -> outgoingBandwidth); verifyCommand.verifyConnect.packetThrottleInterval = ENET_HOST_TO_NET_32 (currentPeer -> packetThrottleInterval); verifyCommand.verifyConnect.packetThrottleAcceleration = ENET_HOST_TO_NET_32 (currentPeer -> packetThrottleAcceleration); verifyCommand.verifyConnect.packetThrottleDeceleration = ENET_HOST_TO_NET_32 (currentPeer -> packetThrottleDeceleration); verifyCommand.verifyConnect.connectID = currentPeer -> connectID; enet_peer_queue_outgoing_command (currentPeer, & verifyCommand, NULL, 0, 0); return currentPeer; } static int enet_protocol_handle_send_reliable (ENetHost * host, ENetPeer * peer, const ENetProtocol * command, enet_uint8 ** currentData) { ENetPacket * packet; size_t dataLength; if (command -> header.channelID >= peer -> channelCount || (peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER)) return -1; dataLength = ENET_NET_TO_HOST_16 (command -> sendReliable.dataLength); * currentData += dataLength; if (dataLength > ENET_PROTOCOL_MAXIMUM_PACKET_SIZE || * currentData < host -> receivedData || * currentData > & host -> receivedData [host -> receivedDataLength]) return -1; packet = enet_packet_create ((const enet_uint8 *) command + sizeof (ENetProtocolSendReliable), dataLength, ENET_PACKET_FLAG_RELIABLE); if (packet == NULL || enet_peer_queue_incoming_command (peer, command, packet, 0) == NULL) return -1; return 0; } static int enet_protocol_handle_send_unsequenced (ENetHost * host, ENetPeer * peer, const ENetProtocol * command, enet_uint8 ** currentData) { ENetPacket * packet; enet_uint32 unsequencedGroup, index; size_t dataLength; if (command -> header.channelID >= peer -> channelCount || (peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER)) return -1; dataLength = ENET_NET_TO_HOST_16 (command -> sendUnsequenced.dataLength); * currentData += dataLength; if (dataLength > ENET_PROTOCOL_MAXIMUM_PACKET_SIZE || * currentData < host -> receivedData || * currentData > & host -> receivedData [host -> receivedDataLength]) return -1; unsequencedGroup = ENET_NET_TO_HOST_16 (command -> sendUnsequenced.unsequencedGroup); index = unsequencedGroup % ENET_PEER_UNSEQUENCED_WINDOW_SIZE; if (unsequencedGroup < peer -> incomingUnsequencedGroup) unsequencedGroup += 0x10000; if (unsequencedGroup >= (enet_uint32) peer -> incomingUnsequencedGroup + ENET_PEER_FREE_UNSEQUENCED_WINDOWS * ENET_PEER_UNSEQUENCED_WINDOW_SIZE) return 0; unsequencedGroup &= 0xFFFF; if (unsequencedGroup - index != peer -> incomingUnsequencedGroup) { peer -> incomingUnsequencedGroup = unsequencedGroup - index; memset (peer -> unsequencedWindow, 0, sizeof (peer -> unsequencedWindow)); } else if (peer -> unsequencedWindow [index / 32] & (1 << (index % 32))) return 0; packet = enet_packet_create ((const enet_uint8 *) command + sizeof (ENetProtocolSendUnsequenced), dataLength, ENET_PACKET_FLAG_UNSEQUENCED); if (packet == NULL || enet_peer_queue_incoming_command (peer, command, packet, 0) == NULL) return -1; peer -> unsequencedWindow [index / 32] |= 1 << (index % 32); return 0; } static int enet_protocol_handle_send_unreliable (ENetHost * host, ENetPeer * peer, const ENetProtocol * command, enet_uint8 ** currentData) { ENetPacket * packet; size_t dataLength; if (command -> header.channelID >= peer -> channelCount || (peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER)) return -1; dataLength = ENET_NET_TO_HOST_16 (command -> sendUnreliable.dataLength); * currentData += dataLength; if (dataLength > ENET_PROTOCOL_MAXIMUM_PACKET_SIZE || * currentData < host -> receivedData || * currentData > & host -> receivedData [host -> receivedDataLength]) return -1; packet = enet_packet_create ((const enet_uint8 *) command + sizeof (ENetProtocolSendUnreliable), dataLength, 0); if (packet == NULL || enet_peer_queue_incoming_command (peer, command, packet, 0) == NULL) return -1; return 0; } static int enet_protocol_handle_send_fragment (ENetHost * host, ENetPeer * peer, const ENetProtocol * command, enet_uint8 ** currentData) { enet_uint32 fragmentNumber, fragmentCount, fragmentOffset, fragmentLength, startSequenceNumber, totalLength; ENetChannel * channel; enet_uint16 startWindow, currentWindow; ENetListIterator currentCommand; ENetIncomingCommand * startCommand = NULL; if (command -> header.channelID >= peer -> channelCount || (peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER)) return -1; fragmentLength = ENET_NET_TO_HOST_16 (command -> sendFragment.dataLength); * currentData += fragmentLength; if (fragmentLength > ENET_PROTOCOL_MAXIMUM_PACKET_SIZE || * currentData < host -> receivedData || * currentData > & host -> receivedData [host -> receivedDataLength]) return -1; channel = & peer -> channels [command -> header.channelID]; startSequenceNumber = ENET_NET_TO_HOST_16 (command -> sendFragment.startSequenceNumber); startWindow = startSequenceNumber / ENET_PEER_RELIABLE_WINDOW_SIZE; currentWindow = channel -> incomingReliableSequenceNumber / ENET_PEER_RELIABLE_WINDOW_SIZE; if (startSequenceNumber < channel -> incomingReliableSequenceNumber) startWindow += ENET_PEER_RELIABLE_WINDOWS; if (startWindow < currentWindow || startWindow >= currentWindow + ENET_PEER_FREE_RELIABLE_WINDOWS - 1) return 0; fragmentNumber = ENET_NET_TO_HOST_32 (command -> sendFragment.fragmentNumber); fragmentCount = ENET_NET_TO_HOST_32 (command -> sendFragment.fragmentCount); fragmentOffset = ENET_NET_TO_HOST_32 (command -> sendFragment.fragmentOffset); totalLength = ENET_NET_TO_HOST_32 (command -> sendFragment.totalLength); if (fragmentCount > ENET_PROTOCOL_MAXIMUM_FRAGMENT_COUNT || fragmentNumber >= fragmentCount || totalLength > ENET_PROTOCOL_MAXIMUM_PACKET_SIZE || fragmentOffset >= totalLength || fragmentLength > totalLength - fragmentOffset) return -1; for (currentCommand = enet_list_previous (enet_list_end (& channel -> incomingReliableCommands)); currentCommand != enet_list_end (& channel -> incomingReliableCommands); currentCommand = enet_list_previous (currentCommand)) { ENetIncomingCommand * incomingCommand = (ENetIncomingCommand *) currentCommand; if (startSequenceNumber >= channel -> incomingReliableSequenceNumber) { if (incomingCommand -> reliableSequenceNumber < channel -> incomingReliableSequenceNumber) continue; } else if (incomingCommand -> reliableSequenceNumber >= channel -> incomingReliableSequenceNumber) break; if (incomingCommand -> reliableSequenceNumber <= startSequenceNumber) { if (incomingCommand -> reliableSequenceNumber < startSequenceNumber) break; if ((incomingCommand -> command.header.command & ENET_PROTOCOL_COMMAND_MASK) != ENET_PROTOCOL_COMMAND_SEND_FRAGMENT || totalLength != incomingCommand -> packet -> dataLength || fragmentCount != incomingCommand -> fragmentCount) return -1; startCommand = incomingCommand; break; } } if (startCommand == NULL) { ENetProtocol hostCommand = * command; ENetPacket * packet = enet_packet_create (NULL, totalLength, ENET_PACKET_FLAG_RELIABLE); if (packet == NULL) return -1; hostCommand.header.reliableSequenceNumber = startSequenceNumber; startCommand = enet_peer_queue_incoming_command (peer, & hostCommand, packet, fragmentCount); if (startCommand == NULL) return -1; } if ((startCommand -> fragments [fragmentNumber / 32] & (1 << (fragmentNumber % 32))) == 0) { -- startCommand -> fragmentsRemaining; startCommand -> fragments [fragmentNumber / 32] |= (1 << (fragmentNumber % 32)); if (fragmentOffset + fragmentLength > startCommand -> packet -> dataLength) fragmentLength = startCommand -> packet -> dataLength - fragmentOffset; memcpy (startCommand -> packet -> data + fragmentOffset, (enet_uint8 *) command + sizeof (ENetProtocolSendFragment), fragmentLength); if (startCommand -> fragmentsRemaining <= 0) enet_peer_dispatch_incoming_reliable_commands (peer, channel); } return 0; } static int enet_protocol_handle_send_unreliable_fragment (ENetHost * host, ENetPeer * peer, const ENetProtocol * command, enet_uint8 ** currentData) { enet_uint32 fragmentNumber, fragmentCount, fragmentOffset, fragmentLength, reliableSequenceNumber, startSequenceNumber, totalLength; enet_uint16 reliableWindow, currentWindow; ENetChannel * channel; ENetListIterator currentCommand; ENetIncomingCommand * startCommand = NULL; if (command -> header.channelID >= peer -> channelCount || (peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER)) return -1; fragmentLength = ENET_NET_TO_HOST_16 (command -> sendFragment.dataLength); * currentData += fragmentLength; if (fragmentLength > ENET_PROTOCOL_MAXIMUM_PACKET_SIZE || * currentData < host -> receivedData || * currentData > & host -> receivedData [host -> receivedDataLength]) return -1; channel = & peer -> channels [command -> header.channelID]; reliableSequenceNumber = command -> header.reliableSequenceNumber; startSequenceNumber = ENET_NET_TO_HOST_16 (command -> sendFragment.startSequenceNumber); reliableWindow = reliableSequenceNumber / ENET_PEER_RELIABLE_WINDOW_SIZE; currentWindow = channel -> incomingReliableSequenceNumber / ENET_PEER_RELIABLE_WINDOW_SIZE; if (reliableSequenceNumber < channel -> incomingReliableSequenceNumber) reliableWindow += ENET_PEER_RELIABLE_WINDOWS; if (reliableWindow < currentWindow || reliableWindow >= currentWindow + ENET_PEER_FREE_RELIABLE_WINDOWS - 1) return 0; if (reliableSequenceNumber == channel -> incomingReliableSequenceNumber && startSequenceNumber <= channel -> incomingUnreliableSequenceNumber) return 0; fragmentNumber = ENET_NET_TO_HOST_32 (command -> sendFragment.fragmentNumber); fragmentCount = ENET_NET_TO_HOST_32 (command -> sendFragment.fragmentCount); fragmentOffset = ENET_NET_TO_HOST_32 (command -> sendFragment.fragmentOffset); totalLength = ENET_NET_TO_HOST_32 (command -> sendFragment.totalLength); if (fragmentCount > ENET_PROTOCOL_MAXIMUM_FRAGMENT_COUNT || fragmentNumber >= fragmentCount || totalLength > ENET_PROTOCOL_MAXIMUM_PACKET_SIZE || fragmentOffset >= totalLength || fragmentLength > totalLength - fragmentOffset) return -1; for (currentCommand = enet_list_previous (enet_list_end (& channel -> incomingUnreliableCommands)); currentCommand != enet_list_end (& channel -> incomingUnreliableCommands); currentCommand = enet_list_previous (currentCommand)) { ENetIncomingCommand * incomingCommand = (ENetIncomingCommand *) currentCommand; if (reliableSequenceNumber >= channel -> incomingReliableSequenceNumber) { if (incomingCommand -> reliableSequenceNumber < channel -> incomingReliableSequenceNumber) continue; } else if (incomingCommand -> reliableSequenceNumber >= channel -> incomingReliableSequenceNumber) break; if (incomingCommand -> reliableSequenceNumber < reliableSequenceNumber) break; if (incomingCommand -> reliableSequenceNumber > reliableSequenceNumber) continue; if (incomingCommand -> unreliableSequenceNumber <= startSequenceNumber) { if (incomingCommand -> unreliableSequenceNumber < startSequenceNumber) break; if ((incomingCommand -> command.header.command & ENET_PROTOCOL_COMMAND_MASK) != ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE_FRAGMENT || totalLength != incomingCommand -> packet -> dataLength || fragmentCount != incomingCommand -> fragmentCount) return -1; startCommand = incomingCommand; break; } } if (startCommand == NULL) { ENetPacket * packet = enet_packet_create (NULL, totalLength, ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT); if (packet == NULL) return -1; startCommand = enet_peer_queue_incoming_command (peer, command, packet, fragmentCount); if (startCommand == NULL) return -1; } if ((startCommand -> fragments [fragmentNumber / 32] & (1 << (fragmentNumber % 32))) == 0) { -- startCommand -> fragmentsRemaining; startCommand -> fragments [fragmentNumber / 32] |= (1 << (fragmentNumber % 32)); if (fragmentOffset + fragmentLength > startCommand -> packet -> dataLength) fragmentLength = startCommand -> packet -> dataLength - fragmentOffset; memcpy (startCommand -> packet -> data + fragmentOffset, (enet_uint8 *) command + sizeof (ENetProtocolSendFragment), fragmentLength); if (startCommand -> fragmentsRemaining <= 0) enet_peer_dispatch_incoming_unreliable_commands (peer, channel); } return 0; } static int enet_protocol_handle_ping (ENetHost * host, ENetPeer * peer, const ENetProtocol * command) { return 0; } static int enet_protocol_handle_bandwidth_limit (ENetHost * host, ENetPeer * peer, const ENetProtocol * command) { peer -> incomingBandwidth = ENET_NET_TO_HOST_32 (command -> bandwidthLimit.incomingBandwidth); peer -> outgoingBandwidth = ENET_NET_TO_HOST_32 (command -> bandwidthLimit.outgoingBandwidth); if (peer -> incomingBandwidth == 0 && host -> outgoingBandwidth == 0) peer -> windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE; else peer -> windowSize = (ENET_MIN (peer -> incomingBandwidth, host -> outgoingBandwidth) / ENET_PEER_WINDOW_SIZE_SCALE) * ENET_PROTOCOL_MINIMUM_WINDOW_SIZE; if (peer -> windowSize < ENET_PROTOCOL_MINIMUM_WINDOW_SIZE) peer -> windowSize = ENET_PROTOCOL_MINIMUM_WINDOW_SIZE; else if (peer -> windowSize > ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE) peer -> windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE; return 0; } static int enet_protocol_handle_throttle_configure (ENetHost * host, ENetPeer * peer, const ENetProtocol * command) { peer -> packetThrottleInterval = ENET_NET_TO_HOST_32 (command -> throttleConfigure.packetThrottleInterval); peer -> packetThrottleAcceleration = ENET_NET_TO_HOST_32 (command -> throttleConfigure.packetThrottleAcceleration); peer -> packetThrottleDeceleration = ENET_NET_TO_HOST_32 (command -> throttleConfigure.packetThrottleDeceleration); return 0; } static int enet_protocol_handle_disconnect (ENetHost * host, ENetPeer * peer, const ENetProtocol * command) { if (peer -> state == ENET_PEER_STATE_ZOMBIE || peer -> state == ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT) return 0; enet_peer_reset_queues (peer); if (peer -> state == ENET_PEER_STATE_CONNECTION_SUCCEEDED || peer -> state == ENET_PEER_STATE_DISCONNECTING) enet_protocol_dispatch_state (host, peer, ENET_PEER_STATE_ZOMBIE); else if (peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER) { if (peer -> state == ENET_PEER_STATE_CONNECTION_PENDING) host -> recalculateBandwidthLimits = 1; enet_peer_reset (peer); } else if (command -> header.command & ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE) peer -> state = ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT; else enet_protocol_dispatch_state (host, peer, ENET_PEER_STATE_ZOMBIE); if (peer -> state != ENET_PEER_STATE_DISCONNECTED) peer -> eventData = ENET_NET_TO_HOST_32 (command -> disconnect.data); return 0; } static int enet_protocol_handle_acknowledge (ENetHost * host, ENetEvent * event, ENetPeer * peer, const ENetProtocol * command) { enet_uint32 roundTripTime, receivedSentTime, receivedReliableSequenceNumber; ENetProtocolCommand commandNumber; receivedSentTime = ENET_NET_TO_HOST_16 (command -> acknowledge.receivedSentTime); receivedSentTime |= host -> serviceTime & 0xFFFF0000; if ((receivedSentTime & 0x8000) > (host -> serviceTime & 0x8000)) receivedSentTime -= 0x10000; if (ENET_TIME_LESS (host -> serviceTime, receivedSentTime)) return 0; peer -> lastReceiveTime = host -> serviceTime; peer -> earliestTimeout = 0; roundTripTime = ENET_TIME_DIFFERENCE (host -> serviceTime, receivedSentTime); enet_peer_throttle (peer, roundTripTime); peer -> roundTripTimeVariance -= peer -> roundTripTimeVariance / 4; if (roundTripTime >= peer -> roundTripTime) { peer -> roundTripTime += (roundTripTime - peer -> roundTripTime) / 8; peer -> roundTripTimeVariance += (roundTripTime - peer -> roundTripTime) / 4; } else { peer -> roundTripTime -= (peer -> roundTripTime - roundTripTime) / 8; peer -> roundTripTimeVariance += (peer -> roundTripTime - roundTripTime) / 4; } if (peer -> roundTripTime < peer -> lowestRoundTripTime) peer -> lowestRoundTripTime = peer -> roundTripTime; if (peer -> roundTripTimeVariance > peer -> highestRoundTripTimeVariance) peer -> highestRoundTripTimeVariance = peer -> roundTripTimeVariance; if (peer -> packetThrottleEpoch == 0 || ENET_TIME_DIFFERENCE (host -> serviceTime, peer -> packetThrottleEpoch) >= peer -> packetThrottleInterval) { peer -> lastRoundTripTime = peer -> lowestRoundTripTime; peer -> lastRoundTripTimeVariance = peer -> highestRoundTripTimeVariance; peer -> lowestRoundTripTime = peer -> roundTripTime; peer -> highestRoundTripTimeVariance = peer -> roundTripTimeVariance; peer -> packetThrottleEpoch = host -> serviceTime; } receivedReliableSequenceNumber = ENET_NET_TO_HOST_16 (command -> acknowledge.receivedReliableSequenceNumber); commandNumber = enet_protocol_remove_sent_reliable_command (peer, receivedReliableSequenceNumber, command -> header.channelID); switch (peer -> state) { case ENET_PEER_STATE_ACKNOWLEDGING_CONNECT: if (commandNumber != ENET_PROTOCOL_COMMAND_VERIFY_CONNECT) return -1; enet_protocol_notify_connect (host, peer, event); break; case ENET_PEER_STATE_DISCONNECTING: if (commandNumber != ENET_PROTOCOL_COMMAND_DISCONNECT) return -1; enet_protocol_notify_disconnect (host, peer, event); break; case ENET_PEER_STATE_DISCONNECT_LATER: if (enet_list_empty (& peer -> outgoingReliableCommands) && enet_list_empty (& peer -> outgoingUnreliableCommands) && enet_list_empty (& peer -> sentReliableCommands)) enet_peer_disconnect (peer, peer -> eventData); break; default: break; } return 0; } static int enet_protocol_handle_verify_connect (ENetHost * host, ENetEvent * event, ENetPeer * peer, const ENetProtocol * command) { enet_uint32 mtu, windowSize; size_t channelCount; if (peer -> state != ENET_PEER_STATE_CONNECTING) return 0; channelCount = ENET_NET_TO_HOST_32 (command -> verifyConnect.channelCount); if (channelCount < ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT || channelCount > ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT || ENET_NET_TO_HOST_32 (command -> verifyConnect.packetThrottleInterval) != peer -> packetThrottleInterval || ENET_NET_TO_HOST_32 (command -> verifyConnect.packetThrottleAcceleration) != peer -> packetThrottleAcceleration || ENET_NET_TO_HOST_32 (command -> verifyConnect.packetThrottleDeceleration) != peer -> packetThrottleDeceleration || command -> verifyConnect.connectID != peer -> connectID) { peer -> eventData = 0; enet_protocol_dispatch_state (host, peer, ENET_PEER_STATE_ZOMBIE); return -1; } enet_protocol_remove_sent_reliable_command (peer, 1, 0xFF); if (channelCount < peer -> channelCount) peer -> channelCount = channelCount; peer -> outgoingPeerID = ENET_NET_TO_HOST_16 (command -> verifyConnect.outgoingPeerID); peer -> incomingSessionID = command -> verifyConnect.incomingSessionID; peer -> outgoingSessionID = command -> verifyConnect.outgoingSessionID; mtu = ENET_NET_TO_HOST_32 (command -> verifyConnect.mtu); if (mtu < ENET_PROTOCOL_MINIMUM_MTU) mtu = ENET_PROTOCOL_MINIMUM_MTU; else if (mtu > ENET_PROTOCOL_MAXIMUM_MTU) mtu = ENET_PROTOCOL_MAXIMUM_MTU; if (mtu < peer -> mtu) peer -> mtu = mtu; windowSize = ENET_NET_TO_HOST_32 (command -> verifyConnect.windowSize); if (windowSize < ENET_PROTOCOL_MINIMUM_WINDOW_SIZE) windowSize = ENET_PROTOCOL_MINIMUM_WINDOW_SIZE; if (windowSize > ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE) windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE; if (windowSize < peer -> windowSize) peer -> windowSize = windowSize; peer -> incomingBandwidth = ENET_NET_TO_HOST_32 (command -> verifyConnect.incomingBandwidth); peer -> outgoingBandwidth = ENET_NET_TO_HOST_32 (command -> verifyConnect.outgoingBandwidth); enet_protocol_notify_connect (host, peer, event); return 0; } static int enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event) { ENetProtocolHeader * header; ENetProtocol * command; ENetPeer * peer; enet_uint8 * currentData; size_t headerSize; enet_uint16 peerID, flags; enet_uint8 sessionID; if (host -> receivedDataLength < (size_t) & ((ENetProtocolHeader *) 0) -> sentTime) return 0; header = (ENetProtocolHeader *) host -> receivedData; peerID = ENET_NET_TO_HOST_16 (header -> peerID); sessionID = (peerID & ENET_PROTOCOL_HEADER_SESSION_MASK) >> ENET_PROTOCOL_HEADER_SESSION_SHIFT; flags = peerID & ENET_PROTOCOL_HEADER_FLAG_MASK; peerID &= ~ (ENET_PROTOCOL_HEADER_FLAG_MASK | ENET_PROTOCOL_HEADER_SESSION_MASK); headerSize = (flags & ENET_PROTOCOL_HEADER_FLAG_SENT_TIME ? sizeof (ENetProtocolHeader) : (size_t) & ((ENetProtocolHeader *) 0) -> sentTime); if (host -> checksum != NULL) headerSize += sizeof (enet_uint32); if (peerID == ENET_PROTOCOL_MAXIMUM_PEER_ID) peer = NULL; else if (peerID >= host -> peerCount) return 0; else { peer = & host -> peers [peerID]; if (peer -> state == ENET_PEER_STATE_DISCONNECTED || peer -> state == ENET_PEER_STATE_ZOMBIE || ((host -> receivedAddress.host != peer -> address.host || host -> receivedAddress.port != peer -> address.port) && peer -> address.host != ENET_HOST_BROADCAST) || (peer -> outgoingPeerID < ENET_PROTOCOL_MAXIMUM_PEER_ID && sessionID != peer -> incomingSessionID)) return 0; } if (flags & ENET_PROTOCOL_HEADER_FLAG_COMPRESSED) { size_t originalSize; if (host -> compressor.context == NULL || host -> compressor.decompress == NULL) return 0; originalSize = host -> compressor.decompress (host -> compressor.context, host -> receivedData + headerSize, host -> receivedDataLength - headerSize, host -> packetData [1] + headerSize, sizeof (host -> packetData [1]) - headerSize); if (originalSize <= 0 || originalSize > sizeof (host -> packetData [1]) - headerSize) return 0; memcpy (host -> packetData [1], header, headerSize); host -> receivedData = host -> packetData [1]; host -> receivedDataLength = headerSize + originalSize; } if (host -> checksum != NULL) { enet_uint32 * checksum = (enet_uint32 *) & host -> receivedData [headerSize - sizeof (enet_uint32)], desiredChecksum = * checksum; ENetBuffer buffer; * checksum = peer != NULL ? peer -> connectID : 0; buffer.data = host -> receivedData; buffer.dataLength = host -> receivedDataLength; if (host -> checksum (& buffer, 1) != desiredChecksum) return 0; } if (peer != NULL) { peer -> address.host = host -> receivedAddress.host; peer -> address.port = host -> receivedAddress.port; peer -> incomingDataTotal += host -> receivedDataLength; } currentData = host -> receivedData + headerSize; while (currentData < & host -> receivedData [host -> receivedDataLength]) { enet_uint8 commandNumber; size_t commandSize; command = (ENetProtocol *) currentData; if (currentData + sizeof (ENetProtocolCommandHeader) > & host -> receivedData [host -> receivedDataLength]) break; commandNumber = command -> header.command & ENET_PROTOCOL_COMMAND_MASK; if (commandNumber >= ENET_PROTOCOL_COMMAND_COUNT) break; commandSize = commandSizes [commandNumber]; if (commandSize == 0 || currentData + commandSize > & host -> receivedData [host -> receivedDataLength]) break; currentData += commandSize; if (peer == NULL && commandNumber != ENET_PROTOCOL_COMMAND_CONNECT) break; command -> header.reliableSequenceNumber = ENET_NET_TO_HOST_16 (command -> header.reliableSequenceNumber); switch (command -> header.command & ENET_PROTOCOL_COMMAND_MASK) { case ENET_PROTOCOL_COMMAND_ACKNOWLEDGE: if (enet_protocol_handle_acknowledge (host, event, peer, command)) goto commandError; break; case ENET_PROTOCOL_COMMAND_CONNECT: peer = enet_protocol_handle_connect (host, header, command); if (peer == NULL) goto commandError; break; case ENET_PROTOCOL_COMMAND_VERIFY_CONNECT: if (enet_protocol_handle_verify_connect (host, event, peer, command)) goto commandError; break; case ENET_PROTOCOL_COMMAND_DISCONNECT: if (enet_protocol_handle_disconnect (host, peer, command)) goto commandError; break; case ENET_PROTOCOL_COMMAND_PING: if (enet_protocol_handle_ping (host, peer, command)) goto commandError; break; case ENET_PROTOCOL_COMMAND_SEND_RELIABLE: if (enet_protocol_handle_send_reliable (host, peer, command, & currentData)) goto commandError; break; case ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE: if (enet_protocol_handle_send_unreliable (host, peer, command, & currentData)) goto commandError; break; case ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED: if (enet_protocol_handle_send_unsequenced (host, peer, command, & currentData)) goto commandError; break; case ENET_PROTOCOL_COMMAND_SEND_FRAGMENT: if (enet_protocol_handle_send_fragment (host, peer, command, & currentData)) goto commandError; break; case ENET_PROTOCOL_COMMAND_BANDWIDTH_LIMIT: if (enet_protocol_handle_bandwidth_limit (host, peer, command)) goto commandError; break; case ENET_PROTOCOL_COMMAND_THROTTLE_CONFIGURE: if (enet_protocol_handle_throttle_configure (host, peer, command)) goto commandError; break; case ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE_FRAGMENT: if (enet_protocol_handle_send_unreliable_fragment (host, peer, command, & currentData)) goto commandError; break; default: goto commandError; } if (peer != NULL && (command -> header.command & ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE) != 0) { enet_uint16 sentTime; if (! (flags & ENET_PROTOCOL_HEADER_FLAG_SENT_TIME)) break; sentTime = ENET_NET_TO_HOST_16 (header -> sentTime); switch (peer -> state) { case ENET_PEER_STATE_DISCONNECTING: case ENET_PEER_STATE_ACKNOWLEDGING_CONNECT: break; case ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT: if ((command -> header.command & ENET_PROTOCOL_COMMAND_MASK) == ENET_PROTOCOL_COMMAND_DISCONNECT) enet_peer_queue_acknowledgement (peer, command, sentTime); break; default: enet_peer_queue_acknowledgement (peer, command, sentTime); break; } } } commandError: if (event != NULL && event -> type != ENET_EVENT_TYPE_NONE) return 1; return 0; } static int enet_protocol_receive_incoming_commands (ENetHost * host, ENetEvent * event) { for (;;) { int receivedLength; ENetBuffer buffer; buffer.data = host -> packetData [0]; buffer.dataLength = sizeof (host -> packetData [0]); receivedLength = enet_socket_receive (host -> socket, & host -> receivedAddress, & buffer, 1); if (receivedLength < 0) return -1; if (receivedLength == 0) return 0; host -> receivedData = host -> packetData [0]; host -> receivedDataLength = receivedLength; host -> totalReceivedData += receivedLength; host -> totalReceivedPackets ++; if (host -> intercept != NULL) { switch (host -> intercept (host, event)) { case 1: if (event != NULL && event -> type != ENET_EVENT_TYPE_NONE) return 1; continue; case -1: return -1; default: break; } } switch (enet_protocol_handle_incoming_commands (host, event)) { case 1: return 1; case -1: return -1; default: break; } } return -1; } static void enet_protocol_send_acknowledgements (ENetHost * host, ENetPeer * peer) { ENetProtocol * command = & host -> commands [host -> commandCount]; ENetBuffer * buffer = & host -> buffers [host -> bufferCount]; ENetAcknowledgement * acknowledgement; ENetListIterator currentAcknowledgement; currentAcknowledgement = enet_list_begin (& peer -> acknowledgements); while (currentAcknowledgement != enet_list_end (& peer -> acknowledgements)) { if (command >= & host -> commands [sizeof (host -> commands) / sizeof (ENetProtocol)] || buffer >= & host -> buffers [sizeof (host -> buffers) / sizeof (ENetBuffer)] || peer -> mtu - host -> packetSize < sizeof (ENetProtocolAcknowledge)) { host -> continueSending = 1; break; } acknowledgement = (ENetAcknowledgement *) currentAcknowledgement; currentAcknowledgement = enet_list_next (currentAcknowledgement); buffer -> data = command; buffer -> dataLength = sizeof (ENetProtocolAcknowledge); host -> packetSize += buffer -> dataLength; command -> header.command = ENET_PROTOCOL_COMMAND_ACKNOWLEDGE; command -> header.channelID = acknowledgement -> command.header.channelID; command -> acknowledge.receivedReliableSequenceNumber = ENET_HOST_TO_NET_16 (acknowledgement -> command.header.reliableSequenceNumber); command -> acknowledge.receivedSentTime = ENET_HOST_TO_NET_16 (acknowledgement -> sentTime); if ((acknowledgement -> command.header.command & ENET_PROTOCOL_COMMAND_MASK) == ENET_PROTOCOL_COMMAND_DISCONNECT) enet_protocol_dispatch_state (host, peer, ENET_PEER_STATE_ZOMBIE); enet_list_remove (& acknowledgement -> acknowledgementList); enet_free (acknowledgement); ++ command; ++ buffer; } host -> commandCount = command - host -> commands; host -> bufferCount = buffer - host -> buffers; } static void enet_protocol_send_unreliable_outgoing_commands (ENetHost * host, ENetPeer * peer) { ENetProtocol * command = & host -> commands [host -> commandCount]; ENetBuffer * buffer = & host -> buffers [host -> bufferCount]; ENetOutgoingCommand * outgoingCommand; ENetListIterator currentCommand; currentCommand = enet_list_begin (& peer -> outgoingUnreliableCommands); while (currentCommand != enet_list_end (& peer -> outgoingUnreliableCommands)) { size_t commandSize; outgoingCommand = (ENetOutgoingCommand *) currentCommand; commandSize = commandSizes [outgoingCommand -> command.header.command & ENET_PROTOCOL_COMMAND_MASK]; if (command >= & host -> commands [sizeof (host -> commands) / sizeof (ENetProtocol)] || buffer + 1 >= & host -> buffers [sizeof (host -> buffers) / sizeof (ENetBuffer)] || peer -> mtu - host -> packetSize < commandSize || (outgoingCommand -> packet != NULL && peer -> mtu - host -> packetSize < commandSize + outgoingCommand -> fragmentLength)) { host -> continueSending = 1; break; } currentCommand = enet_list_next (currentCommand); if (outgoingCommand -> packet != NULL && outgoingCommand -> fragmentOffset == 0) { peer -> packetThrottleCounter += ENET_PEER_PACKET_THROTTLE_COUNTER; peer -> packetThrottleCounter %= ENET_PEER_PACKET_THROTTLE_SCALE; if (peer -> packetThrottleCounter > peer -> packetThrottle) { enet_uint16 reliableSequenceNumber = outgoingCommand -> reliableSequenceNumber, unreliableSequenceNumber = outgoingCommand -> unreliableSequenceNumber; for (;;) { -- outgoingCommand -> packet -> referenceCount; if (outgoingCommand -> packet -> referenceCount == 0) enet_packet_destroy (outgoingCommand -> packet); enet_list_remove (& outgoingCommand -> outgoingCommandList); enet_free (outgoingCommand); if (currentCommand == enet_list_end (& peer -> outgoingUnreliableCommands)) break; outgoingCommand = (ENetOutgoingCommand *) currentCommand; if (outgoingCommand -> reliableSequenceNumber != reliableSequenceNumber || outgoingCommand -> unreliableSequenceNumber != unreliableSequenceNumber) break; currentCommand = enet_list_next (currentCommand); } continue; } } buffer -> data = command; buffer -> dataLength = commandSize; host -> packetSize += buffer -> dataLength; * command = outgoingCommand -> command; enet_list_remove (& outgoingCommand -> outgoingCommandList); if (outgoingCommand -> packet != NULL) { ++ buffer; buffer -> data = outgoingCommand -> packet -> data + outgoingCommand -> fragmentOffset; buffer -> dataLength = outgoingCommand -> fragmentLength; host -> packetSize += buffer -> dataLength; enet_list_insert (enet_list_end (& peer -> sentUnreliableCommands), outgoingCommand); } else enet_free (outgoingCommand); ++ command; ++ buffer; } host -> commandCount = command - host -> commands; host -> bufferCount = buffer - host -> buffers; if (peer -> state == ENET_PEER_STATE_DISCONNECT_LATER && enet_list_empty (& peer -> outgoingReliableCommands) && enet_list_empty (& peer -> outgoingUnreliableCommands) && enet_list_empty (& peer -> sentReliableCommands)) enet_peer_disconnect (peer, peer -> eventData); } static int enet_protocol_check_timeouts (ENetHost * host, ENetPeer * peer, ENetEvent * event) { ENetOutgoingCommand * outgoingCommand; ENetListIterator currentCommand, insertPosition; currentCommand = enet_list_begin (& peer -> sentReliableCommands); insertPosition = enet_list_begin (& peer -> outgoingReliableCommands); while (currentCommand != enet_list_end (& peer -> sentReliableCommands)) { outgoingCommand = (ENetOutgoingCommand *) currentCommand; currentCommand = enet_list_next (currentCommand); if (ENET_TIME_DIFFERENCE (host -> serviceTime, outgoingCommand -> sentTime) < outgoingCommand -> roundTripTimeout) continue; if (peer -> earliestTimeout == 0 || ENET_TIME_LESS (outgoingCommand -> sentTime, peer -> earliestTimeout)) peer -> earliestTimeout = outgoingCommand -> sentTime; if (peer -> earliestTimeout != 0 && (ENET_TIME_DIFFERENCE (host -> serviceTime, peer -> earliestTimeout) >= peer -> timeoutMaximum || (outgoingCommand -> roundTripTimeout >= outgoingCommand -> roundTripTimeoutLimit && ENET_TIME_DIFFERENCE (host -> serviceTime, peer -> earliestTimeout) >= peer -> timeoutMinimum))) { enet_protocol_notify_disconnect (host, peer, event); return 1; } if (outgoingCommand -> packet != NULL) peer -> reliableDataInTransit -= outgoingCommand -> fragmentLength; ++ peer -> packetsLost; outgoingCommand -> roundTripTimeout *= 2; enet_list_insert (insertPosition, enet_list_remove (& outgoingCommand -> outgoingCommandList)); if (currentCommand == enet_list_begin (& peer -> sentReliableCommands) && ! enet_list_empty (& peer -> sentReliableCommands)) { outgoingCommand = (ENetOutgoingCommand *) currentCommand; peer -> nextTimeout = outgoingCommand -> sentTime + outgoingCommand -> roundTripTimeout; } } return 0; } static int enet_protocol_send_reliable_outgoing_commands (ENetHost * host, ENetPeer * peer) { ENetProtocol * command = & host -> commands [host -> commandCount]; ENetBuffer * buffer = & host -> buffers [host -> bufferCount]; ENetOutgoingCommand * outgoingCommand; ENetListIterator currentCommand; ENetChannel *channel; enet_uint16 reliableWindow; size_t commandSize; int windowExceeded = 0, windowWrap = 0, canPing = 1; currentCommand = enet_list_begin (& peer -> outgoingReliableCommands); while (currentCommand != enet_list_end (& peer -> outgoingReliableCommands)) { outgoingCommand = (ENetOutgoingCommand *) currentCommand; channel = outgoingCommand -> command.header.channelID < peer -> channelCount ? & peer -> channels [outgoingCommand -> command.header.channelID] : NULL; reliableWindow = outgoingCommand -> reliableSequenceNumber / ENET_PEER_RELIABLE_WINDOW_SIZE; if (channel != NULL) { if (! windowWrap && outgoingCommand -> sendAttempts < 1 && ! (outgoingCommand -> reliableSequenceNumber % ENET_PEER_RELIABLE_WINDOW_SIZE) && (channel -> reliableWindows [(reliableWindow + ENET_PEER_RELIABLE_WINDOWS - 1) % ENET_PEER_RELIABLE_WINDOWS] >= ENET_PEER_RELIABLE_WINDOW_SIZE || channel -> usedReliableWindows & ((((1 << ENET_PEER_FREE_RELIABLE_WINDOWS) - 1) << reliableWindow) | (((1 << ENET_PEER_FREE_RELIABLE_WINDOWS) - 1) >> (ENET_PEER_RELIABLE_WINDOW_SIZE - reliableWindow))))) windowWrap = 1; if (windowWrap) { currentCommand = enet_list_next (currentCommand); continue; } } if (outgoingCommand -> packet != NULL) { if (! windowExceeded) { enet_uint32 windowSize = (peer -> packetThrottle * peer -> windowSize) / ENET_PEER_PACKET_THROTTLE_SCALE; if (peer -> reliableDataInTransit + outgoingCommand -> fragmentLength > ENET_MAX (windowSize, peer -> mtu)) windowExceeded = 1; } if (windowExceeded) { currentCommand = enet_list_next (currentCommand); continue; } } canPing = 0; commandSize = commandSizes [outgoingCommand -> command.header.command & ENET_PROTOCOL_COMMAND_MASK]; if (command >= & host -> commands [sizeof (host -> commands) / sizeof (ENetProtocol)] || buffer + 1 >= & host -> buffers [sizeof (host -> buffers) / sizeof (ENetBuffer)] || peer -> mtu - host -> packetSize < commandSize || (outgoingCommand -> packet != NULL && (enet_uint16) (peer -> mtu - host -> packetSize) < (enet_uint16) (commandSize + outgoingCommand -> fragmentLength))) { host -> continueSending = 1; break; } currentCommand = enet_list_next (currentCommand); if (channel != NULL && outgoingCommand -> sendAttempts < 1) { channel -> usedReliableWindows |= 1 << reliableWindow; ++ channel -> reliableWindows [reliableWindow]; } ++ outgoingCommand -> sendAttempts; if (outgoingCommand -> roundTripTimeout == 0) { outgoingCommand -> roundTripTimeout = peer -> roundTripTime + 4 * peer -> roundTripTimeVariance; outgoingCommand -> roundTripTimeoutLimit = peer -> timeoutLimit * outgoingCommand -> roundTripTimeout; } if (enet_list_empty (& peer -> sentReliableCommands)) peer -> nextTimeout = host -> serviceTime + outgoingCommand -> roundTripTimeout; enet_list_insert (enet_list_end (& peer -> sentReliableCommands), enet_list_remove (& outgoingCommand -> outgoingCommandList)); outgoingCommand -> sentTime = host -> serviceTime; buffer -> data = command; buffer -> dataLength = commandSize; host -> packetSize += buffer -> dataLength; host -> headerFlags |= ENET_PROTOCOL_HEADER_FLAG_SENT_TIME; * command = outgoingCommand -> command; if (outgoingCommand -> packet != NULL) { ++ buffer; buffer -> data = outgoingCommand -> packet -> data + outgoingCommand -> fragmentOffset; buffer -> dataLength = outgoingCommand -> fragmentLength; host -> packetSize += outgoingCommand -> fragmentLength; peer -> reliableDataInTransit += outgoingCommand -> fragmentLength; } ++ peer -> packetsSent; ++ command; ++ buffer; } host -> commandCount = command - host -> commands; host -> bufferCount = buffer - host -> buffers; return canPing; } static int enet_protocol_send_outgoing_commands (ENetHost * host, ENetEvent * event, int checkForTimeouts) { enet_uint8 headerData [sizeof (ENetProtocolHeader) + sizeof (enet_uint32)]; ENetProtocolHeader * header = (ENetProtocolHeader *) headerData; ENetPeer * currentPeer; int sentLength; size_t shouldCompress = 0; host -> continueSending = 1; while (host -> continueSending) for (host -> continueSending = 0, currentPeer = host -> peers; currentPeer < & host -> peers [host -> peerCount]; ++ currentPeer) { if (currentPeer -> state == ENET_PEER_STATE_DISCONNECTED || currentPeer -> state == ENET_PEER_STATE_ZOMBIE) continue; host -> headerFlags = 0; host -> commandCount = 0; host -> bufferCount = 1; host -> packetSize = sizeof (ENetProtocolHeader); if (! enet_list_empty (& currentPeer -> acknowledgements)) enet_protocol_send_acknowledgements (host, currentPeer); if (checkForTimeouts != 0 && ! enet_list_empty (& currentPeer -> sentReliableCommands) && ENET_TIME_GREATER_EQUAL (host -> serviceTime, currentPeer -> nextTimeout) && enet_protocol_check_timeouts (host, currentPeer, event) == 1) { if (event != NULL && event -> type != ENET_EVENT_TYPE_NONE) return 1; else continue; } if ((enet_list_empty (& currentPeer -> outgoingReliableCommands) || enet_protocol_send_reliable_outgoing_commands (host, currentPeer)) && enet_list_empty (& currentPeer -> sentReliableCommands) && ENET_TIME_DIFFERENCE (host -> serviceTime, currentPeer -> lastReceiveTime) >= currentPeer -> pingInterval && currentPeer -> mtu - host -> packetSize >= sizeof (ENetProtocolPing)) { enet_peer_ping (currentPeer); enet_protocol_send_reliable_outgoing_commands (host, currentPeer); } if (! enet_list_empty (& currentPeer -> outgoingUnreliableCommands)) enet_protocol_send_unreliable_outgoing_commands (host, currentPeer); if (host -> commandCount == 0) continue; if (currentPeer -> packetLossEpoch == 0) currentPeer -> packetLossEpoch = host -> serviceTime; else if (ENET_TIME_DIFFERENCE (host -> serviceTime, currentPeer -> packetLossEpoch) >= ENET_PEER_PACKET_LOSS_INTERVAL && currentPeer -> packetsSent > 0) { enet_uint32 packetLoss = currentPeer -> packetsLost * ENET_PEER_PACKET_LOSS_SCALE / currentPeer -> packetsSent; #ifdef ENET_DEBUG #ifdef WIN32 printf ( #else fprintf (stderr, #endif "peer %u: %f%%+-%f%% packet loss, %u+-%u ms round trip time, %f%% throttle, %u/%u outgoing, %u/%u incoming\n", currentPeer -> incomingPeerID, currentPeer -> packetLoss / (float) ENET_PEER_PACKET_LOSS_SCALE, currentPeer -> packetLossVariance / (float) ENET_PEER_PACKET_LOSS_SCALE, currentPeer -> roundTripTime, currentPeer -> roundTripTimeVariance, currentPeer -> packetThrottle / (float) ENET_PEER_PACKET_THROTTLE_SCALE, enet_list_size (& currentPeer -> outgoingReliableCommands), enet_list_size (& currentPeer -> outgoingUnreliableCommands), currentPeer -> channels != NULL ? enet_list_size (& currentPeer -> channels -> incomingReliableCommands) : 0, currentPeer -> channels != NULL ? enet_list_size (& currentPeer -> channels -> incomingUnreliableCommands) : 0); #endif currentPeer -> packetLossVariance -= currentPeer -> packetLossVariance / 4; if (packetLoss >= currentPeer -> packetLoss) { currentPeer -> packetLoss += (packetLoss - currentPeer -> packetLoss) / 8; currentPeer -> packetLossVariance += (packetLoss - currentPeer -> packetLoss) / 4; } else { currentPeer -> packetLoss -= (currentPeer -> packetLoss - packetLoss) / 8; currentPeer -> packetLossVariance += (currentPeer -> packetLoss - packetLoss) / 4; } currentPeer -> packetLossEpoch = host -> serviceTime; currentPeer -> packetsSent = 0; currentPeer -> packetsLost = 0; } host -> buffers -> data = headerData; if (host -> headerFlags & ENET_PROTOCOL_HEADER_FLAG_SENT_TIME) { header -> sentTime = ENET_HOST_TO_NET_16 (host -> serviceTime & 0xFFFF); host -> buffers -> dataLength = sizeof (ENetProtocolHeader); } else host -> buffers -> dataLength = (size_t) & ((ENetProtocolHeader *) 0) -> sentTime; shouldCompress = 0; if (host -> compressor.context != NULL && host -> compressor.compress != NULL) { size_t originalSize = host -> packetSize - sizeof(ENetProtocolHeader), compressedSize = host -> compressor.compress (host -> compressor.context, & host -> buffers [1], host -> bufferCount - 1, originalSize, host -> packetData [1], originalSize); if (compressedSize > 0 && compressedSize < originalSize) { host -> headerFlags |= ENET_PROTOCOL_HEADER_FLAG_COMPRESSED; shouldCompress = compressedSize; #ifdef ENET_DEBUG_COMPRESS #ifdef WIN32 printf ( #else fprintf (stderr, #endif "peer %u: compressed %u -> %u (%u%%)\n", currentPeer -> incomingPeerID, originalSize, compressedSize, (compressedSize * 100) / originalSize); #endif } } if (currentPeer -> outgoingPeerID < ENET_PROTOCOL_MAXIMUM_PEER_ID) host -> headerFlags |= currentPeer -> outgoingSessionID << ENET_PROTOCOL_HEADER_SESSION_SHIFT; header -> peerID = ENET_HOST_TO_NET_16 (currentPeer -> outgoingPeerID | host -> headerFlags); if (host -> checksum != NULL) { enet_uint32 * checksum = (enet_uint32 *) & headerData [host -> buffers -> dataLength]; * checksum = currentPeer -> outgoingPeerID < ENET_PROTOCOL_MAXIMUM_PEER_ID ? currentPeer -> connectID : 0; host -> buffers -> dataLength += sizeof (enet_uint32); * checksum = host -> checksum (host -> buffers, host -> bufferCount); } if (shouldCompress > 0) { host -> buffers [1].data = host -> packetData [1]; host -> buffers [1].dataLength = shouldCompress; host -> bufferCount = 2; } currentPeer -> lastSendTime = host -> serviceTime; sentLength = enet_socket_send (host -> socket, & currentPeer -> address, host -> buffers, host -> bufferCount); enet_protocol_remove_sent_unreliable_commands (currentPeer); if (sentLength < 0) return -1; host -> totalSentData += sentLength; host -> totalSentPackets ++; } return 0; } /** Sends any queued packets on the host specified to its designated peers. @param host host to flush @remarks this function need only be used in circumstances where one wishes to send queued packets earlier than in a call to enet_host_service(). @ingroup host */ void enet_host_flush (ENetHost * host) { host -> serviceTime = enet_time_get (); enet_protocol_send_outgoing_commands (host, NULL, 0); } /** Checks for any queued events on the host and dispatches one if available. @param host host to check for events @param event an event structure where event details will be placed if available @retval > 0 if an event was dispatched @retval 0 if no events are available @retval < 0 on failure @ingroup host */ int enet_host_check_events (ENetHost * host, ENetEvent * event) { if (event == NULL) return -1; event -> type = ENET_EVENT_TYPE_NONE; event -> peer = NULL; event -> packet = NULL; return enet_protocol_dispatch_incoming_commands (host, event); } /** Waits for events on the host specified and shuttles packets between the host and its peers. @param host host to service @param event an event structure where event details will be placed if one occurs if event == NULL then no events will be delivered @param timeout number of milliseconds that ENet should wait for events @retval > 0 if an event occurred within the specified time limit @retval 0 if no event occurred @retval < 0 on failure @remarks enet_host_service should be called fairly regularly for adequate performance @ingroup host */ int enet_host_service (ENetHost * host, ENetEvent * event, enet_uint32 timeout) { enet_uint32 waitCondition; if (event != NULL) { event -> type = ENET_EVENT_TYPE_NONE; event -> peer = NULL; event -> packet = NULL; switch (enet_protocol_dispatch_incoming_commands (host, event)) { case 1: return 1; case -1: perror ("Error dispatching incoming packets"); return -1; default: break; } } host -> serviceTime = enet_time_get (); timeout += host -> serviceTime; do { if (ENET_TIME_DIFFERENCE (host -> serviceTime, host -> bandwidthThrottleEpoch) >= ENET_HOST_BANDWIDTH_THROTTLE_INTERVAL) enet_host_bandwidth_throttle (host); switch (enet_protocol_send_outgoing_commands (host, event, 1)) { case 1: return 1; case -1: perror ("Error sending outgoing packets"); return -1; default: break; } switch (enet_protocol_receive_incoming_commands (host, event)) { case 1: return 1; case -1: perror ("Error receiving incoming packets"); return -1; default: break; } switch (enet_protocol_send_outgoing_commands (host, event, 1)) { case 1: return 1; case -1: perror ("Error sending outgoing packets"); return -1; default: break; } if (event != NULL) { switch (enet_protocol_dispatch_incoming_commands (host, event)) { case 1: return 1; case -1: perror ("Error dispatching incoming packets"); return -1; default: break; } } host -> serviceTime = enet_time_get (); if (ENET_TIME_GREATER_EQUAL (host -> serviceTime, timeout)) return 0; waitCondition = ENET_SOCKET_WAIT_RECEIVE; if (enet_socket_wait (host -> socket, & waitCondition, ENET_TIME_DIFFERENCE (timeout, host -> serviceTime)) != 0) return -1; host -> serviceTime = enet_time_get (); } while (waitCondition == ENET_SOCKET_WAIT_RECEIVE); return 0; } assaultcube-1.2.0.2.1/source/enet/unix.c000066400000000000000000000251451352165075300177240ustar00rootroot00000000000000/** @file unix.c @brief ENet Unix system specific functions */ #ifndef WIN32 #include #include #include #include #include #include #include #include #include #include #define ENET_BUILDING_LIB 1 #include "enet/enet.h" #ifdef __APPLE__ #ifdef HAS_POLL #undef HAS_POLL #endif #ifndef HAS_FCNTL #define HAS_FCNTL 1 #endif #ifndef HAS_INET_PTON #define HAS_INET_PTON 1 #endif #ifndef HAS_INET_NTOP #define HAS_INET_NTOP 1 #endif #ifndef HAS_MSGHDR_FLAGS #define HAS_MSGHDR_FLAGS 1 #endif #ifndef HAS_SOCKLEN_T #define HAS_SOCKLEN_T 1 #endif #endif #ifdef HAS_FCNTL #include #endif #ifdef HAS_POLL #include #endif #ifndef HAS_SOCKLEN_T typedef int socklen_t; #endif #ifndef MSG_NOSIGNAL #define MSG_NOSIGNAL 0 #endif static enet_uint32 timeBase = 0; int enet_initialize (void) { return 0; } void enet_deinitialize (void) { } enet_uint32 enet_time_get (void) { struct timeval timeVal; gettimeofday (& timeVal, NULL); return timeVal.tv_sec * 1000 + timeVal.tv_usec / 1000 - timeBase; } void enet_time_set (enet_uint32 newTimeBase) { struct timeval timeVal; gettimeofday (& timeVal, NULL); timeBase = timeVal.tv_sec * 1000 + timeVal.tv_usec / 1000 - newTimeBase; } int enet_address_set_host (ENetAddress * address, const char * name) { struct hostent * hostEntry = NULL; #ifdef HAS_GETHOSTBYNAME_R struct hostent hostData; char buffer [2048]; int errnum; #if defined(linux) || defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) gethostbyname_r (name, & hostData, buffer, sizeof (buffer), & hostEntry, & errnum); #else hostEntry = gethostbyname_r (name, & hostData, buffer, sizeof (buffer), & errnum); #endif #else hostEntry = gethostbyname (name); #endif if (hostEntry == NULL || hostEntry -> h_addrtype != AF_INET) { #ifdef HAS_INET_PTON if (! inet_pton (AF_INET, name, & address -> host)) #else if (! inet_aton (name, (struct in_addr *) & address -> host)) #endif return -1; return 0; } address -> host = * (enet_uint32 *) hostEntry -> h_addr_list [0]; return 0; } int enet_address_get_host_ip (const ENetAddress * address, char * name, size_t nameLength) { #ifdef HAS_INET_NTOP if (inet_ntop (AF_INET, & address -> host, name, nameLength) == NULL) #else char * addr = inet_ntoa (* (struct in_addr *) & address -> host); if (addr != NULL) strncpy (name, addr, nameLength); name[nameLength - 1] = '\0'; else #endif return -1; return 0; } int enet_address_get_host (const ENetAddress * address, char * name, size_t nameLength) { struct in_addr in; struct hostent * hostEntry = NULL; #ifdef HAS_GETHOSTBYADDR_R struct hostent hostData; char buffer [2048]; int errnum; in.s_addr = address -> host; #if defined(linux) || defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) gethostbyaddr_r ((char *) & in, sizeof (struct in_addr), AF_INET, & hostData, buffer, sizeof (buffer), & hostEntry, & errnum); #else hostEntry = gethostbyaddr_r ((char *) & in, sizeof (struct in_addr), AF_INET, & hostData, buffer, sizeof (buffer), & errnum); #endif #else in.s_addr = address -> host; hostEntry = gethostbyaddr ((char *) & in, sizeof (struct in_addr), AF_INET); #endif if (hostEntry == NULL) return enet_address_get_host_ip (address, name, nameLength); strncpy (name, hostEntry -> h_name, nameLength); name[nameLength - 1] = '\0'; return 0; } int enet_socket_bind (ENetSocket socket, const ENetAddress * address) { struct sockaddr_in sin; memset (& sin, 0, sizeof (struct sockaddr_in)); sin.sin_family = AF_INET; if (address != NULL) { sin.sin_port = ENET_HOST_TO_NET_16 (address -> port); sin.sin_addr.s_addr = address -> host; } else { sin.sin_port = 0; sin.sin_addr.s_addr = INADDR_ANY; } return bind (socket, (struct sockaddr *) & sin, sizeof (struct sockaddr_in)); } int enet_socket_listen (ENetSocket socket, int backlog) { return listen (socket, backlog < 0 ? SOMAXCONN : backlog); } ENetSocket enet_socket_create (ENetSocketType type) { return socket (PF_INET, type == ENET_SOCKET_TYPE_DATAGRAM ? SOCK_DGRAM : SOCK_STREAM, 0); } int enet_socket_set_option (ENetSocket socket, ENetSocketOption option, int value) { int result = -1; switch (option) { case ENET_SOCKOPT_NONBLOCK: #ifdef HAS_FCNTL result = fcntl (socket, F_SETFL, O_NONBLOCK | fcntl (socket, F_GETFL)); #else result = ioctl (socket, FIONBIO, & value); #endif break; case ENET_SOCKOPT_BROADCAST: result = setsockopt (socket, SOL_SOCKET, SO_BROADCAST, (char *) & value, sizeof (int)); break; case ENET_SOCKOPT_REUSEADDR: result = setsockopt (socket, SOL_SOCKET, SO_REUSEADDR, (char *) & value, sizeof (int)); break; case ENET_SOCKOPT_RCVBUF: result = setsockopt (socket, SOL_SOCKET, SO_RCVBUF, (char *) & value, sizeof (int)); break; case ENET_SOCKOPT_SNDBUF: result = setsockopt (socket, SOL_SOCKET, SO_SNDBUF, (char *) & value, sizeof (int)); break; case ENET_SOCKOPT_RCVTIMEO: result = setsockopt (socket, SOL_SOCKET, SO_RCVTIMEO, (char *) & value, sizeof (int)); break; case ENET_SOCKOPT_SNDTIMEO: result = setsockopt (socket, SOL_SOCKET, SO_SNDTIMEO, (char *) & value, sizeof (int)); break; default: break; } return result == -1 ? -1 : 0; } int enet_socket_connect (ENetSocket socket, const ENetAddress * address) { struct sockaddr_in sin; int result; memset (& sin, 0, sizeof (struct sockaddr_in)); sin.sin_family = AF_INET; sin.sin_port = ENET_HOST_TO_NET_16 (address -> port); sin.sin_addr.s_addr = address -> host; result = connect (socket, (struct sockaddr *) & sin, sizeof (struct sockaddr_in)); if (result == -1 && errno == EINPROGRESS) return 0; return result; } ENetSocket enet_socket_accept (ENetSocket socket, ENetAddress * address) { int result; struct sockaddr_in sin; socklen_t sinLength = sizeof (struct sockaddr_in); result = accept (socket, address != NULL ? (struct sockaddr *) & sin : NULL, address != NULL ? & sinLength : NULL); if (result == -1) return ENET_SOCKET_NULL; if (address != NULL) { address -> host = (enet_uint32) sin.sin_addr.s_addr; address -> port = ENET_NET_TO_HOST_16 (sin.sin_port); } return result; } int enet_socket_shutdown (ENetSocket socket, ENetSocketShutdown how) { return shutdown (socket, (int) how); } void enet_socket_destroy (ENetSocket socket) { if (socket != -1) close (socket); } int enet_socket_send (ENetSocket socket, const ENetAddress * address, const ENetBuffer * buffers, size_t bufferCount) { struct msghdr msgHdr; struct sockaddr_in sin; int sentLength; memset (& msgHdr, 0, sizeof (struct msghdr)); if (address != NULL) { memset (& sin, 0, sizeof (struct sockaddr_in)); sin.sin_family = AF_INET; sin.sin_port = ENET_HOST_TO_NET_16 (address -> port); sin.sin_addr.s_addr = address -> host; msgHdr.msg_name = & sin; msgHdr.msg_namelen = sizeof (struct sockaddr_in); } msgHdr.msg_iov = (struct iovec *) buffers; msgHdr.msg_iovlen = bufferCount; sentLength = sendmsg (socket, & msgHdr, MSG_NOSIGNAL); if (sentLength == -1) { if (errno == EWOULDBLOCK) return 0; return -1; } return sentLength; } int enet_socket_receive (ENetSocket socket, ENetAddress * address, ENetBuffer * buffers, size_t bufferCount) { struct msghdr msgHdr; struct sockaddr_in sin; int recvLength; memset (& msgHdr, 0, sizeof (struct msghdr)); if (address != NULL) { msgHdr.msg_name = & sin; msgHdr.msg_namelen = sizeof (struct sockaddr_in); } msgHdr.msg_iov = (struct iovec *) buffers; msgHdr.msg_iovlen = bufferCount; recvLength = recvmsg (socket, & msgHdr, MSG_NOSIGNAL); if (recvLength == -1) { if (errno == EWOULDBLOCK) return 0; return -1; } #ifdef HAS_MSGHDR_FLAGS if (msgHdr.msg_flags & MSG_TRUNC) return -1; #endif if (address != NULL) { address -> host = (enet_uint32) sin.sin_addr.s_addr; address -> port = ENET_NET_TO_HOST_16 (sin.sin_port); } return recvLength; } int enet_socketset_select (ENetSocket maxSocket, ENetSocketSet * readSet, ENetSocketSet * writeSet, enet_uint32 timeout) { struct timeval timeVal; timeVal.tv_sec = timeout / 1000; timeVal.tv_usec = (timeout % 1000) * 1000; return select (maxSocket + 1, readSet, writeSet, NULL, & timeVal); } int enet_socket_wait (ENetSocket socket, enet_uint32 * condition, enet_uint32 timeout) { #ifdef HAS_POLL struct pollfd pollSocket; int pollCount; pollSocket.fd = socket; pollSocket.events = 0; if (* condition & ENET_SOCKET_WAIT_SEND) pollSocket.events |= POLLOUT; if (* condition & ENET_SOCKET_WAIT_RECEIVE) pollSocket.events |= POLLIN; pollCount = poll (& pollSocket, 1, timeout); if (pollCount < 0) return -1; * condition = ENET_SOCKET_WAIT_NONE; if (pollCount == 0) return 0; if (pollSocket.revents & POLLOUT) * condition |= ENET_SOCKET_WAIT_SEND; if (pollSocket.revents & POLLIN) * condition |= ENET_SOCKET_WAIT_RECEIVE; return 0; #else fd_set readSet, writeSet; struct timeval timeVal; int selectCount; timeVal.tv_sec = timeout / 1000; timeVal.tv_usec = (timeout % 1000) * 1000; FD_ZERO (& readSet); FD_ZERO (& writeSet); if (* condition & ENET_SOCKET_WAIT_SEND) FD_SET (socket, & writeSet); if (* condition & ENET_SOCKET_WAIT_RECEIVE) FD_SET (socket, & readSet); selectCount = select (socket + 1, & readSet, & writeSet, NULL, & timeVal); if (selectCount < 0) return -1; * condition = ENET_SOCKET_WAIT_NONE; if (selectCount == 0) return 0; if (FD_ISSET (socket, & writeSet)) * condition |= ENET_SOCKET_WAIT_SEND; if (FD_ISSET (socket, & readSet)) * condition |= ENET_SOCKET_WAIT_RECEIVE; return 0; #endif } #endif assaultcube-1.2.0.2.1/source/enet/win32.c000066400000000000000000000211331352165075300176740ustar00rootroot00000000000000/** @file win32.c @brief ENet Win32 system specific functions */ #ifdef WIN32 #include #define ENET_BUILDING_LIB 1 #include "enet/enet.h" static enet_uint32 timeBase = 0; int enet_initialize (void) { WORD versionRequested = MAKEWORD (1, 1); WSADATA wsaData; if (WSAStartup (versionRequested, & wsaData)) return -1; if (LOBYTE (wsaData.wVersion) != 1|| HIBYTE (wsaData.wVersion) != 1) { WSACleanup (); return -1; } timeBeginPeriod (1); return 0; } void enet_deinitialize (void) { timeEndPeriod (1); WSACleanup (); } enet_uint32 enet_time_get (void) { return (enet_uint32) timeGetTime () - timeBase; } void enet_time_set (enet_uint32 newTimeBase) { timeBase = (enet_uint32) timeGetTime () - newTimeBase; } int enet_address_set_host (ENetAddress * address, const char * name) { struct hostent * hostEntry; hostEntry = gethostbyname (name); if (hostEntry == NULL || hostEntry -> h_addrtype != AF_INET) { unsigned long host = inet_addr (name); if (host == INADDR_NONE) return -1; address -> host = host; return 0; } address -> host = * (enet_uint32 *) hostEntry -> h_addr_list [0]; return 0; } int enet_address_get_host_ip (const ENetAddress * address, char * name, size_t nameLength) { char * addr = inet_ntoa (* (struct in_addr *) & address -> host); if (addr == NULL) return -1; strncpy (name, addr, nameLength); name[nameLength - 1] = '\0'; return 0; } int enet_address_get_host (const ENetAddress * address, char * name, size_t nameLength) { struct in_addr in; struct hostent * hostEntry; in.s_addr = address -> host; hostEntry = gethostbyaddr ((char *) & in, sizeof (struct in_addr), AF_INET); if (hostEntry == NULL) return enet_address_get_host_ip (address, name, nameLength); strncpy (name, hostEntry -> h_name, nameLength); name[nameLength - 1] = '\0'; return 0; } int enet_socket_bind (ENetSocket socket, const ENetAddress * address) { struct sockaddr_in sin; memset (& sin, 0, sizeof (struct sockaddr_in)); sin.sin_family = AF_INET; if (address != NULL) { sin.sin_port = ENET_HOST_TO_NET_16 (address -> port); sin.sin_addr.s_addr = address -> host; } else { sin.sin_port = 0; sin.sin_addr.s_addr = INADDR_ANY; } return bind (socket, (struct sockaddr *) & sin, sizeof (struct sockaddr_in)) == SOCKET_ERROR ? -1 : 0; } int enet_socket_listen (ENetSocket socket, int backlog) { return listen (socket, backlog < 0 ? SOMAXCONN : backlog) == SOCKET_ERROR ? -1 : 0; } ENetSocket enet_socket_create (ENetSocketType type) { return socket (PF_INET, type == ENET_SOCKET_TYPE_DATAGRAM ? SOCK_DGRAM : SOCK_STREAM, 0); } int enet_socket_set_option (ENetSocket socket, ENetSocketOption option, int value) { int result = SOCKET_ERROR; switch (option) { case ENET_SOCKOPT_NONBLOCK: { u_long nonBlocking = (u_long) value; result = ioctlsocket (socket, FIONBIO, & nonBlocking); break; } case ENET_SOCKOPT_BROADCAST: result = setsockopt (socket, SOL_SOCKET, SO_BROADCAST, (char *) & value, sizeof (int)); break; case ENET_SOCKOPT_REUSEADDR: result = setsockopt (socket, SOL_SOCKET, SO_REUSEADDR, (char *) & value, sizeof (int)); break; case ENET_SOCKOPT_RCVBUF: result = setsockopt (socket, SOL_SOCKET, SO_RCVBUF, (char *) & value, sizeof (int)); break; case ENET_SOCKOPT_SNDBUF: result = setsockopt (socket, SOL_SOCKET, SO_SNDBUF, (char *) & value, sizeof (int)); break; case ENET_SOCKOPT_RCVTIMEO: result = setsockopt (socket, SOL_SOCKET, SO_RCVTIMEO, (char *) & value, sizeof (int)); break; case ENET_SOCKOPT_SNDTIMEO: result = setsockopt (socket, SOL_SOCKET, SO_SNDTIMEO, (char *) & value, sizeof (int)); break; default: break; } return result == SOCKET_ERROR ? -1 : 0; } int enet_socket_connect (ENetSocket socket, const ENetAddress * address) { struct sockaddr_in sin; int result; memset (& sin, 0, sizeof (struct sockaddr_in)); sin.sin_family = AF_INET; sin.sin_port = ENET_HOST_TO_NET_16 (address -> port); sin.sin_addr.s_addr = address -> host; result = connect (socket, (struct sockaddr *) & sin, sizeof (struct sockaddr_in)); if (result == SOCKET_ERROR && WSAGetLastError () != WSAEWOULDBLOCK) return -1; return 0; } ENetSocket enet_socket_accept (ENetSocket socket, ENetAddress * address) { SOCKET result; struct sockaddr_in sin; int sinLength = sizeof (struct sockaddr_in); result = accept (socket, address != NULL ? (struct sockaddr *) & sin : NULL, address != NULL ? & sinLength : NULL); if (result == INVALID_SOCKET) return ENET_SOCKET_NULL; if (address != NULL) { address -> host = (enet_uint32) sin.sin_addr.s_addr; address -> port = ENET_NET_TO_HOST_16 (sin.sin_port); } return result; } int enet_socket_shutdown (ENetSocket socket, ENetSocketShutdown how) { return shutdown (socket, (int) how) == SOCKET_ERROR ? -1 : 0; } void enet_socket_destroy (ENetSocket socket) { if (socket != INVALID_SOCKET) closesocket (socket); } int enet_socket_send (ENetSocket socket, const ENetAddress * address, const ENetBuffer * buffers, size_t bufferCount) { struct sockaddr_in sin; DWORD sentLength; if (address != NULL) { memset (& sin, 0, sizeof (struct sockaddr_in)); sin.sin_family = AF_INET; sin.sin_port = ENET_HOST_TO_NET_16 (address -> port); sin.sin_addr.s_addr = address -> host; } if (WSASendTo (socket, (LPWSABUF) buffers, (DWORD) bufferCount, & sentLength, 0, address != NULL ? (struct sockaddr *) & sin : NULL, address != NULL ? sizeof (struct sockaddr_in) : 0, NULL, NULL) == SOCKET_ERROR) { if (WSAGetLastError () == WSAEWOULDBLOCK) return 0; return -1; } return (int) sentLength; } int enet_socket_receive (ENetSocket socket, ENetAddress * address, ENetBuffer * buffers, size_t bufferCount) { INT sinLength = sizeof (struct sockaddr_in); DWORD flags = 0, recvLength; struct sockaddr_in sin; if (WSARecvFrom (socket, (LPWSABUF) buffers, (DWORD) bufferCount, & recvLength, & flags, address != NULL ? (struct sockaddr *) & sin : NULL, address != NULL ? & sinLength : NULL, NULL, NULL) == SOCKET_ERROR) { switch (WSAGetLastError ()) { case WSAEWOULDBLOCK: case WSAECONNRESET: return 0; } return -1; } if (flags & MSG_PARTIAL) return -1; if (address != NULL) { address -> host = (enet_uint32) sin.sin_addr.s_addr; address -> port = ENET_NET_TO_HOST_16 (sin.sin_port); } return (int) recvLength; } int enet_socketset_select (ENetSocket maxSocket, ENetSocketSet * readSet, ENetSocketSet * writeSet, enet_uint32 timeout) { struct timeval timeVal; timeVal.tv_sec = timeout / 1000; timeVal.tv_usec = (timeout % 1000) * 1000; return select (maxSocket + 1, readSet, writeSet, NULL, & timeVal); } int enet_socket_wait (ENetSocket socket, enet_uint32 * condition, enet_uint32 timeout) { fd_set readSet, writeSet; struct timeval timeVal; int selectCount; timeVal.tv_sec = timeout / 1000; timeVal.tv_usec = (timeout % 1000) * 1000; FD_ZERO (& readSet); FD_ZERO (& writeSet); if (* condition & ENET_SOCKET_WAIT_SEND) FD_SET (socket, & writeSet); if (* condition & ENET_SOCKET_WAIT_RECEIVE) FD_SET (socket, & readSet); selectCount = select (socket + 1, & readSet, & writeSet, NULL, & timeVal); if (selectCount < 0) return -1; * condition = ENET_SOCKET_WAIT_NONE; if (selectCount == 0) return 0; if (FD_ISSET (socket, & writeSet)) * condition |= ENET_SOCKET_WAIT_SEND; if (FD_ISSET (socket, & readSet)) * condition |= ENET_SOCKET_WAIT_RECEIVE; return 0; } #endif assaultcube-1.2.0.2.1/source/src/000077500000000000000000000000001352165075300164225ustar00rootroot00000000000000assaultcube-1.2.0.2.1/source/src/Makefile000066400000000000000000000434201352165075300200650ustar00rootroot00000000000000# Ideally, you can override these parameters directly via the commandline, or by # creating a seperate 'Makefile_local' file (this way, your changes aren't # accidentally commited to the AssaultCube repository). # AssaultCube now uses clang++ as a compiler, as there have been random crashes # found to have been caused by the g++ compiler in the past. This seems to have # been fixed now by relaxing the optimization that g++ does, so although we'll # continue using clang++ (just in case), you can use g++ if you prefer. CXX=clang++ # Changing this to ACDEBUG=yes will compile a debug version of AssaultCube. ACDEBUG=no PLATFORM=$(shell uname -s) # This prefix is only used to name the installed executables. PLATFORM_PREFIX=native # As above, this file is optional only. -include Makefile_local ifeq ($(ACDEBUG),yes) CXXFLAGS= -O0 override CXXFLAGS+= -g -O2 -D_DEBUG endif ifneq (,$(findstring clang,$(CXX))) CXXFLAGS= -g -O2 -fomit-frame-pointer override CXXFLAGS+= -fPIE -Wall -fsigned-char else CXXFLAGS= -g -O2 -fomit-frame-pointer override CXXFLAGS+= -Wall -fsigned-char -ffast-math -rdynamic -Wno-format-zero-length endif INCLUDES= -I. -Ibot -I../enet/include STRIP= ifeq (,$(findstring -g,$(CXXFLAGS))) ifeq (,$(findstring -pg,$(CXXFLAGS))) STRIP=strip endif endif MV=mv RM=rm -rf ifneq (,$(findstring MINGW,$(PLATFORM))) WINDRES= windres CLIENT_INCLUDES= $(INCLUDES) -I../include CLIENT_LIBS= -mwindows -L../lib -lSDL2 -lSDL2_image -lzdll -lopengl32 -lenet -lOpenAL32 -llibvorbisfile -lws2_32 -lwinmm else USRLIB=$(shell if [ -e /usr/lib64 ]; then echo "/usr/lib64"; else echo "/usr/lib"; fi) CLIENT_INCLUDES= $(INCLUDES) -I/usr/include `sdl2-config --cflags` -idirafter ../include CLIENT_LIBS= -L../enet/.libs -lenet -L$(USRLIB) `sdl2-config --libs` -lSDL2_image -lz -lGL -lopenal -lvorbisfile endif CLIENT_OBJS= \ crypto.o \ audiomanager.o \ autodownload.o \ client.o \ clientgame.o \ clients2c.o \ command.o \ console.o \ docs.o \ editing.o \ entities.o \ http.o \ log.o \ main.o \ menus.o \ oggstream.o \ openal.o \ packetqueue.o \ physics.o \ protocol.o \ rendercubes.o \ rendergl.o \ renderhud.o \ rendermodel.o \ renderparticles.o \ rendertext.o \ rndmap.o \ scoreboard.o \ serverms.o \ server.o \ serverbrowser.o \ shadow.o \ soundlocation.o \ soundscheduler.o \ stream.o \ texture.o \ tools.o \ water.o \ weapon.o \ wizard.o \ world.o \ worldio.o \ worldlight.o \ worldocull.o \ worldrender.o \ zip.o \ bot/bot.o \ bot/botmanager.o \ bot/bot_ai.o \ bot/bot_util.o \ bot/bot_waypoint.o \ bot/ac_bot.o \ bot/ac_bot_ai.o CLIENT_PCH= cube.h.gch ifneq (,$(findstring MINGW,$(PLATFORM))) SERVER_INCLUDES= -DSTANDALONE $(INCLUDES) -I../include SERVER_LIBS= -L../lib -lzdll -lenet -lws2_32 -lwinmm else SERVER_INCLUDES= -DSTANDALONE $(INCLUDES) SERVER_LIBS= -L../enet/.libs -lenet -lz -lpthread ifeq (,$(findstring OpenBSD,$(PLATFORM))) SERVER_LIBS+= -lrt endif endif SERVER_OBJS= \ crypto-standalone.o \ log-standalone.o \ protocol-standalone.o \ serverms-standalone.o \ server-standalone.o \ stream-standalone.o \ tools-standalone.o \ wizard-standalone.o MASTER_OBJS= \ crypto-standalone.o \ stream-standalone.o \ command-standalone.o \ master-standalone.o ifeq ($(PLATFORM),SunOS) CLIENT_LIBS+= -lsocket -lnsl -lX11 SERVER_LIBS+= -lsocket -lnsl endif default: all all: client server ../enet/Makefile: cd ../enet; ./configure --enable-shared=no --enable-static=yes libenet: ../enet/Makefile -$(MAKE) -C ../enet all clean-enet: ../enet/Makefile $(MAKE) -C ../enet/ distclean || true -$(RM) ../enet/autom4te.cache clean: clean-enet -$(RM) $(CLIENT_PCH) $(CLIENT_OBJS) $(SERVER_OBJS) $(MASTER_OBJS) ac_client ac_server ac_master profile mrproper: clean ../enet/Makefile $(MAKE) -C ../enet/ distclean || true -$(RM) ../enet/Makefile %.h.gch: %.h $(CXX) $(CXXFLAGS) -x c++-header -o $@.tmp $(subst .h.gch,.h,$@) $(MV) $@.tmp $@ rendermodel.o: rendermodel.cpp $(CXX) $(CXXFLAGS) -fno-strict-aliasing -c -o $@ $(subst .o,.cpp,$@) %-standalone.o: %.cpp $(CXX) $(CXXFLAGS) -c -o $@ $(subst -standalone.o,.cpp,$@) $(CLIENT_OBJS): CXXFLAGS += $(CLIENT_INCLUDES) $(CLIENT_OBJS): $(CLIENT_PCH) $(SERVER_OBJS): CXXFLAGS += $(SERVER_INCLUDES) $(filter-out $(SERVER_OBJS),$(MASTER_OBJS)): CXXFLAGS += $(SERVER_INCLUDES) ifneq (,$(findstring MINGW,$(PLATFORM))) client: $(CLIENT_OBJS) $(WINDRES) -I ../vcpp -i ../vcpp/assaultcube.rc -J rc -o ../vcpp/assaultcube.res -O coff $(CXX) $(CXXFLAGS) -o ../../bin_win32/ac_client.exe ../vcpp/assaultcube.res $(CLIENT_OBJS) $(CLIENT_LIBS) server: $(SERVER_OBJS) $(CXX) $(CXXFLAGS) -o ../../bin_win32/ac_server.exe $(SERVER_OBJS) $(SERVER_LIBS) master: $(MASTER_OBJS) $(CXX) $(CXXFLAGS) -o ../../bin_win32/ac_master.exe $(MASTER_OBJS) $(SERVER_LIBS) client_install: client server_install: server else client: libenet $(CLIENT_OBJS) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o ac_client $(CLIENT_OBJS) $(CLIENT_LIBS) server: libenet $(SERVER_OBJS) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o ac_server $(SERVER_OBJS) $(SERVER_LIBS) master: libenet $(MASTER_OBJS) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o ac_master $(MASTER_OBJS) $(SERVER_LIBS) client_install: client install -d ../../bin_unix/ install -m755 ac_client ../../bin_unix/$(PLATFORM_PREFIX)_client #ifneq (,$(STRIP)) # $(STRIP) ../../bin_unix/$(PLATFORM_PREFIX)_client #endif server_install: server install -d ../../bin_unix/ install -m755 ac_server ../../bin_unix/$(PLATFORM_PREFIX)_server #ifneq (,$(STRIP)) # $(STRIP) ../../bin_unix/$(PLATFORM_PREFIX)_server #endif endif install: client_install server_install depend: makedepend -Y -I. -Ibot $(subst .o,.cpp,$(CLIENT_OBJS)) makedepend -a -o.h.gch -Y -I. -Ibot $(subst .h.gch,.h,$(CLIENT_PCH)) makedepend -a -o-standalone.o -Y -I. -Ibot $(subst -standalone.o,.cpp,$(SERVER_OBJS)) makedepend -a -o-standalone.o -Y -I. $(subst -standalone.o,.cpp,$(filter-out $(SERVER_OBJS), $(MASTER_OBJS))) # DO NOT DELETE crypto.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h crypto.o: weapon.h entity.h world.h command.h varray.h vote.h console.h crypto.o: protos.h crypto_tools.h ge25519_base.data audiomanager.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h audiomanager.o: weapon.h entity.h world.h command.h varray.h vote.h console.h audiomanager.o: protos.h autodownload.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h autodownload.o: weapon.h entity.h world.h command.h varray.h vote.h console.h autodownload.o: protos.h client.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h client.o: weapon.h entity.h world.h command.h varray.h vote.h console.h client.o: protos.h bot/bot.h bot/bot_util.h bot/bot_waypoint.h bot/ac_bot.h clientgame.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h clientgame.o: weapon.h entity.h world.h command.h varray.h vote.h console.h clientgame.o: protos.h bot/bot.h bot/bot_util.h bot/bot_waypoint.h clientgame.o: bot/ac_bot.h clients2c.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h clients2c.o: weapon.h entity.h world.h command.h varray.h vote.h console.h clients2c.o: protos.h bot/bot.h bot/bot_util.h bot/bot_waypoint.h clients2c.o: bot/ac_bot.h command.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h command.o: weapon.h entity.h world.h command.h varray.h vote.h console.h command.o: protos.h console.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h console.o: weapon.h entity.h world.h command.h varray.h vote.h console.h console.o: protos.h docs.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h weapon.h docs.o: entity.h world.h command.h varray.h vote.h console.h protos.h editing.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h editing.o: weapon.h entity.h world.h command.h varray.h vote.h console.h editing.o: protos.h entities.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h entities.o: weapon.h entity.h world.h command.h varray.h vote.h console.h entities.o: protos.h http.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h weapon.h http.o: entity.h world.h command.h varray.h vote.h console.h protos.h log.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h weapon.h log.o: entity.h world.h command.h varray.h vote.h console.h protos.h main.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h weapon.h main.o: entity.h world.h command.h varray.h vote.h console.h protos.h main.o: jpegenc.h menus.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h weapon.h menus.o: entity.h world.h command.h varray.h vote.h console.h protos.h oggstream.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h oggstream.o: weapon.h entity.h world.h command.h varray.h vote.h console.h oggstream.o: protos.h openal.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h openal.o: weapon.h entity.h world.h command.h varray.h vote.h console.h openal.o: protos.h packetqueue.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h packetqueue.o: weapon.h entity.h world.h command.h varray.h vote.h console.h packetqueue.o: protos.h physics.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h physics.o: weapon.h entity.h world.h command.h varray.h vote.h console.h physics.o: protos.h protocol.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h protocol.o: weapon.h entity.h world.h command.h varray.h vote.h console.h protocol.o: protos.h rendercubes.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h rendercubes.o: weapon.h entity.h world.h command.h varray.h vote.h console.h rendercubes.o: protos.h rendergl.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h rendergl.o: weapon.h entity.h world.h command.h varray.h vote.h console.h rendergl.o: protos.h bot/bot.h bot/bot_util.h bot/bot_waypoint.h bot/ac_bot.h renderhud.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h renderhud.o: weapon.h entity.h world.h command.h varray.h vote.h console.h renderhud.o: protos.h rendermodel.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h rendermodel.o: weapon.h entity.h world.h command.h varray.h vote.h console.h rendermodel.o: protos.h tristrip.h modelcache.h vertmodel.h md2.h md3.h renderparticles.o: cube.h platform.h tools.h geom.h model.h protocol.h renderparticles.o: sound.h weapon.h entity.h world.h command.h varray.h renderparticles.o: vote.h console.h protos.h rendertext.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h rendertext.o: weapon.h entity.h world.h command.h varray.h vote.h console.h rendertext.o: protos.h rndmap.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h rndmap.o: weapon.h entity.h world.h command.h varray.h vote.h console.h rndmap.o: protos.h scoreboard.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h scoreboard.o: weapon.h entity.h world.h command.h varray.h vote.h console.h scoreboard.o: protos.h serverms.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h serverms.o: weapon.h entity.h world.h command.h varray.h vote.h console.h serverms.o: protos.h server.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h server.o: weapon.h entity.h world.h command.h varray.h vote.h console.h server.o: protos.h server.h servercontroller.h serverfiles.h serverchecks.h server.o: serverevents.h serveractions.h serverbrowser.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h serverbrowser.o: weapon.h entity.h world.h command.h varray.h vote.h serverbrowser.o: console.h protos.h shadow.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h shadow.o: weapon.h entity.h world.h command.h varray.h vote.h console.h shadow.o: protos.h soundlocation.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h soundlocation.o: weapon.h entity.h world.h command.h varray.h vote.h soundlocation.o: console.h protos.h soundscheduler.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h soundscheduler.o: weapon.h entity.h world.h command.h varray.h vote.h soundscheduler.o: console.h protos.h stream.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h stream.o: weapon.h entity.h world.h command.h varray.h vote.h console.h stream.o: protos.h texture.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h texture.o: weapon.h entity.h world.h command.h varray.h vote.h console.h texture.o: protos.h scale.h tools.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h weapon.h tools.o: entity.h world.h command.h varray.h vote.h console.h protos.h water.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h weapon.h water.o: entity.h world.h command.h varray.h vote.h console.h protos.h weapon.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h weapon.o: weapon.h entity.h world.h command.h varray.h vote.h console.h weapon.o: protos.h bot/bot.h bot/bot_util.h bot/bot_waypoint.h bot/ac_bot.h weapon.o: hudgun.h wizard.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h wizard.o: weapon.h entity.h world.h command.h varray.h vote.h console.h wizard.o: protos.h world.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h weapon.h world.o: entity.h world.h command.h varray.h vote.h console.h protos.h world.o: bot/bot.h bot/bot_util.h bot/bot_waypoint.h bot/ac_bot.h worldio.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h worldio.o: weapon.h entity.h world.h command.h varray.h vote.h console.h worldio.o: protos.h worldlight.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h worldlight.o: weapon.h entity.h world.h command.h varray.h vote.h console.h worldlight.o: protos.h worldocull.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h worldocull.o: weapon.h entity.h world.h command.h varray.h vote.h console.h worldocull.o: protos.h worldrender.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h worldrender.o: weapon.h entity.h world.h command.h varray.h vote.h console.h worldrender.o: protos.h zip.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h weapon.h zip.o: entity.h world.h command.h varray.h vote.h console.h protos.h bot/bot.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h bot/bot.o: weapon.h entity.h world.h command.h varray.h vote.h console.h bot/bot.o: protos.h bot/bot.h bot/bot_util.h bot/bot_waypoint.h bot/ac_bot.h bot/botmanager.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h bot/botmanager.o: weapon.h entity.h world.h command.h varray.h vote.h bot/botmanager.o: console.h protos.h bot/bot.h bot/bot_util.h bot/botmanager.o: bot/bot_waypoint.h bot/ac_bot.h bot/bot_ai.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h bot/bot_ai.o: weapon.h entity.h world.h command.h varray.h vote.h console.h bot/bot_ai.o: protos.h bot/bot.h bot/bot_util.h bot/bot_waypoint.h bot/bot_ai.o: bot/ac_bot.h bot/bot_util.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h bot/bot_util.o: weapon.h entity.h world.h command.h varray.h vote.h console.h bot/bot_util.o: protos.h bot/bot.h bot/bot_util.h bot/bot_waypoint.h bot/bot_util.o: bot/ac_bot.h bot/bot_waypoint.o: cube.h platform.h tools.h geom.h model.h protocol.h bot/bot_waypoint.o: sound.h weapon.h entity.h world.h command.h varray.h bot/bot_waypoint.o: vote.h console.h protos.h bot/bot.h bot/bot_util.h bot/bot_waypoint.o: bot/bot_waypoint.h bot/ac_bot.h bot/ac_bot.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h bot/ac_bot.o: weapon.h entity.h world.h command.h varray.h vote.h console.h bot/ac_bot.o: protos.h bot/bot.h bot/bot_util.h bot/bot_waypoint.h bot/ac_bot.o: bot/ac_bot.h bot/ac_bot_ai.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h bot/ac_bot_ai.o: weapon.h entity.h world.h command.h varray.h vote.h bot/ac_bot_ai.o: console.h protos.h bot/bot.h bot/bot_util.h bot/ac_bot_ai.o: bot/bot_waypoint.h bot/ac_bot.h cube.h.gch: platform.h tools.h geom.h model.h protocol.h sound.h weapon.h cube.h.gch: entity.h world.h command.h varray.h vote.h console.h protos.h crypto-standalone.o: cube.h platform.h tools.h geom.h model.h protocol.h crypto-standalone.o: sound.h weapon.h entity.h world.h command.h varray.h crypto-standalone.o: vote.h console.h protos.h crypto_tools.h crypto-standalone.o: ge25519_base.data log-standalone.o: cube.h platform.h tools.h geom.h model.h protocol.h sound.h log-standalone.o: weapon.h entity.h world.h command.h varray.h vote.h log-standalone.o: console.h protos.h protocol-standalone.o: cube.h platform.h tools.h geom.h model.h protocol.h protocol-standalone.o: sound.h weapon.h entity.h world.h command.h varray.h protocol-standalone.o: vote.h console.h protos.h serverms-standalone.o: cube.h platform.h tools.h geom.h model.h protocol.h serverms-standalone.o: sound.h weapon.h entity.h world.h command.h varray.h serverms-standalone.o: vote.h console.h protos.h server-standalone.o: cube.h platform.h tools.h geom.h model.h protocol.h server-standalone.o: sound.h weapon.h entity.h world.h command.h varray.h server-standalone.o: vote.h console.h protos.h server.h servercontroller.h server-standalone.o: serverfiles.h serverchecks.h serverevents.h server-standalone.o: serveractions.h stream-standalone.o: cube.h platform.h tools.h geom.h model.h protocol.h stream-standalone.o: sound.h weapon.h entity.h world.h command.h varray.h stream-standalone.o: vote.h console.h protos.h tools-standalone.o: cube.h platform.h tools.h geom.h model.h protocol.h tools-standalone.o: sound.h weapon.h entity.h world.h command.h varray.h tools-standalone.o: vote.h console.h protos.h wizard-standalone.o: cube.h platform.h tools.h geom.h model.h protocol.h wizard-standalone.o: sound.h weapon.h entity.h world.h command.h varray.h wizard-standalone.o: vote.h console.h protos.h command-standalone.o: cube.h platform.h tools.h geom.h model.h protocol.h command-standalone.o: sound.h weapon.h entity.h world.h command.h varray.h command-standalone.o: vote.h console.h protos.h master-standalone.o: cube.h platform.h tools.h geom.h model.h protocol.h master-standalone.o: sound.h weapon.h entity.h world.h command.h varray.h master-standalone.o: vote.h console.h protos.h assaultcube-1.2.0.2.1/source/src/audiomanager.cpp000066400000000000000000000752411352165075300215730ustar00rootroot00000000000000// audio interface of the engine #include "cube.h" #define DEBUGCOND (audiodebug==1) VARF(audio, 0, 1, 1, initwarning("sound configuration", INIT_RESET, CHANGE_SOUND)); VARP(audiodebug, 0, 0, 1); char *musicdonecmd = NULL; VARFP(musicvol, 0, 128, 255, audiomgr.setmusicvol(musicvol)); // audio manager audiomanager::audiomanager() { nosound = true; currentpitch = 1.0f; device = NULL; context = NULL; } void audiomanager::initsound() { if(!audio) { conoutf("audio is disabled"); return; } nosound = true; device = NULL; context = NULL; // list available devices if(alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT")) { const ALCchar *devices = alcGetString(NULL, ALC_DEVICE_SPECIFIER); if(devices) { string d; copystring(d, "Audio devices: "); // null separated device string for(const ALchar *c = devices; *c; c += strlen(c)+1) { if(c!=devices) concatstring(d, ", "); concatstring(d, c); } conoutf("%s", d); } } // open device const char *devicename = getalias("openaldevice"); device = alcOpenDevice(devicename && devicename[0] ? devicename : NULL); if(device) { context = alcCreateContext(device, NULL); if(context) { alcMakeContextCurrent(context); alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED); // backend infos conoutf("Sound: %s / %s (%s)", alcGetString(device, ALC_DEVICE_SPECIFIER), alGetString(AL_RENDERER), alGetString(AL_VENDOR)); conoutf("Driver: %s", alGetString(AL_VERSION)); // allocate OpenAL resources sourcescheduler::instance().init(16); // let the stream get the first source from the scheduler gamemusic = new oggstream(); if(!gamemusic->valid) DELETEP(gamemusic); setmusicvol(musicvol); nosound = false; } } if(nosound) { ALERR; if(context) alcDestroyContext(context); if(device) alcCloseDevice(device); conoutf("sound initialization failed!"); } } void audiomanager::music(char *name, int millis, char *cmd) { if(nosound) return; stopsound(); if(musicvol && *name) { if(cmd[0]) musicdonecmd = newstring(cmd); if(gamemusic->open(name)) { // fade if(millis > 0) { const int fadetime = 1000; gamemusic->fadein(lastmillis, fadetime); gamemusic->fadeout(lastmillis+millis, fadetime); } // play bool loop = cmd && cmd[0]; if(!gamemusic->playback(loop)) { conoutf("could not play music: %s", name); return; } setmusicvol(musicvol); } else conoutf("could not open music: %s", name); } } void audiomanager::musicpreload(int id) { if(nosound) return; stopsound(); if(musicvol && (id>=M_FLAGGRAB && id<=M_LASTMINUTE2) && musics.inrange(id)) { char *name = musics[id]; conoutf("preloading music #%d : %s", id, name); if(gamemusic->open(name)) { /*defformatstring(whendone)("musicvol %d", musicvol); musicdonecmd = newstring(whendone); conoutf("when done: %s", musicdonecmd);*/ const int preloadfadetime = 3; gamemusic->fadein(lastmillis, preloadfadetime); gamemusic->fadeout(lastmillis+2*preloadfadetime, preloadfadetime); if(!gamemusic->playback(false)) { conoutf("could not play music: %s", name); return; } setmusicvol(1); // not 0 ! } else conoutf("could not open music: %s", name); } else setmusicvol(musicvol); // call "musicpreload -1" to ensure musicdonecmd runs - but it should w/o that } void audiomanager::musicsuggest(int id, int millis, bool rndofs) // play bg music if nothing else is playing { if(nosound || !gamemusic) return; if(gamemusic->playing()) return; if(!musicvol) return; if(!musics.inrange(id)) { conoutf("\f3music %d not registered", id); return; } char *name = musics[id]; if(gamemusic->open(name)) { gamemusic->fadein(lastmillis, 1000); gamemusic->fadeout(millis ? lastmillis+millis : 0, 1000); if(rndofs) gamemusic->seek(millis ? (double)rnd(millis)/2.0f : (double)lastmillis); if(!gamemusic->playback(rndofs)) conoutf("could not play music: %s", name); } else conoutf("could not open music: %s", name); } void audiomanager::musicfadeout(int id) { if(nosound || !gamemusic) return; if(!gamemusic->playing() || !musics.inrange(id)) return; if(!strcmp(musics[id], gamemusic->name)) gamemusic->fadeout(lastmillis+1000, 1000); } void audiomanager::setmusicvol(int musicvol) { if(gamemusic) gamemusic->setvolume(musicvol > 0 ? musicvol/255.0f : 0); } void reloadmapsoundconfig(); void audiomanager::setlistenervol(int vol) { static int oldvol = 0; if(!nosound) { alListenerf(AL_GAIN, vol/255.0f); if(vol && !oldvol && !mapsounds.length()) reloadmapsoundconfig(); } oldvol = vol; } void audiomanager::registermusic(char *name) { if(nosound||!musicvol) return; if(!name || !name[0]) return; musics.add(newstring(name)); } int audiomanager::findsound(const char *name, int vol, vector &sounds) { loopv(sounds) { if(!strcmp(sounds[i].buf->name, name) && (!vol || sounds[i].vol==vol)) return i; } return -1; } int audiomanager::addsound(const char *name, int vol, int maxuses, bool loop, vector &sounds, bool load, int audibleradius) { if(nosound) return -1; if(!soundvol) return -1; // check if the sound was already registered int index = findsound(name, vol, sounds); if(index > -1) return index; sbuffer *b = bufferpool.find(name); if(!b) { conoutf("\f3failed to allocate sample %s", name); return -1; } if(load && !b->load()) conoutf("\f3failed to load sample %s", name); soundconfig s(b, vol, maxuses, loop, audibleradius); sounds.add(s); return sounds.length()-1; } bool audiomanager::preloadmapsound(entity &e, bool trydl) { if(e.type!=SOUND || !mapsounds.inrange(e.attr1)) return false; sbuffer *buf = mapsounds[e.attr1].buf; if(!buf->load(trydl) && !trydl) { conoutf("\f3failed to load sample %s", buf->name); return false; } return true; } bool audiomanager::preloadmapsounds(bool trydl) { int missing = 0; loopv(ents) { entity &e = ents[i]; if(e.type == SOUND && !preloadmapsound(e, trydl)) missing++; } return !missing; } void audiomanager::applymapsoundchanges() // during map editing, drop all mapsounds so they can be re-added { loopv(locations) { location *l = locations[i]; if(l && l->ref && l->ref->type==worldobjreference::WR_ENTITY) l->drop(); } } void audiomanager::setchannels(int num) { if(!nosound) sourcescheduler::instance().init(num); }; // called at game exit void audiomanager::soundcleanup() { if(nosound) return; // destroy consuming code stopsound(); DELETEP(gamemusic); mapsounds.shrink(0); locations.deletecontents(); gamesounds.shrink(0); // kill scheduler sourcescheduler::instance().reset(); bufferpool.clear(); // shutdown openal alcMakeContextCurrent(NULL); if(context) alcDestroyContext(context); if(device) alcCloseDevice(device); } // clear world-related sounds, called on mapchange void audiomanager::clearworldsounds(bool fullclean) { stopsound(); if(fullclean) mapsounds.shrink(0); locations.deleteworldobjsounds(); } void audiomanager::mapsoundreset() { mapsounds.shrink(0); locations.deleteworldobjsounds(); } VARP(footsteps, 0, 1, 1); VARP(localfootsteps, 0, 1, 1); void audiomanager::updateplayerfootsteps(playerent *p) { if(!p) return; const int footstepradius = 20; // find existing footstep sounds physentreference ref(p); location *locs[] = { locations.find(S_FOOTSTEPS, &ref, gamesounds), locations.find(S_FOOTSTEPSCROUCH, &ref, gamesounds), locations.find(S_WATERFOOTSTEPS, &ref, gamesounds), locations.find(S_WATERFOOTSTEPSCROUCH, &ref, gamesounds) }; bool local = (p == camera1); bool inrange = footsteps && (local || (camera1->o.dist(p->o) < footstepradius)); if(!footsteps || (local && !localfootsteps) || !inrange || p->state != CS_ALIVE || lastmillis-p->lastpain < 300 || (!p->onfloor && p->timeinair>50) || (!p->move && !p->strafe) || p->inwater) { const int minplaytime = 200; loopi(sizeof(locs)/sizeof(locs[0])) { location *l = locs[i]; if(!l) continue; if(l->playmillis+minplaytime>totalmillis) continue; // tolerate short interruptions by enforcing a minimal playtime l->drop(); } } else { // play footsteps float grounddist = 0; if(!((int(p->o.x) | int(p->o.y)) & ~(ssize - 1))) grounddist = waterlevel - S((int)p->o.x, (int)p->o.y)->floor; bool water = p->o.z - p->eyeheight+0.25f < waterlevel; if(water && grounddist > p->eyeheight) return; // don't play step sound when jumping into water int stepsound; if(p->crouching) stepsound = water ? S_WATERFOOTSTEPSCROUCH : S_FOOTSTEPSCROUCH; // crouch else stepsound = water ? S_WATERFOOTSTEPS : S_FOOTSTEPS; // normal // proc existing sounds bool isplaying = false; loopi(sizeof(locs)/sizeof(locs[0])) { location *l = locs[i]; if(!l) continue; if(i+S_FOOTSTEPS==stepsound) isplaying = true; // already playing else l->drop(); // different footstep sound, drop it } if(!isplaying) { // play float rndoffset = float(rnd(500))/500.0f; _playsound(stepsound, ref, local ? SP_HIGH : SP_LOW, rndoffset); } } } // manage looping sounds location *audiomanager::updateloopsound(int sound, bool active, float vol) { location *l = locations.find(sound, NULL, gamesounds); if(!l && active) l = _playsound(sound, camerareference(), SP_HIGH, 0.0f, true); else if(l && !active) l->drop(); if(l && vol != 1.0f) l->src->gain(vol); return l; } VARP(mapsoundrefresh, 0, 10, 1000); void audiomanager::mutesound(int n, int off) { bool mute = (off == 0); if(!gamesounds.inrange(n)) { conoutf("\f3could not %s sound #%d", mute ? "silence" : "unmute", n); return; } gamesounds[n].muted = mute; } void audiomanager::unmuteallsounds() { loopv(gamesounds) gamesounds[i].muted = false; } int audiomanager::soundmuted(int n) { return gamesounds.inrange(n) && !gamesounds[n].muted ? 0 : 1; } void audiomanager::writesoundconfig(stream *f) { bool wrotesound = false; loopv(gamesounds) { if(gamesounds[i].muted) { if(!wrotesound) { f->printf("// sound settings\n\n"); wrotesound = true; } f->printf("mutesound %d\n", i); } } } void voicecom(char *sound, char *text) { if(!sound || !sound[0]) return; if(!text || !text[0]) return; static int last = 0; if(!last || lastmillis-last > 2000) { defformatstring(soundpath)("voicecom/%s", sound); int s = audiomgr.findsound(soundpath, 0, gamesounds); if(!gamesound_isvoicecom(s)) return; if(voicecomsounds>0) audiomgr.playsound(s, SP_HIGH); if(gamesound_ispublicvoicecom(s)) // public { addmsg(SV_VOICECOM, "ri", s); toserver(text); } else // team { addmsg(SV_VOICECOMTEAM, "ri", s); defformatstring(teamtext)("%c%s", '%', text); toserver(teamtext); } last = lastmillis; } } COMMAND(voicecom, "ss"); void soundtest() { loopi(S_NULL) audiomgr.playsound(i, rnd(SP_HIGH+1)); } COMMAND(soundtest, ""); // sound configuration soundconfig::soundconfig(sbuffer *b, int vol, int maxuses, bool loop, int audibleradius) { buf = b; this->vol = vol > 0 ? vol : 100; this->maxuses = maxuses; this->loop = loop; this->audibleradius = audibleradius; this->model = audibleradius > 0 ? DM_LINEAR : DM_DEFAULT; // use linear model when radius is configured uses = 0; muted = false; } void soundconfig::onattach() { uses++; } void soundconfig::ondetach() { uses--; } vector gamesounds, mapsounds; void audiomanager::detachsounds(playerent *owner) { if(nosound) return; // make all dependent locations static locations.replaceworldobjreference(physentreference(owner), staticreference(owner->o)); } VARP(maxsoundsatonce, 0, 32, 100); location *audiomanager::_playsound(int n, const worldobjreference &r, int priority, float offset, bool loop) { if(nosound || !soundvol) return NULL; if(soundmuted(n)) return NULL; DEBUGVAR(n); DEBUGVAR(priority); if(r.type!=worldobjreference::WR_ENTITY) { // avoid bursts of sounds with heavy packetloss and in sp static int soundsatonce = 0, lastsoundmillis = 0; if(totalmillis==lastsoundmillis) soundsatonce++; else soundsatonce = 1; lastsoundmillis = totalmillis; if(maxsoundsatonce && soundsatonce>maxsoundsatonce) { DEBUGVAR(soundsatonce); return NULL; } } location *loc = new location(n, r, priority); locations.add(loc); if(!loc->stale) { if(offset>0) loc->offset(offset); if(currentpitch!=1.0f) loc->pitch(currentpitch); loc->play(loop); } return loc; } void audiomanager::playsound(int n, int priority) { _playsound(n, camerareference(), priority); } void audiomanager::playsound(int n, physent *p, int priority) { if(p) _playsound(n, physentreference(p), priority); } void audiomanager::playsound(int n, entity *e, int priority) { if(e) _playsound(n, entityreference(e), priority); } void audiomanager::playsound(int n, const vec *v, int priority) { if(v) _playsound(n, staticreference(*v), priority); } void audiomanager::playsoundname(char *s, const vec *loc, int vol) { if(!nosound) return; if(vol <= 0) vol = 100; int id = findsound(s, vol, gamesounds); if(id < 0) id = addsound(s, vol, 0, false, gamesounds, true, 0); playsound(id, loc, SP_NORMAL); } void audiomanager::playsoundc(int n, physent *p, int priority) { if(p && p!=player1) playsound(n, p, priority); else { addmsg(SV_SOUND, "i", n); playsound(n, priority); } } void audiomanager::stopsound() { if(nosound) return; DELETEA(musicdonecmd); if(gamemusic) gamemusic->reset(); } VARP(heartbeat, 0, 0, 99); // main audio update routine void audiomanager::updateaudio() { if(nosound) return; alcSuspendContext(context); // don't process sounds while we mess around bool alive = player1->state==CS_ALIVE; bool firstperson = camera1==player1 || (player1->isspectating() && player1->spectatemode==SM_DEATHCAM); // footsteps updateplayerfootsteps(player1); loopv(players) { playerent *p = players[i]; if(!p) continue; updateplayerfootsteps(p); } // water bool underwater = /*alive &&*/ firstperson && waterlevel > player1->o.z + player1->aboveeye; updateloopsound(S_UNDERWATER, underwater); // tinnitus bool tinnitus = alive && firstperson && player1->eardamagemillis>0 && lastmillis<=player1->eardamagemillis; location *tinnitusloc = updateloopsound(S_TINNITUS, tinnitus); // heartbeat bool heartbeatsound = heartbeat && alive && firstperson && !m_osok && player1->health <= heartbeat; updateloopsound(S_HEARTBEAT, heartbeatsound); // pitch fx const float lowpitch = 0.65f; bool pitchfx = underwater || tinnitus; if(pitchfx && currentpitch!=lowpitch) { currentpitch = lowpitch; locations.forcepitch(currentpitch); if(tinnitusloc) tinnitusloc->pitch(1.9f); // super high pitched tinnitus } else if(!pitchfx && currentpitch==lowpitch) { currentpitch = 1.0f; locations.forcepitch(currentpitch); } // update map sounds static int lastmapsound = 0; if(!lastmapsound || totalmillis-lastmapsound>mapsoundrefresh || !mapsoundrefresh) { loopv(ents) { entity &e = ents[i]; vec o(e.x, e.y, e.z); if(e.type!=SOUND) continue; int sound = e.attr1; int radius = e.attr2; bool hearable = (radius==0 || camera1->o.dist(o)drop(); } } lastmapsound = totalmillis; } // update all sound locations locations.updatelocations(); // update background music if(gamemusic) { if(!gamemusic->update()) { // music ended, exec command if(musicdonecmd) { char *cmd = musicdonecmd; musicdonecmd = NULL; setcontext("hook", "musicdonecmd"); execute(cmd); resetcontext(); delete[] cmd; } } } // listener vec o[2]; o[0].x = (float)(cosf(RAD*(camera1->yaw-90))); o[0].y = (float)(sinf(RAD*(camera1->yaw-90))); o[0].z = 0.0f; o[1].x = o[1].y = 0.0f; o[1].z = -1.0f; alListenerfv(AL_ORIENTATION, (ALfloat *) &o); alListenerfv(AL_POSITION, (ALfloat *) &camera1->o); alcProcessContext(context); } // binding of sounds to the 3D world // camera camerareference::camerareference() : worldobjreference(WR_CAMERA) {} worldobjreference *camerareference::clone() const { return new camerareference(*this); } const vec &camerareference::currentposition() const { return camera1->o; } bool camerareference::nodistance() { return true; } bool camerareference::operator==(const worldobjreference &other) { return type==other.type; } // physent physentreference::physentreference(physent *ref) : worldobjreference(WR_PHYSENT) { ASSERT(ref); phys = ref; } worldobjreference *physentreference::clone() const { return new physentreference(*this); } const vec &physentreference::currentposition() const { return phys->o; } bool physentreference::nodistance() { return phys==camera1; } bool physentreference::operator==(const worldobjreference &other) { return type==other.type && phys==((physentreference &)other).phys; } // entity entityreference::entityreference(entity *ref) : worldobjreference(WR_ENTITY) { ASSERT(ref); ent = ref; } worldobjreference *entityreference::clone() const { return new entityreference(*this); } const vec &entityreference::currentposition() const { static vec tmp; tmp = vec(ent->x, ent->y, ent->z); return tmp; } bool entityreference::nodistance() { return ent->attr3>0; } bool entityreference::operator==(const worldobjreference &other) { return type==other.type && ent==((entityreference &)other).ent; } // static staticreference::staticreference(const vec &ref) : worldobjreference(WR_STATICPOS) { pos = ref; } worldobjreference *staticreference::clone() const { return new staticreference(*this); } const vec &staticreference::currentposition() const { return pos; } bool staticreference::nodistance() { return false; } bool staticreference::operator==(const worldobjreference &other) { return type==other.type && pos==((staticreference &)other).pos; } // instance audiomanager audiomgr; const char *soundprioritynames[] = {"LOW", "NORMAL", "HIGH", "HIGHEST", ""}; // keep in sync with enum { SP_LOW = 0, SP_NORMAL, SP_HIGH, SP_HIGHEST } COMMANDF(sound, "is", (int *n, char *priorityname) { int priority = getlistindex(priorityname, soundprioritynames, true, SP_NORMAL); audiomgr.playsound(*n, priority); }); COMMANDF(applymapsoundchanges, "", (){ if(m_coop || !multiplayer("applymapsoundchanges")) audiomgr.applymapsoundchanges(); }); COMMANDF(unmuteallsounds, "", () { audiomgr.unmuteallsounds(); }); COMMANDF(mutesound, "ii", (int *n, int *off) { audiomgr.mutesound(*n, *off); }); COMMANDF(soundmuted, "i", (int *n) { intret(audiomgr.soundmuted(*n)); }); VAR(mapsoundchanged, 0, 0, 1); COMMANDF(mapsoundreset, "", () { audiomgr.mapsoundreset(); mapconfigdata.mapsoundlines.shrink(0); mapsoundchanged = 1; flagmapconfigchange(); }); VARF(soundchannels, 4, 128, 1024, audiomgr.setchannels(soundchannels)); VARFP(soundvol, 0, 128, 255, audiomgr.setlistenervol(soundvol)); COMMANDF(registersound, "siii", (char *name, int *vol, int *loop, int *audibleradius) { intret(audiomgr.addsound(name, *vol, -1, *loop != 0, gamesounds, true, *audibleradius)); }); void registerdefaultsounds() { loopi(S_NULL) { ASSERT(soundcfg[i].key == i); audiomgr.addsound(soundcfg[i].name, soundcfg[i].vol, -1, soundcfg[i].loop != 0, gamesounds, true, soundcfg[i].audibleradius); } } const char *soundcategories[SC_NUM + 1] = { "PAIN", "OWNPAIN", "WEAPON", "PICKUP", "MOVEMENT", "BULLET", "OTHER", "VOICECOM", "TEAM", "PUBLIC", "FFA", "FLAGONLY", "" }; void enumsounds(char *what) { vector w; explodelist(what, w); int flags = 0, nflags = 0; loopv(w) { if(w[i][0] == '!') nflags |= 1 << getlistindex(w[i] + 1, soundcategories, false, SC_NUM); else flags |= 1 << getlistindex(w[i], soundcategories, false, SC_NUM); delstring(w[i]); } vector res; loopi(S_NULL) if((soundcfg[i].flags & flags) && !(soundcfg[i].flags & nflags)) cvecprintf(res, "%d %s\n", i, escapestring(soundcfg[i].desc)); resultcharvector(res, -1); } COMMAND(enumsounds, "s"); const char *mapsoundbasepath = "packages/audio/", *mapsoundfinalpath = "ambience/"; const int mapsoundbasepath_n = strlen(mapsoundbasepath), mapsoundfinalpath_n = strlen(mapsoundfinalpath); COMMANDF(mapsound, "si", (char *name, int *maxuses) { filtertext(name, name, FTXT__MEDIAFILEPATH); defformatstring(stripped)("%s%s", mapsoundbasepath, name[0] == '.' && name[1] == '/' ? name + 2 : name); unixpath(path(stripped)); if(mapconfigdata.mapsoundlines.length() > 254) { conoutf("\f3error: too many mapsounds"); flagmapconfigerror(LWW_CONFIGERR); scripterr(); } else if(!strncmp(stripped, mapsoundbasepath, mapsoundbasepath_n)) { name = stripped + mapsoundbasepath_n; audiomgr.addsound(name, 255, *maxuses, true, mapsounds, false, 0); intret(mapconfigdata.mapsoundlines.length()); if(!strncmp(name, mapsoundfinalpath, mapsoundfinalpath_n)) name += mapsoundfinalpath_n; // base path for mapsoundlines is "packages/audio/ambience" copystring(mapconfigdata.mapsoundlines.add().name, name); mapconfigdata.mapsoundlines.last().maxuses = *maxuses; mapsoundchanged = 1; flagmapconfigchange(); } else { conoutf("\f3error: mapsound \"%s\" outside packages/audio/", stripped); flagmapconfigerror(LWW_CONFIGERR); scripterr(); } }); COMMANDF(registermusic, "s", (char *name) { audiomgr.registermusic(name); }); COMMANDF(musicpreload, "i", (int *id) { audiomgr.musicpreload(*id); }); COMMANDF(music, "sis", (char *name, int *millis, char *cmd) { audiomgr.music(name, *millis, cmd); }); void mapsoundslotusage(int *n) // returns all entity indices that use a mapsound of slot n { string res = ""; loopv(ents) if(ents[i].type == SOUND && ents[i].attr1 == *n) concatformatstring(res, "%s%d", i ? " " : "", i); result(res); } COMMAND(mapsoundslotusage, "i"); void reloadmapsoundconfig() { vector sc; getcurrentmapconfig(sc, true); // only soundconfig execute(sc.getbuf()); // cheap and easy way ;) } void deletemapsoundslot(int *n, char *opt) // delete mapsound slot - only if unused or "purge" is specified { EDITMP("deletemapsoundslot"); if(!mapconfigdata.mapsoundlines.inrange(*n)) return; bool purgeall = !strcmp(opt, "purge"), slotused = false; loopv(ents) if(ents[i].type == SOUND && ents[i].attr1 == *n) slotused = true; if(!purgeall && slotused) { conoutf("mapsound slot #%d is in use: can't delete", *n); return; } audiomgr.mapsoundreset(); int deld = 0; loopv(ents) if(ents[i].type == SOUND) { entity &e = ents[i]; if(e.attr1 == *n) { // delete entity deleted_ents.add(e); deletesoundentity(e); memset(&e, 0, sizeof(persistent_entity)); e.type = NOTUSED; deld++; } else if(e.attr1 > *n) e.attr1--; // adjust models in higher slots } mapconfigdata.mapsoundlines.remove(*n); reloadmapsoundconfig(); defformatstring(s)(" (%d mapsounds purged)", deld); conoutf("mapsound slot #%d deleted%s", *n, deld ? s : ""); mapsoundchanged = 1; unsavededits++; hdr.flags |= MHF_AUTOMAPCONFIG; // requires automapcfg } COMMAND(deletemapsoundslot, "is"); void editmapsoundslot(int *n, char *name, char *maxuses) // edit slot parameters != "" { string res = ""; if(mapconfigdata.mapsoundlines.inrange(*n)) { mapsoundline &msl = mapconfigdata.mapsoundlines[*n]; if((*name || *maxuses) && !noteditmode("editmapsoundslot") && !multiplayer("editmapsoundslot")) { // change attributes if(*maxuses) msl.maxuses = strtol(maxuses, NULL, 0); if(*name) copystring(msl.name, strncmp(name, mapsoundfinalpath, mapsoundfinalpath_n) ? name : name + mapsoundfinalpath_n); reloadmapsoundconfig(); mapsoundchanged = 1; unsavededits++; hdr.flags |= MHF_AUTOMAPCONFIG; // requires automapcfg } formatstring(res)("\"%s\" %d", msl.name, msl.maxuses); // give back all current attributes } result(res); } COMMAND(editmapsoundslot, "iss"); void getmapsoundorigin(char *fname) { if(!*fname) return; defformatstring(s)("packages/audio/ambience/%s", fname); findfile(path(s), "r"); const char *res = s; switch(findfilelocation) { case FFL_ZIP: res = "zip"; break; case FFL_WORKDIR: res = fileexists(s, "r") ? "official" : ""; break; case FFL_HOME: res = "custom"; break; default: formatstring(s)("package dir #%d", findfilelocation); break; } result(res); } COMMAND(getmapsoundorigin, "s"); void mapsoundslotbyname(char *name) // returns the slot(s) that a certain mapsound file is used in { string res = ""; loopv(mapconfigdata.mapsoundlines) if(!strcmp(name, mapconfigdata.mapsoundlines[i].name)) concatformatstring(res, "%s%d", *res ? " " : "", i); result(res); } COMMAND(mapsoundslotbyname, "s"); void getmapsoundlist() // create a list of mapsound filenames { vector files; listfilesrecursive("packages/audio/ambience", files); files.sort(stringsort); loopvrev(files) if(files.inrange(i + 1) && !strcmp(files[i], files[i + 1])) delstring(files.remove(i + 1)); // remove doubles int pn = strlen("packages/audio/ambience/"); vector res; loopv(files) { if(!strncmp(files[i], "packages/audio/ambience/", pn)) { const char *s = files[i] + pn; int sn = strlen(s); if(sn > 4) { const char *e = s + sn - 4; if(!strcmp(e, ".ogg") || !strcmp(e, ".wav")) cvecprintf(res, "\"%s\"\n", s); } } } files.deletearrays(); resultcharvector(res, -1); } COMMAND(getmapsoundlist, ""); struct tempmsslot { mapsoundline m; vector oldslot; bool used; }; int tempmscmp(tempmsslot *a, tempmsslot *b) { int n = strcmp(a->m.name, b->m.name); if(n) return n; return a->m.maxuses - b->m.maxuses; } int tempmssort(tempmsslot *a, tempmsslot *b) { int n = tempmscmp(a, b); return n ? n : a->oldslot[0] - b->oldslot[0]; } int tempmsunsort(tempmsslot *a, tempmsslot *b) { return a->oldslot[0] - b->oldslot[0]; } void sortmapsoundslots(char **args, int numargs) { bool nomerge = false, mergeused = false, nosort = false, unknownarg = false; loopi(numargs) if(args[i][0]) { if(!strcasecmp(args[i], "nomerge")) nomerge = true; else if(!strcasecmp(args[i], "nosort")) nosort = true; else if(!strcasecmp(args[i], "mergeused")) mergeused = true; else { conoutf("sortmapsoundslots: unknown argument \"%s\"", args[i]); unknownarg = true; } } EDITMP("sortmapsoundslots"); if(unknownarg || mapconfigdata.mapsoundlines.length() < 3) return; vector tempslots; loopv(mapconfigdata.mapsoundlines) { tempslots.add().m = mapconfigdata.mapsoundlines[i]; tempslots.last().oldslot.add(i); tempslots.last().used = false; } loopv(ents) if(ents[i].type == SOUND && tempslots.inrange(ents[i].attr1)) tempslots[ents[i].attr1].used = true; tempslots.sort(tempmssort); // remove double entries if(!nomerge) loopvrev(tempslots) if(i > 0) { tempmsslot &s1 = tempslots[i], &s0 = tempslots[i - 1]; if(!tempmscmp(&s0, &s1) && (mergeused || !s0.used || !s1.used)) { if(s1.used) s0.used = true; loopvj(s1.oldslot) s0.oldslot.add(s1.oldslot[j]); tempslots.remove(i); } } if(nosort) tempslots.sort(tempmsunsort); // create translation table uchar newslot[256]; loopk(256) newslot[k] = k; loopv(tempslots) { tempmsslot &t = tempslots[i]; loopvj(t.oldslot) { if(t.oldslot[j] < 256) newslot[t.oldslot[j]] = i; } } // translate all mapsound entities loopv(ents) if(ents[i].type == SOUND) ents[i].attr1 = newslot[ents[i].attr1 & 255]; conoutf("%d mapsound slots%s, %d %sslots merged", tempslots.length(), nosort ? "" : " sorted", mapconfigdata.mapsoundlines.length() - tempslots.length(), mergeused ? "" : "unused "); // rewrite mapmodel slot list mapconfigdata.mapsoundlines.shrink(tempslots.length()); loopv(tempslots) { mapconfigdata.mapsoundlines[i] = tempslots[i].m; } reloadmapsoundconfig(); unsavededits++; mapsoundchanged = 1; hdr.flags |= MHF_AUTOMAPCONFIG; // requires automapcfg } COMMAND(sortmapsoundslots, "v"); assaultcube-1.2.0.2.1/source/src/autodownload.cpp000066400000000000000000000503011352165075300216250ustar00rootroot00000000000000// autodownload.cpp // fetching missing media files from http servers (~ akimbo) #include "cube.h" #define DEBUGCOND (autodownloaddebug == 1) struct pckserver { string host; int priority, ping, resolved; hashtable updates; pckserver() { memset(&host, 0, (char *)&updates - (char *)&host); } }; struct package { string name, fullpath, requestname, host; int type, iszip, strictnames, server; const char **exts; package() { memset(&name, 0, sizeof(struct package)); } }; vector pckservers; vector pendingpackages; VARP(autodownload, 0, 1, 1); VAR(autodownloaddebug, 0, 0, 1); sl_semaphore sem_pckservers(1, NULL); // control access to the pckservers vector void resetpckservers() { delfile(findfile("config" PATHDIVS "pcksources.cfg", "w")); conoutf("\f3Restart AssaultCube to take effect after resetting the list of packages source servers"); } COMMAND(resetpckservers, ""); void addpckserver(char *host, char *priority) // add/adjust a package server { sem_pckservers.wait(); if(*host) { pckserver *s = NULL; loopv(pckservers) if(!strcmp(host, pckservers[i]->host)) s = pckservers[i]; DEBUG((s ? "updated" : "new") << " host " << host << ", priority " << priority); if(!s) s = pckservers.add(new pckserver); copystring(s->host, host); if(*priority) s->priority = atoi(priority); } sem_pckservers.post(); } COMMAND(addpckserver, "ss"); void getpckserver() // return a table of all package servers with four columns { vector res; if(sem_pckservers.timedwait(1000)) cvecprintf(res, "\"serverlist is busy, try again later\" "); // single-word return value signals an error else { loopv(pckservers) cvecprintf(res, "\"%s\" %d %d %d\n", pckservers[i]->host, pckservers[i]->priority, pckservers[i]->ping, pckservers[i]->resolved); sem_pckservers.post(); } resultcharvector(res, -1); } COMMAND(getpckserver, ""); SDL_mutex *pckpinglog_lock; // auxilliary locking for pckping_log vector pckping_log; // access controlled by sem_pckservers (and pckpinglog_lock) const char *updatestxt = "/updates.txt"; int pingpckserver(void *data) // fetch updates.txt from a media server, measure required time { httpget h; urlparse u; pckserver *s = (pckserver *)data; u.set(s->host); s->resolved = h.set_host(u.domain) ? 1 : 0; SDL_mutexP(pckpinglog_lock); cvecprintf(pckping_log, "lresolving hostname %s %s (%s)\n", u.domain, s->resolved ? "succeeded" : "failed", iptoa(ntohl(h.ip.host))); SDL_mutexV(pckpinglog_lock); if(s->resolved) { if(*u.port) h.set_port(atoi(u.port)); defformatstring(url)("%s%s", u.path, updatestxt); int res = h.get(url, 5000, 10000, 0, true); // http HEAD request only - to get a nice ping value if(res >= 0 && h.response > 0) { s->ping = h.elapsedtime; SDL_mutexP(pckpinglog_lock); cvecprintf(pckping_log, "lhttp head %s:%d%s response time: %d, status: %d, contentlength: %d\n", u.domain, h.ip.port, url, s->ping, h.response, h.contentlength); #ifdef _DEBUG if(DEBUGCOND) { cvecprintf(pckping_log, "l%s", escapestring(h.header, true, true)); pckping_log.add('\n'); } #endif SDL_mutexV(pckpinglog_lock); if(h.response == 200) { h.outvec = new vector; res = h.get(url, 5000, 20000); // http GET if(res >= 0 && h.response == 200) { // parse updates.txt h.outvec->add('\0'); s->updates.clear(); parseupdatelist(s->updates, (char *)h.outvec->getbuf()); // don't filter entries SDL_mutexP(pckpinglog_lock); cvecprintf(pckping_log, "lgot %s:%d%s: %d bytes, %d valid update lines\n", u.domain, h.ip.port, url, res, s->updates.numelems); SDL_mutexV(pckpinglog_lock); } else { SDL_mutexP(pckpinglog_lock); cvecprintf(pckping_log, "lretrieving %s:%d%s failed: response %d, err: %s\n", u.domain, h.ip.port, url, h.response, h.err ? h.err : "(null)"); #ifdef _DEBUG if(DEBUGCOND) { if(!h.header) { h.rawrec.setsize(min(h.rawrec.length(), MAXSTRLEN)); h.rawrec.add('\0'); } cvecprintf(pckping_log, "lheader: %s", escapestring(h.header ? h.header : h.rawrec.getbuf(), true, true)); pckping_log.add('\n'); } #endif SDL_mutexV(pckpinglog_lock); } DELETEP(h.outvec); } } else { // connection to server failed SDL_mutexP(pckpinglog_lock); cvecprintf(pckping_log, "lpinging %s failed, err: %s\n", s->host, h.err ? h.err : "(null)"); SDL_mutexV(pckpinglog_lock); } } h.disconnect(); return 0; } int pingallpckservers(void *data) { sem_pckservers.wait(); if(autodownload) { pckpinglog_lock = SDL_CreateMutex(); vector pckthreads; int nop, good = 0, disabled = 0; loopv(pckservers) if(pckservers[i]->priority > -1000) pckthreads.add(SDL_CreateThread(pingpckserver, "PingPackageServer", pckservers[i])); // start pinging all servers at once loopv(pckthreads) if(pckthreads[i]) SDL_WaitThread(pckthreads[i], &nop); // wait for all ping threads to finish SDL_DestroyMutex(pckpinglog_lock); loopv(pckservers) { pckserver *s = pckservers[i]; if(s->priority <= -1000) disabled++; else if(s->resolved && s->ping) good++; } int bad = pckservers.length() - good - disabled; cvecprintf(pckping_log, "csuccessfully pinged %d media server%s, %d failure%s, %d disabled\n", good, good == 1 ? "" : "s", bad, bad == 1 ? "" : "s", disabled); } else cvecprintf(pckping_log, "c\f4(automatic media file download deactivated)\n"); pckping_log.add('e'); // signal end of thread sem_pckservers.post(); return 0; } SDL_Thread *pingallpckthread = NULL; void setupautodownload() { // fetch updates from all configured servers // in a background thread // during startup pingallpckthread = SDL_CreateThread(pingallpckservers, "PingAllPackageServers", NULL); } void pollautodownloadresponse() // thread-safe feedback from the autodownload-updater thread { static int donepolling = 0; if(donepolling) return; if(!sem_pckservers.trywait()) { if(pckping_log.length()) { pckping_log.add('\0'); char *p, *l = pckping_log.getbuf(); do { // break into single lines if((p = strchr(l, '\n'))) *p = '\0'; if(*l == 'c') conoutf("%s", l + 1); // line starts with "c" -> console else if(*l == 'e') donepolling = 1; // line starts with "e" -> end polling else clientlogf("%s", l + 1); // line starts with "l" -> log l = p + 1; } while(p); pckping_log.setsize(0); } sem_pckservers.post(); } if(donepolling) { int nop; SDL_WaitThread(pingallpckthread, &nop); // detaching the thread would be preferrable, but SDL 1.2 doesn't provide that pingallpckthread = NULL; } } const char *mmexts[] = { ".md2", ".md3", ".cfg", ".txt", ".jpg", ".png", "" }, *mapexts[] = { ".cgz", ".cfg", "" }, *sbexts[] = { "_lf.jpg", "_rt.jpg", "_ft.jpg", "_bk.jpg", "_dn.jpg", "_up.jpg", "_license.txt", "" }; bool requirepackage(int type, const char *name, const char *host) { const char *prefix = NULL, *checkprefix = NULL, *forceext = NULL; package *pck = new package; switch(type) { case PCK_AUDIO: prefix = "packages/audio/"; checkprefix = "ambience/"; forceext = ".ogg"; break; case PCK_MAPMODEL: prefix = "packages/models/"; checkprefix = "mapmodels/"; pck->iszip = 1; pck->exts = mmexts; break; case PCK_TEXTURE: checkprefix = "packages/"; forceext = ".jpg"; break; case PCK_SKYBOX: prefix = "packages/textures/skymaps/"; pck->iszip = pck->strictnames = 1; pck->exts = sbexts; break; case PCK_MAP: prefix = "packages/maps/"; pck->iszip = pck->strictnames = 1; pck->exts = mapexts; break; case PCK_MOD: prefix = "mods/"; forceext = ".zip"; break; default: conoutf("\f3requirepackage: illegal package type %d (\"%s\")", type, name); // should probably be fatal() delete pck; return false; } string upath; copystring(upath, name); unixpath(upath); filtertext(pck->name, name, FTXT__MEDIAFILEPATH); // also changes backslashes to slashes if(strlen(upath) > 100 || strcmp(upath, pck->name) || (checkprefix && strncmp(pck->name, checkprefix, strlen(checkprefix))) || (type == PCK_MOD && !validzipmodname(upath))) { conoutf("\f3requirepackage: illegal media path \"%s\" (type: %d)", name, type); delete pck; return false; } if(forceext && strlen(pck->name) > strlen(forceext) && !strcmp(pck->name + strlen(pck->name) - strlen(forceext), forceext)) forceext = NULL; // filename already has required extension formatstring(pck->fullpath)("%s%s%s", prefix ? prefix : "", pck->name, forceext ? forceext : ""); formatstring(pck->requestname)("/%s%s%s", pck->fullpath, type == PCK_MAP ? ".cgz" : "", pck->iszip ? ".zip" : ""); // special case map zips: file ending .cgz.zip loopv(pendingpackages) if(!strcmp(pendingpackages[i]->requestname, pck->requestname)) { // request already queued delete pck; return false; } pck->type = type; if(host) copystring(pck->host, host); // assign fixed server DEBUG("name: " << pck->name << ", fullpath: " << pck->fullpath << ", requestname: " << pck->requestname << ", host: " << pck->host << ", type: " << pck->type << ", iszip: " << pck->iszip << ", strictnames: " << pck->strictnames << ", server: " << pck->server << ", exts: " << (pck->exts ? *pck->exts : "")); pendingpackages.add(pck); return true; } VAR(rereadtexturelists, 0, 1, 1); // flag to indicate additional texture files to trigger a menu rebuild (defaults to "1" to build the menus after startup) VAR(rereadsoundlists, 0, 1, 1); // same for map sounds void processdownload(package *pck, stream *f) // write downloaded data to file(s) { f->seek(0); if(pck->iszip) { // unpack zip file vector files; void *mz = zipmanualopen(f, files); if(mz) { string filename, cleanzname; loopv(files) { if(i >= MAXFILESINADZIP) break; const char *zname = behindpath(files[i]); // ignore _all_ paths inside the zip filtertext(cleanzname, zname, FTXT__MEDIAFILENAME); bool isok = false; for(int n = 0; *pck->exts[n]; n++) { if(pck->strictnames) { // only base names and listed extensions allowed formatstring(filename)("%s%s", pck->fullpath, pck->exts[n]); isok = !strcmp(behindpath(filename), zname); } else { // any name with listed extension, written to subdirectory int zlen = (int)strlen(zname), elen = (int)strlen(pck->exts[n]); if((isok = (zlen > elen && !strcmp(zname + zlen - elen, pck->exts[n])))) formatstring(filename)("%s/%s", pck->fullpath, zname); } if(isok) break; } if(isok && !strcmp(cleanzname, zname)) { stream *zf = openfile(path(filename), "wb"); if(zf) { DEBUGCODE(int got =) zipmanualread(mz, i, zf, MAXMEDIADOWNLOADFILESIZE); // extract file from zip and write to @filename DEBUGCODE(clientlogf("extracted %d bytes from %s %s, written to %s", got, pck->name, files[i], filename)); delete zf; } } else conoutf("\f3illegal filename \"%s\" in %s", files[i], pck->requestname); } zipmanualclose(mz); } else clientlogf("failed to open zip file %s", pck->requestname); } else { // write single file stream *d = openfile(path(pck->fullpath, true), "wb"); if(d) { streamcopy(d, f, pck->type == PCK_MOD ? MAXMODDOWNLOADSIZE : MAXMEDIADOWNLOADFILESIZE); delete d; } delete f; } switch(pck->type) // some housekeeping { case PCK_SKYBOX: case PCK_TEXTURE: rereadtexturelists = 1; break; case PCK_AUDIO: rereadsoundlists = 1; break; case PCK_MAP: case PCK_MAPMODEL: break; } } bool canceldownloads = false; int progress_n, progress_of; int progress_callback_dlpackage(void *data, float progress) { if(progress_of < 0) { defformatstring(txt)("downloading %s... (esc to abort)", (const char *)data); if(progress < 0) show_out_of_renderloop_progress(progress + 1.0f, "waiting for response (esc to abort)"); else show_out_of_renderloop_progress(min(progress, 1.0f), txt); } else loadingscreen("downloading package %d of %d...\n%s \fs%s%d%%\fr\n(ESC to cancel)", progress_n, progress_of, (const char *)data, progress < 0 ? "\f3waiting " : "", int(100.0 * fabs(progress))); if(interceptkey(SDLK_ESCAPE)) { canceldownloads = true; return 1; } return 0; } bool dlpackage(httpget &h, package *pck, pckserver *s) // download one package from one server { urlparse u; u.set(s ? s->host : pck->host); h.callbackfunc = progress_callback_dlpackage; h.callbackdata = pck->name; progress_n = progress_of - pendingpackages.length(); if(*u.domain && h.set_host(u.domain)) { if(*u.port) h.set_port(atoi(u.port)); h.outstream = openvecfile(NULL); defformatstring(url)("%s%s", u.path, pck->requestname); int got = h.get(url, 6000, 90000); if(got < 0 || !h.response) { if(!canceldownloads && s) s->ping = 0; // received a hard error from the server connection, better not try this one again clientlogf("download %s:%d%s failed, err: %s", u.domain, h.ip.port, url, h.err ? h.err : "(null)"); h.disconnect(); } else { if(h.response == 200) { DEBUGCODE(clientlogf("downloaded %s:%d%s, %d bytes (%d raw), %d msec", u.domain, h.ip.port, url, got, h.contentlength, h.elapsedtime)); processdownload(pck, h.outstream); h.outstream = NULL; // deleted by processdownload() return true; } else clientlogf("download %s:%d%s failed, server response %d%s%s", u.domain, h.ip.port, url, h.response, h.err ? ", err: " : "", h.err ? h.err : ""); } DELETEP(h.outstream); } else { if(s) s->resolved = 0; clientlogf("resolving host \"%s\" failed", u.domain); h.disconnect(); } return false; } int packagesort_server(package **a, package **b) { return (*b)->server - (*a)->server; } int packagesort_name(package **a, package **b) { return strcmp((*b)->name, (*a)->name); } int packagesort_host(package **a, package **b) { return strcmp((*b)->host, (*a)->host); } int pckserversort(pckserver **a, pckserver **b) { if((*a)->resolved != (*b)->resolved) return (*b)->resolved - (*a)->resolved; // group resolvable hosts at the top if((*a)->priority != (*b)->priority) return (*b)->priority - (*a)->priority; // manual priority wins over ping (high priority to the top) if((*a)->ping && (*b)->ping) return (*a)->ping - (*b)->ping; // smaller ping wins return (*b)->ping - (*a)->ping; // or whichever ping is not zero } int downloadpackages(bool loadscr) // get all pending packages { bool failed = false; httpget h; canceldownloads = false; progress_of = loadscr ? pendingpackages.length() : -1; if(sem_pckservers.timedwait(1000)) { // can't lock the server list -> this means, the server ping threads have not finished yet if(pendingpackages.length()) conoutf("\f3failed to download packages: still pinging the servers..."); return 0; } pckservers.sort(pckserversort); loopv(pendingpackages) { package *pck = pendingpackages[i]; int maxrev = 0, *rev = NULL; pck->server = -1; // server with highest revision for that content loopvj(pckservers) { pckserver *s = pckservers[j]; if(s->priority > -1000 && s->resolved && s->ping && (rev = s->updates.access(pck->requestname)) && *rev > maxrev) { maxrev = *rev; pck->server = j; } } } // get all packages with auto-assigned servers pendingpackages.sort(packagesort_server); loopvrev(pendingpackages) { if(canceldownloads) break; package *pck = pendingpackages[i]; if(!*pck->host && pckservers.inrange(pck->server) && pckservers[pck->server]->resolved) { if(dlpackage(h, pck, pckservers[pck->server])) delete pendingpackages.remove(i); else pck->server = -1; // auto-assigned server didn't work - try any other now } } // try all packages from all servers - high priority servers first pendingpackages.sort(packagesort_name); loopvj(pckservers) { pckserver *s = pckservers[j]; if(s->priority <= -1000 || !s->resolved || !s->ping) continue; loopv(pendingpackages) { if(canceldownloads) break; package *pck = pendingpackages[i]; if(!*pck->host) { if(dlpackage(h, pck, s)) delete pendingpackages.remove(i--); } if(!s->resolved || !s->ping) break; } } if(canceldownloads) pendingpackages.deletecontents(); // print error messages for all failed packages - and remove them loopv(pendingpackages) { package *pck = pendingpackages[i]; if(!*pck->host) { conoutf("\f3failed to load %s from any host, giving up", pck->name); delete pendingpackages.remove(i--); failed = true; } } // get all packages with manually assigned hosts - those will be deleted from the list regardless of success! pendingpackages.sort(packagesort_host); loopvrev(pendingpackages) { package *pck = pendingpackages[i]; if(!canceldownloads && !dlpackage(h, pck, NULL)) { conoutf("\f3failed to load %s from %s, giving up", pck->name, pck->host); failed = true; } delete pendingpackages.remove(i); } sem_pckservers.post(); h.disconnect(); return failed ? 0 : h.traffic; } void writepcksourcecfg() { if(pckservers.length()) { stream *f = openfile("config" PATHDIVS "pcksources.cfg", "w"); if(!f) return; f->printf("// list of package source servers (only add servers you trust!)\n\n"); f->printf("autodownloaddebug %d\n", autodownloaddebug); // saved.cfg is loaded too late for this to be in it and be efficient... loopv(pckservers) { pckserver *s = pckservers[i]; if(s->priority > -10000) f->printf("addpckserver %s %d // ping: %d, resolved: %d, updates: %d\n", s->host, s->priority, s->ping, s->resolved, s->updates.numelems); } delete f; } } void getmod(char *name) { if(requirepackage(PCK_MOD, name) && downloadpackages(false)) conoutf("mod package %s successfully downloaded", name); else conoutf("failed to download mod package %s", name); } COMMAND(getmod, "s"); assaultcube-1.2.0.2.1/source/src/bot/000077500000000000000000000000001352165075300172065ustar00rootroot00000000000000assaultcube-1.2.0.2.1/source/src/bot/ac_bot.cpp000066400000000000000000000033361352165075300211460ustar00rootroot00000000000000// // C++ Implementation: bot // // Description: Main bot code for AssaultCube // // Main bot file // // Author: Rick // // // #include "cube.h" #include "bot.h" extern int triggertime; extern itemstat itemstats[]; extern void spawnstate(playerent *d); //AC Bot class begin void CACBot::Spawn() { // Init all bot variabeles m_pMyEnt->nextprimary = 2 + rnd(5); // 2011jan18:ft: 2 == GUN_CARBINE, GUN_SHOTGUN, GUN_SUBGUN, GUN_SNIPER, GUN_ASSAULT - if CPISTOL is activated this needs a FIXME to rnd(6) m_pMyEnt->targetyaw = m_pMyEnt->targetpitch = 0.0f; m_pMyEnt->pBot = this; spawnplayer(m_pMyEnt); m_eCurrentBotState = STATE_NORMAL; m_iShootDelay = m_iChangeWeaponDelay = 0; m_iCheckEnvDelay = 0; m_vPrevOrigin = g_vecZero; m_iStuckCheckDelay = lastmillis + 250; m_bStuck = false; m_iStuckTime = 0; m_iStrafeTime = m_iStrafeCheckDelay = 0; m_iMoveDir = DIR_NONE; m_pPrevEnemy = NULL; m_iCombatNavTime = 0; m_iSPMoveTime = 0; m_iEnemySearchDelay = 0; m_bCombatJump = false; m_iCombatJumpDelay = 0; m_iHuntDelay = 0; m_vHuntLocation = m_vPrevHuntLocation = g_vecZero; m_pHuntTarget = NULL; m_fPrevHuntDist = 0.0f; m_iHuntLastTurnLessTime = m_iHuntPlayerUpdateTime = m_iHuntPauseTime = 0; m_iLastJumpPad = 0; m_pTargetEnt = NULL; m_iCheckTeleporterDelay = m_iCheckJumppadsDelay = 0; m_iCheckEntsDelay = 0; m_iCheckTriggersDelay = 0; m_iLookForWaypointTime = 0; m_iAimDelay = 0; m_fYawToTurn = m_fPitchToTurn = 0.0f; m_vGoal = m_vWaterGoal = g_vecZero; ResetWaypointVars(); } void CACBot::CheckItemPickup() { checkitems(m_pMyEnt); } // AC Bot class end assaultcube-1.2.0.2.1/source/src/bot/ac_bot.h000066400000000000000000000016551352165075300206150ustar00rootroot00000000000000// // C++ Implementation: bot // // Description: // // Header specific for AC_CUBE // // Author: Rick // // // #ifndef AC_BOT_H #define AC_BOT_H //#define BOTDEBUG #define MAX_WEAPONS 10 class CACBot: public CBot { public: friend class CBotManager; friend class CWaypointClass; virtual void CheckItemPickup(void); // AI Functions virtual bool ChoosePreferredWeapon(void); void Reload(int Gun); virtual entity *SearchForEnts(bool bUseWPs, float flRange=9999.0f, float flMaxHeight=JUMP_HEIGHT); virtual bool HeadToTargetEnt(void); virtual bool DoSPStuff(void); virtual void Spawn(void); }; inline void AddScreenText(const char *t, ...) {} // UNDONE inline void AddDebugText(const char *t, ...) { #if defined(_DEBUG) && defined(BOTDEBUG) va_list v; va_start(v, t); conoutf(t,v); va_end(v); #endif } #endif assaultcube-1.2.0.2.1/source/src/bot/ac_bot_ai.cpp000066400000000000000000000254331352165075300216210ustar00rootroot00000000000000// // C++ Implementation: ac_bot_ai // // Description: The AI part of the bot for ac is here(navigation, shooting etc) // // // Author: // #include "cube.h" #include "bot.h" weaponinfo_s WeaponInfoTable[MAX_WEAPONS] = { // DD: desired distance // FD: fire distance // mA: min desired Ammo // ---- Type : -- minDD -- maxDD -- minFD -- maxFD -- mA { TYPE_MELEE, 0.0f, 5.0f, 0.0f, 3.5f, 0 }, // KNIFE { TYPE_NORMAL, 3.5f, 15.0f, 3.0f, 60.0f, 6 }, // PISTOL { TYPE_SNIPER, 15.0f, 80.0f, 3.0f, 180.0f, 2 }, // CARBINE // min and max FD just guesstimates for now { TYPE_SHOTGUN, 0.0f, 15.0f, 0.0f, 50.0f, 3 }, // SHOTGUN { TYPE_AUTO, 0.0f, 25.0f, 3.0f, 60.0f, 10 }, // SUBGUN { TYPE_SNIPER, 10.0f, 125.0f, 3.0f, 200.0f, 3 }, // SNIPER { TYPE_AUTO, 20.0f, 80.0f, 3.0f, 150.0f, 6 }, // ASSAULT { TYPE_AUTO, 0.0f, 0.0f, 3.0f, 0.0f, 6 }, // CPISTOL { TYPE_GRENADE, 5.0f, 30.0f, 3.0f, 50.0f, 1 }, // GRENADE { TYPE_AUTO, 0.0f, 50.0f, 3.0f, 50.0f, 0 } // AKIMBO }; // Code of CACBot - Start bool CACBot::ChoosePreferredWeapon() { short bestWeapon = m_pMyEnt->gunselect; short bestWeaponScore = 0; short sWeaponScore; float flDist = GetDistance(m_pMyEnt->enemy->o); // Choose a weapon for(int i=0;i 1 ? 5 : 0; // Primary are usually better if (!m_pMyEnt->mag[i] && WeaponInfoTable[i].eWeaponType != TYPE_MELEE) { continue; } else { sWeaponScore += 5; } if((flDist >= WeaponInfoTable[i].flMinDesiredDistance) && (flDist <= WeaponInfoTable[i].flMaxDesiredDistance)) { // In desired range for this weapon sWeaponScore += 5; // Increase score much if(i == GUN_PISTOL || WeaponInfoTable[i].eWeaponType == TYPE_MELEE) { if(WeaponInfoTable[m_pMyEnt->primary].eWeaponType == TYPE_SNIPER) { sWeaponScore += 10; // At a close range, knife & pistol are strong with a sniper like primary weapon } if(WeaponInfoTable[i].eWeaponType == TYPE_MELEE && WeaponInfoTable[m_pMyEnt->primary].eWeaponType == TYPE_SHOTGUN) { sWeaponScore -= 2; // Penalize a bit knife on close range with shotgun } } } else if ((flDist < WeaponInfoTable[i].flMinFireDistance) || (flDist > WeaponInfoTable[i].flMaxFireDistance)) { continue; // Wrong distance for this weapon } if(i == GUN_GRENADE) { sWeaponScore += 30; // Nades have high priority } // The ideal distance would be between the Min and Max desired distance. // Score on the difference of the avarage of the Min and Max desired distance. float flAvarage = (WeaponInfoTable[i].flMinDesiredDistance + WeaponInfoTable[i].flMaxDesiredDistance) / 2.0f; float flIdealDiff = fabs(flDist - flAvarage); if (flIdealDiff < 0.5f) // Close to ideal distance sWeaponScore += 4; else if (flIdealDiff <= 1.0f) sWeaponScore += 2; // Now rate the weapon on available ammo... if (WeaponInfoTable[i].sMinDesiredAmmo > 0) { // Calculate how much percent of the min desired ammo the bot has float flDesiredPercent = (float(m_pMyEnt->ammo[i]) / float(WeaponInfoTable[i].sMinDesiredAmmo)) * 100.0f; if (flDesiredPercent >= 400.0f) sWeaponScore += 4; else if (flDesiredPercent >= 200.0f) sWeaponScore += 3; else if (flDesiredPercent >= 100.0f) sWeaponScore += 1; } else { // Not needing ammo is an advantage... sWeaponScore += 10; } if(sWeaponScore > bestWeaponScore) { bestWeaponScore = sWeaponScore; bestWeapon = i; } } if(lastmillis > m_iChangeWeaponDelay) { SelectGun(bestWeapon); } return true; }; void CACBot::Reload(int Gun) { }; entity *CACBot::SearchForEnts(bool bUseWPs, float flRange, float flMaxHeight) { /* Entities are scored on the following things: - Visibility - For ammo: Need(ie has this bot much of this type or not) - distance */ float flDist; entity *pNewTargetEnt = NULL; waypoint_s *pWptNearBot = NULL, *pBestWpt = NULL; short sScore, sHighestScore = 0; if ((WaypointClass.m_iWaypointCount >= 1) && bUseWPs) pWptNearBot = GetNearestWaypoint(15.0f); #ifdef WP_FLOOD if (!pWptNearBot && bUseWPs) pWptNearBot = GetNearestFloodWP(5.0f); #endif loopv(ents) { sScore = 0; entity &e = ents[i]; vec o(e.x, e.y, S(e.x, e.y)->floor+player1->eyeheight); if (!ents[i].spawned) continue; if (OUTBORD(e.x, e.y)) continue; bool bInteresting = false; short sAmmo = 0, sMaxAmmo = 0; switch(e.type) { case I_CLIPS: sMaxAmmo = ammostats[GUN_PISTOL].max; bInteresting = (m_pMyEnt->ammo[GUN_PISTOL]ammo[GUN_PISTOL]; break; case I_AMMO: sMaxAmmo = ammostats[m_pMyEnt->primary].max; bInteresting = (m_pMyEnt->ammo[m_pMyEnt->primary]ammo[m_pMyEnt->primary]; break; case I_GRENADE: sMaxAmmo = ammostats[GUN_GRENADE].max; bInteresting = (m_pMyEnt->mag[GUN_GRENADE]health < sMaxAmmo); sAmmo = m_pMyEnt->health; break; case I_HELMET: case I_ARMOUR: sMaxAmmo = powerupstats[I_ARMOUR-I_HEALTH].max; bInteresting = (m_pMyEnt->armour < sMaxAmmo); sAmmo = m_pMyEnt->armour; break; case I_AKIMBO: bInteresting = !m_pMyEnt->akimbo; sAmmo = -1; break; }; if (!bInteresting) continue; // Not an interesting item, skip // Score on ammo and need // Akimbo & nade if (sAmmo == -1) { sScore += 75; // Bonus } else { // Calculate current percentage of max ammo float percent = ((float)sAmmo / (float)sMaxAmmo) * 100.0f; if (percent > 100.0f) percent = 100.0f; sScore += ((100 - short(percent))/2); } flDist = GetDistance(o); if (flDist > flRange) continue; // Score on distance float f = flDist; if (f > 100.0f) f = 100.0f; sScore += ((100 - short(f)) / 2); waypoint_s *pWptNearEnt = NULL; // If this entity isn't visible check if there is a nearby waypoint if (!IsReachable(o, flMaxHeight))//(!IsVisible(o)) { if (!pWptNearBot) continue; #ifdef WP_FLOOD if (pWptNearBot->pNode->iFlags & W_FL_FLOOD) pWptNearEnt = GetNearestFloodWP(o, 8.0f); else #endif pWptNearEnt = GetNearestWaypoint(o, 15.0f); if (!pWptNearEnt) continue; } // Score on visibility if (pWptNearEnt == NULL) // Ent is visible sScore += 30; else sScore += 15; if (sScore > sHighestScore) { // Found a valid wp near the bot and the ent,so...lets store it :) if (pWptNearEnt) pBestWpt = pWptNearEnt; else pBestWpt = NULL; // Best ent so far doesn't need any waypoints sHighestScore = sScore; pNewTargetEnt = &ents[i]; } } if (pNewTargetEnt) { // Need waypoints to reach it? if (pBestWpt) { ResetWaypointVars(); SetCurrentWaypoint(pWptNearBot); SetCurrentGoalWaypoint(pBestWpt); } m_vGoal.x = pNewTargetEnt->x; m_vGoal.y = pNewTargetEnt->y; m_vGoal.z = S(pNewTargetEnt->x, pNewTargetEnt->y)->floor+player1->eyeheight; } return pNewTargetEnt; } bool CACBot::HeadToTargetEnt() { if (m_pTargetEnt) { vec o(m_pTargetEnt->x, m_pTargetEnt->y, S(m_pTargetEnt->x, m_pTargetEnt->y)->floor+m_pMyEnt->eyeheight); if (m_pTargetEnt->spawned && (!UnderWater(m_pMyEnt->o) || !UnderWater(o))) { bool bIsVisible = false; if (m_pCurrentGoalWaypoint) { if ((GetDistance(o) <= 20.0f) && IsReachable(o, 1.0f)) bIsVisible = true; else if (HeadToGoal()) { //debugbeam(m_pMyEnt->o, m_pCurrentWaypoint->pNode->v_origin); //debugbeam(m_pMyEnt->o, // m_pCurrentGoalWaypoint->pNode->v_origin); AddDebugText("Using WPs for ents"); return true; } } else bIsVisible = IsVisible(o); if (bIsVisible) { if (m_pCurrentWaypoint || m_pCurrentGoalWaypoint) { condebug("ent is now visible"); ResetWaypointVars(); } float flHeightDiff = o.z - m_pMyEnt->o.z; bool bToHigh = false; if (Get2DDistance(o) <= 2.0f) { if (flHeightDiff >= 1.5f) { if (flHeightDiff <= JUMP_HEIGHT) { #ifndef RELEASE_BUILD char sz[64]; sprintf(sz, "Ent z diff: %f", o.z-m_pMyEnt->o.z); condebug(sz); #endif // Jump if close to ent and the ent is high m_pMyEnt->jumpnext = true; } else bToHigh = true; } } if (!bToHigh) { AimToVec(o); return true; } } } } return false; } bool CACBot::DoSPStuff() { return false; } // Code of CACBot - End assaultcube-1.2.0.2.1/source/src/bot/bot.cpp000066400000000000000000000253711352165075300205060ustar00rootroot00000000000000// // C++ Implementation: bot // // Description: // // Contains code of the base bot class // // Author: Rick // // // #include "cube.h" #include "bot.h" vector bots; extern int triggertime; extern itemstat itemstats[]; extern ENetHost *clienthost; const vec g_vecZero(0, 0, 0); //Bot class begin CBot::~CBot() { // Delete all waypoints loopi(MAX_MAP_GRIDS) { loopj(MAX_MAP_GRIDS) { while (m_WaypointList[i][j].Empty() == false) delete m_WaypointList[i][j].Pop(); } } } void CBot::Spawn() { // Init all bot variabeles spawnplayer(m_pMyEnt); m_pMyEnt->targetyaw = m_pMyEnt->targetpitch = 0.0f; m_pMyEnt->enemy = NULL; m_pMyEnt->maxspeed = 22.0f; m_pMyEnt->pBot = this; m_eCurrentBotState = STATE_NORMAL; m_iShootDelay = m_iChangeWeaponDelay = 0; m_iCheckEnvDelay = 0; m_vPrevOrigin = g_vecZero; m_iStuckCheckDelay = lastmillis + 250; m_bStuck = false; m_iStuckTime = 0; m_iStrafeTime = m_iStrafeCheckDelay = 0; m_iMoveDir = DIR_NONE; m_pPrevEnemy = NULL; m_iCombatNavTime = 0; m_iSPMoveTime = 0; m_iEnemySearchDelay = 0; m_iSawEnemyTime = 0; m_bCombatJump = false; m_iCombatJumpDelay = 0; m_iHuntDelay = 0; m_vHuntLocation = m_vPrevHuntLocation = g_vecZero; m_pHuntTarget = NULL; m_fPrevHuntDist = 0.0f; m_iHuntLastTurnLessTime = m_iHuntPlayerUpdateTime = m_iHuntPauseTime = 0; m_iLookAroundDelay = m_iLookAroundTime = m_iLookAroundUpdateTime = 0; m_fLookAroundYaw = 0.0f; m_bLookLeft = false; m_iLastJumpPad = 0; m_pTargetEnt = NULL; while(!m_UnreachableEnts.Empty()) delete m_UnreachableEnts.Pop(); m_iCheckTeleporterDelay = m_iCheckJumppadsDelay = 0; m_iCheckEntsDelay = 0; m_iCheckTriggersDelay = 0; m_iLookForWaypointTime = 0; m_iAimDelay = 0; m_fYawToTurn = m_fPitchToTurn = 0.0f; m_vGoal = m_vWaterGoal = g_vecZero; ResetWaypointVars(); } void CBot::Think() { if (intermission) return; // Bot is dead? if (m_pMyEnt->state == CS_DEAD) { if(lastmillis-m_pMyEnt->lastdeath<1200) { m_pMyEnt->move = 0; moveplayer(m_pMyEnt, 1, true); } else if (!m_arena && lastmillis-m_pMyEnt->lastdeath>5000) Spawn(); SendBotInfo(); return; } CheckItemPickup(); TLinkedList::node_s *p = m_UnreachableEnts.GetFirst(), *tmp; while(p) { if ((lastmillis - p->Entry->time) > 3500) { tmp = p; p = p->next; delete tmp->Entry; m_UnreachableEnts.DeleteNode(tmp); continue; } p = p->next; } if (!BotManager.IdleBots()) { MainAI(); } else { ResetMoveSpeed(); } // Aim to ideal yaw and pitch AimToIdeal(); // Store current location, to see if the bot is stuck m_vPrevOrigin = m_pMyEnt->o; // Don't check for stuck if the bot doesn't want to move if (!m_pMyEnt->move && !m_pMyEnt->strafe) m_iStuckCheckDelay = max(m_iStuckCheckDelay, lastmillis+100.0f); // Move the bot moveplayer(m_pMyEnt, 1, true); // Update bot info on all clients SendBotInfo(); } void CBot::AimToVec(const vec &o) { m_pMyEnt->targetpitch = atan2(o.z-m_pMyEnt->o.z, GetDistance(o))*180/PI; m_pMyEnt->targetyaw = -(float)atan2(o.x - m_pMyEnt->o.x, o.y - m_pMyEnt->o.y)/PI*180+180; } void CBot::AimToIdeal() { if (m_iAimDelay > lastmillis) return; float MaxXSpeed = RandomFloat(m_pBotSkill->flMinAimXSpeed, m_pBotSkill->flMaxAimXSpeed); float MaxYSpeed = RandomFloat(m_pBotSkill->flMinAimYSpeed, m_pBotSkill->flMaxAimYSpeed); float XOffset = RandomFloat(m_pBotSkill->flMinAimXOffset, m_pBotSkill->flMaxAimXOffset); float YOffset = RandomFloat(m_pBotSkill->flMinAimYOffset, m_pBotSkill->flMaxAimYOffset); float RealXOffset, RealYOffset; float AimXSpeed = MaxXSpeed, AimYSpeed = MaxYSpeed; float XDiff = fabs(m_pMyEnt->targetpitch - m_pMyEnt->pitch); float YDiff = fabs(m_pMyEnt->targetyaw - m_pMyEnt->yaw); // How higher the diff, how higher the offsets and aim speed if (XOffset) { if (RandomLong(0, 1)) RealXOffset = XDiff * (XOffset / 100.0f); else RealXOffset = -(XDiff * (XOffset / 100.0f)); } else RealXOffset = 0.0f; if (YOffset) { if (RandomLong(0, 1)) RealYOffset = YDiff * (YOffset / 100.0f); else RealYOffset = -(YDiff * (YOffset / 100.0f)); } else RealYOffset = 0.0f; if (XDiff >= 1.0f) AimXSpeed = (AimXSpeed * (XDiff / 80.0f)) + (AimXSpeed * 0.25f); else AimXSpeed *= 0.01f; if (YDiff >= 1.0f) AimYSpeed = (AimYSpeed * (YDiff / 70.0f)) + (AimYSpeed * 0.25f); else AimYSpeed *= 0.015f; m_fPitchToTurn = fabs((m_pMyEnt->targetpitch + RealXOffset) - m_pMyEnt->pitch); m_fYawToTurn = fabs((m_pMyEnt->targetyaw + RealYOffset) - m_pMyEnt->yaw); float flIdealPitch = ChangeAngle(AimXSpeed, m_pMyEnt->targetpitch + RealXOffset, m_pMyEnt->pitch); float flIdealYaw = ChangeAngle(AimYSpeed, m_pMyEnt->targetyaw + RealYOffset, m_pMyEnt->yaw); // m_pMyEnt->pitch = WrapXAngle(m_pMyEnt->targetpitch); // Uncomment for instant aiming // m_pMyEnt->yaw = WrapYZAngle(m_pMyEnt->targetyaw); m_pMyEnt->pitch = WrapXAngle(flIdealPitch); m_pMyEnt->yaw = WrapYZAngle(flIdealYaw); } // Function code by Botman float CBot::ChangeAngle(float speed, float ideal, float current) { float current_180; // current +/- 180 degrees float diff; // find the difference in the current and ideal angle diff = fabs(current - ideal); // speed that we can turn during this frame... speed = speed * (float(BotManager.m_iFrameTime)/1000.0f); // check if difference is less than the max degrees per turn if (diff < speed) speed = diff; // just need to turn a little bit (less than max) // check if the bot is already facing the idealpitch direction... if (diff <= 0.5f) return ideal; if ((current >= 180) && (ideal >= 180)) { if (current > ideal) current -= speed; else current += speed; } else if ((current >= 180) && (ideal < 180)) { current_180 = current - 180; if (current_180 > ideal) current += speed; else current -= speed; } else if ((current < 180) && (ideal >= 180)) { current_180 = current + 180; if (current_180 > ideal) current += speed; else current -= speed; } else // (current < 180) && (ideal < 180) { if (current > ideal) current -= speed; else current += speed; } return current; } void CBot::SendBotInfo() { if(lastmillis-m_iLastBotUpdate<40) return; // don't update faster than 25fps m_iLastBotUpdate = lastmillis; } float CBot::GetDistance(const vec &o) { return o.dist(m_pMyEnt->o); } float CBot::GetDistance(const vec &v1, const vec &v2) { return v2.dist(v1); } float CBot::GetDistance(entity *e) { vec v(e->x, e->y, e->z); return v.dist(m_pMyEnt->o); } bool CBot::SelectGun(int Gun) { if(!m_pMyEnt->weapons[Gun]->selectable()) return false; if(m_pMyEnt->weaponsel->reloading || m_pMyEnt->weaponchanging) return false; m_pMyEnt->gunselect = Gun; if(m_pMyEnt->weaponsel->type != Gun) { m_pMyEnt->weaponswitch(m_pMyEnt->weapons[Gun]); m_iChangeWeaponDelay = lastmillis + 1000; } return true; } bool CBot::IsVisible(entity *e, bool CheckPlayers) { vec v(e->x, e->y, e->z); return ::IsVisible(m_pMyEnt->o, v, (CheckPlayers) ? m_pMyEnt : NULL); } bool CBot::IsVisible(vec o, int Dir, float flDist, bool CheckPlayers, float *pEndDist) { static vec angles, end, forward, right, up; static traceresult_s tr; end = o; angles = GetViewAngles(); angles.x = 0; if (Dir & UP) angles.x = WrapXAngle(angles.x + 45.0f); else if (Dir & DOWN) angles.x = WrapXAngle(angles.x - 45.0f); if ((Dir & FORWARD) || (Dir & BACKWARD)) { if (Dir & BACKWARD) angles.y = WrapYZAngle(angles.y + 180.0f); if (Dir & LEFT) { if (Dir & FORWARD) angles.y = WrapYZAngle(angles.y - 45.0f); else angles.y = WrapYZAngle(angles.y + 45.0f); } else if (Dir & RIGHT) { if (Dir & FORWARD) angles.y = WrapYZAngle(angles.y + 45.0f); else angles.y = WrapYZAngle(angles.y - 45.0f); } } else if (Dir & LEFT) angles.y = WrapYZAngle(angles.y - 90.0f); else if (Dir & RIGHT) angles.y = WrapYZAngle(angles.y + 90.0f); else if (Dir & UP) angles.x = WrapXAngle(angles.x + 90.0f); else if (Dir & DOWN) angles.x = WrapXAngle(angles.x - 90.0f); AnglesToVectors(angles, forward, right, up); forward.mul(flDist); end.add(forward); TraceLine(o, end, m_pMyEnt, CheckPlayers, &tr); if (pEndDist) *pEndDist = GetDistance(o, tr.end); return !tr.collided; } void CBot::SetMoveDir(int iMoveDir, bool add) { if (iMoveDir & FORWARD) m_pMyEnt->move = 1; else if (m_iMoveDir & BACKWARD) m_pMyEnt->move = -1; else if (!add) m_pMyEnt->move = 0; if (iMoveDir & LEFT) m_pMyEnt->strafe = 1; else if (m_iMoveDir & RIGHT) m_pMyEnt->strafe = -1; else if (!add) m_pMyEnt->strafe = 0; if (iMoveDir & UP) m_pMyEnt->jumpnext = true; } // Used when switching to another task/state void CBot::ResetCurrentTask() { switch (m_eCurrentBotState) { case STATE_ENEMY: m_pMyEnt->enemy = NULL; m_pTargetEnt = NULL; m_iCombatNavTime = m_iMoveDir = 0; m_bCombatJump = false; m_vGoal = g_vecZero; break; case STATE_ENT: m_pTargetEnt = NULL; m_vGoal = g_vecZero; break; case STATE_SP: m_iSPMoveTime = m_iMoveDir = 0; m_pTargetEnt = NULL; m_vGoal = g_vecZero; break; case STATE_NORMAL: m_iStrafeTime = m_iMoveDir = 0; break; default: break; } } // Bot class end assaultcube-1.2.0.2.1/source/src/bot/bot.h000066400000000000000000000331751352165075300201540ustar00rootroot00000000000000// // C++ Interface: bot // // Description: // // Main bot header // // // Author: Rick // // // /* TODO list -bots that "cover" each other in team matches ? -If a bot gets ammo it should ignore that kind of ammo for the next 10 seconds. ? -bots should ignore players that are too far away ? -bots should dodge/jump when shot at -If the bot's only weapon is the fist it should make looking for ammo its priority - Done ? -Make all the "UNDONE's" done :) -Finish waypoint navigation -Make bot personalities -More advanced enemy scoring -Bots should less bump into walls -(Better) Coop support -Check for reachable instead of visible in GetNearestWaypoint -Waypoint experience file -Bots should avoid team mates -Handle failed goals better(ie remember them) -Fix bots getting stuck in each other -Optimize hunting code -Check/Fix msg code */ #ifndef BOT_H #define BOT_H #ifndef RELEASE_BUILD #define RELEASE_BUILD // Set when you want to make a release build #endif #include "bot_util.h" #include "bot_waypoint.h" extern itemstat itemstats[]; #ifdef RELEASE_BUILD inline void condebug(const char *s, int a = 0, int b = 0, int c = 0) {} inline void debugnav(const char *s, int a = 0, int b = 0, int c = 0) {} inline void debugbeam(vec &s, vec &e) { } #else inline void condebug(const char *s, int a = 0, int b = 0, int c = 0) { /*conoutf(s, a, b, c);*/ } inline void debugnav(const char *s, int a = 0, int b = 0, int c = 0) { /*conoutf(s, a, b, c);*/ } inline void debugbeam(vec &s, vec &e) { /*particle_trail(1, 500, s, e);*/ } #endif #define JUMP_HEIGHT 4.0f // NOT accurate #define FORWARD (1<<1) #define BACKWARD (1<<2) #define LEFT (1<<3) #define RIGHT (1<<4) #define UP (1<<5) #define DOWN (1<<6) #define DIR_NONE 0 //fixmebot #define m_sp 1000 #define m_classicsp 1000 enum EBotCommands // For voting of bot commands { COMMAND_ADDBOT=0, COMMAND_KICKBOT, COMMAND_BOTSKILL }; struct bot_skill_s { float flMinReactionDelay; // Minimal reaction time float flMaxReactionDelay; // Maximal reaction time float flMinAimXSpeed; // Minimal X aim speed in degrees(base value) float flMaxAimXSpeed; // Maximal X aim speed in degrees(base value) float flMinAimYSpeed; // Minimal Y aim speed in degrees(base value) float flMaxAimYSpeed; // Maximal Y aim speed in degrees(base value) float flMinAimXOffset; // Minimal X aim offset in degrees(base value) float flMaxAimXOffset; // Maximal X aim offset in degrees(base value) float flMinAimYOffset; // Minimal Y aim offset in degrees(base value) float flMaxAimYOffset; // Maximal Y aim offset in degrees(base value) float flMinAttackDelay; // Minimal delay for when a bot can attack again float flMaxAttackDelay; // Maximal delay for when a bot can attack again float flMinEnemySearchDelay; // Minimal delay for when a bot can search for an // enemy again float flMaxEnemySearchDelay; // Maximal delay for when a bot can search for an // enemy again float flAlwaysDetectDistance; int iMaxHearVolume; // Max volume that bot can hear int iFov; // bots field of view bool bCanPredict; // Can this bot predict his enemy position? bool bCircleStrafe; // Can this bot circle strafe? bool bCanSearchItemsInCombat; }; enum EBotWeaponTypes { TYPE_MELEE, // Fist, knife etc TYPE_NORMAL, // Normal weapon, distance doesn't really matter(ie pistol) TYPE_SHOTGUN, TYPE_SNIPER, // Rifle, sniper etc TYPE_GRENADE, TYPE_AUTO // Chain gun, machine gun etc }; struct weaponinfo_s { EBotWeaponTypes eWeaponType; float flMinDesiredDistance; float flMaxDesiredDistance; float flMinFireDistance; float flMaxFireDistance; short sMinDesiredAmmo; }; enum ECurrentBotState { STATE_ENEMY, // Bot has an enemy STATE_HUNT, // Bot is hunting an enemy STATE_ENT, // Bot is heading to an entity STATE_SP, // Bot is doing sp specific stuff STATE_NORMAL // Bot is doing normal navigation }; struct unreachable_ent_s { entity *ent; int time; unreachable_ent_s(entity *e, int t) : ent(e), time(t) { }; }; class CBot { public: botent *m_pMyEnt; int m_iLastBotUpdate; // Combat variabels playerent *m_pPrevEnemy; int m_iShootDelay; int m_iChangeWeaponDelay; int m_iCombatNavTime; int m_iEnemySearchDelay; int m_iSawEnemyTime; bool m_bCombatJump; float m_iCombatJumpDelay; bool m_bShootAtFeet; // Hunting variabeles int m_iHuntDelay; vec m_vHuntLocation, m_vPrevHuntLocation; playerent *m_pHuntTarget; float m_fPrevHuntDist; int m_iHuntPauseTime, m_iHuntPlayerUpdateTime, m_iHuntLastTurnLessTime; int m_iLookAroundDelay, m_iLookAroundTime, m_iLookAroundUpdateTime; float m_fLookAroundYaw; bool m_bLookLeft; // Navigation variabeles int m_iCheckEnvDelay; int m_iLastJumpPad; vec m_vPrevOrigin; float m_iStuckCheckDelay; bool m_bStuck; int m_iStuckTime; int m_iStrafeTime; int m_iStrafeCheckDelay; int m_iMoveDir; int m_iSPMoveTime; bool m_bCalculatingAStarPath; TLinkedList m_AStarNodeList; TPriorList m_AStarOpenList[2]; TLinkedList m_AStarClosedList[2]; vec m_vWaterGoal; // Place to go to when underwater // Waypoint variabeles TLinkedList m_WaypointList[MAX_MAP_GRIDS][MAX_MAP_GRIDS]; float m_iWaypointTime; waypoint_s *m_pCurrentWaypoint; waypoint_s *m_pCurrentGoalWaypoint; vec m_vGoal; waypoint_s *m_pPrevWaypoints[5]; int m_iRandomWaypointTime; float m_fPrevWaypointDistance; int m_iLookForWaypointTime; int m_iWaypointHeadLastTurnLessTime; // Last time the didn't had to turn much wile // heading to a WP int m_iWaypointHeadPauseTime; // Pause time to give the bot time to aim. bool m_bGoToDebugGoal; // Misc stuff ECurrentBotState m_eCurrentBotState; entity *m_pTargetEnt; TLinkedList m_UnreachableEnts; int m_iCheckTeleporterDelay; int m_iCheckJumppadsDelay; int m_iCheckEntsDelay; int m_iCheckTriggersDelay; int m_iAimDelay; float m_fYawToTurn, m_fPitchToTurn; bot_skill_s *m_pBotSkill; // Pointer to current bot skill short m_sSkillNr; // Skill number, 0 == best 4 == worst void AimToVec(const vec &o); void AimToIdeal(void); float ChangeAngle(float speed, float ideal, float current); bool SelectGun(int Gun); virtual void CheckItemPickup(void) = 0; void SendBotInfo(void); float GetDistance(const vec &o); float GetDistance(const vec &v1, const vec &v2); float GetDistance(entity *e); float Get2DDistance(const vec &v) { return ::Get2DDistance(m_pMyEnt->o, v); }; vec GetViewAngles(void) { return vec(m_pMyEnt->pitch, m_pMyEnt->yaw, m_pMyEnt->roll); }; void ResetMoveSpeed(void) { m_pMyEnt->move = m_pMyEnt->strafe = 0; }; void SetMoveDir(int iMoveDir, bool add); void ResetCurrentTask(); // AI Functions bool BotsAgainstHumans(); bool DetectEnemy(playerent *p); bool FindEnemy(void); void CheckReload(void); void CheckWeaponSwitch(void); // 2011jan17:ft: fix non-shooting bots void CheckScope(void); void ShootEnemy(void); bool CheckHunt(void); bool HuntEnemy(void); void DoCombatNav(void); void MainAI(void); bool CheckStuck(void); bool CheckJump(void); bool CheckCrouch(void); bool CheckStrafe(void); void CheckFOV(void); bool IsVisible(const vec &o, bool CheckPlayers = false) { return ::IsVisible(m_pMyEnt->o, o, (CheckPlayers) ? m_pMyEnt : NULL); }; bool IsVisible(playerent *d, bool CheckPlayers = false) { return ::IsVisible(m_pMyEnt->o, d->o, (CheckPlayers) ? m_pMyEnt : NULL); }; bool IsVisible(entity *e, bool CheckPlayers = false); bool IsVisible(vec o, int Dir, float flDist, bool CheckPlayers, float *pEndDist = NULL); bool IsVisible(int Dir, float flDist, bool CheckPlayers) { return IsVisible(m_pMyEnt->o, Dir, flDist, CheckPlayers); }; bool IsInFOV(const vec &o); bool IsInFOV(playerent *d) { return IsInFOV(d->o); }; int GetShootDelay(void); virtual bool ChoosePreferredWeapon(void); virtual entity *SearchForEnts(bool bUseWPs, float flRange=9999.0f, float flMaxHeight=JUMP_HEIGHT) = 0; virtual bool HeadToTargetEnt(void) = 0; bool CheckItems(void); bool InUnreachableList(entity *e); virtual bool DoSPStuff(void) = 0; vec GetEnemyPos(playerent *d); bool AStar(void); float AStarCost(waypoint_s *pWP1, waypoint_s *pWP2); void CleanAStarLists(bool bPathFailed); bool IsReachable(vec to, float flMaxHeight=JUMP_HEIGHT); bool WaterNav(void); void HearSound(int n, vec *o); // Waypoint functions bool HeadToWaypoint(void); bool FindWaypoint(void); void ResetWaypointVars(void); void SetCurrentWaypoint(node_s *pWP); void SetCurrentWaypoint(waypoint_s *pWP); void SetCurrentGoalWaypoint(node_s *pNode); void SetCurrentGoalWaypoint(waypoint_s *pWP); bool CurrentWPIsValid(void); bool ReachedGoalWP(void); bool HeadToGoal(void); waypoint_s *GetWPFromNode(node_s *pNode); waypoint_s *GetNearestWaypoint(vec v_src, float flRange); waypoint_s *GetNearestWaypoint(float flRange) { return GetNearestWaypoint(m_pMyEnt->o, flRange); }; waypoint_s *GetNearestTriggerWaypoint(vec v_src, float flRange); #ifdef WP_FLOOD waypoint_s *GetNearestFloodWP(vec v_origin, float flRange); waypoint_s *GetNearestFloodWP(float flRange) { return GetNearestFloodWP(m_pMyEnt->o, flRange); }; waypoint_s *GetNearestTriggerFloodWP(vec v_origin, float flRange); #endif void SyncWaypoints(void); friend class CBotManager; friend class CWaypointClass; bool m_bSendC2SInit; virtual ~CBot(void); virtual void Spawn(void); virtual void Think(void); void GoToDebugGoal(vec o); }; class CStoredBot // Used to store bots after mapchange, so that they can be readded { public: char m_szName[32]; char m_szTeam[32]; short m_sSkillNr; CStoredBot(char *name, char *team, short skill) : m_sSkillNr(skill) { strcpy(m_szName, name); strcpy(m_szTeam, team); }; }; extern vector bots; class CBotManager { char m_szBotNames[150][16]; // Max 150 bot names with a length of 16 characters short m_sBotNameCount; char m_szBotTeams[20][5]; // Max 100 bot teams co a length of 5 characters short m_sBotTeamCount; bool m_bInit; bool m_bBotsShoot; bool m_bIdleBots; bot_skill_s m_BotSkills[5]; // 5 different bot skills, 0 = best 4 = worst int m_iFrameTime; int m_iPrevTime; short m_sBotSkill; // Bad - Worse - Medium - Good - Best short m_sMaxAStarBots; // Max bots that can use a* at the same time short m_sUsingAStarBotsCount; // Number of bots that are using a* short m_sCurrentTriggerNr; // Current waypoint trigger bots should use TLinkedList m_StoredBots; // List of bots that should be re-added after map change float m_fReAddBotDelay; void LoadBotNamesFile(void); const char *GetBotName(void); void LoadBotTeamsFile(void); void CreateSkillData(void); void InitSkillData(void); void InitBotItems(void); friend class CBot; friend class CACBot; friend class CWaypointClass; public: botent *m_pBotToView; // Construction CBotManager(void) { m_bInit = true; m_bBotsShoot = true; m_bIdleBots = false; m_fReAddBotDelay = -1.0f; }; // Destruction ~CBotManager(void); void Init(void); void Think(void); void RenderBots(void); void RespawnBots(void) { loopv(bots) if (bots[i] && bots[i]->pBot) bots[i]->pBot->Spawn(); }; void ClearStoredBots(void) { while(!m_StoredBots.Empty()) delete m_StoredBots.Pop(); } void ReAddBot(CStoredBot *bot) { CreateBot(bot->m_szTeam, SkillNrToSkillName(bot->m_sSkillNr), bot->m_szName); }; void EndMap(void); void BeginMap(const char *szMapName); int GetBotIndex(botent *m); void LetBotsUpdateStats(void); void LetBotsHear(int n, vec *loc); void AddWaypoint(node_s *pNode); void DelWaypoint(node_s *pNode); bool BotsShoot(void) { return m_bBotsShoot; }; bool IdleBots(void) { return m_bIdleBots; }; void SetBotsShoot(bool bShoot) { m_bBotsShoot = bShoot; }; void SetIdleBots(bool bIdle) { m_bIdleBots = bIdle; }; void EnableBotView(botent *bot) { m_pBotToView = bot; }; void DisableBotView(void); void ChangeBotSkill(short Skill, botent *bot = NULL); botent *CreateBot(const char *team, const char *skill, const char *name); void ViewBot(void); void CalculateMaxAStarCount(void); void PickNextTrigger(void); const char *GetBotTeam(void); void MakeBotFileName(const char *szFileName, const char *szDir1, const char *szDir2, char *szOutput); }; #include "ac_bot.h" extern CBotManager BotManager; extern const vec g_vecZero; extern CACWaypointClass WaypointClass; extern void kickallbots(); #endif assaultcube-1.2.0.2.1/source/src/bot/bot_ai.cpp000066400000000000000000001622231352165075300211550ustar00rootroot00000000000000// // C++ Implementation: bot_ai // // Description: The AI part comes here(navigation, shooting etc) // // // Author: // // Code of CBot - Start #include "cube.h" #include "bot.h" extern weaponinfo_s WeaponInfoTable[MAX_WEAPONS]; vec CBot::GetEnemyPos(playerent *d) { // Aim offset idea by botman vec o = m_pMyEnt->weaponsel->type == GUN_SNIPER && d->head.x >= 0 ? d->head : d->o, offset; float flDist = GetDistance(o), flScale; if (m_pBotSkill->bCanPredict) { // How higher the skill, how 'more' the bot predicts float flPredictTime = RandomFloat(0.8f, 1.2f) / (m_sSkillNr+1); o = PredictPos(o, d->vel, flPredictTime); } if (flDist > 60.0f) flScale = 1.0f; else if (flDist > 6.0f) flScale = flDist / 60.0f; else flScale = 0.1f; switch (m_sSkillNr) { case 0: // no offset offset.x = 0; offset.y = 0; offset.z = 0; break; case 1: // GOOD, offset a little for x, y, and z offset.x = RandomFloat(-3, 3) * flScale; offset.y = RandomFloat(-3, 3) * flScale; offset.z = RandomFloat(-6, 6) * flScale; break; case 2: // FAIR, offset somewhat for x, y, and z offset.x = RandomFloat(-8, 8) * flScale; offset.y = RandomFloat(-8, 8) * flScale; offset.z = RandomFloat(-12, 12) * flScale; break; case 3: // POOR, offset for x, y, and z offset.x = RandomFloat(-15, 15) * flScale; offset.y = RandomFloat(-15, 15) * flScale; offset.z = RandomFloat(-25, 25) * flScale; break; case 4: // BAD, offset lots for x, y, and z offset.x = RandomFloat(-20, 20) * flScale; offset.y = RandomFloat(-20, 20) * flScale; offset.z = RandomFloat(-35, 35) * flScale; break; } o.add(offset); return o; } // WIP bool CBot::BotsAgainstHumans() { return false; } bool CBot::DetectEnemy(playerent *p) { return (IsInFOV(p) || (m_pBotSkill->flAlwaysDetectDistance > m_pMyEnt->o.dist(p->o))) && IsVisible(p); } bool CBot::FindEnemy(void) { // UNDONE: Enemies are now only scored on their distance if(BotsAgainstHumans()) { m_pMyEnt->enemy = NULL; if(player1->state == CS_ALIVE) { m_pMyEnt->enemy = player1; } return m_pMyEnt->enemy != NULL; } if (m_pMyEnt->enemy) // Bot already has an enemy { // Check if the enemy is still in game bool found = IsInGame(m_pMyEnt->enemy); // Check if the enemy is still ingame, still alive, not joined my team and is visible if (found && !isteam(m_pMyEnt->team, m_pMyEnt->enemy->team)) { if ((m_pMyEnt->enemy->state == CS_ALIVE) && (IsVisible(m_pMyEnt->enemy))) return true; else m_pPrevEnemy = m_pMyEnt->enemy; } else m_pMyEnt->enemy = NULL; } if (m_iEnemySearchDelay > lastmillis) return (m_pMyEnt->enemy!=NULL); m_pMyEnt->enemy = NULL; // Add enemy searchy delay float MinDelay = m_pBotSkill->flMinEnemySearchDelay; float MaxDelay = m_pBotSkill->flMaxEnemySearchDelay; m_iEnemySearchDelay = lastmillis + int(RandomFloat(MinDelay, MaxDelay) * 1000.0f); playerent *pNewEnemy = NULL, *d = NULL; float flDist, flNearestDist = 99999.9f; short EnemyVal, BestEnemyVal = -100; // First loop through all bots loopv(bots) { d = bots[i]; // Handy shortcut if (d == m_pMyEnt || !d || isteam(d->team, m_pMyEnt->team) || (d->state != CS_ALIVE)) continue; // Check if the enemy is visible if(!DetectEnemy(d)) continue; flDist = GetDistance(d->o); EnemyVal = 1; if (flDist < flNearestDist) { EnemyVal+=2; flNearestDist = flDist; } if (EnemyVal > BestEnemyVal) { pNewEnemy = d; BestEnemyVal = EnemyVal; } } // Then examine the local player if (player1 && !isteam(player1->team, m_pMyEnt->team) && (player1->state == CS_ALIVE)) { // Check if the enemy is visible if(DetectEnemy(player1)) { flDist = GetDistance(player1->o); EnemyVal = 1; if (flDist < flNearestDist) { EnemyVal+=2; flNearestDist = flDist; } if (EnemyVal > BestEnemyVal) { pNewEnemy = player1; BestEnemyVal = EnemyVal; } } } //} if (pNewEnemy) { if (!m_pMyEnt->enemy) // Add shoot delay if new enemy is found { float flMinShootDelay = m_pBotSkill->flMinAttackDelay; float flMaxShootDelay = m_pBotSkill->flMaxAttackDelay; m_iShootDelay = lastmillis + int(RandomFloat(flMinShootDelay, flMaxShootDelay) * 1000.0f); } if ((m_pMyEnt->enemy != pNewEnemy) && m_pMyEnt->enemy) m_pPrevEnemy = m_pMyEnt->enemy; m_pMyEnt->enemy = pNewEnemy; return true; } return false; } bool CBot::CheckHunt(void) { if (!BotManager.BotsShoot()) return false; if (m_pHuntTarget) // Bot already has an enemy to hunt { // Check if the enemy is still in game bool found = IsInGame(m_pHuntTarget); // Check if the enemy is still ingame, still alive, not joined my team and is visible if (found && !isteam(m_pMyEnt->team, m_pHuntTarget->team)) { if ((m_pHuntTarget->state == CS_ALIVE) && IsReachable(m_vHuntLocation)) return true; } else m_pHuntTarget = NULL; } if (m_iHuntDelay > lastmillis) return (m_pHuntTarget!=NULL); if (m_vHuntLocation!=g_vecZero) m_vPrevHuntLocation = m_vHuntLocation; m_pHuntTarget = NULL; m_vHuntLocation = g_vecZero; // Add enemy hunt search delay m_iHuntDelay = lastmillis + 1500; playerent *pNewEnemy = NULL, *d = NULL; float flDist, flNearestDist = 99999.9f, flNearestOldPosDistToEnemy = 99999.9f; float flNearestOldPosDistToBot = 99999.9f; short EnemyVal, BestEnemyVal = -100; vec BestOldPos; // First loop through all bots loopv(bots) { d = bots[i]; // Handy shortcut if (d == m_pMyEnt || !d || isteam(d->team, m_pMyEnt->team) || (d->state != CS_ALIVE)) continue; flDist = GetDistance(d->o); if (flDist > 250.0f) continue; EnemyVal = 1; if (flDist < flNearestDist) { EnemyVal+=2; flNearestDist = flDist; } if (d == m_pPrevEnemy) EnemyVal+=2; if (EnemyVal < BestEnemyVal) continue; vec bestfromenemy = g_vecZero, bestfrombot = g_vecZero; flNearestOldPosDistToEnemy = flNearestOldPosDistToBot = 9999.9f; // Check previous locations of enemy for (int j=0;jhistory.size();j++) { const vec &v = d->history.getpos(j); if (v==m_vPrevHuntLocation) continue; flDist = GetDistance(d->o, v); if ((flDist < flNearestOldPosDistToEnemy) && IsReachable(v)) { flNearestOldPosDistToEnemy = flDist; bestfromenemy = v; } } // Check previous locations of bot hisself for (int j=0;jhistory.size();j++) { const vec &v = m_pMyEnt->history.getpos(j); if (v==m_vPrevHuntLocation) continue; flDist = GetDistance(v); if ((flDist < flNearestOldPosDistToBot) && ::IsVisible(d->o, v) && IsReachable(v)) { flNearestOldPosDistToBot = flDist; bestfrombot = v; } } if (bestfromenemy!=g_vecZero) { pNewEnemy = d; BestEnemyVal = EnemyVal; BestOldPos = bestfromenemy; } else if (bestfrombot!=g_vecZero) { pNewEnemy = d; BestEnemyVal = EnemyVal; BestOldPos = bestfrombot; } // Then examine the local player if (player1 && !isteam(player1->team, m_pMyEnt->team) && (player1->state == CS_ALIVE) && ((flDist = GetDistance(player1->o)) <= 250.0f)) { d = player1; EnemyVal = 1; if (flDist < flNearestDist) { EnemyVal+=2; flNearestDist = flDist; } if (d == m_pPrevEnemy) EnemyVal+=2; if (EnemyVal >= BestEnemyVal) { BestEnemyVal = EnemyVal; vec bestfromenemy = g_vecZero, bestfrombot = g_vecZero; flNearestOldPosDistToEnemy = flNearestOldPosDistToBot = 9999.9f; // Check previous locations of enemy for (int j=0;jhistory.size();j++) { const vec &v = d->history.getpos(j); if (v==m_vPrevHuntLocation) continue; flDist = GetDistance(d->o, v); if ((flDist < flNearestOldPosDistToEnemy) && IsReachable(v)) { flNearestOldPosDistToEnemy = flDist; bestfromenemy = v; } } // Check previous locations of bot hisself for (int j=0;jhistory.size();j++) { const vec &v = m_pMyEnt->history.getpos(j); if (v==m_vPrevHuntLocation) continue; flDist = GetDistance(v); if ((flDist < flNearestOldPosDistToBot) && ::IsVisible(d->o, v) && IsReachable(v)) { flNearestOldPosDistToBot = flDist; bestfrombot = v; } } if (bestfromenemy!=g_vecZero) { pNewEnemy = d; BestEnemyVal = EnemyVal; BestOldPos = bestfromenemy; } else if (bestfrombot!=g_vecZero) { pNewEnemy = d; BestEnemyVal = EnemyVal; BestOldPos = bestfrombot; } } } } if (pNewEnemy) { if (!m_pHuntTarget) // Add shoot delay if new enemy is found { float flMinShootDelay = m_pBotSkill->flMinAttackDelay; float flMaxShootDelay = m_pBotSkill->flMaxAttackDelay; m_iShootDelay = lastmillis + int(RandomFloat(flMinShootDelay, flMaxShootDelay) * 1000.0f); } if (m_vHuntLocation!=g_vecZero) m_vPrevHuntLocation = m_vHuntLocation; m_pHuntTarget = pNewEnemy; m_vHuntLocation = BestOldPos; m_fPrevHuntDist = 0.0f; return true; } return false; } bool CBot::HuntEnemy(void) { if (m_iCombatNavTime > lastmillis) { SetMoveDir(m_iMoveDir, false); return true; } m_iCombatNavTime = m_iMoveDir = 0; bool bDone = false, bNew = false; float flDist = GetDistance(m_vHuntLocation); if (flDist <= 3.0f) bDone = true; if ((m_fPrevHuntDist > 0.0) && (flDist > m_fPrevHuntDist)) bDone = true; m_fPrevHuntDist = flDist; if ((m_iHuntPlayerUpdateTime < lastmillis) || bDone) { m_iHuntPlayerUpdateTime = lastmillis + 1250; short BestPosIndexFromEnemy = -1, BestPosIndexFromBot = -1, j; float NearestDistToEnemy = 9999.9f, NearestDistToBot = 9999.9f; // Check previous locations of enemy for (j=0;jhistory.size();j++) { const vec &OldPos = m_pHuntTarget->history.getpos(j); if (bDone && m_vHuntLocation==OldPos) continue; if (GetDistance(OldPos) > 250.0f) continue; flDist = GetDistance(m_pHuntTarget->o, OldPos); if ((flDist < NearestDistToEnemy) && (IsReachable(OldPos))) { NearestDistToEnemy = flDist; BestPosIndexFromEnemy = j; break; } } // Check previous locations of bot for (j=0;jhistory.size();j++) { const vec &OldPos = m_pMyEnt->history.getpos(j); if (bDone && m_vHuntLocation==OldPos) continue; if (GetDistance(OldPos) > 25.0f) continue; flDist = GetDistance(OldPos); if ((flDist < NearestDistToBot) && ::IsVisible(m_pHuntTarget->o, OldPos) && (IsReachable(OldPos))) { NearestDistToBot = flDist; BestPosIndexFromBot = j; break; } } if (BestPosIndexFromEnemy > -1) { m_vPrevHuntLocation = m_vHuntLocation; m_vHuntLocation = m_pHuntTarget->history.getpos(BestPosIndexFromEnemy); bNew = true; m_fPrevHuntDist = 0.0f; } else if (BestPosIndexFromBot > -1) { m_vPrevHuntLocation = m_vHuntLocation; m_vHuntLocation = m_pMyEnt->history.getpos(BestPosIndexFromEnemy); bNew = true; m_fPrevHuntDist = 0.0f; } } if (!bNew) // Check if current location is still reachable { if (bDone || !IsReachable(m_vHuntLocation)) { m_pHuntTarget = NULL; m_vPrevHuntLocation = m_vHuntLocation; m_vHuntLocation = g_vecZero; m_fPrevHuntDist = 0.0f; m_iHuntDelay = lastmillis + 3500; return false; } } else condebug("New hunt pos"); // Aim to position //AimToVec(m_vHuntLocation); int iMoveDir = GetDirection(GetViewAngles(), m_pMyEnt->o, m_vHuntLocation); if (iMoveDir != DIR_NONE) { m_iMoveDir = iMoveDir; m_iCombatNavTime = lastmillis + 125; } bool aimtopos = true; if ((lastmillis - m_iSawEnemyTime) > 1500) { if (m_iLookAroundDelay < lastmillis) { if (m_iLookAroundTime > lastmillis) { if (m_iLookAroundUpdateTime < lastmillis) { float flAddAngle; if (m_bLookLeft) flAddAngle = RandomFloat(-110, -80); else flAddAngle = RandomFloat(80, 110); m_pMyEnt->targetyaw = WrapYZAngle(m_pMyEnt->targetyaw + flAddAngle); m_iLookAroundUpdateTime = lastmillis + RandomLong(400, 800); } aimtopos = false; } else if (m_iLookAroundTime > 0) { m_iLookAroundTime = 0; m_iLookAroundDelay = lastmillis + RandomLong(750, 1000); } else m_iLookAroundTime = lastmillis + RandomLong(2200, 3200); } } if (aimtopos) AimToVec(m_vHuntLocation); debugbeam(m_pMyEnt->o, m_vHuntLocation); if (m_fYawToTurn <= 25.0f) m_iHuntLastTurnLessTime = lastmillis; // Bot had to turn much for a while? if ((m_iHuntLastTurnLessTime > 0) && (m_iHuntLastTurnLessTime < (lastmillis - 1000))) { m_iHuntPauseTime = lastmillis + 200; } if (m_iHuntPauseTime >= lastmillis) { m_pMyEnt->move = 0; m_fPrevHuntDist = 0.0f; } else { // Check if bot has to jump over a wall... if (CheckJump()) m_pMyEnt->jumpnext = true; else // Check if bot has to jump to reach this location { float flHeightDiff = m_vHuntLocation.z - m_pMyEnt->o.z; bool bToHigh = false; if (Get2DDistance(m_vHuntLocation) <= 2.0f) { if (flHeightDiff >= 1.5f) { if (flHeightDiff <= JUMP_HEIGHT) { #ifndef RELEASE_BUILD char sz[64]; sprintf(sz, "OldPos z diff: %f", m_vHuntLocation.z-m_pMyEnt->o.z); condebug(sz); #endif // Jump if close to pos and the pos is high m_pMyEnt->jumpnext = true; } else bToHigh = true; } } if (bToHigh) { m_pHuntTarget = NULL; m_vPrevHuntLocation = m_vHuntLocation; m_vHuntLocation = g_vecZero; m_fPrevHuntDist = 0.0f; m_iHuntDelay = lastmillis + 3500; return false; } } } return true; } void CBot::CheckWeaponSwitch() { if(m_pMyEnt->nextweaponsel == NULL) m_pMyEnt->weaponchanging = 0; if(!m_pMyEnt->weaponchanging) return; int timeprogress = lastmillis-m_pMyEnt->weaponchanging; if(timeprogress>weapon::weaponchangetime) { m_pMyEnt->prevweaponsel = m_pMyEnt->weaponsel; m_pMyEnt->weaponsel = m_pMyEnt->nextweaponsel; m_pMyEnt->weaponchanging = 0; m_iChangeWeaponDelay = 0; if(!m_pMyEnt->weaponsel->mag) { tryreload(m_pMyEnt); } } } void CBot::ShootEnemy() { if(!m_pMyEnt->enemy) return; if(!IsVisible(m_pMyEnt->enemy)) return; m_iSawEnemyTime = lastmillis; // Aim to enemy vec enemypos = GetEnemyPos(m_pMyEnt->enemy); AimToVec(enemypos); // Time to shoot? if (m_iShootDelay < lastmillis) //if ((lastmillis-m_pMyEnt->lastaction) >= m_pMyEnt->gunwait) { if (m_pMyEnt->mag[m_pMyEnt->gunselect]) { // If the bot is using a sniper only shoot if crosshair is near the enemy if (WeaponInfoTable[m_pMyEnt->gunselect].eWeaponType == TYPE_SNIPER) { float yawtoturn = fabs(WrapYZAngle(m_pMyEnt->yaw - m_pMyEnt->targetyaw)); float pitchtoturn = fabs(WrapYZAngle(m_pMyEnt->pitch - m_pMyEnt->targetpitch)); if ((yawtoturn > 5) || (pitchtoturn > 15)) // UNDONE: Should be skill based return; } float flDist = GetDistance(enemypos); // Check if bot is in fire range if ((flDist < WeaponInfoTable[m_pMyEnt->gunselect].flMinFireDistance) || (flDist > WeaponInfoTable[m_pMyEnt->gunselect].flMaxFireDistance)) return; // Now shoot! m_pMyEnt->attacking = true; // Get the position the bot is aiming at vec forward, right, up, dest; traceresult_s tr; AnglesToVectors(GetViewAngles(), forward, right, up); dest = m_pMyEnt->o; forward.mul(1000); dest.add(forward); TraceLine(m_pMyEnt->o, dest, m_pMyEnt, false, &tr); debugbeam(m_pMyEnt->o, tr.end); shoot(m_pMyEnt, tr.end); // Add shoot delay m_iShootDelay = lastmillis + GetShootDelay(); } } #ifndef RELEASE_BUILD else { char sz[64]; sprintf(sz, "shootdelay: %d\n", (m_iShootDelay-lastmillis)); AddDebugText(sz); } #endif } bool CBot::ChoosePreferredWeapon() { return true; } int CBot::GetShootDelay() { // UNDONE return m_pMyEnt->gunwait[m_pMyEnt->gunselect]; if ((WeaponInfoTable[m_pMyEnt->gunselect].eWeaponType == TYPE_MELEE) || (WeaponInfoTable[m_pMyEnt->gunselect].eWeaponType == TYPE_AUTO)) return m_pMyEnt->gunwait[m_pMyEnt->gunselect]; float flMinShootDelay = m_pBotSkill->flMinAttackDelay; float flMaxShootDelay = m_pBotSkill->flMaxAttackDelay; return max(m_pMyEnt->gunwait[m_pMyEnt->gunselect], int(RandomFloat(flMinShootDelay, flMaxShootDelay) * 1000.0f)); } void CBot::CheckReload() // reload gun if no enemies are around { if(m_pMyEnt->mag[m_pMyEnt->weaponsel->type] >= WeaponInfoTable[m_pMyEnt->weaponsel->type].sMinDesiredAmmo) return; // do not reload if mindesiredammo is satisfied if(m_pMyEnt->enemy && m_pMyEnt->mag[m_pMyEnt->weaponsel->type]) { return; // ignore the enemy, if no ammo in mag. } tryreload(m_pMyEnt); return; } void CBot::CheckScope() { #define MINSCOPEDIST 15 #define MINSCOPETIME 1000 if(m_pMyEnt->weaponsel->type != GUN_SNIPER) return; sniperrifle *sniper = (sniperrifle *)m_pMyEnt->weaponsel; if(m_pMyEnt->enemy && m_pMyEnt->o.dist(m_pMyEnt->enemy->o) > MINSCOPEDIST) { sniper->setscope(true); } else if(m_pMyEnt->scoping && lastmillis - sniper->scoped_since < MINSCOPETIME) { sniper->setscope(false); } } void CBot::MainAI() { // Default bots will run forward m_pMyEnt->move = 1; // Default bots won't strafe m_pMyEnt->strafe = 0; // Whatever the bot is doing, check for needed crouch if(CheckCrouch()) m_pMyEnt->trycrouch = true; else m_pMyEnt->trycrouch = false; if (!BotManager.BotsShoot() && m_pMyEnt->enemy) m_pMyEnt->enemy = NULL; // Clear enemy when bots may not shoot if (m_bGoToDebugGoal) // For debugging the waypoint navigation { if (!HeadToGoal()) { ResetWaypointVars(); m_vGoal = g_vecZero; } else AddDebugText("Heading to debug goal..."); } if (BotManager.BotsShoot() && FindEnemy()) // Combat { CheckReload(); CheckScope(); AddDebugText("has enemy"); // Use best weapon ChoosePreferredWeapon(); // Shoot at enemy ShootEnemy(); if (m_eCurrentBotState != STATE_ENEMY) { m_vGoal = g_vecZero; ResetWaypointVars(); } m_eCurrentBotState = STATE_ENEMY; if (!CheckJump()) DoCombatNav(); } else if (CheckHunt() && HuntEnemy()) { CheckReload(); CheckScope(); AddDebugText("Hunting to %s", m_pHuntTarget->name); m_eCurrentBotState = STATE_HUNT; } // Heading to an interesting entity(ammo, armour etc) else if (CheckItems()) { CheckReload(); AddDebugText("has ent"); m_eCurrentBotState = STATE_ENT; } else if (m_classicsp && DoSPStuff()) // Home to goal, find/follow friends etc. { AddDebugText("SP stuff"); m_eCurrentBotState = STATE_SP; } else // Normal navigation { CheckReload(); if (m_eCurrentBotState != STATE_NORMAL) { m_vGoal = g_vecZero; ResetWaypointVars(); } m_eCurrentBotState = STATE_NORMAL; bool bDoNormalNav = true; AddDebugText("normal nav"); // Make sure the bot looks straight forward and not up or down m_pMyEnt->pitch = 0; // if it is time to look for a waypoint AND if there are waypoints in this // level... if (WaypointClass.m_iWaypointCount >= 1) { // check if we need to find a waypoint... if (CurrentWPIsValid() == false) { if (m_iLookForWaypointTime <= lastmillis) { // find the nearest reachable waypoint waypoint_s *pWP = GetNearestWaypoint(10.0f); if (pWP && (pWP != m_pCurrentWaypoint)) { SetCurrentWaypoint(pWP); condebug("New nav wp"); bDoNormalNav = !HeadToWaypoint(); if (bDoNormalNav) ResetWaypointVars(); } else ResetWaypointVars(); m_iLookForWaypointTime = lastmillis + 250; } } else { bDoNormalNav = !HeadToWaypoint(); if (bDoNormalNav) ResetWaypointVars(); AddDebugText("Using wps for nav"); } } // If nothing special, do regular (waypointless) navigation if(bDoNormalNav) { // Is the bot underwater? if (UnderWater(m_pMyEnt->o) && WaterNav()) { // Bot is under water, navigation happens in WaterNav } // Time to check the environment? else if (m_iCheckEnvDelay < lastmillis) { if (m_vWaterGoal!=g_vecZero) m_vWaterGoal = g_vecZero; // Check for stuck and strafe if (UnderWater(m_pMyEnt->o) || !CheckStuck()) { // Only do this when the bot is underwater or when the bot isn't stuck // Check field of view (FOV) CheckFOV(); } } // Check if the bot has to strafe CheckStrafe(); m_pMyEnt->move = 1; } } } void CBot::DoCombatNav() { if (m_iCombatNavTime > lastmillis) { // If bot has a lower skill and has to turn much, wait if ((m_sSkillNr > 2) && (m_fYawToTurn > 90.0f)) { ResetMoveSpeed(); } else { SetMoveDir(m_iMoveDir, false); } return; } if (m_bCombatJump) { m_pMyEnt->jumpnext = true; m_bCombatJump = false; m_iCombatJumpDelay = lastmillis + RandomLong(1500, 2800); return; } m_iMoveDir = DIR_NONE; // Check if bot is on top of his enemy float r = m_pMyEnt->radius+m_pMyEnt->enemy->radius; if ((fabs(m_pMyEnt->enemy->o.x-m_pMyEnt->o.x)enemy->o.y-m_pMyEnt->o.y)enemy->o.z+m_pMyEnt->enemy->aboveeye) < (m_pMyEnt->o.z + m_pMyEnt->aboveeye))) { // Try to get off him! condebug("On enemy!"); TMultiChoice AwayDirChoices; if (IsVisible(LEFT, 4.0f, false)) AwayDirChoices.Insert(LEFT); if (IsVisible(RIGHT, 4.0f, false)) AwayDirChoices.Insert(RIGHT); if (IsVisible(FORWARD, 4.0f, false)) AwayDirChoices.Insert(FORWARD); if (IsVisible(BACKWARD, 4.0f, false)) AwayDirChoices.Insert(BACKWARD); int iDir; if (AwayDirChoices.GetSelection(iDir)) { m_iMoveDir = iDir; m_iCombatNavTime = lastmillis + 500; } } float flDist = GetDistance(m_pMyEnt->enemy->o); // Check for nearby items? if (((m_iCheckEntsDelay < lastmillis) || m_pTargetEnt) && m_pBotSkill->bCanSearchItemsInCombat) { m_iCheckEntsDelay = lastmillis + 125; bool bSearchItems = false; if (m_pTargetEnt) { // Bot has already found an entity, still valid? vec v(m_pTargetEnt->x, m_pTargetEnt->y, S(m_pTargetEnt->x, m_pTargetEnt->y)->floor+m_pMyEnt->eyeheight); if ((GetDistance(v) > 25.0f) || !IsVisible(m_pTargetEnt)) m_pTargetEnt = NULL; } if (!m_pTargetEnt && (m_iCheckEntsDelay <= lastmillis)) { if (WeaponInfoTable[m_pMyEnt->gunselect].eWeaponType == TYPE_MELEE) bSearchItems = (flDist >= 8.0f); else bSearchItems = (m_pMyEnt->ammo[m_pMyEnt->gunselect] <= WeaponInfoTable[m_pMyEnt->gunselect].sMinDesiredAmmo); if (bSearchItems) m_pTargetEnt = SearchForEnts(false, 25.0f, 1.0f); } if (m_pTargetEnt) { condebug("Combat ent"); vec v(m_pTargetEnt->x, m_pTargetEnt->y, S(m_pTargetEnt->x, m_pTargetEnt->y)->floor+m_pMyEnt->eyeheight); debugbeam(m_pMyEnt->o, v); float flHeightDiff = v.z - m_pMyEnt->o.z; bool bToHigh = false; // Check he height for this ent if (Get2DDistance(v) <= 2.0f) { if (flHeightDiff >= 1.5f) { if (flHeightDiff <= JUMP_HEIGHT) { #ifndef RELEASE_BUILD char sz[64]; sprintf(sz, "Ent z diff: %f", v.z-m_pMyEnt->o.z); condebug(sz); #endif m_pMyEnt->jumpnext = true; // Jump if close to ent and the ent is high } else bToHigh = true; } } if (!bToHigh) { int iMoveDir = GetDirection(GetViewAngles(), m_pMyEnt->o, v); if (iMoveDir != DIR_NONE) { m_iMoveDir = iMoveDir; m_iCombatNavTime = lastmillis + RandomLong(125, 250); } // Check if bot needs to jump over something vec from = m_pMyEnt->o; from.z -= 1.0f; if (!IsVisible(from, iMoveDir, 3.0f, false)) m_pMyEnt->jumpnext = true; return; } } } // High skill and enemy is close? if ((m_sSkillNr <= 1) && (m_fYawToTurn < 80.0f) && (flDist <= 20.0f) && (m_iCombatJumpDelay < lastmillis)) { // Randomly jump a bit, to avoid some basic firepower ;) // How lower the distance to the enemy, how higher the chance for a jump short sJumpPercent = (100 - ((short)flDist * 8)); if (RandomLong(1, 100) <= sJumpPercent) { // Choose a nice direction to jump to // Is the enemy close? if ((GetDistance(m_pMyEnt->enemy->o) <= 4.0f) || (WeaponInfoTable[m_pMyEnt->gunselect].eWeaponType == TYPE_MELEE)) { m_iMoveDir = FORWARD; // Jump forward SetMoveDir(FORWARD, false); m_bCombatJump = true; } else if (WeaponInfoTable[m_pMyEnt->gunselect].eWeaponType != TYPE_MELEE)// else jump to a random direction { /* Directions to choose: - Forward-right - Right - Backward-right - Backward - Backward-left - Left - Forward-left */ TMultiChoice JumpDirChoices; short sForwardScore = ((flDist > 8.0f) || (flDist < 4.0f)) ? 20 : 10; short sBackwardScore = (flDist <= 6.0f) ? 20 : 10; short sStrafeScore = (flDist < 6.0f) ? 20 : 10; if (IsVisible((FORWARD | LEFT), 4.0f, false)) JumpDirChoices.Insert((FORWARD | LEFT), sForwardScore); if (IsVisible((FORWARD | RIGHT), 4.0f, false)) JumpDirChoices.Insert((FORWARD | RIGHT), sForwardScore); if (IsVisible(BACKWARD, 4.0f, false)) JumpDirChoices.Insert(BACKWARD, sBackwardScore); if (IsVisible((BACKWARD | LEFT), 4.0f, false)) JumpDirChoices.Insert((BACKWARD | LEFT), sBackwardScore); if (IsVisible((BACKWARD | RIGHT), 4.0f, false)) JumpDirChoices.Insert((BACKWARD | RIGHT), sBackwardScore); if (IsVisible(LEFT, 4.0f, false)) JumpDirChoices.Insert(LEFT, sStrafeScore); if (IsVisible(RIGHT, 4.0f, false)) JumpDirChoices.Insert(RIGHT, sStrafeScore); int JumpDir; if (JumpDirChoices.GetSelection(JumpDir)) { m_iMoveDir = JumpDir; SetMoveDir(JumpDir, false); m_bCombatJump = true; } } if (m_bCombatJump) { m_iCombatNavTime = lastmillis + RandomLong(125, 250); return; } } } if (WeaponInfoTable[m_pMyEnt->gunselect].eWeaponType == TYPE_MELEE) return; // Simply walk towards enemy if using a melee type flDist = Get2DDistance(m_pMyEnt->enemy->o); // Out of desired range for current weapon? if ((flDist <= WeaponInfoTable[m_pMyEnt->gunselect].flMinDesiredDistance) || (flDist >= WeaponInfoTable[m_pMyEnt->gunselect].flMaxDesiredDistance)) { if (flDist >= WeaponInfoTable[m_pMyEnt->gunselect].flMaxDesiredDistance) { m_iMoveDir = FORWARD; } else { m_iMoveDir = BACKWARD; } vec src, forward, right, up, dest, MyAngles = GetViewAngles(), o = m_pMyEnt->o; traceresult_s tr; // Is it furthest or farthest? bleh float flFurthestDist = 0; int bestdir = -1, dir = 0; bool moveback = (m_pMyEnt->move == -1); for(int j=-45;j<=45;j+=45) { src = MyAngles; src.y = WrapYZAngle(src.y + j); src.x = 0.0f; // If we're moving backwards, trace backwards if (moveback) src.y = WrapYZAngle(src.y + 180); AnglesToVectors(src, forward, right, up); dest = o; forward.mul(40); dest.add(forward); TraceLine(o, dest, m_pMyEnt, false, &tr); //debugbeam(origin, end); flDist = GetDistance(tr.end); if (flFurthestDist < flDist) { flFurthestDist = flDist; bestdir = dir; } dir++; } switch(bestdir) { case 0: if (moveback) m_iMoveDir |= RIGHT; // Strafe right else m_iMoveDir |= LEFT; // Strafe left break; case 2: if (moveback) m_iMoveDir |= LEFT; // Strafe left else m_iMoveDir |= RIGHT; // Strafe right break; } if (m_iMoveDir != DIR_NONE) { SetMoveDir(m_iMoveDir, false); m_iCombatNavTime = lastmillis + 500; } } else if (m_pBotSkill->bCircleStrafe) // Circle strafe when in desired range... { traceresult_s tr; vec angles, end, forward, right, up; TMultiChoice StrafeDirChoices; // Check the left side... angles = GetViewAngles(); angles.y = WrapYZAngle(angles.y - 75.0f); // Not 90 degrees because the bot // doesn't strafe in a straight line // (aims still to enemy). AnglesToVectors(angles, forward, right, up); end = m_pMyEnt->o; forward.mul(15.0f); end.add(forward); TraceLine(m_pMyEnt->o, end, m_pMyEnt, true, &tr); StrafeDirChoices.Insert(LEFT, (int)GetDistance(m_pMyEnt->o, tr.end)); // Check the right side... angles = GetViewAngles(); angles.y = WrapYZAngle(angles.y + 75.0f); // Not 90 degrees because the bot // doesn't strafe in a straight line // (aims still to enemy). AnglesToVectors(angles, forward, right, up); end = m_pMyEnt->o; forward.mul(15.0f); end.add(forward); TraceLine(m_pMyEnt->o, end, m_pMyEnt, true, &tr); StrafeDirChoices.Insert(RIGHT, (int)GetDistance(m_pMyEnt->o, tr.end)); int StrafeDir; if (StrafeDirChoices.GetSelection(StrafeDir)) { m_iMoveDir = StrafeDir; SetMoveDir(StrafeDir, false); m_iCombatNavTime = lastmillis + RandomLong(1500, 3000); } } else // Bot can't circle strafe(low skill), just stand still ResetMoveSpeed(); } bool CBot::CheckStuck() { if (m_iStuckCheckDelay + (CheckCrouch() ? 2000 : 0) >= lastmillis) return false; if ((m_vGoal!=g_vecZero) && (GetDistance(m_vGoal) < 2.0f)) return false; bool IsStuck = false; vec CurPos = m_pMyEnt->o, PrevPos = m_vPrevOrigin; CurPos.z = PrevPos.z = 0; // Did the bot hardly move the last frame? if (GetDistance(CurPos, PrevPos) <= 0.1f) { if (m_bStuck) { if (m_iStuckTime < lastmillis) IsStuck = true; } else { m_bStuck = true; m_iStuckTime = lastmillis + 1000; } } else { m_bStuck = false; m_iStuckTime = 0; } if (IsStuck) { #ifndef RELEASE_BUILD char msg[64]; sprintf(msg, "stuck (%f)", GetDistance(m_vPrevOrigin)); condebug(msg); #endif m_bStuck = false; m_iStuckTime = 0; // Crap bot is stuck, lets just try some random things // Check if the bot can turn around vec src = GetViewAngles(); src.x = 0; vec forward, right, up, dir, dest; traceresult_s tr; AnglesToVectors(src, forward, right, up); // Check the left side... dir = right; dest = m_pMyEnt->o; dir.mul(3); dest.sub(dir); TraceLine(m_pMyEnt->o, dest, m_pMyEnt, false, &tr); //debugbeam(m_pMyEnt->o, end); if (!tr.collided) { // Bot can turn left, do so m_pMyEnt->targetyaw = WrapYZAngle(m_pMyEnt->yaw - 90); m_iStuckCheckDelay = m_iCheckEnvDelay = lastmillis + 500; return true; } // Check the right side... dir = right; dest = m_pMyEnt->o; dir.mul(3); dest.add(dir); TraceLine(m_pMyEnt->o, dest, m_pMyEnt, true, &tr); //debugbeam(m_pMyEnt->o, end); if (!tr.collided) { // Bot can turn right, do so m_pMyEnt->targetyaw = WrapYZAngle(m_pMyEnt->yaw + 90); m_iStuckCheckDelay = m_iCheckEnvDelay = lastmillis + 500; return true; } // Check if bot can turn 180 degrees dir = forward; dest = m_pMyEnt->o; dir.mul(3); dest.add(dir); TraceLine(m_pMyEnt->o, dest, m_pMyEnt, true, &tr); //debugbeam(m_pMyEnt->o, end); if (!tr.collided) { // Bot can turn around, do so m_pMyEnt->targetyaw = WrapYZAngle(m_pMyEnt->yaw + 180); m_iStuckCheckDelay = m_iCheckEnvDelay = lastmillis + 500; return true; } // Bleh bot couldn't turn, lets just randomly jump :| condebug("Randomly avoiding stuck..."); if (RandomLong(0, 2) == 0) m_pMyEnt->jumpnext = true; else m_pMyEnt->targetyaw = WrapYZAngle(m_pMyEnt->yaw + RandomLong(60, 160)); return true; } return false; } // Check if a near wall is blocking and we can jump over it bool CBot::CheckJump() { bool bHasGoal = m_vGoal!=g_vecZero; float flGoalDist = (bHasGoal) ? GetDistance(m_vGoal) : 0.0f; // if ((bHasGoal) && (flGoalDist < 2.0f)) // return false; UNDONE? vec start = m_pMyEnt->o; float flTraceDist = 3.0f; if (bHasGoal && (flGoalDist < flTraceDist)) flTraceDist = flGoalDist; // Something blocks at eye hight? if (!IsVisible(start, FORWARD, flTraceDist, false)) { // Check if the bot can jump over it start.z += (JUMP_HEIGHT - 1.0f); if (IsVisible(start) && !IsVisible(start, FORWARD, flTraceDist, false)) { // Jump debugnav("High wall"); m_pMyEnt->jumpnext = true; return true; } } else { // Check if something is blocking at feet height, so the bot can jump over it start.z -= 1.7f; // Trace was blocked? if (!IsVisible(start, FORWARD, flTraceDist, false)) { //debugbeam(start, end); // Jump debugnav("Low wall"); m_pMyEnt->jumpnext = true; return true; } } return false; // Bot didn't had to jump(or couldn't) } bool CBot::CheckCrouch() { bool bHasGoal = m_vGoal!=g_vecZero; float flGoalDist = (bHasGoal) ? GetDistance(m_vGoal) : 0.0f; vec start = m_pMyEnt->o; vec crouch = vec(0, 0, 2.0f); float flTraceDist = 3.0f; if (bHasGoal && (flGoalDist < flTraceDist)) flTraceDist = flGoalDist; if (!IsVisible(vec(start).add(crouch), FORWARD, flTraceDist, false) && IsVisible(vec(start).sub(crouch), FORWARD, flTraceDist, false)) return true; return false; } bool CBot::CheckStrafe() { if (m_iStrafeTime >= lastmillis) { SetMoveDir(m_iMoveDir, true); return true; } if (m_iStrafeCheckDelay >= lastmillis) return false; // Check for near walls traceresult_s tr; vec from = m_pMyEnt->o, to, forward, right, up, dir; float flLeftDist = -1.0f, flRightDist = -1.0f; bool bStrafe = false; int iStrafeDir = DIR_NONE; AnglesToVectors(GetViewAngles(), forward, right, up); // Check for a near left wall to = from; dir = right; dir.mul(3.0f); to.sub(dir); TraceLine(from, to, m_pMyEnt, false, &tr); if (tr.collided) flLeftDist = GetDistance(from, tr.end); //debugbeam(m_pMyEnt->o, to); // Check for a near right wall to = from; dir = right; dir.mul(3.0f); to.add(dir); TraceLine(from, to, m_pMyEnt, false, &tr); if (tr.collided) flRightDist = GetDistance(from, tr.end); //debugbeam(m_pMyEnt->o, to); if ((flLeftDist == -1.0f) && (flRightDist == -1.0f)) { dir = right; dir.mul(m_pMyEnt->radius); // Check left from = m_pMyEnt->o; from.sub(dir); if (IsVisible(from, FORWARD, 3.0f, false, &flLeftDist)) flLeftDist = -1.0f; // Check right from = m_pMyEnt->o; from.add(dir); if (IsVisible(from, FORWARD, 3.0f, false, &flRightDist)) flRightDist = -1.0f; } if ((flLeftDist != -1.0f) && (flRightDist != -1.0f)) { if (flLeftDist < flRightDist) { // Strafe right bStrafe = true; iStrafeDir = RIGHT; } else if (flRightDist < flLeftDist) { // Strafe left bStrafe = true; iStrafeDir = LEFT; } else { // Randomly choose a strafe direction bStrafe = true; if (RandomLong(0, 1)) iStrafeDir = LEFT; else iStrafeDir = RIGHT; } } else if (flLeftDist != -1.0f) { // Strafe right bStrafe = true; iStrafeDir = RIGHT; } else if (flRightDist != -1.0f) { // Strafe left bStrafe = true; iStrafeDir = LEFT; } if (bStrafe) { SetMoveDir(iStrafeDir, true); m_iMoveDir = iStrafeDir; m_iStrafeTime = lastmillis + RandomLong(75, 150); } return bStrafe; } void CBot::CheckFOV() { m_iCheckEnvDelay = lastmillis + RandomLong(125, 250); vec MyAngles = GetViewAngles(); vec src, forward, right, up, dest, best(0, 0, 0); vec origin = m_pMyEnt->o; float flDist, flFurthestDist = 0; bool WallLeft = false; traceresult_s tr; //origin.z -= 1.5; // Slightly under eye level // Scan 90 degrees FOV for(int angle=-45;angle<=45;angle+=5) { src = MyAngles; src.y = WrapYZAngle(src.y + angle); AnglesToVectors(src, forward, right, up); dest = origin; forward.mul(40); dest.add(forward); TraceLine(origin, dest, m_pMyEnt, false, &tr); //debugbeam(origin, end); flDist = GetDistance(tr.end); if (flFurthestDist < flDist) { flFurthestDist = flDist; best = tr.end; } } if (best.x && best.y && best.z) { AimToVec(best); // Update MyAngles, since their (going to be) change(d) MyAngles.x = m_pMyEnt->targetpitch; MyAngles.y = m_pMyEnt->targetyaw; } float flNearestHitDist = GetDistance(best); if (!UnderWater(m_pMyEnt->o) && m_pMyEnt->onfloor) { // Check if a near wall is blocking and we can jump over it if (flNearestHitDist < 4) { // Check if the bot can jump over it src = MyAngles; src.x = 0; AnglesToVectors(src, forward, right, up); vec start = origin; start.z += 2.0f; dest = start; forward.mul(6); dest.add(forward); TraceLine(start, dest, m_pMyEnt, false, &tr); //debugbeam(start, end); if (!tr.collided) { // Jump debugnav("High wall"); m_pMyEnt->jumpnext = true; m_iStrafeCheckDelay = lastmillis + RandomLong(250, 500); return; } } else { // Check if something is blocking below us, so the bot can jump over it src = MyAngles; src.x = 0; AnglesToVectors(src, forward, right, up); vec start = origin; start.z -= 1.7f; dest = start; forward.mul(4); dest.add(forward); TraceLine(start, dest, m_pMyEnt, false, &tr); // Trace was blocked? if (tr.collided) { //debugbeam(start, end); // Jump debugnav("Low wall"); m_pMyEnt->jumpnext = true; m_iStrafeCheckDelay = lastmillis + RandomLong(250, 500); return; } } // Check if the bot is going to fall... src = MyAngles; src.x = 0.0f; AnglesToVectors(src, forward, right, up); dest = origin; forward.mul(3.0f); dest.add(forward); TraceLine(origin, dest, m_pMyEnt, false, &tr); int cx = int(tr.end.x), cy = int(tr.end.y); short CubesInWater=0; for(int x=cx-1;x<=(cx+1);x++) { for(int y=cy-1;y<=(cy+1);y++) { if (OUTBORD(x, y)) continue; //sqr *s = S(fast_f2nat(x), fast_f2nat(y)); //if (!SOLID(s)) { vec from(x, y, m_pMyEnt->o.z); dest = from; dest.z -= 6.0f; TraceLine(from, dest, m_pMyEnt, false, &tr); bool turn = false; if (UnderWater(tr.end)) CubesInWater++; if (CubesInWater > 2) turn = true; // Always avoid water if (!tr.collided && RandomLong(0, 1)) turn = true; // Randomly avoid a fall if (turn) { m_pMyEnt->targetyaw = WrapYZAngle(m_pMyEnt->yaw + 180); m_iCheckEnvDelay = m_iStrafeCheckDelay = lastmillis + RandomLong(750, 1500); debugnav("Water or a fall in front"); return; } } } } } // Is the bot about to head a corner? if (flNearestHitDist <= 4.0f) { src = MyAngles; src.y = WrapYZAngle(src.y - 45.0f); AnglesToVectors(src, forward, right, up); dest = origin; forward.mul(4.0f); dest.add(forward); TraceLine(origin, dest, m_pMyEnt, false, &tr); WallLeft = (tr.collided); src = MyAngles; src.y += WrapYZAngle(src.y + 45.0f); AnglesToVectors(src, forward, right, up); dest = origin; forward.mul(4.0f); dest.add(forward); TraceLine(origin, dest, m_pMyEnt, false, &tr); if (WallLeft && tr.collided) { // We're about to hit a corner, turn away debugnav("Corner"); m_pMyEnt->targetyaw = WrapYZAngle(m_pMyEnt->yaw + RandomFloat(160.0f, 200.0f)); m_iCheckEnvDelay = m_iStrafeCheckDelay = lastmillis + RandomLong(750, 1500); return; } } } // Called when bot is underwater bool CBot::WaterNav() { const int iSearchRange = 4; if (m_vWaterGoal==g_vecZero) { AddDebugText("WaterNav"); // Find the nearest and reachable cube which isn't underwater int cx = int(m_pMyEnt->o.x); int cy = int(m_pMyEnt->o.y); float flNearestDist = 9999.0f, flDist; if (OUTBORD(cx, cy)) return false; // Check all cubes in range... for (int x=(cx-iSearchRange);x<=(cx+iSearchRange);x++) { for (int y=(cy-iSearchRange);y<=(cy+iSearchRange);y++) { sqr *s = S(x, y); if (SOLID(s)) continue; if ((x==cx) && (y==cy)) continue; vec v(x, y, GetCubeFloor(x, y)); if (UnderWater(v)) continue; // Skip, cube is underwater if (waterlevel < (v.z - 2.0f)) continue; // Cube is too high // Check if the bot 'can fit' on the cube(no near obstacles) bool small_ = false; for (int a=(x-2);a<=(x+2);a++) { if (small_) break; for (int b=(y-2);b<=(y+2);b++) { if ((x==a) && (y==b)) continue; vec v2(a, b, GetCubeFloor(a, b)); if (v.z < (v2.z-1-JUMP_HEIGHT)) { small_=true; break; } if ((a >= (x-1)) && (a <= (x+1)) && (b >= (y-1)) && (b <= (y+1))) { if ((v2.z) < (v.z-2.0f)) { small_ = true; break; } } traceresult_s tr; TraceLine(v, v2, NULL, false, &tr); if (tr.collided) { small_=true; break; } } if (small_) break; } if (small_) { debugbeam(m_pMyEnt->o, v); continue; } // Okay, cube is valid. flDist = GetDistance(v); if (flDist < flNearestDist) { flNearestDist = flDist; m_vWaterGoal = v; } } } } if (m_vWaterGoal!=g_vecZero) { AddDebugText("WaterNav"); //debugbeam(m_pMyEnt->o, m_vWaterGoal); vec aim = m_vWaterGoal; aim.z += 1.5f; // Aim a bit further up AimToVec(aim); if ((RandomLong(1, 100) <= 15) && (Get2DDistance(m_vWaterGoal) <= 7.0f)) m_pMyEnt->jumpnext = true; return true; } return false; } bool CBot::CheckItems() { if (!m_pCurrentGoalWaypoint && !CheckJump() && CheckStuck()) { // Don't check for ents a while when stuck m_iCheckEntsDelay = lastmillis + RandomLong(1000, 2000); return false; } if (m_vGoal==g_vecZero) m_pTargetEnt = NULL; if (!m_pTargetEnt) { if (m_iCheckEntsDelay > lastmillis) return false; else { m_pTargetEnt = SearchForEnts(!m_classicsp); m_iCheckEntsDelay = lastmillis + RandomLong(2500, 5000); } } if (m_pTargetEnt) { if (HeadToTargetEnt()) return true; } if (m_eCurrentBotState == STATE_ENT) { ResetWaypointVars(); m_vGoal = g_vecZero; m_pTargetEnt = NULL; } return false; } bool CBot::InUnreachableList(entity *e) { TLinkedList::node_s *p = m_UnreachableEnts.GetFirst(); while(p) { if (p->Entry->ent == e) return true; p = p->next; } return false; } bool CBot::IsReachable(vec to, float flMaxHeight) { vec from = m_pMyEnt->o; traceresult_s tr; float curr_height, last_height; float distance = GetDistance(from, to); // is the destination close enough? //if (distance < REACHABLE_RANGE) { if (IsVisible(to)) { // Look if bot can 'fit trough' vec src = from, forward, right, up; AnglesToVectors(GetViewAngles(), forward, right, up); // Trace from 1 cube to the left vec temp = right; temp.mul(1.0f); src.sub(temp); if (!::IsVisible(src, to)) return false; // Trace from 1 cube to the right src.add(temp); if (!::IsVisible(src, to)) return false; if (UnderWater(from) && UnderWater(to)) { // No need to worry about heights in water return true; } /* if (to.z > (from.z + JUMP_HEIGHT)) { vec v_new_src = to; vec v_new_dest = to; v_new_dest.z = v_new_dest.z - (JUMP_HEIGHT + 1.0f); // check if we didn't hit anything, if so then it's in mid-air if (::IsVisible(v_new_src, v_new_dest, NULL)) { condebug("to is in midair"); debugbeam(from, to); return false; // can't reach this one } } */ // check if distance to ground increases more than jump height // at points between from and to... vec v_temp = to; v_temp.sub(from); vec v_direction = Normalize(v_temp); // 1 unit long vec v_check = from; vec v_down = from; v_down.z = v_down.z - 100.0f; // straight down TraceLine(v_check, v_down, NULL, false, &tr); // height from ground last_height = GetDistance(v_check, tr.end); distance = GetDistance(to, v_check); // distance from goal while (distance > 2.0f) { // move 2 units closer to the goal v_temp = v_direction; v_temp.mul(2.0f); v_check.add(v_temp); v_down = v_check; v_down.z = v_down.z - 100.0f; TraceLine(v_check, v_down, NULL, false, &tr); curr_height = GetDistance(v_check, tr.end); // is the difference in the last height and the current height // higher that the jump height? if ((last_height - curr_height) >= flMaxHeight) { // can't get there from here... //condebug("traces failed to to"); debugbeam(from, to); return false; } last_height = curr_height; distance = GetDistance(to, v_check); // distance from goal } return true; } } return false; } void CBot::HearSound(int n, vec *o) { // Has the bot already an enemy? if (m_pMyEnt->enemy) return; //fixmebot // Is the sound not interesting? if(n == S_DIE1 || n == S_DIE2) return; int soundvol = m_pBotSkill->iMaxHearVolume - (int)(GetDistance(*o)*3*m_pBotSkill->iMaxHearVolume/255); if (soundvol == 0) return; // Look who made the sound(check for the nearest enemy) float flDist, flNearestDist = 3.0f; // Range of 3 units playerent *pNearest = NULL; // Check all bots first loopv(bots) { playerent *d = bots[i]; if (d == m_pMyEnt || !d || (d->state != CS_ALIVE) || isteam(m_pMyEnt->team, d->team)) continue; flDist = GetDistance(*o, d->o); if ((flDist < flNearestDist) && IsVisible(d)) { pNearest = d; flNearestDist = flDist; } } // Check local player if (player1 && (player1->state == CS_ALIVE) && !isteam(m_pMyEnt->team, player1->team)) { flDist = GetDistance(*o, player1->o); if ((flDist < flNearestDist) && IsVisible(player1)) { pNearest = player1; flNearestDist = flDist; } } if (pNearest) { if (m_pMyEnt->enemy != pNearest) m_iShootDelay = lastmillis + GetShootDelay(); // Add shoot delay when new enemy found m_pMyEnt->enemy = pNearest; } } bool CBot::IsInFOV(const vec &o) { vec target, dir, forward, right, up; float flDot, flAngle; AnglesToVectors(GetViewAngles(), forward, right, up); // direction the bot is aiming at dir = forward; dir.z = 0; // Make 2D // ideal direction target = o; target.sub(m_pMyEnt->o); target.z = 0.0f; // Make 2D // angle between these two directions flDot = target.dot(dir); flAngle = acos(flDot/(target.magnitude() * dir.magnitude())); return m_pBotSkill->iFov/2.0f >= flAngle/RAD; } // Code of CBot - End assaultcube-1.2.0.2.1/source/src/bot/bot_util.cpp000066400000000000000000000314361352165075300215420ustar00rootroot00000000000000// // C++ Implementation: bot_util // // Description: Basic util functions, mostly bot related // // // Author: // // // // #include "cube.h" #include "bot.h" // Function code by PMB - Begin // Random functions begin // copied from // http://forums.bots-united.com/showthread.php?t=244&page=1&pp=10&highlight=random // So credits to PMB and the person(s) who actually made it :] // maximum value returned by our number generator (2^31 - 1 = 0x7FFFFFFF) #define LRAND_MAX 2147483647L long lseed; // our random number generator's seed long lrand (void) { // this function is the equivalent of the rand() standard C library function, // except that whereas rand() works only with short integers // (i.e. not above 32767), this function is able to generate 32-bit random // numbers. Isn't that nice ? // credits go to Ray Gardner for his fast implementation of minimal random // number generators // http://c.snippets.org/snip_lister.php?fname=rg_rand.c // compose the two 16-bit parts of the long integer and assemble them static unsigned long lrand_lo, lrand_hi; lrand_lo = 16807 * (long) (lseed & 0xFFFF); // low part lrand_hi = 16807 * (long) ((unsigned long) lseed >> 16); // high part lrand_lo += (lrand_hi & 0x7FFF) << 16; // assemble both in lrand_lo // is the resulting number greater than LRAND_MAX (half the capacity) ? if (lrand_lo > LRAND_MAX) { lrand_lo &= LRAND_MAX; // then get rid of the disturbing bit lrand_lo++; // and increase it a bit (to avoid overflow problems, I suppose) } lrand_lo += lrand_hi >> 15; // now do twisted maths to generate the next seed // is the resulting number greater than LRAND_MAX (half the capacity) ? if (lrand_lo > LRAND_MAX) { lrand_lo &= LRAND_MAX; // then get rid of the disturbing bit lrand_lo++; // and increase it a bit (to avoid overflow problems, I suppose) } // now we've got our (pseudo-)random number. lseed = (long) lrand_lo; // put it in the seed for next time return (lseed); // and return it. Yeah, simple as that. } void lsrand (unsigned long initial_seed) { // this function initializes the random seed based on the initial seed value // passed in the initial_seed parameter. Since random seeds are // usually initialized with the time of day, and time is a value that // changes slowly, we bump the seed twice to have it in a more // random state for future calls of the random number generator. // fill in the initial seed of the random number generator lseed = (long) initial_seed; lseed = lrand (); // bump it once lseed = lrand (); // bump it twice return; // that's all folks } long RandomLong (long from, long to) { // this function returns a random integer number between (and including) // the starting and ending values passed by parameters from and to. if (to <= from) return (from); return (from + lrand () / (LRAND_MAX / (to - from + 1))); } float RandomFloat (float from, float to) { // this function returns a random floating-point number between (and including) // the starting and ending values passed by parameters from and to. if (to <= from) return (from); return (from + (float) lrand () / (LRAND_MAX / (to - from))); } // End random functions void AnglesToVectors(vec angles, vec &forward, vec &right, vec &up) { float angle; float sin_pitch; float sin_yaw; float sin_roll; float cos_pitch; float cos_yaw; float cos_roll; // For some reason this has to be done :) // Me = math n00b angles.x = -angles.x; angles.y -= 90; // compute the sin and cosine of the pitch component angle = angles.x * RAD; sin_pitch = sinf (angle); cos_pitch = cosf (angle); // compute the sin and cosine of the yaw component angle = angles.y * RAD; sin_yaw = sinf (angle); cos_yaw = cosf (angle); // compute the sin and cosine of the roll component angle = angles.z * RAD; sin_roll = sinf (angle); cos_roll = cosf (angle); // build the FORWARD vector forward.x = cos_pitch * cos_yaw; forward.y = cos_pitch * sin_yaw; forward.z = -sin_pitch; // build the RIGHT vector right.x = -(-(sin_roll * sin_pitch * cos_yaw) - (cos_roll * -sin_yaw)); right.y = -(-(sin_roll * sin_pitch * sin_yaw) - (cos_roll * cos_yaw)); right.z = -(sin_roll * cos_pitch); // build the UPWARDS vector up.x = ((cos_roll * sin_pitch * cos_yaw) - (sin_roll * -sin_yaw)); up.y = ((cos_roll * sin_pitch * sin_yaw) - (sin_roll * cos_yaw)); up.z = cos_roll * cos_pitch; return; } // Function code by PMB - End float WrapXAngle(float angle) { if (angle > 90) angle = 90; else if (angle < -90) angle = -90; return angle; } float WrapYZAngle(float angle) { while (angle >= 360.0f) angle -= 360.0f; while (angle < 0.0f) angle += 360.0f; return angle; } // Sees how far it can come from 'from' to 'to' and puts the end vector in 'end' // (1337 description :-) // UNDONE: Optimize this as much as possible void TraceLine(vec from, vec to, dynent *pTracer, bool CheckPlayers, traceresult_s *tr, bool SkipTags) { tr->end = from; tr->collided = false; static float flNearestDist, flDist; static vec v; static bool solid; flNearestDist = 9999.0f; if(OUTBORD((int)from.x, (int)from.y)) return; // Check if the 'line' collides with entities like mapmodels loopv(ents) { entity &e = ents[i]; if(e.type!=MAPMODEL) continue; // Only check map models for now mapmodelinfo *mmi = getmminfo(e.attr2); if(!mmi || !mmi->h) continue; float lo = (float)(S(e.x, e.y)->floor + mmi->zoff + e.attr3); float hi = lo + mmi->h; float z = (fabs(from.z-lo) < fabs(from.z-hi)) ? lo : hi; makevec(&v, e.x, e.y, z); flDist = GetDistance(from, v); if ((flDist < flNearestDist) && (intersect(&e, from, to, &tr->end))) { flNearestDist = GetDistance(from, tr->end); tr->collided = true; } } if (CheckPlayers) { // Check if the 'line' collides with bots loopv(bots) { playerent *d = bots[i]; if(!d || (d==pTracer) || (d->state != CS_ALIVE)) continue; // Only check valid bots flDist = GetDistance(from, d->o); if ((flDist < flNearestDist) && (intersect(d, from, to, &tr->end))) { flNearestDist = flDist; tr->collided = true; } } // Check if the 'line' collides with the local player(player1) playerent *d = player1; // Shortcut if (d && (d!=pTracer) && !BotManager.m_pBotToView && (d->state == CS_ALIVE)) { flDist = GetDistance(from, d->o); if ((flDist < flNearestDist) && (intersect(d, from, to, &tr->end))) { flNearestDist = flDist; tr->collided = true; } } } float dx = to.x-from.x; float dy = to.y-from.y; int steps = (int)(sqrt(dx*dx+dy*dy)/0.9); if(!steps) // If from and to are on the same cube... { if (GetDistance(from, to) < flNearestDist) { tr->end = to; sqr *s = S(int(from.x), int(from.y)); float flr = GetCubeFloor(int(from.x), int(from.y)); solid = ((!SkipTags || !s->tag) && SOLID(s)); if (solid || (to.z < flr) || (to.z > s->ceil)) { tr->collided = true; tr->end.z = (fabs(to.z-s->ceil) < fabs(to.z-flr)) ? s->ceil : flr; } } return; } float x = from.x; float y = from.y; int i = 0; vec endcube = from; // Now check if the 'line' is hit by a cube while(i= flNearestDist) break; sqr *s = S(int(x), int(y)); solid = ((!SkipTags || !s->tag) && SOLID(s)); if(solid) break; float floor = s->floor; if(s->type==FHF) floor -= s->vdelta/4.0f; float ceil = s->ceil; if(s->type==CHF) ceil += s->vdelta/4.0f; float rz = from.z-((from.z-to.z)*(i/(float)steps)); if(rzceil) break; endcube.x = x; endcube.y = y; endcube.z = rz; x += dx/(float)steps; y += dy/(float)steps; i++; } if ((i>=steps) && !tr->collided) { tr->end = to; } else { tr->collided = true; if (GetDistance(from, endcube) < flNearestDist) tr->end = endcube; } return; } float GetDistance(vec v1, vec v2) { if ((v1.x == 0) && (v2.x == 0) && (v1.y == 0) && (v2.y == 0) && (v1.z == 0) && (v2.z == 0)) return 0.0f; return v1.dist(v2); } // As GetDistance(), but doesn take height in account. float Get2DDistance(vec v1, vec v2) { if ((v1.x == 0) && (v2.x == 0) && (v1.y == 0) && (v2.y == 0)) return 0.0f; v1.z = v2.z = 0.0f; return v1.dist(v2); } bool IsVisible(vec v1, vec v2, dynent *tracer, bool SkipTags) { traceresult_s tr; TraceLine(v1, v2, tracer, (tracer!=NULL), &tr, SkipTags); return !tr.collided; } // Prediction: // - pos: Current position // - vel: Current velocity // - Time: In seconds, predict how far it is in Time seconds vec PredictPos(vec pos, vec vel, float Time) { float flVelLength = vel.magnitude(); if (flVelLength <= 1.0) return pos; // don't bother with low velocities... vec v_end = vel; v_end.mul(Time); v_end.add(pos); return v_end; } // returns true if the given file is valid bool IsValidFile(const char *szFileName) { FILE *fp = fopen(szFileName, "r"); if (fp) { fclose(fp); return true; } return false; } bool FileIsOlder(const char *szFileName1, const char *szFileName2) { /* int file1, file2; struct stat stat1, stat2; file1 = open(szFileName1, O_RDONLY); file2 = open(szFileName2, O_RDONLY); fstat(file1, &stat1); fstat(file2, &stat2); close(file1); close(file2); return(stat1.st_mtime < stat2.st_mtime);*/ return false; // FIXME } vec Normalize(vec v) { float flLen = sqrt(v.x*v.x + v.y*v.y + v.z*v.z); static vec v_norm = g_vecZero; if (flLen == 0) { v_norm.x=0;v_norm.y=0;v_norm.z=1; } else { flLen = 1 / flLen; v_norm.x = v.x * flLen; v_norm.y = v.y * flLen; v_norm.z = v.z * flLen; } return v_norm; } float GetYawDiff(float curyaw, vec v1, vec v2) { float yaw = -(float)atan2(v2.x - v1.x, v2.y - v1.y)/PI*180+180; return yaw-curyaw; } vec CrossProduct(const vec &a, const vec &b) { vec cross(a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x); return cross; } int GetDirection(const vec &angles, const vec &v1, const vec &v2) { vec tmp, forward, right, up, cross; float flDot; AnglesToVectors(angles, forward, right, up); tmp = v2; tmp.sub(v1); tmp.z = 0.0f; // Make 2D tmp = Normalize(tmp); forward.z = 0; // Make 2D flDot = tmp.dot(forward); cross = CrossProduct(tmp, forward); int Dir = DIR_NONE; if (cross.z > 0.1f) Dir |= LEFT; else if (cross.z < -0.1f) Dir |= RIGHT; if (flDot < -0.1f) Dir |= BACKWARD; else if (flDot > 0.1f) Dir |= FORWARD; if (v1.z > v2.z) Dir |= DOWN; if (v1.z < v2.z) Dir |= UP; return Dir; } float GetCubeFloor(int x, int y) { sqr *s = S(x, y); float floor = s->floor; if (s->type == FHF) floor -= (s->vdelta+S(x+1,y)->vdelta+S(x,y+1)->vdelta+S(x+1,y+1)->vdelta)/16.0f; return floor; } float GetCubeHeight(int x, int y) { sqr *s = S(x, y); float ceil = s->ceil; if(s->type == CHF) ceil += (s->vdelta+S(x+1,y)->vdelta+S(x,y+1)->vdelta+S(x+1,y+1)->vdelta)/16.0f; return ceil; } const char *SkillNrToSkillName(short skillnr) { if (skillnr == 0) return "best"; else if (skillnr == 1) return "good"; else if (skillnr == 2) return "medium"; else if (skillnr == 3) return "worse"; else if (skillnr == 4) return "bad"; return NULL; } bool IsInGame(dynent *d) { if (!d) return false; if (d->type==ENT_BOT) { loopv(bots) { if (bots[i] == d) return true; } } else { if (d == player1) return true; } return false; } assaultcube-1.2.0.2.1/source/src/bot/bot_util.h000066400000000000000000000337551352165075300212150ustar00rootroot00000000000000#ifndef BOT_UTIL_H #define BOT_UTIL_H // Structure for storing traceresults struct traceresult_s { vec end; bool collided; }; long RandomLong(long from, long to); float RandomFloat(float from, float to); void lsrand(unsigned long initial_seed); void AnglesToVectors(vec angles, vec &forward, vec &right, vec &up); float WrapXAngle(float angle); float WrapYZAngle(float angle); void TraceLine(vec from, vec to, dynent *pTracer, bool CheckPlayers, traceresult_s *tr, bool SkipTags=false); float GetDistance(vec v1, vec v2); float Get2DDistance(vec v1, vec v2); bool IsVisible(vec v1, vec v2, dynent *tracer = NULL, bool SkipTags=false); bool IsValidFile(const char *szFileName); bool FileIsOlder(const char *szFileName1, const char *szFileName2); vec PredictPos(vec pos, vec vel, float Time); vec Normalize(vec v); inline void makevec(vec *v, float x, float y, float z) { v->x=x; v->y=y; v->z=z; } inline bool UnderWater(const vec &o) { return waterlevel > o.z - 0.5f; } inline bool InWater(const vec &o) { return waterlevel >= o.z; } float GetYawDiff(float curyaw, vec v1, vec v2); vec CrossProduct(const vec &a, const vec &b); int GetDirection(const vec &angles, const vec &v1, const vec &v2); float GetCubeFloor(int x, int y); float GetCubeHeight(int x, int y); const char *SkillNrToSkillName(short skillnr); bool IsInGame(dynent *d); // ================================================================== // Code of TLinkedList - Start // ================================================================== template class TLinkedList { public: struct node_s { C Entry; node_s *next; node_s *prev; node_s(void) : next(NULL), prev(NULL) { //memset(&Entry, 0, sizeof(Entry)); }; }; // member functions void AddNode(C entry) { if (!pNodeList) { pNodeList = new node_s; pNodeList->Entry = entry; pNodeList->next = NULL; pNodeList->prev = NULL; pLastNode = pNodeList; iNodeCount = 1; } else { pLastNode->next = new node_s; pLastNode->next->prev = pLastNode; pLastNode = pLastNode->next; pLastNode->Entry = entry; pLastNode->next = NULL; iNodeCount++; } } void PushNode(C Entry) { if (!pNodeList) { pNodeList = new node_s; pNodeList->Entry = Entry; pNodeList->next = NULL; pNodeList->prev = NULL; pLastNode = pNodeList; iNodeCount = 1; } else { node_s *pNew = new node_s; pNew->Entry = Entry; pNew->prev = NULL; pNew->next = pNodeList; pNodeList->prev = pNew; pNodeList = pNew; iNodeCount++; } } void DeleteEntry(C Entry) { node_s *pNode = pNodeList; if (!pNode) return; if (pNode->Entry == Entry) // first node { if (pNodeList == pLastNode) pLastNode = NULL; pNodeList = pNodeList->next; if (pNodeList) pNodeList->prev = NULL; pNode->next = NULL; delete pNode; pNode = NULL; iNodeCount--; return; } if (Entry == pLastNode->Entry) // last node { pNode = pLastNode; pLastNode = pLastNode->prev; pLastNode->next = NULL; pNode->next = NULL; pNode->prev = NULL; delete pNode; pNode = NULL; iNodeCount--; return; } // node is somewhere in the middle pNode = SearchNode(Entry); if (!pNode) return; node_s *pPrevNode = pNode->prev; if (!pPrevNode) return; // unlink pNode pNode->next->prev = pPrevNode; pPrevNode->next = pNode->next; pNode->next = NULL; pNode->prev = NULL; delete pNode; pNode = NULL; iNodeCount--; } void DeleteNode(node_s *pNode) { if (!pNode) return; if (pNodeList == pNode) // first node { if (pNodeList == pLastNode) pLastNode = pNodeList->next; pNodeList = pNodeList->next; if (pNodeList) pNodeList->prev = NULL; pNode->next = NULL; delete pNode; pNode = NULL; iNodeCount--; return; } if (pNode == pLastNode) // last node { pNode = pLastNode; pLastNode = pLastNode->prev; pLastNode->next = NULL; pNode->next = NULL; pNode->prev = NULL; delete pNode; pNode = NULL; iNodeCount--; return; } // node is somewhere in the middle node_s *pPrevNode = pNode->prev; if (!pPrevNode) return; // unlink pNode pNode->next->prev = pPrevNode; pPrevNode->next = pNode->next; pNode->next = NULL; pNode->prev = NULL; delete pNode; pNode = NULL; iNodeCount--; } void DeleteAllNodes(void) { node_s *pNode = pNodeList; node_s *pTemp; while (pNode != NULL) { pTemp = pNode; pNode = pNode->next; pTemp->next = NULL; pTemp->prev = NULL; delete pTemp; } pNodeList = pLastNode = NULL; iNodeCount = 0; } void Reset(void) // Special case, doesn't delete existing nodes { pNodeList = pLastNode = NULL; iNodeCount = 0; } node_s *SearchNode(C Entry) { node_s *pNode = pNodeList; while(pNode) { if (pNode->Entry == Entry) return pNode; pNode = pNode->next; } return NULL; } C Pop(void) { if (!pNodeList) return static_cast(NULL); C Entry = pNodeList->Entry; DeleteNode(pNodeList); return Entry; } node_s *GetFirst(void) { return pNodeList; }; node_s *GetLast(void) { return pLastNode; }; void EditEntry(C OrigEntry, C NewVal) { node_s *pNode = SearchNode(OrigEntry); if (pNode) pNode->Entry = NewVal; } bool IsInList(C Entry) { return (SearchNode(Entry) != NULL); } bool Empty(void) { return (pNodeList == NULL); }; int NodeCount(void) { return iNodeCount; }; // construction/destruction TLinkedList(void) { pNodeList = NULL; pLastNode = NULL; iNodeCount = 0; }; ~TLinkedList(void) { DeleteAllNodes(); }; //fixmebot //private: node_s *pNodeList; node_s *pLastNode; int iNodeCount; }; // ================================================================== // Code of TLinkedList - End // ================================================================== // ================================================================== // Code of TPriorList - Begin // ================================================================== template class TPriorList { public: struct node_s { C Entry; D Priority; node_s *next; node_s(C Ent, D Prior) : Entry(Ent), Priority(Prior), next(NULL) {}; }; TPriorList(void) : pHeadNode(NULL), pLastNode(NULL) {}; ~TPriorList(void) { Clear(); }; void AddEntry(C Entry, D Prior) { if (!pHeadNode) { pHeadNode = new node_s(Entry, Prior); pLastNode = pHeadNode; iNodeCount=1; } else { iNodeCount++; node_s *pNew = new node_s(Entry, Prior); node_s *pNode = pHeadNode; node_s *pPrev = NULL; while(pNode) { if (Prior < pNode->Priority) { if (!pPrev) { pNew->next = pNode; pHeadNode = pNew; } else { pPrev->next = pNew; pNew->next = pNode; } break; } pPrev = pNode; pNode = pNode->next; } if (!pNode) { pLastNode = pNew; if (pPrev) pPrev->next = pNew; } } } C Pop(void) { if (!pHeadNode) return static_cast(NULL); C Entry = pHeadNode->Entry; DeleteNode(pHeadNode); return Entry; } void Clear(void) { node_s *pTemp; while(pHeadNode) { pTemp = pHeadNode; pHeadNode = pHeadNode->next; delete pTemp; } pHeadNode = pLastNode = NULL; } bool IsInList(C Entry, D Prior) { node_s *pNode = pHeadNode; while(pNode) { if (pNode->Entry == Entry) return true; if (Prior < pNode->Priority) return false; pNode = pNode->next; } return false; } bool Empty(void) { return (pHeadNode == NULL); } node_s *GetFirst(void) { return pHeadNode; } private: node_s *pHeadNode; node_s *pLastNode; int iNodeCount; node_s *GetPrevNode(node_s *pNode) { node_s *pTemp = pHeadNode; while(pTemp) { if (pTemp->next == pNode) return pTemp; pTemp = pTemp->next; } return NULL; } void DeleteNode(node_s *pNode) { if (!pNode) return; if (pHeadNode == pNode) // first node { if (pHeadNode == pLastNode) pLastNode = pHeadNode->next; pHeadNode = pHeadNode->next; pNode->next = NULL; delete pNode; pNode = NULL; iNodeCount--; return; } if (pNode == pLastNode) // last node { pNode = pLastNode; pLastNode->next = NULL; pNode->next = NULL; delete pNode; pNode = NULL; iNodeCount--; return; } // node is somewhere in the middle node_s *pPrevNode = GetPrevNode(pNode); if (!pPrevNode) return; // unlink pNode pPrevNode->next = pNode->next; pNode->next = NULL; delete pNode; pNode = NULL; iNodeCount--; } }; // ================================================================== // Code of TPriorList - End // ================================================================== // ================================================================== // Code of TMultiChoice - Begin // ================================================================== template class TMultiChoice { struct SMultiChoice { int MinVal; int MaxVal; C Choice; SMultiChoice(void) : MinVal(0), MaxVal(0){}; }; int TotalVal; TLinkedList *pChoiceList; public: TMultiChoice(void) : TotalVal(0) // Constructor { pChoiceList = new TLinkedList; }; ~TMultiChoice(void) // Destructor { while(pChoiceList->Empty() == false) { SMultiChoice *pEntry = pChoiceList->Pop(); if (pEntry) delete pEntry; else break; } delete pChoiceList; pChoiceList = NULL; } void Insert(C Choice, short Percent = 50) { if (Percent == 0) return; SMultiChoice *pChoiceEntry = new SMultiChoice; pChoiceEntry->MinVal = TotalVal; pChoiceEntry->MaxVal = TotalVal + Percent; pChoiceEntry->Choice = Choice; pChoiceList->AddNode(pChoiceEntry); TotalVal += Percent; }; bool FindSelection(SMultiChoice *MS, int Choice) { if ((Choice >= MS->MinVal) && (Choice < MS->MaxVal)) { return true; } return false; } void ClearChoices(void) { TotalVal = 0; while(pChoiceList->Empty() == false) delete pChoiceList->Pop(); } bool GetSelection(C &Var) { int Choice = RandomLong(0, (TotalVal - 1)); typename TLinkedList::node_s *pNode = pChoiceList->GetFirst(); while(pNode) { if ((Choice >= pNode->Entry->MinVal) && (Choice < pNode->Entry->MaxVal)) { Var = pNode->Entry->Choice; return true; } pNode = pNode->next; } return false; } }; // ================================================================== // Code of TMutiChoice - End // ================================================================== #endif assaultcube-1.2.0.2.1/source/src/bot/bot_waypoint.cpp000066400000000000000000002606171352165075300224440ustar00rootroot00000000000000// // C++ Implementation: bot_waypoint // // Description: Waypoint class for bots // // // Author: Rick // #include "cube.h" #include "bot.h" vec v_debuggoal = g_vecZero; CACWaypointClass WaypointClass; VAR(xhairwpsel, 0, 1, 1); // FIXME: multiple selections support ? // well, TBH I haven't groked this myself yet, but the following curselection segfaults the client, so I'm just putting in a sane-variant until someone groks it ;-) - ft 2011sep28 extern vector sels; //#define curselection (xhairwpsel ? vec(sels.last().x, sels.last().y, S(sels.last().x, sels.last().y)->floor+2.0f) : vec(player1->o.x, player1->o.y, player1->o.z)) #define curselection (vec(player1->o.x, player1->o.y, player1->o.z)) // Waypoint class begin CWaypointClass::CWaypointClass(void) : m_bDrawWaypoints(false), m_bDrawWPPaths(true), m_bAutoWaypoint(false), m_bAutoPlacePaths(true), m_bDrawWPText(false), m_vLastCreatedWP(g_vecZero), m_bFlooding(false), m_bFilteringNodes(false), m_iFloodStartTime(0), m_iCurFloodX(0), m_iCurFloodY(0), m_iFloodSize(0), m_iFilteredNodes(0), m_iWaypointCount(0) { loopi(MAX_MAP_GRIDS) { loopj(MAX_MAP_GRIDS) { while(!m_Waypoints[i][j].Empty()) delete m_Waypoints[i][j].Pop(); } } m_szMapName[0] = 0; } void CWaypointClass::Init() { Clear(); // Free previously allocated path memory loopi(MAX_MAP_GRIDS) { loopj(MAX_MAP_GRIDS) { while(!m_Waypoints[i][j].Empty()) delete m_Waypoints[i][j].Pop(); } } m_fPathDrawTime = 0.0; m_iWaypointCount = 0; m_vLastCreatedWP = g_vecZero; } void CWaypointClass::Clear() { for(int i=0;iConnectedWPs.DeleteAllNodes(); p->ConnectedWPsWithMe.DeleteAllNodes(); BotManager.DelWaypoint(p); delete p; } } } } //fixme TLinkedList::node_s *testx; // returns true if waypoints succesfull loaded bool CWaypointClass::LoadWaypoints() { stream *bfp; char szWPFileName[64]; char filename[256]; waypoint_header_s header; short num, triggernr, yaw; int i, j, flags; vec from, to; strcpy(szWPFileName, m_szMapName); strcat(szWPFileName, ".wpt"); BotManager.MakeBotFileName(szWPFileName, "waypoints", NULL, filename); bfp = openfile(filename, "rb"); BotManager.m_sCurrentTriggerNr = -1; // if file exists, read the waypoint structure from it if (bfp != NULL) { bfp->read(&header, sizeof(header)); header.szFileType[sizeof(header.szFileType)-1] = 0; if (strcmp(header.szFileType, "cube_bot") == 0) { header.szMapName[sizeof(header.szMapName)-1] = 0; if (strcmp(header.szMapName, m_szMapName) == 0) { Init(); // remove any existing waypoints // Check which waypoint file version this is, handle each of them different if (header.iFileVersion == 1) { // First version, works with an big array and has a limit waypoint_version_1_s WPs[1024]; int path_index; m_iWaypointCount = header.iWPCount; for (i=0; i < header.iWPCount; i++) { bfp->read(&WPs[i], sizeof(WPs[0])); WPs[i].ConnectedWPs.Reset(); // We get garbage when we read this from // a file, so just clear it // Convert to new waypoint structure node_s *pNode = new node_s(WPs[i].v_origin, WPs[i].iFlags, 0); short x, y; GetNodeIndexes(pNode->v_origin, &x, &y); m_Waypoints[x][y].AddNode(pNode); BotManager.AddWaypoint(pNode); } // read and add waypoint paths... for (i=0; i < m_iWaypointCount; i++) { // read the number of paths from this node... bfp->read(&num, sizeof(num)); // See which waypoint the current is node_s *pCurrent = GetWaypointFromVec(WPs[i].v_origin); if (!pCurrent) { conoutf("Error: NULL path in waypoint file"); continue; } for (j=0; j < num; j++) { bfp->read(&path_index, sizeof(path_index)); // See which waypoint this is node_s *pTo = GetWaypointFromVec(WPs[path_index].v_origin); if (!pTo) { conoutf("Error: NULL path in waypoint file"); continue; } AddPath(pCurrent, pTo); } } conoutf("Old waypoint version(%d) converted to new version(%d)", header.iFileVersion, WAYPOINT_VERSION); conoutf("Use the wpsave command to convert permently"); } else if (header.iFileVersion == 2) { m_iWaypointCount = header.iWPCount; for (i=0; i < header.iWPCount; i++) { bfp->read(&from, sizeof(from)); // Read origin bfp->read(&flags, sizeof(flags)); // Read waypoint flags bfp->read(&triggernr, sizeof(triggernr)); // Read trigger nr bfp->read(&yaw, sizeof(yaw)); // Read target yaw node_s *pNode = new node_s(from, flags, triggernr, yaw); short x, y; GetNodeIndexes(pNode->v_origin, &x, &y); m_Waypoints[x][y].AddNode(pNode); BotManager.AddWaypoint(pNode); if ((BotManager.m_sCurrentTriggerNr == -1) || (triggernr < BotManager.m_sCurrentTriggerNr)) BotManager.m_sCurrentTriggerNr = triggernr; } for (i=0; i < header.iWPCount; i++) { // read the number of paths from this node... bfp->read(&num, sizeof(num)); bfp->read(&from, sizeof(from)); if (!num) continue; node_s *pCurrent = GetWaypointFromVec(from); if (!pCurrent) { conoutf("Error: NULL path in waypoint file"); for(j=0;jread(&to, sizeof(to)); // Read rest of block continue; } for (j=0; j < num; j++) { bfp->read(&to, sizeof(to)); node_s *p = GetWaypointFromVec(to); if (p) AddPath(pCurrent, p); } } } else if (header.iFileVersion > WAYPOINT_VERSION) { conoutf("Error: Waypoint file is newer then current, upgrade cube bot."); delete bfp; return false; } else { conoutf("Error: Unknown waypoint version for cube bot"); delete bfp; return false; } } else { conoutf("Waypoints aren't for map %s but for map %s", m_szMapName, header.szMapName); delete bfp; return false; } } else { conoutf("Waypoint file isn't for cube bot"); //conoutf("Header FileType: %s", int(header.szFileType)); delete bfp; return false; } delete bfp; //RouteInit(); } else { conoutf("Waypoint file %s does not exist", (filename)); return false; } if (BotManager.m_sCurrentTriggerNr == -1) BotManager.m_sCurrentTriggerNr = 0; ReCalcCosts(); conoutf("Waypoints for map %s loaded", (m_szMapName)); testx = m_Waypoints[1][1].pNodeList; return true; } void CWaypointClass::SaveWaypoints() { char filename[256]; char mapname[64]; waypoint_header_s header; short int num; TLinkedList::node_s *pPath; strcpy(header.szFileType, "cube_bot"); header.iFileVersion = WAYPOINT_VERSION; header.iFileFlags = 0; // not currently used header.iWPCount = m_iWaypointCount; memset(header.szMapName, 0, sizeof(header.szMapName)); strncpy(header.szMapName, m_szMapName, sizeof(header.szMapName)-1); header.szMapName[sizeof(header.szMapName)-1] = 0; strcpy(mapname, m_szMapName); strcat(mapname, ".wpt"); BotManager.MakeBotFileName(mapname, "waypoints", NULL, filename); stream *bfp = openfile(filename, "wb"); if (!bfp) { conoutf("Error writing waypoint file, check if the directory \"bot/waypoint\" exists and " "the right permissions are set"); return; } // write the waypoint header to the file... bfp->write(&header, sizeof(header)); // write the waypoint data to the file... loopi(MAX_MAP_GRIDS) { loopj(MAX_MAP_GRIDS) { TLinkedList::node_s *p = m_Waypoints[i][j].GetFirst(); while(p) { bfp->write(&p->Entry->v_origin, sizeof(p->Entry->v_origin)); // Write origin bfp->write(&p->Entry->iFlags, sizeof(p->Entry->iFlags)); // Write waypoint flags bfp->write(&p->Entry->sTriggerNr, sizeof(p->Entry->sTriggerNr)); // Write trigger nr bfp->write(&p->Entry->sYaw, sizeof(p->Entry->sYaw)); // Write target yaw p = p->next; } } } loopi(MAX_MAP_GRIDS) { loopj(MAX_MAP_GRIDS) { TLinkedList::node_s *p = m_Waypoints[i][j].GetFirst(); while(p) { // save the waypoint paths... // count the number of paths from this node... pPath = p->Entry->ConnectedWPs.GetFirst(); num = p->Entry->ConnectedWPs.NodeCount(); bfp->write(&num, sizeof(num)); // write the count bfp->write(&p->Entry->v_origin, sizeof(p->Entry->v_origin)); // write the origin of this path // now write out each path... while (pPath != NULL) { bfp->write(&pPath->Entry->v_origin, sizeof(pPath->Entry->v_origin)); pPath = pPath->next; // go to next node in linked list } p = p->next; } } } delete bfp; } bool CWaypointClass::LoadWPExpFile() { FILE *bfp; char szWPFileName[64]; char filename[256]; waypoint_header_s header; short int num; int i, j; vec from, to; if (m_iWaypointCount == 0) return false; strcpy(szWPFileName, m_szMapName); strcat(szWPFileName, ".exp"); BotManager.MakeBotFileName(szWPFileName, "waypoints", NULL, filename); bfp = fopen(filename, "rb"); // if file exists, read the waypoint structure from it if (bfp != NULL) { fread(&header, sizeof(header), 1, bfp); header.szFileType[sizeof(header.szFileType)-1] = 0; if (strcmp(header.szFileType, "cube_bot") == 0) { header.szMapName[sizeof(header.szMapName)-1] = 0; if (strcmp(header.szMapName, m_szMapName) == 0) { // Check which waypoint file version this is, handle each of them different if (header.iFileVersion == 1) { for (i=0; i < header.iWPCount; i++) { // read the number of paths from this node... fread(&num, sizeof(num), 1, bfp); fread(&from, sizeof(vec), 1, bfp); if (!num) continue; node_s *pCurrent = GetWaypointFromVec(from); if (!pCurrent) { conoutf("Error: NULL node in waypoint experience file"); continue; } for (j=0; j < num; j++) { fread(&to, sizeof(vec), 1, bfp); node_s *p = GetWaypointFromVec(to); if (p) { pCurrent->FailedGoalList.AddNode(p); } } } } else if (header.iFileVersion > EXP_WP_VERSION) { conoutf("Error: Waypoint experience file is newer then current, upgrade cube bot."); fclose(bfp); return false; } else { conoutf("Error: Unknown waypoint experience file version for cube bot"); fclose(bfp); return false; } } else { conoutf("Waypoint experience file isn't for map %s but for map %s", (m_szMapName), (header.szMapName)); fclose(bfp); return false; } } else { conoutf("Waypoint experience file isn't for cube bot"); //conoutf("Header FileType: %s", int(header.szFileType)); fclose(bfp); return false; } fclose(bfp); //RouteInit(); } else { conoutf("Waypoint experience file %s does not exist", (filename)); return false; } conoutf("Waypoint experience file for map %s loaded", (m_szMapName)); return true; } void CWaypointClass::SaveWPExpFile() { if (!m_iWaypointCount) return; char filename[256]; char mapname[64]; waypoint_header_s header; short int num; strcpy(header.szFileType, "cube_bot"); header.iFileVersion = EXP_WP_VERSION; header.iFileFlags = 0; // not currently used header.iWPCount = m_iWaypointCount; memset(header.szMapName, 0, sizeof(header.szMapName)); strncpy(header.szMapName, m_szMapName, 31); header.szMapName[31] = 0; strcpy(mapname, m_szMapName); strcat(mapname, ".exp"); BotManager.MakeBotFileName(mapname, "waypoints", NULL, filename); FILE *bfp = fopen(filename, "wb"); if (!bfp) { conoutf("Error writing waypoint experience file, check if the directory \"bot/waypoint\" exists and " "the right permissions are set"); return; } // write the waypoint header to the file... fwrite(&header, sizeof(header), 1, bfp); // save the waypoint experience data... loopi(MAX_MAP_GRIDS) { loopj(MAX_MAP_GRIDS) { TLinkedList::node_s *p = m_Waypoints[i][j].GetFirst(); while(p) { // count the number of paths from this node... TLinkedList::node_s *p2 = p->Entry->FailedGoalList.GetFirst(); num = p->Entry->FailedGoalList.NodeCount(); if (!num || !p2) continue; fwrite(&num, sizeof(num), 1, bfp); // write the count fwrite(&p->Entry->v_origin, sizeof(vec), 1, bfp); // write the origin of this node while (p2 != NULL) { // Write out the node which a bot can't reach with the current node fwrite(&p2->Entry->v_origin, sizeof(vec), 1, bfp); p2 = p2->next; // go to next node in linked list } p = p->next; } } } fclose(bfp); } void CWaypointClass::Think() { #ifdef WP_FLOOD FloodThink(); #endif if (m_bAutoWaypoint) // is auto waypoint on? { // find the distance from the last used waypoint float flDistance = GetDistance(m_vLastCreatedWP, player1->o); bool NoLastCreatedWP = ((m_vLastCreatedWP.x == 0) && (m_vLastCreatedWP.y == 0) && (m_vLastCreatedWP.z == 0)); if ((flDistance > 3.0f) || NoLastCreatedWP) { // check that no other reachable waypoints are nearby... if (!GetNearestWaypoint(player1, 10.0f)) { AddWaypoint(player1->o, true); // place a waypoint here } } } // Draw info for nearest waypoint? if (m_bDrawWPText) { node_s *nearestwp = GetNearestWaypoint(player1, 20.0f); #ifdef WP_FLOOD if (!nearestwp) nearestwp = GetNearestFloodWP(player1, 10.0f); #endif if (nearestwp) { char szWPInfo[256]; sprintf(szWPInfo, "Distance nearest waypoint: %f", GetDistance(player1->o, nearestwp->v_origin)); AddScreenText(szWPInfo); strcpy(szWPInfo, "Flags: "); if (nearestwp->iFlags & W_FL_TELEPORT) strcat(szWPInfo, "Teleport "); if (nearestwp->iFlags & W_FL_TELEPORTDEST) strcat(szWPInfo, "Teleport destination "); if (nearestwp->iFlags & W_FL_JUMP) strcat(szWPInfo, "Jump "); if (nearestwp->iFlags & W_FL_TRIGGER) { char sz[32]; sprintf(sz, "Trigger(nr %d) ", nearestwp->sTriggerNr); strcat(szWPInfo, sz); } if (nearestwp->iFlags & W_FL_INTAG) strcat(szWPInfo, "In tagged cube(s) "); if (strlen(szWPInfo) == 7) strcat(szWPInfo, "None"); AddScreenText(szWPInfo); if (nearestwp->sYaw != -1) AddScreenText("yaw %d", nearestwp->sYaw); sprintf(szWPInfo, "Waypoint has %d connections", nearestwp->ConnectedWPs.NodeCount()); AddScreenText(szWPInfo); AddScreenText("Base Cost: %d", nearestwp->sCost); } } if (m_bDrawWaypoints) // display the waypoints if turned on... { DrawNearWaypoints(); } } void CWaypointClass::DrawNearWaypoints() { glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glDisable(GL_CULL_FACE); TLinkedList::node_s *pNode; node_s *pNearest = NULL; short i, j, MinI, MaxI, MinJ, MaxJ, Offset = (short)ceilf(15.0f / MAX_MAP_GRIDS); float flNearestDist = 9999.99f, flDist; GetNodeIndexes(player1->o, &i, &j); MinI = i - Offset; MaxI = i + Offset; MinJ = j - Offset; MaxJ = j + Offset; if (MinI < 0) MinI = 0; if (MaxI > MAX_MAP_GRIDS - 1) MaxI = MAX_MAP_GRIDS - 1; if (MinJ < 0) MinJ = 0; if (MaxJ > MAX_MAP_GRIDS - 1) MaxJ = MAX_MAP_GRIDS - 1; node_s *nearestwp = WaypointClass.GetNearestWaypoint(curselection, 20.0f); #ifdef WP_FLOOD if (!nearestwp) nearestwp = GetNearestFloodWP(player1, 20.0f); #endif for (int x=MinI;x<=MaxI;x++) { for(int y=MinJ;y<=MaxJ;y++) { pNode = m_Waypoints[x][y].GetFirst(); while(pNode) { flDist = GetDistance(worldpos, pNode->Entry->v_origin); if (flDist <= 15) { vec o = pNode->Entry->v_origin; vec e = o; o.z -= 2; e.z += 2; if (pNode->Entry->iFlags & W_FL_JUMP) { // draw a red waypoint linestyle(2.5f, 0xFF, 0x40, 0x40); } else if (nearestwp == pNode->Entry) { // draw a green waypoint linestyle(2.5f, 0x40, 0xFF, 0x40); } else { // draw a blue waypoint linestyle(2.5f, 0x40, 0x40, 0xFF); } line(int(o.x), int(o.y), int(o.z), int(e.x), int(e.y), int(e.z)); if (flNearestDist > flDist) { flNearestDist = flDist; pNearest = pNode->Entry; } } pNode = pNode->next; } } } if (pNearest) { pNode = pNearest->ConnectedWPs.GetFirst(); linestyle(2.0f, 0xFF, 0xFF, 0xFF); while(pNode) { vec o = pNode->Entry->v_origin; vec e = pNearest->v_origin; line(int(o.x), int(o.y), int(o.z), int(e.x), int(e.y), int(e.z)); pNode = pNode->next; } // Has this waypoint an target yaw? if (pNearest->sYaw != -1) { vec angles(0, pNearest->sYaw, 0); vec from = pNearest->v_origin, end = pNearest->v_origin; vec forward, right, up; from.z = end.z = (pNearest->v_origin.z-1.0f); AnglesToVectors(angles, forward, right, up); forward.mul(5.0f); end.add(forward); linestyle(2.0f, 0xFF, 0x40, 0x40); line(int(from.x), int(from.y), int(from.z), int(end.x), int(end.y), int(end.z)); } } #ifndef RELEASE_BUILD // check if path waypointing is on... if (m_bDrawWPPaths) { // Draw path from first bot if (bots.length() && bots[0] && bots[0]->pBot && bots[0]->pBot->m_pCurrentWaypoint && bots[0]->pBot->m_pCurrentGoalWaypoint) { CBot *pB = bots[0]->pBot; if (!pB->m_bCalculatingAStarPath && !pB->m_AStarNodeList.Empty()) { TLinkedList::node_s *pNode = pB->m_AStarNodeList.GetFirst(), *pNext; linestyle(2.5f, 0xFF, 0x40, 0x40); line((int)pB->m_pCurrentWaypoint->pNode->v_origin.x, (int)pB->m_pCurrentWaypoint->pNode->v_origin.y, (int)pB->m_pCurrentWaypoint->pNode->v_origin.z, (int)pNode->Entry->pNode->v_origin.x, (int)pNode->Entry->pNode->v_origin.y, (int)pNode->Entry->pNode->v_origin.z); while(pNode && pNode->next) { pNext = pNode->next; vec &v1 = pNode->Entry->pNode->v_origin; vec &v2 = pNext->Entry->pNode->v_origin; line(int(v1.x), int(v1.y), int(v1.z), int(v2.x), int(v2.y), int(v2.z)); pNode = pNode->next; } } } } #endif glEnable(GL_CULL_FACE); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } // Add waypoint at location o, returns pointer of created wp node_s *CWaypointClass::AddWaypoint(vec o, bool connectwp) { short x, y; int flags = 0; if (S((int)o.x, (int)o.y)->tag) flags |= W_FL_INTAG; node_s *pNode = new node_s(o, flags, 0); m_vLastCreatedWP = o; GetNodeIndexes(o, &x, &y); m_Waypoints[x][y].AddNode(pNode); BotManager.AddWaypoint(pNode); m_iWaypointCount++; if (connectwp && m_bAutoPlacePaths) { // Connect new waypoint with other near waypoints. loopi(MAX_MAP_GRIDS) { loopj(MAX_MAP_GRIDS) { TLinkedList::node_s *p = m_Waypoints[i][j].GetFirst(); while(p) { if (p->Entry == pNode) { p = p->next; continue; // skip the waypoint that was just added } // check if the waypoint is reachable from the new one (one-way) if (WPIsReachable(o, p->Entry->v_origin)) AddPath(pNode, p->Entry); // Add a path from a to b if (WPIsReachable(p->Entry->v_origin, pNode->v_origin)) AddPath(p->Entry, pNode); // Add a path from b to a p = p->next; } } } } return pNode; } void CWaypointClass::DeleteWaypoint(vec v_src) { node_s *pWP; pWP = GetNearestWaypoint(v_src, 7.0f); if (!pWP) { conoutf("Error: Couldn't find near waypoint"); return; } BotManager.DelWaypoint(pWP); // delete any paths that lead to this index... DeletePath(pWP); short x, y; GetNodeIndexes(pWP->v_origin, &x, &y); m_Waypoints[x][y].DeleteEntry(pWP); pWP->ConnectedWPs.DeleteAllNodes(); pWP->ConnectedWPsWithMe.DeleteAllNodes(); m_iWaypointCount--; delete pWP; } void CWaypointClass::AddPath(node_s *pWP1, node_s *pWP2) { pWP1->ConnectedWPs.AddNode(pWP2); pWP2->ConnectedWPsWithMe.AddNode(pWP1); } // Deletes all paths connected to the given waypoint void CWaypointClass::DeletePath(node_s *pWP) { TLinkedList::node_s *p; loopi(MAX_MAP_GRIDS) { loopj(MAX_MAP_GRIDS) { p = m_Waypoints[i][j].GetFirst(); while (p) { p->Entry->ConnectedWPs.DeleteEntry(pWP); pWP->ConnectedWPsWithMe.DeleteEntry(p->Entry); p = p->next; } } } } // Deletes path between 2 waypoints(1 way) void CWaypointClass::DeletePath(node_s *pWP1, node_s *pWP2) { pWP1->ConnectedWPs.DeleteEntry(pWP2); pWP2->ConnectedWPsWithMe.DeleteEntry(pWP1); } void CWaypointClass::ManuallyCreatePath(vec v_src, int iCmd, bool TwoWay) { static node_s *waypoint1 = NULL; // initialized to unassigned static node_s *waypoint2 = NULL; // initialized to unassigned if (iCmd == 1) // assign source of path { waypoint1 = GetNearestWaypoint(v_src, 7.0f); if (!waypoint1) { conoutf("Error: Couldn't find near waypoint"); return; } return; } if (iCmd == 2) // assign dest of path and make path { if (!waypoint1) { conoutf("Error: First waypoint unset"); return; } waypoint2 = GetNearestWaypoint(v_src, 7.0f); if (!waypoint2) { conoutf("Error: Couldn't find near waypoint"); return; } AddPath(waypoint1, waypoint2); if (TwoWay) AddPath(waypoint2, waypoint1); } } void CWaypointClass::ManuallyDeletePath(vec v_src, int iCmd, bool TwoWay) { static node_s *waypoint1 = NULL; // initialized to unassigned static node_s *waypoint2 = NULL; // initialized to unassigned if (iCmd == 1) // assign source of path { waypoint1 = GetNearestWaypoint(v_src, 7.0f); if (!waypoint1) { conoutf("Error: Couldn't find near waypoint"); return; } return; } if (iCmd == 2) // assign dest of path and delete path { if (!waypoint1) { conoutf("Error: First waypoint unset"); return; } waypoint2 = GetNearestWaypoint(v_src, 7.0f); if (!waypoint2) { conoutf("Error: Couldn't find near waypoint"); return; } DeletePath(waypoint1, waypoint2); if (TwoWay) DeletePath(waypoint2, waypoint1); } } bool CWaypointClass::WPIsReachable(vec from, vec to) { traceresult_s tr; float curr_height, last_height; float distance = GetDistance(from, to); // is the destination close enough? if (distance < REACHABLE_RANGE) { if (IsVisible(from, to)) { if (UnderWater(from) && UnderWater(to)) { // No need to worry about heights in water return true; } /* if (to.z > (from.z + JUMP_HEIGHT)) { vec v_new_src = to; vec v_new_dest = to; v_new_dest.z = v_new_dest.z - (JUMP_HEIGHT + 1.0f); // check if we didn't hit anything, if so then it's in mid-air if (::IsVisible(v_new_src, v_new_dest, NULL)) { conoutf("to is in midair"); debugbeam(from, to); return false; // can't reach this one } } */ // check if distance to ground increases more than jump height // at points between from and to... vec v_temp = to; v_temp.sub(from); vec v_direction = Normalize(v_temp); // 1 unit long vec v_check = from; vec v_down = from; v_down.z = v_down.z - 100.0f; // straight down TraceLine(v_check, v_down, NULL, false, &tr); // height from ground last_height = GetDistance(v_check, tr.end); distance = GetDistance(to, v_check); // distance from goal while (distance > 2.0f) { // move 2 units closer to the goal v_temp = v_direction; v_temp.mul(2.0f); v_check.add(v_temp); v_down = v_check; v_down.z = v_down.z - 100.0f; TraceLine(v_check, v_down, NULL, false, &tr); curr_height = GetDistance(v_check, tr.end); // is the difference in the last height and the current height // higher that the jump height? if ((last_height - curr_height) >= JUMP_HEIGHT) { // can't get there from here... //conoutf("traces failed to to"); return false; } last_height = curr_height; distance = GetDistance(to, v_check); // distance from goal } return true; } } return false; } node_s *CWaypointClass::GetNearestWaypoint(vec v_src, float flRange) { TLinkedList::node_s *pNode; node_s *pNearest = NULL; short i, j, MinI, MaxI, MinJ, MaxJ, Offset = (short)ceil(flRange / MAX_MAP_GRIDS); float flNearestDist = 9999.99f, flDist; GetNodeIndexes(v_src, &i, &j); MinI = i - Offset; MaxI = i + Offset; MinJ = j - Offset; MaxJ = j + Offset; if (MinI < 0) MinI = 0; if (MaxI > MAX_MAP_GRIDS - 1) MaxI = MAX_MAP_GRIDS - 1; if (MinJ < 0) MinJ = 0; if (MaxJ > MAX_MAP_GRIDS - 1) MaxJ = MAX_MAP_GRIDS - 1; for (int x=MinI;x<=MaxI;x++) { for(int y=MinJ;y<=MaxJ;y++) { pNode = m_Waypoints[x][y].GetFirst(); while(pNode) { flDist = GetDistance(v_src, pNode->Entry->v_origin); if ((flDist < flNearestDist) && (flDist <= flRange)) { if (IsVisible(v_src, pNode->Entry->v_origin, NULL)) { pNearest = pNode->Entry; flNearestDist = flDist; } } pNode = pNode->next; } } } return pNearest; } node_s *CWaypointClass::GetNearestTriggerWaypoint(vec v_src, float flRange) { TLinkedList::node_s *pNode; node_s *pNearest = NULL; short i, j, MinI, MaxI, MinJ, MaxJ, Offset = (short)ceil(flRange / MAX_MAP_GRIDS); float flNearestDist = 9999.99f, flDist; GetNodeIndexes(v_src, &i, &j); MinI = i - Offset; MaxI = i + Offset; MinJ = j - Offset; MaxJ = j + Offset; if (MinI < 0) MinI = 0; if (MaxI > MAX_MAP_GRIDS - 1) MaxI = MAX_MAP_GRIDS - 1; if (MinJ < 0) MinJ = 0; if (MaxJ > MAX_MAP_GRIDS - 1) MaxJ = MAX_MAP_GRIDS - 1; for (int x=MinI;x<=MaxI;x++) { for(int y=MinJ;y<=MaxJ;y++) { pNode = m_Waypoints[x][y].GetFirst(); while(pNode) { if ((pNode->Entry->iFlags & W_FL_FLOOD) || !(pNode->Entry->iFlags & W_FL_TRIGGER)) { pNode = pNode->next; continue; } flDist = GetDistance(v_src, pNode->Entry->v_origin); if ((flDist < flNearestDist) && (flDist <= flRange)) { if (IsVisible(v_src, pNode->Entry->v_origin, NULL)) { pNearest = pNode->Entry; flNearestDist = flDist; } } pNode = pNode->next; } } } return pNearest; } node_s *CWaypointClass::GetWaypointFromVec(const vec &v_src) { static TLinkedList::node_s *pNode; static short x, y; GetNodeIndexes(v_src, &x, &y); pNode = m_Waypoints[x][y].GetFirst(); while(pNode) { if (pNode->Entry->v_origin==v_src) return pNode->Entry; pNode = pNode->next; } return NULL; } void CWaypointClass::CalcCost(node_s *pNode) { float flCost = 10.0f; // Check nearby cubes... int x = int(pNode->v_origin.x); int y = int(pNode->v_origin.y); int a, b, row; for (row=0;row<=1;row++) { if (row==0) b = y - 6; else b = y + 6; for (a=(x-6);a<=(x+6);a++) { if (OUTBORD(a, b)) continue; vec to(a, b, GetCubeFloor(a, b) + 1.0f); // See if there is a obstacle(cube or mapmodel) nearby traceresult_s tr; TraceLine(pNode->v_origin, to, NULL, false, &tr); if (tr.collided) { float flFraction = (GetDistance(pNode->v_origin, tr.end) / GetDistance(pNode->v_origin, to)); flCost += (1.0f-flFraction)*0.5f; } if ((iabs(a) > 4) || (iabs(b) > 4)) continue; vec from = to; to.z -= (JUMP_HEIGHT - 1.0f); TraceLine(from, to, NULL, false, &tr); if (!tr.collided) flCost += 0.5f; } if (row==0) a = x - 6; else a = x + 6; for (b=(y-6);b<=(y+6);b++) { if (OUTBORD(a, b)) continue; vec to(a, b, GetCubeFloor(a, b) + 1.0f); // See if there is a obstacle(cube or mapmodel) nearby traceresult_s tr; TraceLine(pNode->v_origin, to, NULL, false, &tr); if (tr.collided) { float flFraction = (GetDistance(pNode->v_origin, tr.end) / GetDistance(pNode->v_origin, to)); flCost += (1.0f-flFraction)*0.5f; } if ((iabs(a) > 4) || (iabs(b) > 4)) continue; vec from = to; to.z -= (JUMP_HEIGHT - 1.0f); TraceLine(from, to, NULL, false, &tr); if (!tr.collided) flCost += 0.5f; } } if (UnderWater(pNode->v_origin)) // Water is annoying flCost += 5.0f; pNode->sCost = (short)flCost; } void CWaypointClass::ReCalcCosts(void) { loopi(MAX_MAP_GRIDS) { loopj(MAX_MAP_GRIDS) { TLinkedList::node_s *p = m_Waypoints[i][j].GetFirst(); while(p) { CalcCost(p->Entry); p = p->next; } } } } #ifdef WP_FLOOD void CWaypointClass::StartFlood() { if (m_bFlooding) return; conoutf("Starting flood, this may take a while on large maps...."); m_bFlooding = true; m_iFloodStartTime = SDL_GetTicks(); m_iCurFloodX = m_iCurFloodY = MINBORD; m_iFloodSize = 0; } void CWaypointClass::FloodThink() { if (!m_bFlooding) return; static int x, y, count; count = 0; if (!m_bFilteringNodes) { // loop through ALL cubes and check if we should add a waypoint here for (x=m_iCurFloodX; x<(ssize-MINBORD); x+=4) { if (count >= 3) { AddScreenText("Flooding map with waypoints... %.2f %%", ((float)x / float(ssize-MINBORD)) * 100.0f); m_iCurFloodX = x; return; } count++; for (y=MINBORD; y<(ssize-MINBORD); y+=4) { vec from(x, y, GetCubeFloor(x, y)+2.0f); bool bFound = CanPlaceNodeHere(from); if (!bFound) { for (int a=x-2;a<=(x+2);a++) { for (int b=y-2;b<=(y+2);b++) { if (OUTBORD(a, b)) continue; if ((a==x) && (b==y)) continue; makevec(&from, a, b, GetCubeFloor(a, b) + 2.0f); if (CanPlaceNodeHere(from)) { bFound = true; break; } } if (bFound) break; } } if (!bFound) continue; // Add WP int flags = W_FL_FLOOD; if (S((int)from.x, (int)from.y)->tag) flags |= W_FL_INTAG; node_s *pWP = new node_s(from, flags, 0); short i, j; GetNodeIndexes(from, &i, &j); m_Waypoints[i][j].PushNode(pWP); BotManager.AddWaypoint(pWP); m_iFloodSize += sizeof(node_s); m_iWaypointCount++; // Connect with other nearby nodes ConnectFloodWP(pWP); } } } if (!m_bFilteringNodes) { m_bFilteringNodes = true; m_iCurFloodX = m_iCurFloodY = 0; m_iFilteredNodes = 0; } count = 0; // Filter all nodes which aren't connected to any other nodes for (x=m_iCurFloodX;x 3) { AddScreenText("Filtering useless waypoints and"); AddScreenText("adding costs... %.2f %%", ((float)x / float(MAX_MAP_GRIDS)) * 100.0f); m_iCurFloodX = x; return; } count++; for (y=0;y::node_s *pNode = m_Waypoints[x][y].GetFirst(), *pTemp; while(pNode) { if (pNode->Entry->ConnectedWPs.Empty() || pNode->Entry->ConnectedWPsWithMe.Empty()) { BotManager.DelWaypoint(pNode->Entry); pTemp = pNode; pNode = pNode->next; delete pTemp->Entry; m_Waypoints[x][y].DeleteNode(pTemp); m_iFilteredNodes++; m_iFloodSize -= sizeof(node_s); m_iWaypointCount--; continue; } else CalcCost(pNode->Entry); pNode = pNode->next; } } } // Done with flooding m_bFlooding = false; m_bFilteringNodes = false; //ReCalcCosts(); BotManager.PickNextTrigger(); m_iFloodSize += sizeof(m_Waypoints); conoutf("Added %d wps in %d milliseconds", m_iWaypointCount, SDL_GetTicks()-m_iFloodStartTime); conoutf("Filtered %d wps", m_iFilteredNodes); BotManager.CalculateMaxAStarCount(); conoutf("Total size: %.2f Kb", float(m_iFloodSize)/1024.0f); } bool CWaypointClass::CanPlaceNodeHere(const vec &from) { static short x, y, a, b; static traceresult_s tr; static vec to, v1, v2; x = short(from.x); y = short(from.y); sqr *s = S(x, y); if (SOLID(s)) { return false; } if (fabs((float)(s->ceil - s->floor)) < player1->radius) { return false; } if (GetNearestFloodWP(from, 2.0f, NULL)) return false; for (a=(x-1);a<=(x+1);a++) { for (b=(y-1);b<=(y+1);b++) { if ((x==a) && (y==b)) continue; if (OUTBORD(a, b)) return false; makevec(&v1, a, b, from.z); v2 = v1; v2.z -= 1000.0f; TraceLine(v1, v2, NULL, false, &tr, true); to = tr.end; if ((a >= (x-1)) && (a <= (x+1)) && (b >= (y-1)) && (b <= (y+1))) { if (!tr.collided || (to.z < (from.z-4.0f))) { return false; } } to.z += 2.0f; if (from.z < (to.z-JUMP_HEIGHT)) { return false; } TraceLine(from, to, NULL, false, &tr, true); if (tr.collided) return false; } } return true; } void CWaypointClass::ConnectFloodWP(node_s *pWP) { if (!pWP) return; static float flRange; static TLinkedList::node_s *pNode; static short i, j, MinI, MaxI, MinJ, MaxJ, x, y, Offset; static float flDist; static node_s *p; // Calculate range, based on distance to nearest node p = GetNearestFloodWP(pWP->v_origin, 15.0f, pWP, true); if (p) { flDist = GetDistance(pWP->v_origin, p->v_origin); flRange = min(flDist+2.0f, 15.0f); if (flRange < 5.0f) flRange = 5.0f; } else return; Offset = (short)ceil(flRange / MAX_MAP_GRIDS); GetNodeIndexes(pWP->v_origin, &i, &j); MinI = i - Offset; MaxI = i + Offset; MinJ = j - Offset; MaxJ = j + Offset; if (MinI < 0) MinI = 0; if (MaxI > MAX_MAP_GRIDS - 1) MaxI = MAX_MAP_GRIDS - 1; if (MinJ < 0) MinJ = 0; if (MaxJ > MAX_MAP_GRIDS - 1) MaxJ = MAX_MAP_GRIDS - 1; for (x=MinI;x<=MaxI;x++) { for(y=MinJ;y<=MaxJ;y++) { pNode = m_Waypoints[x][y].GetFirst(); while(pNode) { if (pNode->Entry == pWP) { pNode = pNode->next; continue; } flDist = GetDistance(pWP->v_origin, pNode->Entry->v_origin); if (flDist <= flRange) { if (IsVisible(pWP->v_origin, pNode->Entry->v_origin, NULL, true)) { // Connect a with b pWP->ConnectedWPs.AddNode(pNode->Entry); pNode->Entry->ConnectedWPsWithMe.AddNode(pWP); // Connect b with a pNode->Entry->ConnectedWPs.AddNode(pWP); pWP->ConnectedWPsWithMe.AddNode(pNode->Entry); m_iFloodSize += (2 * sizeof(node_s *)); } } pNode = pNode->next; } } } } node_s *CWaypointClass::GetNearestFloodWP(vec v_origin, float flRange, node_s *pIgnore, bool SkipTags) { TLinkedList::node_s *p; node_s *pNearest = NULL; short i, j, MinI, MaxI, MinJ, MaxJ, Offset = (short)ceil(flRange / MAX_MAP_GRIDS); float flNearestDist = 9999.99f, flDist; GetNodeIndexes(v_origin, &i, &j); MinI = i - Offset; MaxI = i + Offset; MinJ = j - Offset; MaxJ = j + Offset; if (MinI < 0) MinI = 0; if (MaxI > MAX_MAP_GRIDS - 1) MaxI = MAX_MAP_GRIDS - 1; if (MinJ < 0) MinJ = 0; if (MaxJ > MAX_MAP_GRIDS - 1) MaxJ = MAX_MAP_GRIDS - 1; for (int x=MinI;x<=MaxI;x++) { for(int y=MinJ;y<=MaxJ;y++) { p = m_Waypoints[x][y].GetFirst(); while(p) { if ((p->Entry == pIgnore) || (!(p->Entry->iFlags & W_FL_FLOOD))) { p = p->next; continue; } flDist = GetDistance(v_origin, p->Entry->v_origin); if ((flDist < flNearestDist) && (flDist <= flRange)) { if (IsVisible(v_origin, p->Entry->v_origin, NULL, SkipTags)) { pNearest = p->Entry; flNearestDist = flDist; } } p = p->next; } } } return pNearest; } node_s *CWaypointClass::GetNearestTriggerFloodWP(vec v_origin, float flRange) { TLinkedList::node_s *p; node_s *pNearest = NULL; short i, j, MinI, MaxI, MinJ, MaxJ, Offset = (short)ceil(flRange / MAX_MAP_GRIDS); float flNearestDist = 9999.99f, flDist; GetNodeIndexes(v_origin, &i, &j); MinI = i - Offset; MaxI = i + Offset; MinJ = j - Offset; MaxJ = j + Offset; if (MinI < 0) MinI = 0; if (MaxI > MAX_MAP_GRIDS - 1) MaxI = MAX_MAP_GRIDS - 1; if (MinJ < 0) MinJ = 0; if (MaxJ > MAX_MAP_GRIDS - 1) MaxJ = MAX_MAP_GRIDS - 1; for (int x=MinI;x<=MaxI;x++) { for(int y=MinJ;y<=MaxJ;y++) { p = m_Waypoints[x][y].GetFirst(); while(p) { if (!(p->Entry->iFlags & (W_FL_FLOOD | W_FL_TRIGGER))) { p = p->next; continue; } flDist = GetDistance(v_origin, p->Entry->v_origin); if ((flDist < flNearestDist) && (flDist <= flRange)) { if (IsVisible(v_origin, p->Entry->v_origin, NULL)) { pNearest = p->Entry; flNearestDist = flDist; } } p = p->next; } } } return pNearest; } void CWaypointClass::GetNodeIndexes(const vec &v_origin, short *i, short *j) { // Function code by cheesy and PMB //*i = iabs((int)((int)(v_origin.x + (2*ssize)) / SECTOR_SIZE)); //*j = iabs((int)((int)(v_origin.y + (2*ssize)) / SECTOR_SIZE)); //*i = (int)((v_origin.x) / ssize * MAX_MAP_GRIDS); //*j = (int)((v_origin.y) / ssize * MAX_MAP_GRIDS); *i = iabs((int)((v_origin.x) / MAX_MAP_GRIDS)); *j = iabs((int)((v_origin.y) / MAX_MAP_GRIDS)); if (*i > MAX_MAP_GRIDS - 1) *i = MAX_MAP_GRIDS - 1; if (*j > MAX_MAP_GRIDS - 1) *j = MAX_MAP_GRIDS - 1; } #endif // WP_FLOOD // Waypoint class end // AC waypoint class begin void CACWaypointClass::StartFlood() { // UNDONE? CWaypointClass::StartFlood(); } // AC waypoint class end // Waypoint commands begin void addwp(int *autoconnect) { WaypointClass.SetWaypointsVisible(true); WaypointClass.AddWaypoint(curselection, *autoconnect!=0); } COMMAND(addwp, "i"); void delwp(void) { WaypointClass.SetWaypointsVisible(true); WaypointClass.DeleteWaypoint(curselection); } COMMAND(delwp, ""); void wpvisible(int *on) { WaypointClass.SetWaypointsVisible(*on!=0); } COMMAND(wpvisible, "i"); void wpsave(void) { WaypointClass.SaveWaypoints(); } COMMAND(wpsave, ""); void wpload(void) { WaypointClass.LoadWaypoints(); } COMMAND(wpload, ""); void wpclear(void) { WaypointClass.Clear(); } COMMAND(wpclear, ""); void autowp(int *on) { WaypointClass.SetWaypointsVisible(true); WaypointClass.SetAutoWaypoint(*on!=0); } COMMAND(autowp, "i"); void wpinfo(int *on) { WaypointClass.SetWaypointsVisible(true); WaypointClass.SetWPInfo(*on!=0); } COMMAND(wpinfo, "i"); void addpath1way1(void) { WaypointClass.SetWaypointsVisible(true); WaypointClass.ManuallyCreatePath(curselection, 1, false); } COMMAND(addpath1way1, ""); void addpath1way2(void) { WaypointClass.SetWaypointsVisible(true); WaypointClass.ManuallyCreatePath(curselection, 2, false); } COMMAND(addpath1way2, ""); void addpath2way1(void) { WaypointClass.SetWaypointsVisible(true); WaypointClass.ManuallyCreatePath(curselection, 1, true); } COMMAND(addpath2way1, ""); void addpath2way2(void) { WaypointClass.SetWaypointsVisible(true); WaypointClass.ManuallyCreatePath(curselection, 2, true); } COMMAND(addpath2way2, ""); void delpath1way1(void) { WaypointClass.SetWaypointsVisible(true); WaypointClass.ManuallyDeletePath(curselection, 1, false); } COMMAND(delpath1way1, ""); void delpath1way2(void) { WaypointClass.SetWaypointsVisible(true); WaypointClass.ManuallyDeletePath(curselection, 2, false); } COMMAND(delpath1way2, ""); void delpath2way1(void) { WaypointClass.SetWaypointsVisible(true); WaypointClass.ManuallyDeletePath(curselection, 1, true); } COMMAND(delpath2way1, ""); void delpath2way2(void) { WaypointClass.SetWaypointsVisible(true); WaypointClass.ManuallyDeletePath(curselection, 2, true); } COMMAND(delpath2way2, ""); void setjumpwp(void) { node_s *wp = WaypointClass.GetNearestWaypoint(curselection, 20.0f); if (wp) { WaypointClass.SetWPFlags(wp, W_FL_JUMP); } } COMMAND(setjumpwp, ""); void unsetjumpwp(void) { node_s *wp = WaypointClass.GetNearestWaypoint(curselection, 20.0f); if (wp) { WaypointClass.UnsetWPFlags(wp, W_FL_JUMP); } } COMMAND(unsetjumpwp, ""); void setwptriggernr(int *nr) { node_s *wp = WaypointClass.GetNearestWaypoint(curselection, 20.0f); if (wp) { WaypointClass.SetWPTriggerNr(wp, *nr); } } COMMAND(setwptriggernr, "i"); void setwpyaw(void) { node_s *wp = WaypointClass.GetNearestWaypoint(curselection, 20.0f); if (wp) { WaypointClass.SetWPYaw(wp, short(player1->yaw)); } } COMMAND(setwpyaw, ""); #ifdef WP_FLOOD void wpflood(void) { WaypointClass.StartFlood(); } COMMAND(wpflood, ""); #endif // Debug functions #ifdef WP_FLOOD #ifndef RELEASE_BUILD void botsheadtome(void) { loopv(bots) { if (!bots[i] || !bots[i]->pBot) continue; bots[i]->pBot->HeadToGoal(); bots[i]->pBot->GoToDebugGoal(player1->o); } } COMMAND(botsheadtome, ""); void setdebuggoal(void) { v_debuggoal = player1->o; }; COMMAND(setdebuggoal, ""); void botsheadtodebuggoal(void) { loopv(bots) { if (!bots[i] || !bots[i]->pBot) continue; bots[i]->pBot->GoToDebugGoal(v_debuggoal); } } COMMAND(botsheadtodebuggoal, ""); #endif // RELEASE_BUILD #endif // WP_FLOOD // End debug functions // Waypoint commands end // Bot class begin bool CBot::FindWaypoint() { waypoint_s *wp, *wpselect; int index; float distance, min_distance[3]; waypoint_s *min_wp[3]; for (index=0; index < 3; index++) { min_distance[index] = 9999.0; min_wp[index] = NULL; } TLinkedList::node_s *pNode = m_pCurrentWaypoint->pNode->ConnectedWPs.GetFirst(); while (pNode) { if ((pNode->Entry->iFlags & W_FL_INTAG) && SOLID(S((int)pNode->Entry->v_origin.x, (int)pNode->Entry->v_origin.y))) { pNode = pNode->next; continue; } wp = GetWPFromNode(pNode->Entry); if (!wp) { pNode = pNode->next; continue; } // if index is not a current or recent previous waypoint... if ((wp != m_pCurrentWaypoint) && (wp != m_pPrevWaypoints[0]) && (wp != m_pPrevWaypoints[1]) && (wp != m_pPrevWaypoints[2]) && (wp != m_pPrevWaypoints[3]) && (wp != m_pPrevWaypoints[4])) { // find the distance from the bot to this waypoint distance = GetDistance(wp->pNode->v_origin); if (distance < min_distance[0]) { min_distance[2] = min_distance[1]; min_wp[2] = min_wp[1]; min_distance[1] = min_distance[0]; min_wp[1] = min_wp[0]; min_distance[0] = distance; min_wp[0] = wp; } else if (distance < min_distance [1]) { min_distance[2] = min_distance[1]; min_wp[2] = min_wp[1]; min_distance[1] = distance; min_wp[1] = wp; } else if (distance < min_distance[2]) { min_distance[2] = distance; min_wp[2] = wp; } } pNode = pNode->next; } wpselect = NULL; // about 20% of the time choose a waypoint at random // (don't do this any more often than every 10 seconds) if ((RandomLong(1, 100) <= 20) && (m_iRandomWaypointTime <= lastmillis)) { m_iRandomWaypointTime = lastmillis + 10000; if (min_wp[2]) index = RandomLong(0, 2); else if (min_wp[1]) index = RandomLong(0, 1); else if (min_wp[0]) index = 0; else return false; // no waypoints found! wpselect = min_wp[index]; } else { // use the closest waypoint that has been recently used wpselect = min_wp[0]; } if (wpselect) // was a waypoint found? { m_pPrevWaypoints[4] = m_pPrevWaypoints[3]; m_pPrevWaypoints[3] = m_pPrevWaypoints[2]; m_pPrevWaypoints[2] = m_pPrevWaypoints[1]; m_pPrevWaypoints[1] = m_pPrevWaypoints[0]; m_pPrevWaypoints[0] = m_pCurrentWaypoint; SetCurrentWaypoint(wpselect); return true; } return false; // couldn't find a waypoint } bool CBot::HeadToWaypoint() { if (!m_pCurrentWaypoint) return false; // Can't head to waypoint bool Touching = false; float WPDist = GetDistance(m_pCurrentWaypoint->pNode->v_origin); #ifndef RELEASE_BUILD if (m_pCurrentGoalWaypoint && m_vGoal==g_vecZero) condebug("Warning: m_vGoal unset"); #endif // did the bot run past the waypoint? (prevent the loop-the-loop problem) if ((m_fPrevWaypointDistance > 1.0) && (WPDist > m_fPrevWaypointDistance) && (WPDist <= 5.0f)) Touching = true; // bot needs to be close for jump and trigger waypoints else if ((m_pCurrentWaypoint->pNode->iFlags & W_FL_JUMP) || (m_pCurrentWaypoint->pNode->iFlags & W_FL_TRIGGER)) Touching = (WPDist <= 1.5f); else if (m_pCurrentWaypoint->pNode->iFlags & W_FL_TELEPORT) Touching = (WPDist <= 4.0f); // are we close enough to a target waypoint... else if (WPDist <= 3.0f) { if (!m_pCurrentGoalWaypoint || (m_pCurrentWaypoint != m_pCurrentGoalWaypoint) || IsVisible(m_vGoal) || (WPDist <= 1.5f)) Touching = true; // If the bot has a goal check if he can see his next wp if (m_pCurrentGoalWaypoint && (m_pCurrentGoalWaypoint != m_pCurrentWaypoint) && !m_AStarNodeList.Empty() && (WPDist >= 1.0f) && !IsVisible(m_AStarNodeList.GetFirst()->Entry->pNode->v_origin)) Touching = false; } // save current distance as previous m_fPrevWaypointDistance = WPDist; // Reached the waypoint? if (Touching) { // Does this waypoint has a targetyaw? if (m_pCurrentWaypoint->pNode->sYaw != -1) { // UNDONE: Inhuman m_pMyEnt->yaw = m_pMyEnt->targetyaw = m_pCurrentWaypoint->pNode->sYaw; } // Reached a jump waypoint? if (m_pCurrentWaypoint->pNode->iFlags & W_FL_JUMP) m_pMyEnt->jumpnext = true; m_fPrevWaypointDistance = 0.0f; // Does the bot has a goal? if (m_pCurrentGoalWaypoint) { if (m_pCurrentWaypoint != m_pCurrentGoalWaypoint) { if (m_AStarNodeList.Empty()) { if (!AStar()) { // Bot is calculating a new path, just stand still for now ResetMoveSpeed(); m_iWaypointTime += 200; return true; } else { if (m_AStarNodeList.Empty()) { //m_UnreachableNodes.PushNode(unreachable_node_s(m_pCurrentGoalWaypoint, gpGlobals->time)); return false; // Couldn't get a new wp to go to } } } m_pCurrentWaypoint = m_AStarNodeList.Pop(); if (!IsVisible(m_pCurrentWaypoint->pNode->v_origin)) //(!(m_pCurrentWaypoint->iFlags & W_FL_TELEPORT))) { //m_UnreachableNodes.PushNode(unreachable_node_s(m_pCurrentGoalWaypoint, gpGlobals->time)); condebug("Next WP not visible"); return false; } SetCurrentWaypoint(m_pCurrentWaypoint); } else { // Bot reached the goal waypoint but couldn't reach the goal itself // (otherwise we wouldn't be in this function) //m_UnreachableNodes.PushNode(unreachable_node_s(m_pCurrentGoalWaypoint, gpGlobals->time)); return false; } } else { short index = 4; bool status; // try to find the next waypoint while (((status = FindWaypoint()) == false) && (index > 0)) { // if waypoint not found, clear oldest previous index and try again m_pPrevWaypoints[index] = NULL; index--; } if (status == false) { ResetWaypointVars(); condebug("Couldn't find new random waypoint"); return false; } } m_iWaypointHeadPauseTime = lastmillis + 75; m_iWaypointTime += 75; } // keep turning towards the waypoint... /*if (m_pCurrentWaypoint->pNode->iFlags & W_FL_FLOOD) {UNDONE? vec aim = m_pCurrentWaypoint->pNode->v_origin; aim.x+=0.5f; aim.y+=0.5f; AimToVec(aim); } else*/ AimToVec(m_pCurrentWaypoint->pNode->v_origin); if (m_fYawToTurn <= 25.0f) m_iWaypointHeadLastTurnLessTime = lastmillis; // Bot had to turn much for a while? if ((m_iWaypointHeadLastTurnLessTime > 0) && (m_iWaypointHeadLastTurnLessTime < (lastmillis - 1000))) { m_iWaypointHeadPauseTime = lastmillis + 200; m_iWaypointTime += 200; } if (m_iWaypointHeadPauseTime >= lastmillis) { m_pMyEnt->move = 0; //conoutf("Pause in HeadToWaypoint()"); } else { // Check if bot has to jump vec from = m_pMyEnt->o; from.z -= (m_pMyEnt->eyeheight - 1.25f); float flEndDist; if (!IsVisible(from, FORWARD, 3.0f, false, &flEndDist) && (GetDistance(from, m_pCurrentWaypoint->pNode->v_origin) > flEndDist)) { m_pMyEnt->jumpnext = true; condebug("Low wall in HeadToWaypoint()"); } // Check if bot has to strafe if (m_iStrafeTime > lastmillis) SetMoveDir(m_iMoveDir, true); else { m_iStrafeTime = 0; m_iMoveDir = DIR_NONE; vec forward, up, right; AnglesToVectors(GetViewAngles(), forward, right, up); float flLeftDist = -1.0f, flRightDist = -1.0f; vec dir = right; bool bStrafe = false; int iStrafeDir = 0; dir.mul(m_pMyEnt->radius); // Check left from = m_pMyEnt->o; from.sub(dir); if (IsVisible(from, FORWARD, 3.0f, false, &flLeftDist)) flLeftDist = -1.0f; // Check right from = m_pMyEnt->o; from.add(dir); if (IsVisible(from, FORWARD, 3.0f, false, &flRightDist)) flRightDist = -1.0f; if ((flLeftDist != -1.0f) && (flRightDist != -1.0f)) { if (flLeftDist < flRightDist) { // Strafe right bStrafe = true; iStrafeDir = RIGHT; } else if (flRightDist < flLeftDist) { // Strafe left bStrafe = true; iStrafeDir = LEFT; } else { // Randomly choose a strafe direction bStrafe = true; if (RandomLong(0, 1)) iStrafeDir = LEFT; else iStrafeDir = RIGHT; } } else if (flLeftDist != -1.0f) { // Strafe right bStrafe = true; iStrafeDir = RIGHT; } else if (flRightDist != -1.0f) { // Strafe left bStrafe = true; iStrafeDir = LEFT; } if (bStrafe) { SetMoveDir(iStrafeDir, true); m_iMoveDir = iStrafeDir; m_iStrafeTime = lastmillis + RandomLong(30, 50); } } } return true; } // returns true when done or failure bool CBot::HeadToGoal() { // Does the bot has a goal(waypoint)? if (m_pCurrentGoalWaypoint) { if (ReachedGoalWP()) { return false; } else { if (CurrentWPIsValid()) { if (m_bCalculatingAStarPath) { // Bot is calculating a new path, just stand still for now ResetMoveSpeed(); m_iWaypointTime += 200; // Done calculating the path? if (AStar()) { if (m_AStarNodeList.Empty()) { return false; // Couldn't find a path } //else // SetCurrentWaypoint(m_AStarNodeList.Pop()); } else return true; // else just wait a little bit longer } //ResetMoveSpeed(); //return true; } else { // Current waypoint isn't reachable, search new one waypoint_s *pWP = NULL; #ifdef WP_FLOOD if (m_pCurrentGoalWaypoint->pNode->iFlags & W_FL_FLOOD) pWP = GetNearestFloodWP(8.0f); else #endif pWP = GetNearestWaypoint(15.0f); if (!pWP || (pWP == m_pCurrentWaypoint)) return false; SetCurrentWaypoint(pWP); if (AStar()) { if (m_AStarNodeList.Empty()) return false; } else { m_iWaypointTime += 200; ResetMoveSpeed(); return true; } } //debugbeam(m_pMyEnt->o, m_pCurrentWaypoint->pNode->v_origin); } } else return false; return HeadToWaypoint(); } // return true when done calculating bool CBot::AStar() { if (!m_pCurrentGoalWaypoint || !m_pCurrentWaypoint) { if (m_bCalculatingAStarPath) { m_bCalculatingAStarPath = false; BotManager.m_sUsingAStarBotsCount--; } return true; } // Ideas by PMB : // * Make locals static to speed up a bit // * MaxCycles per frame and make it fps dependent static int iMaxCycles; static int iCurrentCycles; static short newg; static waypoint_s *n, *n2; static TLinkedList::node_s *pPath = NULL; static bool bPathFailed; iMaxCycles = BotManager.m_iFrameTime / 10; if (iMaxCycles < 10) iMaxCycles = 10; //condebug("MaxCycles: %d", iMaxCycles); iCurrentCycles = 0; bPathFailed = false; if (!m_bCalculatingAStarPath) { if ((BotManager.m_sUsingAStarBotsCount+1) > BotManager.m_sMaxAStarBots) { return true; } BotManager.m_sUsingAStarBotsCount++; CleanAStarLists(false); m_pCurrentWaypoint->g[0] = m_pCurrentWaypoint->g[1] = 0; m_pCurrentWaypoint->pParent[0] = m_pCurrentWaypoint->pParent[1] = NULL; m_pCurrentGoalWaypoint->g[0] = m_pCurrentGoalWaypoint->g[1] = 0; m_pCurrentGoalWaypoint->pParent[0] = m_pCurrentGoalWaypoint->pParent[1] = NULL; m_AStarNodeList.DeleteAllNodes(); m_AStarOpenList[0].Clear(); m_AStarOpenList[1].Clear(); m_AStarClosedList[0].DeleteAllNodes(); m_AStarClosedList[1].DeleteAllNodes(); m_AStarOpenList[0].AddEntry(m_pCurrentWaypoint, GetDistance(m_pCurrentGoalWaypoint->pNode->v_origin)); m_AStarOpenList[1].AddEntry(m_pCurrentGoalWaypoint, GetDistance(m_pCurrentGoalWaypoint->pNode->v_origin)); m_pCurrentWaypoint->bIsOpen[0] = m_pCurrentGoalWaypoint->bIsOpen[1] = true; m_pCurrentWaypoint->bIsOpen[1] = m_pCurrentGoalWaypoint->bIsOpen[0] = false; m_pCurrentWaypoint->bIsClosed[0] = m_pCurrentGoalWaypoint->bIsClosed[1] = false; m_pCurrentWaypoint->bIsClosed[1] = m_pCurrentGoalWaypoint->bIsClosed[0] = false; } while(!m_AStarOpenList[0].Empty()) { if (iCurrentCycles >= (iMaxCycles/2)) { m_bCalculatingAStarPath = true; break; } n = m_AStarOpenList[0].Pop(); n->bIsOpen[0] = false; if (n->pNode->FailedGoalList.IsInList(m_pCurrentGoalWaypoint->pNode)) { bPathFailed = true; break; // Can't make path to goal } // Done with calculating if (n == m_pCurrentGoalWaypoint) { m_bCalculatingAStarPath = false; BotManager.m_sUsingAStarBotsCount--; while(n) { m_AStarNodeList.PushNode(n); n = n->pParent[0]; } CleanAStarLists(false); return true; } pPath = n->pNode->ConnectedWPs.GetFirst(); while(pPath) { if ((pPath->Entry->iFlags & W_FL_INTAG) && SOLID(S((int)pPath->Entry->v_origin.x, (int)pPath->Entry->v_origin.y))) { pPath = pPath->next; continue; } n2 = GetWPFromNode(pPath->Entry); if (!n2) { pPath = pPath->next; continue; } if (n2->bIsClosed[1]) { m_bCalculatingAStarPath = false; BotManager.m_sUsingAStarBotsCount--; while(n2) { m_AStarNodeList.AddNode(n2); n2 = n2->pParent[1]; } while(n) { m_AStarNodeList.PushNode(n); n = n->pParent[0]; } CleanAStarLists(false); return true; } newg = n->g[0] + (short)AStarCost(n, n2); if ((n2->g[0] <= newg) && (n2->bIsOpen[0] || n2->bIsClosed[0])) { pPath = pPath->next; continue; } n2->pParent[0] = n; n2->g[0] = newg; n2->bIsClosed[0] = false; if (!n2->bIsOpen[0]) { m_AStarOpenList[0].AddEntry(n2, n2->g[1] + GetDistance(n2->pNode->v_origin, m_pCurrentGoalWaypoint->pNode->v_origin)); n2->bIsOpen[0] = true; } pPath = pPath->next; } m_AStarClosedList[0].PushNode(n); n->bIsClosed[0] = true; iCurrentCycles++; } if (!bPathFailed) { while(!m_AStarOpenList[1].Empty()) { if (iCurrentCycles >= iMaxCycles) { m_bCalculatingAStarPath = true; return false; } n = m_AStarOpenList[1].Pop(); n->bIsOpen[1] = false; if (n->pNode->FailedGoalList.IsInList(m_pCurrentWaypoint->pNode)) { bPathFailed = true; break; // Can't make path to goal } // Done with calculating if (n == m_pCurrentWaypoint) { m_bCalculatingAStarPath = false; BotManager.m_sUsingAStarBotsCount--; while(n) { m_AStarNodeList.AddNode(n); n = n->pParent[1]; } CleanAStarLists(false); return true; } pPath = n->pNode->ConnectedWPsWithMe.GetFirst(); while(pPath) { if ((pPath->Entry->iFlags & W_FL_INTAG) && SOLID(S((int)pPath->Entry->v_origin.x, (int)pPath->Entry->v_origin.y))) { pPath = pPath->next; continue; } n2 = GetWPFromNode(pPath->Entry); if (!n2) { pPath = pPath->next; continue; } if (n2->bIsClosed[0]) { m_bCalculatingAStarPath = false; BotManager.m_sUsingAStarBotsCount--; while(n2) { m_AStarNodeList.PushNode(n2); n2 = n2->pParent[0]; } while(n) { m_AStarNodeList.AddNode(n); n = n->pParent[1]; } CleanAStarLists(false); return true; } newg = n->g[1] + (short)AStarCost(n, n2); if ((n2->g[1] <= newg) && (n2->bIsOpen[1] || n2->bIsClosed[1])) { pPath = pPath->next; continue; } n2->pParent[1] = n; n2->g[1] = newg; n2->bIsClosed[1] = false; if (!n2->bIsOpen[1]) { m_AStarOpenList[1].AddEntry(n2, n2->g[1] + GetDistance(n2->pNode->v_origin, m_pCurrentWaypoint->pNode->v_origin)); n2->bIsOpen[1] = true; } pPath = pPath->next; } m_AStarClosedList[1].PushNode(n); n->bIsClosed[1] = true; iCurrentCycles++; } } // Failed making path condebug("Path failed"); CleanAStarLists(true); m_bCalculatingAStarPath = false; BotManager.m_sUsingAStarBotsCount--; return true; } float CBot::AStarCost(waypoint_s *pWP1, waypoint_s *pWP2) { // UNDONE? return (GetDistance(pWP1->pNode->v_origin, pWP2->pNode->v_origin) * pWP2->pNode->sCost); } void CBot::CleanAStarLists(bool bPathFailed) { while(m_AStarOpenList[0].Empty() == false) { waypoint_s *p = m_AStarOpenList[0].Pop(); p->bIsOpen[0] = p->bIsOpen[1] = false; p->bIsClosed[0] = p->bIsClosed[1] = false; p->pParent[0] = p->pParent[1] = NULL; p->g[0] = p->g[1] = 0; } while(m_AStarOpenList[1].Empty() == false) { waypoint_s *p = m_AStarOpenList[1].Pop(); p->bIsOpen[0] = p->bIsOpen[1] = false; p->bIsClosed[0] = p->bIsClosed[1] = false; p->pParent[0] = p->pParent[1] = NULL; p->g[0] = p->g[1] = 0; } while(m_AStarClosedList[0].Empty() == false) { waypoint_s *p = m_AStarClosedList[0].Pop(); p->bIsOpen[0] = p->bIsOpen[1] = false; p->bIsClosed[0] = p->bIsClosed[1] = false; p->pParent[0] = p->pParent[1] = NULL; p->g[0] = p->g[1] = 0; if (bPathFailed) p->pNode->FailedGoalList.AddNode(m_pCurrentGoalWaypoint->pNode); } while(m_AStarClosedList[1].Empty() == false) { waypoint_s *p = m_AStarClosedList[1].Pop(); p->bIsOpen[0] = p->bIsOpen[1] = false; p->bIsClosed[0] = p->bIsClosed[1] = false; p->pParent[0] = p->pParent[1] = NULL; p->g[0] = p->g[1] = 0; if (bPathFailed) p->pNode->FailedGoalList.AddNode(m_pCurrentWaypoint->pNode); } } void CBot::ResetWaypointVars() { m_iWaypointTime = 0; m_pCurrentWaypoint = NULL; m_pCurrentGoalWaypoint = NULL; m_pPrevWaypoints[0] = NULL; m_pPrevWaypoints[1] = NULL; m_pPrevWaypoints[2] = NULL; m_pPrevWaypoints[3] = NULL; m_pPrevWaypoints[4] = NULL; m_fPrevWaypointDistance = 0; m_iWaypointHeadLastTurnLessTime = 0; m_iWaypointHeadPauseTime = 0; if (m_bCalculatingAStarPath) { m_bCalculatingAStarPath = false; BotManager.m_sUsingAStarBotsCount--; } m_AStarNodeList.DeleteAllNodes(); CleanAStarLists(false); m_bGoToDebugGoal = false; } void CBot::SetCurrentWaypoint(node_s *pNode) { waypoint_s *pWP = GetWPFromNode(pNode); #ifndef RELEASE_BUILD if (!pWP || !pNode) condebug("NULL WP In SetCurrentWP"); #endif m_pCurrentWaypoint = pWP; m_iWaypointTime = lastmillis; } void CBot::SetCurrentWaypoint(waypoint_s *pWP) { #ifndef RELEASE_BUILD if (!pWP) condebug("NULL WP In SetCurrentWP(2)"); #endif m_pCurrentWaypoint = pWP; m_iWaypointTime = lastmillis; } void CBot::SetCurrentGoalWaypoint(node_s *pNode) { waypoint_s *pWP = GetWPFromNode(pNode); #ifndef RELEASE_BUILD if (!pWP || !pNode) condebug("NULL WP In SetCurrentGoalWP"); #endif m_pCurrentGoalWaypoint = pWP; } void CBot::SetCurrentGoalWaypoint(waypoint_s *pWP) { #ifndef RELEASE_BUILD if (!pWP) condebug("NULL WP In SetCurrentGoalWP(2)"); #endif m_pCurrentGoalWaypoint = pWP; } bool CBot::CurrentWPIsValid() { if (!m_pCurrentWaypoint) { //condebug("Invalid WP: Is NULL"); return false; } // check if the bot has been trying to get to this waypoint for a while... if ((m_iWaypointTime + 5000) < lastmillis) { condebug("Invalid WP: time over"); return false; } #ifndef RELEASE_BUILD if (!IsVisible(m_pCurrentWaypoint->pNode->v_origin)) condebug("Invalid WP: Not visible"); #endif return (IsVisible(m_pCurrentWaypoint->pNode->v_origin)); } bool CBot::ReachedGoalWP() { if ((!m_pCurrentWaypoint) || (!m_pCurrentGoalWaypoint)) return false; if (m_pCurrentWaypoint != m_pCurrentGoalWaypoint) return false; return ((GetDistance(m_pCurrentGoalWaypoint->pNode->v_origin) <= 3.0f) && (IsVisible(m_pCurrentGoalWaypoint->pNode->v_origin))); } waypoint_s *CBot::GetWPFromNode(node_s *pNode) { if (!pNode) return NULL; short x, y; WaypointClass.GetNodeIndexes(pNode->v_origin, &x, &y); TLinkedList::node_s *p = m_WaypointList[x][y].GetFirst(); while(p) { if (p->Entry->pNode == pNode) return p->Entry; p = p->next; } return NULL; } waypoint_s *CBot::GetNearestWaypoint(vec v_src, float flRange) { TLinkedList::node_s *p; waypoint_s *pNearest = NULL; short i, j, MinI, MaxI, MinJ, MaxJ, Offset = (short)ceil(flRange / MAX_MAP_GRIDS); float flNearestDist = 9999.99f, flDist; WaypointClass.GetNodeIndexes(v_src, &i, &j); MinI = i - Offset; MaxI = i + Offset; MinJ = j - Offset; MaxJ = j + Offset; if (MinI < 0) MinI = 0; if (MaxI > MAX_MAP_GRIDS - 1) MaxI = MAX_MAP_GRIDS - 1; if (MinJ < 0) MinJ = 0; if (MaxJ > MAX_MAP_GRIDS - 1) MaxJ = MAX_MAP_GRIDS - 1; for (int x=MinI;x<=MaxI;x++) { for(int y=MinJ;y<=MaxJ;y++) { p = m_WaypointList[x][y].GetFirst(); while(p) { if (p->Entry->pNode->iFlags & W_FL_FLOOD) { p = p->next; continue; } flDist = GetDistance(v_src, p->Entry->pNode->v_origin); if ((flDist < flNearestDist) && (flDist <= flRange)) { if (::IsVisible(v_src, p->Entry->pNode->v_origin, NULL)) { pNearest = p->Entry; flNearestDist = flDist; } } p = p->next; } } } return pNearest; } waypoint_s *CBot::GetNearestTriggerWaypoint(vec v_src, float flRange) { TLinkedList::node_s *p; waypoint_s *pNearest = NULL; short i, j, MinI, MaxI, MinJ, MaxJ, Offset = (short)ceil(flRange / MAX_MAP_GRIDS); float flNearestDist = 9999.99f, flDist; WaypointClass.GetNodeIndexes(v_src, &i, &j); MinI = i - Offset; MaxI = i + Offset; MinJ = j - Offset; MaxJ = j + Offset; if (MinI < 0) MinI = 0; if (MaxI > MAX_MAP_GRIDS - 1) MaxI = MAX_MAP_GRIDS - 1; if (MinJ < 0) MinJ = 0; if (MaxJ > MAX_MAP_GRIDS - 1) MaxJ = MAX_MAP_GRIDS - 1; for (int x=MinI;x<=MaxI;x++) { for(int y=MinJ;y<=MaxJ;y++) { p = m_WaypointList[x][y].GetFirst(); while(p) { if (!(p->Entry->pNode->iFlags & W_FL_TRIGGER)) { p = p->next; continue; } flDist = GetDistance(v_src, p->Entry->pNode->v_origin); if ((flDist < flNearestDist) && (flDist <= flRange)) { if (::IsVisible(v_src, p->Entry->pNode->v_origin, NULL)) { pNearest = p->Entry; flNearestDist = flDist; } } p = p->next; } } } return pNearest; } // Makes a waypoint list for this bot based on the list from WaypointClass void CBot::SyncWaypoints() { short x, y; TLinkedList::node_s *p; // Clean everything first for (x=0;xpNode = p->Entry; m_WaypointList[x][y].AddNode(pWP); #ifndef RELEASE_BUILD if (!GetWPFromNode(p->Entry)) condebug("Error adding bot wp!"); #endif p = p->next; } } } } #ifdef WP_FLOOD waypoint_s *CBot::GetNearestFloodWP(vec v_origin, float flRange) { TLinkedList::node_s *p; waypoint_s *pNearest = NULL; short i, j, MinI, MaxI, MinJ, MaxJ, Offset = (short)ceil(flRange / MAX_MAP_GRIDS); float flNearestDist = 9999.99f, flDist; WaypointClass.GetNodeIndexes(v_origin, &i, &j); MinI = i - Offset; MaxI = i + Offset; MinJ = j - Offset; MaxJ = j + Offset; if (MinI < 0) MinI = 0; if (MaxI > MAX_MAP_GRIDS - 1) MaxI = MAX_MAP_GRIDS - 1; if (MinJ < 0) MinJ = 0; if (MaxJ > MAX_MAP_GRIDS - 1) MaxJ = MAX_MAP_GRIDS - 1; for (int x=MinI;x<=MaxI;x++) { for(int y=MinJ;y<=MaxJ;y++) { p = m_WaypointList[x][y].GetFirst(); while(p) { if (!(p->Entry->pNode->iFlags & W_FL_FLOOD)) { p = p->next; continue; } flDist = GetDistance(v_origin, p->Entry->pNode->v_origin); if ((flDist < flNearestDist) && (flDist <= flRange)) { if (::IsVisible(v_origin, p->Entry->pNode->v_origin, NULL)) { pNearest = p->Entry; flNearestDist = flDist; } } p = p->next; } } } return pNearest; } waypoint_s *CBot::GetNearestTriggerFloodWP(vec v_origin, float flRange) { TLinkedList::node_s *p; waypoint_s *pNearest = NULL; short i, j, MinI, MaxI, MinJ, MaxJ, Offset = (short)ceil(flRange / MAX_MAP_GRIDS); float flNearestDist = 9999.99f, flDist; WaypointClass.GetNodeIndexes(v_origin, &i, &j); MinI = i - Offset; MaxI = i + Offset; MinJ = j - Offset; MaxJ = j + Offset; if (MinI < 0) MinI = 0; if (MaxI > MAX_MAP_GRIDS - 1) MaxI = MAX_MAP_GRIDS - 1; if (MinJ < 0) MinJ = 0; if (MaxJ > MAX_MAP_GRIDS - 1) MaxJ = MAX_MAP_GRIDS - 1; for (int x=MinI;x<=MaxI;x++) { for(int y=MinJ;y<=MaxJ;y++) { p = m_WaypointList[x][y].GetFirst(); while(p) { if (!(p->Entry->pNode->iFlags & (W_FL_FLOOD | W_FL_TRIGGER))) { p = p->next; continue; } flDist = GetDistance(v_origin, p->Entry->pNode->v_origin); if ((flDist < flNearestDist) && (flDist <= flRange)) { if (::IsVisible(v_origin, p->Entry->pNode->v_origin, NULL)) { pNearest = p->Entry; flNearestDist = flDist; } } p = p->next; } } } return pNearest; } void CBot::GoToDebugGoal(vec o) { ResetWaypointVars(); node_s *wp = WaypointClass.GetNearestWaypoint(m_pMyEnt, 20.0f); node_s *goalwp = WaypointClass.GetNearestWaypoint(player1, 20.0f); if (!wp || !goalwp) { wp = WaypointClass.GetNearestFloodWP(m_pMyEnt, 8.0f); goalwp = WaypointClass.GetNearestFloodWP(player1, 5.0f); } if (!wp || !goalwp) { condebug("No near WP"); return; } SetCurrentWaypoint(wp); SetCurrentGoalWaypoint(goalwp); m_vGoal = o; m_bGoToDebugGoal = true; } #endif // Bot class end assaultcube-1.2.0.2.1/source/src/bot/bot_waypoint.h000066400000000000000000000135101352165075300220750ustar00rootroot00000000000000// // C++ Implementation: bot_waypoint.h // // Description: Containts all defintions for bot waypoint code // // // Author: Rick Helmus // // Enable this for flood support #define WP_FLOOD #ifndef BOT_WAYPOINT_H #define BOT_WAYPOINT_H #define WAYPOINT_VERSION 2 #define EXP_WP_VERSION 1 #define REACHABLE_RANGE 15.0f #define MAX_MAP_GRIDS 64 #define SECTOR_SIZE 18 #define W_FL_TELEPORT (1<<1) // used if waypoint is at a teleporter #define W_FL_TELEPORTDEST (1<<2) // used if waypoint is at a teleporter destination #define W_FL_FLOOD (1<<3) // used if this waypoint is made by flooding the map #define W_FL_JUMP (1<<4) // if set, bot jumps when reached this waypoint #define W_FL_TRIGGER (1<<5) // used if this waypoint is at a trigger #define W_FL_INTAG (1<<6) // used if this waypoint is in a tagged cube #define MAX_FLOODWPCONNECTDIST 2 #define MAX_FLOODWPDIST 4.0f struct waypoint_header_s { char szFileType[10]; int iFileVersion; int iFileFlags; // not currently used int iWPCount; char szMapName[32]; // name of map for these waypoints }; // Old waypoint structure, used for waypoint version 1 struct waypoint_version_1_s { int iFlags; vec v_origin; TLinkedList ConnectedWPs; // A* stuff float f, g; waypoint_version_1_s *pParent; // Construction waypoint_version_1_s(void) : iFlags(0), f(0.0f), g(0.0f), pParent(NULL) { }; }; struct node_s { vec v_origin; int iFlags; short sTriggerNr; short sYaw; short sCost; // Base and static cost TLinkedList ConnectedWPs; TLinkedList ConnectedWPsWithMe; TLinkedList FailedGoalList; // Construction node_s(void) : iFlags(0), sTriggerNr(0), sYaw(-1), sCost(10) { }; node_s(const vec &o, const int &f, const short t=0, const short y=-1) : v_origin(o), iFlags(f), sTriggerNr(t), sYaw(y), sCost(0) { }; }; struct waypoint_s { node_s *pNode; short g[2]; waypoint_s *pParent[2]; bool bIsOpen[2], bIsClosed[2]; // Construction waypoint_s(void) : pNode(NULL) { bIsOpen[0] = bIsOpen[1] = bIsClosed[0] = bIsClosed[1] = false; pParent[0] = pParent[1] = NULL; g[0] = g[1] = 0; }; }; class CWaypointClass { protected: bool m_bDrawWaypoints; bool m_bDrawWPPaths; bool m_bAutoWaypoint; bool m_bAutoPlacePaths; bool m_bDrawWPText; vec m_vLastCreatedWP; float m_fPathDrawTime; char m_szMapName[32]; #ifdef WP_FLOOD bool m_bFlooding; // True if flooding map with waypoints bool m_bFilteringNodes; int m_iFloodStartTime; int m_iCurFloodX, m_iCurFloodY; int m_iFloodSize; int m_iFilteredNodes; #endif friend class CBot; public: TLinkedList m_Waypoints[MAX_MAP_GRIDS][MAX_MAP_GRIDS]; int m_iWaypointCount; // number of waypoints currently in use CWaypointClass(void); virtual ~CWaypointClass(void) { Clear(); }; void Think(void); void Init(void); void Clear(void); bool LoadWaypoints(void); void SaveWaypoints(void); bool LoadWPExpFile(void); void SaveWPExpFile(void); void SetMapName(const char *map) { strcpy(m_szMapName, map); }; void SetWaypointsVisible(bool Visible) { m_bDrawWaypoints = Visible; }; void SetPathsVisible(bool Visible) { m_bDrawWPPaths = Visible; }; void SetAutoWaypoint(bool On) { m_bAutoWaypoint = On; }; void SetWPInfo(bool on) { m_bDrawWPText = on; }; void SetWPFlags(node_s *wp, int iFlags) { wp->iFlags |= iFlags; }; void UnsetWPFlags(node_s *wp, int iFlags) { wp->iFlags &= ~iFlags; }; void SetWPTriggerNr(node_s *wp, short sTriggerNr) { wp->sTriggerNr = sTriggerNr; }; void SetWPYaw(node_s *wp, short sYaw) { wp->sYaw = sYaw; }; bool WaypointsAreVisible(void) { return m_bDrawWaypoints; }; node_s *AddWaypoint(vec o, bool connectwp); void DeleteWaypoint(vec v_src); void AddPath(node_s *pWP1, node_s *pWP2); void DeletePath(node_s *pWP); void DeletePath(node_s *pWP1, node_s *pWP2); void ManuallyCreatePath(vec v_src, int iCmd, bool TwoWay); void ManuallyDeletePath(vec v_src, int iCmd, bool TwoWay); bool WPIsReachable(vec from, vec to); //node_s *GetNearestWaypoint(vec v_src, float flRange, bool CheckVisible = true, bool SkipFloodWPs = true); node_s *GetNearestWaypoint(vec v_src, float flRange); node_s *GetNearestWaypoint(dynent *d, float flRange) { return GetNearestWaypoint(d->o, flRange); }; node_s *GetNearestTriggerWaypoint(vec v_src, float flRange); node_s *GetWaypointFromVec(const vec &v_src); void DrawNearWaypoints(); void GetNodeIndexes(const vec &v_origin, short *i, short *j); void CalcCost(node_s *pNode); void ReCalcCosts(void); #ifdef WP_FLOOD // Flood functions virtual void StartFlood(void); void StopFlood(void); void FloodThink(void); bool CanPlaceNodeHere(const vec &from); void ConnectFloodWP(node_s *pWP); node_s *GetNearestFloodWP(vec v_origin, float flRange, node_s *pIgnore, bool SkipTags=false); node_s *GetNearestFloodWP(dynent *d, float flRange) { return GetNearestFloodWP(d->o, flRange, NULL); }; node_s *GetNearestTriggerFloodWP(vec v_origin, float flRange); #endif }; class CACWaypointClass: public CWaypointClass { public: #ifdef WP_FLOOD // Flood functions virtual void StartFlood(void); #endif }; #endif // BOT_WAYPOINT_H assaultcube-1.2.0.2.1/source/src/bot/botmanager.cpp000066400000000000000000000755751352165075300220540ustar00rootroot00000000000000// // C++ Implementation: bot // // Description: Code for botmanager // // Main bot file // // Author: Rick // // // #include "cube.h" #include "bot.h" extern void respawnself(); CBotManager BotManager; // Bot manager class begin CBotManager::~CBotManager(void) { EndMap(); ClearStoredBots(); } void CBotManager::Init() { m_pBotToView = NULL; m_iFrameTime = 0; m_iPrevTime = lastmillis; m_sBotSkill = 1; // Default all bots have the skill 'Good' CreateSkillData(); LoadBotNamesFile(); LoadBotTeamsFile(); //WaypointClass.Init(); lsrand(time(NULL)); } void CBotManager::Think() { if (m_bInit) { Init(); m_bInit = false; } if (m_pBotToView) ViewBot(); AddDebugText("m_sMaxAStarBots: %d", m_sMaxAStarBots); AddDebugText("m_sCurrentTriggerNr: %d", m_sCurrentTriggerNr); short x, y; WaypointClass.GetNodeIndexes(player1->o, &x, &y); AddDebugText("x: %d y: %d", x, y); m_iFrameTime = lastmillis - m_iPrevTime; if (m_iFrameTime > 250) m_iFrameTime = 250; m_iPrevTime = lastmillis; // Is it time to re-add bots? if ((m_fReAddBotDelay < lastmillis) && (m_fReAddBotDelay != -1.0f)) { while(m_StoredBots.Empty() == false) { CStoredBot *pStoredBot = m_StoredBots.Pop(); ReAddBot(pStoredBot); delete pStoredBot; } m_fReAddBotDelay = -1.0f; } // Let all bots 'think' loopv(bots) { if (!bots[i]) continue; if (bots[i]->pBot) { bots[i]->pBot->CheckWeaponSwitch(); // 2011jan17:ft: fix non-shooting bots bots[i]->pBot->Think(); } else condebug("Error: pBot == NULL in bot ent\n"); } } void CBotManager::LoadBotNamesFile() { // Init bot names array first for (int i=0;i<100;i++) strcpy(m_szBotNames[i], "Bot"); m_sBotNameCount = 0; // Load bot file char szNameFileName[256]; MakeBotFileName("bot_names.txt", NULL, NULL, szNameFileName); FILE *fp = fopen(szNameFileName, "r"); char szNameBuffer[256]; int iIndex, iStrIndex; if (!fp) { conoutf("Warning: Couldn't load bot names file"); return; } while (fgets(szNameBuffer, 80, fp) != NULL) { if (m_sBotNameCount >= 150) { conoutf("Warning: Max bot names reached(150), ignoring the rest of the" "names"); break; } short length = (short)strlen(szNameBuffer); if (szNameBuffer[length-1] == '\n') { szNameBuffer[length-1] = 0; // remove '\n' length--; } iStrIndex = 0; while (iStrIndex < length) { if ((szNameBuffer[iStrIndex] < ' ') || (szNameBuffer[iStrIndex] > '~') || (szNameBuffer[iStrIndex] == '"')) { for (iIndex=iStrIndex; iIndex < length; iIndex++) szNameBuffer[iIndex] = szNameBuffer[iIndex+1]; } iStrIndex++; } if (szNameBuffer[0] != 0) { if (strlen(szNameBuffer) >= 16) { conoutf("Warning: bot name \"%s\" has to many characters(16 is max)", szNameBuffer); } copystring(m_szBotNames[m_sBotNameCount], szNameBuffer, 16); m_sBotNameCount++; } } fclose(fp); } const char *CBotManager::GetBotName() { const char *szOutput = NULL; TMultiChoice BotNameChoices; short ChoiceVal; for(int j=0;jname, m_szBotNames[j]))) { ChoiceVal = 0; break; } } if (!strcasecmp(player1->name, m_szBotNames[j])) ChoiceVal = 0; if(ChoiceVal) BotNameChoices.Insert(m_szBotNames[j], ChoiceVal); } // Couldn't find a selection? if (!BotNameChoices.GetSelection(szOutput)) szOutput = "Bot"; return szOutput; } void CBotManager::LoadBotTeamsFile() { // Init bot teams array first for (int i=0;i<20;i++) strcpy(m_szBotTeams[i], "b0ts"); m_sBotTeamCount = 0; // Load bot file char szNameFileName[256]; MakeBotFileName("bot_teams.txt", NULL, NULL, szNameFileName); FILE *fp = fopen(szNameFileName, "r"); char szNameBuffer[256]; int iIndex, iStrIndex; if (!fp) { conoutf("Warning: Couldn't load bot teams file"); return; } while ((m_sBotTeamCount < 20) && (fgets(szNameBuffer, 80, fp) != NULL)) { short length = (short)strlen(szNameBuffer); if (szNameBuffer[length-1] == '\n') { szNameBuffer[length-1] = 0; // remove '\n' length--; } iStrIndex = 0; while (iStrIndex < length) { if ((szNameBuffer[iStrIndex] < ' ') || (szNameBuffer[iStrIndex] > '~') || (szNameBuffer[iStrIndex] == '"')) { for (iIndex=iStrIndex; iIndex < length; iIndex++) szNameBuffer[iIndex] = szNameBuffer[iIndex+1]; } iStrIndex++; } if (szNameBuffer[0] != 0) { copystring(m_szBotTeams[m_sBotTeamCount], szNameBuffer, 5); m_sBotTeamCount++; } } fclose(fp); } const char *CBotManager::GetBotTeam() { int teamsize[2] = {0, 0}; int biggestTeam = 0; if(team_isactive(player1->team)) { teamsize[player1->team]++; } loopv(bots) if(bots[i] && team_isactive(bots[i]->team)) { teamsize[bots[i]->team]++; } biggestTeam = teamsize[1] > teamsize[0]; return teamnames[biggestTeam ^ 1]; // Following code will never be executed. // (bot teams aren't ready, we use normal teams instead) const char *szOutput = NULL; TMultiChoice BotTeamChoices; short ChoiceVal; for(int j=0;jname, m_szBotNames[j]))) ChoiceVal -= 10; } if (!strcasecmp(player1->name, m_szBotNames[j])) ChoiceVal -= 10; if (ChoiceVal <= 0) ChoiceVmonsterclearal = 1;*/ BotTeamChoices.Insert(m_szBotTeams[j], ChoiceVal); } // Couldn't find a selection? if (!BotTeamChoices.GetSelection(szOutput)) szOutput = "b0t"; return szOutput; } void CBotManager::RenderBots() { //static bool drawblue; loopv(bots) { if (bots[i] && (bots[i] != m_pBotToView)) { renderclientp(bots[i]); } } } void CBotManager::EndMap() { // Remove all bots loopv(bots) { if(!bots[i] || !bots[i]->pBot) continue; // Store bots so they can be re-added after map change if (bots[i]->pBot && bots[i]->name[0] && team_isactive(bots[i]->team)) { CStoredBot *pStoredBot = new CStoredBot(bots[i]->name, (char *) team_string(bots[i]->team), bots[i]->pBot->m_sSkillNr); m_StoredBots.AddNode(pStoredBot); } delete bots[i]->pBot; bots[i]->pBot = NULL; freebotent(bots[i]); } bots.setsize(0); condebug("Cleared all bots"); m_fReAddBotDelay = lastmillis + 7500; //if(ishost()) WaypointClass.SaveWPExpFile(); //UNDONE } void CBotManager::BeginMap(const char *szMapName) { EndMap(); // End previous map WaypointClass.Init(); WaypointClass.SetMapName(szMapName); if (!WaypointClass.LoadWaypoints()) WaypointClass.StartFlood(); //WaypointClass.LoadWPExpFile(); // UNDONE CalculateMaxAStarCount(); m_sUsingAStarBotsCount = 0; PickNextTrigger(); } int CBotManager::GetBotIndex(botent *m) { loopv(bots) { if (!bots[i]) continue; if (bots[i] == m) return i; } return -1; } void CBotManager::LetBotsUpdateStats() { loopv(bots) if (bots[i] && bots[i]->pBot) bots[i]->pBot->m_bSendC2SInit = false; } void CBotManager::LetBotsHear(int n, vec *loc) { if (bots.length() == 0 || !loc) return; loopv(bots) { if (!bots[i] || !bots[i]->pBot || (bots[i]->state == CS_DEAD)) continue; bots[i]->pBot->HearSound(n, loc); } } // Notify all bots of a new waypoint void CBotManager::AddWaypoint(node_s *pNode) { if (bots.length()) { short x, y; waypoint_s *pWP; loopv(bots) { if (!bots[i] || !bots[i]->pBot) continue; pWP = new waypoint_s; pWP->pNode = pNode; WaypointClass.GetNodeIndexes(pNode->v_origin, &x, &y); bots[i]->pBot->m_WaypointList[x][y].AddNode(pWP); #ifndef RELEASE_BUILD if (!bots[i]->pBot->GetWPFromNode(pNode)) condebug("Error adding bot wp!"); #endif } } CalculateMaxAStarCount(); } // Notify all bots of a deleted waypoint void CBotManager::DelWaypoint(node_s *pNode) { if (bots.length()) { short x, y; TLinkedList::node_s *p; loopv(bots) { if (!bots[i] || !bots[i]->pBot) continue; WaypointClass.GetNodeIndexes(pNode->v_origin, &x, &y); p = bots[i]->pBot->m_WaypointList[x][y].GetFirst(); while(p) { if (p->Entry->pNode == pNode) { delete p->Entry; bots[i]->pBot->m_WaypointList[x][y].DeleteNode(p); break; } p = p->next; } } } CalculateMaxAStarCount(); } void CBotManager::MakeBotFileName(const char *szFileName, const char *szDir1, const char *szDir2, char *szOutput) { const char *DirSeperator; #ifdef WIN32 DirSeperator = "\\"; strcpy(szOutput, "bot\\"); #else DirSeperator = "/"; strcpy(szOutput, "bot/"); #endif if (szDir1) { strcat(szOutput, szDir1); strcat(szOutput, DirSeperator); } if (szDir2) { strcat(szOutput, szDir2); strcat(szOutput, DirSeperator); } strcat(szOutput, szFileName); } void CBotManager::CreateSkillData() { // First give the bot skill structure some default data InitSkillData(); // Now see if we can load the skill.cfg file char SkillFileName[256] = ""; FILE *pSkillFile = NULL; int SkillNr = -1; float value = 0; MakeBotFileName("bot_skill.cfg", NULL, NULL, SkillFileName); pSkillFile = fopen(SkillFileName, "r"); conoutf("Reading bot_skill.cfg file... "); if (pSkillFile == NULL) // file doesn't exist { conoutf("skill file not found, default settings will be used\n"); return; } int ch; char cmd_line[256]; int cmd_index; char *cmd, *arg1; while (pSkillFile) { cmd_index = 0; cmd_line[cmd_index] = 0; ch = fgetc(pSkillFile); // skip any leading blanks while (ch == ' ') ch = fgetc(pSkillFile); while ((ch != EOF) && (ch != '\r') && (ch != '\n')) { if (ch == '\t') // convert tabs to spaces ch = ' '; cmd_line[cmd_index] = ch; ch = fgetc(pSkillFile); // skip multiple spaces in input file while ((cmd_line[cmd_index] == ' ') && (ch == ' ')) ch = fgetc(pSkillFile); cmd_index++; } if (ch == '\r') // is it a carriage return? { ch = fgetc(pSkillFile); // skip the linefeed } // if reached end of file, then close it if (ch == EOF) { fclose(pSkillFile); pSkillFile = NULL; } cmd_line[cmd_index] = 0; // terminate the command line cmd_index = 0; cmd = cmd_line; arg1 = NULL; // skip to blank or end of string... while ((cmd_line[cmd_index] != ' ') && (cmd_line[cmd_index] != 0)) cmd_index++; if (cmd_line[cmd_index] == ' ') { cmd_line[cmd_index++] = 0; arg1 = &cmd_line[cmd_index]; } if ((cmd_line[0] == '#') || (cmd_line[0] == 0)) continue; // skip if comment or blank line if (strcasecmp(cmd, "[SKILL1]") == 0) SkillNr = 0; else if (strcasecmp(cmd, "[SKILL2]") == 0) SkillNr = 1; else if (strcasecmp(cmd, "[SKILL3]") == 0) SkillNr = 2; else if (strcasecmp(cmd, "[SKILL4]") == 0) SkillNr = 3; else if (strcasecmp(cmd, "[SKILL5]") == 0) SkillNr = 4; if ((arg1 == NULL) || (*arg1 == 0)) continue; if (SkillNr == -1) // Not in a skill block yet? continue; value = atof(arg1); if (strcasecmp(cmd, "min_x_aim_speed") == 0) { m_BotSkills[SkillNr].flMinAimXSpeed = value; } else if (strcasecmp(cmd, "max_x_aim_speed") == 0) { m_BotSkills[SkillNr].flMaxAimXSpeed = value; } else if (strcasecmp(cmd, "min_y_aim_speed") == 0) { m_BotSkills[SkillNr].flMinAimYSpeed = value; } else if (strcasecmp(cmd, "max_y_aim_speed") == 0) { m_BotSkills[SkillNr].flMaxAimYSpeed = value; } else if (strcasecmp(cmd, "min_x_aim_offset") == 0) { m_BotSkills[SkillNr].flMinAimXOffset = value; } else if (strcasecmp(cmd, "max_x_aim_offset") == 0) { m_BotSkills[SkillNr].flMaxAimXOffset = value; } else if (strcasecmp(cmd, "min_y_aim_offset") == 0) { m_BotSkills[SkillNr].flMinAimYOffset = value; } else if (strcasecmp(cmd, "max_y_aim_offset") == 0) { m_BotSkills[SkillNr].flMaxAimYOffset = value; } else if (strcasecmp(cmd, "min_attack_delay") == 0) { m_BotSkills[SkillNr].flMinAttackDelay = value; } else if (strcasecmp(cmd, "max_attack_delay") == 0) { m_BotSkills[SkillNr].flMaxAttackDelay = value; } else if (strcasecmp(cmd, "min_enemy_search_delay") == 0) { m_BotSkills[SkillNr].flMinEnemySearchDelay = value; } else if (strcasecmp(cmd, "max_enemy_search_delay") == 0) { m_BotSkills[SkillNr].flMaxEnemySearchDelay = value; } else if (strcasecmp(cmd, "max_always_detect_distance") == 0) { m_BotSkills[SkillNr].flAlwaysDetectDistance = value; } else if (strcasecmp(cmd, "can_predict_position") == 0) { m_BotSkills[SkillNr].bCanPredict = value!=0; } else if (strcasecmp(cmd, "field_of_view") == 0) { if (value < 80) value = 80; else if (value > 240) value = 120; m_BotSkills[SkillNr].iFov = (int)value; } else if (strcasecmp(cmd, "max_hear_volume") == 0) { if (value < 0) value = 0; else if (value > 255) value = 100; m_BotSkills[SkillNr].iMaxHearVolume = (int)value; } else if (strcasecmp(cmd, "can_circle_strafe") == 0) { m_BotSkills[SkillNr].bCircleStrafe = value!=0; } else if (strcasecmp(cmd, "can_search_items_in_combat") == 0) { m_BotSkills[SkillNr].bCanSearchItemsInCombat = value!=0; } } conoutf("done"); } void CBotManager::InitSkillData() { // Best skill m_BotSkills[0].flMinReactionDelay = 0.015f; m_BotSkills[0].flMaxReactionDelay = 0.035f; m_BotSkills[0].flMinAimXOffset = 15.0f; m_BotSkills[0].flMaxAimXOffset = 20.0f; m_BotSkills[0].flMinAimYOffset = 10.0f; m_BotSkills[0].flMaxAimYOffset = 15.0f; m_BotSkills[0].flMinAimXSpeed = 330.0f; m_BotSkills[0].flMaxAimXSpeed = 355.0f; m_BotSkills[0].flMinAimYSpeed = 400.0f; m_BotSkills[0].flMaxAimYSpeed = 450.0f; m_BotSkills[0].flMinAttackDelay = 0.1f; m_BotSkills[0].flMaxAttackDelay = 0.4f; m_BotSkills[0].flMinEnemySearchDelay = 0.09f; m_BotSkills[0].flMaxEnemySearchDelay = 0.12f; m_BotSkills[0].flAlwaysDetectDistance = 12.0f; m_BotSkills[0].bCanPredict = true; m_BotSkills[0].iMaxHearVolume = 75; m_BotSkills[0].iFov = 200; m_BotSkills[0].bCircleStrafe = true; m_BotSkills[0].bCanSearchItemsInCombat = true; // Good skill m_BotSkills[1].flMinReactionDelay = 0.035f; m_BotSkills[1].flMaxReactionDelay = 0.045f; m_BotSkills[1].flMinAimXOffset = 20.0f; m_BotSkills[1].flMaxAimXOffset = 25.0f; m_BotSkills[1].flMinAimYOffset = 15.0f; m_BotSkills[1].flMaxAimYOffset = 20.0f; m_BotSkills[1].flMinAimXSpeed = 250.0f; m_BotSkills[1].flMaxAimXSpeed = 265.0f; m_BotSkills[1].flMinAimYSpeed = 260.0f; m_BotSkills[1].flMaxAimYSpeed = 285.0f; m_BotSkills[1].flMinAttackDelay = 0.3f; m_BotSkills[1].flMaxAttackDelay = 0.6f; m_BotSkills[1].flMinEnemySearchDelay = 0.12f; m_BotSkills[1].flMaxEnemySearchDelay = 0.17f; m_BotSkills[1].flAlwaysDetectDistance = 10.0f; m_BotSkills[1].bCanPredict = true; m_BotSkills[1].iMaxHearVolume = 60; m_BotSkills[1].iFov = 160; m_BotSkills[1].bCircleStrafe = true; m_BotSkills[1].bCanSearchItemsInCombat = true; // Medium skill m_BotSkills[2].flMinReactionDelay = 0.075f; m_BotSkills[2].flMaxReactionDelay = 0.010f; m_BotSkills[2].flMinAimXOffset = 25.0f; m_BotSkills[2].flMaxAimXOffset = 30.0f; m_BotSkills[2].flMinAimYOffset = 20.0f; m_BotSkills[2].flMaxAimYOffset = 25.0f; m_BotSkills[2].flMinAimXSpeed = 190.0f; m_BotSkills[2].flMaxAimXSpeed = 125.0f; m_BotSkills[2].flMinAimYSpeed = 210.0f; m_BotSkills[2].flMaxAimYSpeed = 240.0f; m_BotSkills[2].flMinAttackDelay = 0.75f; m_BotSkills[2].flMaxAttackDelay = 1.0f; m_BotSkills[2].flMinEnemySearchDelay = 0.18f; m_BotSkills[2].flMaxEnemySearchDelay = 0.22f; m_BotSkills[2].flAlwaysDetectDistance = 8.0f; m_BotSkills[2].bCanPredict = false; m_BotSkills[2].iMaxHearVolume = 45; m_BotSkills[2].iFov = 130; m_BotSkills[2].bCircleStrafe = true; m_BotSkills[2].bCanSearchItemsInCombat = false; // Worse skill m_BotSkills[3].flMinReactionDelay = 0.15f; m_BotSkills[3].flMaxReactionDelay = 0.20f; m_BotSkills[3].flMinAimXOffset = 30.0f; m_BotSkills[3].flMaxAimXOffset = 35.0f; m_BotSkills[3].flMinAimYOffset = 25.0f; m_BotSkills[3].flMaxAimYOffset = 30.0f; m_BotSkills[3].flMinAimXSpeed = 155.0f; m_BotSkills[3].flMaxAimXSpeed = 170.0f; m_BotSkills[3].flMinAimYSpeed = 160.0f; m_BotSkills[3].flMaxAimYSpeed = 210.0f; m_BotSkills[3].flMinAttackDelay = 1.2f; m_BotSkills[3].flMaxAttackDelay = 1.6f; m_BotSkills[3].flMinEnemySearchDelay = 0.25f; m_BotSkills[3].flMaxEnemySearchDelay = 0.30f; m_BotSkills[3].flAlwaysDetectDistance = 6.0f; m_BotSkills[3].bCanPredict = false; m_BotSkills[3].iMaxHearVolume = 30; m_BotSkills[3].iFov = 120; m_BotSkills[3].bCircleStrafe = false; m_BotSkills[3].bCanSearchItemsInCombat = false; // Bad skill m_BotSkills[4].flMinReactionDelay = 0.30f; m_BotSkills[4].flMaxReactionDelay = 0.50f; m_BotSkills[4].flMinAimXOffset = 35.0f; m_BotSkills[4].flMaxAimXOffset = 40.0f; m_BotSkills[4].flMinAimYOffset = 30.0f; m_BotSkills[4].flMaxAimYOffset = 35.0f; m_BotSkills[4].flMinAimXSpeed = 45.0f; m_BotSkills[4].flMaxAimXSpeed = 60.0f; m_BotSkills[4].flMinAimYSpeed = 125.0f; m_BotSkills[4].flMaxAimYSpeed = 180.0f; m_BotSkills[4].flMinAttackDelay = 1.5f; m_BotSkills[4].flMaxAttackDelay = 2.0f; m_BotSkills[4].flMinEnemySearchDelay = 0.30f; m_BotSkills[4].flMaxEnemySearchDelay = 0.36f; m_BotSkills[4].flAlwaysDetectDistance = 4.0f; m_BotSkills[4].bCanPredict = false; m_BotSkills[4].iMaxHearVolume = 15; m_BotSkills[4].iFov = 110; m_BotSkills[4].bCircleStrafe = false; m_BotSkills[4].bCanSearchItemsInCombat = false; } void CBotManager::ChangeBotSkill(short Skill, botent *bot) { static const char *SkillNames[5] = { "best", "good", "medium", "worse", "bad" }; if (bot && bot->pBot) { // Only change skill of a single bot bot->pBot->m_pBotSkill = &m_BotSkills[Skill]; bot->pBot->m_sSkillNr = Skill; conoutf("Skill of %s is now %s", bot->name, SkillNames[Skill]); return; } // Change skill of all bots loopv(bots) { if (!bots[i] || !bots[i]->pBot) continue; bots[i]->pBot->m_pBotSkill = &m_BotSkills[Skill]; bots[i]->pBot->m_sSkillNr = Skill; } // Change default bot skill m_sBotSkill = Skill; conoutf("Skill of all bots is now %s", SkillNames[Skill]); } void CBotManager::ViewBot() { // Check if this bot is still in game bool bFound = false; loopv(bots) { if (bots[i] == m_pBotToView) { bFound = true; break; } } if (!bFound) { DisableBotView(); return; } player1->state = CS_DEAD; // Fake dead player1->o = m_pBotToView->o; player1->o.z += 1.0f; player1->yaw = m_pBotToView->yaw; player1->pitch = m_pBotToView->pitch; player1->roll = m_pBotToView->roll; player1->radius = 0; // Don't collide player1->resetinterp(); } void CBotManager::DisableBotView() { m_pBotToView = NULL; respawnself(); player1->radius = 1.1f; } void CBotManager::CalculateMaxAStarCount() { if (WaypointClass.m_iWaypointCount > 0) // Are there any waypoints? { m_sMaxAStarBots = 8 - short(ceil((float)WaypointClass.m_iWaypointCount / 1000.0f)); if (m_sMaxAStarBots < 1) m_sMaxAStarBots = 1; } else m_sMaxAStarBots = 1; } void CBotManager::PickNextTrigger() { short lowest = -1; bool found0 = false; // True if found a trigger with nr 0 loopv(ents) { entity &e = ents[i]; if (OUTBORD(e.x, e.y)) continue; vec o(e.x, e.y, S(e.x, e.y)->floor+player1->eyeheight); node_s *pWptNearEnt = NULL; pWptNearEnt = WaypointClass.GetNearestTriggerWaypoint(o, 2.0f); if (pWptNearEnt) { if ((pWptNearEnt->sTriggerNr > 0) && ((pWptNearEnt->sTriggerNr < lowest) || (lowest == -1))) lowest = pWptNearEnt->sTriggerNr; if (pWptNearEnt->sTriggerNr == 0) found0 = true; } #ifdef WP_FLOOD pWptNearEnt = WaypointClass.GetNearestTriggerFloodWP(o, 2.0f); if (pWptNearEnt) { if ((pWptNearEnt->sTriggerNr > 0) && ((pWptNearEnt->sTriggerNr < lowest) || (lowest == -1))) lowest = pWptNearEnt->sTriggerNr; if (pWptNearEnt->sTriggerNr == 0) found0 = true; } #endif } if ((lowest == -1) && found0) lowest = 0; if (lowest != -1) m_sCurrentTriggerNr = lowest; } botent *CBotManager::CreateBot(const char *team, const char *skill, const char *name) { if (m_bInit) { Init(); m_bInit = false; } botent *m = newbotent(); if (!m) return NULL; loopi(NUMGUNS) m->ammo[i] = m->mag[i] = 0; m->lifesequence = 0; m->pBot = new CACBot; m->type = ENT_BOT; m->pBot->m_pMyEnt = m; m->pBot->m_iLastBotUpdate = 0; m->pBot->m_bSendC2SInit = false; if (name && *name) copystring(m->name, name, 16); else copystring(m->name, BotManager.GetBotName(), 16); updateclientname((playerent *)m); const char *tempteam = team && *team && strcmp(team, "random") ? team : BotManager.GetBotTeam(); m->team = team_base(teamatoi(tempteam)); setskin(m, m->team == TEAM_CLA ? rnd(4) : rnd(6), m->team); if (skill && *skill && strcmp(skill, "random")) { if (!strcasecmp(skill, "best")) m->pBot->m_sSkillNr = 0; else if (!strcasecmp(skill, "good")) m->pBot->m_sSkillNr = 1; else if (!strcasecmp(skill, "medium")) m->pBot->m_sSkillNr = 2; else if (!strcasecmp(skill, "worse")) m->pBot->m_sSkillNr = 3; else if (!strcasecmp(skill, "bad")) m->pBot->m_sSkillNr = 4; else { conoutf("Wrong skill specified. Should be best, good, medium, " "worse or bad"); conoutf("Using default skill instead..."); m->pBot->m_sSkillNr = BotManager.m_sBotSkill; } } else // No skill specified, use default m->pBot->m_sSkillNr = BotManager.m_sBotSkill; m->pBot->m_pBotSkill = &BotManager.m_BotSkills[m->pBot->m_sSkillNr]; // Sync waypoints m->pBot->SyncWaypoints(); m->pBot->Spawn(); bots.add(m); return m; } bool botmode() { if(m_botmode) return true; conoutf("the current game mode does not support bots"); return false; } // Bot manager class end void addbot(char *arg1, char *arg2, char *arg3) { if(!botmode()) return; botent *b = BotManager.CreateBot(arg1, arg2, arg3); if (b) conoutf("Bot connected: %s", b->name); else { conoutf("Error: Couldn't create bot!"); return; } } COMMAND(addbot, "sss"); void addnbot(char *arg1, char *arg2, char *arg3) { if(!botmode()) return; if (!arg1 || !arg1[0]) return; int i = atoi(arg1); while(i > 0) { addbot(arg2, arg3, NULL); i--; } } COMMAND(addnbot, "sss"); void botsshoot(int *Shoot) { switch(*Shoot) { case 0: BotManager.SetBotsShoot(false); conoutf("Bots won't shoot"); break; case 1: BotManager.SetBotsShoot(true); conoutf("Bots will shoot"); break; default: intret(BotManager.BotsShoot()); break; } } COMMAND(botsshoot, "i"); void idlebots(int *Idle) { switch(*Idle) { case 0: BotManager.SetIdleBots(false); conoutf("Bots aren't idle"); break; case 1: BotManager.SetIdleBots(true); conoutf("Bots are idle"); break; default: intret(BotManager.IdleBots()); break; } } COMMAND(idlebots, "i"); void kickbot(const char *szName) { if(!botmode()) return; if (!szName || !(*szName)) return; int iBotInd = -1; loopv(bots) { if (!bots[i]) continue; if (!strcmp(bots[i]->name, szName)) { iBotInd = i; break; } } if (iBotInd != -1) { botent *d = bots[iBotInd]; if(d->name[0]) conoutf("bot %s disconnected", d->name); delete d->pBot; bots.remove(iBotInd); freebotent(d); } } COMMAND(kickbot, "s"); void kickallbots(void) { BotManager.ClearStoredBots(); loopv(bots) { if (bots[i]) { if(bots[i]->name[0]) conoutf("bot %s disconnected", bots[i]->name); delete bots[i]->pBot; freebotent(bots[i]); } }; bots.setsize(0); } COMMAND(kickallbots, ""); void togglebotview(char *bot) { if(!botmode()) return; /** Disable in arena modes, this command causes the game to go in an "infinite loop" due to player1 automatically suiciding thus causing a new round to begin. */ if(m_arena) { conoutf("togglebotview is not allowed in %s", modestr(gamemode, modeacronyms > 0)); return; } if (BotManager.m_pBotToView) BotManager.DisableBotView(); else if (bot && *bot) { loopv(bots) { if (!bots[i]) continue; if (!strcmp(bots[i]->name, bot)) { BotManager.EnableBotView(bots[i]); break; } } } } COMMAND(togglebotview, "s"); void botskill(char *bot, char *skill) { if (!skill || !(*skill)) return; short SkillNr; if (!strcasecmp(skill, "best")) SkillNr = 0; else if (!strcasecmp(skill, "good")) SkillNr = 1; else if (!strcasecmp(skill, "medium")) SkillNr = 2; else if (!strcasecmp(skill, "worse")) SkillNr = 3; else if (!strcasecmp(skill, "bad")) SkillNr = 4; else { conoutf("Wrong skill specified. Should be best, good, medium, worse or bad"); return; } if (bot) { loopv(bots) { if (bots[i] && !strcmp(bots[i]->name, bot)) { BotManager.ChangeBotSkill(SkillNr, bots[i]); break; } } } else BotManager.ChangeBotSkill(SkillNr); } COMMAND(botskill, "ss"); void botskillall(char *skill) { botskill(NULL, skill); } COMMAND(botskillall, "s"); #ifndef RELEASE_BUILD void telebot(void) { vec dest = player1->o, forward, right, up; vec angles(player1->pitch, player1->yaw, player1->roll); traceresult_s tr; AnglesToVectors(angles, forward, right, up); forward.mul(4.0f); dest.add(forward); TraceLine(player1->o, dest, player1, true, &tr); if (!tr.collided) { // Get the first bot loopv(bots) { if (!bots[i] || !bots[i]->pBot) continue; bots[i]->o = tr.end; bots[i]->resetinterp(); break; } } } COMMAND(telebot, ""); void testvisible(int iDir) { vec angles, end, forward, right, up; traceresult_s tr; int Dir; switch(iDir) { case 0: default: Dir = FORWARD; break; case 1: Dir = BACKWARD; break; case 2: Dir = LEFT; break; case 3: Dir = RIGHT; break; case 4: Dir = UP; break; case 5: Dir = DOWN; break; } vec from = player1->o; from.z -= (player1->eyeheight - 1.25f); end = from; makevec(&angles, player1->pitch, player1->yaw, player1->roll); angles.x=0; if (Dir & UP) angles.x = WrapXAngle(angles.x + 45.0f); else if (Dir & DOWN) angles.x = WrapXAngle(angles.x - 45.0f); if ((Dir & FORWARD) || (Dir & BACKWARD)) { if (Dir & BACKWARD) angles.y = WrapYZAngle(angles.y + 180.0f); if (Dir & LEFT) { if (Dir & FORWARD) angles.y = WrapYZAngle(angles.y - 45.0f); else angles.y = WrapYZAngle(angles.y + 45.0f); } else if (Dir & RIGHT) { if (Dir & FORWARD) angles.y = WrapYZAngle(angles.y + 45.0f); else angles.y = WrapYZAngle(angles.y - 45.0f); } } else if (Dir & LEFT) angles.y = WrapYZAngle(angles.y - 90.0f); else if (Dir & RIGHT) angles.y = WrapYZAngle(angles.y + 90.0f); else if (Dir & UP) angles.x = WrapXAngle(angles.x + 90.0f); else if (Dir & DOWN) angles.x = WrapXAngle(angles.x - 90.0f); AnglesToVectors(angles, forward, right, up); forward.mul(20.0f); end.add(forward); TraceLine(from, end, player1, false, &tr); //debugbeam(from, tr.end); char sz[250]; sprintf(sz, "dist: %f; hit: %d", GetDistance(from, tr.end), tr.collided); condebug(sz); } COMMANDF(testvisible, "i", (int *dir) { testvisible(*dir); }); #endif assaultcube-1.2.0.2.1/source/src/client.cpp000066400000000000000000000617151352165075300204160ustar00rootroot00000000000000// client.cpp, mostly network related client game code #include "cube.h" #include "bot/bot.h" VAR(connected, 1, 0, 0); ENetHost *clienthost = NULL; ENetPeer *curpeer = NULL, *connpeer = NULL; int connmillis = 0, connattempts = 0, discmillis = 0; SVAR(curdemofile, "n/a"); extern bool clfail, cllock; extern int searchlan; int getclientnum() { return player1 ? player1->clientnum : -1; } bool multiplayer(const char *op) { // check not correct on listen server? if(curpeer && op) conoutf("%s%s%s not available in multiplayer", *op ? "\"" : "", *op ? op : "operation", *op ? "\"" : ""); return curpeer!=NULL; } bool allowedittoggle() { bool allow = !curpeer || gamemode==1; if(!allow) conoutf("editing in multiplayer requires coopedit mode (1)"); return allow; } void throttle(); VARF(throttle_interval, 0, 5, 30, throttle()); VARF(throttle_accel, 0, 2, 32, throttle()); VARF(throttle_decel, 0, 2, 32, throttle()); void throttle() { if(!curpeer) return; ASSERT(ENET_PEER_PACKET_THROTTLE_SCALE==32); enet_peer_throttle_configure(curpeer, throttle_interval*1000, throttle_accel, throttle_decel); } string clientpassword = ""; int connectrole = CR_DEFAULT; bool modprotocol = false; void abortconnect() { if(!connpeer) return; clientpassword[0] = '\0'; connectrole = CR_DEFAULT; if(connpeer->state!=ENET_PEER_STATE_DISCONNECTED) enet_peer_reset(connpeer); connpeer = NULL; #if 0 if(!curpeer) { enet_host_destroy(clienthost); clienthost = NULL; } #endif } void connectserv_(const char *servername, int serverport = 0, const char *password = NULL, int role = CR_DEFAULT) { if(serverport <= 0) serverport = CUBE_DEFAULT_SERVER_PORT; if(watchingdemo) enddemoplayback(); if(!clfail && cllock && searchlan<2) return; if(connpeer) { conoutf("aborting connection attempt"); abortconnect(); } connectrole = role; copystring(clientpassword, password ? password : ""); ENetAddress address; address.port = serverport; if(servername) { addserver(servername, serverport, 0); conoutf("\f2attempting to %sconnect to \f5%s\f4:%d\f2", role==CR_DEFAULT?"":"\f8admin\f2", servername, serverport); if(!resolverwait(servername, &address)) { conoutf("\f2could \f3not resolve\f2 server \f5%s\f2", servername); clientpassword[0] = '\0'; connectrole = CR_DEFAULT; return; } } else { conoutf("\f2attempting to connect over \f1LAN\f2"); address.host = ENET_HOST_BROADCAST; } if(!clienthost) clienthost = enet_host_create(NULL, 2, 3, 0, 0); if(clienthost) { connpeer = enet_host_connect(clienthost, &address, 3, 0); enet_host_flush(clienthost); connmillis = totalmillis; connattempts = 0; if(!m_mp(gamemode)) gamemode = GMODE_TEAMDEATHMATCH; } else { conoutf("\f2could \f3not connect\f2 to server"); clientpassword[0] = '\0'; connectrole = CR_DEFAULT; } } void connectserv(char *servername, int *serverport, char *password) { modprotocol = false; connectserv_(servername, *serverport, password); } void connectadmin(char *servername, int *serverport, char *password) { modprotocol = false; if(!password[0]) return; connectserv_(servername, *serverport, password, CR_ADMIN); } void lanconnect() { modprotocol = false; connectserv_(NULL); } void modconnectserv(char *servername, int *serverport, char *password) { modprotocol = true; connectserv_(servername, *serverport, password); } void modconnectadmin(char *servername, int *serverport, char *password) { modprotocol = true; if(!password[0]) return; connectserv_(servername, *serverport, password, CR_ADMIN); } void modlanconnect() { modprotocol = true; connectserv_(NULL); } void whereami() { conoutf("you are at (%.2f,%.2f)", player1->o.x, player1->o.y); } void disconnect(int onlyclean, int async) { bool cleanup = onlyclean!=0; if(curpeer) { if(!discmillis) { enet_peer_disconnect(curpeer, DISC_NONE); enet_host_flush(clienthost); discmillis = totalmillis; } if(curpeer->state!=ENET_PEER_STATE_DISCONNECTED) { if(async) return; enet_peer_reset(curpeer); } curpeer = NULL; discmillis = 0; connected = 0; conoutf("disconnected"); cleanup = true; } if(cleanup) { player1->clientnum = -1; player1->lifesequence = 0; player1->clientrole = CR_DEFAULT; lastpm = -1; kickallbots(); loopv(players) zapplayer(players[i]); clearvote(); audiomgr.clearworldsounds(false); localdisconnect(); } #if 0 if(!connpeer && clienthost) { enet_host_destroy(clienthost); clienthost = NULL; } #endif if(!onlyclean) localconnect(); exechook(HOOK_SP_MP, "onDisconnect", "%d", -1); } void trydisconnect() { if(connpeer) { conoutf("aborting connection attempt"); abortconnect(); return; } if(!curpeer) { conoutf("not connected"); return; } conoutf("attempting to disconnect..."); disconnect(0, !discmillis); } void _toserver(char *text, int msg, int msgt) { bool toteam = text && text[0] == '%' && (m_teammode || team_isspect(player1->team)); if(!toteam && text[0] == '%' && strlen(text) > 1) text++; // convert team-text to normal-text if no team-mode is active if(toteam) text++; filtertext(text, text, FTXT__CHAT); trimtrailingwhitespace(text); if(servstate.mastermode == MM_MATCH && servstate.matchteamsize && !team_isactive(player1->team) && !(player1->team == TEAM_SPECT && player1->clientrole == CR_ADMIN)) toteam = true; // spect chat if(*text) { if(msg == SV_TEXTME) conoutf("\f%d%s %s", toteam ? 1 : 0, colorname(player1), highlight(text)); else conoutf("%s:\f%d %s", colorname(player1), toteam ? 1 : 0, highlight(text)); addmsg(toteam ? msgt : msg, "rs", text); } } void toserver(char *text) { _toserver(text, SV_TEXT, SV_TEAMTEXT); } void toserverme(char *text) { _toserver(text, SV_TEXTME, SV_TEAMTEXTME); } void echo(char *text) { char *b, *s = strtok_r(text, "\n", &b); do { conoutf("%s", s ? s : ""); s = strtok_r(NULL, "\n", &b); } while(s); } VARP(allowhudechos, 0, 1, 1); void hudecho(char *text) { char *b, *s = strtok_r(text, "\n", &b); void (*outf)(const char *s, ...) = allowhudechos ? hudoutf : conoutf; do { outf("%s", s ? s : ""); s = strtok_r(NULL, "\n", &b); } while(s); } void pm(char *text) { if(!text || !text[0]) return; int cn = -1; char digit; while ((digit = *text++) != '\0') { if (digit < '0' || digit > '9') break; if(cn < 0) cn = 0; else cn *= 10; cn += digit - '0'; } playerent *to = getclient(cn); if(!to) { conoutf("invalid client number specified"); return; } if(!isspace(digit)) { --text; } // FIXME: /*if(!text || !text[0] || !isdigit(text[0])) return; int cn = -1; char *numend = strpbrk(text, " \t"); if(!numend) return; string cnbuf; copystring(cnbuf, text, min(numend-text+1, MAXSTRLEN)); cn = atoi(cnbuf); playerent *to = getclient(cn); if(!to) { conoutf("invalid client number specified"); return; } if(*numend) numend++;*/ // :FIXME filtertext(text, text, FTXT__CHAT); trimtrailingwhitespace(text); addmsg(SV_TEXTPRIVATE, "ris", cn, text); conoutf("to %s (PM):\f9 %s", colorname(to), highlight(text)); } COMMAND(pm, "c"); COMMAND(echo, "c"); COMMAND(hudecho, "c"); COMMANDN(say, toserver, "c"); COMMANDN(me, toserverme, "c"); COMMANDN(connect, connectserv, "sis"); COMMAND(connectadmin, "sis"); COMMAND(lanconnect, ""); COMMANDN(modconnect, modconnectserv, "sis"); COMMAND(modconnectadmin, "sis"); COMMAND(modlanconnect, ""); COMMANDN(disconnect, trydisconnect, ""); COMMAND(whereami, ""); void current_version(char *text) { int version = atoi(text); if (version && AC_VERSION messages; void addmsg(int type, const char *fmt, ...) { static uchar buf[MAXTRANS]; ucharbuf p(buf, MAXTRANS); putint(p, type); int numi = 1, nums = 0; bool reliable = false; if(fmt) { va_list args; va_start(args, fmt); while(*fmt) switch(*fmt++) { case 'r': reliable = true; break; case 'v': { int n = va_arg(args, int); int *v = va_arg(args, int *); loopi(n) putint(p, v[i]); numi += n; break; } case 'i': { int n = isdigit(*fmt) ? *fmt++-'0' : 1; loopi(n) putint(p, va_arg(args, int)); numi += n; break; } case 'a': { int n = isdigit(*fmt) ? *fmt++-'0' : 1; loopi(n) putaint(p, va_arg(args, int)); numi += n; break; } case 's': { const char *t = va_arg(args, const char *); if(t) sendstring(t, p); nums++; break; } } va_end(args); } int num = nums?0:numi, msgsize = msgsizelookup(type); if(msgsize && num!=msgsize) { fatal("inconsistent msg size for %d (%d != %d)", type, num, msgsize); } int len = p.length(); messages.add(len&0xFF); messages.add((len>>8)|(reliable ? 0x80 : 0)); loopi(len) messages.add(buf[i]); } static int lastupdate = -1000, lastping = 0; bool sendmapidenttoserver = false; void sendpackettoserv(int chan, ENetPacket *packet) { if(curpeer) enet_peer_send(curpeer, chan, packet); else localclienttoserver(chan, packet); } void c2skeepalive() { if(clienthost && (curpeer || connpeer)) enet_host_service(clienthost, NULL, 0); } extern string masterpwd; bool sv_pos = true; void c2sinfo(playerent *d) // send update to the server { if(d->clientnum<0) return; // we haven't had a welcome message from the server yet if(totalmillis-lastupdate<40) return; // don't update faster than 25fps if(d->state==CS_ALIVE || d->state==CS_EDITING) { packetbuf q(100); int cn = d->clientnum, x = (int)(d->o.x*DMF), // quantize coordinates to 1/16th of a cube, between 1 and 3 bytes y = (int)(d->o.y*DMF), z = (int)((d->o.z - d->eyeheight)*DMF), ya = (int)((512 * d->yaw) / 360.0f), pi = (int)((127 * d->pitch) / 90.0f), r = (int)(31*d->roll/20), dxt = (int)(d->vel.x*DVELF), dyt = (int)(d->vel.y*DVELF), dzt = (int)(d->vel.z*DVELF), dx = dxt - d->vel_t.i[0], dy = dyt - d->vel_t.i[1], dz = dzt - d->vel_t.i[2], // pack rest in 1 int: strafe:2, move:2, onfloor:1, onladder: 1 f = (d->strafe&3) | ((d->move&3)<<2) | (((int)d->onfloor)<<4) | (((int)d->onladder)<<5) | ((d->lifesequence&1)<<6) | (((int)d->crouching)<<7), g = (dx?1:0) | ((dy?1:0)<<1) | ((dz?1:0)<<2) | ((r?1:0)<<3) | (((int)d->scoping)<<4) | (((int)d->shoot)<<5); d->vel_t.i[0] = dxt; d->vel_t.i[1] = dyt; d->vel_t.i[2] = dzt; int usefactor = sfactor < 7 ? 7 : sfactor, sizexy = 1 << (usefactor + 4); if(cn >= 0 && cn < 32 && usefactor <= 7 + 3 && // map size 7..10 x >= 0 && x < sizexy && y >= 0 && y < sizexy && z >= -2047 && z <= 2047 && ya >= 0 && ya < 512 && pi >= -128 && pi <= 127 && r >= -32 && r <= 31 && dx >= -8 && dx <= 7 && // FIXME dy >= -8 && dy <= 7 && dz >= -8 && dz <= 7) { // compact POS packet bool noroll = !r, novel = !dx && !dy && !dz; bitbuf b(q); putint(q, SV_POSC); b.putbits(5, cn); b.putbits(2, usefactor - 7); b.putbits(usefactor + 4, x); b.putbits(usefactor + 4, y); b.putbits(9, ya); b.putbits(8, pi + 128); b.putbits(1, noroll ? 1 : 0); if(!noroll) b.putbits(6, r + 32); b.putbits(1, novel ? 1 : 0); if(!novel) { b.putbits(4, dx + 8); b.putbits(4, dy + 8); b.putbits(4, dz + 8); } b.putbits(8, f); b.putbits(1, z < 0 ? 1 : 0); if(z < 0) z = -z; // z is encoded with 3..10 bits minimum (fitted to byte boundaries), or full 11 bits if necessary int s = (b.rembits() - 1 + 8) % 8; if(s < 3) s += 8; if(z >= (1 << s)) s = 11; b.putbits(1, s == 11 ? 1 : 0); b.putbits(s, z); b.putbits(1, d->scoping ? 1 : 0); b.putbits(1, d->shoot ? 1 : 0); } else { // classic POS packet putint(q, SV_POS); putint(q, d->clientnum); putuint(q, x); putuint(q, y); putuint(q, z); putuint(q, (int)d->yaw); putint(q, (int)d->pitch); putuint(q, g); if (r) putint(q, (int)(125*d->roll/20)); if (dx) putint(q, dx); if (dy) putint(q, dy); if (dz) putint(q, dz); putuint(q, f); } sendpackettoserv(0, q.finalize()); d->shoot = false; } if(sendmapidenttoserver || messages.length() || totalmillis-lastping>250) { packetbuf p(MAXTRANS); if(sendmapidenttoserver) // new map { p.reliable(); putint(p, SV_MAPIDENT); putint(p, maploaded); putint(p, hdr.maprevision); sendmapidenttoserver = false; } int i = 0; while(i < messages.length()) // send messages collected during the previous frames { int len = messages[i] | ((messages[i+1]&0x7F)<<8); if(p.remaining() < len) break; if(messages[i+1]&0x80) p.reliable(); p.put(&messages[i+2], len); i += 2 + len; } messages.remove(0, i); if(totalmillis-lastping>250) { putint(p, SV_PING); putint(p, totalmillis); lastping = totalmillis; } if(p.length()) sendpackettoserv(1, p.finalize()); } if(clienthost) enet_host_flush(clienthost); lastupdate = totalmillis; } int getbuildtype() { return (isbigendian() ? 0x80 : 0 )|(adler((unsigned char *)guns, sizeof(guns)) % 31 << 8)| #ifdef WIN32 0x40 | #endif #ifdef __APPLE__ 0x20 | #endif #ifdef _DEBUG 0x08 | #endif #ifdef __GNUC__ 0x04 | #endif 0; } void sendintro() { packetbuf p(MAXTRANS, ENET_PACKET_FLAG_RELIABLE); putint(p, SV_CONNECT); putint(p, AC_VERSION); putint(p, getbuildtype()); sendstring(player1->name, p); sendstring(genpwdhash(player1->name, clientpassword, sessionid), p); sendstring(!lang || strlen(lang) != 2 ? "" : lang, p); putint(p, connectrole); clientpassword[0] = '\0'; connectrole = CR_DEFAULT; putint(p, player1->nextprimweap->type); loopi(2) putint(p, player1->skin(i)); sendpackettoserv(1, p.finalize()); } void gets2c() // get updates from the server { ENetEvent event; if(!clienthost || (!curpeer && !connpeer)) return; if(connpeer && totalmillis/3000 > connmillis/3000) { conoutf("attempting to connect..."); connmillis = totalmillis; ++connattempts; if(connattempts > 3) { conoutf("\f3could not connect to server"); abortconnect(); return; } } while(clienthost!=NULL && enet_host_service(clienthost, &event, 0)>0) switch(event.type) { case ENET_EVENT_TYPE_CONNECT: disconnect(1); curpeer = connpeer; connpeer = NULL; connected = 1; conoutf("connected to server"); exechook(HOOK_SP_MP, "onConnect", "%d", -1); throttle(); if(editmode) toggleedit(true); break; case ENET_EVENT_TYPE_RECEIVE: { extern packetqueue pktlogger; pktlogger.queue(event.packet); if(discmillis) conoutf("attempting to disconnect..."); else servertoclient(event.channelID, event.packet->data, (int)event.packet->dataLength); // destroyed in logger //enet_packet_destroy(event.packet); break; } case ENET_EVENT_TYPE_DISCONNECT: { extern const char *disc_reason(int reason); if(event.data>=DISC_NUM) event.data = DISC_NONE; if(event.peer==connpeer) { conoutf("\f3could not connect to server"); abortconnect(); } else { if(!discmillis || event.data) conoutf("\f3server network error, disconnecting (%s) ...", disc_reason(event.data)); disconnect(); } return; } default: break; } } #if 0 // for AUTH: vector authkeys; VARP(autoauth, 0, 1, 1); authkey *findauthkey(const char *desc) { loopv(authkeys) if(!strcmp(authkeys[i]->desc, desc) && !strcmp(authkeys[i]->name, player1->name)) return authkeys[i]; loopv(authkeys) if(!strcmp(authkeys[i]->desc, desc)) return authkeys[i]; return NULL; } void addauthkey(const char *name, const char *key, const char *desc) { loopvrev(authkeys) if(!strcmp(authkeys[i]->desc, desc) && !strcmp(authkeys[i]->name, name)) delete authkeys.remove(i); if(name[0] && key[0]) authkeys.add(new authkey(name, key, desc)); } bool _hasauthkey(const char *name, const char *desc) { if(!name[0] && !desc[0]) return authkeys.length() > 0; loopvrev(authkeys) if(!strcmp(authkeys[i]->desc, desc) && !strcmp(authkeys[i]->name, name)) return true; return false; } void genauthkey(const char *secret) { if(!secret[0]) { conoutf("you must specify a secret password"); return; } vector privkey, pubkey; genprivkey(secret, privkey, pubkey); conoutf("private key: %s", privkey.getbuf()); conoutf("public key: %s", pubkey.getbuf()); } void saveauthkeys() { if(authkeys.length()) { stream *f = openfile("config/auth.cfg", "w"); if(!f) { conoutf("failed to open config/auth.cfg for writing"); return; } loopv(authkeys) { authkey *a = authkeys[i]; f->printf("authkey \"%s\" \"%s\" \"%s\"\n", a->name, a->key, a->desc); } conoutf("saved authkeys to config/auth.cfg"); delete f; } else conoutf("you need to use 'addauthkey USER KEY DESC' first; one DESC 'public', one DESC empty(=private)"); } bool tryauth(const char *desc) { authkey *a = findauthkey(desc); if(!a) return false; a->lastauth = lastmillis; addmsg(SV_AUTHTRY, "rss", a->desc, a->name); return true; } COMMANDN(authkey, addauthkey, "sss"); COMMANDF(hasauthkey, "ss", (char *name, char *desc) { intret(_hasauthkey(name, desc) ? 1 : 0); }); COMMAND(genauthkey, "s"); COMMAND(saveauthkeys, ""); COMMANDF(auth, "s", (char *desc) { intret(tryauth(desc)); }); // :for AUTH #endif // sendmap/getmap commands, should be replaced by more intuitive map downloading vector securemaps; void resetsecuremaps() { securemaps.deletearrays(); } void securemap(char *map) { if(map) securemaps.add(newstring(map)); } bool securemapcheck(const char *map, bool msg) { if(strstr(map, "maps/")==map || strstr(map, "maps\\")==map) map += strlen("maps/"); loopv(securemaps) if(!strcmp(securemaps[i], map)) { if(msg) { conoutf("\f3Map \f4%s\f3 is secured. This means you CAN'T send, receive or overwrite it.", map); if(connected) { conoutf("\f3If you get this error often, you (or the server) may be running an outdated game."); conoutf("\f3You can check for updates at \f1http://assault.cubers.net/download.html"); } } return true; } return false; } void sendmap(char *mapname) { if(!*mapname) mapname = getclientmap(); if(securemapcheck(mapname)) return; if(gamemode == GMODE_COOPEDIT && !strcmp(getclientmap(), mapname)) save_world(mapname, true, false); // skip optimisations, don't add undos int mapsize, cfgsize, cfgsizegz, revision; uchar *mapdata = readmap(path(mapname), &mapsize, &revision); if(!mapdata) return; uchar *cfgdata = readmcfggz(path(mapname), &cfgsize, &cfgsizegz); if(!cfgdata) { cfgsize = 0; cfgsizegz = 0; } packetbuf p(MAXTRANS + mapsize + cfgsizegz, ENET_PACKET_FLAG_RELIABLE); putint(p, SV_SENDMAP); sendstring(mapname, p); putint(p, mapsize); putint(p, cfgsize); putint(p, cfgsizegz); putint(p, revision); if(MAXMAPSENDSIZE - p.length() < mapsize + cfgsizegz || cfgsize > MAXCFGFILESIZE) { conoutf("map %s is too large to send", mapname); delete[] mapdata; if(cfgsize) delete[] cfgdata; return; } p.put(mapdata, mapsize); delete[] mapdata; if(cfgsizegz) { p.put(cfgdata, cfgsizegz); delete[] cfgdata; } sendpackettoserv(2, p.finalize()); conoutf("sending map %s to server...", mapname); } void getmap(char *name, char *callback) { if((!name || !*name) || (connected && !strcmp(name, getclientmap())) ) { conoutf("requesting map from server..."); packetbuf p(10, ENET_PACKET_FLAG_RELIABLE); putint(p, SV_RECVMAP); sendpackettoserv(2, p.finalize()); } else { requirepackage(PCK_MAP, name); if(downloadpackages(false)) { if(callback && *callback) execute(callback); conoutf("map %s installed successfully", name); } else conoutf("\f3map download failed"); } } void deleteservermap(char *mapname) { const char *name = behindpath(mapname); if(!*name || securemapcheck(name)) return; addmsg(SV_REMOVEMAP, "rs", name); } string demosubpath; void getdemo(int *idx, char *dsp) { if(!multiplayer(NULL)) { conoutf("\f3Getting demo from server is not available in singleplayer"); return; } if(dsp && dsp[0]) formatstring(demosubpath)("%s/", dsp); else copystring(demosubpath, ""); if(*idx<=0) conoutf("getting demo..."); else conoutf("getting demo %d...", *idx); addmsg(SV_GETDEMO, "ri", *idx); } void listdemos() { if(!multiplayer(NULL)) { conoutf("\f3Listing demos from server is not available in singleplayer"); return; } conoutf("listing demos..."); addmsg(SV_LISTDEMOS, "r"); } void shiftgametime(int newmillis) { if(!watchingdemo) { conoutf("You have to be watching a demo to change game time"); return; } newmillis = max(0, newmillis); if(newmillis > gametimemaximum) { conoutf("Invalid time specified"); return; } int gamemillis = gametimecurrent + (lastmillis - lastgametimeupdate); if(newmillis < gamemillis) { // if rewinding if(!curdemofile || !curdemofile[0]) return; watchingdemo = false; callvote(SA_MAP, curdemofile, "-1", "0"); skipmillis = newmillis; } else { skipmillis = newmillis - gamemillis; } } void setminutesremaining(char *minutes) { if(*minutes) shiftgametime(gametimemaximum - ATOI(minutes) * 60000); } COMMANDN(setmr, setminutesremaining, "s"); void rewinddemo(char *seconds) { int gamemillis = gametimecurrent+(lastmillis-lastgametimeupdate); if(*seconds) shiftgametime(gamemillis - ATOI(seconds) * 1000); } COMMANDN(rewind, rewinddemo, "s"); COMMAND(sendmap, "s"); COMMAND(getmap, "ss"); COMMAND(deleteservermap, "s"); COMMAND(resetsecuremaps, ""); COMMAND(securemap, "s"); COMMAND(getdemo, "is"); COMMAND(listdemos, ""); COMMANDF(watchingdemo, "", () { intret(watchingdemo); }); COMMANDF(systime, "", () { result(numtime()); }); COMMANDF(timestamp, "", () { result(timestring(true, "%Y %m %d %H %M %S")); }); COMMANDF(datestring, "", () { result(timestring(true, "%c")); }); COMMANDF(timestring, "", () { const char *res = timestring(true, "%H:%M:%S"); result(res[0] == '0' ? res + 1 : res); }); COMMANDF(millis, "", () { intret(totalmillis); }); assaultcube-1.2.0.2.1/source/src/clientgame.cpp000066400000000000000000001606741352165075300212540ustar00rootroot00000000000000// clientgame.cpp: core game related stuff #include "cube.h" #include "bot/bot.h" int nextmode = 0; // nextmode becomes gamemode after next map load VAR(gamemode, 1, 0, 0); VAR(nextGameMode, 1, 0, 0); VARP(modeacronyms, 0, 1, 1); flaginfo flaginfos[2]; entitystats_s clentstats; mapdim_s clmapdims; // min/max X/Y and delta X/Y and min/max Z void mode(int *n) { nextmode = *n; nextGameMode = nextmode; if(m_mp(*n) || !multiplayer()) addmsg(SV_GAMEMODE, "ri", *n); } COMMAND(mode, "i"); bool intermission = false; int arenaintermission = 0; struct serverstate servstate = { 0 }; playerent *player1 = newplayerent(); // our client vector players; // other clients int lastmillis = 0, totalmillis = 0, skipmillis = 0; int lasthit = 0; int curtime = 0; string clientmap = ""; int spawnpermission = SP_WRONGMAP; char *getclientmap() { return clientmap; } int getclientmode() { return gamemode; } extern bool sendmapidenttoserver; void setskin(playerent *pl, int skin, int team) { if(!pl) return; pl->setskin(team, skin); } extern char *global_name; bool duplicatename(playerent *d, char *name = NULL) { if(!name) name = d->name; if(d!=player1 && !strcmp(name, player1->name) && !watchingdemo) return true; if(!strcmp(name, "you")) return true; loopv(players) if(players[i] && d!=players[i] && !strcmp(name, players[i]->name)) return true; global_name = player1->name; // this certainly is not the best place to put this return false; } char *colorname(playerent *d, char *name, const char *prefix) { if(!name) name = d->name; if(name[0] && !duplicatename(d, name)) return name; static string cname[4]; static int num = 0; num = (num + 1) % 4; formatstring(cname[num])("%s%s \fs\f6(%d)\fr", prefix, name, d->clientnum); return cname[num]; } char *colorping(int ping) { static string cping; formatstring(cping)("\fs\f%d%d\fr", ping <= 500 ? 0 : ping <= 1000 ? 2 : 3, ping); return cping; } char *colorpj(int pj) { static string cpj; formatstring(cpj)("\fs\f%d%d\fr", pj <= 90 ? 0 : pj <= 170 ? 2 : 3, pj); return cpj; } const char *highlight(const char *text) { static char result[MAXTRANS + 10]; const char *marker = getalias("HIGHLIGHT"), *sep = " ,;:!\"'"; if(!marker || !strstr(text, player1->name)) return text; defformatstring(subst)("\fs%s%s\fr", marker, player1->name); char *temp = newstring(text); char *b, *s = strtok_r(temp, sep, &b), *l = temp, *c, *r = result; result[0] = '\0'; while(s) { if(!strcmp(s, player1->name)) { if(MAXTRANS - strlen(result) > strlen(subst) + (s - l)) { for(c = l; c < s; c++) *r++ = text[c - temp]; *r = '\0'; strcat(r, subst); } l = s + strlen(s); } s = strtok_r(NULL, sep, &b); } if(MAXTRANS - strlen(result) > strlen(text) - (l - temp)) strcat(result, text + (l - temp)); delete[] temp; return *result ? result : text; } void ignore(int *cn) { playerent *d = getclient(*cn); if(d && d != player1) d->ignored = true; } void listignored() { string pl; pl[0] = '\0'; loopv(players) if(players[i] && players[i]->ignored) concatformatstring(pl, ", %s", colorname(players[i])); if(*pl) conoutf("ignored players: %s", pl + 2); else conoutf("no players are ignored"); } void clearignored(int *cn) { loopv(players) if(players[i] && (*cn < 0 || *cn == i)) players[i]->ignored = false; } void muteplayer(int *cn) { playerent *d = getclient(*cn); if(d && d != player1) d->muted = true; } void listmuted() { string pl; pl[0] = '\0'; loopv(players) if(players[i] && players[i]->muted) concatformatstring(pl, ", %s", colorname(players[i])); if(*pl) conoutf("muted players: %s", pl + 2); else conoutf("no players are muted"); } void clearmuted(char *cn) { loopv(players) if(players[i] && (*cn < 0 || *cn == i)) players[i]->muted = false; } COMMAND(ignore, "i"); COMMAND(listignored, ""); COMMAND(clearignored, "i"); COMMAND(muteplayer, "i"); COMMAND(listmuted, ""); COMMAND(clearmuted, "i"); void newname(const char *name) { if(name[0]) { string tmpname; filtertext(tmpname, name, FTXT__PLAYERNAME, MAXNAMELEN); exechook(HOOK_SP, "onNameChange", "%d \"%s\"", player1->clientnum, tmpname); copystring(player1->name, tmpname);//12345678901234// if(!player1->name[0]) copystring(player1->name, "unarmed"); updateclientname(player1); addmsg(SV_SWITCHNAME, "rs", player1->name); } else conoutf("your name is: %s", player1->name); } SVARFF(curname, { curname = exchangestr(curname, player1->name); }, {} ); int teamatoi(const char *name) { return getlistindex(name, teamnames, true, -1); } void newteam(char *name) { if(*name) { int nt = teamatoi(name); if(nt == player1->team) return; // same team if(!team_isvalid(nt)) { conoutf("\f3\"%s\" is not a valid team name or number", name); return; } if(player1->state == CS_EDITING) conoutf("you can't change team while editing"); else addmsg(SV_SWITCHTEAM, "ri", nt); } else conoutf("your team is: %s", team_string(player1->team)); } void benchme() { if(team_isactive(player1->team) && servstate.mastermode == MM_MATCH) addmsg(SV_SWITCHTEAM, "ri", team_tospec(player1->team)); } int _setskin(int s, int t) { setskin(player1, s, t); addmsg(SV_SWITCHSKIN, "rii", player1->skin(0), player1->skin(1)); return player1->skin(t); } COMMANDF(skin_cla, "i", (int *s) { intret(_setskin(*s, TEAM_CLA)); }); COMMANDF(skin_rvsf, "i", (int *s) { intret(_setskin(*s, TEAM_RVSF)); }); COMMANDF(skin, "i", (int *s) { intret(_setskin(*s, player1->team)); }); void curmodeattr(char *attr) { if(!strcmp(attr, "team")) { intret(m_teammode); return; } else if(!strcmp(attr, "arena")) { intret(m_arena); return; } else if(!strcmp(attr, "flag")) { intret(m_flags); return; } else if(!strcmp(attr, "bot")) { intret(m_botmode); return; } intret(0); } COMMANDN(team, newteam, "s"); COMMANDN(name, newname, "s"); COMMAND(benchme, ""); COMMANDF(isclient, "i", (int *cn) { intret(getclient(*cn) != NULL ? 1 : 0); } ); COMMANDF(curmastermode, "", (void) { intret(servstate.mastermode); }); COMMANDF(curautoteam, "", (void) { intret(servstate.autoteam); }); COMMAND(curmodeattr, "s"); COMMANDF(curmap, "", (void) { result(behindpath(getclientmap())); }); COMMANDF(curplayers, "", (void) { intret(players.length() + 1); }); VARP(showscoresondeath, 0, 1, 1); VARP(autoscreenshot, 0, 0, 1); void stopdemo() { if(watchingdemo) enddemoplayback(); else conoutf("not playing a demo"); } COMMAND(stopdemo, ""); // macros for playerinfo() & teaminfo(). Use this to replace pstats_xxx ? #define ATTR_INT(name, attribute) if(!strcmp(attr, #name)) { intret(attribute); return; } #define ATTR_FLOAT(name, attribute) if(!strcmp(attr, #name)) { floatret(attribute); return; } #define ATTR_STR(name, attribute) if(!strcmp(attr, #name)) { result(attribute); return; } void playerinfo(int *cn, const char *attr) { if(!*attr || !attr) return; int clientnum = *cn; // get player clientnum playerent *p = clientnum < 0 ? player1 : getclient(clientnum); if(!p) { if(!m_botmode && multiplayer(NULL)) // bot clientnums are still glitchy, causing this message to sometimes appear in offline/singleplayer when it shouldn't??? -Bukz 2012may conoutf("invalid clientnum cn: %d attr: %s", clientnum, attr); return; } if(p == player1) { ATTR_INT(magcontent, p->weaponsel->mag); ATTR_INT(ammo, p->weaponsel->ammo); ATTR_INT(primary, p->primary); ATTR_INT(curweapon, p->weaponsel->type); ATTR_INT(nextprimary, p->nextprimary); } if(p == player1 || (team_base(p->team) == team_base(player1->team) && m_teammode) || player1->team == TEAM_SPECT || m_coop) { ATTR_INT(health, p->health); ATTR_INT(armour, p->armour); ATTR_INT(attacking, p->attacking); ATTR_INT(scoping, p->scoping); ATTR_FLOAT(x, p->o.x); ATTR_FLOAT(y, p->o.y); ATTR_FLOAT(z, p->o.z); } ATTR_STR(name, p->name); ATTR_INT(team, p->team); ATTR_INT(ping, p->ping); ATTR_INT(pj, p->plag); ATTR_INT(state, p->state); ATTR_INT(role, p->clientrole); ATTR_INT(frags, p->frags); ATTR_INT(flags, p->flagscore); ATTR_INT(points, p->points); ATTR_INT(deaths, p->deaths); ATTR_INT(tks, p->tks); ATTR_INT(alive, p->state == CS_ALIVE ? 1 : 0); ATTR_INT(spect, p->team == TEAM_SPECT || p->spectatemode == SM_FLY ? 1 : 0); ATTR_INT(cn, p->clientnum); // only useful to get player1's client number. ATTR_INT(skin_cla, p->skin(TEAM_CLA)); ATTR_INT(skin_rvsf, p->skin(TEAM_RVSF)); ATTR_INT(skin, p->skin(player1->team)); string addrstr = ""; uint2ip(p->address, addr); if(addr[3] != 0 || player1->clientrole==CR_ADMIN) formatstring(addrstr)("%d.%d.%d.%d", addr[0], addr[1], addr[2], addr[3]); // full IP else formatstring(addrstr)("%d.%d.%d.x", addr[0], addr[1], addr[2]); // censored IP ATTR_STR(ip, addrstr); conoutf("invalid attribute: %s", attr); } void playerinfolocal(const char *attr) { int cn = -1; playerinfo(&cn, attr); } COMMANDN(player, playerinfo, "is"); COMMANDN(player1, playerinfolocal, "s"); void teaminfo(const char *team, const char *attr) { if(!team || !attr || !m_teammode) return; int t = teamatoi(team); // get player clientnum if(!team_isactive(t)) { conoutf("invalid team: %s", team); return; } int t_flags = 0; int t_frags = 0; int t_deaths = 0; int t_points = 0; string teammembers = ""; loopv(players) if(players[i] && players[i]->team == t) { t_frags += players[i]->frags; t_deaths += players[i]->deaths; t_points += players[i]->points; t_flags += players[i]->flagscore; concatformatstring(teammembers, "%d ", players[i]->clientnum); } loopv(discscores) if(discscores[i].team == t) { t_frags += discscores[i].frags; t_deaths += discscores[i].deaths; t_points += discscores[i].points; t_flags += discscores[i].flags; } if(player1->team == t) { t_frags += player1->frags; t_deaths += player1->deaths; t_points += player1->points; t_flags += player1->flagscore; concatformatstring(teammembers, "%d ", player1->clientnum); } ATTR_INT(flags, t_flags); ATTR_INT(frags, t_frags); ATTR_INT(deaths, t_deaths); ATTR_INT(points, t_points); ATTR_STR(name, team_string(t)); ATTR_STR(players, teammembers); conoutf("invalid attribute: %s", attr); } COMMAND(teaminfo, "ss"); const char *currentserver(int i) // [client version] { static string curSRVinfo; // using the curpeer directly we can get the info of our currently connected server string r; r[0] = '\0'; extern ENetPeer *curpeer; if(curpeer) { switch(i) { case 1: // IP { uchar *ip = (uchar *)&curpeer->address.host; formatstring(r)("%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); break; } case 2: // HOST { char hn[1024]; formatstring(r)("%s", (enet_address_get_host(&curpeer->address, hn, sizeof(hn))==0) ? hn : "unknown"); break; } case 3: // PORT { formatstring(r)("%d", curpeer->address.port); break; } case 4: // STATE { const char *statenames[] = { "disconnected", "connecting", "acknowledging connect", "connection pending", "connection succeeded", "connected", "disconnect later", "disconnecting", "acknowledging disconnect", "zombie" }; if(curpeer->state>=0 && curpeer->statestate]); break; // 5 == Connected (compare ../enet/include/enet/enet.h +165) } // CAUTION: the following are only filled if the serverbrowser was used or the scoreboard shown // SERVERNAME case 5: { serverinfo *si = getconnectedserverinfo(); if(si) copystring(r, si->name); break; } // DESCRIPTION (3) case 6: { serverinfo *si = getconnectedserverinfo(); if(si) copystring(r, si->sdesc); break; } case 7: { serverinfo *si = getconnectedserverinfo(); if(si) copystring(r, si->description); break; } // CAUTION: the following is only the last full-description _seen_ in the serverbrowser! case 8: { serverinfo *si = getconnectedserverinfo(); if(si) copystring(r, si->full); break; } // just IP & PORT as default response - always available, no lookup-delay either default: { uchar *ip = (uchar *)&curpeer->address.host; formatstring(r)("%d.%d.%d.%d %d", ip[0], ip[1], ip[2], ip[3], curpeer->address.port); break; } } } copystring(curSRVinfo, r); return curSRVinfo; } COMMANDF(curserver, "i", (int *i) { result(currentserver(*i)); }); COMMANDF(getmode, "i", (int *acr) { result(modestr(gamemode, *acr != 0)); }); void deathstate(playerent *pl) { pl->state = CS_DEAD; pl->spectatemode = SM_DEATHCAM; pl->lastdeath = pl->lastpain = lastmillis; pl->move = pl->strafe = 0; pl->pitch = pl->roll = pl->movroll = pl->effroll = 0; pl->attacking = false; pl->weaponsel->onownerdies(); if(pl==player1) { if(showscoresondeath) showscores(true); setscope(false); setburst(false); if(editmode) toggleedit(true); if(pl->team == TEAM_SPECT) spectatemode(SM_FLY); else if(team_isspect(pl->team)) spectatemode(SM_FOLLOW1ST); } else pl->resetinterp(); } void spawnstate(playerent *d) // reset player state not persistent accross spawns { d->respawn(); d->spawnstate(gamemode); if(d==player1) { setscope(false); setburst(false); } if(d->deaths==0) d->resetstats(); } playerent *newplayerent() // create a new blank player { playerent *d = new playerent; d->lastupdate = totalmillis; setskin(d, rnd(6)); weapon::equipplayer(d); // flowtron : avoid overwriting d->spawnstate(gamemode) stuff from the following line (this used to be called afterwards) spawnstate(d); return d; } botent *newbotent() // create a new blank player { botent *d = new botent; d->lastupdate = totalmillis; setskin(d, rnd(6)); weapon::equipplayer(d); spawnstate(d); // move like above int nextcn = 0; bool lukin = true; while(lukin) { bool used = nextcn==getclientnum(); loopv(players) if(!used && players[i]) if(players[i]->clientnum==nextcn) used = true; if(!used) lukin = false; else nextcn++; } loopv(players) if(i!=getclientnum() && !players[i]) { players[i] = d; d->clientnum = nextcn; return d; } if(players.length()==getclientnum()) players.add(NULL); d->clientnum = nextcn; players.add(d); return d; } void freebotent(botent *d) { loopv(players) if(players[i]==d) { DELETEP(players[i]); players.remove(i); } } VAR(lastpm, 1, -1, 0); void zapplayer(playerent *&d) { if(d && d->clientnum == lastpm) lastpm = -1; if(d == (playerent *)camera1) resetcamera(); DELETEP(d); } void movelocalplayer() { if(player1->state==CS_DEAD && !player1->allowmove()) { if(lastmillis-player1->lastpain<2000) { player1->move = player1->strafe = 0; moveplayer(player1, 10, false); } } else if(!intermission) { moveplayer(player1, 10, true); checkitems(player1); } } // use physics to extrapolate player position VARP(smoothmove, 0, 75, 100); VARP(smoothdist, 0, 8, 16); void predictplayer(playerent *d, bool move) { d->o = d->newpos; d->o.z += d->eyeheight; d->yaw = d->newyaw; d->pitch = d->newpitch; if(move) { moveplayer(d, 1, false); d->newpos = d->o; d->newpos.z -= d->eyeheight; } float k = 1.0f - float(lastmillis - d->smoothmillis)/smoothmove; if(k>0) { d->o.add(vec(d->deltapos).mul(k)); d->yaw += d->deltayaw*k; if(d->yaw<0) d->yaw += 360; else if(d->yaw>=360) d->yaw -= 360; d->pitch += d->deltapitch*k; } } void moveotherplayers() { loopv(players) if(players[i] && players[i]->type==ENT_PLAYER) { playerent *d = players[i]; const int lagtime = totalmillis-d->lastupdate; if(!lagtime || intermission) continue; else if(lagtime>1000 && d->state==CS_ALIVE) { d->state = CS_LAGGED; continue; } if(d->state==CS_ALIVE || d->state==CS_EDITING) { if(smoothmove && d->smoothmillis>0) predictplayer(d, true); else moveplayer(d, 1, false); } else if(d->state==CS_DEAD && lastmillis-d->lastpain<2000) moveplayer(d, 1, true); } } bool showhudtimer(int maxsecs, int startmillis, const char *msg, bool flash) { static string str = ""; static int tickstart = 0, curticks = -1, maxticks = -1; int nextticks = (lastmillis - startmillis) / 200; if(tickstart!=startmillis || maxticks != 5*maxsecs) { tickstart = startmillis; maxticks = 5*maxsecs; curticks = -1; copystring(str, "\f3"); } if(curticks >= maxticks) return false; nextticks = min(nextticks, maxticks); while(curticks < nextticks) { if(++curticks%5) concatstring(str, "."); else { defformatstring(sec)("%d", maxsecs - (curticks/5)); concatstring(str, sec); } } if(nextticks < maxticks) hudeditf(HUDMSG_TIMER|HUDMSG_OVERWRITE, "%s", flash ? str : str+2); else hudeditf(HUDMSG_TIMER, "%s", msg); return true; } int lastspawnattempt = 0; void showrespawntimer() { if(intermission || spawnpermission > SP_OK_NUM) return; if(m_arena) { if(!arenaintermission) return; showhudtimer(5, arenaintermission, "FIGHT!", lastspawnattempt >= arenaintermission && lastmillis < lastspawnattempt+100); } else if(player1->state==CS_DEAD && m_flags && (!player1->isspectating() || player1->spectatemode==SM_DEATHCAM)) { int secs = 5; showhudtimer(secs, player1->lastdeath, "READY!", lastspawnattempt >= arenaintermission && lastmillis < lastspawnattempt+100); } } struct scriptsleep { int wait, millis; char *cmd; bool persist; }; vector sleeps; sl_semaphore *sleepssemaphore = new sl_semaphore(1, NULL); // guard the sleeps-vector with a semaphore, so we can add sleeps from other threads void addsleep(int msec, const char *cmd, bool persist) { sleepssemaphore->wait(); scriptsleep &s = sleeps.add(); s.wait = max(msec, 1); s.millis = lastmillis; s.cmd = newstring(cmd); s.persist = persist; sleepssemaphore->post(); } void addsleep_(int *msec, char *cmd, int *persist) { addsleep(*msec, cmd, *persist != 0); } void resetsleep(bool force) { sleepssemaphore->wait(); loopvrev(sleeps) if(!sleeps[i].persist || force) { DELSTRING(sleeps[i].cmd); sleeps.remove(i); } sleepssemaphore->post(); } COMMANDN(sleep, addsleep_, "isi"); COMMANDF(resetsleeps, "", (void) { resetsleep(true); }); void updateworld(int curtime, int lastmillis) // main game update loop { // process command sleeps sleepssemaphore->wait(); loopv(sleeps) { if(lastmillis - sleeps[i].millis >= sleeps[i].wait) { char *cmd = sleeps[i].cmd; sleeps[i].cmd = NULL; sleeps.remove(i--); sleepssemaphore->post(); execute(cmd); delete[] cmd; sleepssemaphore->wait(); } } sleepssemaphore->post(); syncentchanges(); physicsframe(); checkweaponstate(); if(getclientnum()>=0) shoot(player1, worldpos); // only shoot when connected to server movebounceents(); moveotherplayers(); gets2c(); showrespawntimer(); // Added by Rick: let bots think if(m_botmode) BotManager.Think(); movelocalplayer(); c2sinfo(player1); // do this last, to reduce the effective frame lag } #define SECURESPAWNDIST 15 int spawncycle = -1; int fixspawn = 2; // returns -1 for a free place, else dist to the nearest enemy float nearestenemy(vec place, int team) { float nearestenemydist = -1; loopv(players) { playerent *other = players[i]; if(!other || isteam(team, other->team)) continue; float dist = place.dist(other->o); if(dist < nearestenemydist || nearestenemydist == -1) nearestenemydist = dist; } if(nearestenemydist >= SECURESPAWNDIST || nearestenemydist < 0) return -1; else return nearestenemydist; } void gotoplayerstart(playerent *d, entity *e) { d->o.x = e->x; d->o.y = e->y; d->o.z = e->z; d->yaw = float(e->attr1) / ENTSCALE10; d->pitch = 0; d->roll = d->movroll = d->effroll = 0; } void findplayerstart(playerent *d, bool mapcenter, int arenaspawn) { int r = fixspawn-->0 ? 4 : rnd(10)+1; entity *e = NULL; if(!mapcenter) { int type = m_teammode ? team_base(d->team) : 100; if(m_arena && arenaspawn >= 0) { int x = -1; loopi(arenaspawn + 1) x = findentity(PLAYERSTART, x+1, type); if(x >= 0) e = &ents[x]; } else if((m_teammode || m_arena) && !m_ktf) // ktf uses ffa spawns { loopi(r) spawncycle = findentity(PLAYERSTART, spawncycle+1, type); if(spawncycle >= 0) e = &ents[spawncycle]; } else { float bestdist = -1; loopi(r) { spawncycle = clentstats.hasffaspawns ? findentity(PLAYERSTART, spawncycle+1, 100) : findentity(PLAYERSTART, spawncycle+1); // if not enough ffa-spawns are available, use all if(spawncycle < 0) continue; float dist = nearestenemy(vec(ents[spawncycle].x, ents[spawncycle].y, ents[spawncycle].z), d->team); if(!e || dist < 0 || (bestdist >= 0 && dist > bestdist)) { e = &ents[spawncycle]; bestdist = dist; } } } } if(e) { gotoplayerstart(d, e); } else { d->o.x = d->o.y = (float)ssize/2; d->o.z = 4; } entinmap(d); exechook(HOOK_SP, "onSpawn", "%d", d->clientnum); } void spawnplayer(playerent *d) { d->respawn(); d->spawnstate(gamemode); d->state = (d==player1 && editmode) ? CS_EDITING : CS_ALIVE; findplayerstart(d); } void respawnself() { if( m_mp(gamemode) ) addmsg(SV_TRYSPAWN, "r"); else { if(team_isspect(player1->team)) { addmsg(SV_SWITCHTEAM, "ri", m_teammode ? teamatoi(BotManager.GetBotTeam()) : rnd(2)); } showscores(false); setscope(false); setburst(false); lasthit = 0; spawnplayer(player1); player1->lifesequence++; player1->weaponswitch(player1->primweap); player1->weaponchanging -= player1->weapons[player1->gunselect]->weaponchangetime/2; // 2011jan16:ft: for a little no-shoot after spawn } } extern int checkarea(int maplayout_factor, char *maplayout); extern int MA; extern float Mh; bool bad_map() // this function makes a pair with good_map from clients2c { return (gamemode != GMODE_COOPEDIT && ( Mh >= MAXMHEIGHT || MA >= MAXMAREA )); } inline const char * spawn_message() { if (spawnpermission == SP_WRONGMAP) { // Don't use "/n" within these messages. If you do, the words won't align to the middle of the screen. if (securemapcheck(getclientmap())) return "3The server will NOT allow spawning or getmap!"; // Also see client.cpp which has a conoutf message else return "3You must be on the correct map to spawn. Type /getmap to download it."; } else if (m_coop) return "3Type /getmap or send a map and vote for it to start co-op edit."; else if (multiplayer(NULL)) return "4Awaiting permission to spawn. \f2DON'T PANIC!"; else return ""; // theres no waiting for permission in sp // Despite its many glaring (and occasionally fatal) inaccuracies, AssaultCube itself has outsold the // Encyclopedia Galactica because it is slightly cheaper, and because it has the words "Don't Panic" // in large, friendly letters. } int waiting_permission = 0; bool tryrespawn() { if(m_mp(gamemode) && multiplayer(NULL) && bad_map()) { hudoutf("This map is not supported in multiplayer. Read the docs about map quality/dimensions."); } else if(spawnpermission > SP_OK_NUM) { hudeditf(HUDMSG_TIMER, "\f%s", spawn_message()); } else if(player1->state==CS_DEAD || player1->state==CS_SPECTATE) { if(team_isspect(player1->team)) { respawnself(); return true; } else { int respawnmillis = player1->lastdeath + (m_arena ? 0 : (m_flags ? 5000 : 2000)); if(lastmillis>respawnmillis) { player1->attacking = false; if(m_arena) { if(!arenaintermission) hudeditf(HUDMSG_TIMER, "waiting for new round to start..."); else lastspawnattempt = lastmillis; return false; } if (lastmillis > waiting_permission) { waiting_permission = lastmillis + 1000; respawnself(); } else hudeditf(HUDMSG_TIMER, "\f%s", spawn_message()); return true; } else lastspawnattempt = lastmillis; } } return false; } VARP(hitsound, 0, 0, 2); // client kill messages void setkillmessage(const char *gun, bool gib, const char *message) { int guni = getlistindex(gun, gunnames, true, -1); if(!valid_weapon(guni)) { conoutf("invalid gun specified"); } else { defformatstring(aname)("%smessage_%s", gib ? "gib" : "frag", gunnames[guni]); if(*message) alias(aname, message); const char *res = getalias(aname); result(res ? res : killmessages[gib ? 1 : 0][guni]); } } COMMANDF(fragmessage, "ss", (const char *gun, const char *message) { setkillmessage(gun, false, message); }); COMMANDF(gibmessage, "ss", (const char *gun, const char *message) { setkillmessage(gun, true, message); }); const char *killmessage(int gun, bool gib = false) { if(valid_weapon(gun)) { defformatstring(aname)("%smessage_%s", gib ? "gib" : "frag", gunnames[gun]); const char *res = getalias(aname); return res ? res : killmessages[gib ? 1 : 0][gun]; } return ""; } COMMANDF(burstshots, "si", (char *gun, int *shots) { int guni = getlistindex(gun, gunnames, true, -1); if(guni >= 0 && guns[guni].isauto) { if(*shots >= 0) burstshotssettings[guni] = min(*shots, (guns[guni].magsize-1)); else intret(burstshotssettings[guni]); } else conoutf("invalid gun specified"); }); // damage arriving from the network, monsters, yourself, all ends up here. void dodamage(int damage, playerent *pl, playerent *actor, int gun, bool gib, bool local) { if(pl->state != CS_ALIVE || intermission) return; pl->lastpain = lastmillis; // could the author of the FIXME below please elaborate what's to fix?! (ft:2011mar28) // I suppose someone wanted to play the hitsound for player1 or spectated player (lucas:2011may22) playerent *h = player1->isspectating() && player1->followplayercn >= 0 && (player1->spectatemode == SM_FOLLOW1ST || player1->spectatemode == SM_FOLLOW3RD || player1->spectatemode == SM_FOLLOW3RD_TRANSPARENT) ? getclient(player1->followplayercn) : NULL; if(!h) h = player1; exechook(HOOK_SP, "onHit", "%d %d %d %d %d", actor->clientnum, pl->clientnum, damage, gun, gib ? 1 : 0); if(actor==h && pl!=actor) { if( (hitsound == 1 || (hitsound && h != player1) ) && lasthit != lastmillis) audiomgr.playsound(S_HITSOUND, SP_HIGHEST); lasthit = lastmillis; } if (pl != player1) { damageeffect(damage, pl); audiomgr.playsound(S_PAIN1+rnd(5), pl); } if(local) damage = pl->dodamage(damage, gun); else if(actor==player1) return; if(pl == h) { if(pl != actor) updatedmgindicator(pl, actor->o); damageblend(damage, pl); pl->damageroll(damage); } if(pl->health<=0) { if(local) dokill(pl, actor, gib, gun >= 0 ? gun : actor->weaponsel->type); } else if(pl==player1) audiomgr.playsound(S_PAIN6, SP_HIGH); else audiomgr.playsound(S_PAIN1+rnd(5), pl); } void dokill(playerent *pl, playerent *act, bool gib, int gun) { if(pl->state!=CS_ALIVE || intermission) return; exechook(HOOK_SP, "onKill", "%d %d %d %d", act->clientnum, pl->clientnum, gun, gib ? 1 : 0); string pname, aname, death; copystring(pname, pl==player1 ? "you" : colorname(pl)); copystring(aname, act==player1 ? "you" : colorname(act)); copystring(death, killmessage(gun, gib)); void (*outf)(const char *s, ...) = (pl == player1 || act == player1) ? hudoutf : conoutf; if(pl==act) { outf("\f2%s suicided%s", pname, pl==player1 ? "!" : ""); } else if(isteam(pl->team, act->team)) { if(pl==player1) outf("\f2you were %s by teammate %s", death, aname); else outf("%s%s %s teammate %s", act==player1 ? "\f3" : "\f2", aname, death, pname); } else { if(pl==player1) outf("\f2you were %s by %s", death, aname); else outf("\f2%s %s %s", aname, death, pname); } if(pl == act || isteam(pl->team, act->team)) { if(pl != act) act->tks++; if(!m_mp(gamemode)) act->frags--; } else if(!m_mp(gamemode)) act->frags += ( gib && gun != GUN_GRENADE && gun != GUN_SHOTGUN) ? 2 : 1; if(gib) { if(pl!=act && gun == GUN_SNIPER) audiomgr.playsound(S_HEADSHOT, SP_LOW); addgib(pl); } deathstate(pl); pl->deaths++; audiomgr.playsound(rnd(2) ? S_DIE1 : S_DIE2, pl); } void pstat_weap(int *cn) { string weapstring = ""; playerent *pl = getclient(*cn); if(pl) loopi(NUMGUNS) concatformatstring(weapstring, "%s%d %d", strlen(weapstring) ? " " : "", pl->pstatshots[i], pl->pstatdamage[i]); result(weapstring); } COMMAND(pstat_weap, "i"); VAR(minutesremaining, 1, 0, 0); VAR(gametimecurrent, 1, 0, 0); VAR(gametimemaximum, 1, 0, 0); VAR(lastgametimeupdate, 1, 0, 0); void silenttimeupdate(int milliscur, int millismax) { lastgametimeupdate = lastmillis; gametimecurrent = milliscur; gametimemaximum = millismax; minutesremaining = (gametimemaximum - gametimecurrent + 60000 - 1) / 60000; } void timeupdate(int milliscur, int millismax) { static int lastgametimedisplay = 0; silenttimeupdate(milliscur, millismax); int lastdisplay = lastmillis - lastgametimedisplay; if(lastdisplay >= 0 && lastdisplay <= 1000) return; // avoid double-output lastgametimedisplay = lastmillis; if(!minutesremaining) { intermission = true; extern bool needsautoscreenshot; if(autoscreenshot) needsautoscreenshot = true; player1->attacking = false; conoutf("intermission:"); conoutf("game has ended!"); consolescores(); showscores(true); exechook(HOOK_SP_MP, "start_intermission", ""); } else { extern int gametimedisplay; // only output to console if no hud-clock with game time is being shown int sec = 60 - ( (gametimecurrent + ( lastmillis - lastgametimeupdate ) ) / 1000) % 60; if(minutesremaining==1) { audiomgr.musicsuggest(M_LASTMINUTE1 + rnd(2), 70*1000, true); hudoutf("%s1 minute left!", sec==60 ? "" : "less than "); exechook(HOOK_SP_MP, "onLastMin", ""); } else if(!gametimedisplay) conoutf("time remaining: %d minutes", minutesremaining); else clientlogf("time remaining: %d minutes", minutesremaining); } } playerent *newclient(int cn) // ensure valid entity { if(cn<0 || cn>=MAXCLIENTS) { neterr("clientnum"); return NULL; } while(cn>=players.length()) players.add(NULL); playerent *d = players[cn]; if(d) return d; d = newplayerent(); players[cn] = d; d->clientnum = cn; return d; } playerent *getclient(int cn) // ensure valid entity { if(cn == player1->clientnum) return player1; return players.inrange(cn) ? players[cn] : NULL; } void initclient() { newname("unarmed"); player1->team = TEAM_SPECT; } entity flagdummies[2] = // in case the map does not provide flags { entity(-1, -1, -1, CTF_FLAG, 0, 0, 0, 0), entity(-1, -1, -1, CTF_FLAG, 0, 1, 0, 0) }; void initflag(int i) { flaginfo &f = flaginfos[i]; f.flagent = &flagdummies[i]; f.pos = vec(f.flagent->x, f.flagent->y, f.flagent->z); f.ack = true; f.actor = NULL; f.actor_cn = -1; f.team = i; f.state = m_ktf ? CTFF_IDLE : CTFF_INBASE; } void zapplayerflags(playerent *p) { loopi(2) if(flaginfos[i].state==CTFF_STOLEN && flaginfos[i].actor==p) initflag(i); } void preparectf(bool cleanonly=false) { loopi(2) initflag(i); if(!cleanonly) { loopv(ents) { entity &e = ents[i]; if(e.type==CTF_FLAG) { e.spawned = true; if(e.attr2>=2) { conoutf("\f3invalid ctf-flag entity (%d)", i); e.attr2 = 0; } flaginfo &f = flaginfos[e.attr2]; f.flagent = &e; f.pos.x = (float) e.x; f.pos.y = (float) e.y; f.pos.z = (float) e.z; } } } } struct gmdesc { int mode; char *desc; }; vector gmdescs; void gamemodedesc(int *modenr, char *desc) { if(!desc) return; struct gmdesc &gd = gmdescs.add(); gd.mode = *modenr; gd.desc = newstring(desc); } COMMAND(gamemodedesc, "is"); void resetmap(bool mrproper) { resetsleep(); resetzones(); clearminimap(); cleardynlights(); reseteditor(); changedents.setsize(0); deleted_ents.setsize(0); particlereset(); setmapinfo("", ""); if(mrproper) { audiomgr.clearworldsounds(); setvar("gamespeed", 100); setvar("paused", 0); setvar("fog", DEFAULT_FOG); setvar("fogcolour", DEFAULT_FOGCOLOUR); setvar("shadowyaw", DEFAULT_SHADOWYAW); } } int suicided = -1; extern bool good_map(); extern bool item_fail; extern int MA, F2F, Ma, Hhits; extern float Mh; VARP(mapstats_hud, 0, 0, 1); void showmapstats() { conoutf("\f2Map Quality Stats"); conoutf(" The mean height is: %.2f", Mh); if (Hhits) conoutf(" Height check is: %d", Hhits); if (MA) conoutf(" The max area is: %d (of %d)", MA, Ma); if (m_flags && F2F < 1000) conoutf(" Flag-to-flag distance is: %d", (int)sqrtf(F2F)); if (item_fail) conoutf(" There are one or more items too close to each other in this map"); } COMMAND(showmapstats, ""); VARP(showmodedescriptions, 0, 1, 1); extern bool canceldownloads; void startmap(const char *name, bool reset, bool norespawn) // called just after a map load { canceldownloads = false; copystring(clientmap, name); if(norespawn) return; sendmapidenttoserver = true; if(m_botmode) BotManager.BeginMap(name); else kickallbots(); clearbounceents(); preparectf(!m_flags); suicided = -1; spawncycle = -1; lasthit = 0; player1->followplayercn = -1; if(m_valid(gamemode) && !m_mp(gamemode)) respawnself(); else findplayerstart(player1); if(good_map()==MAP_IS_BAD) conoutf("You cannot play in this map due to quality requisites. Please, report this incident."); if (mapstats_hud) showmapstats(); if(!reset) return; player1->frags = player1->flagscore = player1->deaths = player1->lifesequence = player1->points = player1->tks = 0; loopv(players) if(players[i]) players[i]->frags = players[i]->flagscore = players[i]->deaths = players[i]->lifesequence = players[i]->points = players[i]->tks = 0; if(editmode) toggleedit(true); intermission = false; showscores(false); closemenu("Download demo"); // close and reset demo list, because it may be no longer accurate, since a new game has started extern void *downloaddemomenu; menureset(downloaddemomenu); needscoresreorder = true; minutesremaining = -1; lastgametimeupdate = 0; arenaintermission = 0; bool noflags = (m_ctf || m_ktf) && !clentstats.hasflags; if(*clientmap) conoutf("game mode is \"%s\"%s", modestr(gamemode, modeacronyms > 0), noflags ? " - \f2but there are no flag bases on this map" : ""); if(showmodedescriptions && (multiplayer(NULL) || m_botmode)) { loopv(gmdescs) if(gmdescs[i].mode == gamemode) conoutf("\f1%s", gmdescs[i].desc); } // execute mapstart event once const char *mapstartonce = getalias("mapstartonce"); if(mapstartonce && mapstartonce[0]) { addsleep(0, mapstartonce); // do this as a sleep to make sure map changes don't recurse inside a welcome packet // BTW: in v1.0.4 sleep 1 was required to make it work on initial mapload [flowtron:2010jun25] alias("mapstartonce", ""); } // execute mapstart event const char *mapstartalways = getalias("mapstartalways"); if(mapstartalways && mapstartalways[0]) { addsleep(0, mapstartalways); } } void suicide() { if(player1->state == CS_ALIVE && suicided!=player1->lifesequence) { addmsg(SV_SUICIDE, "r"); suicided = player1->lifesequence; } } COMMAND(suicide, ""); // console and audio feedback void flagmsg(int flag, int message, int actor, int flagtime) { static int musicplaying = -1; playerent *act = getclient(actor); if(actor != getclientnum() && !act && message != FM_RESET) return; bool own = flag == team_base(player1->team); bool neutral = team_isspect(player1->team); bool firstperson = actor == getclientnum(); bool teammate = !act ? true : isteam(player1->team, act->team); bool firstpersondrop = false; defformatstring(ownerstr)("the %s", teamnames[flag]); const char *teamstr = m_ktf ? "the" : neutral ? ownerstr : own ? "your" : "the enemy"; const char *flagteam = (m_ktf && !neutral) ? (teammate ? "your teammate " : "your enemy ") : ""; exechook(HOOK_SP, "onFlag", "%d %d %d", message, actor, flag); switch(message) { case FM_PICKUP: audiomgr.playsound(S_FLAGPICKUP, SP_HIGHEST); if(firstperson) { hudoutf("\f2you have the %sflag", m_ctf ? "enemy " : ""); audiomgr.musicsuggest(M_FLAGGRAB, m_ctf ? 90*1000 : 900*1000, true); musicplaying = flag; } else hudoutf("\f2%s%s has %s flag", flagteam, colorname(act), teamstr); break; case FM_LOST: case FM_DROP: { const char *droplost = message == FM_LOST ? "lost" : "dropped"; audiomgr.playsound(S_FLAGDROP, SP_HIGHEST); if(firstperson) { hudoutf("\f2you %s the flag", droplost); firstpersondrop = true; } else hudoutf("\f2%s %s %s flag", colorname(act), droplost, teamstr); break; } case FM_RETURN: audiomgr.playsound(S_FLAGRETURN, SP_HIGHEST); if(firstperson) hudoutf("\f2you returned your flag"); else hudoutf("\f2%s returned %s flag", colorname(act), teamstr); break; case FM_SCORE: audiomgr.playsound(S_FLAGSCORE, SP_HIGHEST); if(firstperson) { hudoutf("\f2you scored"); if(m_ctf) firstpersondrop = true; } else hudoutf("\f2%s scored for %s", colorname(act), neutral ? teamnames[act->team] : teammate ? "your team" : "the enemy team"); break; case FM_KTFSCORE: { audiomgr.playsound(S_KTFSCORE, SP_HIGHEST); const char *ta = firstperson ? "you have" : colorname(act); const char *tb = firstperson ? "" : " has"; const char *tc = firstperson ? "" : flagteam; int m = flagtime / 60; if(m) hudoutf("\f2%s%s%s kept the flag for %d min %d s now", tc, ta, tb, m, flagtime % 60); else hudoutf("\f2%s%s%s kept the flag for %d s now", tc, ta, tb, flagtime); break; } case FM_SCOREFAIL: // sound? hudoutf("\f2%s failed to score (own team flag not taken)", firstperson ? "you" : colorname(act)); break; case FM_RESET: audiomgr.playsound(S_FLAGRETURN, SP_HIGHEST); hudoutf("the server reset the flag"); firstpersondrop = true; break; } if(firstpersondrop && flag == musicplaying) { audiomgr.musicfadeout(M_FLAGGRAB); musicplaying = -1; } } void dropflag() { tryflagdrop(true); } COMMAND(dropflag, ""); char *votestring(int type, const char *arg1, const char *arg2, const char *arg3) { const char *msgs[] = { "kick player %s, reason: %s", "ban player %s, reason: %s", "remove all bans", "set mastermode to %s", "%s autoteam", "force player %s to team %s", "give admin to player %s", "load map %s in mode %s%s%s", "%s demo recording for the next match", "stop demo recording", "clear all demos", "set server description to '%s'", "shuffle teams"}; const char *msg = msgs[type]; char *out = newstring(MAXSTRLEN); out[MAXSTRLEN] = '\0'; switch(type) { case SA_KICK: case SA_BAN: case SA_FORCETEAM: case SA_GIVEADMIN: { int cn = atoi(arg1); playerent *p = getclient(cn); if(!p) break; if (type == SA_KICK || type == SA_BAN) { string reason = ""; if(m_teammode) formatstring(reason)("%s (%d tk%s, ping %d)", arg2, p->tks, p->tks == 1 ? "" : "s", p->ping); else formatstring(reason)("%s (ping %d)", arg2, p->ping); formatstring(out)(msg, colorname(p), reason); } else if(type == SA_FORCETEAM) { int team = atoi(arg2); formatstring(out)(msg, colorname(p), team_isvalid(team) ? teamnames[team] : ""); } else formatstring(out)(msg, colorname(p)); break; } case SA_MASTERMODE: formatstring(out)(msg, mmfullname(atoi(arg1))); break; case SA_AUTOTEAM: case SA_RECORDDEMO: formatstring(out)(msg, atoi(arg1) == 0 ? "disable" : "enable"); break; case SA_MAP: { int n = atoi(arg2); string timestr = ""; if(arg3 && arg3[0]) { int time = atoi(arg3); if(time > 0 && time != defaultgamelimit(n)) formatstring(timestr)(" for %d minute%s", time, time == 1 ? "" : "s"); } if ( n >= GMODE_NUM ) { formatstring(out)(msg, arg1, modestr(n-GMODE_NUM, modeacronyms > 0)," (in the next game)", timestr); } else { formatstring(out)(msg, arg1, modestr(n, modeacronyms > 0), "", timestr); } break; } case SA_SERVERDESC: formatstring(out)(msg, arg1); break; default: formatstring(out)(msg, arg1, arg2); break; } return out; } votedisplayinfo *newvotedisplayinfo(playerent *owner, int type, const char *arg1, const char *arg2, const char *arg3) { if(type < 0 || type >= SA_NUM) return NULL; votedisplayinfo *v = new votedisplayinfo(); v->owner = owner; v->type = type; v->millis = totalmillis + (30+10)*1000; char *votedesc = votestring(type, arg1, arg2, arg3); copystring(v->desc, votedesc); DELETEA(votedesc); return v; } votedisplayinfo *curvote = NULL, *calledvote = NULL; void callvote(int type, const char *arg1, const char *arg2, const char *arg3) { if(calledvote) return; votedisplayinfo *v = newvotedisplayinfo(player1, type, arg1, arg2, arg3); if(v) { calledvote = v; packetbuf p(MAXTRANS, ENET_PACKET_FLAG_RELIABLE); putint(p, SV_CALLVOTE); putint(p, v->type); switch(v->type) { case SA_KICK: case SA_BAN: putint(p, atoi(arg1)); sendstring(arg2, p); break; case SA_MAP: sendstring(arg1, p); putint(p, atoi(arg2)); putint(p, atoi(arg3)); break; case SA_SERVERDESC: sendstring(arg1, p); break; case SA_STOPDEMO: // compatibility break; case SA_REMBANS: case SA_SHUFFLETEAMS: break; case SA_FORCETEAM: putint(p, atoi(arg1)); putint(p, atoi(arg2)); break; default: putint(p, atoi(arg1)); break; } sendpackettoserv(1, p.finalize()); exechook(HOOK_SP_MP, "onCallVote", "%d %d [%s] [%s]", type, player1->clientnum, arg1, arg2); } else conoutf("\f3invalid vote"); } void scallvote(int *type, const char *arg1, const char *arg2) { if(type && inmainloop) { int t = *type; switch (t) { case SA_MAP: { //FIXME: this stupid conversion of ints to strings and back should // really be replaced with a saner method defformatstring(m)("%d", nextmode); callvote(t, arg1, m, arg2); break; } case SA_KICK: case SA_BAN: { if (!arg1 || !isdigit(arg1[0]) || !arg2 || strlen(arg2) <= 3 || !multiplayer(NULL)) { if(!multiplayer(NULL)) conoutf("\f3%s is not available in singleplayer.", t == SA_BAN ? "Ban" : "Kick"); else if(arg1 && !isdigit(arg1[0])) conoutf("\f3invalid vote"); else conoutf("\f3invalid reason"); break; } } case SA_FORCETEAM: { int team = atoi(arg2); if(team < 0) arg2 = (team == 0) ? "RVSF" : "CLA"; // fall through } default: callvote(t, arg1, arg2); } } } int vote(int v) { if(!curvote || v < 0 || v >= VOTE_NUM) return 0; if(curvote->localplayervoted) { conoutf("\f3you voted already"); return 0; } packetbuf p(MAXTRANS, ENET_PACKET_FLAG_RELIABLE); putint(p, SV_VOTE); putint(p, v); sendpackettoserv(1, p.finalize()); if(!curvote) return 0; curvote->stats[v]++; curvote->localplayervoted = true; return 1; } VAR(votepending, 1, 0, 0); void displayvote(votedisplayinfo *v) { if(!v) return; DELETEP(curvote); curvote = v; conoutf("%s called a vote: %s", v->owner ? colorname(v->owner) : "", curvote->desc); audiomgr.playsound(S_CALLVOTE, SP_HIGHEST); curvote->localplayervoted = false; votepending = 1; } void callvotesuc() { if(!calledvote) return; displayvote(calledvote); calledvote = NULL; vote(VOTE_YES); // not automatically done by callvote to keep a clear sequence } void callvoteerr(int e) { if(e < 0 || e >= VOTEE_NUM) return; conoutf("\f3could not vote: %s", voteerrorstr(e)); DELETEP(calledvote); } void votecount(int v) { if(curvote && v >= 0 && v < VOTE_NUM) curvote->stats[v]++; } void voteresult(int v) { if(curvote && v >= 0 && v < VOTE_NUM) { curvote->result = v; curvote->millis = totalmillis + 5000; conoutf("vote %s", v == VOTE_YES ? "passed" : "failed"); if(multiplayer(NULL)) audiomgr.playsound(v == VOTE_YES ? S_VOTEPASS : S_VOTEFAIL, SP_HIGH); exechook(HOOK_SP_MP, "onVoteEnd", ""); votepending = 0; } } void clearvote() { DELETEP(curvote); DELETEP(calledvote); } const char *modestrings[] = { "tdm", "coop", "dm", "lms", "ts", "ctf", "pf", "btdm", "bdm", "lss", "osok", "tosok", "bosok", "htf", "tktf", "ktf", "tpf", "tlss", "bpf", "blss", "btsurv", "btosok" }; void setnext(char *mode, char *map) { if(!multiplayer(NULL)) { //RR 10/12/12 - Is this the action we want? conoutf("You cannot use setnext in singleplayer."); return; } if(!mode || !map) return; loopi(GMODE_NUM) { switch(i) { case GMODE_COOPEDIT: case GMODE_BOTTEAMDEATHMATCH: case GMODE_BOTDEATHMATCH: case GMODE_BOTONESHOTONEKILL: case GMODE_BOTLSS: case GMODE_BOTPISTOLFRENZY: case GMODE_BOTTEAMONESHOTONKILL: continue; } if(!strcmp(mode, modestrings[i])) { nextmode=i+GMODE_NUM; string nm = ""; itoa(nm, nextmode); callvote(SA_MAP, map, nm, "0"); break; } } } COMMAND(setnext, "ss"); void gonext(int *arg1) { if(calledvote || !multiplayer(NULL)) return; packetbuf p(MAXTRANS, ENET_PACKET_FLAG_RELIABLE); putint(p, SV_CALLVOTE); putint(p, SA_MAP); sendstring("+1", p); putint(p, *arg1); putint(p, -1); sendpackettoserv(1, p.finalize()); } COMMAND(gonext, "i"); COMMANDN(callvote, scallvote, "iss"); //fixme,ah COMMANDF(vote, "i", (int *v) { vote(*v); }); void cleanplayervotes(playerent *p) { if(calledvote && calledvote->owner==p) calledvote->owner = NULL; if(curvote && curvote->owner==p) curvote->owner = NULL; } void whois(int *cn) { loopv(players) if(players[i] && players[i]->type == ENT_PLAYER && (*cn == -1 || players[i]->clientnum == *cn)) { playerent *p = players[i]; uint2ip(p->address, ip); if(ip[3] != 0 || player1->clientrole==CR_ADMIN) conoutf("WHOIS client %d:\tname %s , IP %d.%d.%d.%d , %d teamkill%s", p->clientnum, colorname(p), ip[0], ip[1], ip[2], ip[3], p->tks, p->tks == 1 ? "" : "s"); // full IP else conoutf("WHOIS client %d:\tname %s , IP %d.%d.%d.x , %d teamkill%s", p->clientnum, colorname(p), ip[0], ip[1], ip[2], p->tks, p->tks == 1 ? "" : "s"); // censored IP } } COMMAND(whois, "i"); void findcn(char *name) { loopv(players) if(players[i] && !strcmp(name, players[i]->name)) { intret(players[i]->clientnum); return; } if(!strcmp(name, player1->name)) { intret(player1->clientnum); return; } intret(-1); } COMMAND(findcn, "s"); int sessionid = 0; void setadmin(int *claim, char *password) { if(!*claim && (player1->clientrole)) { conoutf("you released admin status"); addmsg(SV_SETADMIN, "ri", 0); } else if(*claim != 0 && *password) addmsg(SV_SETADMIN, "ris", *claim, genpwdhash(player1->name, password, sessionid)); } COMMAND(setadmin, "is"); static vector mlines; void *kickmenu = NULL, *banmenu = NULL, *forceteammenu = NULL, *giveadminmenu = NULL; void refreshsopmenu(void *menu, bool init) { menureset(menu); mlines.shrink(0); mlines.reserve(players.length()); loopv(players) if(players[i]) { mline &m = mlines.add(); copystring(m.name, colorname(players[i])); string kbr; if(getalias("_kickbanreason")!=NULL) formatstring(kbr)(" [ %s ]", getalias("_kickbanreason")); // leading space! formatstring(m.cmd)("%s %d%s", menu==kickmenu ? "kick" : (menu==banmenu ? "ban" : (menu==forceteammenu ? "forceteam" : "giveadmin")), i, (menu==kickmenu||menu==banmenu)?(strlen(kbr)>8?kbr:" NONE"):""); // 8==3 + "format-extra-chars" menuitemmanual(menu, m.name, m.cmd); } } extern bool watchingdemo; VARP(spectatepersistent,0,1,1); // rotate through all spec-able players playerent *updatefollowplayer(int shiftdirection) { playerent *f = players.inrange(player1->followplayercn) ? players[player1->followplayercn] : NULL; // last spectated player // collect spec-able players int omit_team = m_teammode && !watchingdemo && player1->team != TEAM_SPECT ? team_opposite(team_base(player1->team)) : TEAM_NUM; // don't spect enemy team in team mode bool stayondeadplayers = spectatepersistent || !m_arena; vector available; loopv(players) if(players[i]) { if(team_group(players[i]->team) == omit_team) continue; // if not team SPECT and not watchingdemo and teammode: don't spectate enemy team if((players[i]->state == CS_DEAD || players[i]->isspectating()) && (!stayondeadplayers || players[i] != f)) continue; // don't spect dead players, but in some cases stay on them available.add(players[i]); } if(available.length() < 1) return NULL; // rotate int oldidx = f ? available.find(f) : 0; if(oldidx < 0) oldidx = 0; int idx = ((oldidx + shiftdirection) % available.length() + available.length()) % available.length(); player1->followplayercn = available[idx]->clientnum; return players[player1->followplayercn]; } void spectate() { if(m_demo || editmode) return; if(!team_isspect(player1->team)) addmsg(SV_SWITCHTEAM, "ri", TEAM_SPECT); else tryrespawn(); } COMMAND(spectate, ""); void setfollowplayer(int cn) { // silently ignores invalid player-cn value passed if(players.inrange(cn) && players[cn] && !m_botmode) { if(!(m_teammode && player1->team != TEAM_SPECT && !watchingdemo && team_base(players[cn]->team) != team_base(player1->team))) { player1->followplayercn = cn; if(player1->spectatemode == SM_FLY) player1->spectatemode = SM_FOLLOW1ST; } } } COMMANDF(setfollowplayer, "i", (int *cn) { setfollowplayer(*cn); }); // set new spect mode void spectatemode(int mode) { if((player1->state != CS_DEAD && player1->state != CS_SPECTATE && !team_isspect(player1->team)) || (!m_teammode && !team_isspect(player1->team) && servstate.mastermode == MM_MATCH)) return; // during ffa matches only SPECTATORS can spectate if(mode == player1->spectatemode || (m_botmode && mode != SM_FLY)) return; showscores(false); switch(mode) { case SM_FOLLOW1ST: case SM_FOLLOW3RD: case SM_FOLLOW3RD_TRANSPARENT: { if(players.length() && updatefollowplayer()) break; else mode = SM_FLY; } case SM_FLY: { if(player1->spectatemode != SM_FLY) { playerent *f = getclient(player1->followplayercn); if(f) { player1->o = f->o; player1->yaw = f->yaw; player1->pitch = 0.0f; player1->resetinterp(); } else entinmap(player1); // or drop 'em at a random place } break; } case SM_OVERVIEW: break; default: break; } player1->spectatemode = mode; } COMMANDF(spectatemode, "i", (int *mode) { spectatemode(*mode); }); void togglespect() // cycle through all spectating modes { if(m_botmode) spectatemode(SM_FLY); else { int mode; if(player1->spectatemode==SM_NONE) mode = SM_FOLLOW1ST; // start with 1st person spect else mode = SM_FOLLOW1ST + ((player1->spectatemode - SM_FOLLOW1ST + 1) % (SM_OVERVIEW-SM_FOLLOW1ST)); // replace SM_OVERVIEW by SM_NUM to enable overview mode spectatemode(mode); } } COMMAND(togglespect, ""); void changefollowplayer(int shift) { if(!m_botmode) updatefollowplayer(shift); } COMMANDF(changefollowplayer, "i", (int *dir) { changefollowplayer(*dir); }); void spectatecn() { int spectcn = -1; if(player1->isspectating() && player1->spectatemode >= SM_FOLLOW1ST && player1->spectatemode <= SM_FOLLOW3RD_TRANSPARENT) spectcn = player1->followplayercn; intret(spectcn); } COMMAND(spectatecn, ""); void serverextension(char *ext, char *args) { if(!ext || !ext[0]) return; size_t n = args ? strlen(args)+1 : 0; if(n>0) addmsg(SV_EXTENSION, "rsis", ext, n, args); else addmsg(SV_EXTENSION, "rsi", ext, n); } COMMAND(serverextension, "ss"); assaultcube-1.2.0.2.1/source/src/clients2c.cpp000066400000000000000000001607311352165075300210240ustar00rootroot00000000000000// client processing of the incoming network stream #include "cube.h" #include "bot/bot.h" VARP(networkdebug, 0, 0, 1); #define DEBUGCOND (networkdebug==1) extern bool watchingdemo; extern string clientpassword; void *downloaddemomenu = NULL; static vector demo_mlines; packetqueue pktlogger; void neterr(const char *s) { conoutf("\f3illegal network message (%s)", s); // might indicate a client/server communication bug, create error report pktlogger.flushtolog("packetlog.txt"); conoutf("\f3wrote a network error report to packetlog.txt, please post this file to the bugtracker now!"); disconnect(); } VARP(autogetmap, 0, 1, 1); // only if the client doesn't have that map VARP(autogetnewmaprevisions, 0, 1, 1); VAR(disconnectonmaperror, 0, 1, 1); extern bool incompatiblemap; extern void trydisconnect(); bool localwrongmap = false; int MA = 0, Hhits = 0; // flowtron: moved here bool changemapserv(char *name, int mode, int download, int revision) // forced map change from the server { MA = Hhits = 0; // reset for checkarea() gamemode = mode; if(m_demo) return true; if(m_coop) { if(!name[0] || load_world(name) < 0) empty_world(0, true); return true; } else if(player1->state==CS_EDITING) { /*conoutf("SANITY drop from EDITING");*/ toggleedit(true); } // fix stuck-in-editmode bug bool loaded = load_world(name) >= 0; if(disconnectonmaperror && incompatiblemap && multiplayer(NULL)) trydisconnect(); if(download > 0) { bool revmatch = hdr.maprevision == revision || revision == 0; if(watchingdemo) { if(loaded && !revmatch) conoutf("\f3demo was recorded on map revision %d, you have map revision %d", revision, hdr.maprevision); } else { if(securemapcheck(name, false)) return true; bool sizematch = maploaded == download || download < 10; if(loaded && sizematch && revmatch) return true; bool getnewrev = autogetnewmaprevisions && revision > hdr.maprevision; if(autogetmap || getnewrev) { if(!loaded || getnewrev) getmap(); // no need to ask else { defformatstring(msg)("map '%s' revision: local %d, provided by server %d", name, hdr.maprevision, revision); alias("__getmaprevisions", msg, true); showmenu("getmap"); } } else { if(!loaded || download < 10) conoutf("\"getmap\" to download the current map from the server"); else conoutf("\"getmap\" to download a %s version of the current map from the server", revision == 0 ? "different" : (revision > hdr.maprevision ? "newer" : "older")); } } } else return true; return false; } // update the position of other clients in the game in our world // don't care if he's in the scenery or other players, // just don't overlap with our client void updateplayerpos(playerent *d) { const float r = player1->radius+d->radius; const float dx = player1->o.x-d->o.x; const float dy = player1->o.y-d->o.y; const float dz = player1->o.z-d->o.z; const float rz = player1->aboveeye+d->eyeheight; const float fx = (float)fabs(dx), fy = (float)fabs(dy), fz = (float)fabs(dz); if(fxstate!=CS_DEAD) { if(fxo.y += dy<0 ? r-fy : -(r-fy); // push aside else d->o.x += dx<0 ? r-fx : -(r-fx); } } void updatelagtime(playerent *d) { int lagtime = totalmillis-d->lastupdate; if(lagtime) { if(d->state!=CS_SPAWNING && d->lastupdate) d->plag = (d->plag*5+lagtime)/6; d->lastupdate = totalmillis; } } extern void trydisconnect(); void parsepositions(ucharbuf &p) { int type; while(p.remaining()) switch(type = getint(p)) { case SV_POS: // position of another client case SV_POSC: { int cn, f, g; vec o, vel; float yaw, pitch = 0; bool scoping;//, shoot; if(type == SV_POSC) { bitbuf q(p); cn = q.getbits(5); int usefactor = q.getbits(2) + 7; o.x = q.getbits(usefactor + 4) / DMF; o.y = q.getbits(usefactor + 4) / DMF; yaw = q.getbits(9) * 360.0f / 512; pitch = (q.getbits(8) - 128) * 90.0f / 127; if(!q.getbits(1)) q.getbits(6); if(!q.getbits(1)) { vel.x = (q.getbits(4) - 8) / DVELF; vel.y = (q.getbits(4) - 8) / DVELF; vel.z = (q.getbits(4) - 8) / DVELF; } else vel.x = vel.y = vel.z = 0.0f; f = q.getbits(8); int negz = q.getbits(1); int full = q.getbits(1); int s = q.rembits(); if(s < 3) s += 8; if(full) s = 11; int z = q.getbits(s); if(negz) z = -z; o.z = z / DMF; scoping = ( q.getbits(1) ? true : false ); q.getbits(1);//shoot = ( q.getbits(1) ? true : false ); } else { cn = getint(p); o.x = getuint(p)/DMF; o.y = getuint(p)/DMF; o.z = getuint(p)/DMF; yaw = (float)getuint(p); pitch = (float)getint(p); g = getuint(p); if ((g>>3) & 1) getint(p); if (g & 1) vel.x = getint(p)/DVELF; else vel.x = 0; if ((g>>1) & 1) vel.y = getint(p)/DVELF; else vel.y = 0; if ((g>>2) & 1) vel.z = getint(p)/DVELF; else vel.z = 0; scoping = ( (g>>4) & 1 ? true : false ); //shoot = ( (g>>5) & 1 ? true : false ); // we are not using this yet f = getuint(p); } int seqcolor = (f>>6)&1; playerent *d = getclient(cn); if(!d || seqcolor!=(d->lifesequence&1)) continue; vec oldpos(d->o); float oldyaw = d->yaw, oldpitch = d->pitch; loopi(3) { float dr = o.v[i] - d->o.v[i] + ( i == 2 ? d->eyeheight : 0); if ( !dr ) d->vel.v[i] = 0.0f; else if ( d->vel.v[i] ) d->vel.v[i] = dr * 0.05f + d->vel.v[i] * 0.95f; d->vel.v[i] += vel.v[i]; if ( i==2 && d->onfloor && d->vel.v[i] < 0.0f ) d->vel.v[i] = 0.0f; } d->o = o; d->o.z += d->eyeheight; d->yaw = yaw; d->pitch = pitch; if(d->weaponsel->type == GUN_SNIPER) { sniperrifle *sr = (sniperrifle *)d->weaponsel; sr->scoped = d->scoping = scoping; } d->strafe = (f&3)==3 ? -1 : f&3; f >>= 2; d->move = (f&3)==3 ? -1 : f&3; f >>= 2; d->onfloor = f&1; f >>= 1; d->onladder = f&1; f >>= 2; d->last_pos = totalmillis; updatecrouch(d, f&1); updateplayerpos(d); updatelagtime(d); extern int smoothmove, smoothdist; if(d->state==CS_DEAD) { d->resetinterp(); d->smoothmillis = 0; } else if(smoothmove && d->smoothmillis>=0 && oldpos.dist(d->o) < smoothdist) { d->newpos = d->o; d->newpos.z -= d->eyeheight; d->newyaw = d->yaw; d->newpitch = d->pitch; d->o = oldpos; d->yaw = oldyaw; d->pitch = oldpitch; oldpos.z -= d->eyeheight; (d->deltapos = oldpos).sub(d->newpos); d->deltayaw = oldyaw - d->newyaw; if(d->deltayaw > 180) d->deltayaw -= 360; else if(d->deltayaw < -180) d->deltayaw += 360; d->deltapitch = oldpitch - d->newpitch; d->smoothmillis = lastmillis; } else d->smoothmillis = 0; if(d->state==CS_LAGGED || d->state==CS_SPAWNING) d->state = CS_ALIVE; // when playing a demo spectate first player we know about if(player1->isspectating() && player1->spectatemode==SM_NONE) togglespect(); break; } default: neterr("type"); return; } } extern int checkarea(int maplayout_factor, char *maplayout); char *mlayout = NULL; int Mv = 0, Ma = 0, F2F = 1000 * MINFF; // moved up:, MA = 0; float Mh = 0; extern int connected; extern bool noflags; bool item_fail = false; int map_quality = MAP_IS_EDITABLE; /// TODO: many functions and variables are redundant between client and server... someone should redo the entire server code and unify client and server. bool good_map() // call this function only at startmap { return true; if (mlayout) MA = checkarea(sfactor, mlayout); F2F = 1000 * MINFF; if(m_flags) { // flaginfo &f0 = flaginfos[0]; // flaginfo &f1 = flaginfos[1]; #define DIST(x) (f0.pos.x - f1.pos.x) F2F = 1000;//(!numflagspawn[0] || !numflagspawn[1]) ? 1000 * MINFF : DIST(x)*DIST(x)+DIST(y)*DIST(y); #undef DIST } item_fail = false; loopv(ents) { entity &e1 = ents[i]; if (e1.type < I_CLIPS || e1.type > I_AKIMBO) continue; float density = 0, hdensity = 0; loopvj(ents) { entity &e2 = ents[j]; if (e2.type < I_CLIPS || e2.type > I_AKIMBO || i == j) continue; // only I_CLIPS, I_AMMO, I_GRENADE, I_HEALTH, I_HELMET, I_ARMOUR, I_AKIMBO #define DIST(x) (e1.x - e2.x) #define DIST_ATT ((e1.z + float(e1.attr1) / entscale[e1.type][0]) - (e2.z + float(e2.attr1) / entscale[e2.type][0])) float r2 = DIST(x)*DIST(x) + DIST(y)*DIST(y) + DIST_ATT*DIST_ATT; #undef DIST_ATT #undef DIST if ( r2 == 0.0f ) { conoutf("\f3MAP CHECK FAIL: Items too close %s %s (%hd,%hd)", entnames[e1.type], entnames[e2.type],e1.x,e1.y); item_fail = true; break; } r2 = 1/r2; if (r2 < 0.0025f) continue; if (e1.type != e2.type) { hdensity += r2; continue; } density += r2; } if ( hdensity > 0.5f ) { conoutf("\f3MAP CHECK FAIL: Items too close %s %.2f (%hd,%hd)", entnames[e1.type],hdensity,e1.x,e1.y); item_fail = true; break; } switch(e1.type) { #define LOGTHISSWITCH(X) if( density > X ) { conoutf("\f3MAP CHECK FAIL: Items too close %s %.2f (%hd,%hd)", entnames[e1.type],density,e1.x,e1.y); item_fail = true; break; } case I_CLIPS: case I_HEALTH: LOGTHISSWITCH(0.24f); break; case I_AMMO: LOGTHISSWITCH(0.04f); break; case I_HELMET: LOGTHISSWITCH(0.02f); break; case I_ARMOUR: case I_GRENADE: case I_AKIMBO: LOGTHISSWITCH(0.005f); break; default: break; #undef LOGTHISSWITCH } } map_quality = (!item_fail && F2F > MINFF && MA < MAXMAREA && Mh < MAXMHEIGHT && Hhits < MAXHHITS) ? MAP_IS_GOOD : MAP_IS_BAD; if ( (!connected || gamemode == GMODE_COOPEDIT) && map_quality == MAP_IS_BAD ) map_quality = MAP_IS_EDITABLE; return map_quality > 0; } VARP(hudextras, 0, 0, 3); int teamworkid = -1; char *strcaps(const char *s, bool on) { static string r; char *o = r; if(on) while(*s && o < &r[sizeof(r)-1]) *o++ = toupper(*s++); else while(*s && o < &r[sizeof(r)-1]) *o++ = tolower(*s++); *o = '\0'; return r; } void showhudextras(char hudextras, char value){ void (*outf)(const char *s, ...) = (hudextras > 1 ? hudoutf : conoutf); bool caps = hudextras < 3 ? false : true; switch(value) { case HE_COMBO: case HE_COMBO2: case HE_COMBO3: case HE_COMBO4: case HE_COMBO5: { int n = value - HE_COMBO; if (n > 3) outf("\f3%s",strcaps("monster combo!!!",caps)); // I expect to never see this one else if (!n) outf("\f5%s",strcaps("combo", caps)); else outf("\f5%s x%d",strcaps("multi combo", caps),n+1); break; } case HE_TEAMWORK: outf("\f5%s",strcaps("teamwork done", caps)); break; case HE_FLAGDEFENDED: outf("\f5%s",strcaps("you defended the flag", caps)); break; case HE_FLAGCOVERED: outf("\f5%s",strcaps("you covered the flag", caps)); break; case HE_COVER: if (teamworkid >= 0) { playerent *p = getclient(teamworkid); if (!p || p == player1) teamworkid = -1; else outf("\f5you covered %s",p->name); break; } default: { if (value >= HE_NUM) { teamworkid = value - HE_NUM; playerent *p = getclient(teamworkid); if (!p || p == player1) teamworkid = -1; else outf("\f4you replied to %s",p->name); } else outf("\f3Update your client!"); break; } } #undef SSPAM } int lastspawn = 0; void onCallVote(int type, int vcn, char *text, char *a) { exechook(HOOK_SP_MP, "onCallVote", "%d %d [%s] [%s]", type, vcn, text, a); } void onChangeVote(int mod, int id) { exechook(HOOK_SP_MP, "onChangeVote", "%d %d", mod, id); } VARP(voicecomsounds, 0, 1, 2); bool medals_arrived=0; medalsst a_medals[END_MDS]; void parsemessages(int cn, playerent *d, ucharbuf &p, bool demo = false) { static char text[MAXTRANS]; int type, joining = 0; while(p.remaining()) { type = getint(p); if(demo && watchingdemo && demoprotocol == 1132) { if(type > SV_IPLIST) --type; // SV_WHOIS removed if(type >= SV_TEXTPRIVATE) ++type; // SV_TEXTPRIVATE added if(type == SV_SWITCHNAME) // SV_SPECTCN removed { getint(p); continue; } else if(type > SV_SWITCHNAME) --type; } #ifdef _DEBUG if(type!=SV_POS && type!=SV_CLIENTPING && type!=SV_PING && type!=SV_PONG && type!=SV_CLIENT) { DEBUGVAR(d); ASSERT(type>=0 && typeclientnum = mycn; if(getint(p) > 0) conoutf("INFO: this server is password protected"); sendintro(); break; } case SV_WELCOME: joining = getint(p); player1->resetspec(); resetcamera(); break; case SV_CLIENT: { int cn = getint(p), len = getuint(p); ucharbuf q = p.subbuf(len); parsemessages(cn, getclient(cn), q, demo); break; } case SV_SOUND: audiomgr.playsound(getint(p), d); break; case SV_VOICECOMTEAM: { playerent *d = getclient(getint(p)); if(d) d->lastvoicecom = lastmillis; int t = getint(p); if(!d || !(d->muted || d->ignored)) { if ( voicecomsounds == 1 || (voicecomsounds == 2 && m_teammode) ) audiomgr.playsound(t, SP_HIGH); } break; } case SV_VOICECOM: { int t = getint(p); if(!d || !(d->muted || d->ignored)) { if ( voicecomsounds == 1 ) audiomgr.playsound(t, SP_HIGH); } if(d) d->lastvoicecom = lastmillis; break; } case SV_TEAMTEXTME: case SV_TEAMTEXT: { int cn = getint(p); getstring(text, p); filtertext(text, text, FTXT__CHAT); playerent *d = getclient(cn); if(!d) break; if(d->ignored) clientlogf("ignored: %s%s %s", colorname(d), type == SV_TEAMTEXT ? ":" : "", text); else { if(m_teammode || team_isspect(player1->team)) conoutf(type == SV_TEAMTEXTME ? "\f1%s %s" : "%s:\f1 %s", colorname(d), highlight(text)); else conoutf(type == SV_TEAMTEXTME ? "\f0%s %s" : "%s:\f0 %s", colorname(d), highlight(text)); } break; } case SV_TEXTME: case SV_TEXT: if(cn == -1) { getstring(text, p); conoutf("MOTD:"); conoutf("\f4%s", text); } else if(d) { getstring(text, p); filtertext(text, text, FTXT__CHAT); if(d->ignored && d->clientrole != CR_ADMIN) clientlogf("ignored: %s%s %s", colorname(d), type == SV_TEXT ? ":" : "", text); else conoutf(type == SV_TEXTME ? "\f0%s %s" : "%s:\f0 %s", colorname(d), highlight(text)); } else return; break; case SV_TEXTPRIVATE: { int cn = getint(p); getstring(text, p); filtertext(text, text, FTXT__CHAT); playerent *d = getclient(cn); if(!d) break; if(d->ignored) clientlogf("ignored: pm %s %s", colorname(d), text); else { conoutf("%s (PM):\f9 %s", colorname(d), highlight(text)); lastpm = d->clientnum; exechook(HOOK_SP_MP, "onPM", "%d [%s]", d->clientnum, text); } break; } case SV_MAPCHANGE: { extern int spawnpermission; spawnpermission = SP_SPECT; getstring(text, p); int mode = getint(p); int downloadable = getint(p); int revision = getint(p); localwrongmap = !changemapserv(text, mode, downloadable, revision); if(m_arena && joining > 1 && !watchingdemo) deathstate(player1); break; } case SV_ITEMLIST: { int n; resetpickups(); while((n = getint(p))!=-1) setpickupspawn(n, true); break; } case SV_MAPIDENT: { loopi(2) getint(p); break; } case SV_SWITCHNAME: getstring(text, p); filtertext(text, text, FTXT__PLAYERNAME, MAXNAMELEN); if(!text[0]) copystring(text, "unarmed"); if(d) { if(strcmp(d->name, text)) conoutf("%s is now known as %s", colorname(d), colorname(d, text)); exechook(HOOK_SP, "onNameChange", "%d \"%s\"", d->clientnum, text); copystring(d->name, text, MAXNAMELEN+1); updateclientname(d); } break; case SV_SWITCHTEAM: getint(p); break; case SV_SWITCHSKIN: loopi(2) { int skin = getint(p); if(d) d->setskin(i, skin); } break; case SV_INITCLIENT: // another client either connected or changed name/team { int cn = getint(p); playerent *d = newclient(cn); if(!d) { getstring(text, p); loopi(2) getint(p); getint(p); if(!demo || !watchingdemo || demoprotocol > 1132) getint(p); break; } getstring(text, p); filtertext(text, text, FTXT__PLAYERNAME, MAXNAMELEN); if(!text[0]) copystring(text, "unarmed"); if(d->name[0]) // already connected { if(strcmp(d->name, text)) conoutf("%s is now known as %s", colorname(d), colorname(d, text)); } else // new client { conoutf("connected: %s", colorname(d, text)); } copystring(d->name, text, MAXNAMELEN+1); exechook(HOOK_SP_MP, "onConnect", "%d", d->clientnum); loopi(2) d->setskin(i, getint(p)); d->team = getint(p); // d->maxroll = (float)clamp(getint(p), 0, ROLLMOVMAX); FIXME: uncomment on protocol bump + etc. // d->maxrolleffect = (float)clamp(getint(p), 0, ROLLEFFMAX); FIXME: uncomment on protocol bump if(!demo || !watchingdemo || demoprotocol > 1132) d->address = getint(p); // partial IP address if(m_flags) loopi(2) { flaginfo &f = flaginfos[i]; if(!f.actor) f.actor = getclient(f.actor_cn); } updateclientname(d); break; } case SV_CDIS: { int cn = getint(p); playerent *d = getclient(cn); if(!d) break; if(d->name[0]) conoutf("player %s disconnected", colorname(d)); zapplayer(players[cn]); exechook(HOOK_SP_MP, "onDisconnect", "%d", d->clientnum); break; } case SV_EDITMODE: { int val = getint(p); if(!d) break; if(val) d->state = CS_EDITING; else d->state = CS_ALIVE; break; } case SV_SPAWN: { playerent *s = d; if(!s) { static playerent dummy; s = &dummy; } s->respawn(); s->lifesequence = getint(p); s->health = getint(p); s->armour = getint(p); int gunselect = getint(p); s->setprimary(gunselect); s->selectweapon(gunselect); loopi(NUMGUNS) s->ammo[i] = getint(p); loopi(NUMGUNS) s->mag[i] = getint(p); s->state = CS_SPAWNING; arenaintermission = 0; if(s->lifesequence==0) s->resetstats(); //NEW break; } case SV_SPAWNSTATE: { if ( map_quality == MAP_IS_BAD ) { loopi(6+2*NUMGUNS) getint(p); conoutf("map deemed unplayable - fix it before you can spawn"); break; } if(editmode) toggleedit(true); showscores(false); setscope(false); setburst(false); player1->respawn(); player1->lifesequence = getint(p); player1->health = getint(p); player1->armour = getint(p); player1->setprimary(getint(p)); player1->selectweapon(getint(p)); int arenaspawn = getint(p); loopi(NUMGUNS) player1->ammo[i] = getint(p); loopi(NUMGUNS) player1->mag[i] = getint(p); player1->state = CS_ALIVE; lastspawn = lastmillis; findplayerstart(player1, false, arenaspawn); arenaintermission = 0; if(m_arena && !localwrongmap) { if(connected) closemenu(NULL); conoutf("new round starting... fight!"); hudeditf(HUDMSG_TIMER, "FIGHT!"); if(m_botmode) BotManager.RespawnBots(); } addmsg(SV_SPAWN, "rii", player1->lifesequence, player1->weaponsel->type); player1->weaponswitch(player1->primweap); player1->weaponchanging -= weapon::weaponchangetime/2; if(player1->lifesequence==0) player1->resetstats(); //NEW break; } case SV_SHOTFX: { int scn = getint(p), gun = getint(p); vec from, to; loopk(3) to[k] = getint(p)/DMF; playerent *s = getclient(scn); if(!s || !valid_weapon(gun)) break; loopk(3) from[k] = s->o.v[k]; if(gun==GUN_SHOTGUN) createrays(from, to); s->lastaction = lastmillis; s->weaponchanging = 0; s->mag[gun]--; if(s->weapons[gun]) { s->lastattackweapon = s->weapons[gun]; s->weapons[gun]->gunwait = s->weapons[gun]->info.attackdelay; s->weapons[gun]->attackfx(from, to, -1); s->weapons[gun]->reloading = 0; } s->pstatshots[gun]++; //NEW break; } case SV_THROWNADE: { vec from, to; loopk(3) from[k] = getint(p)/DMF; loopk(3) to[k] = getint(p)/DMF; int nademillis = getint(p); if(!d) break; d->lastaction = lastmillis; d->weaponchanging = 0; d->lastattackweapon = d->weapons[GUN_GRENADE]; if(d->weapons[GUN_GRENADE]) { d->weapons[GUN_GRENADE]->attackfx(from, to, nademillis); d->weapons[GUN_GRENADE]->reloading = 0; } if(d!=player1) d->pstatshots[GUN_GRENADE]++; //NEW break; } case SV_RELOAD: { int cn = getint(p), gun = getint(p); playerent *p = getclient(cn); if(p && p!=player1) p->weapons[gun]->reload(false); break; } // for AUTH: WIP case SV_AUTHREQ: { // extern int autoauth; getstring(text, p); // if(autoauth && text[0] && tryauth(text)) conoutf("server requested authkey \"%s\"", text); break; } case SV_AUTHCHAL: { getstring(text, p); // authkey *a = findauthkey(text); // uint id = (uint)getint(p); getstring(text, p); // if(a && a->lastauth && lastmillis - a->lastauth < 60*1000) { // vector buf; // answerchallenge(a->key, text, buf); //conoutf("answering %u, challenge %s with %s", id, text, buf.getbuf()); // addmsg(SV_AUTHANS, "rsis", a->desc, id, buf.getbuf()); } break; } // :for AUTH case SV_GIBDAMAGE: case SV_DAMAGE: { int tcn = getint(p), acn = getint(p), gun = getint(p), damage = getint(p), armour = getint(p), health = getint(p); playerent *target = getclient(tcn), *actor = getclient(acn); if(!target || !actor) break; target->armour = armour; target->health = health; dodamage(damage, target, actor, -1, type==SV_GIBDAMAGE, false); actor->pstatdamage[gun]+=damage; //NEW break; } case SV_POINTS: { int count = getint(p); if ( count > 0 ) { loopi(count){ int pcn = getint(p); int score = getint(p); playerent *ppl = getclient(pcn); if (!ppl) break; ppl->points += score; } } else { int medals = getint(p); if(medals > 0) { // medals_arrived=1; loopi(medals) { int mcn=getint(p); int mtype=getint(p); int mitem=getint(p); a_medals[mtype].assigned=1; a_medals[mtype].cn=mcn; a_medals[mtype].item=mitem; } } } break; } case SV_HUDEXTRAS: { char value = getint(p); if (hudextras) showhudextras(hudextras, value); break; } case SV_HITPUSH: { int gun = getint(p), damage = getint(p); vec dir; loopk(3) dir[k] = getint(p)/DNF; player1->hitpush(damage, dir, NULL, gun); break; } case SV_GIBDIED: case SV_DIED: { int vcn = getint(p), acn = getint(p), frags = getint(p), gun = getint(p); playerent *victim = getclient(vcn), *actor = getclient(acn); if(!actor) break; if ( m_mp(gamemode) ) actor->frags = frags; if(!victim) break; dokill(victim, actor, type==SV_GIBDIED, gun); break; } case SV_RESUME: { loopi(MAXCLIENTS) { int cn = getint(p); if(p.overread() || cn<0) break; int state = getint(p), lifesequence = getint(p), primary = getint(p), gunselect = getint(p), flagscore = getint(p), frags = getint(p), deaths = getint(p), health = getint(p), armour = getint(p), points = getint(p); int teamkills = 0; if(!demo || !watchingdemo || demoprotocol > 1132) teamkills = getint(p); int ammo[NUMGUNS], mag[NUMGUNS]; loopi(NUMGUNS) ammo[i] = getint(p); loopi(NUMGUNS) mag[i] = getint(p); playerent *d = (cn == getclientnum() ? player1 : newclient(cn)); if(!d) continue; if(d!=player1) d->state = state; d->lifesequence = lifesequence; d->flagscore = flagscore; d->frags = frags; d->deaths = deaths; d->points = points; d->tks = teamkills; if(d!=player1) { d->setprimary(primary); d->selectweapon(gunselect); d->health = health; d->armour = armour; memcpy(d->ammo, ammo, sizeof(ammo)); memcpy(d->mag, mag, sizeof(mag)); if(d->lifesequence==0) d->resetstats(); //NEW } } break; } case SV_DISCSCORES: { discscores.shrink(0); int team; while((team = getint(p)) >= 0) { discscore &ds = discscores.add(); ds.team = team; getstring(text, p); filtertext(ds.name, text, FTXT__PLAYERNAME, MAXNAMELEN); ds.flags = getint(p); ds.frags = getint(p); ds.deaths = getint(p); ds.points = getint(p); } break; } case SV_ITEMSPAWN: { int i = getint(p); setpickupspawn(i, true); break; } case SV_ITEMACC: { int i = getint(p), cn = getint(p); playerent *d = getclient(cn); pickupeffects(i, d); break; } case SV_EDITXY: // coop editing messages, should be extended to include all possible editing ops { int cmd = getint(p); int x = getint(p); int y = getint(p); int xs = getint(p); int ys = getint(p); int a1 = getint(p); int a2 = getint(p); if(m_coop && !OUTBORD(x,y) && xs > 0 && ys > 0 && !OUTBORD(x + xs-1, y + ys - 1)) { block b = { x, y, xs, ys }; switch(cmd) { case EDITXY_HEIGHT: editheightxy(a1 != 0, a2, b); break; case EDITXY_TEX: edittexxy(a1, a2, b); break; case EDITXY_TYPE: edittypexy(a1, b); break; case EDITXY_VDELTA: setvdeltaxy(a1, b); break; case EDITXY_EQUALISE: editequalisexy(a1 != 0, b); break; case EDITXY_TAG: edittagxy(a1, a2, b); break; case EDITXY_SLOPE: slopexy(a1, a2, b); break; case EDITXY_STAIRS: stairsxy(a1, a2, b); break; case EDITXY_FLIPROT: selfliprotate(b, a1); break; } } break; } case SV_EDITARCH: { int av[50]; // MAXARCHVERT, hardcoded int x = getint(p); int y = getint(p); int xs = getint(p); int ys = getint(p); int a1 = getint(p); loopi(50) av[i] = getint(p); if(m_coop && !OUTBORD(x,y) && xs > 0 && ys > 0 && !OUTBORD(x + xs-1, y + ys - 1)) { block b = { x, y, xs, ys }; archxy(a1, av, b); } break; } case SV_EDITBLOCK: { int bx = getuint(p), by = getuint(p), bxs = getuint(p), bys = getuint(p), light = getuint(p); ucharbuf *pp = getgzbuf(p); if(m_coop) netblockpastexy(pp, bx, by, bxs, bys, light); freegzbuf(pp); break; } case SV_NEWMAP: { int size = getint(p); if(!m_coop) break; if(size < 0 && sfactor > 9) break; // don't enlarge over 10 in MP empty_world(size, true); if(d && d!=player1) conoutf(size>=0 ? "%s started a new map of size %d" : "%s enlarged the map to size %d", colorname(d), sfactor); break; } case SV_EDITENT: // coop edit of ent { if(!m_coop) { loopi(12) getint(p); break; } uint i = getint(p); while((uint)ents.length()<=i) ents.add().type = NOTUSED; int to = ents[i].type; if(ents[i].type==SOUND) { entity &e = ents[i]; entityreference entref(&e); location *loc = audiomgr.locations.find(e.attr1, &entref, mapsounds); if(loc) loc->drop(); } ents[i].type = getint(p); ents[i].x = getint(p); ents[i].y = getint(p); ents[i].z = getint(p); ents[i].attr1 = getint(p); ents[i].attr2 = getint(p); ents[i].attr3 = getint(p); ents[i].attr4 = getint(p); ents[i].attr5 = getint(p); ents[i].attr6 = getint(p); ents[i].attr7 = getint(p); ents[i].spawned = false; if(ents[i].type==LIGHT || to==LIGHT) calclight(); if(ents[i].type==SOUND) audiomgr.preloadmapsound(ents[i]); break; } case SV_PONG: { int millis = getint(p); addmsg(SV_CLIENTPING, "i", player1->ping = max(0, (player1->ping*5+totalmillis-millis)/6)); break; } case SV_CLIENTPING: if(!d) return; d->ping = getint(p); break; case SV_GAMEMODE: nextmode = getint(p); if (nextmode >= GMODE_NUM) nextmode -= GMODE_NUM; break; case SV_TIMEUP: { int curgamemillis = getint(p); int curgamelimit = getint(p); timeupdate(curgamemillis, curgamelimit); break; } case SV_WEAPCHANGE: { int gun = getint(p); if(d) d->selectweapon(gun); break; } case SV_SERVMSG: getstring(text, p); conoutf("%s", text); break; case SV_FLAGINFO: { int flag = getint(p); if(flag<0 || flag>1) return; flaginfo &f = flaginfos[flag]; f.state = getint(p); switch(f.state) { case CTFF_STOLEN: flagstolen(flag, getint(p)); break; case CTFF_DROPPED: { float x = getuint(p)/DMF; float y = getuint(p)/DMF; float z = getuint(p)/DMF; flagdropped(flag, x, y, z); break; } case CTFF_INBASE: flaginbase(flag); break; case CTFF_IDLE: flagidle(flag); break; } break; } case SV_FLAGMSG: { int flag = getint(p); int message = getint(p); int actor = getint(p); int flagtime = message == FM_KTFSCORE ? getint(p) : -1; flagmsg(flag, message, actor, flagtime); break; } case SV_FLAGCNT: { int fcn = getint(p); int flags = getint(p); playerent *p = getclient(fcn); if(p) p->flagscore = flags; break; } case SV_ARENAWIN: { int acn = getint(p); playerent *alive = getclient(acn); conoutf("the round is over! next round in 5 seconds..."); if(m_botmode && acn==-2) hudoutf("the bots have won the round!"); else if(acn==-1) hudoutf("everyone died!"); else if(m_teammode) hudoutf("team %s has won the round!", team_string(alive->team)); else if(alive==player1) hudoutf("you are the survivor!"); else hudoutf("%s is the survivor!", colorname(alive)); arenaintermission = lastmillis; break; } case SV_SPAWNDENY: { extern int spawnpermission; spawnpermission = getint(p); if(spawnpermission == SP_REFILLMATCH) hudoutf("\f3you can spawn now to refill your team"); break; } case SV_FORCEDEATH: { int cn = getint(p); playerent *d = cn==getclientnum() ? player1 : newclient(cn); if(!d) break; deathstate(d); break; } case SV_SERVOPINFO: { loopv(players) { if(players[i]) players[i]->clientrole = CR_DEFAULT; } player1->clientrole = CR_DEFAULT; int cl = getint(p), r = getint(p); if(cl >= 0 && r >= 0) { playerent *pl = (cl == getclientnum() ? player1 : newclient(cl)); if(pl) { pl->clientrole = r; if(pl->name[0]) { // two messages required to allow for proper german translation - is there a better way to do it? if(pl==player1) conoutf("you claimed %s status", r == CR_ADMIN ? "admin" : "master"); else conoutf("%s claimed %s status", colorname(pl), r == CR_ADMIN ? "admin" : "master"); } } } break; } case SV_TEAMDENY: { int t = getint(p); if(m_teammode) { if(team_isvalid(t)) conoutf("you can't change to team %s", team_string(t)); } else { if(team_isspect(t)) conoutf("you can't change to spectate mode"); else if (player1->state!=CS_ALIVE) conoutf("you can't change to active mode"); else conoutf("you can't switch teams while being alive"); } break; } case SV_SETTEAM: { int fpl = getint(p), fnt = getint(p), ftr = fnt >> 4; fnt &= 0x0f; playerent *d = (fpl == getclientnum() ? player1 : newclient(fpl)); if(d) { const char *nts = team_string(fnt); bool you = fpl == player1->clientnum; if(m_teammode || team_isspect(fnt)) { if(d->team == fnt) { if(you && ftr == FTR_AUTOTEAM) hudoutf("you stay in team %s", nts); } else { if(you && !watchingdemo) { switch(ftr) { case FTR_PLAYERWISH: conoutf("you're now in team %s", nts); break; case FTR_AUTOTEAM: hudoutf("the server forced you to team %s", nts); break; } } else { const char *pls = colorname(d); bool et = team_base(player1->team) != team_base(fnt); switch(ftr) { case FTR_PLAYERWISH: conoutf("player %s switched to team %s", pls, nts); // new message break; case FTR_AUTOTEAM: if(watchingdemo || team_isspect(player1->team)) conoutf("the server forced %s to team %s", colorname(d), nts); else hudoutf("the server forced %s to %s team", colorname(d), et ? "the enemy" : "your"); break; } } if(you && !team_isspect(d->team) && team_isspect(fnt) && d->state == CS_DEAD) spectatemode(SM_FLY); } } else if(d->team != fnt && ftr == FTR_PLAYERWISH && !team_isactive(d->team)) conoutf("%s changed to active play", you ? "you" : colorname(d)); d->team = fnt; if(team_isspect(d->team)) d->state = CS_SPECTATE; } break; } case SV_SERVERMODE: { int sm = getint(p); servstate.autoteam = sm & 1; servstate.mastermode = (sm >> 2) & MM_MASK; servstate.matchteamsize = sm >> 4; //if(sm & AT_SHUFFLE) playsound(TEAMSHUFFLE); // TODO break; } case SV_CALLVOTE: { int type = getint(p); int vcn = -1, n_yes = 0, n_no = 0; if ( type == -1 ) { d = getclient(vcn = getint(p)); n_yes = getint(p); n_no = getint(p); type = getint(p); } if (type == SA_MAP && d == NULL) d = player1; // gonext uses this if( type < 0 || type >= SA_NUM || !d ) return; votedisplayinfo *v = NULL; string a1, a2; switch(type) { case SA_MAP: { getstring(text, p); int mode = getint(p); if(m_isdemo(mode)) filtertext(text, text, FTXT__DEMONAME); else filtertext(text, behindpath(text), FTXT__MAPNAME); itoa(a1, mode); defformatstring(t)("%d", getint(p)); v = newvotedisplayinfo(d, type, text, a1, t); break; } case SA_KICK: case SA_BAN: { itoa(a1, getint(p)); getstring(text, p); filtertext(text, text, FTXT__CHAT); v = newvotedisplayinfo(d, type, a1, text); break; } case SA_SERVERDESC: getstring(text, p); filtertext(text, text, FTXT__SERVDESC); v = newvotedisplayinfo(d, type, text, NULL); break; case SA_STOPDEMO: // compatibility break; case SA_REMBANS: case SA_SHUFFLETEAMS: v = newvotedisplayinfo(d, type, NULL, NULL); break; case SA_FORCETEAM: itoa(a1, getint(p)); itoa(a2, getint(p)); v = newvotedisplayinfo(d, type, a1, a2); break; default: itoa(a1, getint(p)); v = newvotedisplayinfo(d, type, a1, NULL); break; } displayvote(v); onCallVote(type, v->owner->clientnum, text, a1); if (vcn >= 0) { loopi(n_yes) votecount(VOTE_YES); loopi(n_no) votecount(VOTE_NO); } extern int vote(int); if (d == player1) vote(VOTE_YES); break; } case SV_CALLVOTESUC: { callvotesuc(); onChangeVote( 0, -1); break; } case SV_CALLVOTEERR: { int errn = getint(p); callvoteerr(errn); onChangeVote( 1, errn); break; } case SV_VOTE: { int vote = getint(p); votecount(vote); onChangeVote( 2, vote); break; } case SV_VOTERESULT: { int vres = getint(p); voteresult(vres); onChangeVote( 3, vres); break; } case SV_IPLIST: { int cn; while((cn = getint(p)) >= 0 && !p.overread()) { playerent *pl = getclient(cn); int ip = getint(p); if(!pl) continue; else pl->address = ip; } break; } case SV_SENDDEMOLIST: { int demos = getint(p); menureset(downloaddemomenu); demo_mlines.shrink(0); if(!demos) { conoutf("no demos available"); mline &m = demo_mlines.add(); copystring(m.name, "no demos available"); menuitemmanual(downloaddemomenu,m.name); } else { demo_mlines.reserve(demos); loopi(demos) { getstring(text, p); conoutf("%d. %s", i+1, text); mline &m = demo_mlines.add(); formatstring(m.name)("%d. %s", i+1, text); formatstring(m.cmd)("getdemo %d", i+1); menuitemmanual(downloaddemomenu, m.name, m.cmd); } } break; } case SV_DEMOPLAYBACK: { bool demoplayback = false; string demofile; extern char *curdemofile; if(demo && watchingdemo && demoprotocol == 1132) { watchingdemo = demoplayback = getint(p)!=0; copystring(demofile, "n/a"); } else { getstring(demofile, p, MAXSTRLEN); watchingdemo = demoplayback = demofile[0] != '\0'; } DELETEA(curdemofile); if(demoplayback) { curdemofile = newstring(demofile); player1->resetspec(); player1->state = CS_SPECTATE; player1->team = TEAM_SPECT; } else { // cleanups curdemofile = newstring("n/a"); loopv(players) zapplayer(players[i]); clearvote(); player1->state = CS_ALIVE; player1->resetspec(); } player1->clientnum = getint(p); break; } default: neterr("type"); return; } } #ifdef _DEBUG protocoldebug(false); #endif } void setDemoFilenameFormat(char *fmt) { extern string demofilenameformat; if(fmt && fmt[0]!='\0') { copystring(demofilenameformat, fmt); } else copystring(demofilenameformat, DEFDEMOFILEFMT); // reset to default if passed empty string - or should we output the current value in this case? } COMMANDN(demonameformat, setDemoFilenameFormat, "s"); void setDemoTimestampFormat(char *fmt) { extern string demotimestampformat; if(fmt && fmt[0]!='\0') { copystring(demotimestampformat, fmt); } else copystring(demotimestampformat, DEFDEMOTIMEFMT); // reset to default if passed empty string - or should we output the current value in this case? } COMMANDN(demotimeformat, setDemoTimestampFormat, "s"); void setDemoTimeLocal(int *truth) { extern int demotimelocal; demotimelocal = *truth == 0 ? 0 : 1; } COMMANDN(demotimelocal, setDemoTimeLocal, "i"); void getdemonameformat() { extern string demofilenameformat; result(demofilenameformat); } COMMAND(getdemonameformat, ""); void getdemotimeformat() { extern string demotimestampformat; result(demotimestampformat); } COMMAND(getdemotimeformat, ""); void getdemotimelocal() { extern int demotimelocal; intret(demotimelocal); } COMMAND(getdemotimelocal, ""); const char *parseDemoFilename(char *srvfinfo) { int gmode = 0; //-314; int mplay = 0; int mdrop = 0; int stamp = 0; string srvmap; if(srvfinfo && srvfinfo[0]) { int fip = 0; char sep[] = ":"; char *pch, *b; pch = strtok_r(srvfinfo, sep, &b); while (pch != NULL && fip < 4) { fip++; switch(fip) { case 1: gmode = atoi(pch); break; case 2: mplay = atoi(pch); break; case 3: mdrop = atoi(pch); break; case 4: stamp = atoi(pch); break; default: break; } pch = strtok_r(NULL, sep, &b); } copystring(srvmap, pch); } extern const char *getDemoFilename(int gmode, int mplay, int mdrop, int tstamp, char *srvmap); return getDemoFilename(gmode, mplay, mdrop, stamp, srvmap); } void receivefile(uchar *data, int len) { static char text[MAXTRANS]; ucharbuf p(data, len); int type = getint(p); data += p.length(); len -= p.length(); switch(type) { case SV_SENDDEMO: { getstring(text, p); extern string demosubpath; defformatstring(demofn)("%s", parseDemoFilename(text)); defformatstring(fname)("demos/%s%s.dmo", demosubpath, demofn); copystring(demosubpath, ""); data += strlen(text); int demosize = getint(p); if(p.remaining() < demosize) { p.forceoverread(); break; } path(fname); stream *demo = openfile(fname, "wb"); if(!demo) { conoutf("failed writing to \"%s\"", fname); return; } conoutf("received demo \"%s\"", fname); demo->write(&p.buf[p.len], demosize); delete demo; break; } case SV_RECVMAP: { getstring(text, p); conoutf("received map \"%s\" from server, reloading..", text); int mapsize = getint(p); int cfgsize = getint(p); int cfgsizegz = getint(p); /* int revision = */ getint(p); int size = mapsize + cfgsizegz; if(MAXMAPSENDSIZE < mapsize + cfgsizegz || cfgsize > MAXCFGFILESIZE) { // sam's suggestion conoutf("map %s is too large to receive", text); } else { if(p.remaining() < size) { p.forceoverread(); break; } if(securemapcheck(text)) { p.len += size; break; } writemap(path(text), mapsize, &p.buf[p.len]); p.len += mapsize; writecfggz(path(text), cfgsize, cfgsizegz, &p.buf[p.len]); p.len += cfgsizegz; } break; } default: p.len = 0; parsemessages(-1, NULL, p); break; } } void servertoclient(int chan, uchar *buf, int len, bool demo) // processes any updates from the server { ucharbuf p(buf, len); switch(chan) { case 0: parsepositions(p); break; case 1: parsemessages(-1, NULL, p, demo); break; case 2: receivefile(p.buf, p.maxlen); break; } } void localservertoclient(int chan, uchar *buf, int len, bool demo) // processes any updates from the server { // pktlogger.queue(enet_packet_create (buf, len, 0)); // log local & demo packets servertoclient(chan, buf, len, demo); } assaultcube-1.2.0.2.1/source/src/command.cpp000066400000000000000000001741171352165075300205570ustar00rootroot00000000000000// command.cpp: implements the parsing and execution of a tiny script language which // is largely backwards compatible with the quake console language. #include "cube.h" #define CSLIMIT_LOOKUPNESTING 3 // fails silently #define CSLIMIT_RECURSION 333 // rarely depths over 20 will be reached and setting this one over 10000 won't prevent crashes anymore #define CSLIMIT_PUSHLEVEL 33 // beware: also grows with alias execution nesting as arg1 gets pushed #define CSLIMIT_ITERATION 33333 // determines length of endlees loop (while 1) #define CSLIMIT_STRINGLEN 333333 // yet another arbitrary limit inline bool identaccessdenied(ident *id); void cslimiterr(const char*msg); char *exchangestr(char *o, const char *n) { delete[] o; return newstring(n); } vector executionstack; // keep history of recursive command execution (to write to log in case of a crash) char *commandret = NULL; bool loop_break = false, loop_skip = false; // break or continue (skip) current loop int loop_level = 0; // avoid bad calls of break & continue hashtable *idents = NULL; // contains ALL vars/commands/aliases bool persistidents = false; bool currentcontextisolated = false; // true for map and model config files COMMANDF(persistidents, "s", (char *on) { if(on && *on) persistidents = ATOI(on) != 0; intret(persistidents ? 1 : 0); }); void clearstack(identstack *&stack) { while(stack) { delete[] stack->action; identstack *tmp = stack; stack = stack->next; delete tmp; } } void pushident(ident &id, char *val, int context = execcontext) { if(id.type != ID_ALIAS) { delete[] val; return; } int d = 0; for(identstack *s = id.stack; s; s = s->next, d++) { if(d > CSLIMIT_PUSHLEVEL) { cslimiterr("push level"); delete[] val; return; } } identstack *stack = new identstack; stack->action = id.executing==id.action ? newstring(id.action) : id.action; stack->context = id.context; stack->next = id.stack; id.stack = stack; id.action = val; id.context = context; } void popident(ident &id) { if(id.type != ID_ALIAS || !id.stack) return; if(id.action != id.executing) delete[] id.action; identstack *stack = id.stack; id.action = stack->action; id.stack = stack->next; id.context = stack->context; delete stack; } ident *newident(const char *name, int context = execcontext) { ident *id = idents->access(name); if(!id) { ident init(ID_ALIAS, newstring(name), newstring(""), persistidents, context); id = &idents->access(init.name, init); } return id; } void pusha(const char *name, char *action) { ident *id = newident(name, execcontext); if(identaccessdenied(id)) { conoutf("cannot redefine alias %s in this execution context", id->name); scripterr(); return; } pushident(*id, action); } void push(const char *name, const char *action) { pusha(name, newstring(action)); } COMMAND(push, "ss"); void pop(const char *name) { ident *id = idents->access(name); if(!id || id->type != ID_ALIAS) conoutf("unknown alias %s", name); else if(identaccessdenied(id)) conoutf("cannot redefine alias %s in this execution context", name); else if(!id->stack) conoutf("ident stack exhausted"); else { popident(*id); return; } scripterr(); } COMMANDF(pop, "v", (char **args, int numargs) { if(numargs > 0) { const char *beforepopval = getalias(args[0]); if(beforepopval) commandret = newstring(beforepopval); } loopi(numargs) pop(args[i]); }); void delalias(const char *name) { ident *id = idents->access(name); if(!id || id->type != ID_ALIAS) conoutf("unknown alias %s", name); else if(identaccessdenied(id)) conoutf("cannot remove alias %s in this execution context", id->name); else { clearstack(id->stack); idents->remove(name); return; } scripterr(); } COMMAND(delalias, "s"); void alias(const char *name, const char *action, bool temp, bool constant) { ident *b = idents->access(name); if(!b) { // new alias ident b(ID_ALIAS, newstring(name), newstring(action), persistidents && !constant && !temp, execcontext); b.isconst = constant; b.istemp = temp; idents->access(b.name, b); return; } else if(b->type != ID_ALIAS) conoutf("cannot redefine builtin %s with an alias", name); else if(identaccessdenied(b)) conoutf("cannot redefine alias %s in this execution context", name); else if(b->isconst) conoutf("alias %s is a constant and cannot be redefined", name); else { // new action b->isconst = constant; if(temp) b->istemp = true; if(!constant || (action && action[0])) { if(b->action != b->executing) delete[] b->action; b->action = newstring(action); if(!b->stack) b->persist = persistidents != 0; } if(b->istemp) b->persist = false; return; } scripterr(); } COMMANDF(alias, "ss", (const char *name, const char *action) { alias(name, action, false, false); }); COMMANDF(tempalias, "ss", (const char *name, const char *action) { alias(name, action, true, false); }); COMMANDF(const, "ss", (const char *name, const char *action) { alias(name, action, false, true); }); COMMANDF(checkalias, "s", (const char *name) { intret(getalias(name) ? 1 : 0); }); COMMANDF(isconst, "s", (const char *name) { ident *id = idents->access(name); intret(id && id->isconst ? 1 : 0); }); // variable's and commands are registered through globals, see cube.h int variable(const char *name, int minval, int cur, int maxval, int *storage, void (*fun)(), bool persist) { if(!idents) idents = new hashtable; ident v(ID_VAR, name, minval, maxval, storage, cur, fun, persist, IEXC_CORE); idents->access(name, v); return cur; } float fvariable(const char *name, float minval, float cur, float maxval, float *storage, void (*fun)(), bool persist) { if(!idents) idents = new hashtable; ident v(ID_FVAR, name, minval, maxval, storage, cur, fun, persist, IEXC_CORE); idents->access(name, v); return cur; } char *svariable(const char *name, const char *cur, char **storage, void (*fun)(), void (*getfun)(), bool persist) { if(!idents) idents = new hashtable; ident v(ID_SVAR, name, storage, fun, getfun, persist, IEXC_CORE); idents->access(name, v); return newstring(cur); } #define GETVAR(id, vartype, name) \ ident *id = idents->access(name); \ ASSERT(id && id->type == vartype); \ if(!id || id->type!=vartype) return; void setvar(const char *name, int i, bool dofunc) { GETVAR(id, ID_VAR, name); *id->storage.i = clamp(i, id->minval, id->maxval); if(dofunc && id->fun) ((void (__cdecl *)())id->fun)(); // call trigger function if available } void setfvar(const char *name, float f, bool dofunc) { GETVAR(id, ID_FVAR, name); *id->storage.f = clamp(f, id->minvalf, id->maxvalf); if(dofunc && id->fun) ((void (__cdecl *)())id->fun)(); // call trigger function if available } void setsvar(const char *name, const char *str, bool dofunc) { GETVAR(id, ID_SVAR, name); *id->storage.s = exchangestr(*id->storage.s, str); if(dofunc && id->fun) ((void (__cdecl *)())id->fun)(); // call trigger function if available } bool identexists(const char *name) { return idents->access(name)!=NULL; } const char *getalias(const char *name) { ident *i = idents->access(name); return i && i->type==ID_ALIAS ? i->action : NULL; } void _getalias(char *name) { string o = ""; const char *res = o; ident *id = idents->access(name); if(id) { switch(id->type) { case ID_VAR: formatstring(o)("%d", *id->storage.i); break; case ID_FVAR: formatstring(o)("%.3f", *id->storage.f); break; case ID_SVAR: if(id->getfun) ((void (__cdecl *)())id->getfun)(); res = *id->storage.s; break; case ID_ALIAS: if(id->action) res = id->action; break; } } result(res); } COMMANDN(getalias, _getalias, "s"); #ifndef STANDALONE void getvarrange(char *_what, char *name) { ident *id = idents->access(name); const char *attrs[] = { "min", "max", "default", "" }; int what = getlistindex(_what, attrs, false, -1); if(id) { int *i = NULL; switch(what) { case 0: i = &(id->minval); break; case 1: i = &(id->maxval); break; case 2: i = &(id->defaultval); break; } if(i) switch(id->type) { case ID_VAR: intret(*i); return; case ID_FVAR: floatret(*((float *) i), true); return; } } result(""); } COMMAND(getvarrange, "ss"); #endif COMMANDF(isIdent, "s", (char *name) { intret(identexists(name) ? 1 : 0); }); bool addcommand(const char *name, void (*fun)(), const char *sig) { ASSERT(strlen(sig) < 9); if(!idents) idents = new hashtable; ident c(ID_COMMAND, name, fun, sig, IEXC_CORE); idents->access(name, c); return false; } inline char *parsequotes(const char *&p) { const char *word = p + 1; do { p++; p += strcspn(p, "\"\n\r"); } while(*p == '\"' && p[-1] == '\\'); // skip escaped quotes char *s = newstring(word, p - word); #ifndef STANDALONE filterrichtext(s, s, p - word); #endif if(*p=='\"') p++; return s; } char *lookup(char *n, int levels); char *parseexp(const char *&p, int right, int rec) // parse any nested set of () or [] { if(rec > CSLIMIT_RECURSION) { cslimiterr("recursion depth"); return NULL; } vector res; int left = *p++; const char *word = p; char *s; bool quot = false, issq = left == '['; for(int brak = 1; brak; ) { p += strcspn(p, "([\"])@"); int c = *p++; if(c==left && !quot) brak++; else if(c=='"') quot = !quot; else if(c==right && !quot) brak--; else if(!c) { p--; conoutf("missing \"%c\"", right); goto screrr; } else if(issq && c == '@' && !quot) { const char *sq = p; while(*p == '@') p++; int level = p - sq + 1; if(level == brak) { res.put(word, sq - word - 1); char *n, a = *p; switch(a) { case '(': n = parseexp(p, ')', rec + 1); break; case '"': n = parsequotes(p); break; case '[': n = parseexp(p, ']', rec + 1); if(n) n = lookup(n, 1); break; default: { const char *w = p; p += strcspn(p, "])@; \t\n\r"); n = lookup(newstring(w, p - w), 1); break; } } if(n) res.put(n, strlen(n)), delete[] n; word = p; } else if(level > brak) { conoutf("too many @"); goto screrr; } } } if(res.length()) { res.put(word, p - word - 1); if(res.length() > CSLIMIT_STRINGLEN) { cslimiterr("string length"); return newstring(""); } return newstring(res.getbuf(), res.length()); } s = newstring(word, p-word-1); if(left=='(') { char *ret = executeret(s); // evaluate () exps directly, and substitute result delete[] s; s = ret ? ret : newstring(""); } return s; screrr: scripterr(); flagmapconfigerror(LWW_SCRIPTERR * 4); return NULL; } char *lookup(char *n, int levels) // find value of ident referenced with $ in exp { if(levels > 1) n = exchangestr(n, lookup(newstring(n), min(levels - 1, CSLIMIT_LOOKUPNESTING - 1))); // nested ("$$var"), limit to three levels ident *id = idents->access(n); if(id) switch(id->type) { case ID_VAR: { string t; itoa(t, *id->storage.i); return exchangestr(n, t); } case ID_FVAR: return exchangestr(n, floatstr(*id->storage.f)); case ID_SVAR: { { if(id->getfun) ((void (__cdecl *)())id->getfun)(); } return exchangestr(n, *id->storage.s); } case ID_ALIAS: return exchangestr(n, id->action); } conoutf("unknown alias lookup: %s", n); scripterr(); flagmapconfigerror(LWW_SCRIPTERR * 4); return n; } char *parseword(const char *&p, int arg, int *infix, int rec) // parse single argument, including expressions { p += strspn(p, " \t"); if(p[0]=='/' && p[1]=='/') p += strcspn(p, "\n\r\0"); if(*p=='"') return parsequotes(p); if(*p=='(' && !currentcontextisolated) return parseexp(p, ')', rec + 1); if(*p=='[' && !currentcontextisolated) return parseexp(p, ']', rec + 1); int lvls = currentcontextisolated ? 0 : strspn(p, "$"); if(lvls && (p[lvls]=='(' || p[lvls]=='[')) { // $() $[] p += lvls; char *b = parseexp(p, *p == '(' ? ')' : ']', rec + 1); if(b) return lookup(b, lvls); } const char *word = p; p += strcspn(p, "; \t\n\r\0"); if(p-word==0) return NULL; if(arg == 1 && *word == '=' && p - word == 1) *infix = *word; return lvls ? lookup(newstring(word + lvls, p - word - lvls), lvls) : newstring(word, p-word); } char *conc(const char **w, int n, bool space) { if(n < 0) { // auto-determine number of strings n = 0; while(w[n] && w[n][0]) n++; } static vector wlen; wlen.setsize(0); int len = space ? max(n-1, 0) : 0; loopj(n) len += wlen.add((int)strlen(w[j])); if(len > CSLIMIT_STRINGLEN) { cslimiterr("string length"); return newstring(""); } char *r = newstring("", len), *res = r; loopi(n) { strncpy(r, w[i], wlen[i]); // make string-list out of all arguments r += wlen[i]; if(space) *r++ = ' '; } if(space && n) --r; *r = '\0'; return res; } VARN(numargs, _numargs, MAXWORDS, 0, 0); void intret(int v) { string t; itoa(t, v); commandret = newstring(t); } const char *floatstr(float v, bool neat) { static char s[2 * MAXSTRLEN]; static int i = 0; if(i > MAXSTRLEN - 10) i = 0; char *t = s + i; formatstring(t)(!neat && (v) == int(v) ? "%.1f" : "%.7g", v); // was ftoa() i += strlen(t) + 1; return t; } void floatret(float v, bool neat) { commandret = newstring(floatstr(v, neat)); } void result(const char *s) { commandret = newstring(s); } COMMAND(result, "s"); void resultcharvector(const vector &res, int adj) // use char vector as result, optionally remove some bytes at the end { adj += res.length(); if(adj > CSLIMIT_STRINGLEN) { cslimiterr("string length"); commandret = newstring(""); return; } commandret = adj <= 0 ? newstring("", 0) : newstring(res.getbuf(), (size_t) adj); } char *executeret(const char *p) // all evaluation happens here, recursively { if(!p || !p[0]) return NULL; if(executionstack.length() > CSLIMIT_RECURSION) { cslimiterr("recursion depth"); return NULL; } executionstack.add(p); char *w[MAXWORDS], emptychar = '\0'; char *retval = NULL; #define setretval(v) { char *rv = v; if(rv) retval = rv; } for(bool cont = true; cont;) // for each ; seperated statement { if(loop_level && loop_skip) break; int numargs = MAXWORDS, infix = 0; loopi(MAXWORDS) // collect all argument values { w[i] = &emptychar; if(i>numargs) continue; char *s = parseword(p, i, &infix, executionstack.length()); // parse and evaluate exps if(s) w[i] = s; else numargs = i; } p += strcspn(p, ";\n\r\0"); cont = *p++!=0; // more statements if this isn't the end of the string const char *c = w[0]; if(!*c) continue; // empty statement DELETEA(retval); if(infix == '=') { DELETEA(w[1]); swap(w[0], w[1]); c = "alias"; } ident *id = idents->access(c); if(!id) { if(!isdigit(*c) && ((*c!='+' && *c!='-' && *c!='.') || !isdigit(c[1]))) { conoutf("unknown command: %s", c); scripterr(); flagmapconfigerror(LWW_SCRIPTERR * 4); } setretval(newstring(c)); } else if(identaccessdenied(id)) { conoutf("not allowed in this execution context: %s", id->name); scripterr(); flagmapconfigerror(LWW_SCRIPTERR * 4); } else { switch(id->type) { case ID_COMMAND: // game defined commands { if(strstr(id->sig, "v")) ((void (__cdecl *)(char **, int))id->fun)(&w[1], numargs-1); else if(strstr(id->sig, "c") || strstr(id->sig, "w")) { char *r = conc((const char **)w+1, numargs-1, strstr(id->sig, "c") != NULL); ((void (__cdecl *)(char *))id->fun)(r); delete[] r; } else if(strstr(id->sig, "d")) { #ifndef STANDALONE ((void (__cdecl *)(bool))id->fun)(addreleaseaction(id->name)!=NULL); #endif } else { int ib1, ib2, ib3, ib4, ib5, ib6, ib7, ib8; float fb1, fb2, fb3, fb4, fb5, fb6, fb7, fb8; #define ARG(i) (id->sig[i-1] == 'i' ? ((void *)&(ib##i=strtol(w[i], NULL, 0))) : (id->sig[i-1] == 'f' ? ((void *)&(fb##i=atof(w[i]))) : (void *)w[i])) switch(strlen(id->sig)) // use very ad-hoc function signature, and just call it { case 0: ((void (__cdecl *)())id->fun)(); break; case 1: ((void (__cdecl *)(void*))id->fun)(ARG(1)); break; case 2: ((void (__cdecl *)(void*, void*))id->fun)(ARG(1), ARG(2)); break; case 3: ((void (__cdecl *)(void*, void*, void*))id->fun)(ARG(1), ARG(2), ARG(3)); break; case 4: ((void (__cdecl *)(void*, void*, void*, void*))id->fun)(ARG(1), ARG(2), ARG(3), ARG(4)); break; case 5: ((void (__cdecl *)(void*, void*, void*, void*, void*))id->fun)(ARG(1), ARG(2), ARG(3), ARG(4), ARG(5)); break; case 6: ((void (__cdecl *)(void*, void*, void*, void*, void*, void*))id->fun)(ARG(1), ARG(2), ARG(3), ARG(4), ARG(5), ARG(6)); break; case 7: ((void (__cdecl *)(void*, void*, void*, void*, void*, void*, void*))id->fun)(ARG(1), ARG(2), ARG(3), ARG(4), ARG(5), ARG(6), ARG(7)); break; case 8: ((void (__cdecl *)(void*, void*, void*, void*, void*, void*, void*, void*))id->fun)(ARG(1), ARG(2), ARG(3), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8)); break; default: fatal("command %s has too many arguments (signature: %s)", id->name, id->sig); break; } #undef ARG } setretval(commandret); commandret = NULL; break; } case ID_VAR: // game defined variables if(!w[1][0]) conoutf("%s = %d", c, *id->storage.i); // var with no value just prints its current value else if(id->minval>id->maxval) conoutf("variable %s is read-only", id->name); else { int i1 = ATOI(w[1]); if(i1minval || i1>id->maxval) { i1 = i1minval ? id->minval : id->maxval; // clamp to valid range conoutf("valid range for %s is %d..%d", id->name, id->minval, id->maxval); flagmapconfigerror(LWW_SCRIPTERR); } *id->storage.i = i1; if(id->fun) ((void (__cdecl *)())id->fun)(); // call trigger function if available } break; case ID_FVAR: // game defined variables if(!w[1][0]) conoutf("%s = %s", c, floatstr(*id->storage.f)); // var with no value just prints its current value else if(id->minvalf>id->maxvalf) conoutf("variable %s is read-only", id->name); else { float f1 = atof(w[1]); if(f1minvalf || f1>id->maxvalf) { f1 = f1minvalf ? id->minvalf : id->maxvalf; // clamp to valid range conoutf("valid range for %s is %s..%s", id->name, floatstr(id->minvalf), floatstr(id->maxvalf)); flagmapconfigerror(LWW_SCRIPTERR * 2); } *id->storage.f = f1; if(id->fun) ((void (__cdecl *)())id->fun)(); // call trigger function if available } break; case ID_SVAR: // game defined variables if(!w[1][0]) { if(id->getfun) ((void (__cdecl *)())id->getfun)(); conoutf(strchr(*id->storage.s, '"') ? "%s = [%s]" : "%s = \"%s\"", c, *id->storage.s); // var with no value just prints its current value } else { *id->storage.s = exchangestr(*id->storage.s, newstring(w[1])); if(id->fun) ((void (__cdecl *)())id->fun)(); // call trigger function if available } break; case ID_ALIAS: // alias, also used as functions and (global) variables delete[] w[0]; static vector argids; for(int i = 1; i argids.length()) { defformatstring(argname)("arg%d", i); argids.add(newident(argname, IEXC_CORE)); } pushident(*argids[i-1], w[i]); // set any arguments as (global) arg values so functions can access them } int old_numargs = _numargs; _numargs = numargs-1; char *wasexecuting = id->executing; id->executing = id->action; setretval(executeret(id->action)); if(id->executing!=id->action && id->executing!=wasexecuting) delete[] id->executing; id->executing = wasexecuting; _numargs = old_numargs; for(int i = 1; i matchingnames; vector matchingigs; loopv(players) if(players[i] && !strncasecmp(players[i]->name, cp, nickcompletesize)) matchingnames.add(i); // find all matching player names first if(nickcompletesize > 0 && *cp == ':') enumigraphs(matchingigs, cp + 1, nickcompletesize - 1); // find all matching igraphs int totalmatches = matchingnames.length() + matchingigs.length(); if(totalmatches) { nickcompleteidx += reversedirection ? totalmatches - 1 : 1; nickcompleteidx %= totalmatches; bool isig = nickcompleteidx >= matchingnames.length(); const char *fillin = isig ? matchingigs[nickcompleteidx - matchingnames.length()] : players[matchingnames[nickcompleteidx]]->name; if(*fillin == '/' && cp == s) *cp++ = ' '; if(isig) cp++; *cp = '\0'; concatstring(s, fillin); return true; } return false; } enum { COMPLETE_FILE = 0, COMPLETE_LIST, COMPLETE_NICK }; struct completekey { int type; const char *dir, *ext; completekey() {} completekey(int type, const char *dir, const char *ext) : type(type), dir(dir), ext(ext) {} }; struct completeval { int type; char *dir, *ext; vector dirlist; vector list; completeval(int type, const char *dir, const char *ext) : type(type), dir(dir && dir[0] ? newstring(dir) : NULL), ext(ext && ext[0] ? newstring(ext) : NULL) {} ~completeval() { DELETEA(dir); DELETEA(ext); dirlist.deletearrays(); list.deletearrays(); } }; static inline bool htcmp(const completekey &x, const completekey &y) { return x.type==y.type && (x.dir == y.dir || (x.dir && y.dir && !strcmp(x.dir, y.dir))) && (x.ext == y.ext || (x.ext && y.ext && !strcmp(x.ext, y.ext))); } static inline uint hthash(const completekey &k) { return k.dir ? hthash(k.dir) + k.type : k.type; } static hashtable completedata; static hashtable completions; void addcomplete(char *command, int type, char *dir, char *ext) { if(type==COMPLETE_FILE) { int dirlen = (int)strlen(dir); while(dirlen > 0 && (dir[dirlen-1] == '/' || dir[dirlen-1] == '\\')) dir[--dirlen] = '\0'; if(ext) { if(strchr(ext, '*')) ext[0] = '\0'; if(!ext[0]) ext = NULL; } } completekey key(type, dir, ext); completeval **val = completedata.access(key); if(!val) { completeval *f = new completeval(type, dir, ext); if(type==COMPLETE_LIST) explodelist(dir, f->list); if(type==COMPLETE_FILE) { explodelist(dir, f->dirlist); loopv(f->dirlist) { char *dir = f->dirlist[i]; int dirlen = (int)strlen(dir); while(dirlen > 0 && (dir[dirlen-1] == '/' || dir[dirlen-1] == '\\')) dir[--dirlen] = '\0'; } } val = &completedata[completekey(type, f->dir, f->ext)]; *val = f; } completeval **hascomplete = completions.access(command); if(hascomplete) *hascomplete = *val; else completions[newstring(command)] = *val; } void addfilecomplete(char *command, char *dir, char *ext) { addcomplete(command, COMPLETE_FILE, dir, ext); } void addlistcomplete(char *command, char *list) { addcomplete(command, COMPLETE_LIST, list, NULL); } void addnickcomplete(char *command) { addcomplete(command, COMPLETE_NICK, NULL, NULL); } COMMANDN(complete, addfilecomplete, "sss"); COMMANDN(listcomplete, addlistcomplete, "ss"); COMMANDN(nickcomplete, addnickcomplete, "s"); void commandcomplete(char *s, bool reversedirection) { // s is required to be of size "string"! static int completeidx; if(*s != '/') { string t; copystring(t, s); copystring(s, "/"); concatstring(s, t); } if(!s[1]) return; // find start position of last command char *cmd = strrchr(s, ';'); // find last ';' (this will not always work properly, because it doesn't take quoted texts into account) if(!cmd) cmd = s; // no ';' found: command starts after '/' char *openblock = strrchr(cmd + 1, '('), *closeblock = strrchr(cmd + 1, ')'); // find last open and closed parenthesis if(openblock && (!closeblock || closeblock < openblock)) cmd = openblock; // found opening parenthesis inside the command: assume, a new command starts here cmd += strspn(cmd + 1, " ") + 1; // skip blanks and one of "/;( ", cmd now points to the first char of the command // check, if the command is complete, and we want argument completion instead char *arg = strrchr(cmd, ' '); // find last space in command -> if there is one, we use argument completion completeval *cdata = NULL; if(arg) // full command is present { // extract command name to find argument list string command; copystring(command, cmd); command[strcspn(cmd, " ")] = '\0'; completeval **hascomplete = completions.access(command); if(hascomplete) cdata = *hascomplete; if(completesize < 0 && cdata && cdata->type == COMPLETE_FILE) { // get directory contents on first run cdata->list.deletearrays(); vector files; loopv(cdata->dirlist) { listfiles(cdata->dirlist[i], cdata->ext, files, stringsort); loopv(files) cdata->list.add(files[i]); files.setsize(0); } } } char *cp = arg ? arg + 1 : cmd; // part of string to complete bool firstrun = false; if(completesize < 0) { // first run since resetcomplete() completesize = (int)strlen(cp); completeidx = reversedirection ? 0 : -1; firstrun = true; } if(!arg) { // commandname completion vector matchingidents; enumerate(*idents, ident, id, if(!strncasecmp(id.name, cp, completesize) && (id.type != ID_ALIAS || *id.action)) matchingidents.add(id.name); // find all matching possibilities to get the list length (and give an opportunity to sort the list first) ); if(matchingidents.length()) { completeidx += reversedirection ? matchingidents.length() - 1 : 1; completeidx %= matchingidents.length(); matchingidents.sort(stringsortignorecase); if(firstrun && !reversedirection && !strcmp(matchingidents[completeidx], cp)) completeidx = min(completeidx + 1, matchingidents.length() - 1); *cp = '\0'; concatstring(s, matchingidents[completeidx]); } } else if(!cdata) return; else if(cdata->type == COMPLETE_NICK) nickcomplete(s, reversedirection); else { // argument completion vector matchingargs; loopv(cdata->list) if(!strncasecmp(cdata->list[i], cp, completesize)) matchingargs.add(i); // find all matching args first if(matchingargs.length()) { completeidx += reversedirection ? matchingargs.length() - 1 : 1; completeidx %= matchingargs.length(); *cp = '\0'; concatstring(s, cdata->list[matchingargs[completeidx]]); } } } void complete(char *s, bool reversedirection) { if(*s == '/' || !nickcomplete(s, reversedirection)) { commandcomplete(s, reversedirection); } } #endif void cleancubescript(char *buf) // drop easy to spot surplus whitespace and comments { if(!buf || !*buf) return; char *src = buf, c; bool quot = false; for(char l = 0; (c = *src++); l = c) { if(c == '\r') c = '\n'; if(quot) { if((c == '"' && l != '\\') || c == '\n') quot = false; } else { if(c == l && isspace(c)) continue; if(c == ' ' && l == '\n') continue; if(c == '/' && *src == '/') { src += strcspn(src, "\n\r\0"); continue; } if(c == '"') quot = true; } *buf++ = c; } *buf = '\0'; } bool execfile(const char *cfgfile) { string s; copystring(s, cfgfile); setcontext("file", cfgfile); bool oldpersist = persistidents; char *buf = loadfile(path(s), NULL); if(!buf) { resetcontext(); return false; } if(!currentcontextisolated && !strstr(s, "docs.cfg")) cleancubescript(buf); execute(buf); delete[] buf; resetcontext(); persistidents = oldpersist; return true; } void exec(const char *cfgfile) { if(!execfile(cfgfile)) conoutf("could not read \"%s\"", cfgfile); } COMMANDF(exec, "v", (char **args, int numargs) { defformatstring(buf)("%d", numargs - 1); push("execnumargs", buf); for(int i = 1; i <= MAXWORDS - 2; i++) { formatstring(buf)("execarg%d", i); push(buf, i < numargs ? args[i] : ""); } push("execresult", ""); exec(numargs > 0 ? args[0] : ""); const char *res = getalias("execresult"); if(res) result(res); pop("execresult"); for(int i = MAXWORDS - 2; i >= 1; i--) { formatstring(buf)("execarg%d", i); pop(buf); } pop("execnumargs"); }); COMMANDF(execute, "s", (char *s) { intret(execute(s)); }); void execdir(const char *dir) { if(dir[0]) { vector files; listfiles(dir, "cfg", files, stringsort); loopv(files) { defformatstring(d)("%s/%s.cfg",dir,files[i]); exec(d); delstring(files[i]); } } } COMMAND(execdir, "s"); // below the commands that implement a small imperative language. thanks to the semantics of // () and [] expressions, any control construct can be defined trivially. void ifthen(char *cond, char *thenp, char *elsep) { commandret = executeret(cond[0]!='0' ? thenp : elsep); } bool __dummy_ifthen = addcommand("if", (void (*)())ifthen, "sss"); //COMMANDN(if, ifthen, "sss"); // CB seriously trips over this one ;) void loopa(char *var, int *times, char *body) { if(*times > CSLIMIT_ITERATION) { cslimiterr("loop iterations"); return; } int t = *times; if(t<=0) return; ident *id = newident(var, execcontext); if(id->type!=ID_ALIAS) return; char *buf = newstring("0", 16); pushident(*id, buf); loop_level++; execute(body); loop_skip = false; if(loop_break) loop_break = false; else { loopi(t-1) { if(buf != id->action) { if(id->action != id->executing) delete[] id->action; id->action = buf = newstring(16); } itoa(id->action, i+1); execute(body); loop_skip = false; if(loop_break) { loop_break = false; break; } } } popident(*id); loop_level--; } COMMANDN(loop, loopa, "sis"); void whilea(char *cond, char *body) { loop_level++; int its = 0; while(execute(cond)) { execute(body); loop_skip = false; if(loop_break) { loop_break = false; break; } if(++its > CSLIMIT_ITERATION) { cslimiterr("loop iterations"); return; } } loop_level--; } COMMANDN(while, whilea, "ss"); COMMANDF(break, "", () { if(loop_level) loop_skip = loop_break = true; }); COMMANDF(continue, "", () { if(loop_level) loop_skip = true; }); COMMANDF(concat, "c", (const char *s) { result(s); }); COMMANDF(concatword, "w", (const char *s) { result(s); }); void format(char **args, int numargs) { vector s; const char *f = numargs > 0 ? args[0] : ""; while(*f) { int c = *f++; if(c == '%') { int i = *f++; bool twodigit = i == '0' && isdigit(f[0]) && isdigit(f[1]); if((i >= '1' && i <= '9') || twodigit) { if(twodigit) i = (f[0] - '0') * 10 + f[1] - '0', f += 2; else i -= '0'; const char *sub = i < numargs ? args[i] : ""; while(*sub) s.add(*sub++); } else s.add(i); } else s.add(c); } resultcharvector(s, 0); } COMMAND(format, "v"); void format2(char **args, int numargs) { if(numargs > 0) { vector pars; pars.add(newstring(args[0])); for(int i = 1; i < numargs ; i++) explodelist(args[i], pars); format(pars.getbuf(), pars.length()); loopv(pars) delstring(pars[i]); } } COMMAND(format2, "v"); #define whitespaceskip do { s += strspn(s, "\n\r\t "); } while(s[0] == '/' && s[1] == '/' && (s += strcspn(s, "\n\r\0"))) #define elementskip { if(*s=='"') { do { ++s; s += strcspn(s, "\"\n\r"); } while(*s == '\"' && s[-1] == '\\'); s += *s=='"'; } else s += strcspn(s, "\n\r\t "); } void explodelist(const char *s, vector &elems) { whitespaceskip; while(*s) { const char *elem = s; elementskip; #ifdef STANDALONE char *newelem = *elem == '"' ? newstring(elem + 1, s - elem - (s[-1]=='"' ? 2 : 1)) : newstring(elem, s-elem); #else size_t len = 0; char *newelem = *elem == '"' ? newstring(elem + 1, (len = s - elem - (s[-1]=='"' ? 2 : 1))) : newstring(elem, s-elem); if(*elem == '"') filterrichtext(newelem, newelem, len); #endif elems.add(newelem); whitespaceskip; } } void looplist(char *list, char *varlist, char *body, bool withi) { vector vars; explodelist(varlist, vars); if(vars.length() < 1) return; int columns = vars.length(); if(withi) vars.add(newstring("i")); vector ids; bool ok = true; loopv(vars) if(ids.add(newident(vars[i]))->type != ID_ALIAS) { conoutf("looplist error: \"%s\" is readonly", vars[i]); ok = false; } if(ok) { int ii = 0; vector elems; explodelist(list, elems); loopv(ids) pushident(*ids[i], newstring("")); loop_level++; if(elems.length() / columns > CSLIMIT_ITERATION) cslimiterr("loop iterations"); else for(int i = 0; i <= elems.length() - columns; i += columns) { loopj(vars.length()) { if(ids[j]->action != ids[j]->executing) delete[] ids[j]->action; if(j < columns) { ids[j]->action = elems[i + j]; elems[i + j] = NULL; } else { defformatstring(sii)("%d", ii++); ids[j]->action = newstring(sii); } } execute(body); loop_skip = false; if(loop_break) break; } loopv(ids) popident(*ids[i]); loopv(elems) if(elems[i]) delete[] elems[i]; loop_break = false; loop_level--; } loopv(vars) delete[] vars[i]; } COMMANDF(looplist, "sss", (char *list, char *varlist, char *body) { looplist(list, varlist, body, false); }); COMMANDF(looplisti, "sss", (char *list, char *varlist, char *body) { looplist(list, varlist, body, true); }); char *indexlist(const char *s, int pos) { DEBUGCODE(if(pos < 0) conoutf("\f3warning: negative index for 'at' \"%s\" %d", s, pos);) // FIXME remove this warning before release if(pos < 0) return newstring(""); whitespaceskip; loopi(pos) { elementskip; whitespaceskip; if(!*s) break; } const char *e = s; char *res; elementskip; if(*e=='"') { e++; if(s[-1]=='"') --s; res = newstring(e, s - e); #ifndef STANDALONE filterrichtext(res, res, s - e); #endif } else res = newstring(e, s-e); return res; } COMMANDF(at, "si", (char *s, int *pos) { commandret = indexlist(s, *pos); }); int listlen(const char *s) { int n = 0; whitespaceskip; for(; *s; n++) { elementskip; whitespaceskip; } return n; } COMMANDF(listlen, "s", (char *l) { intret(listlen(l)); }); int find(char *s, const char *key) { whitespaceskip; int len = strlen(key); for(int i = 0; *s; i++) { char *e = s; elementskip; char *a = s; if(*e == '"') { e++; if(s[-1] == '"') --s; if(s - e >= len) { *s = '\0'; #ifndef STANDALONE filterrichtext(e, e, s - e); #endif if(int(strlen(e)) == len && !strncmp(e, key, len)) return i; *s = ' '; } } else if(s - e == len && !strncmp(e, key, s - e)) return i; s = a; whitespaceskip; } return -1; } COMMANDF(findlist, "ss", (char *s, char *key) { intret(find(s, key)); }); #ifndef STANDALONE COMMANDF(l0, "ii", (int *p, int *v) { defformatstring(f)("%%0%dd", clamp(*p, 0, 200)); defformatstring(r)(f, *v); result(r); }); COMMANDF(h0, "ii", (int *p, int *v) { defformatstring(f)("%%0%dx", clamp(*p, 0, 200)); defformatstring(r)(f, *v); result(r); }); COMMANDF(strlen, "s", (char *s) { intret(strlen(s)); }); COMMANDF(strstr, "ss", (char *h, char *n) { char *r = strstr(h, n); intret(r ? r - h + 1 : 0); }); void substr_(char *text, int *_start, int *_len) { int start = *_start, len = *_len, textlen = (int)strlen(text); if(start < 0) start += textlen; // negative positions count from the end if(len < 0) len += textlen; // negative len subtracts from total if(start > textlen || start < 0 || len < 0) return; if(!len) len = textlen - start; // zero len gets all if(len >= 0 && len < int(strlen(text + start))) (text + start)[len] = '\0'; // cut text at len, if too long result(text + start); } COMMANDN(substr, substr_, "sii"); void strreplace(char *text, char *search, char *replace) { vector buf; char *o = text; while(*search && (o = strstr(text, search))) { buf.put(text, o - text); buf.put(replace, strlen(replace)); text = o + strlen(search); } buf.put(text, strlen(text)); resultcharvector(buf, 0); } COMMAND(strreplace, "sss"); const char *punctnames[] = { "QUOTES", "BRACKETS", "PARENTHESIS", "_$_", "QUOTE", "PERCENT", "" }; void addpunct(char *s, char *type) // Easily inject a string into various CubeScript punctuations { int t = getlistindex(type, punctnames, true, 0); const char *puncts[] = { "\"%s\"", "[%s]", "(%s)", "$%s", "\"", "%" }, *punct = puncts[t]; if(strchr(punct, 's')) { defformatstring(res)(punct, s); result(res); } else result(punct); } COMMAND(addpunct, "ss"); #endif void toany(char *s, int (*c)(int)) { while(*s) { *s = (*c)(*s); s++; } } COMMANDF(tolower, "s", (char *s) { toany(s, tolower); result(s); }); COMMANDF(toupper, "s", (char *s) { toany(s, toupper); result(s); }); void testchar(char *s, int *type) { int (*funcs[8])(int) = { isdigit, isalpha, isalnum, islower, isupper, isprint, ispunct, isspace }; if(*type < 1 || *type > 7) *type = 0; // default to isdigit intret((funcs[*type])(*s) ? 1 : 0); } COMMAND(testchar, "si"); void sortlist(char *list) { vector elems; explodelist(list, elems); elems.sort(stringsort); commandret = conc((const char **)elems.getbuf(), elems.length(), true); elems.deletearrays(); } COMMAND(sortlist, "c"); void modifyvar(const char *name, int arg, char op) { ident *id = idents->access(name); if(!id) return; if(identaccessdenied(id)) { conoutf("not allowed in this execution context: %s", id->name); scripterr(); return; } if((id->type == ID_VAR && id->minval > id->maxval) || (id->type == ID_FVAR && id->minvalf > id->maxvalf)) { conoutf("variable %s is read-only", id->name); return; } int val = 0; switch(id->type) { case ID_VAR: val = *id->storage.i; break; case ID_FVAR: val = int(*id->storage.f); break; case ID_SVAR: { { if(id->getfun) ((void (__cdecl *)())id->getfun)(); } val = ATOI(*id->storage.s); break; } case ID_ALIAS: val = ATOI(id->action); break; default: return; } switch(op) { case '+': val += arg; break; case '-': val -= arg; break; case '*': val *= arg; break; case '/': val = arg ? val / arg : 0; break; } switch(id->type) { case ID_VAR: *id->storage.i = clamp(val, id->minval, id->maxval); break; case ID_FVAR: *id->storage.f = clamp((float)val, id->minvalf, id->maxvalf); break; case ID_SVAR: { string str; itoa(str, val); *id->storage.s = exchangestr(*id->storage.s, str); break; } case ID_ALIAS: { string str; itoa(str, val); alias(name, str); return; } } if(id->fun) ((void (__cdecl *)())id->fun)(); } void addeq(char *name, int *arg) { modifyvar(name, *arg, '+'); } COMMANDN(+=, addeq, "si"); void subeq(char *name, int *arg) { modifyvar(name, *arg, '-'); } COMMANDN(-=, subeq, "si"); void muleq(char *name, int *arg) { modifyvar(name, *arg, '*'); } COMMANDN(*=, muleq, "si"); void diveq(char *name, int *arg) { modifyvar(name, *arg, '/'); } COMMANDN(div=, diveq, "si"); void modifyfvar(const char *name, float arg, char op) { ident *id = idents->access(name); if(!id) return; if(identaccessdenied(id)) { conoutf("not allowed in this execution context: %s", id->name); scripterr(); return; } if((id->type == ID_VAR && id->minval > id->maxval) || (id->type == ID_FVAR && id->minvalf > id->maxvalf)) { conoutf("variable %s is read-only", id->name); return; } float val = 0; switch(id->type) { case ID_VAR: val = *id->storage.i; break; case ID_FVAR: val = *id->storage.f; break; case ID_SVAR: { { if(id->getfun) ((void (__cdecl *)())id->getfun)(); } val = atof(*id->storage.s); break; } case ID_ALIAS: val = atof(id->action); break; default: return; } switch(op) { case '+': val += arg; break; case '-': val -= arg; break; case '*': val *= arg; break; case '/': val = (arg == 0.0f) ? 0 : val / arg; break; } switch(id->type) { case ID_VAR: *id->storage.i = clamp((int)val, id->minval, id->maxval); break; case ID_FVAR: *id->storage.f = clamp(val, id->minvalf, id->maxvalf); break; case ID_SVAR: *id->storage.s = exchangestr(*id->storage.s, floatstr(val)); break; case ID_ALIAS: alias(name, floatstr(val)); return; } if(id->fun) ((void (__cdecl *)())id->fun)(); } void addeqf(char *name, float *arg) { modifyfvar(name, *arg, '+'); } COMMANDN(+=f, addeqf, "sf"); void subeqf(char *name, float *arg) { modifyfvar(name, *arg, '-'); } COMMANDN(-=f, subeqf, "sf"); void muleqf(char *name, float *arg) { modifyfvar(name, *arg, '*'); } COMMANDN(*=f, muleqf, "sf"); void diveqf(char *name, float *arg) { modifyfvar(name, *arg, '/'); } COMMANDN(div=f, diveqf, "sf"); void add_(char **args, int numargs) { int sum = 0; loopi(numargs) sum += ATOI(args[i]); intret(sum); } COMMANDN(+, add_, "v"); void mul_(char **args, int numargs) { int prod = 1; if(numargs < 2) numargs = 2; // emulate classic (* ) = 0, (* 2) = 0, (* 2 3) = 6 loopi(numargs) prod *= ATOI(args[i]); intret(prod); } COMMANDN(*, mul_, "v"); void addf_(char **args, int numargs) { float sum = 0; loopi(numargs) sum += atof(args[i]); floatret(sum); } COMMANDN(+f, addf_, "v"); void mulf_(char **args, int numargs) { float prod = 1; if(numargs < 2) numargs = 2; // emulate classic (* ) = 0, (* 2) = 0, (* 2 3) = 6 loopi(numargs) prod *= atof(args[i]); floatret(prod); } COMMANDN(*f, mulf_, "v"); void sub_(int *a, int *b) { intret(*a - *b); } COMMANDN(-, sub_, "ii"); void div_(int *a, int *b) { intret(*b ? (*a)/(*b) : 0); } COMMANDN(div, div_, "ii"); void mod_(int *a, int *b) { intret(*b ? (*a)%(*b) : 0); } COMMANDN(mod, mod_, "ii"); void subf_(float *a, float *b) { floatret(*a - *b); } COMMANDN(-f, subf_, "ff"); void divf_(float *a, float *b) { floatret(*b ? (*a)/(*b) : 0); } COMMANDN(divf, divf_, "ff"); void modf_(float *a, float *b) { floatret(*b ? fmod(*a, *b) : 0); } COMMANDN(modf, modf_, "ff"); void powf_(float *a, float *b) { floatret(powf(*a, *b)); } COMMANDN(powf, powf_, "ff"); void not_(int *a) { intret((int)(!(*a))); } COMMANDN(!, not_, "i"); void equal_(int *a, int *b) { intret((int)(*a == *b)); } COMMANDN(=, equal_, "ii"); void notequal_(int *a, int *b) { intret((int)(*a != *b)); } COMMANDN(!=, notequal_, "ii"); void lt_(int *a, int *b) { intret((int)(*a < *b)); } COMMANDN(<, lt_, "ii"); void gt_(int *a, int *b) { intret((int)(*a > *b)); } COMMANDN(>, gt_, "ii"); void lte_(int *a, int *b) { intret((int)(*a <= *b)); } COMMANDN(<=, lte_, "ii"); void gte_(int *a, int *b) { intret((int)(*a >= *b)); } COMMANDN(>=, gte_, "ii"); void round_(float *a) { intret(int(*a + 0.5f)); } COMMANDN(round, round_, "f"); void ceil_(float *a) { intret((int)ceil(*a)); } COMMANDN(ceil, ceil_, "f"); void floor_(float *a) { intret((int)floor(*a)); } COMMANDN(floor, floor_, "f"); #define COMPAREF(opname, func, op) \ void func(float *a, float *b) { intret((int)((*a) op (*b))); } \ COMMANDN(opname, func, "ff") COMPAREF(=f, equalf_, ==); COMPAREF(!=f, notequalf_, !=); COMPAREF(f, gtf_, >); COMPAREF(<=f, ltef_, <=); COMPAREF(>=f, gtef_, >=); void anda_(char *a, char *b) { intret(execute(a)!=0 && execute(b)!=0); } COMMANDN(&&, anda_, "ss"); void ora_(char *a, char *b) { intret(execute(a)!=0 || execute(b)!=0); } COMMANDN(||, ora_, "ss"); void band_(int *a, int *b) { intret((*a) & (*b)); } COMMANDN(&b, band_, "ii"); void bor_(int *a, int *b) { intret((*a) | (*b)); } COMMANDN(|b, bor_, "ii"); void bxor_(int *a, int *b) { intret((*a) ^ (*b)); } COMMANDN(^b, bxor_, "ii"); void bnot_(int *a) { intret(~(*a)); } COMMANDN(!b, bnot_, "i"); COMMANDF(strcmp, "ss", (char *a, char *b) { intret((strcmp(a, b) == 0) ? 1 : 0); }); COMMANDF(rnd, "i", (int *a) { intret(*a>0 ? rnd(*a) : 0); }); #ifndef STANDALONE const char *escapestring(const char *s, bool force, bool noquotes) { static vector strbuf[3]; static int stridx = 0; if(noquotes) force = false; if(!s) return force ? "\"\"" : ""; if(!force && !*(s + strcspn(s, "\"/\\;()[] \f\t\n\r$"))) return s; stridx = (stridx + 1) % 3; vector &buf = strbuf[stridx]; buf.setsize(0); if(!noquotes) buf.add('"'); for(; *s; s++) switch(*s) { case '\n': buf.put("\\n", 2); break; case '\r': buf.put("\\n", 2); break; case '\t': buf.put("\\t", 2); break; case '\a': buf.put("\\a", 2); break; case '\f': buf.put("\\f", 2); break; case '"': buf.put("\\\"", 2); break; case '\\': buf.put("\\\\", 2); break; default: buf.add(*s); break; } if(!noquotes) buf.add('"'); buf.add(0); return buf.getbuf(); } COMMANDF(escape, "s", (const char *s) { result(escapestring(s));}); int sortident(ident **a, ident **b) { return strcasecmp((*a)->name, (*b)->name); } void enumalias(char *prefix) { vector res; vector sids; size_t np = strlen(prefix); enumerate(*idents, ident, id, if(id.type == ID_ALIAS && id.persist && !id.isconst && !id.istemp && !strncmp(id.name, prefix, np)) sids.add(&id); ); sids.sort(sortident); loopv(sids) cvecprintf(res, "%s %s\n", escapestring(sids[i]->name, false), escapestring(sids[i]->name + np, false)); resultcharvector(res, -1); } COMMAND(enumalias, "s"); VARP(omitunchangeddefaults, 0, 0, 1); VAR(groupvariables, 0, 4, 10); void writecfg() { filerotate("config/saved", "cfg", CONFIGROTATEMAX); // keep five old config sets stream *f = openfile(path("config/saved.cfg", true), "w"); if(!f) return; f->printf("// automatically written on exit, DO NOT MODIFY\n// delete this file to have defaults.cfg overwrite these settings\n// modify settings in game, or put settings in autoexec.cfg to override anything\n\n"); f->printf("// basic settings\n\n"); f->printf("name %s\n", escapestring(player1->name, false)); f->printf("skin_cla %d\nskin_rvsf %d\n", player1->skin(TEAM_CLA), player1->skin(TEAM_RVSF)); for(int i = CROSSHAIR_DEFAULT; i < CROSSHAIR_NUM; i++) if(crosshairs[i] && crosshairs[i] != notexture) { f->printf("loadcrosshair %s %s\n", crosshairnames[i], behindpath(crosshairs[i]->name)); } extern int lowfps, highfps; f->printf("fpsrange %d %d\n", lowfps, highfps); if(curfont && curfont->name) f->printf("setfont %s\n", curfont->name); f->printf("\n"); audiomgr.writesoundconfig(f); f->printf("\n"); f->printf("// crosshairs for each weapon\n\nlooplist [\n"); loopi(NUMGUNS) f->printf(" %-7s %s\n", gunnames[i], crosshairs[i] && crosshairs[i] != notexture ? behindpath(crosshairs[i]->name) : "\"\""); f->printf("] [ w cc ] [ loadcrosshair $w $cc ]\n"); f->printf("\n\n// client variables (unchanged default values %s)\n", omitunchangeddefaults ? "omitted" : "commented out"); vector sids; enumerate(*idents, ident, id, if(id.persist) switch(id.type) { case ID_VAR: case ID_FVAR: case ID_SVAR: sids.add(&id); break; } ); sids.sort(sortident); const char *rep = ""; int repn = 0; bool lastdef = false, curdef; loopv(sids) { ident &id = *sids[i]; curdef = (id.type == ID_VAR && *id.storage.i == id.defaultval) || (id.type == ID_FVAR && *id.storage.f == id.defaultvalf); if(curdef && omitunchangeddefaults) continue; f->printf("%s", !strncmp(rep, id.name, curdef ? 1 : 3) && ++repn < groupvariables && lastdef == curdef ? " ; " : (repn = 0, "\n")); rep = id.name; lastdef = curdef; if(curdef && repn == 0) f->printf("// "); switch(id.type) { case ID_VAR: f->printf("%s %d", id.name, *id.storage.i); break; case ID_FVAR: f->printf("%s %s", id.name, floatstr(*id.storage.f)); break; case ID_SVAR: f->printf("%s %s", id.name, escapestring(*id.storage.s, false)); break; } if(!groupvariables) { if(id.type == ID_VAR) f->printf(" // min: %d, max: %d, def: %d", id.minval, id.maxval, id.defaultval); if(id.type == ID_FVAR) f->printf(" // min: %s, max: %s, def: %s", floatstr(id.minvalf), floatstr(id.maxvalf), floatstr(id.defaultvalf)); const char *doc = docgetdesc(id.name); if(doc) f->printf(id.type == ID_SVAR ? " // %s" : ", %s", doc); } } f->printf("\n\n// weapon settings\n\n"); loopi(NUMGUNS) if(guns[i].isauto) { f->printf("burstshots %s %d\n", gunnames[i], burstshotssettings[i]); } f->printf("\n// key binds\n\n"); writebinds(f); f->printf("\n// aliases\n\n"); sids.setsize(0); enumerate(*idents, ident, id, if(id.type == ID_ALIAS && id.persist) sids.add(&id); ); sids.sort(sortident); loopv(sids) { ident &id = *sids[i]; if(strncmp(id.name, "demodesc_", 9)) { const char *action = id.action; for(identstack *s = id.stack; s; s = s->next) action = s->action; if(action[0]) f->printf("alias %s %s\n", escapestring(id.name, false), escapestring(action, false)); sids.remove(i--); } } if(sids.length()) { f->printf("\n// demo descriptions\n\n"); loopv(sids) { ident &id = *sids[i]; const char *action = id.action; for(identstack *s = id.stack; s; s = s->next) action = s->action; if(action[0]) f->printf("alias %s %s\n", escapestring(id.name, false), escapestring(action, false)); } } f->printf("\n"); delete f; } COMMAND(writecfg, ""); void deletecfg() { string configs[] = { "config/saved.cfg", "config/init.cfg" }; loopj(2) // delete files in homedir and basedir if possible { loopi(sizeof(configs)/sizeof(configs[0])) { const char *file = findfile(path(configs[i], true), "r"); if(!file || findfilelocation == FFL_ZIP) continue; delfile(file); } } } #endif void identnames(vector &names, bool builtinonly) { enumeratekt(*idents, const char *, name, ident, id, { if(!builtinonly || id.type != ID_ALIAS) names.add(name); }); } // script execution context management const char *contextnames[IEXC_NUM + 1] = { "CORE", "CFG", "PROMPT", "MAPCFG", "MDLCFG", "" }; bool contextisolated[IEXC_NUM] = { false }; bool contextsealed = false; vector contextstack; int execcontext; void pushscontext(int newcontext) { ASSERT(newcontext >= 0 && newcontext < IEXC_NUM); contextstack.add(execcontext); execcontext = newcontext; currentcontextisolated = contextsealed && contextisolated[execcontext]; } int popscontext() { ASSERT(contextstack.length() > 0); int old = execcontext; execcontext = contextstack.pop(); currentcontextisolated = contextsealed && contextisolated[execcontext]; if(execcontext < old && old >= IEXC_MAPCFG) // clean up aliases created in the old (map cfg) context { int limitcontext = max(execcontext + 1, (int) IEXC_MAPCFG); // don't clean up below IEXC_MAPCFG enumeratekt(*idents, const char *, name, ident, id, { if(id.type == ID_ALIAS && id.context >= limitcontext) { while(id.stack && id.stack->context >= limitcontext) popident(id); if(id.context >= limitcontext) { if(id.action != id.executing) delete[] id.action; idents->remove(name); } } }); } return execcontext; } void scriptcontext(char *context, char *idname) { if(contextsealed) return; ident *id = idents->access(idname); if(!id) return; int c = getlistindex(context, contextnames, true, -1); if(c >= 0 && c < IEXC_NUM) id->context = c; } COMMAND(scriptcontext, "ss"); void isolatecontext(char *context) { int c = getlistindex(context, contextnames, true, -1); if(c >= 0 && c < IEXC_NUM && !contextsealed) contextisolated[c] = true; } COMMAND(isolatecontext, "s"); COMMANDF(sealcontexts, "",() { contextsealed = true; }); inline bool identaccessdenied(ident *id) // check if ident is allowed in current context { ASSERT(execcontext >= 0 && execcontext < IEXC_NUM && id); return contextisolated[execcontext] && execcontext > id->context; } // script origin tracking const char *curcontext = NULL, *curinfo = NULL; void scripterr() { ASSERT(execcontext >= 0 && execcontext < IEXC_NUM); if(curcontext) conoutf("(%s: %s [%s])", curcontext, curinfo, contextnames[execcontext]); else conoutf("(from console or builtin [%s])", contextnames[execcontext]); clientlogf("exec nesting level: %d", executionstack.length()); clientlogf("%s", executionstack.length() ? executionstack.last() : ":::nevermind:::"); } void setcontext(const char *context, const char *info) { curcontext = context; curinfo = info; } void resetcontext() { curcontext = curinfo = NULL; } void dumpexecutionstack(stream *f) { if(f && executionstack.length()) { f->printf("cubescript execution stack (%d levels)\n", executionstack.length()); if(curcontext) f->printf(" cubescript context: %s %s\n", curcontext, curinfo ? curinfo : ""); loopvrev(executionstack) f->printf("%4d: %s\n", i + 1, executionstack[i]); f->fflush(); } } void cslimiterr(const char*msg) { conoutf("\f3[ERROR] cubescript hard limit reached: max %s exceeded (check log for details)", msg); scripterr(); } #ifndef STANDALONE void listoptions(char *s) { extern const char *menufilesortorders[], *texturestacktypes[], *soundprioritynames[], *soundcategories[]; const char *optionnames[] = { "entities", "ents", "weapons", "teamnames", "teamnames-abbrv", "punctuations", "crosshairnames", "menufilesortorders", "texturestacktypes", "cubetypes", "soundpriorities", "soundcategories", "" }; const char **optionlists[] = { optionnames, entnames + 1, entnames + 1, gunnames, teamnames, teamnames_s, punctnames, crosshairnames, menufilesortorders, texturestacktypes, cubetypenames, soundprioritynames, soundcategories }; const char **listp = optionlists[getlistindex(s, optionnames, true, -1) + 1]; commandret = conc(listp, -1, true); } COMMAND(listoptions, "s"); #endif void debugargs(char **args, int numargs) { printf("debugargs: "); loopi(numargs) { if(i) printf(", "); printf("\"%s\"", args[i]); } printf("\n"); } COMMAND(debugargs, "v"); #ifndef STANDALONE #ifdef _DEBUG void debugline(char *fname, char *line) // print one line to a logfile { if(!multiplayer()) { stream *f = openfile(behindpath(fname), "a"); if(f) f->printf("%s\n", line); if(f) delete f; } } COMMAND(debugline, "ss"); #endif #endif assaultcube-1.2.0.2.1/source/src/command.h000066400000000000000000000132501352165075300202120ustar00rootroot00000000000000enum { ID_VAR, ID_FVAR, ID_SVAR, ID_COMMAND, ID_ALIAS }; struct identstack { char *action; int context; identstack *next; }; struct ident { int type; // one of ID_* above const char *name; union { int minval; // ID_VAR float minvalf; // ID_FVAR }; union { int maxval; // ID_VAR float maxvalf; // ID_FVAR }; union { int *i; // ID_VAR float *f; // ID_FVAR char **s; // ID_SVAR; } storage; union { void (*fun)(); // ID_VAR, ID_FVAR, ID_SVAR, ID_COMMAND identstack *stack; // ID_ALIAS }; const char *sig; // command signature char *action; // ID_ALIAS union { void (*getfun)(); // ID_SVAR (called /before/ reading the value string, as a chance for last-minute updates) char *executing; // ID_ALIAS int defaultval; // ID_VAR float defaultvalf; // ID_FVAR }; short context; // one of IEXC_* below bool persist; // if true, value gets written to saved.cfg on exit; set to true, if it's an ID_ALIAS and the value gets changed bool isconst; // ID_ALIAS: value may not be overwritten bool istemp; // ID_ALIAS: if value is changed, "persist" will not be set true ident() {} // ID_VAR ident(int type, const char *name, int minval, int maxval, int *i, int defval, void (*fun)(), bool persist, int context) : type(type), name(name), minval(minval), maxval(maxval), fun(fun), sig(NULL), action(NULL), defaultval(defval), context(context), persist(persist), isconst(false), istemp(false) { storage.i = i; } // ID_FVAR ident(int type, const char *name, float minval, float maxval, float *f, float defval, void (*fun)(), bool persist, int context) : type(type), name(name), minvalf(minval), maxvalf(maxval), fun(fun), sig(NULL), action(NULL), defaultvalf(defval), context(context), persist(persist), isconst(false), istemp(false) { storage.f = f; } // ID_SVAR ident(int type, const char *name, char **s, void (*fun)(), void (*getfun)(), bool persist, int context) : type(type), name(name), minval(0), maxval(0), fun(fun), sig(NULL), action(NULL), getfun(getfun), context(context), persist(persist), isconst(false), istemp(false) { storage.s = s; } // ID_ALIAS ident(int type, const char *name, char *action, bool persist, int context) : type(type), name(name), minval(0), maxval(0), stack(0), sig(NULL), action(action), executing(NULL), context(context), persist(persist), isconst(false), istemp(false) { storage.i = NULL; } // ID_COMMAND ident(int type, const char *name, void (*fun)(), const char *sig, int context) : type(type), name(name), minval(0), maxval(0), fun(fun), sig(sig), action(NULL), executing(NULL), context(context), persist(false), isconst(false), istemp(false) { storage.i = NULL; } }; enum { IEXC_CORE = 0, IEXC_CFG, IEXC_PROMPT, IEXC_MAPCFG, IEXC_MDLCFG, IEXC_NUM }; // script execution context // nasty macros for registering script functions, abuses globals to avoid excessive infrastructure #define COMMANDN(name, fun, sig) bool __dummy_##fun = addcommand(#name, (void (*)())fun, sig) #define COMMAND(name, sig) COMMANDN(name, name, sig) #define COMMANDF(name, sig, inlinefunc) static void __dummy_##name inlinefunc ; COMMANDN(name, __dummy_##name, sig) #define VARP(name, min, cur, max) int name = variable(#name, min, cur, max, &name, NULL, true) #define VAR(name, min, cur, max) int name = variable(#name, min, cur, max, &name, NULL, false) #define VARN(name, global, min, cur, max) int global = variable(#name, min, cur, max, &global, NULL, false) #define VARNP(name, global, min, cur, max) int global = variable(#name, min, cur, max, &global, NULL, true) #define VARF(name, min, cur, max, body) extern int name; void var_##name() { body; } int name = variable(#name, min, cur, max, &name, var_##name, false) #define VARFP(name, min, cur, max, body) extern int name; void var_##name() { body; } int name = variable(#name, min, cur, max, &name, var_##name, true) #define VARNFP(name, global, min, cur, max, body) extern int global; void var_##name() { body; } int global = variable(#name, min, cur, max, &global, var_##name, true) #define FVARP(name, min, cur, max) float name = fvariable(#name, min, cur, max, &name, NULL, true) #define FVAR(name, min, cur, max) float name = fvariable(#name, min, cur, max, &name, NULL, false) #define FVARF(name, min, cur, max, body) extern float name; void var_##name() { body; } float name = fvariable(#name, min, cur, max, &name, var_##name, false) #define FVARFP(name, min, cur, max, body) extern float name; void var_##name() { body; } float name = fvariable(#name, min, cur, max, &name, var_##name, true) // SVARs are represented by "char *name" which has to be a valid "newstring()" all the time #define SVARP(name, cur) char *name = svariable(#name, cur, &name, NULL, NULL, true) #define SVAR(name, cur) char *name = svariable(#name, cur, &name, NULL, NULL, false) #define SVARF(name, cur, body) extern char *name; void var_##name() { body; } char *name = svariable(#name, cur, &name, var_##name, NULL, false) #define SVARFP(name, cur, body) extern char *name; void var_##name() { body; } char *name = svariable(#name, cur, &name, var_##name, NULL, true) #define SVARFF(name, getb, checkb) extern char *name; void var_get##name() { getb; } void var_check##name() { checkb; } char *name = svariable(#name, "", &name, var_check##name, var_get##name, false) #define ATOI(s) strtol(s, NULL, 0) // supports hexadecimal numbers #define MAXWORDS 25 assaultcube-1.2.0.2.1/source/src/console.cpp000066400000000000000000000713551352165075300206030ustar00rootroot00000000000000// console.cpp: the console buffer, its display, and command line control #include "cube.h" #define CONSPAD (FONTH/3) VARP(altconsize, 0, 0, 100); VARP(fullconsize, 0, 40, 100); VARP(consize, 0, 6, 100); VARP(confade, 0, 20, 60); VARP(conalpha, 0, 255, 255); VAR(conopen, 1, 0, 0); VAR(numconlines, 0, 0, 1); struct console : consolebuffer { int conskip; void setconskip(int n) { int visible_lines = (int)(min(fullconsole ? ((VIRTH*2 - 2*CONSPAD - 2*FONTH/3)*(fullconsole==1 ? altconsize : fullconsize))/100 : FONTH*consize, (VIRTH*2 - 2*CONSPAD - 2*FONTH/3))/ (CONSPAD + 2*FONTH/3)) - 1; conskip = clamp(conskip + n, 0, clamp(conlines.length()-visible_lines, 0, conlines.length())); } static const int WORDWRAP = 80; int fullconsole; void toggleconsole() { if(!fullconsole) fullconsole = altconsize ? 1 : 2; else fullconsole = (fullconsole + 1) % 3; conopen = fullconsole; } void addline(const char *sf) { consolebuffer::addline(sf, totalmillis); numconlines++; } void render() { int conwidth = (fullconsole ? VIRTW : int(floor(getradarpos().x)))*2 - 2*CONSPAD - 2*FONTH/3; int h = VIRTH*2 - 2*CONSPAD - 2*FONTH/3; int conheight = min(fullconsole ? (h*(fullconsole==1 ? altconsize : fullconsize))/100 : FONTH*consize, h); if(fullconsole) blendbox(CONSPAD, CONSPAD, conwidth+CONSPAD+2*FONTH/3, conheight+CONSPAD+2*FONTH/3, true); int numl = conlines.length(), offset = min(conskip, numl); if(!fullconsole && confade) { if(!conskip) { numl = 0; loopvrev(conlines) if(totalmillis-conlines[i].millis < confade*1000) { numl = i+1; break; } } else offset--; } int y = 0; loopi(numl) //determine visible height { // shuffle backwards to fill if necessary int idx = offset+i < numl ? offset+i : --offset; char *line = conlines[idx].line; int width, height; text_bounds(line, width, height, conwidth); y += height; if(y > conheight) { numl = i; if(offset == idx) ++offset; break; } } y = CONSPAD+FONTH/3; loopi(numl) { int idx = offset + numl-i-1; char *line = conlines[idx].line; draw_text(line, CONSPAD+FONTH/3, y, 0xFF, 0xFF, 0xFF, fullconsole ? 0xFF : conalpha, -1, conwidth); int width, height; text_bounds(line, width, height, conwidth); y += height; } } console() : consolebuffer(200), fullconsole(false) {} }; console con; textinputbuffer cmdline; char *cmdaction = NULL, *cmdprompt = NULL; bool saycommandon = false, storeinputcommand = false; VARFP(maxcon, 10, 200, 1000, con.setmaxlines(maxcon)); void setconskip(int *n) { con.setconskip(*n); } COMMANDN(conskip, setconskip, "i"); void toggleconsole() { con.toggleconsole(); } COMMANDN(toggleconsole, toggleconsole, ""); void renderconsole() { con.render(); } stream *clientlogfile = NULL; vector *bootclientlog = new vector; int clientloglinesremaining = INT_MAX; void clientlogf(const char *s, ...) { defvformatstring(sp, s, s); filtertext(sp, sp, FTXT__LOG); extern struct servercommandline scl; const char *ts = scl.logtimestamp ? timestring(true, "%b %d %H:%M:%S ") : ""; char *p, *l = sp; do { // break into single lines first if((p = strchr(l, '\n'))) *p = '\0'; printf("%s%s\n", ts, l); if(clientlogfile) { clientlogfile->printf("%s%s\n", ts, l); if(--clientloglinesremaining <= 0) DELETEP(clientlogfile); } else if(bootclientlog) cvecprintf(*bootclientlog, "%s%s\n", ts, l); l = p + 1; } while(p); } SVAR(conline,"n/a"); void conoutf(const char *s, ...) { defvformatstring(sf, s, s); clientlogf("%s", sf); con.addline(sf); delete[] conline; conline=newstring(sf); } int rendercommand(int x, int y, int w) { const char *useprompt = cmdprompt ? cmdprompt : "#"; defformatstring(s)("%s %s", useprompt, cmdline.buf); int width, height; text_bounds(s, width, height, w); y -= height - FONTH; if (x >= 0) draw_text(s, x, y, 0xFF, 0xFF, 0xFF, 0xFF, cmdline.pos>=0 ? cmdline.pos + strlen(useprompt) + 1 : (int)strlen(s), w); return height; } // keymap is defined externally in keymap.cfg hashtable keyms(256); const char *keycmds[keym::NUMACTIONS] = { "bind", "editbind", "specbind" }; inline const char *keycmd(int type) { return type >= 0 && type < keym::NUMACTIONS ? keycmds[type] : ""; } void keymap(int *code, char *key) { if(findbindc(*code)) { clientlogf("keymap: double assignment for code %d ignored", *code); return; } keym &km = keyms[*code]; km.code = *code; km.name = newstring(key); } COMMAND(keymap, "is"); keym *findbind(const char *key) { enumerate(keyms, keym, km, if(!strcasecmp(km.name, key)) return &km;); return NULL; } keym **findbinda(const char *action, int type) { static vector res; res.setsize(0); enumerate(keyms, keym, km, if(!strcasecmp(km.actions[type], action)) res.add(&km);); res.add(NULL); return res.getbuf(); } keym *findbindc(int code) { return keyms.access(code); } keym *autokeymap(int keycode, int scancode) { static bool scdone[SDL_NUM_SCANCODES] = { false }; int sc = keycode <= SDLK_SCANCODE_MASK ? scancode : (keycode & (SDLK_SCANCODE_MASK - 1)); if(sc < 0 || sc >= SDL_NUM_SCANCODES || scdone[sc]) return NULL; scdone[sc] = true; string text; filtertext(text, SDL_GetScancodeName((SDL_Scancode) sc), FTXT__AUTOKEYMAPNAME); if(!*text || (int)SDL_GetScancodeFromName(text) != sc || findbind(text)) return NULL; // name is not unique (collision probably caused by filtertext) or can't be properly resolved in reverse clientlogf("autokeymap: create keymap entry for scancode %d, \"%s\"", sc, text); sc |= SDLK_SCANCODE_MASK; keymap(&sc, text); return keyms.access(sc); } void findkey(int *code) { const char *res = "-255"; enumerate(keyms, keym, km, if(km.code == *code) { res = km.name; break; } ); result(res); } COMMAND(findkey, "i"); void findkeycode(const char* s) { int res = -255; enumerate(keyms, keym, km, if(!strcmp(s, km.name)) { res = km.code; break; } ); intret(res); } COMMAND(findkeycode, "s"); COMMANDF(modkeypressed, "", () { intret((SDL_GetModState() & MOD_KEYS_CTRL) ? 1 : 0); }); keym *keypressed = NULL; char *keyaction = NULL; VAR(_defaultbinds, 0, 0, 1); COMMANDF(_resetallbinds, "", () { if(_defaultbinds) enumerate(keyms, keym, km, loopj(keym::NUMACTIONS) bindkey(&km, "", j);); }); bool bindkey(keym *km, const char *action, int type) { if(!km || type < keym::ACTION_DEFAULT || type >= keym::NUMACTIONS) return false; if(strcmp(action, km->actions[type])) { if(!keypressed || keyaction!=km->actions[type]) delete[] km->actions[type]; km->actions[type] = newstring(action); km->unchangeddefault[type] = _defaultbinds != 0; } return true; } void bindk(const char *key, const char *action, int type) { keym *km = findbind(key); if(!km) { string text; filtertext(text, key, FTXT__AUTOKEYMAPNAME); int sc = *text && !strcmp(key, text) ? (int)SDL_GetScancodeFromName(text) : SDL_SCANCODE_UNKNOWN; if(sc != SDL_SCANCODE_UNKNOWN) { clientlogf("autokeymap: re-create keymap entry for scancode %d, \"%s\"", sc, text); sc |= SDLK_SCANCODE_MASK; keymap(&sc, text); km = findbind(key); } } if(!km) { conoutf("unknown key \"%s\"", key); return; } bindkey(km, action, type); } void keybind(const char *key, int type) { keym *km = findbind(key); if(!km) { conoutf("unknown key \"%s\"", key); return; } if(type < keym::ACTION_DEFAULT || type >= keym::NUMACTIONS) { conoutf("invalid bind type \"%d\"", type); return; } result(km->actions[type]); } bool bindc(int code, const char *action, int type) { keym *km = findbindc(code); if(km) return bindkey(km, action, type); else return false; } void searchbinds(const char *action, int type) { if(!action || !action[0]) return; if(type < keym::ACTION_DEFAULT || type >= keym::NUMACTIONS) { conoutf("invalid bind type \"%d\"", type); return; } vector names; enumerate(keyms, keym, km, if(!strcmp(km.actions[type], action)) { if(names.length()) names.add(' '); names.put(km.name, strlen(km.name)); } ); resultcharvector(names, 0); } COMMANDF(keybind, "s", (const char *key) { keybind(key, keym::ACTION_DEFAULT); } ); COMMANDF(keyspecbind, "s", (const char *key) { keybind(key, keym::ACTION_SPECTATOR); } ); COMMANDF(keyeditbind, "s", (const char *key) { keybind(key, keym::ACTION_EDITING); } ); COMMANDF(bind, "ss", (const char *key, const char *action) { bindk(key, action, keym::ACTION_DEFAULT); } ); COMMANDF(specbind, "ss", (const char *key, const char *action) { bindk(key, action, keym::ACTION_SPECTATOR); } ); COMMANDF(editbind, "ss", (const char *key, const char *action) { bindk(key, action, keym::ACTION_EDITING); } ); COMMANDF(searchbinds, "s", (const char *action) { searchbinds(action, keym::ACTION_DEFAULT); }); COMMANDF(searchspecbinds, "s", (const char *action) { searchbinds(action, keym::ACTION_SPECTATOR); }); COMMANDF(searcheditbinds, "s", (const char *action) { searchbinds(action, keym::ACTION_EDITING); }); struct releaseaction { keym *key; char *action; }; vector releaseactions; char *addreleaseaction(const char *s) { if(!keypressed) return NULL; releaseaction &ra = releaseactions.add(); ra.key = keypressed; ra.action = newstring(s); return keypressed->name; } void onrelease(char *s) { addreleaseaction(s); } COMMAND(onrelease, "s"); void saycommand(char *init) // turns input to the command line on or off { saycommandon = (init != NULL); textinput(saycommandon, TI_CONSOLE); keyrepeat(saycommandon, KR_CONSOLE); setscope(false); setburst(false); copystring(cmdline.buf, init ? escapestring(init, false, true) : ""); DELETEA(cmdaction); DELETEA(cmdprompt); cmdline.pos = -1; } COMMAND(saycommand, "c"); void inputcommand(char *init, char *action, char *prompt, int *nopersist) { saycommand(init); if(action[0]) cmdaction = newstring(action); if(prompt[0]) cmdprompt = newstring(prompt); storeinputcommand = cmdaction && !*nopersist; } COMMAND(inputcommand, "sssi"); SVARFF(mapmsg, { // read mapmsg hdr.maptitle[127] = '\0'; mapmsg = exchangestr(mapmsg, hdr.maptitle); }, { // set new mapmsg string text; filtertext(text, mapmsg, FTXT__MAPMSG); copystring(hdr.maptitle, text, 128); if(editmode) unsavededits++; }); struct hline { char *buf, *action, *prompt; hline() : buf(NULL), action(NULL), prompt(NULL) {} ~hline() { DELETEA(buf); DELETEA(action); DELETEA(prompt); } void restore() { copystring(cmdline.buf, buf); if(cmdline.pos >= (int)strlen(cmdline.buf)) cmdline.pos = -1; DELETEA(cmdaction); DELETEA(cmdprompt); if(action) cmdaction = newstring(action); if(prompt) cmdprompt = newstring(prompt); storeinputcommand = false; } bool shouldsave() { return strcmp(cmdline.buf, buf) || (cmdaction ? !action || strcmp(cmdaction, action) : action!=NULL) || (cmdprompt ? !prompt || strcmp(cmdprompt, prompt) : prompt!=NULL); } void save() { buf = newstring(cmdline.buf); if(cmdaction) action = newstring(cmdaction); if(cmdprompt) prompt = newstring(cmdprompt); } void run() { pushscontext(IEXC_PROMPT); if(action) { push("cmdbuf", buf); execute(action); pop("cmdbuf"); } else if(buf[0]=='/') execute(buf+1); else toserver(buf); popscontext(); } }; vector history; int histpos = 0; VARP(maxhistory, 0, 1000, 10000); void history_(int *n) { static bool inhistory = false; if(!inhistory && history.inrange(*n)) { inhistory = true; history[history.length() - *n - 1]->run(); inhistory = false; } } COMMANDN(history, history_, "i"); void savehistory() { stream *f = openfile(path("config/history", true), "w"); if(!f) return; loopv(history) { hline *h = history[i]; if(!h->action && !h->prompt && strncmp(h->buf, "/ ", 2)) f->printf("%s\n",h->buf); } delete f; } void loadhistory() { char *histbuf = loadfile(path("config/history", true), NULL); if(!histbuf) return; char *line = NULL, *b; line = strtok_r(histbuf, "\n", &b); while(line) { history.add(new hline)->buf = newstring(line); line = strtok_r(NULL, "\n", &b); } DELETEA(histbuf); histpos = history.length(); } void execbind(keym &k, bool isdown) { loopv(releaseactions) { releaseaction &ra = releaseactions[i]; if(ra.key==&k) { if(!isdown) execute(ra.action); delete[] ra.action; releaseactions.remove(i--); } } if(isdown) { int state = keym::ACTION_DEFAULT; if(editmode) state = keym::ACTION_EDITING; else if(player1->isspectating()) state = keym::ACTION_SPECTATOR; char *&action = k.actions[state][0] ? k.actions[state] : k.actions[keym::ACTION_DEFAULT]; keyaction = action; keypressed = &k; execute(keyaction); keypressed = NULL; if(keyaction!=action) delete[] keyaction; } k.pressed = isdown; } void consolekey(int code, bool isdown, SDL_Keymod mod) { static char *beforecomplete = NULL; static bool ignoreescup = false; if(isdown) { switch(code) { case SDLK_F1: toggledoc(); break; case SDLK_F2: scrolldoc(-4); break; case SDLK_F3: scrolldoc(4); break; case SDL_AC_BUTTON_WHEELUP: case SDLK_UP: if(histpos > history.length()) histpos = history.length(); if(histpos > 0) history[--histpos]->restore(); break; case SDL_AC_BUTTON_WHEELDOWN: case SDLK_DOWN: if(histpos + 1 < history.length()) history[++histpos]->restore(); break; case SDLK_TAB: if(!cmdaction) { if(!beforecomplete) beforecomplete = newstring(cmdline.buf); complete(cmdline.buf, (mod & KMOD_LSHIFT) ? true : false); if(cmdline.pos >= 0 && cmdline.pos >= (int)strlen(cmdline.buf)) cmdline.pos = -1; } break; case SDLK_ESCAPE: if(mod & KMOD_LSHIFT) // LSHIFT+ESC restores buffer from before complete() { if(beforecomplete) copystring(cmdline.buf, beforecomplete); ignoreescup = true; } else ignoreescup = false; break; default: resetcomplete(); DELETEA(beforecomplete); case SDLK_LSHIFT: cmdline.key(code); break; } } else { if(code==SDLK_RETURN || code==SDLK_KP_ENTER || code==SDL_AC_BUTTON_LEFT || code==SDL_AC_BUTTON_MIDDLE) { // make laptop users happy; LMB shall only work with history if(code == SDL_AC_BUTTON_LEFT && histpos == history.length()) return; hline *h = NULL; if(cmdline.buf[0] || cmdaction) { if(history.empty() || history.last()->shouldsave()) { if(maxhistory && history.length() >= maxhistory) { loopi(history.length()-maxhistory+1) delete history[i]; history.remove(0, history.length()-maxhistory+1); } history.add(h = new hline)->save(); } else h = history.last(); } histpos = history.length(); saycommand(NULL); if(h) { h->run(); if(h->action && !storeinputcommand) history.drop(); } } else if((code==SDLK_ESCAPE && !ignoreescup) || code== SDL_AC_BUTTON_RIGHT) { histpos = history.length(); saycommand(NULL); } } } void processtextinput(const char *text) { if(saycommandon) { cmdline.say(text); } else { menusay(text); } } void keypress(int keycode, int scancode, bool isdown, SDL_Keymod mod) { keym *haskey = keyms.access(keycode); if(!haskey && !(keycode & SDLK_SCANCODE_MASK) && scancode) haskey = keyms.access(scancode | SDLK_SCANCODE_MASK); // keycode not found: maybe we know the scancode if(!haskey && isdown) haskey = autokeymap(keycode, scancode); if(haskey && haskey->pressed) execbind(*haskey, isdown); // allow pressed keys to release else if(saycommandon) consolekey(keycode, isdown, mod); // keystrokes go to commandline else if(!menukey(keycode, isdown)) // keystrokes go to menu { if(haskey) execbind(*haskey, isdown); } if(keycode & SDLK_SCANCODE_MASK) scancode = keycode & ~SDLK_SCANCODE_MASK; if(isdown) exechook(HOOK_SP, "KEYPRESS", "KEYPRESS %d %d", keycode, scancode); else exechook(HOOK_SP, "KEYRELEASE", "%d %d", keycode, scancode); } char *getcurcommand(int *pos) { if(pos && saycommandon) *pos = cmdline.pos; return saycommandon ? cmdline.buf : NULL; } VARP(omitunchangeddefaultbinds, 0, 1, 2); void writebinds(stream *f) { enumerate(keyms, keym, km, loopj(3) if(*km.actions[j] && (!km.unchangeddefault[j] || omitunchangeddefaultbinds < 2)) f->printf("%s%s \"%s\" %s\n", km.unchangeddefault[j] && omitunchangeddefaultbinds ? "//" : "", keycmd(j), km.name, escapestring(km.actions[j])); ); } bool textinputbuffer::say(const char *c) { string txt; copystring(txt, c); if(filterunrenderables(txt)) audiomgr.playsound(S_PAIN1, SP_LOW); int buflen = (int)strlen(buf), txtlen = (int)strlen(txt); if(txtlen && buflen < maxlen() && buflen + txtlen < (int)sizeof(buf)) { if(pos < 0) strncpy(buf + buflen, txt, txtlen); else { memmove(&buf[pos + txtlen], &buf[pos], buflen - pos); memcpy(&buf[pos], txt, txtlen); pos += txtlen; } buf[buflen + txtlen] = '\0'; return true; } return false; } void textinputbuffer::pasteclipboard() { const char *s = SDL_GetClipboardText(); if(s) { string f; filtertext(f, s, FTXT__CONSOLEPASTE); say(f); SDL_free((void*)s); } } #ifdef _DEBUG void writekeymap() // create keymap.cfg with proper constants from SDL2 header files { const struct _keymaptab { int keycode; const char *keyname; } keymaptab[] = { { -1, "MOUSE1" }, { -3, "MOUSE2" }, { -2, "MOUSE3" }, { -4, "MOUSE4" }, { -5, "MOUSE5" }, { -6, "MOUSE6" }, { -7, "MOUSE7" }, { -8, "MOUSE8" }, { -9, "MOUSE9" }, { -10, "MOUSE10" }, { -11, "MOUSE11" }, { -12, "MOUSE12" }, { -13, "MOUSE13" }, { -14, "MOUSE14" }, { -15, "MOUSE15" }, { -16, "MOUSE16" }, { SDLK_BACKSPACE, "BACKSPACE" }, { SDLK_TAB, "TAB" }, { SDLK_CLEAR, "CLEAR" }, { SDLK_RETURN, "RETURN" }, { SDLK_PAUSE, "PAUSE" }, { SDLK_ESCAPE, "ESCAPE" }, { SDLK_SPACE, "SPACE" }, { SDLK_EXCLAIM, "EXCLAIM" }, { SDLK_QUOTEDBL, "QUOTEDBL" }, { SDLK_HASH, "HASH" }, { SDLK_DOLLAR, "DOLLAR" }, { SDLK_AMPERSAND, "AMPERSAND" }, { SDLK_QUOTE, "QUOTE" }, { SDLK_LEFTPAREN, "LEFTPAREN" }, { SDLK_RIGHTPAREN, "RIGHTPAREN" }, { SDLK_ASTERISK, "ASTERISK" }, { SDLK_PLUS, "PLUS" }, { SDLK_COMMA, "COMMA" }, { SDLK_MINUS, "MINUS" }, { SDLK_PERIOD, "PERIOD" }, { SDLK_SLASH, "SLASH" }, { SDLK_0, "0" }, { SDLK_1, "1" }, { SDLK_2, "2" }, { SDLK_3, "3" }, { SDLK_4, "4" }, { SDLK_5, "5" }, { SDLK_6, "6" }, { SDLK_7, "7" }, { SDLK_8, "8" }, { SDLK_9, "9" }, { SDLK_COLON, "COLON" }, { SDLK_SEMICOLON, "SEMICOLON" }, { SDLK_LESS, "LESS" }, { SDLK_EQUALS, "EQUALS" }, { SDLK_GREATER, "GREATER" }, { SDLK_QUESTION, "QUESTION" }, { SDLK_AT, "AT" }, { SDLK_LEFTBRACKET, "LEFTBRACKET" }, { SDLK_BACKSLASH, "BACKSLASH" }, { SDLK_RIGHTBRACKET, "RIGHTBRACKET" }, { SDLK_CARET, "CARET" }, { SDLK_UNDERSCORE, "UNDERSCORE" }, { SDLK_BACKQUOTE, "BACKQUOTE" }, { SDLK_a, "A" }, { SDLK_b, "B" }, { SDLK_c, "C" }, { SDLK_d, "D" }, { SDLK_e, "E" }, { SDLK_f, "F" }, { SDLK_g, "G" }, { SDLK_h, "H" }, { SDLK_i, "I" }, { SDLK_j, "J" }, { SDLK_k, "K" }, { SDLK_l, "L" }, { SDLK_m, "M" }, { SDLK_n, "N" }, { SDLK_o, "O" }, { SDLK_p, "P" }, { SDLK_q, "Q" }, { SDLK_r, "R" }, { SDLK_s, "S" }, { SDLK_t, "T" }, { SDLK_u, "U" }, { SDLK_v, "V" }, { SDLK_w, "W" }, { SDLK_x, "X" }, { SDLK_y, "Y" }, { SDLK_z, "Z" }, { SDLK_DELETE, "DELETE" }, { SDLK_KP_0, "KP0" }, { SDLK_KP_1, "KP1" }, { SDLK_KP_2, "KP2" }, { SDLK_KP_3, "KP3" }, { SDLK_KP_4, "KP4" }, { SDLK_KP_5, "KP5" }, { SDLK_KP_6, "KP6" }, { SDLK_KP_7, "KP7" }, { SDLK_KP_8, "KP8" }, { SDLK_KP_9, "KP9" }, { SDLK_KP_PERIOD, "KP_PERIOD" }, { SDLK_KP_DIVIDE, "KP_DIVIDE" }, { SDLK_KP_MULTIPLY, "KP_MULTIPLY" }, { SDLK_KP_MINUS, "KP_MINUS" }, { SDLK_KP_PLUS, "KP_PLUS" }, { SDLK_KP_ENTER, "KP_ENTER" }, { SDLK_KP_EQUALS, "KP_EQUALS" }, { SDLK_UP, "UP" }, { SDLK_DOWN, "DOWN" }, { SDLK_RIGHT, "RIGHT" }, { SDLK_LEFT, "LEFT" }, { SDLK_INSERT, "INSERT" }, { SDLK_HOME, "HOME" }, { SDLK_END, "END" }, { SDLK_PAGEUP, "PAGEUP" }, { SDLK_PAGEDOWN, "PAGEDOWN" }, { SDLK_F1, "F1" }, { SDLK_F2, "F2" }, { SDLK_F3, "F3" }, { SDLK_F4, "F4" }, { SDLK_F5, "F5" }, { SDLK_F6, "F6" }, { SDLK_F7, "F7" }, { SDLK_F8, "F8" }, { SDLK_F9, "F9" }, { SDLK_F10, "F10" }, { SDLK_F11, "F11" }, { SDLK_F12, "F12" }, { SDLK_F13, "F13" }, { SDLK_F14, "F14" }, { SDLK_F15, "F15" }, { SDLK_NUMLOCKCLEAR, "NUMLOCK" }, { SDLK_CAPSLOCK, "CAPSLOCK" }, { SDLK_SCROLLLOCK, "SCROLLOCK" }, { SDLK_RSHIFT, "RSHIFT" }, { SDLK_LSHIFT, "LSHIFT" }, { SDLK_RCTRL, "RCTRL" }, { SDLK_LCTRL, "LCTRL" }, { SDLK_RALT, "RALT" }, { SDLK_LALT, "LALT" }, { SDLK_RGUI, "RMETA" }, { SDLK_LGUI, "LMETA" }, { SDLK_MODE, "MODE" }, { SDLK_APPLICATION, "COMPOSE" }, { SDLK_HELP, "HELP" }, { SDLK_PRINTSCREEN, "PRINT" }, { SDLK_SYSREQ, "SYSREQ" }, { SDLK_MENU, "MENU" }, { 223, "SZ" }, // appear to work, but are undocumented... { 252, "UE" }, { 246, "OE" }, { 228, "AE" }, { SDL_SCANCODE_GRAVE | SDLK_SCANCODE_MASK, "LEFTOF1" }, // may not produce a proper keycode if the layout has dead keys { SDL_SCANCODE_EQUALS | SDLK_SCANCODE_MASK, "LEFTOFDEL" }, { -1, " " }, // keys below are commented out by default { SDLK_PERCENT, "PERCENT" }, { SDLK_POWER, "POWER" }, { SDLK_F16, "F16" }, { SDLK_F17, "F17" }, { SDLK_F18, "F18" }, { SDLK_F19, "F19" }, { SDLK_F20, "F20" }, { SDLK_F21, "F21" }, { SDLK_F22, "F22" }, { SDLK_F23, "F23" }, { SDLK_F24, "F24" }, { SDLK_EXECUTE, "EXECUTE" }, { SDLK_SELECT, "SELECT" }, { SDLK_STOP, "STOP" }, { SDLK_AGAIN, "AGAIN" }, { SDLK_UNDO, "UNDO" }, { SDLK_CUT, "CUT" }, { SDLK_COPY, "COPY" }, { SDLK_PASTE, "PASTE" }, { SDLK_FIND, "FIND" }, { SDLK_MUTE, "MUTE" }, { SDLK_VOLUMEUP, "VOLUMEUP" }, { SDLK_VOLUMEDOWN, "VOLUMEDOWN" }, { SDLK_KP_COMMA, "KP_COMMA" }, { SDLK_KP_EQUALSAS400, "KP_EQUALSAS400" }, { SDLK_ALTERASE, "ALTERASE" }, { SDLK_CANCEL, "CANCEL" }, { SDLK_PRIOR, "PRIOR" }, { SDLK_RETURN2, "RETURN2" }, { SDLK_SEPARATOR, "SEPARATOR" }, { SDLK_OUT, "OUT" }, { SDLK_OPER, "OPER" }, { SDLK_CLEARAGAIN, "CLEARAGAIN" }, { SDLK_CRSEL, "CRSEL" }, { SDLK_EXSEL, "EXSEL" }, { SDLK_KP_00, "KP_00" }, { SDLK_KP_000, "KP_000" }, { SDLK_THOUSANDSSEPARATOR, "THOUSANDSSEPARATOR" }, { SDLK_DECIMALSEPARATOR, "DECIMALSEPARATOR" }, { SDLK_CURRENCYUNIT, "CURRENCYUNIT" }, { SDLK_CURRENCYSUBUNIT, "CURRENCYSUBUNIT" }, { SDLK_KP_LEFTPAREN, "KP_LEFTPAREN" }, { SDLK_KP_RIGHTPAREN, "KP_RIGHTPAREN" }, { SDLK_KP_LEFTBRACE, "KP_LEFTBRACE" }, { SDLK_KP_RIGHTBRACE, "KP_RIGHTBRACE" }, { SDLK_KP_TAB, "KP_TAB" }, { SDLK_KP_BACKSPACE, "KP_BACKSPACE" }, { SDLK_KP_A, "KP_A" }, { SDLK_KP_B, "KP_B" }, { SDLK_KP_C, "KP_C" }, { SDLK_KP_D, "KP_D" }, { SDLK_KP_E, "KP_E" }, { SDLK_KP_F, "KP_F" }, { SDLK_KP_XOR, "KP_XOR" }, { SDLK_KP_POWER, "KP_POWER" }, { SDLK_KP_PERCENT, "KP_PERCENT" }, { SDLK_KP_LESS, "KP_LESS" }, { SDLK_KP_GREATER, "KP_GREATER" }, { SDLK_KP_AMPERSAND, "KP_AMPERSAND" }, { SDLK_KP_DBLAMPERSAND, "KP_DBLAMPERSAND" }, { SDLK_KP_VERTICALBAR, "KP_VERTICALBAR" }, { SDLK_KP_DBLVERTICALBAR, "KP_DBLVERTICALBAR" }, { SDLK_KP_COLON, "KP_COLON" }, { SDLK_KP_HASH, "KP_HASH" }, { SDLK_KP_SPACE, "KP_SPACE" }, { SDLK_KP_AT, "KP_AT" }, { SDLK_KP_EXCLAM, "KP_EXCLAM" }, { SDLK_KP_MEMSTORE, "KP_MEMSTORE" }, { SDLK_KP_MEMRECALL, "KP_MEMRECALL" }, { SDLK_KP_MEMCLEAR, "KP_MEMCLEAR" }, { SDLK_KP_MEMADD, "KP_MEMADD" }, { SDLK_KP_MEMSUBTRACT, "KP_MEMSUBTRACT" }, { SDLK_KP_MEMMULTIPLY, "KP_MEMMULTIPLY" }, { SDLK_KP_MEMDIVIDE, "KP_MEMDIVIDE" }, { SDLK_KP_PLUSMINUS, "KP_PLUSMINUS" }, { SDLK_KP_CLEAR, "KP_CLEAR" }, { SDLK_KP_CLEARENTRY, "KP_CLEARENTRY" }, { SDLK_KP_BINARY, "KP_BINARY" }, { SDLK_KP_OCTAL, "KP_OCTAL" }, { SDLK_KP_DECIMAL, "KP_DECIMAL" }, { SDLK_KP_HEXADECIMAL, "KP_HEXADECIMAL" }, { SDLK_AUDIONEXT, "AUDIONEXT" }, { SDLK_AUDIOPREV, "AUDIOPREV" }, { SDLK_AUDIOSTOP, "AUDIOSTOP" }, { SDLK_AUDIOPLAY, "AUDIOPLAY" }, { SDLK_AUDIOMUTE, "AUDIOMUTE" }, { SDLK_MEDIASELECT, "MEDIASELECT" }, { SDLK_WWW, "WWW" }, { SDLK_MAIL, "MAIL" }, { SDLK_CALCULATOR, "CALCULATOR" }, { SDLK_COMPUTER, "COMPUTER" }, { SDLK_AC_SEARCH, "AC_SEARCH" }, { SDLK_AC_HOME, "AC_HOME" }, { SDLK_AC_BACK, "AC_BACK" }, { SDLK_AC_FORWARD, "AC_FORWARD" }, { SDLK_AC_STOP, "AC_STOP" }, { SDLK_AC_REFRESH, "AC_REFRESH" }, { SDLK_AC_BOOKMARKS, "AC_BOOKMARKS" }, { SDLK_BRIGHTNESSDOWN, "BRIGHTNESSDOWN" }, { SDLK_BRIGHTNESSUP, "BRIGHTNESSUP" }, { SDLK_DISPLAYSWITCH, "DISPLAYSWITCH" }, { SDLK_KBDILLUMTOGGLE, "KBDILLUMTOGGLE" }, { SDLK_KBDILLUMDOWN, "KBDILLUMDOWN" }, { SDLK_KBDILLUMUP, "KBDILLUMUP" }, { SDLK_EJECT, "EJECT" }, { SDLK_SLEEP, "SLEEP" }, { 0, "" } }; const char *c = ""; stream *f = openfile("config" PATHDIVS "keymap.cfg", "w"); if(f) { f->printf("push sc [ result (|b 0x40000000 $arg1) ]\n\n"); for(int i = 0; keymaptab[i].keycode; i++) { if(keymaptab[i].keyname[0] == ' ') c = "//"; else f->printf(keymaptab[i].keycode < SDLK_SCANCODE_MASK ? "%skeymap %d %s\n" : "%skeymap (sc %d) %s\n", c, keymaptab[i].keycode & (keymaptab[i].keycode > 0 ? (SDLK_SCANCODE_MASK-1) : -1), keymaptab[i].keyname); } f->printf("\npop sc\nexec config/resetbinds.cfg\n"); delete f; } } COMMAND(writekeymap, ""); #endif assaultcube-1.2.0.2.1/source/src/console.h000066400000000000000000000053601352165075300202410ustar00rootroot00000000000000struct cline { char *line; int millis; }; template struct consolebuffer { int maxlines; vector conlines; consolebuffer(int maxlines = 100) : maxlines(maxlines) {} LINE &addline(const char *sf, int millis) // add a line to the console buffer { LINE cl; cl.line = conlines.length()>maxlines ? conlines.pop().line : newstringbuf(""); // constrain the buffer size cl.millis = millis; // for how long to keep line on screen extern void encodeigraphs(char *d, const char *s, int len); encodeigraphs(cl.line, sf, MAXSTRLEN); return conlines.insert(0, cl); } void setmaxlines(int numlines) { maxlines = numlines; while(conlines.length() > maxlines) delete[] conlines.pop().line; } virtual ~consolebuffer() { while(conlines.length()) delete[] conlines.pop().line; } virtual void render() = 0; }; struct textinputbuffer { string buf; int pos, max; textinputbuffer() : pos(-1), max(0) { buf[0] = '\0'; } int maxlen() const { return max ? max : sizeof(buf); } bool say(const char *c); // returns true if buffer was modified void pasteclipboard(); bool key(int code) // returns true if buffer was modified { switch(code) { case SDLK_RETURN: case SDLK_KP_ENTER: break; case SDLK_HOME: if(strlen(buf)) pos = 0; break; case SDLK_END: pos = -1; break; case SDLK_DELETE: { int len = (int)strlen(buf); if(pos<0) break; memmove(&buf[pos], &buf[pos+1], len - pos); if(pos>=len-1) pos = -1; return true; } case SDLK_BACKSPACE: { int len = (int)strlen(buf), i = pos>=0 ? pos : len; if(i<1) break; memmove(&buf[i-1], &buf[i], len - i + 1); if(pos>0) pos--; else if(!pos && len<=1) pos = -1; return true; } case SDLK_LEFT: if(pos > 0) pos--; else if(pos < 0) pos = (int)strlen(buf)-1; break; case SDLK_RIGHT: if(pos>=0 && ++pos>=(int)strlen(buf)) pos = -1; break; case SDLK_v: if(SDL_GetModState() & MOD_KEYS_CTRL) { pasteclipboard(); return true; } break; default: break; } return false; } }; assaultcube-1.2.0.2.1/source/src/crypto.cpp000066400000000000000000001613071352165075300204560ustar00rootroot00000000000000#include "cube.h" #ifdef STANDALONE #define DEBUGCOND (true) #else VARP(cryptodebug, 0, 1, 1); #define DEBUGCOND (cryptodebug==1) #endif static const char *hexdigits = "0123456789abcdef"; ///////////////////////// cryptography ///////////////////////////////// /* Based off the reference implementation of Tiger, a cryptographically * secure 192 bit hash function by Ross Anderson and Eli Biham. More info at: * http://www.cs.technion.ac.il/~biham/Reports/Tiger/ */ #define TIGER_PASSES 3 namespace tiger { typedef uint64_t chunk; union hashval { uchar bytes[3*8]; chunk chunks[3]; }; chunk sboxes[4*256]; void compress(const chunk *str, chunk state[3]) { ASSERT(sizeof(chunk) == 8); chunk a, b, c; chunk aa, bb, cc; chunk x0, x1, x2, x3, x4, x5, x6, x7; a = state[0]; b = state[1]; c = state[2]; x0 = lilswap(str[0]); x1 = lilswap(str[1]); x2 = lilswap(str[2]); x3 = lilswap(str[3]); x4 = lilswap(str[4]); x5 = lilswap(str[5]); x6 = lilswap(str[6]); x7 = lilswap(str[7]); aa = a; bb = b; cc = c; loop(pass_no, TIGER_PASSES) { if(pass_no) { x0 -= x7 ^ 0xA5A5A5A5A5A5A5A5ULL; x1 ^= x0; x2 += x1; x3 -= x2 ^ ((~x1)<<19); x4 ^= x3; x5 += x4; x6 -= x5 ^ ((~x4)>>23); x7 ^= x6; x0 += x7; x1 -= x0 ^ ((~x7)<<19); x2 ^= x1; x3 += x2; x4 -= x3 ^ ((~x2)>>23); x5 ^= x4; x6 += x5; x7 -= x6 ^ 0x0123456789ABCDEFULL; } #define sb1 (sboxes) #define sb2 (sboxes+256) #define sb3 (sboxes+256*2) #define sb4 (sboxes+256*3) #define tround(a, b, c, x) \ c ^= x; \ a -= sb1[((c)>>(0*8))&0xFF] ^ sb2[((c)>>(2*8))&0xFF] ^ \ sb3[((c)>>(4*8))&0xFF] ^ sb4[((c)>>(6*8))&0xFF] ; \ b += sb4[((c)>>(1*8))&0xFF] ^ sb3[((c)>>(3*8))&0xFF] ^ \ sb2[((c)>>(5*8))&0xFF] ^ sb1[((c)>>(7*8))&0xFF] ; \ b *= mul; uint mul = !pass_no ? 5 : (pass_no==1 ? 7 : 9); tround(a, b, c, x0) tround(b, c, a, x1) tround(c, a, b, x2) tround(a, b, c, x3) tround(b, c, a, x4) tround(c, a, b, x5) tround(a, b, c, x6) tround(b, c, a, x7) chunk tmp = a; a = c; c = b; b = tmp; } a ^= aa; b -= bb; c += cc; state[0] = a; state[1] = b; state[2] = c; } void gensboxes() { const char *str = "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham"; chunk state[3] = { 0x0123456789ABCDEFULL, 0xFEDCBA9876543210ULL, 0xF096A5B4C3B2E187ULL }; loopi(1024) loop(col, 8) ((uchar *)&sboxes[i])[col] = i&0xFF; int abc = 2; loop(pass, 5) loopi(256) for(int sb = 0; sb < 1024; sb += 256) { abc++; if(abc >= 3) { abc = 0; compress((const chunk *)str, state); } loop(col, 8) { uchar val = ((uchar *)&sboxes[sb+i])[col]; ((uchar *)&sboxes[sb+i])[col] = ((uchar *)&sboxes[sb + ((uchar *)&state[abc])[col]])[col]; ((uchar *)&sboxes[sb + ((uchar *)&state[abc])[col]])[col] = val; } } } struct incremental_buffer { int len, total; union { uchar u[64]; chunk c[8]; }; incremental_buffer() { len = total = 0; } }; incremental_buffer *hash_init(hashval &val) { static bool init = false; if(!init) { gensboxes(); init = true; } val.chunks[0] = 0x0123456789ABCDEFULL; val.chunks[1] = 0xFEDCBA9876543210ULL; val.chunks[2] = 0xF096A5B4C3B2E187ULL; return new incremental_buffer; } void hash_incremental(const uchar *msg, int len, hashval &val, incremental_buffer *b) { ASSERT(b && b->len >= 0 && b->len < 64); b->total += len; while(b->len + len >= 64) { if(b->len > 0) { // fill up buffer and compress int fill = 64 - b->len; memcpy(b->u + b->len, msg, fill); compress(b->c, val.chunks); b->len = 0; len -= fill; msg += fill; } else { // compress directly from msg compress((chunk *)msg, val.chunks); len -= 64; msg += 64; } } if(len > 0) { // pur rest in buffer memcpy(b->u + b->len, msg, len); b->len += len; } } void hash_finish(hashval &val, incremental_buffer *b) { ASSERT(b && b->len >= 0 && b->len < 64); memset(b->u + b->len, 0, 64 - b->len); b->u[b->len] = 0x01; if(b->len >= 56) { compress(b->c, val.chunks); memset(b->u, 0, 64); b->len = 0; } b->c[7] = lilswap(chunk(b->total << 3)); compress(b->c, val.chunks); lilswap(val.chunks, 3); delete b; } void hash(const uchar *str, int length, hashval &val) { incremental_buffer *b = hash_init(val); int i = length; for(; i >= 64; i -= 64, str += 64) { compress((chunk *)str, val.chunks); } memcpy(b->u, str, i); b->len = i; b->total = length; hash_finish(val, b); } } void tigerhash(uchar *hash, const uchar *msg, int len) { tiger::hash(msg, len, *((tiger::hashval *) hash)); } void *tigerhash_init(uchar *hash) { return (void *)tiger::hash_init(*((tiger::hashval *) hash)); } void tigerhash_add(uchar *hash, const void *msg, int len, void *state) { tiger::hash_incremental((const uchar *)msg, len, *((tiger::hashval *) hash), (tiger::incremental_buffer *)state); } void tigerhash_finish(uchar *hash, void *state) { if(hash) tiger::hash_finish(*((tiger::hashval *) hash), (tiger::incremental_buffer *)state); else delete (tiger::incremental_buffer *)state; } #undef sb1 #undef sb2 #undef sb3 #undef sb4 #undef tround /////////////////////////////////////////// SHA512 //////////////////////////////////////////////////////////////////// // adapted from pseudocode and various public domain sources (probably all originating in LibTomCrypt) // (consider this code public domain, too) #define RR64(x, n) (((x) >> (n)) | ((x) << (64 - (n)))) #define SHA512ROUND(a, b, c, d, e, f, g, h, i) \ d += h = h + (RR64(e,14) ^ RR64(e,18) ^ RR64(e,41)) + (g ^ (e & (f ^ g))) + K[i] + W[i]; \ h += (RR64(a,28) ^ RR64(a,34) ^ RR64(a,39)) + (((a | b) & c) | (a & b)); #define SHA512SIZE (512 / 8) void sha512_compress(uint64_t *state, const uchar *inbuf) // sha512 main function: compress one chunk of 128 bytes { static const uint64_t K[80] = { 0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL, 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL, 0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL, 0xd807aa98a3030242ULL, 0x12835b0145706fbeULL, 0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL, 0x72be5d74f27b896fULL, 0x80deb1fe3b1696b1ULL, 0x9bdc06a725c71235ULL, 0xc19bf174cf692694ULL, 0xe49b69c19ef14ad2ULL, 0xefbe4786384f25e3ULL, 0x0fc19dc68b8cd5b5ULL, 0x240ca1cc77ac9c65ULL, 0x2de92c6f592b0275ULL, 0x4a7484aa6ea6e483ULL, 0x5cb0a9dcbd41fbd4ULL, 0x76f988da831153b5ULL, 0x983e5152ee66dfabULL, 0xa831c66d2db43210ULL, 0xb00327c898fb213fULL, 0xbf597fc7beef0ee4ULL, 0xc6e00bf33da88fc2ULL, 0xd5a79147930aa725ULL, 0x06ca6351e003826fULL, 0x142929670a0e6e70ULL, 0x27b70a8546d22ffcULL, 0x2e1b21385c26c926ULL, 0x4d2c6dfc5ac42aedULL, 0x53380d139d95b3dfULL, 0x650a73548baf63deULL, 0x766a0abb3c77b2a8ULL, 0x81c2c92e47edaee6ULL, 0x92722c851482353bULL, 0xa2bfe8a14cf10364ULL, 0xa81a664bbc423001ULL, 0xc24b8b70d0f89791ULL, 0xc76c51a30654be30ULL, 0xd192e819d6ef5218ULL, 0xd69906245565a910ULL, 0xf40e35855771202aULL, 0x106aa07032bbd1b8ULL, 0x19a4c116b8d2d0c8ULL, 0x1e376c085141ab53ULL, 0x2748774cdf8eeb99ULL, 0x34b0bcb5e19b48a8ULL, 0x391c0cb3c5c95a63ULL, 0x4ed8aa4ae3418acbULL, 0x5b9cca4f7763e373ULL, 0x682e6ff3d6b2b8a3ULL, 0x748f82ee5defb2fcULL, 0x78a5636f43172f60ULL, 0x84c87814a1f0ab72ULL, 0x8cc702081a6439ecULL, 0x90befffa23631e28ULL, 0xa4506cebde82bde9ULL, 0xbef9a3f7b2c67915ULL, 0xc67178f2e372532bULL, 0xca273eceea26619cULL, 0xd186b8c721c0c207ULL, 0xeada7dd6cde0eb1eULL, 0xf57d4f7fee6ed178ULL, 0x06f067aa72176fbaULL, 0x0a637dc5a2c898a6ULL, 0x113f9804bef90daeULL, 0x1b710b35131c471bULL, 0x28db77f523047d84ULL, 0x32caab7b40c72493ULL, 0x3c9ebe0a15c9bebcULL, 0x431d67c49c100d4cULL, 0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL, 0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL }; uint64_t S[8], W[80]; loopi(8) S[i] = state[i]; loopi(16) W[i] = bigswap(((uint64_t*)inbuf)[i]); loopi(64) W[i + 16] = W[i] + W[i + 9] + (RR64(W[i + 14],19) ^ RR64(W[i + 14],61) ^ (W[i + 14] >> 6)) + (RR64(W[i + 1],1) ^ RR64(W[i + 1], 8) ^ (W[i + 1] >> 7)); for(int i = 0; i < 80; i += 8) { SHA512ROUND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],i+0); SHA512ROUND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],i+1); SHA512ROUND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],i+2); SHA512ROUND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],i+3); SHA512ROUND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],i+4); SHA512ROUND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],i+5); SHA512ROUND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],i+6); SHA512ROUND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],i+7); } loopi(8) state[i] += S[i]; } void sha512(uchar *hash, const uchar *msg, int msglen) { uint64_t state[8] = { 0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL, 0x3c6ef372fe94f82bULL, 0xa54ff53a5f1d36f1ULL, 0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL, 0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL }; uint64_t total = msglen * 8ULL; for(; msglen >= 128; msglen -= 128) { sha512_compress(state, msg); msg += 128; } uchar endmsg[128] = { 0 }; memcpy(endmsg, msg, msglen); endmsg[msglen] = 0x80; if(msglen > 111) { sha512_compress(state, endmsg); memset(endmsg, 0, 128); } *((uint64_t*)(endmsg + 120)) = bigswap(total); sha512_compress(state, endmsg); loopi(8) ((uint64_t*)hash)[i] = bigswap(state[i]); } #undef RR64 #undef SHA512ROUND #ifndef STANDALONE #ifdef _DEBUG COMMANDF(sha512, "s", (char *msg) // SHA512 debug command { uchar hash[SHA512SIZE]; sha512(hash, (uchar*)msg, strlen(msg)); defformatstring(erg)("SHA512: "); loopi(SHA512SIZE) concatformatstring(erg, "%02x", hash[i]); conoutf("%s", erg); }); COMMANDF(tiger, "s", (char *msg) // tiger debug command { tiger::hashval hash; // tiger::hash((uchar *)msg, (int)strlen(msg), hash); void *s = tigerhash_init((uchar *)&hash); tigerhash_add((uchar *)&hash, msg, (int)strlen(msg), s); tigerhash_finish((uchar *)&hash, s); defformatstring(erg)("TIGER: "); loopi(24) concatformatstring(erg, "%02x", hash.bytes[i]); conoutf("%s", erg); }); #endif #endif #ifdef _DEBUG int __hashtest() // crash, if hash functions don't work properly - no one ever tested the big endian code { const char *msg = "The quick brown fox jumps over the lazy dog"; const uchar ht[] = { 0x6d, 0x12, 0xa4, 0x1e, 0x72, 0xe6, 0x44, 0xf0, 0x17, 0xb6, 0xf0, 0xe2, 0xf7, 0xb4, 0x4c, 0x62, 0x85, 0xf0, 0x6d, 0xd5, 0xd2, 0xc5, 0xb0, 0x75 }; const uchar hs[] = { 0x07, 0xe5, 0x47, 0xd9, 0x58, 0x6f, 0x6a, 0x73, 0xf7, 0x3f, 0xba, 0xc0, 0x43, 0x5e, 0xd7, 0x69, 0x51, 0x21, 0x8f, 0xb7, 0xd0, 0xc8, 0xd7, 0x88, 0xa3, 0x09, 0xd7, 0x85, 0x43, 0x6b, 0xbb, 0x64, 0x2e, 0x93, 0xa2, 0x52, 0xa9, 0x54, 0xf2, 0x39, 0x12, 0x54, 0x7d, 0x1e, 0x8a, 0x3b, 0x5e, 0xd6, 0xe1, 0xbf, 0xd7, 0x09, 0x78, 0x21, 0x23, 0x3f, 0xa0, 0x53, 0x8f, 0x3d, 0xb8, 0x54, 0xfe, 0xe6 }; tiger::hashval hash; tiger::hash((uchar *)msg, (int)strlen(msg), hash); uchar shash[SHA512SIZE]; sha512(shash, (uchar*)msg, strlen(msg)); int res = memcmp(hash.bytes, ht, TIGERHASHSIZE) | memcmp(shash, hs, SHA512SIZE); ASSERT(!res); return res; } static int __ht = __hashtest(); #endif ///////////////////////////////////////////////////////// FNV-1a /////////////////////////////////////////////////////////////////// // Fowler–Noll–Vo is a non-cryptographic hash function created by Glenn Fowler, Landon Curt Noll, and Phong Vo. It is public domain. // We use the 32-bit-version here. inline void fnv1a_init(uint32_t &hash) { hash = 2166136261UL; } inline void fnv1a_add(uint32_t &hash, uchar byte) { hash ^= byte; hash *= 16777619; } ////////////////////////// crypto rand (Mersenne twister) //////////////////////////////////////// #define MT_N (624) #define MT_M (397) #define MT_K (0x9908B0DFU) static uint mt_state[2 * MT_N]; static int mt_next = MT_N; void seedMT_do(uint seed, uint *statearray, uint arraysize) { statearray[0] = seed; for(uint i = 1; i < arraysize; i++) statearray[i] = seed = 1812433253U * (seed ^ (seed >> 30)) + i; } void seedMT(uint seed) { loopi(MT_N) mt_state[i + MT_N] = mt_state[i]; mt_state[0] = seed; seedMT_do(seed, mt_state, MT_N); mt_next = 0; } uint randomMT() { int cur = mt_next; if(++mt_next >= MT_N) { if(mt_next > MT_N) { seedMT(5489U + time(NULL)); cur = mt_next++; } else mt_next = 0; } uint y = (mt_state[cur] & 0x80000000U) | (mt_state[mt_next] & 0x7FFFFFFFU); mt_state[cur] = y = mt_state[cur < MT_N - MT_M ? cur + MT_M : cur + MT_M - MT_N] ^ (y >> 1) ^ (-int(y & 1U) & MT_K); y ^= (y >> 11); y ^= (y << 7) & 0x9D2C5680U; y ^= (y << 15) & 0xEFC60000U; y ^= (y >> 18); return y; } void popMT() // undo last seedMT() { loopi(MT_N) mt_state[i] = mt_state[i + MT_N]; } /////////////////////////////////////////////// Entropy collector //////////////////////////////////////////////////////////////////////////////// // * collects entropy (true random data) through mouse moves and keyboard action (and from other sources) // * used to seed the pseudorandom generator // * used to generate very good private keys #define ENTCHUNKS 32 // pool size (in 128-bytes chunks) #define ENTPOOLSIZE (ENTCHUNKS * 128) #define ENTROPYSAVEFILE "config" PATHDIVS "entropy.dat" static uchar *entpool = NULL; static void xor_block(uchar *d, const uchar *s, int len) { uint64_t *dd = (uint64_t *)d, *ss = (uint64_t *)s; for( ; len > 7; len -= 8) *dd++ ^= *ss++; d = (uchar*)dd, s = (uchar*)ss; while(len-- > 0) *d++ ^= *s++; } static void mix_block(uchar *d, const uchar *s, int len) { static uchar sum = 0; int t; while(len-- > 0) { t = *d * *s++ + sum; *d++ += t >> 4; sum += t >> 7; } } void entropy_init(uint seed) { DELETEP(entpool); entpool = new uchar[ENTPOOLSIZE + 128]; seedMT_do(seed, (uint*)entpool, ENTPOOLSIZE / sizeof(uint)); int len = 0; char *buf = loadfile(ENTROPYSAVEFILE, &len); if(buf && len) entropy_add_block((uchar*)buf, len); #ifndef STANDALONE else { extern int bootstrapentropy; bootstrapentropy += 7 + rnd(13); clientlogf(ENTROPYSAVEFILE " not found."); } #endif DELETEA(buf); entropy_get((uchar*)mt_state, MT_N * sizeof(uint)); } void entropy_save() { stream *f = openfile(ENTROPYSAVEFILE, "w"); if(f) f->write(entpool, ENTPOOLSIZE); DELETEP(f); } void entropy_add_byte(uchar b) { static int next = 0; int r = entpool[next] & 7; entpool[next++] ^= b << r | b >> (8 - r); if(next >= ENTPOOLSIZE) next = 0; } void entropy_add_block(const uchar *s, int len) { for( ; len > 0; s += 128, len -= 128) { int bl = min(len, 128); xor_block(entpool + rnd(ENTPOOLSIZE / 8 - 16) * 8, s, bl); // use pseudorandom to mix entropy into the pool in a hard to predict fashion mix_block(entpool + rnd(ENTPOOLSIZE - bl), s, bl); } } void entropy_get(uchar *buf, int len) { ASSERT(len <= ENTPOOLSIZE); uchar *tempbuf = new uchar[len + SHA512SIZE]; memcpy(tempbuf, entpool, len); memcpy(entpool + ENTPOOLSIZE, entpool, 128); sha512(tempbuf, entpool, ENTPOOLSIZE); loopi(len) sha512_compress((uint64_t*)(tempbuf + (i & ~7)), entpool + rnd(ENTPOOLSIZE / 8) * 8); memcpy(buf, tempbuf, len); delete[] tempbuf; } #ifndef STANDALONE /////////////////////////////////////////////// key derivation function //////////////////////////////////////////////////////////////////////// // * basically a hash function that delivers keylen bytes calculated from pass and salt // * but uses a lot of memory and a quite complex algorithm, to make brute-force offline-attacks on short passwords as hard as possible (even if someone uses fpgas) // * last line of defense against "evil little brothers" void passphrase2key(const char *pass, const uchar *salt, int saltlen, uchar *key, int keylen, int *iterations, int maxtime, int memusage) { memset(key, 0, keylen); if(!*pass) return; // password "" -> memusage = clamp(memusage, 2, 1024); // keep memory usage between 2MB and 1GB int memsize = (1<<20) * memusage, passlen = strlen(pass), tmpbuflen = 2 * SHA512SIZE, pplen = 2 * (saltlen + passlen); // prepare the passphrase (including salt) uchar *pp = new uchar[pplen]; memcpy(pp, salt, saltlen); memcpy(pp + saltlen, pass, passlen); memcpy(pp + saltlen + passlen, pass, passlen); memcpy(pp + saltlen + 2 * passlen, salt, saltlen); if((memusage & 1) && passlen + saltlen >= 8) identhash((uint64_t *)(pp + saltlen + passlen)); // mix up the passphrase a bit uchar *tmpbuf = new uchar[tmpbuflen + sizeof(uint)]; memset(tmpbuf, 0, tmpbuflen + sizeof(uint)); sha512(tmpbuf, pp, pplen); xor_block(pp, tmpbuf, min(pplen, tmpbuflen)); sha512(tmpbuf + SHA512SIZE, pp, pplen); tiger::hash(pp, pplen, *((tiger::hashval *)tmpbuf)); // initialise the huge buffer uchar *hugebuf = new uchar[memsize]; memset(hugebuf, 0, memsize); int memchunk = memsize / tmpbuflen; loopi(tmpbuflen) seedMT_do(*((uint*)(tmpbuf + i)), (uint*)(hugebuf + memchunk * i), memchunk / sizeof(uint)); // spread the passphrase all over the huge buffer // start mixing #define mixit(x, y) (((((uint*)tmpbuf)[(roundsdone ^ (x)) % (tmpbuflen / sizeof(uint))]) % ((y) / 8 - (x) % 11)) * 8) stopwatch watch; watch.start(); int roundsdone = 0; uint shortseed = 0; do { loopirev(memsize / 127) shortseed = ((uint*)hugebuf)[shortseed % (memsize / sizeof(uint))]; seedMT_do(shortseed, (uint*)tmpbuf, tmpbuflen / sizeof(uint)); loopi(2999) sha512_compress((uint64_t*)(hugebuf + mixit(i * 5, memsize - SHA512SIZE)), hugebuf + mixit(i * 17, memsize - 128)); roundsdone++; } while((!*iterations && watch.elapsed() < maxtime) || (*iterations && *iterations > roundsdone)); // *iterations == 0: time-limited, otherwise rounds-limited // extract the key if(keylen * 8 > 192) sha512(tmpbuf, hugebuf, memsize); else tiger::hash(hugebuf, memsize, *((tiger::hashval *)tmpbuf)); loopi(SHA512SIZE) sha512_compress(((uint64_t*)tmpbuf) + (i / 8), hugebuf + (((tmpbuf[i] * 68111) % (memsize - 128)) & ~7)); memcpy(key, tmpbuf, min(keylen, tmpbuflen)); // max keylen is 2 * SHA512SIZE DEBUG("passphrase2key: " << watch.elapsed() << " ms, " << roundsdone << " rounds, " << memsize << " bytes used"); *iterations = roundsdone; delete[] hugebuf; delete[] tmpbuf; delete[] pp; #undef mixit } #endif /////////////////////////////////////////////// hex converters ///////////////////////////////////////////////////////////////////////////////////// const char *bin2hex(char *d, const uchar *s, int len) { // d needs to be at least of size 2 * len + 1 len *= 2; loopi(len) d[i] = hexdigits[(s[i / 2] >> ((i & 1) ? 0 : 4)) & 0xf]; d[len] = '\0'; return d; } int hex2bin(uchar *d, const char *s, int maxlen) { memset(d, 0, maxlen); int len; for(len = 0; s[len] && len < maxlen * 2; len++) { const char *hd = strchr(hexdigits, tolower(s[len])); if(!hd) break; // -> not a hex digit d[len / 2] |= (hd - hexdigits) << ((len & 1) ? 0 : 4); } return len / 2; } /////////////////////////////////////////////// Ed25519: high-speed high-security signatures ////////////////////////////////////////////////////// #include "crypto_tools.h" void ed25519_pubkey_from_private(uchar *pubkey, const uchar *privkey) { unsigned char az[64]; sc25519 scsk; ge25519 gepk; sha512(az, privkey, 32); az[0] &= 248; az[31] &= 127; az[31] |= 64; sc25519_from32bytes(&scsk,az); ge25519_scalarmult_base(&gepk, &scsk); ge25519_pack(pubkey, &gepk); } void privkey_from_prepriv(unsigned char *privkey, const unsigned char *prepriv, int preprivlen, unsigned char *privpriv = NULL) // derive private key from even more secret bulk of entropy { uchar temp[SHA512SIZE], pub[32], testpriv[32]; sha512(temp, prepriv, preprivlen); int esc, minesc = 32, minescpos = 0; loopi(33) { // find privte key with the public key with the least getint() escape codes (yes, that decreases the keyrange. sue me.) ed25519_pubkey_from_private(testpriv, temp + i); ed25519_pubkey_from_private(pub, testpriv); esc = 0; loopj(32) if((pub[j] & 0xfe) == 0x80) esc++; if(esc < minesc) { minesc = esc; minescpos = i; } if(esc == 0) break; } ed25519_pubkey_from_private(privkey, temp + minescpos); // (the resulting private key is actually itself a public key of a private derived from prepriv) if(privpriv) memcpy(privpriv, temp + minescpos, 32); } void ed25519_sign(uchar *sm, int *smlen, const uchar *m, int mlen, const uchar *sk) { // sk: 32-byte private key + 32-byte public key uchar pk[32], az[64], nonce[64], hram[64]; sc25519 sck, scs, scsk; ge25519 ger; memmove(pk, sk + 32, 32); // pk: 32-byte public key A sha512(az, sk, 32); az[0] &= 248; az[31] &= 127; az[31] |= 64; // az: 32-byte scalar a, 32-byte randomizer z if(smlen) *smlen = mlen + 64; memmove(sm + 64, m, mlen); // need memmove here: m and sm may overlap memmove(sm + 32, az + 32, 32); // sm: 32-byte uninit, 32-byte z, mlen-byte m sha512(nonce, sm + 32, mlen + 32); // nonce: 64-byte H(z,m) sc25519_from64bytes(&sck, nonce); ge25519_scalarmult_base(&ger, &sck); ge25519_pack(sm, &ger); // sm: 32-byte R, 32-byte z, mlen-byte m memmove(sm + 32, pk, 32); // sm: 32-byte R, 32-byte A, mlen-byte m sha512(hram, sm, mlen + 64); // hram: 64-byte H(R,A,m) sc25519_from64bytes(&scs, hram); sc25519_from32bytes(&scsk, az); sc25519_mul(&scs, &scs, &scsk); sc25519_add(&scs, &scs, &sck); // scs: S = nonce + H(R,A,m)a sc25519_to32bytes(sm + 32, &scs); // sm: 32-byte R, 32-byte S, mlen-byte m } uchar *ed25519_sign_check(uchar *sm, int smlen, const uchar *pk) { uchar scopy[32], hram[64], rcheck[32]; ge25519 get1, get2; sc25519 schram, scs; if(smlen < 64 || (sm[63] & 224) || ge25519_unpackneg_vartime(&get1, pk)) return NULL; // frame error memmove(scopy, sm + 32, 32); sc25519_from32bytes(&scs, sm + 32); memmove(sm + 32, pk, 32); sha512(hram, sm, smlen); sc25519_from64bytes(&schram, hram); ge25519_double_scalarmult_vartime(&get2, &get1, &schram, &ge25519_base, &scs); ge25519_pack(rcheck, &get2); memmove(sm + 32, scopy, 32); // restore sm return memcmp(rcheck, sm, 32) ? NULL : sm + 64; } #ifndef STANDALONE #ifdef _DEBUG void ed25519test(char *vectorfilename) // check ed25519 functions with test vectors from http://ed25519.cr.yp.to/python/sign.input { path(vectorfilename); stopwatch watch; int vectorfilesize = 0; char *vectorfile = loadfile(vectorfilename, &vectorfilesize); if(!vectorfile) { conoutf("could not read test vector file %s", vectorfilename); return; } conoutf("loaded %d bytes from %s", vectorfilesize, vectorfilename); watch.start(); int lines = 0, inputerrors = 0, pubfail = 0, signfail = 0, verifyfail = 0, verifyfail2 = 0; for(char *l = strtok(vectorfile, "\n"); l; l = strtok(NULL, "\n")) { // a line consists of 32 bytes private key, 32 byte public key, ":", 32 byte public key (again), ":", message, ":", signed message, ":" char *vprivpub = l, *vpub = strchr(l, ':'), *vmsg, *vsmsg, hextemp[65]; int linelen = strlen(l), msglen = 0; uchar privpub[64], pub[32], *msg = new uchar[linelen], *smsg = new uchar[linelen], temp[64]; lines++; if(!vpub || !(vmsg = strchr(vpub + 1, ':')) || !(vsmsg = strchr(vmsg + 1, ':')) || hex2bin(privpub, vprivpub, 64) != 64 || hex2bin(pub, ++vpub, 32) != 32 || (msglen = hex2bin(msg, ++vmsg, linelen)) < 0 || hex2bin(smsg, ++vsmsg, linelen) != (msglen + 64) || memcmp(msg, smsg + 64, msglen) || memcmp(privpub + 32, pub, 32)) { inputerrors++; continue; } // line does not match template ed25519_pubkey_from_private(temp, privpub); if(strncmp(bin2hex(hextemp, temp, 32), vpub, 64)) { pubfail++; continue; } // private and public key don't match ed25519_sign(msg, &linelen, msg, msglen, privpub); if(linelen != msglen + 64 || memcmp(msg, smsg, linelen)) { signfail++; continue; } // newly signed message doesn't match vector data if(!ed25519_sign_check(smsg, msglen + 64, pub)) { verifyfail++; continue; } // verification of signed message failed smsg[msglen % 64]++; if(ed25519_sign_check(smsg, msglen + 64, pub)) { verifyfail2++; continue; } // verification of altered signed message didn't fail (...but should've) smsg[msglen % 64]--; if(msglen) { smsg[42 % msglen]++; if(ed25519_sign_check(smsg, msglen + 64, pub)) { verifyfail2++; continue; } // verification of altered signed message didn't fail (...but should've) smsg[42 % msglen]--; } pub[msglen % 32]++; if(ed25519_sign_check(smsg, msglen + 64, pub)) { verifyfail2++; continue; } // verification of altered signed message didn't fail (...but should've) delete[] smsg; delete[] msg; } DELETEA(vectorfile); conoutf("processed %d lines in %d milliseconds", lines, watch.elapsed()); conoutf("%d vector file errors, %d private-pubkey mismatches, %d sign fails, %d verify fails, %d missed verify fails", inputerrors, pubfail, signfail, verifyfail, verifyfail2); } COMMAND(ed25519test, "s"); void ed25519speedtest() // check speed of ed25519 functions { uchar priv[32], pub[32], msg[64], smsg[128], sk[64]; entropy_get(priv, 32); entropy_get(msg, 32); stopwatch watch; watch.start(); loopi(200) ed25519_pubkey_from_private(pub, priv); conoutf("create public key from private key: %.2f ms", watch.elapsed() / 200.0f); memcpy(sk, priv, 32); memcpy(sk + 32, pub, 32); watch.start(); loopi(200) ed25519_sign(smsg, NULL, msg, 64, sk); conoutf("signing 64-byte message: %.2f ms", watch.elapsed() / 200.0f); watch.start(); loopi(200) ed25519_sign_check(smsg, 128, pub); conoutf("verify signature of 64-byte message: %.2f ms", watch.elapsed() / 200.0f); } COMMAND(ed25519speedtest, ""); #endif #endif #ifndef STANDALONE //////////////////////////////////// game key management //////////////////////////////////////////////////////////////////////// // * the game key is the primary player key that is associated with his player account // * it is used during playing to authenticate the player to the server // * needs special protection... #define AUTHPREPRIVATECFGFILE "config" PATHDIVS "authpreprivate.cfg" #define AUTHPRIVATECFGFILE "config" PATHDIVS "authprivate.cfg" VARP(authmemusage, 2, 24, (1<<10) - 1); // megabytes of RAM to use for password hash (when using a new password) VARP(authrounds, 0, 0, INT_MAX - 1); // create new password hashes with a fixed number of rounds (if authrounds > 0) VARP(authmaxtime, 1<<9, 1<<12, 1<<16); // create new password hashes with a fixed amount of time (in ms) static uchar *sk = NULL; // game key static struct { uchar *salt, *priv; uint pwdcfg; } passdargs; static int passdeferred(void *pass) // decrypt the private key in the background { uchar keyhash[32]; int iterations = passdargs.pwdcfg >> 10; passphrase2key((char*)pass, passdargs.salt, 16, keyhash, 32, &iterations, 0, passdargs.pwdcfg & 0x3ff); xor_block(passdargs.priv, keyhash, 32); delstring((char *)pass); extern void authsetup(char **args, int numargs); authsetup(NULL, -1); // tell authsetup, that the passwd is done return 0; } void authsetup(char **args, int numargs) // set up private and public keys { const int preprivminlen = 32, preprivmaxlen = 128; static uchar *buf = NULL, pub[32], keyhash[128], psalt[16], salt[16], preprivlen = 0; static uint preprivpwdcfg = 0, privpwdcfg = 0; static void *passdrunning = NULL, *passdcleanup = NULL; static char *sleepcmd = NULL; if(!buf) entropy_get((buf = new uchar[1536]), 1536); uint32_t offs = 7337; loopi(16) fnv1a_add(offs, buf[i]); uchar *priv = buf + 24 + (offs & 0xfc), *prepriv = priv + 112 + ((offs >> 9) & 0xfc), res = 0; char hextemp[2 * preprivmaxlen + 1]; if(passdrunning) { if(numargs < 0) { // finish password decryption (background mode) privpwdcfg = 0; passdcleanup = passdrunning; passdrunning = NULL; if(sleepcmd) addsleep(0, sleepcmd); DELSTRING(sleepcmd); } else return; // ignore further "authsetup" commands while a password decryption is running in the background } else { if(numargs < 0) return; // should not happen else if(passdcleanup) { sl_waitthread(passdcleanup); passdcleanup = NULL; } } if(numargs > 0) { if(!strcasecmp(args[0], "PRE")) { // authsetup pre preprivhex [psalthex pwdcfg] preprivlen = numargs > 1 ? clamp(int(strlen(args[1])) / 2, preprivminlen, preprivmaxlen) : 32; if(numargs > 1) hex2bin(prepriv, args[1], preprivlen); if(numargs > 2) hex2bin(psalt, args[2], 16); preprivpwdcfg = numargs > 3 ? atoi(args[3]) : 0; } else if(!strcasecmp(args[0], "PRIV")) { // authsetup priv privhex [salthex pwdcfg] if(numargs > 1) hex2bin(priv, args[1], 32); if(numargs > 2) hex2bin(salt, args[2], 16); privpwdcfg = numargs > 3 ? atoi(args[3]) : 0; sk = NULL; } else if(!strcasecmp(args[0], "PUB")) { // authsetup pub pubhex if(numargs > 1) hex2bin(pub, args[1], 32); sk = NULL; } else if(!strcasecmp(args[0], "PPASS")) { // authsetup ppass preprivpass int iterations = preprivpwdcfg >> 10; if(iterations) passphrase2key(numargs > 1 ? args[1] : "", psalt, 16, keyhash, preprivlen, &iterations, 0, preprivpwdcfg & 0x3fe); xor_block(prepriv, keyhash, preprivlen); preprivpwdcfg = 0; } else if(!strcasecmp(args[0], "PASS")) { // authsetup pass privpass int iterations = privpwdcfg >> 10; if(iterations) passphrase2key(numargs > 1 ? args[1] : "", salt, 16, keyhash, 32, &iterations, 0, privpwdcfg & 0x3ff); xor_block(priv, keyhash, 32); privpwdcfg = 0; } else if(!strcasecmp(args[0], "PASSD")) { // authsetup passd privpass [commandwhendone] if(!passdrunning && privpwdcfg) { passdargs.salt = salt; passdargs.priv = priv; passdargs.pwdcfg = privpwdcfg; passdrunning = sl_createthread(passdeferred, newstring(numargs > 1 ? args[1] : "")); sleepcmd = numargs > 2 ? newstring(args[2]) : NULL; } } else if(!strcasecmp(args[0], "NEEDPASS")) { // authsetup needpass if(privpwdcfg) res = 1; } else if(!strcasecmp(args[0], "GENPRE")) { // authsetup genpre prelen preprivlen = clamp((numargs > 1) ? atoi(args[1]) : 42, preprivminlen, preprivmaxlen); entropy_get(prepriv, preprivlen); preprivpwdcfg = 0; } else if(!strcasecmp(args[0], "GENPRIV")) { // authsetup genpriv if(!preprivpwdcfg) privkey_from_prepriv(priv, prepriv, preprivlen); privpwdcfg = 0; } else if(!strcasecmp(args[0], "GENPUB")) { // authsetup genpub ed25519_pubkey_from_private(pub, priv); privpwdcfg = 0; } else if(!strcasecmp(args[0], "NEWPPASS")) { // authsetup newppass preprivpass [preprivfilename] if(preprivlen && !preprivpwdcfg) { if(numargs > 1 && args[1][0]) // new password { entropy_get(psalt, 16); int iterations = authrounds; passphrase2key(args[1], psalt, 16, keyhash, preprivlen, &iterations, authmaxtime, authmemusage & 0x3fe); preprivpwdcfg = (iterations << 10) | authmemusage; xor_block(prepriv, keyhash, preprivlen); } const char *fn = numargs > 2 && args[2][0] ? path(args[2]) : AUTHPREPRIVATECFGFILE; char *oldfile = loadfile(fn, NULL); stream *f = openfile(fn, "wb"); if(f) { f->printf("\n" "// remove this file from your computer immediately!\n" "// either print it out and delete it or move it to a thumbdrive.\n" "// YOU DO NOT NEED THIS FILE TO PLAY AC!\n" "\n"); if(oldfile) for(char *l = strtok(oldfile, "\n\r"); l; l = strtok(NULL, "\n\r")) if(*l) f->printf("// %s\n", l); f->printf("authsetup pre %s", bin2hex(hextemp, prepriv, preprivlen)); if(preprivpwdcfg) f->printf(" %s %u", bin2hex(hextemp, psalt, 16), preprivpwdcfg & ~1); f->printf("\n\n"); delete f; } DELETEA(oldfile); } } else if(!strcasecmp(args[0], "NEWPASS")) { // authsetup newpass privpass [privatefilename] if(!privpwdcfg) { ed25519_pubkey_from_private(keyhash + 32, priv); if(numargs > 1 && args[1][0]) // new password { entropy_get(salt, 16); int iterations = authrounds; passphrase2key(args[1], salt, 16, keyhash, 32, &iterations, authmaxtime, authmemusage); privpwdcfg = (iterations << 10) | authmemusage; xor_block(priv, keyhash, 32); } const char *fn = numargs > 2 && args[2][0] ? path(args[2]) : AUTHPRIVATECFGFILE; char *oldfile = loadfile(fn, NULL); stream *f = openfile(fn, "wb"); if(f) { if(oldfile) for(char *l = strtok(oldfile, "\n\r"); l; l = strtok(NULL, "\n\r")) if(*l) f->printf("// %s\n", l); f->printf("\nauthsetup priv %s", bin2hex(hextemp, priv, 32)); if(privpwdcfg) f->printf(" %s %u", bin2hex(hextemp, salt, 16), privpwdcfg); f->printf("\nauthsetup pub %s\n\n", bin2hex(hextemp, keyhash + 32, 32)); delete f; } DELETEA(oldfile); } } else if(!strcasecmp(args[0], "UNARMED")) // FIXME: this is for testing purposes only - to test simultaneous logins from the same account - delete before release! { // authsetup unarmed // pub aa55aab6d746c2000f3f6dc133c49c5d0485e0e44cbf036757e7945bca20106f priv aa55aa55aa55aa55aa55aa55aa55aae5a973aa55aa55aa55aa55aa55aa55aa55 hex2bin(priv, "aa55aa55aa55aa55aa55aa55aa55aae5a973aa55aa55aa55aa55aa55aa55aa55", 32); ed25519_pubkey_from_private(pub, priv); privpwdcfg = 0; } } ed25519_pubkey_from_private(keyhash, priv); if(!privpwdcfg && !memcmp(pub, keyhash, 32)) { // priv matches pub: yay memcpy(priv + 32, pub, 32); sk = priv; if(!numargs) res = 1; // "authsetup" with no arguments just checks the status DEBUG("successfully found keypair for pub " << bin2hex(hextemp, pub, 32)); } else sk = NULL; intret(res); } COMMAND(authsetup, "v"); void mypubkey() { string res = ""; if(sk) bin2hex(res, sk + 32, 32); result(res); } COMMAND(mypubkey, ""); ///////////////////////////////////////////////// misc key management ////////////////////////////////////////////////////// // * used to sign certs or other stuff // * dev/admin/master keys // * clanboss keys // #define AUTHKEYSCFGFILE "config" PATHDIVS "authkeys.cfg" vector authkeys; authkey::authkey(const char *aname, const char *privkey) : name(NULL) { if(*aname && strlen(privkey) == 64 && hex2bin(sk, privkey, 32) == 32) { ed25519_pubkey_from_private(sk + 32, sk); name = newstring(aname); } } bool delauthkey(const char *name) { int before = authkeys.length(); loopvrev(authkeys) if(!strcmp(authkeys[i]->name, name)) delete authkeys.remove(i); return authkeys.length() < before; } const uchar *getauthkey(const char *name) { loopvrev(authkeys) if(!strcmp(authkeys[i]->name, name)) return authkeys[i]->sk; return NULL; } void authkey_(char **args, int numargs) // set up misc keys { if(numargs > 0) { string buf; if(!strcasecmp(args[0], "CLEAR")) { // authkey clear if(authkeys.length()) { char *oldfile = loadfile(AUTHKEYSCFGFILE, NULL); if(oldfile) { stream *f = openfile(AUTHKEYSCFGFILE, "wb"); if(f) { // don't really delete the old keys, just comment them out for(char *l = strtok(oldfile, "\n\r"); l; l = strtok(NULL, "\n\r")) if(*l) f->printf("// %s\n", l); delete f; } delete[] oldfile; } authkeys.shrink(0); conoutf("all authkeys deleted"); } } else if(!strcasecmp(args[0], "LIST")) { // authkey list if(authkeys.length()) { conoutf("name\tpubkey"); loopv(authkeys) conoutf("%s\t%s", authkeys[i]->name, bin2hex(buf, authkeys[i]->sk + 32, 32)); } else conoutf("no authkeys"); } else if(!strcasecmp(args[0], "DELETE")) { // authkey delete name if(numargs > 1) delauthkey(args[1]); } else if(!strcasecmp(args[0], "NEW")) { // authkey new name if(numargs > 1 && args[1][0]) { uchar prepriv[42], priv[32], pub[32]; delauthkey(args[1]); entropy_get(prepriv, 42); privkey_from_prepriv(priv, prepriv, 42); ed25519_pubkey_from_private(pub, priv); authkey *ak = new authkey(args[1], bin2hex(buf, priv, 32)); if(ak->name) { authkeys.add(ak); stream *f = openfile(AUTHKEYSCFGFILE, "ab"); if(f) { f->printf("// authkey \"%s\", generated %s\n", ak->name, timestring("%c")); f->printf("// prepriv %s\n", bin2hex(buf, prepriv, 42)); f->printf("// priv %s\n", bin2hex(buf, priv, 32)); f->printf("// pub %s\n", bin2hex(buf, pub, 32)); f->printf("authkey add %s %s\n\n", ak->name, bin2hex(buf, priv, 32)); delete f; } conoutf("authkey %s generated.", ak->name); } else { delete ak; } } } else if(!strcasecmp(args[0], "ADD")) { // authkey add name privkey if(numargs > 2) { delauthkey(args[1]); authkey *ak = new authkey(args[1], args[2]); if(ak->name) authkeys.add(ak); else delete ak; } } else if(!strcasecmp(args[0], "SELFCERT")) { // authkey selfcert name const uchar *sk; if(numargs > 1 && (sk = getauthkey(args[1]))) { defformatstring(cmd)("newcert start\n" "newcert line pubkey %s\n" "newcert line name \"%s\" \"%s\"\n" "newcert sign \"%s\" \"self-signed cert\"\n" "\n", bin2hex(buf, sk + 32, 32), args[1], numargs > 2 ? args[2] : "", args[1]); execute(cmd); } } } } COMMANDN(authkey,authkey_, "v"); #endif ///////////////////////// manage tree of certificates /////////////////////////////////////////////////// #define CERTFILEDIR "config" PATHDIVS "certs" PATHDIVS #define CERTFILEEXT "acc" #define CERTTIMEDAY (24 * 60) #define CERTTIMEMONTH (30 * 24 * 60) // FIXME: replace this for release // pub aa558eb043105536d72a433d8fa121797f134805c526727c43f57cefdaec289b priv aa55aa55aa55aa55aa55aa55aa55aac97034aa55aa55aa55aa55aa55aa55aa55 uchar rootcert[] = { 0xaa, 0x55, 0x8e, 0xb0, 0x43, 0x10, 0x55, 0x36, 0xd7, 0x2a, 0x43, 0x3d, 0x8f, 0xa1, 0x21, 0x79, 0x7f, 0x13, 0x48, 0x05, 0xc5, 0x26, 0x72, 0x7c, 0x43, 0xf5, 0x7c, 0xef, 0xda, 0xec, 0x28, 0x9b }; static const char *certheader = "AC-CERT v1 "; static const int certheaderlen = strlen(certheader), certheaderlenfull = certheaderlen + 128 + 1; static const char *certtypekeywords[] = { "misc", "dev", "master", "server", "player", "clanboss", "clan" }; // needs to match the enums! static int certtypemaxrank[] = { 0, 1, 2, 3, 3, 3, 0 }; // max allowed rank of some cert types static int certtypeexpiration[] = { 0, 0, 0, 2 * CERTTIMEMONTH, CERTTIMEMONTH, 3 * CERTTIMEMONTH, CERTTIMEMONTH }; // time after which certs are usually re-signed, after 3x the time they expire vector certs; hashtable certblacklist; static inline int aktcerttime() { return time(NULL) / (time_t) 60; } // use minutes instead of seconds as timebase, so int will be more than enough bool cert::parse() // parse orgmsg[] and check the signature { isvalid = ischecked = needsrenewal = expired = false; pubkey = signedby = NULL; name = NULL; type = CERT_MISC; DELETEA(workmsg); lines.setsize(0); if(orglen > certheaderlenfull && orglen < (1<<20) && !strncmp(orgmsg, certheader, certheaderlen) && orgmsg[certheaderlen + 128] == '\n') { // frame ok workmsg = new char[orglen + 1]; memcpy(workmsg, orgmsg, orglen + 1); uchar *signature = (uchar*) orgmsg + certheaderlenfull - 64; if(hex2bin(signature, workmsg + certheaderlen, 64) == 64) { // parse all lines certline line; for(char *l = strtok(workmsg + certheaderlenfull, "\n\r"); l; l = strtok(NULL, "\n\r")) { // get comment line.comment = strstr(l, "//"); if(line.comment) { *line.comment = '\0'; line.comment += 2 + strspn(line.comment + 2, " "); trimtrailingwhitespace(line.comment); } trimtrailingwhitespace(l); // get keyword and value, separated by ":" l += strspn(l, " \t"); line.val = strchr(l, ':'); if(line.val && line.val > l) { line.key = l; *line.val++ = '\0'; line.val += strspn(line.val, " \t"); trimtrailingwhitespace(line.key); trimtrailingwhitespace(line.val); if(!strcasecmp(line.key, "signed-by")) { // parse "signed-by" key directly if(!(strlen(line.val) == 64 && (signedby = (uchar*)line.val) && hex2bin(signedby, orgmsg + (line.val - workmsg), 32) == 32)) signedby = NULL; } else if(!strcasecmp(line.key, "signed-date")) { // parse "signed-date" key directly signeddate = atoi(line.val); } else if(!strcasecmp(line.key, "pubkey")) { // parse "pubkey" key directly if(!(strlen(line.val) == 64 && (pubkey = (uchar*)line.val) && hex2bin(pubkey, orgmsg + (line.val - workmsg), 32) == 32)) pubkey = NULL; } else if(!strcasecmp(line.key, "name")) { // parse "name" key directly name = line.val; } else { // add to list lines.add(line); if(!strcasecmp(line.key, "type")) type = getlistindex(line.val, certtypekeywords, false, 0); } } } if(signedby) { // check signature (if signature contained a "signed-by" line) if(ed25519_sign_check(signature, orglen - certheaderlenfull + 64, signedby)) { ischecked = true; if(certtypeexpiration[type]) { int age = aktcerttime() - signeddate; if(age > certtypeexpiration[type]) needsrenewal = true; if(age > 3 * certtypeexpiration[type]) expired = true; } isvalid = !expired; } } } memcpy(orgmsg, workmsg, certheaderlenfull); // restore original message if(ischecked && pubkey && !name) bin2hex((name = workmsg), pubkey, 32); // if cert has no name, use pubkey as name } return ischecked; } struct certline *cert::getline(const char *key) { loopv(lines) if(!strcasecmp(lines[i].key, key)) return &lines[i]; return NULL; } const char *cert::getval(const char *key) { loopv(lines) if(!strcasecmp(lines[i].key, key)) return lines[i].val; return NULL; } char *cert::getcertfilename(const char *subpath) { if(!orgfilename) return NULL; defformatstring(s)(CERTFILEDIR "%s%s%s." CERTFILEEXT, subpath ? subpath : "", subpath ? PATHDIVS : "", orgfilename); return newstring(s); } char *cert::getnewcertfilename(const char *subpath) { string fname; filtertext(fname, name ? name : "", FTXT__CERTFILENAME); defformatstring(s)(CERTFILEDIR "%s%s%s_%s_%d." CERTFILEEXT, subpath ? subpath : "", subpath ? PATHDIVS : "", certtypekeywords[type], fname, signeddate); return newstring(s); } void cert::movecertfile(const char *subpath) { char *ofn = getcertfilename(NULL), *nfn = getcertfilename(subpath); if(subpath && ofn && nfn) backup(ofn, nfn); DELSTRING(ofn); DELSTRING(nfn); } makecert::makecert(int bufsize) { curbuf = buf = new char[1 << bufsize]; endbuf = buf + (1 << bufsize) - 1; c = new cert(NULL); } makecert::~makecert() { DELETEP(c); DELETEA(buf); } void makecert::addline(const char *key, const char *val, const char *com) { if(!com || !*com) com = ""; int keylen = strlen(key), vallen = strlen(val), comlen = strlen(com); if(*key && *val && endbuf - curbuf > keylen + vallen + comlen + 3) { certline &l = c->lines.add(); l.key = curbuf; strcpy(curbuf, key); curbuf += keylen + 1; l.val = curbuf; strcpy(curbuf, val); curbuf += vallen + 1; l.comment = curbuf; strcpy(curbuf, com); curbuf += comlen + 1; // extract name and type for the filename if(!strcasecmp(l.key, "name")) c->name = l.val; else if(!strcasecmp(l.key, "type")) c->type = getlistindex(l.val, certtypekeywords, false, 0); } } char *makecert::sign(const uchar *keypair, const char *com) { char hextemp[129]; vector msg; cvecprintf(msg, "signed-by: %s%s%s\n", bin2hex(hextemp, keypair + 32, 32), com && *com ? " // " : "", com ? com : ""); loopv(c->lines) cvecprintf(msg, "%s: %s%s%s\n", c->lines[i].key, c->lines[i].val, c->lines[i].comment[0] ? " // " : "", c->lines[i].comment); cvecprintf(msg, "signed-date: %d // %s\n", (c->signeddate = aktcerttime()), timestring("%c")); int len = msg.length(); loopi(64) msg.add(0); // make room for the signature uchar *msgbuf = (uchar*)msg.getbuf(); ed25519_sign(msgbuf, NULL, msgbuf, len, keypair); char *signedmsg = new char[certheaderlenfull + len + 1]; sprintf(signedmsg, "%s%s\n", certheader, bin2hex(hextemp, msgbuf, 64)); // header line memcpy(signedmsg + certheaderlenfull, msgbuf + 64, len); // body signedmsg[certheaderlenfull + len] = '\0'; return signedmsg; } #ifndef STANDALONE COMMANDF(newcert, "v", (char **args, int numargs) // create and sign certs from cubescript { static makecert *mc = NULL; if(!mc) mc = new makecert(20); if(numargs > 0) { if(!strcasecmp(args[0], "CLEAR")) { DELETEP(mc); } else if(!strcasecmp(args[0], "LINE")) { // newcert line key val [comment] if(numargs > 2 && args[1][0] && args[2][0]) mc->addline(args[1], args[2], numargs > 3 ? args[3] : ""); } else if(!strcasecmp(args[0], "SIGN")) { // newcert sign privkey|authkeyname [comment] uchar keypair[64]; // 32byte private + 32byte public if(numargs > 1 && ((getauthkey(args[1]) && memcpy(keypair, getauthkey(args[1]), 32)) || (strlen(args[1]) == 64 && hex2bin(keypair, args[1], 32) == 32))) { // sign cert and write to file ed25519_pubkey_from_private(keypair + 32, keypair); char *msg = mc->sign(keypair, numargs > 2 ? args[2] : NULL); char *fname = mc->c->getnewcertfilename(NULL); stream *f = openfile(fname, "wb"); f->write(msg, strlen(msg)); delete f; DELETEP(mc); } } } }); #endif void marksuperseded(cert *chain) // checks all { for(cert *c = chain; c; c = c->next) { if(c->isvalid) for(cert *r = c->next; r; r = r->next) { if(r->isvalid && c->isvalid) { if((c->type == r->type && c->name && r->name && !strcmp(c->name, r->name)) || (c->pubkey && r->pubkey && !memcmp(c->pubkey, r->pubkey, 32))) { // same name and type or same pubkey cert *x = c->signeddate < r->signeddate ? c : r; // older one has to go x->superseded = true; x->isvalid = false; } } } } for(cert *c = chain; c; c = c->next) { // check, if certs lost their parent during the cleanup above if(c->isvalid && c->parent && (!c->parent->isvalid || !c->parent->rank)) c->rank = 0; } } void rebuildcerttree() // determines the rank of all certs; ages them; removes all kinds of illegal certs { int act = aktcerttime(); cert *treechain = NULL; // all nested list searches are done on a chain of relevant certs, to keep complexity from reaching n^2 loopv(certs) // 1st run: cleanup, age, check if signed by root { cert *c = certs[i]; c->parent = c->next = NULL; c->rank = !memcmp(rootcert, c->signedby, 32) ? 1 : 0; c->superseded = false; c->days2expire = c->days2renew = 365; if(certtypeexpiration[c->type]) // age the certs { int age = act - c->signeddate; c->days2renew = certtypeexpiration[c->type] - age; c->days2expire = 3 * certtypeexpiration[c->type] - age; if(c->days2renew < 0) c->needsrenewal = true; if(c->days2expire < 0) { c->expired = true; c->isvalid = false; } } if(c->pubkey && certblacklist.access(c->pubkey)) { c->blacklisted = true; c->isvalid = false; } if(c->isvalid && c->rank) { c->next = treechain; treechain = c; } } marksuperseded(treechain); loopk(200) { bool onemoreround = false; loopv(certs) // build tree, rank by rank { cert *c = certs[i]; if(c->isvalid && !c->rank) { for(cert *r = treechain; r; r = r->next) { if(r->rank && r->isvalid && r->pubkey && !memcmp(r->pubkey, c->signedby, 32)) { c->rank = r->rank + 1; if(c->rank > certtypemaxrank[c->type]) { // maxrank exceeded (no, you can not sign your own master cert...) c->isvalid = false; c->illegal = true; } else { // include cert into tree c->parent = r; c->next = treechain; treechain = c; if(c->pubkey) onemoreround = true; // more public keys in the tree -> need to check the remaining certs again } break; } } } } marksuperseded(treechain); if(!onemoreround) break; } // tree itself is now complete and valid - clean up the rest a bit treechain = NULL; loopv(certs) { cert *c = certs[i]; if(c->isvalid && !c->rank) { c->next = treechain; treechain = c; } } marksuperseded(treechain); // of the valid certs that are not in the tree: remove outdated ones, where newer versions exist loopv(certs) // move files of invalid certs to subdirectories { cert *c = certs[i]; if(!c->isvalid) { if(c->superseded) c->movecertfile("superseded"); else if(c->blacklisted) c->movecertfile("blacklisted"); else if(c->illegal) c->movecertfile("illegal"); else if(c->expired) {}// c->movecertfile("expired"); else c->movecertfile("invalid2"); } } } void loadcert(const char *fname) { cert *c = new cert(fname); if(c->ischecked && c->name) { certs.add(c); // certs in "certs" are required to have a name DEBUG("loaded cert " << c->name << ", type " << certtypekeywords[c->type] << ", signed-date " << c->signeddate); } else delete c; } void loadcertdir() // load all certs in "config/certs" { vector certfiles; listfiles(CERTFILEDIR, CERTFILEEXT, certfiles); loopv(certfiles) { loadcert(certfiles[i]); delstring(certfiles[i]); } rebuildcerttree(); } #ifndef STANDALONE void listcerts() { loopv(certs) { cert *c = certs[i]; conoutf("certs[%d]: %16s, t:%s, r:%d, l:%d, sd:%d, d2e:%d, d2r:%d, parent:%d%s%s%s%s%s%s%s", i, c->name, certtypekeywords[c->type], c->rank, c->lines.length(), c->signeddate, c->days2expire, c->days2renew, certs.find(c->parent), c->ischecked ? ", ischecked" : "", c->isvalid ? ", isvalid" : "", c->needsrenewal ? ", needsrenewal" : "", c->expired ? ", expired" : "", c->superseded ? ", superseded" : "", c->blacklisted ? ", blacklisted" : "", c->illegal ? ", illegal" : ""); } } COMMAND(listcerts, ""); #endif /////////////////// misc helper functions //////////////////////////////////////////////////////////////// static const char *hashchunktoa(tiger::chunk h) // portable solution instead of printf("%llx") { // use next protocol bump to switch to hashstring() above! static string buf; static int bufidx; bufidx = (bufidx + 1) & 0x3; char *s = buf + (bufidx * 33) + 33; *s-- = '\0'; while(h) { *s-- = "0123456789abcdef"[h & 0xf]; h >>= 4; } return s + 1; } const char *genpwdhash(const char *name, const char *pwd, int salt) { static string temp; formatstring(temp)("%s %d %s %s %d", pwd, salt, name, pwd, iabs(PROTOCOL_VERSION)); tiger::hashval hash; tiger::hash((uchar *)temp, (int)strlen(temp), hash); formatstring(temp)("%s %s %s", hashchunktoa(hash.chunks[0]), hashchunktoa(hash.chunks[1]), hashchunktoa(hash.chunks[2])); return temp; } assaultcube-1.2.0.2.1/source/src/crypto_tools.h000066400000000000000000000736241352165075300213470ustar00rootroot00000000000000// Ed25519: high-speed high-security signatures // Contributors (alphabetical order) // Daniel J. Bernstein, University of Illinois at Chicago // Niels Duif, Technische Universiteit Eindhoven // Tanja Lange, Technische Universiteit Eindhoven // Peter Schwabe, National Taiwan University // Bo-Yin Yang, Academia Sinica // The Ed25519 sources were taken from the crypto_sign/ed25519 subdirectory of the SUPERCOP benchmarking tool. // The Ed25519 software is in the public domain. // this file (crypto_tools.h) contains fe25519.c, fe25519.h, ge25519.c, ge25519.h, sc25519.c and sc25519.h. // ge25519_base.data is kept as a separate file and keypair.c, open.c and sign.c got merged into crypto.cpp. // sry for just throwing this all in here... // I'm cleaning this up later, I promise ;) /////////////////////////////////////////// fe25519.h //////////////////////////////////// typedef struct { uint32_t v[32]; } fe25519; void fe25519_freeze(fe25519 *r); void fe25519_unpack(fe25519 *r, const unsigned char x[32]); void fe25519_pack(unsigned char r[32], const fe25519 *x); int fe25519_iszero(const fe25519 *x); int fe25519_iseq_vartime(const fe25519 *x, const fe25519 *y); void fe25519_cmov(fe25519 *r, const fe25519 *x, unsigned char b); void fe25519_setone(fe25519 *r); void fe25519_setzero(fe25519 *r); void fe25519_neg(fe25519 *r, const fe25519 *x); unsigned char fe25519_getparity(const fe25519 *x); void fe25519_add(fe25519 *r, const fe25519 *x, const fe25519 *y); void fe25519_sub(fe25519 *r, const fe25519 *x, const fe25519 *y); void fe25519_mul(fe25519 *r, const fe25519 *x, const fe25519 *y); void fe25519_square(fe25519 *r, const fe25519 *x); void fe25519_invert(fe25519 *r, const fe25519 *x); void fe25519_pow2523(fe25519 *r, const fe25519 *x); /////////////////////////////////////////// fe25519.c //////////////////////////////////// static uint32_t equal(uint32_t a,uint32_t b) /* 16-bit inputs */ { uint32_t x = a ^ b; /* 0: yes; 1..65535: no */ x -= 1; /* 4294967295: yes; 0..65534: no */ x >>= 31; /* 1: yes; 0: no */ return x; } static uint32_t ge(uint32_t a,uint32_t b) /* 16-bit inputs */ { unsigned int x = a; x -= (unsigned int) b; /* 0..65535: yes; 4294901761..4294967295: no */ x >>= 31; /* 0: yes; 1: no */ x ^= 1; /* 1: yes; 0: no */ return x; } static uint32_t times19(uint32_t a) { return (a << 4) + (a << 1) + a; } static uint32_t times38(uint32_t a) { return (a << 5) + (a << 2) + (a << 1); } static void reduce_add_sub(fe25519 *r) { uint32_t t; int i,rep; for(rep=0;rep<4;rep++) { t = r->v[31] >> 7; r->v[31] &= 127; t = times19(t); r->v[0] += t; for(i=0;i<31;i++) { t = r->v[i] >> 8; r->v[i+1] += t; r->v[i] &= 255; } } } static void reduce_mul(fe25519 *r) { uint32_t t; int i,rep; for(rep=0;rep<2;rep++) { t = r->v[31] >> 7; r->v[31] &= 127; t = times19(t); r->v[0] += t; for(i=0;i<31;i++) { t = r->v[i] >> 8; r->v[i+1] += t; r->v[i] &= 255; } } } /* reduction modulo 2^255-19 */ void fe25519_freeze(fe25519 *r) { int i; uint32_t m = equal(r->v[31],127); for(i=30;i>0;i--) m &= equal(r->v[i],255); m &= ge(r->v[0],237); m = (uint32_t) -int(m); r->v[31] -= m&127; for(i=30;i>0;i--) r->v[i] -= m&255; r->v[0] -= m&237; } void fe25519_unpack(fe25519 *r, const unsigned char x[32]) { int i; for(i=0;i<32;i++) r->v[i] = x[i]; r->v[31] &= 127; } /* Assumes input x being reduced below 2^255 */ void fe25519_pack(unsigned char r[32], const fe25519 *x) { int i; fe25519 y = *x; fe25519_freeze(&y); for(i=0;i<32;i++) r[i] = y.v[i]; } int fe25519_iszero(const fe25519 *x) { int i; int r; fe25519 t = *x; fe25519_freeze(&t); r = equal(t.v[0],0); for(i=1;i<32;i++) r &= equal(t.v[i],0); return r; } int fe25519_iseq_vartime(const fe25519 *x, const fe25519 *y) { int i; fe25519 t1 = *x; fe25519 t2 = *y; fe25519_freeze(&t1); fe25519_freeze(&t2); for(i=0;i<32;i++) if(t1.v[i] != t2.v[i]) return 0; return 1; } void fe25519_cmov(fe25519 *r, const fe25519 *x, unsigned char b) { int i; uint32_t mask = b; mask = (uint32_t) -int(mask); for(i=0;i<32;i++) r->v[i] ^= mask & (x->v[i] ^ r->v[i]); } unsigned char fe25519_getparity(const fe25519 *x) { fe25519 t = *x; fe25519_freeze(&t); return t.v[0] & 1; } void fe25519_setone(fe25519 *r) { int i; r->v[0] = 1; for(i=1;i<32;i++) r->v[i]=0; } void fe25519_setzero(fe25519 *r) { int i; for(i=0;i<32;i++) r->v[i]=0; } void fe25519_neg(fe25519 *r, const fe25519 *x) { fe25519 t; int i; for(i=0;i<32;i++) t.v[i]=x->v[i]; fe25519_setzero(r); fe25519_sub(r, r, &t); } void fe25519_add(fe25519 *r, const fe25519 *x, const fe25519 *y) { int i; for(i=0;i<32;i++) r->v[i] = x->v[i] + y->v[i]; reduce_add_sub(r); } void fe25519_sub(fe25519 *r, const fe25519 *x, const fe25519 *y) { int i; uint32_t t[32]; t[0] = x->v[0] + 0x1da; t[31] = x->v[31] + 0xfe; for(i=1;i<31;i++) t[i] = x->v[i] + 0x1fe; for(i=0;i<32;i++) r->v[i] = t[i] - y->v[i]; reduce_add_sub(r); } void fe25519_mul(fe25519 *r, const fe25519 *x, const fe25519 *y) { int i,j; uint32_t t[63]; for(i=0;i<63;i++)t[i] = 0; for(i=0;i<32;i++) for(j=0;j<32;j++) t[i+j] += x->v[i] * y->v[j]; for(i=32;i<63;i++) r->v[i-32] = t[i-32] + times38(t[i]); r->v[31] = t[31]; /* result now in r[0]...r[31] */ reduce_mul(r); } void fe25519_square(fe25519 *r, const fe25519 *x) { fe25519_mul(r, x, x); } void fe25519_invert(fe25519 *r, const fe25519 *x) { fe25519 z2; fe25519 z9; fe25519 z11; fe25519 z2_5_0; fe25519 z2_10_0; fe25519 z2_20_0; fe25519 z2_50_0; fe25519 z2_100_0; fe25519 t0; fe25519 t1; int i; /* 2 */ fe25519_square(&z2,x); /* 4 */ fe25519_square(&t1,&z2); /* 8 */ fe25519_square(&t0,&t1); /* 9 */ fe25519_mul(&z9,&t0,x); /* 11 */ fe25519_mul(&z11,&z9,&z2); /* 22 */ fe25519_square(&t0,&z11); /* 2^5 - 2^0 = 31 */ fe25519_mul(&z2_5_0,&t0,&z9); /* 2^6 - 2^1 */ fe25519_square(&t0,&z2_5_0); /* 2^7 - 2^2 */ fe25519_square(&t1,&t0); /* 2^8 - 2^3 */ fe25519_square(&t0,&t1); /* 2^9 - 2^4 */ fe25519_square(&t1,&t0); /* 2^10 - 2^5 */ fe25519_square(&t0,&t1); /* 2^10 - 2^0 */ fe25519_mul(&z2_10_0,&t0,&z2_5_0); /* 2^11 - 2^1 */ fe25519_square(&t0,&z2_10_0); /* 2^12 - 2^2 */ fe25519_square(&t1,&t0); /* 2^20 - 2^10 */ for (i = 2;i < 10;i += 2) { fe25519_square(&t0,&t1); fe25519_square(&t1,&t0); } /* 2^20 - 2^0 */ fe25519_mul(&z2_20_0,&t1,&z2_10_0); /* 2^21 - 2^1 */ fe25519_square(&t0,&z2_20_0); /* 2^22 - 2^2 */ fe25519_square(&t1,&t0); /* 2^40 - 2^20 */ for (i = 2;i < 20;i += 2) { fe25519_square(&t0,&t1); fe25519_square(&t1,&t0); } /* 2^40 - 2^0 */ fe25519_mul(&t0,&t1,&z2_20_0); /* 2^41 - 2^1 */ fe25519_square(&t1,&t0); /* 2^42 - 2^2 */ fe25519_square(&t0,&t1); /* 2^50 - 2^10 */ for (i = 2;i < 10;i += 2) { fe25519_square(&t1,&t0); fe25519_square(&t0,&t1); } /* 2^50 - 2^0 */ fe25519_mul(&z2_50_0,&t0,&z2_10_0); /* 2^51 - 2^1 */ fe25519_square(&t0,&z2_50_0); /* 2^52 - 2^2 */ fe25519_square(&t1,&t0); /* 2^100 - 2^50 */ for (i = 2;i < 50;i += 2) { fe25519_square(&t0,&t1); fe25519_square(&t1,&t0); } /* 2^100 - 2^0 */ fe25519_mul(&z2_100_0,&t1,&z2_50_0); /* 2^101 - 2^1 */ fe25519_square(&t1,&z2_100_0); /* 2^102 - 2^2 */ fe25519_square(&t0,&t1); /* 2^200 - 2^100 */ for (i = 2;i < 100;i += 2) { fe25519_square(&t1,&t0); fe25519_square(&t0,&t1); } /* 2^200 - 2^0 */ fe25519_mul(&t1,&t0,&z2_100_0); /* 2^201 - 2^1 */ fe25519_square(&t0,&t1); /* 2^202 - 2^2 */ fe25519_square(&t1,&t0); /* 2^250 - 2^50 */ for (i = 2;i < 50;i += 2) { fe25519_square(&t0,&t1); fe25519_square(&t1,&t0); } /* 2^250 - 2^0 */ fe25519_mul(&t0,&t1,&z2_50_0); /* 2^251 - 2^1 */ fe25519_square(&t1,&t0); /* 2^252 - 2^2 */ fe25519_square(&t0,&t1); /* 2^253 - 2^3 */ fe25519_square(&t1,&t0); /* 2^254 - 2^4 */ fe25519_square(&t0,&t1); /* 2^255 - 2^5 */ fe25519_square(&t1,&t0); /* 2^255 - 21 */ fe25519_mul(r,&t1,&z11); } void fe25519_pow2523(fe25519 *r, const fe25519 *x) { fe25519 z2; fe25519 z9; fe25519 z11; fe25519 z2_5_0; fe25519 z2_10_0; fe25519 z2_20_0; fe25519 z2_50_0; fe25519 z2_100_0; fe25519 t; int i; /* 2 */ fe25519_square(&z2,x); /* 4 */ fe25519_square(&t,&z2); /* 8 */ fe25519_square(&t,&t); /* 9 */ fe25519_mul(&z9,&t,x); /* 11 */ fe25519_mul(&z11,&z9,&z2); /* 22 */ fe25519_square(&t,&z11); /* 2^5 - 2^0 = 31 */ fe25519_mul(&z2_5_0,&t,&z9); /* 2^6 - 2^1 */ fe25519_square(&t,&z2_5_0); /* 2^10 - 2^5 */ for (i = 1;i < 5;i++) { fe25519_square(&t,&t); } /* 2^10 - 2^0 */ fe25519_mul(&z2_10_0,&t,&z2_5_0); /* 2^11 - 2^1 */ fe25519_square(&t,&z2_10_0); /* 2^20 - 2^10 */ for (i = 1;i < 10;i++) { fe25519_square(&t,&t); } /* 2^20 - 2^0 */ fe25519_mul(&z2_20_0,&t,&z2_10_0); /* 2^21 - 2^1 */ fe25519_square(&t,&z2_20_0); /* 2^40 - 2^20 */ for (i = 1;i < 20;i++) { fe25519_square(&t,&t); } /* 2^40 - 2^0 */ fe25519_mul(&t,&t,&z2_20_0); /* 2^41 - 2^1 */ fe25519_square(&t,&t); /* 2^50 - 2^10 */ for (i = 1;i < 10;i++) { fe25519_square(&t,&t); } /* 2^50 - 2^0 */ fe25519_mul(&z2_50_0,&t,&z2_10_0); /* 2^51 - 2^1 */ fe25519_square(&t,&z2_50_0); /* 2^100 - 2^50 */ for (i = 1;i < 50;i++) { fe25519_square(&t,&t); } /* 2^100 - 2^0 */ fe25519_mul(&z2_100_0,&t,&z2_50_0); /* 2^101 - 2^1 */ fe25519_square(&t,&z2_100_0); /* 2^200 - 2^100 */ for (i = 1;i < 100;i++) { fe25519_square(&t,&t); } /* 2^200 - 2^0 */ fe25519_mul(&t,&t,&z2_100_0); /* 2^201 - 2^1 */ fe25519_square(&t,&t); /* 2^250 - 2^50 */ for (i = 1;i < 50;i++) { fe25519_square(&t,&t); } /* 2^250 - 2^0 */ fe25519_mul(&t,&t,&z2_50_0); /* 2^251 - 2^1 */ fe25519_square(&t,&t); /* 2^252 - 2^2 */ fe25519_square(&t,&t); /* 2^252 - 3 */ fe25519_mul(r,&t,x); } /////////////////////////////////////////// sc25519.h //////////////////////////////////// typedef struct { uint32_t v[32]; } sc25519; typedef struct { uint32_t v[16]; } shortsc25519; void sc25519_from32bytes(sc25519 *r, const unsigned char x[32]); void shortsc25519_from16bytes(shortsc25519 *r, const unsigned char x[16]); void sc25519_from64bytes(sc25519 *r, const unsigned char x[64]); void sc25519_from_shortsc(sc25519 *r, const shortsc25519 *x); void sc25519_to32bytes(unsigned char r[32], const sc25519 *x); int sc25519_iszero_vartime(const sc25519 *x); int sc25519_isshort_vartime(const sc25519 *x); int sc25519_lt_vartime(const sc25519 *x, const sc25519 *y); void sc25519_add(sc25519 *r, const sc25519 *x, const sc25519 *y); void sc25519_sub_nored(sc25519 *r, const sc25519 *x, const sc25519 *y); void sc25519_mul(sc25519 *r, const sc25519 *x, const sc25519 *y); void sc25519_mul_shortsc(sc25519 *r, const sc25519 *x, const shortsc25519 *y); /* Convert s into a representation of the form \sum_{i=0}^{84}r[i]2^3 * with r[i] in {-4,...,3} */ void sc25519_window3(signed char r[85], const sc25519 *s); /* Convert s into a representation of the form \sum_{i=0}^{50}r[i]2^5 * with r[i] in {-16,...,15} */ void sc25519_window5(signed char r[51], const sc25519 *s); void sc25519_2interleave2(unsigned char r[127], const sc25519 *s1, const sc25519 *s2); /////////////////////////////////////////// sc25519.c //////////////////////////////////// /*Arithmetic modulo the group order m = 2^252 + 27742317777372353535851937790883648493 = 7237005577332262213973186563042994240857116359379907606001950938285454250989 */ static const uint32_t m[32] = {0xED, 0xD3, 0xF5, 0x5C, 0x1A, 0x63, 0x12, 0x58, 0xD6, 0x9C, 0xF7, 0xA2, 0xDE, 0xF9, 0xDE, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}; static const uint32_t mu[33] = {0x1B, 0x13, 0x2C, 0x0A, 0xA3, 0xE5, 0x9C, 0xED, 0xA7, 0x29, 0x63, 0x08, 0x5D, 0x21, 0x06, 0x21, 0xEB, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F}; static uint32_t lt(uint32_t a,uint32_t b) /* 16-bit inputs */ { unsigned int x = a; x -= (unsigned int) b; /* 0..65535: no; 4294901761..4294967295: yes */ x >>= 31; /* 0: no; 1: yes */ return x; } /* Reduce coefficients of r before calling reduce_add_sub */ static void reduce_add_sub(sc25519 *r) { uint32_t pb = 0; uint32_t b; uint32_t mask; int i; unsigned char t[32]; for(i=0;i<32;i++) { pb += m[i]; b = lt(r->v[i],pb); t[i] = r->v[i]-pb+(b<<8); pb = b; } mask = b - 1; for(i=0;i<32;i++) r->v[i] ^= mask & (r->v[i] ^ t[i]); } /* Reduce coefficients of x before calling barrett_reduce */ static void barrett_reduce(sc25519 *r, const uint32_t x[64]) { /* See HAC, Alg. 14.42 */ int i,j; uint32_t q2[66]; uint32_t *q3 = q2 + 33; uint32_t r1[33]; uint32_t r2[33]; uint32_t carry; uint32_t pb = 0; uint32_t b; for (i = 0;i < 66;++i) q2[i] = 0; for (i = 0;i < 33;++i) r2[i] = 0; for(i=0;i<33;i++) for(j=0;j<33;j++) if(i+j >= 31) q2[i+j] += mu[i]*x[j+31]; carry = q2[31] >> 8; q2[32] += carry; carry = q2[32] >> 8; q2[33] += carry; for(i=0;i<33;i++)r1[i] = x[i]; for(i=0;i<32;i++) for(j=0;j<33;j++) if(i+j < 33) r2[i+j] += m[i]*q3[j]; for(i=0;i<32;i++) { carry = r2[i] >> 8; r2[i+1] += carry; r2[i] &= 0xff; } for(i=0;i<32;i++) { pb += r2[i]; b = lt(r1[i],pb); r->v[i] = r1[i]-pb+(b<<8); pb = b; } /* XXX: Can it really happen that r<0?, See HAC, Alg 14.42, Step 3 * If so: Handle it here! */ reduce_add_sub(r); reduce_add_sub(r); } void sc25519_from32bytes(sc25519 *r, const unsigned char x[32]) { int i; uint32_t t[64]; for(i=0;i<32;i++) t[i] = x[i]; for(i=32;i<64;++i) t[i] = 0; barrett_reduce(r, t); } void shortsc25519_from16bytes(shortsc25519 *r, const unsigned char x[16]) { int i; for(i=0;i<16;i++) r->v[i] = x[i]; } void sc25519_from64bytes(sc25519 *r, const unsigned char x[64]) { int i; uint32_t t[64]; for(i=0;i<64;i++) t[i] = x[i]; barrett_reduce(r, t); } void sc25519_from_shortsc(sc25519 *r, const shortsc25519 *x) { int i; for(i=0;i<16;i++) r->v[i] = x->v[i]; for(i=0;i<16;i++) r->v[16+i] = 0; } void sc25519_to32bytes(unsigned char r[32], const sc25519 *x) { int i; for(i=0;i<32;i++) r[i] = x->v[i]; } int sc25519_iszero_vartime(const sc25519 *x) { int i; for(i=0;i<32;i++) if(x->v[i] != 0) return 0; return 1; } int sc25519_isshort_vartime(const sc25519 *x) { int i; for(i=31;i>15;i--) if(x->v[i] != 0) return 0; return 1; } int sc25519_lt_vartime(const sc25519 *x, const sc25519 *y) { int i; for(i=31;i>=0;i--) { if(x->v[i] < y->v[i]) return 1; if(x->v[i] > y->v[i]) return 0; } return 0; } void sc25519_add(sc25519 *r, const sc25519 *x, const sc25519 *y) { int i, carry; for(i=0;i<32;i++) r->v[i] = x->v[i] + y->v[i]; for(i=0;i<31;i++) { carry = r->v[i] >> 8; r->v[i+1] += carry; r->v[i] &= 0xff; } reduce_add_sub(r); } void sc25519_sub_nored(sc25519 *r, const sc25519 *x, const sc25519 *y) { uint32_t b = 0; uint32_t t; int i; for(i=0;i<32;i++) { t = x->v[i] - y->v[i] - b; r->v[i] = t & 255; b = (t >> 8) & 1; } } void sc25519_mul(sc25519 *r, const sc25519 *x, const sc25519 *y) { int i,j,carry; uint32_t t[64]; for(i=0;i<64;i++)t[i] = 0; for(i=0;i<32;i++) for(j=0;j<32;j++) t[i+j] += x->v[i] * y->v[j]; /* Reduce coefficients */ for(i=0;i<63;i++) { carry = t[i] >> 8; t[i+1] += carry; t[i] &= 0xff; } barrett_reduce(r, t); } void sc25519_mul_shortsc(sc25519 *r, const sc25519 *x, const shortsc25519 *y) { sc25519 t; sc25519_from_shortsc(&t, y); sc25519_mul(r, x, &t); } void sc25519_window3(signed char r[85], const sc25519 *s) { char carry; int i; for(i=0;i<10;i++) { r[8*i+0] = s->v[3*i+0] & 7; r[8*i+1] = (s->v[3*i+0] >> 3) & 7; r[8*i+2] = (s->v[3*i+0] >> 6) & 7; r[8*i+2] ^= (s->v[3*i+1] << 2) & 7; r[8*i+3] = (s->v[3*i+1] >> 1) & 7; r[8*i+4] = (s->v[3*i+1] >> 4) & 7; r[8*i+5] = (s->v[3*i+1] >> 7) & 7; r[8*i+5] ^= (s->v[3*i+2] << 1) & 7; r[8*i+6] = (s->v[3*i+2] >> 2) & 7; r[8*i+7] = (s->v[3*i+2] >> 5) & 7; } r[8*i+0] = s->v[3*i+0] & 7; r[8*i+1] = (s->v[3*i+0] >> 3) & 7; r[8*i+2] = (s->v[3*i+0] >> 6) & 7; r[8*i+2] ^= (s->v[3*i+1] << 2) & 7; r[8*i+3] = (s->v[3*i+1] >> 1) & 7; r[8*i+4] = (s->v[3*i+1] >> 4) & 7; /* Making it signed */ carry = 0; for(i=0;i<84;i++) { r[i] += carry; r[i+1] += r[i] >> 3; r[i] &= 7; carry = r[i] >> 2; r[i] -= carry<<3; } r[84] += carry; } void sc25519_window5(signed char r[51], const sc25519 *s) { char carry; int i; for(i=0;i<6;i++) { r[8*i+0] = s->v[5*i+0] & 31; r[8*i+1] = (s->v[5*i+0] >> 5) & 31; r[8*i+1] ^= (s->v[5*i+1] << 3) & 31; r[8*i+2] = (s->v[5*i+1] >> 2) & 31; r[8*i+3] = (s->v[5*i+1] >> 7) & 31; r[8*i+3] ^= (s->v[5*i+2] << 1) & 31; r[8*i+4] = (s->v[5*i+2] >> 4) & 31; r[8*i+4] ^= (s->v[5*i+3] << 4) & 31; r[8*i+5] = (s->v[5*i+3] >> 1) & 31; r[8*i+6] = (s->v[5*i+3] >> 6) & 31; r[8*i+6] ^= (s->v[5*i+4] << 2) & 31; r[8*i+7] = (s->v[5*i+4] >> 3) & 31; } r[8*i+0] = s->v[5*i+0] & 31; r[8*i+1] = (s->v[5*i+0] >> 5) & 31; r[8*i+1] ^= (s->v[5*i+1] << 3) & 31; r[8*i+2] = (s->v[5*i+1] >> 2) & 31; /* Making it signed */ carry = 0; for(i=0;i<50;i++) { r[i] += carry; r[i+1] += r[i] >> 5; r[i] &= 31; carry = r[i] >> 4; r[i] -= carry<<5; } r[50] += carry; } void sc25519_2interleave2(unsigned char r[127], const sc25519 *s1, const sc25519 *s2) { int i; for(i=0;i<31;i++) { r[4*i] = ( s1->v[i] & 3) ^ (( s2->v[i] & 3) << 2); r[4*i+1] = ((s1->v[i] >> 2) & 3) ^ (((s2->v[i] >> 2) & 3) << 2); r[4*i+2] = ((s1->v[i] >> 4) & 3) ^ (((s2->v[i] >> 4) & 3) << 2); r[4*i+3] = ((s1->v[i] >> 6) & 3) ^ (((s2->v[i] >> 6) & 3) << 2); } r[124] = ( s1->v[31] & 3) ^ (( s2->v[31] & 3) << 2); r[125] = ((s1->v[31] >> 2) & 3) ^ (((s2->v[31] >> 2) & 3) << 2); r[126] = ((s1->v[31] >> 4) & 3) ^ (((s2->v[31] >> 4) & 3) << 2); } /////////////////////////////////////////// ge25519.h //////////////////////////////////// typedef struct { fe25519 x; fe25519 y; fe25519 z; fe25519 t; } ge25519; //const ge25519 ge25519_base; int ge25519_unpackneg_vartime(ge25519 *r, const unsigned char p[32]); void ge25519_pack(unsigned char r[32], const ge25519 *p); int ge25519_isneutral_vartime(const ge25519 *p); void ge25519_double_scalarmult_vartime(ge25519 *r, const ge25519 *p1, const sc25519 *s1, const ge25519 *p2, const sc25519 *s2); void ge25519_scalarmult_base(ge25519 *r, const sc25519 *s); /////////////////////////////////////////// ge25519.c //////////////////////////////////// /* * Arithmetic on the twisted Edwards curve -x^2 + y^2 = 1 + dx^2y^2 * with d = -(121665/121666) = 37095705934669439343138083508754565189542113879843219016388785533085940283555 * Base point: (15112221349535400772501151409588531511454012693041857206046113283949847762202,46316835694926478169428394003475163141307993866256225615783033603165251855960); */ /* d */ static const fe25519 ge25519_ecd = {{0xA3, 0x78, 0x59, 0x13, 0xCA, 0x4D, 0xEB, 0x75, 0xAB, 0xD8, 0x41, 0x41, 0x4D, 0x0A, 0x70, 0x00, 0x98, 0xE8, 0x79, 0x77, 0x79, 0x40, 0xC7, 0x8C, 0x73, 0xFE, 0x6F, 0x2B, 0xEE, 0x6C, 0x03, 0x52}}; /* 2*d */ static const fe25519 ge25519_ec2d = {{0x59, 0xF1, 0xB2, 0x26, 0x94, 0x9B, 0xD6, 0xEB, 0x56, 0xB1, 0x83, 0x82, 0x9A, 0x14, 0xE0, 0x00, 0x30, 0xD1, 0xF3, 0xEE, 0xF2, 0x80, 0x8E, 0x19, 0xE7, 0xFC, 0xDF, 0x56, 0xDC, 0xD9, 0x06, 0x24}}; /* sqrt(-1) */ static const fe25519 ge25519_sqrtm1 = {{0xB0, 0xA0, 0x0E, 0x4A, 0x27, 0x1B, 0xEE, 0xC4, 0x78, 0xE4, 0x2F, 0xAD, 0x06, 0x18, 0x43, 0x2F, 0xA7, 0xD7, 0xFB, 0x3D, 0x99, 0x00, 0x4D, 0x2B, 0x0B, 0xDF, 0xC1, 0x4F, 0x80, 0x24, 0x83, 0x2B}}; #define ge25519_p3 ge25519 typedef struct { fe25519 x; fe25519 z; fe25519 y; fe25519 t; } ge25519_p1p1; typedef struct { fe25519 x; fe25519 y; fe25519 z; } ge25519_p2; typedef struct { fe25519 x; fe25519 y; } ge25519_aff; /* Packed coordinates of the base point */ const ge25519 ge25519_base = {{{0x1A, 0xD5, 0x25, 0x8F, 0x60, 0x2D, 0x56, 0xC9, 0xB2, 0xA7, 0x25, 0x95, 0x60, 0xC7, 0x2C, 0x69, 0x5C, 0xDC, 0xD6, 0xFD, 0x31, 0xE2, 0xA4, 0xC0, 0xFE, 0x53, 0x6E, 0xCD, 0xD3, 0x36, 0x69, 0x21}}, {{0x58, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0xA3, 0xDD, 0xB7, 0xA5, 0xB3, 0x8A, 0xDE, 0x6D, 0xF5, 0x52, 0x51, 0x77, 0x80, 0x9F, 0xF0, 0x20, 0x7D, 0xE3, 0xAB, 0x64, 0x8E, 0x4E, 0xEA, 0x66, 0x65, 0x76, 0x8B, 0xD7, 0x0F, 0x5F, 0x87, 0x67}}}; /* Multiples of the base point in affine representation */ static const ge25519_aff ge25519_base_multiples_affine[425] = { #include "ge25519_base.data" }; #ifndef AC_NOALIASING static void p1p1_to_p2_(ge25519_p3 *r, const ge25519_p1p1 *p) // to avoid errors because of aliasing { fe25519_mul(&r->x, &p->x, &p->t); fe25519_mul(&r->y, &p->y, &p->z); fe25519_mul(&r->z, &p->z, &p->t); } #else static void p1p1_to_p2(ge25519_p2 *r, const ge25519_p1p1 *p) { fe25519_mul(&r->x, &p->x, &p->t); fe25519_mul(&r->y, &p->y, &p->z); fe25519_mul(&r->z, &p->z, &p->t); } #endif static void p1p1_to_p3(ge25519_p3 *r, const ge25519_p1p1 *p) { #ifndef AC_NOALIASING p1p1_to_p2_(r, p); #else p1p1_to_p2((ge25519_p2 *)r, p); #endif fe25519_mul(&r->t, &p->x, &p->y); } static void ge25519_mixadd2(ge25519_p3 *r, const ge25519_aff *q) { fe25519 a,b,t1,t2,c,d,e,f,g,h,qt; fe25519_mul(&qt, &q->x, &q->y); fe25519_sub(&a, &r->y, &r->x); /* A = (Y1-X1)*(Y2-X2) */ fe25519_add(&b, &r->y, &r->x); /* B = (Y1+X1)*(Y2+X2) */ fe25519_sub(&t1, &q->y, &q->x); fe25519_add(&t2, &q->y, &q->x); fe25519_mul(&a, &a, &t1); fe25519_mul(&b, &b, &t2); fe25519_sub(&e, &b, &a); /* E = B-A */ fe25519_add(&h, &b, &a); /* H = B+A */ fe25519_mul(&c, &r->t, &qt); /* C = T1*k*T2 */ fe25519_mul(&c, &c, &ge25519_ec2d); fe25519_add(&d, &r->z, &r->z); /* D = Z1*2 */ fe25519_sub(&f, &d, &c); /* F = D-C */ fe25519_add(&g, &d, &c); /* G = D+C */ fe25519_mul(&r->x, &e, &f); fe25519_mul(&r->y, &h, &g); fe25519_mul(&r->z, &g, &f); fe25519_mul(&r->t, &e, &h); } static void add_p1p1(ge25519_p1p1 *r, const ge25519_p3 *p, const ge25519_p3 *q) { fe25519 a, b, c, d, t; fe25519_sub(&a, &p->y, &p->x); /* A = (Y1-X1)*(Y2-X2) */ fe25519_sub(&t, &q->y, &q->x); fe25519_mul(&a, &a, &t); fe25519_add(&b, &p->x, &p->y); /* B = (Y1+X1)*(Y2+X2) */ fe25519_add(&t, &q->x, &q->y); fe25519_mul(&b, &b, &t); fe25519_mul(&c, &p->t, &q->t); /* C = T1*k*T2 */ fe25519_mul(&c, &c, &ge25519_ec2d); fe25519_mul(&d, &p->z, &q->z); /* D = Z1*2*Z2 */ fe25519_add(&d, &d, &d); fe25519_sub(&r->x, &b, &a); /* E = B-A */ fe25519_sub(&r->t, &d, &c); /* F = D-C */ fe25519_add(&r->z, &d, &c); /* G = D+C */ fe25519_add(&r->y, &b, &a); /* H = B+A */ } /* See http://www.hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html#doubling-dbl-2008-hwcd */ static void dbl_p1p1(ge25519_p1p1 *r, const ge25519_p2 *p) { fe25519 a,b,c,d; fe25519_square(&a, &p->x); fe25519_square(&b, &p->y); fe25519_square(&c, &p->z); fe25519_add(&c, &c, &c); fe25519_neg(&d, &a); fe25519_add(&r->x, &p->x, &p->y); fe25519_square(&r->x, &r->x); fe25519_sub(&r->x, &r->x, &a); fe25519_sub(&r->x, &r->x, &b); fe25519_add(&r->z, &d, &b); fe25519_sub(&r->t, &r->z, &c); fe25519_sub(&r->y, &d, &b); } /* Constant-time version of: if(b) r = p */ static void cmov_aff(ge25519_aff *r, const ge25519_aff *p, unsigned char b) { fe25519_cmov(&r->x, &p->x, b); fe25519_cmov(&r->y, &p->y, b); } static unsigned char equal(signed char b,signed char c) { unsigned char ub = b; unsigned char uc = c; unsigned char x = ub ^ uc; /* 0: yes; 1..255: no */ uint32_t y = x; /* 0: yes; 1..255: no */ y -= 1; /* 4294967295: yes; 0..254: no */ y >>= 31; /* 1: yes; 0: no */ return y; } static unsigned char negative(signed char b) { unsigned long long x = b; /* 18446744073709551361..18446744073709551615: yes; 0..255: no */ x >>= 63; /* 1: yes; 0: no */ return x; } static void choose_t(ge25519_aff *t, unsigned long long pos, signed char b) { /* constant time */ fe25519 v; *t = ge25519_base_multiples_affine[5*pos+0]; cmov_aff(t, &ge25519_base_multiples_affine[5*pos+1],equal(b,1) | equal(b,-1)); cmov_aff(t, &ge25519_base_multiples_affine[5*pos+2],equal(b,2) | equal(b,-2)); cmov_aff(t, &ge25519_base_multiples_affine[5*pos+3],equal(b,3) | equal(b,-3)); cmov_aff(t, &ge25519_base_multiples_affine[5*pos+4],equal(b,-4)); fe25519_neg(&v, &t->x); fe25519_cmov(&t->x, &v, negative(b)); } static void setneutral(ge25519 *r) { fe25519_setzero(&r->x); fe25519_setone(&r->y); fe25519_setone(&r->z); fe25519_setzero(&r->t); } /* ******************************************************************** * EXPORTED FUNCTIONS ******************************************************************** */ /* return 0 on success, -1 otherwise */ int ge25519_unpackneg_vartime(ge25519_p3 *r, const unsigned char p[32]) { unsigned char par; fe25519 t, chk, num, den, den2, den4, den6; fe25519_setone(&r->z); par = p[31] >> 7; fe25519_unpack(&r->y, p); fe25519_square(&num, &r->y); /* x = y^2 */ fe25519_mul(&den, &num, &ge25519_ecd); /* den = dy^2 */ fe25519_sub(&num, &num, &r->z); /* x = y^2-1 */ fe25519_add(&den, &r->z, &den); /* den = dy^2+1 */ /* Computation of sqrt(num/den) */ /* 1.: computation of num^((p-5)/8)*den^((7p-35)/8) = (num*den^7)^((p-5)/8) */ fe25519_square(&den2, &den); fe25519_square(&den4, &den2); fe25519_mul(&den6, &den4, &den2); fe25519_mul(&t, &den6, &num); fe25519_mul(&t, &t, &den); fe25519_pow2523(&t, &t); /* 2. computation of r->x = t * num * den^3 */ fe25519_mul(&t, &t, &num); fe25519_mul(&t, &t, &den); fe25519_mul(&t, &t, &den); fe25519_mul(&r->x, &t, &den); /* 3. Check whether sqrt computation gave correct result, multiply by sqrt(-1) if not: */ fe25519_square(&chk, &r->x); fe25519_mul(&chk, &chk, &den); if (!fe25519_iseq_vartime(&chk, &num)) fe25519_mul(&r->x, &r->x, &ge25519_sqrtm1); /* 4. Now we have one of the two square roots, except if input was not a square */ fe25519_square(&chk, &r->x); fe25519_mul(&chk, &chk, &den); if (!fe25519_iseq_vartime(&chk, &num)) return -1; /* 5. Choose the desired square root according to parity: */ if(fe25519_getparity(&r->x) != (1-par)) fe25519_neg(&r->x, &r->x); fe25519_mul(&r->t, &r->x, &r->y); return 0; } void ge25519_pack(unsigned char r[32], const ge25519_p3 *p) { fe25519 tx, ty, zi; fe25519_invert(&zi, &p->z); fe25519_mul(&tx, &p->x, &zi); fe25519_mul(&ty, &p->y, &zi); fe25519_pack(r, &ty); r[31] ^= fe25519_getparity(&tx) << 7; } int ge25519_isneutral_vartime(const ge25519_p3 *p) { int ret = 1; if(!fe25519_iszero(&p->x)) ret = 0; if(!fe25519_iseq_vartime(&p->y, &p->z)) ret = 0; return ret; } /* computes [s1]p1 + [s2]p2 */ void ge25519_double_scalarmult_vartime(ge25519_p3 *r, const ge25519_p3 *p1, const sc25519 *s1, const ge25519_p3 *p2, const sc25519 *s2) { ge25519_p1p1 tp1p1; ge25519_p3 pre[16]; unsigned char b[127]; int i; /* precomputation s2 s1 */ setneutral(pre); /* 00 00 */ pre[1] = *p1; /* 00 01 */ dbl_p1p1(&tp1p1,(ge25519_p2 *)p1); p1p1_to_p3( &pre[2], &tp1p1); /* 00 10 */ add_p1p1(&tp1p1,&pre[1], &pre[2]); p1p1_to_p3( &pre[3], &tp1p1); /* 00 11 */ pre[4] = *p2; /* 01 00 */ add_p1p1(&tp1p1,&pre[1], &pre[4]); p1p1_to_p3( &pre[5], &tp1p1); /* 01 01 */ add_p1p1(&tp1p1,&pre[2], &pre[4]); p1p1_to_p3( &pre[6], &tp1p1); /* 01 10 */ add_p1p1(&tp1p1,&pre[3], &pre[4]); p1p1_to_p3( &pre[7], &tp1p1); /* 01 11 */ dbl_p1p1(&tp1p1,(ge25519_p2 *)p2); p1p1_to_p3( &pre[8], &tp1p1); /* 10 00 */ add_p1p1(&tp1p1,&pre[1], &pre[8]); p1p1_to_p3( &pre[9], &tp1p1); /* 10 01 */ dbl_p1p1(&tp1p1,(ge25519_p2 *)&pre[5]); p1p1_to_p3(&pre[10], &tp1p1); /* 10 10 */ add_p1p1(&tp1p1,&pre[3], &pre[8]); p1p1_to_p3(&pre[11], &tp1p1); /* 10 11 */ add_p1p1(&tp1p1,&pre[4], &pre[8]); p1p1_to_p3(&pre[12], &tp1p1); /* 11 00 */ add_p1p1(&tp1p1,&pre[1],&pre[12]); p1p1_to_p3(&pre[13], &tp1p1); /* 11 01 */ add_p1p1(&tp1p1,&pre[2],&pre[12]); p1p1_to_p3(&pre[14], &tp1p1); /* 11 10 */ add_p1p1(&tp1p1,&pre[3],&pre[12]); p1p1_to_p3(&pre[15], &tp1p1); /* 11 11 */ sc25519_2interleave2(b,s1,s2); /* scalar multiplication */ *r = pre[b[126]]; for(i=125;i>=0;i--) { dbl_p1p1(&tp1p1, (ge25519_p2 *)r); #ifndef AC_NOALIASING p1p1_to_p2_(r, &tp1p1); #else p1p1_to_p2((ge25519_p2 *) r, &tp1p1); #endif dbl_p1p1(&tp1p1, (ge25519_p2 *)r); if(b[i]!=0) { p1p1_to_p3(r, &tp1p1); add_p1p1(&tp1p1, r, &pre[b[i]]); } #ifndef AC_NOALIASING if(i != 0) p1p1_to_p2_(r, &tp1p1); #else if(i != 0) p1p1_to_p2((ge25519_p2 *)r, &tp1p1); #endif else p1p1_to_p3(r, &tp1p1); } } void ge25519_scalarmult_base(ge25519_p3 *r, const sc25519 *s) { signed char b[85]; int i; ge25519_aff t; sc25519_window3(b,s); choose_t((ge25519_aff *)r, 0, b[0]); fe25519_setone(&r->z); fe25519_mul(&r->t, &r->x, &r->y); for(i=1;i<85;i++) { choose_t(&t, (unsigned long long) i, b[i]); ge25519_mixadd2(r, &t); } } /////////////////////////////////////////// misc //////////////////////////////////// #if 0 // we're not really vulnerable to timing attacks, so we can use memcmp() int crypto_verify_32(const unsigned char *x,const unsigned char *y) { unsigned int differentbits = 0; loopi(32) differentbits |= x[i] ^ y[i]; return differentbits; } #endif #undef ge25519_p3 assaultcube-1.2.0.2.1/source/src/cube.h000066400000000000000000000044671352165075300175240ustar00rootroot00000000000000#ifndef __CUBE_H__ #define __CUBE_H__ #include "platform.h" #include "tools.h" #include "geom.h" #include "model.h" #include "protocol.h" #include "sound.h" #include "weapon.h" #include "entity.h" #include "world.h" #include "command.h" #ifndef STANDALONE #include "varray.h" #include "vote.h" #include "console.h" enum { SDL_AC_BUTTON_WHEELLEFT = -7, SDL_AC_BUTTON_WHEELRIGHT = -6, SDL_AC_BUTTON_WHEELDOWN = -5, SDL_AC_BUTTON_WHEELUP = -4, SDL_AC_BUTTON_RIGHT = -3, SDL_AC_BUTTON_MIDDLE = -2, SDL_AC_BUTTON_LEFT = -1 }; #endif extern sqr *world, *wmip[]; // map data, the mips are sequential 2D arrays in memory extern header hdr; // current map header extern _mapconfigdata mapconfigdata; // current mapconfig extern int sfactor, ssize; // ssize = 2^sfactor extern int cubicsize, mipsize; // cubicsize = ssize^2 extern physent *camera1; // camera representing perspective of player, usually player1 extern playerent *player1; // special client ent that receives input and acts as camera extern vector players; // all the other clients (in multiplayer) extern vector bounceents; extern bool editmode; extern int unsavededits; extern vector ents; // map entities extern vec worldpos, camup, camright, camdir; // current target of the crosshair in the world extern int lastmillis, totalmillis, skipmillis; // last time extern int curtime; // current frame time extern int interm; extern int gamemode, nextmode; extern int gamespeed; extern int xtraverts; extern float fovy, aspect; extern int farplane; extern bool minimap, reflecting, refracting; extern int stenciling, stencilshadow, effective_stencilshadow; extern bool intermission; extern int arenaintermission; extern hashtable mapinfo; extern int hwtexsize, hwmaxaniso; extern int maploaded, msctrl; extern float waterlevel; #define AC_VERSION 1202 #define AC_MASTER_URI "ms.cubers.net" #define AC_MASTER_PORT 28760 #define MAXCL 16 #define CONFIGROTATEMAX 5 // keep 5 old versions of saved.cfg and init.cfg around #define DEFAULT_FOG 180 #define DEFAULT_FOGCOLOUR 0x8099B3 #define DEFAULT_SHADOWYAW 45 #include "protos.h" // external function decls #endif assaultcube-1.2.0.2.1/source/src/docs.cpp000066400000000000000000000561561352165075300200730ustar00rootroot00000000000000// docs.cpp: ingame command documentation system #include "cube.h" void renderdocsection(void *menu, bool init); extern hashtable *idents; struct docargument { char *token, *desc, *values; bool vararg; docargument() : token(NULL), desc(NULL), values(NULL) {}; ~docargument() { DELETEA(token); DELETEA(desc); DELETEA(values); } }; struct docexample { char *code, *explanation; docexample() : code(NULL), explanation(NULL) {} ~docexample() { DELETEA(code); DELETEA(explanation); } }; struct docident { char *name, *desc; vector arguments; vector remarks; vector references; vector examples; vector keylines; int a, b, c; char *label, *related; docident() : name(NULL), desc(NULL), label(NULL), related(NULL) {} ~docident() { DELETEA(name); DELETEA(desc); DELETEA(label); DELETEA(related); } }; struct docsection { char *name; vector sidents; void *menu; docsection() : name(NULL) {}; ~docsection() { DELETEA(name); } }; vector sections; hashtable docidents; // manage globally instead of a section tree to ensure uniqueness docsection *lastsection = NULL; docident *lastident = NULL; void adddocsection(char *name) { if(!name || !*name) { lastsection = NULL; return; } docsection &s = sections.add(); s.name = newstring(name); s.menu = addmenu(s.name, NULL, true, renderdocsection); lastsection = &s; } COMMANDN(docsection, adddocsection, "s"); void adddocident(char *name, char *desc) { if(!name || !desc || !lastsection || !*name) { lastident = NULL; return; } name = newstring(name); docident &c = docidents[name]; lastsection->sidents.add(&c); c.name = name; c.desc = newstring(desc); lastident = &c; DEBUGCODE(if(strlen(desc) > 111) clientlogf("docident: very long description for ident %s (%d)", name, (int)strlen(desc))); } COMMANDN(docident, adddocident, "ss"); void adddocargument(char *token, char *desc, char *values, char *vararg) { if(!lastident || !token || !desc) return; if(*token) loopv(lastident->arguments) if(!strcmp(token, lastident->arguments[i].token)) clientlogf("docargument: double token %s in reference %s", token, lastident->name); docargument &a = lastident->arguments.add(); a.token = newstring(token); a.desc = newstring(desc); a.values = values && strlen(values) ? newstring(values) : NULL; a.vararg = vararg && atoi(vararg) == 1 ? true : false; } COMMANDN(docargument, adddocargument, "ssss"); void adddocremark(char *remark) { if(!lastident || !remark || !*remark) return; lastident->remarks.add(newstring(remark)); } COMMANDN(docremark, adddocremark, "s"); void adddocref(char *refident) { if(!lastident || !refident || !*refident) return; #ifdef _DEBUG if(!strcasecmp(refident, lastident->name)) clientlogf("docref: circular reference for %s", refident); loopv(lastident->references) if(!strcasecmp(lastident->references[i], refident)) clientlogf("docref: double reference %s in %s", refident, lastident->name); #endif lastident->references.add(newstring(refident)); } COMMANDN(docref, adddocref, "s"); void adddocexample(char *code, char *explanation) { if(!lastident || !code) return; docexample &e = lastident->examples.add(); e.code = newstring(code); e.explanation = explanation && strlen(explanation) ? newstring(explanation) : NULL; } COMMANDN(docexample, adddocexample, "ss"); void adddockey(char *alias, char *name, char *desc) { if(!lastident || !alias) return; defformatstring(line)("~%-10s %s", *name ? name : alias, desc); lastident->keylines.add(newstring(line)); } COMMANDN(dockey, adddockey, "sss"); const char *docgetdesc(const char *name) { docident *id = docidents.access(name); return id ? id->desc : NULL; } char *cvecstr(vector &cvec, const char *substr, int *rline = NULL) { char *r = NULL; loopv(cvec) if(cvec[i]) if((r = strstr(cvec[i], substr)) != NULL) { if(rline) *rline = i; break; } return r; } void listundoneidents(vector &inames, int allidents) { enumeratekt(*idents, const char *, name, ident, id, { if((allidents > 0) || id.type != ID_ALIAS) { docident *id = docidents.access(name); if(id) // search for substrings that indicate undoneness { vector srch; srch.add(id->name); srch.add(id->desc); loopvj(id->remarks) srch.add(id->remarks[j]); loopvj(id->arguments) { srch.add(id->arguments[j].token); srch.add(id->arguments[j].desc); srch.add(id->arguments[j].values); } loopvj(id->references) srch.add(id->references[j]); if(cvecstr(srch, "TODO") || cvecstr(srch, "UNDONE")) id = NULL; } if(!id) inames.add(name); } }); inames.sort(stringsort); } void docundone(int *allidents) { vector inames; listundoneidents(inames, *allidents); inames.sort(stringsort); loopv(inames) conoutf("%s", inames[i]); } COMMAND(docundone, "i"); void docinvalid() { vector inames, irefs; enumerate(docidents, docident, d, if(!strchr(d.name, ' ') && !identexists(d.name)) inames.add(d.name);); inames.sort(stringsort); if(inames.length()) conoutf("no such ident:"); loopv(inames) conoutf(" %s", inames[i]); enumerate(docidents, docident, d, { loopv(d.references) if(!identexists(d.references[i])) { bool add = true; loopvj(inames) if(!strcasecmp(inames[j], d.references[i])) add = false; // don't list references to nonexisting but documented entries if(add) irefs.add(d.references[i]); } }); irefs.sort(stringsort); if(irefs.length()) conoutf("no such reference:"); loopv(irefs) conoutf(" %s", irefs[i]); } COMMAND(docinvalid, ""); void docfind(char *search, int *silent) { vector res; vector inames; enumerate(docidents, docident, i, inames.add(i.name)); inames.sort(stringsort); loopvj(inames) { docident &i = *docidents.access(inames[j]); vector srch; srch.add(i.name); // 0 srch.add(i.desc); // 1 loopvk(i.remarks) srch.add(i.remarks[k]); char *r; int rline; if((r = cvecstr(srch, search, &rline))) { cvecprintf(res, "%s %d\n", escapestring(i.name, false), rline); if(!rline) r = srch[(rline = 1)]; if(!*silent) { const int showchars = 100; string match; int pos = r - srch[rline]; copystring(match, srch[rline] + (pos < showchars - 10 ? 0 : pos - 10), showchars); conoutf("%-20s%s", i.name, match); } } } resultcharvector(res, -1); } COMMAND(docfind, "si"); void getdoc(char *name, int *line) { const char *res = ""; docident *d = docidents.access(name); if(d) { switch(*line) { case 0: res = d->name; break; case 1: res = d->desc; break; default: if(d->remarks.inrange(*line - 2)) res = d->remarks[*line - 2]; break; } } else conoutf("\f3getdoc: \"%s\" not found", name); result(res); } COMMAND(getdoc, "si"); char *xmlstringenc(char *d, const char *s, size_t len) { if(!d || !s) return NULL; struct spchar { char c; char repl[8]; } const spchars[] = { {'&', "&"}, {'<', "<"}, {'>', "gt;"}, {'"', """}, {'\'', "'"}}; char *dc = d; const char *sc = s; while(*sc && (size_t)(dc - d) < len - 1) { bool specialc = false; loopi(sizeof(spchars)/sizeof(spchar)) if(spchars[i].c == *sc) { specialc = true; size_t rlen = strlen(spchars[i].repl); if(dc - d + rlen <= len - 1) { memcpy(dc, spchars[i].repl, rlen); dc += rlen; break; } } if(!specialc) memcpy(dc++, sc, 1); *dc = 0; sc++; } return d; } void docwriteref(int allidents, const char *ref, const char *schemalocation, const char *transformation) { stream *f = openfile(path(allidents < 0 ? "docs/autogenerated_base_reference.xml" : "docs/autogenerated_todo_reference.xml", true), "w"); if(!f) return; char desc[] = "TODO: Description"; vector inames; if(allidents < 0) identnames(inames, true); // -1: all builtin else listundoneidents(inames, allidents); // 0: todo builtin, 1: todo builtin + alias inames.sort(stringsort); if(allidents < 0) { f->printf("\n"); f->printf("\n", transformation && strlen(transformation) ? transformation : "transformations/cuberef2xhtml.xslt"); f->printf("\n", ref && strlen(ref) ? ref : "Unnamed Reference", schemalocation && strlen(schemalocation) ? schemalocation : "http://cubers.net/Schemas/CubeRef schemas/cuberef.xsd"); f->printf("\t%s\n", desc); f->printf("\t\n"); f->printf("\t\t
\n"); f->printf("\t\t\t%s\n", desc); f->printf("\t\t\t\n"); } string name; loopv(inames) { ident *id = idents->access(inames[i]); if(!id || id->type != ID_COMMAND) continue; f->printf("\t\t\t\t\n", xmlstringenc(name, id->name, MAXSTRLEN)); f->printf("\t\t\t\t\t%s\n", desc); if(id->sig && id->sig[0]) { f->printf("\t\t\t\t\t\n"); loopi(strlen(id->sig)) { f->printf("\t\t\t\t\t\t\n", id->sig[i]); } f->printf("\t\t\t\t\t\n"); } f->printf("\t\t\t\t\n"); } loopv(inames) { ident *id = idents->access(inames[i]); if(!id || (id->type != ID_VAR && id->type != ID_FVAR)) continue; f->printf("\t\t\t\t\n", xmlstringenc(name, id->name, MAXSTRLEN)); f->printf("\t\t\t\t\tTODO\n"); switch(id->type) { case ID_VAR: f->printf("\t\t\t\t\t\n", id->minval>id->maxval ? "" : "token=\"N\"", id->minval, id->maxval, *id->storage.i, id->minval>id->maxval ? "readOnly=\"true\"" : ""); break; case ID_FVAR: f->printf("\t\t\t\t\t\n", id->minvalf>id->maxvalf ? "" : "token=\"N\"", floatstr(id->minvalf), floatstr(id->maxvalf), floatstr(*id->storage.f), id->minvalf>id->maxvalf ? "readOnly=\"true\"" : ""); break; } f->printf("\t\t\t\t\n"); } loopv(inames) { ident *id = idents->access(inames[i]); if(!id || id->type != ID_ALIAS) continue; f->printf("\t\t\t\t\n", xmlstringenc(name, id->name, MAXSTRLEN)); f->printf("\t\t\t\t\t%s\n", desc); f->printf("\t\t\t\t\n"); } if(allidents < 0) f->printf("\t\t\t\n\t\t
\n\t
\n
\n"); delete f; } void docwritebaseref(char *ref, char *schemalocation, char *transformation) { docwriteref(-1, ref, schemalocation, transformation); } COMMAND(docwritebaseref, "sss"); void docwritetodoref(int *allidents) { docwriteref(*allidents ? 1 : 0, "", "", ""); } COMMAND(docwritetodoref, "i"); VAR(docvisible, 0, 1, 1); VAR(docrefvisible, 0, 1, 1); VAR(docskip, 0, 0, 1000); VAR(docidentverbose, 0, 1, 3); void toggledoc() { docvisible = !docvisible; } void scrolldoc(int i) { docskip += i; if(docskip < 0) docskip = 0; } int docs_parsecmd(const char *p, const char *pos, const char *w[MAXWORDS], int wl[MAXWORDS], bool outer, int *unmatched) { vector brak; for(;;) // loop statements { int nargs = MAXWORDS, curarg = -1; loopi(MAXWORDS) { w[i] = NULL; wl[i] = 0; if(i > nargs) continue; w[i] = (p += strspn(p, " \t")); // skip whitespace if(p[0]=='/' && p[1]=='/') p += strcspn(p, "\n\r\0"); // skip comment if(*p == '"') { // find matching " do { ++p; p += strcspn(p, "\"\n\r"); } while(*p == '\"' && p[-1] == '\\'); p++; } else if(*p == '[' || *p == '(') { // find matching ) or ] bool quot = false; char right = *p == '[' ? ']' : ')', left = *p++; brak.add(p); while(brak.length()) { p += strcspn(p, "([\"])"); int c = *p++; if(c == left && !quot) brak.add(p); else if(c == '"') quot = !quot; else if(c == right && !quot) brak.drop(); else if(!c) { // unmatched braces, interpret from there (in first pass) *unmatched = right; if(w[0] == brak.last() || brak.last() == p - 1 || outer) break; p = brak.last(); brak.setsize(0); i = -1; } } } else p += strcspn(p, "; \t\n\r\0"); // skip regular word if(i < 0) continue; if(!(wl[i] = (int) (p - w[i]))) w[i] = NULL, nargs = i; else if(w[i] <= pos) curarg = i - 1; } p += strcspn(p, ";\n\r\0"); // skip statement delimiter if(!*p++ || pos < p) return curarg; // was last statement, or the one we wanted } } void renderdoc(int x, int y, int doch) { if(!docvisible) return; doch -= 3*FONTH + FONTH/2; int cmdpos; const char *exp = getcurcommand(&cmdpos); // get command buffer and cursor position if(!exp || *exp != '/') return; const char *pos = exp + (cmdpos < 0 ? strlen(exp) : cmdpos), *w[MAXWORDS]; int wl[MAXWORDS], carg, unmatched = 0; docident *curident = NULL; string buf; loopi(2) // two scan passes, first one retries on unmatched braces { carg = docs_parsecmd(exp + 1, pos, w, wl, i != 0, &unmatched); // break into words if(!w[0]) return; copystring(buf, w[0], wl[0] + 1); curident = docidents.access(buf); // get doc entry if(curident) break; } if(unmatched) draw_textf("\f3missing '%c'", x + 1111, y + doch + 2*FONTH, unmatched); ident *csident = idents->access(buf); // check for cs ident if(!curident && !csident && docidentverbose < 3) { docskip = 0; return; } vector doclines; vector heaplines; if(curident) { if(!curident->label) { formatstring(buf)("~%s", curident->name); // label loopvj(curident->arguments) concatformatstring(buf, " %s", curident->arguments[j].token); curident->label = newstring(buf); } doclines.add(curident->label); doclines.add(NULL); doclines.add(curident->desc); doclines.add(NULL); if(curident->arguments.length()) // args { if(carg >= curident->arguments.length() && curident->arguments.last().vararg) carg = curident->arguments.length() - 1; // vararg spans the line loopvj(curident->arguments) { docargument *a = &curident->arguments[j]; formatstring(doclines.add(heaplines.add(newstringbuf())))("\f%c%-8s%s", j == carg ? '4' : '5', a->token, a->desc); if(a->values) concatformatstring(heaplines.last(), " (%s)", a->values); } doclines.add(NULL); } if(curident->remarks.length()) // remarks { loopvj(curident->remarks) doclines.add(curident->remarks[j]); doclines.add(NULL); } if(curident->examples.length()) // examples { doclines.add(curident->examples.length() == 1 ? "Example:" : "Examples:"); loopvj(curident->examples) { doclines.add(curident->examples[j].code); doclines.add(curident->examples[j].explanation); } doclines.add(NULL); } if(curident->keylines.length()) // default keys { doclines.add(curident->keylines.length() == 1 ? "Default key:" : "Default keys:"); loopvj(curident->keylines) doclines.add(curident->keylines[j]); // stored preformatted doclines.add(NULL); } if(docrefvisible && curident->references.length()) // references { if(!curident->related) { string refs = ""; loopvj(curident->references) concatformatstring(refs, ", %s", curident->references[j]); formatstring(buf)("Related identifiers:%s", refs + 1); curident->related = newstring(buf); } doclines.add(curident->related); doclines.add(NULL); } } if(csident && docidentverbose) // cs ident details { doclines.add("\f4Ident info:"); formatstring(buf)("\fs\f1%s\fr: ", csident->name); switch(csident->type) { case ID_VAR: if(csident->maxval < csident->minval) concatformatstring(buf, "integer variable, current %d, read-only", *csident->storage.i); else concatformatstring(buf, "integer variable, current %d, min %d, max %d, default %d", *csident->storage.i, csident->minval, csident->maxval, csident->defaultval); break; case ID_FVAR: if(csident->maxvalf < csident->minvalf) concatformatstring(buf, "float variable, current %s, read-only", floatstr(*csident->storage.f)); else concatformatstring(buf, "float variable, current %s, min %s, max %s, default %s", floatstr(*csident->storage.f), floatstr(csident->minvalf), floatstr(csident->maxvalf), floatstr(csident->defaultvalf)); break; case ID_SVAR: concatstring(buf, "string variable"); break; case ID_COMMAND: concatformatstring(buf, "builtin command%s", strchr("sif", *csident->sig) ? ", arguments:" : ""); loopi(strlen(csident->sig)) switch(csident->sig[i]) { case 's': concatstring(buf, i == carg ? " \fs\f4string\fr": " string"); break; case 'i': concatstring(buf, i == carg ? " \fs\f4int\fr" : " int"); break; case 'f': concatstring(buf, i == carg ? " \fs\f4float\fr" : " float"); break; case 'd': concatstring(buf, ", keybind-only"); break; case 'v': concatstring(buf, ", argument list varies"); break; case 'c': concatstring(buf, ", concatenates arguments with spaces"); break; case 'w': concatstring(buf, ", concatenates arguments without spaces"); break; } break; case ID_ALIAS: concatformatstring(buf, "alias, %s", csident->istemp ? "temp" : (csident->isconst ? "const" : (csident->persist ? "persistent" : "non-persistent"))); break; } doclines.add(heaplines.add(newstring(buf))); doclines.add(NULL); } if(docidentverbose >= 2) { doclines.add("\f4Cubescript statement broken into words:"); int n; loopi(MAXWORDS) if(w[i]) { if(i) formatstring(buf)("\fs\f4arg%d: \fr%n%s", i, &n, w[i]); else formatstring(buf)("\fs\f4cmd: \fr%n%s", &n, w[i]); doclines.add(heaplines.add(newstring(buf, n + wl[i]))); } } while(doclines.length() && !doclines.last()) doclines.pop(); int offset = min(docskip, doclines.length()-1), maxl = offset, cury = 0; for(int j = offset; j < doclines.length(); j++) { const char *str = doclines[j]; int width = 0, height = FONTH; if(str) text_bounds(*str=='~' ? str+1 : str, width, height, *str=='~' ? -1 : VIRTW*4/3); if(cury + height > doch) break; cury += height; maxl = j+1; } if(offset > 0 && maxl >= doclines.length()) { for(int j = offset-1; j >= 0; j--) { const char *str = doclines[j]; int width = 0, height = FONTH; if(str) text_bounds(*str=='~' ? str+1 : str, width, height, *str=='~' ? -1 : VIRTW*4/3); if(cury + height > doch) break; cury += height; offset = j; } } cury = y; for(int j = offset; j < maxl; j++) { const char *str = doclines[j]; if(str) { const char *text = *str=='~' ? str+1 : str; draw_text(text, x, cury, 0xFF, 0xFF, 0xFF, 0xFF, -1, str==text ? VIRTW*4/3 : -1); int width, height; text_bounds(text, width, height, str==text ? VIRTW*4/3 : -1); cury += height; } else cury += FONTH; } heaplines.deletearrays(); if(docskip > offset) docskip = offset; if(maxl < doclines.length()) draw_text("\f4more (F3)", x, y+doch); // footer if(offset > 0) draw_text("\f4less (F2)", x, y+doch+FONTH); draw_text("\f4disable doc reference (F1)", x, y+doch+2*FONTH); } void *docmenu = NULL; struct msection { char *name, *desc; string cmd; }; int msectionsort(const msection *a, const msection *b) { return strcmp(a->name, b->name); } void renderdocsection(void *menu, bool init) { static vector msections; msections.shrink(0); loopv(sections) { if(sections[i].menu != menu) continue; loopvj(sections[i].sidents) { docident &id = *sections[i].sidents[j]; msection &s = msections.add(); s.name = id.name; formatstring(s.cmd)("saycommand [/%s ]", id.name); s.desc = id.desc; } msections.sort(msectionsort); menureset(menu); loopv(msections) { menuitemmanual(menu, msections[i].name, msections[i].cmd, NULL, msections[i].desc); } return; } } struct maction { string cmd; }; void renderdocmenu(void *menu, bool init) { static vector actions; actions.shrink(0); menureset(menu); loopv(sections) { maction &a = actions.add(); formatstring(a.cmd)("showmenu [%s]", sections[i].name); menuitemmanual(menu, sections[i].name, a.cmd); } } assaultcube-1.2.0.2.1/source/src/editing.cpp000066400000000000000000001230241352165075300205530ustar00rootroot00000000000000// editing.cpp: most map editing commands go here, entity editing commands are in world.cpp #include "cube.h" bool editmode = false; // the current selections, used by almost all editing commands // invariant: all code assumes that these are kept inside MINBORD distance of the edge of the map // => selections are checked when they are made or when the world is reloaded vector sels; #define loopselxy(sel, b) { makeundo(sel); loop(x,(sel).xs) loop(y,(sel).ys) { sqr *s = S((sel).x+x, (sel).y+y); b; } remipgenerous(sel); } #define loopselsxy(b) { loopv(sels) loopselxy(sels[i], b); } int cx, cy, ch; int curedittex[] = { -1, -1, -1 }; bool dragging = false; int lastx, lasty, lasth; int lasttype = 0, lasttex = 0; sqr rtex; VAR(editing, 1, 0, 0); VAR(editing_sp, 1, 0, 0); VAR(unsavededits, 1, 0, 0); VAR(editmetakeydown, 1, 0, 0); COMMANDF(editmeta, "d", (bool on) { editmetakeydown = on ? 1 : 0; } ); void toggleedit(bool force) { if(player1->state==CS_DEAD) return; // do not allow dead players to edit to avoid state confusion if(!force && !editmode && !allowedittoggle()) return; // not in most multiplayer modes if(player1->state == CS_SPECTATE) { if(watchingdemo) { if(player1->spectatemode != SM_FLY) spectatemode(SM_FLY); // release in a place of followed player } else return; } if(!(editmode = !editmode)) { float oldz = player1->o.z; entinmap(player1); // find spawn closest to current floating pos player1->timeinair = player1->o.z == oldz ? 0: 300; } else { //put call to clear/restart gamemode player1->attacking = false; } keyrepeat(editmode, KR_EDITMODE); editing = editmode ? 1 : 0; editing_sp = editmode && !multiplayer(NULL) ? 1 : 0; player1->state = editing ? CS_EDITING : (watchingdemo ? CS_SPECTATE : CS_ALIVE); if(editing && player1->onladder) player1->onladder = false; if(editing && (player1->weaponsel->type == GUN_SNIPER && ((sniperrifle *)player1->weaponsel)->scoped)) ((sniperrifle *)player1->weaponsel)->onownerdies(); // or ondeselecting() if(editing && (player1->weaponsel->type == GUN_GRENADE)) ((grenades *)player1->weaponsel)->onownerdies(); if(!force) addmsg(SV_EDITMODE, "ri", editing); } void edittoggle() { toggleedit(false); } COMMAND(edittoggle, ""); bool correctsel(block &s) // ensures above invariant { int bsize = ssize - MINBORD; if(s.xs+s.x>bsize) s.xs = bsize-s.x; if(s.ys+s.y>bsize) s.ys = bsize-s.y; if(s.xs<=0 || s.ys<=0) return false; else return !OUTBORD(s.x, s.y); } bool noteditmode(const char* func) { if(!editmode) { if(func && func[0]!='\0') conoutf("\f4[\f3%s\f4]\f5 is only allowed in edit mode", func); else conoutf("this function is only allowed in edit mode"); } return !editmode; } inline bool selset() { return (sels.length() > 0); } bool noselection() { if(!selset()) conoutf("no selection"); return !selset(); } VARP(hideeditslotinfo, 0, 0, 2); char *editinfo() { static string info; if(!editmode) return NULL; info[0] = '\0'; int e = closestent(); if(e >= 0) { entity &c = ents[e]; int t = c.type < MAXENTTYPES ? c.type : 0; formatstring(info)("%s entity: %s (%s)", pinnedclosestent ? "\fs\f3pinned\fr" : "closest", entnames[t], formatentityattributes(c, true)); const char *unassigned = "unassigned slot", *slotinfo = unassigned; if(t == MAPMODEL) { mapmodelinfo *mmi = getmminfo(c.attr2); if(mmi) slotinfo = mmshortname(mmi->name); } else if(t == SOUND) { if(mapconfigdata.mapsoundlines.inrange(c.attr1)) slotinfo = mapconfigdata.mapsoundlines[c.attr1].name; } else slotinfo = ""; if(*slotinfo && (hideeditslotinfo == 0 || (hideeditslotinfo == 1 && slotinfo == unassigned))) concatformatstring(info, " %s", slotinfo); } if(selset()) { concatformatstring(info, "\n\tselection = (%d, %d)", (sels.last()).xs, (sels.last()).ys); if(sels.length() > 1) concatformatstring(info, " and %d more", sels.length() - 1); } else concatformatstring(info, "\n\tno selection"); sqr *s; if(!OUTBORD(cx, cy) && (s = S(cx,cy)) && !editfocusdetails(s) && !SOLID(s) && s->tag) concatformatstring(info, ", tag 0x%02X", s->tag); return info; } // multiple sels // add a selection to the list void addselection(int x, int y, int xs, int ys, int h) { block &s = sels.add(); if(h == -999 && !OUTBORD(x + xs / 2, y + ys / 2)) h = S(x + xs / 2, y + ys / 2)->floor; s.x = x; s.y = y; s.xs = xs; s.ys = ys; s.h = h; if(!correctsel(s)) { sels.drop(); } } // reset all selections void resetselections() { sels.shrink(0); } COMMANDF(select, "iiii", (int *x, int *y, int *xs, int *ys) { resetselections(); addselection(*x, *y, *xs, *ys, -999); }); COMMANDF(addselection, "iiii", (int *x, int *y, int *xs, int *ys) { addselection(*x, *y, *xs, *ys, -999); }); COMMAND(resetselections, ""); // reset all invalid selections void checkselections() { loopv(sels) if(!correctsel(sels[i])) sels.remove(i); } // update current selection, or add a new one void makesel(bool isnew) { if(isnew || sels.length() == 0) addselection(min(lastx, cx), min(lasty, cy), iabs(lastx-cx)+1, iabs(lasty-cy)+1, max(lasth, ch)); else { block &cursel = sels.last(); cursel.x = min(lastx, cx); cursel.y = min(lasty, cy); cursel.xs = iabs(lastx-cx)+1; cursel.ys = iabs(lasty-cy)+1; cursel.h = max(lasth, ch); correctsel(cursel); } if(selset()) rtex = *S((sels.last()).x, (sels.last()).y); } #define SEL_ATTR(attr) { string buf = ""; loopv(sels) { concatformatstring(buf, "%d ", sels[i].attr); } result(buf); } COMMANDF(selx, "", (void) { SEL_ATTR(x); }); COMMANDF(sely, "", (void) { SEL_ATTR(y); }); COMMANDF(selxs, "", (void) { SEL_ATTR(xs); }); COMMANDF(selys, "", (void) { SEL_ATTR(ys); }); #undef SEL_ATTR VAR(flrceil, 2, 0, 0); VAR(editaxis, 113, 0, 0); VARP(showgrid, 0, 1, 1); // VC8 optimizer screws up rendering somehow if this is an actual function #define sheight(s,t,z) (!flrceil ? (s->type==FHF ? s->floor-t->vdelta/4.0f : (float)s->floor) : (s->type==CHF ? s->ceil+t->vdelta/4.0f : (float)s->ceil)) // remove those two after playing with the values a bit :) VAR(tagnum, 1, 14, 100); VAR(tagnumfull, 0, 0, 100); VAR(taglife, 1, 30, 1000); // and have mercy with old graphics cards... vector tagclipcubes; bool showtagclipfocus = false; COMMANDF(showtagclipfocus, "d", (bool on) { showtagclipfocus = on; } ); VAR(showtagclips, 0, 1, 1); FVAR(tagcliplinewidth, 0.2, 1, 3); inline void forceinsideborders(int &xy) { if(xy < MINBORD) xy = MINBORD; if(xy >= ssize - MINBORD) xy = ssize - MINBORD - 1; } void cursorupdate() // called every frame from hud { ASSERT(editmode); flrceil = camera1->pitch >= 0 ? 2 : 0; editaxis = fabs(camera1->pitch) > 60 ? "\161\15\15"[flrceil] : "\160\13\14\157"[(int(camera1->yaw + 45) / 90) & 3]; volatile float x = worldpos.x; // volatile needed to prevent msvc7 optimizer bug? volatile float y = worldpos.y; volatile float z = worldpos.z; cx = (int)x; cy = (int)y; if(OUTBORD(cx, cy)) { forceinsideborders(cx); forceinsideborders(cy); return; } sqr *s = S(cx,cy); if(fabs(sheight(s,s,z)-z)>1) // selected wall { x += x>camera1->o.x ? 0.5f : -0.5f; // find right wall cube y += y>camera1->o.y ? 0.5f : -0.5f; cx = (int)x; cy = (int)y; if(OUTBORD(cx, cy)) { forceinsideborders(cx); forceinsideborders(cy); return; } } if(dragging) makesel(false); const int GRIDSIZE = 5; const float GRIDW = 0.5f; const float GRID8 = 2.0f; const float GRIDS = 2.0f; const int GRIDM = 0x7; static int lastsparkle = 0; bool sparkletime = lastmillis - lastsparkle >= 20; if(sparkletime) lastsparkle = lastmillis - (lastmillis%20); // clip adding sparklies at 50 fps // render editing grid extern int blankouthud; if(showgrid && !blankouthud) { for(int ix = cx-GRIDSIZE; ix<=cx+GRIDSIZE; ix++) for(int iy = cy-GRIDSIZE; iy<=cy+GRIDSIZE; iy++) { if(OUTBORD(ix, iy)) continue; sqr *s = S(ix,iy); if(SOLID(s)) continue; float h1 = sheight(s, s, z); float h2 = sheight(s, SWS(s,1,0,sfactor), z); float h3 = sheight(s, SWS(s,1,1,sfactor), z); float h4 = sheight(s, SWS(s,0,1,sfactor), z); if(sparkletime && showtagclips && showtagclipfocus && s->tag & TAGANYCLIP) particle_cube(s->tag & TAGCLIP ? PART_EPICKUP : PART_EMODEL, tagnum, taglife, ix, iy); if(s->tag) linestyle(GRIDW, 0xFF, 0x40, 0x40); else if(s->type==FHF || s->type==CHF) linestyle(GRIDW, 0x80, 0xFF, 0x80); else linestyle(GRIDW, 0x80, 0x80, 0x80); block b = { ix, iy, 1, 1 }; box(b, h1, h2, h3, h4); linestyle(GRID8, 0x40, 0x40, 0xFF); if(!(ix&GRIDM)) line(ix, iy, h1, ix, iy+1, h4); if(!((ix+1)&GRIDM)) line(ix+1, iy, h2, ix+1, iy+1, h3); if(!(iy&GRIDM)) line(ix, iy, h1, ix+1, iy, h2); if(!((iy+1)&GRIDM)) line(ix, iy+1, h4, ix+1, iy+1, h3); } if(!SOLID(s)) { float ih = sheight(s, s, z); linestyle(GRIDS, 0xFF, 0xFF, 0xFF); block b = { cx, cy, 1, 1 }; box(b, ih, sheight(s, SWS(s,1,0,sfactor), z), sheight(s, SWS(s,1,1,sfactor), z), sheight(s, SWS(s,0,1,sfactor), z)); linestyle(GRIDS, 0xFF, 0x00, 0x00); dot(cx, cy, ih); ch = (int)ih; } } else ch = (int) sheight(s, s, z); if(selset() && !blankouthud) { linestyle(GRIDS, 0xFF, 0x40, 0x40); loopv(sels) box(sels[i], (float)sels[i].h, (float)sels[i].h, (float)sels[i].h, (float)sels[i].h); } if(!showtagclipfocus && showtagclips && !blankouthud) { const int xo[] = { 0, 0, 1, 1, 0 }, yo[] = {0, 1, 1, 0, 0 }; loopv(tagclipcubes) // all non-solid & have clips { int x = tagclipcubes[i] & 0xFFFF, y = tagclipcubes[i] >> 16; ASSERT(!OUTBORD(x, y)); sqr *s = S(x,y), *o[9]; if(s->tag & TAGCLIP) linestyle(tagcliplinewidth, 0xFF, 0xFF, 0); // yello else linestyle(tagcliplinewidth, 0xFF, 0, 0xFF); // magenta o[8] = SWS(s,-1,-1,sfactor); o[3] = o[8] + 1; // 837 o[7] = o[3] + 1; // 0s2 o[0] = o[4] = SWS(s,-1,0,sfactor); // 516 o[2] = o[0] + 2; o[5] = SWS(s,-1,1,sfactor); o[1] = o[5] + 1; o[6] = o[1] + 1; bool clipped[9]; loopj(9) clipped[j] = !SOLID(o[j]) && (o[j]->tag & TAGANYCLIP) > 0; int h = s->floor - (s->type == FHF ? (s->vdelta + 3) / 4 : 0), c = s->ceil + (s->type == CHF ? (s->vdelta + 3) / 4 : 0); loopk(4) if((clipped[k] == clipped[k+1]) && !(clipped[k] && clipped[k + 5])) line(x + xo[k+1], y + yo[k+1], h, x + xo[k+1], y + yo[k+1], c); for( ; h < c; h++) { int k = (h + x + y) & 3; if(k < 2 && !clipped[k]) line(x + xo[k], y + yo[k], h + 1, x + xo[k+1], y + yo[k+1], h); k = (h - x - y) & 3; if(k > 1 && !clipped[k]) line(x + xo[k], y + yo[k], h + 1, x + xo[k+1], y + yo[k+1], h); } if(sparkletime && tagnumfull) particle_cube(s->tag & TAGCLIP ? PART_EPICKUP : PART_EMODEL, tagnumfull, 30, x, y); } } glLineWidth(1); } vector undos, redos; // unlimited undo VAR(undomegs, 0, 5, 50); // bounded by n megs int undolevel = 0; void pruneundos(int maxremain) // bound memory { int u = 0, r = 0; maxremain /= sizeof(sqr); loopvrev(undos) { u += undos[i]->xs * undos[i]->ys; if(u > maxremain) freeblockp(undos.remove(i)); } loopvrev(redos) { r += redos[i]->xs * redos[i]->ys; if(r > maxremain) freeblockp(redos.remove(i)); } } void storeposition(short p[]) { loopi(3) p[i] = player1->o.v[i] * DMF; p[3] = player1->yaw; p[4] = player1->pitch; } void makeundo(block &sel) { storeposition(sel.p); undos.add(blockcopy(sel)); pruneundos(undomegs<<20); unsavededits++; undolevel++; } void restoreposition(short p[]) { loopi(3) player1->o.v[i] = float(p[i]) / DMF; player1->yaw = p[3]; player1->pitch = p[4]; player1->resetinterp(); } void restoreposition(block &sel) { restoreposition(sel.p); resetselections(); addselection(sel.x, sel.y, sel.xs, sel.ys, sel.h); // select undone area checkselections(); } void gotoentity(int *n) { if(noteditmode("gotoentity")) return; if(ents.inrange(*n) && ents[*n].type != NOTUSED) { player1->o.x = ents[*n].x; player1->o.y = ents[*n].y; player1->o.z = ents[*n].z; player1->yaw = ((ents[*n].attr1 / ENTSCALE10) % 360 + 360) % 360; // works for most ;) player1->pitch = 0; player1->resetinterp(); } } COMMAND(gotoentity, "i"); void gotoposition(char *x, char *y, char *z, char *yaw, char *pitch) { if(noteditmode("gotoposition")) return; if(*x) player1->o.x = atof(x); if(*y) player1->o.y = atof(y); if(*z) player1->o.z = atof(z); if(*yaw) player1->yaw = (atoi(yaw) % 360 + 360) % 360; if(*pitch) player1->pitch = atoi(pitch) % 90; player1->resetinterp(); defformatstring(res)("%s %s %s %d %d", floatstr(player1->o.x), floatstr(player1->o.y), floatstr(player1->o.z), int(player1->yaw), int(player1->pitch)); result(res); } COMMAND(gotoposition, "sssss"); const int MAXNETBLOCKSQR = MAXGZMSGSIZE / sizeof(sqr); void netblockpaste(const block &b, int bx, int by, bool light) // transmit block to be pasted at bx,by { ASSERT(b.xs * b.ys <= MAXNETBLOCKSQR); vector t, tmp; putuint(t, bx); putuint(t, by); putuint(t, b.xs); putuint(t, b.ys); putuint(t, light ? 1 : 0); tmp.put((uchar *)((&b)+1), b.xs * b.ys * (int)sizeof(sqr)); putgzbuf(t, tmp); packetbuf p(t.length() + 10, ENET_PACKET_FLAG_RELIABLE); putint(p, SV_EDITBLOCK); p.put(t.getbuf(), t.length()); sendpackettoserv(1, p.finalize()); } void netblockpastexy(ucharbuf *p, int bx, int by, int bxs, int bys, int light) { if(bxs < 0 || bys < 0 || bxs > ssize || bys > ssize || bxs * bys > MAXNETBLOCKSQR || OUTBORD(bx, by) || OUTBORD(bx+bxs-1, by+bys-1)) return; block *b = (block *)new uchar[sizeof(block) + bxs * bys * sizeof(sqr)]; b->x = bx; b->y = by; b->xs = bxs; b->ys = bys; memcpy(b + 1, p->buf, p->maxlen); makeundo(*b); blockpaste(*b, bx, by, light != 0, NULL); freeblockp(b); } void editundo() { EDIT("undo"); bool mp = multiplayer(NULL); if(mp && undos.length() && undos.last()->xs * undos.last()->ys > MAXNETBLOCKSQR) { conoutf("\f3next undo area too big for multiplayer editing"); return; } if(undos.empty()) { conoutf("nothing more to undo"); return; } block *p = undos.pop(); undolevel--; redos.add(blockcopy(*p)); if(editmetakeydown) restoreposition(*p); blockpaste(*p); if(mp) netblockpaste(*p, p->x, p->y, true); freeblock(p); unsavededits++; } COMMANDN(undo, editundo, ""); void gotoundolevel(char *lev) { if(*lev && isdigit(*lev)) { EDITMP("undolevel"); int n = ATOI(lev); while(undolevel > n && undos.length() > 0) editundo(); } intret(undolevel); } COMMANDN(undolevel, gotoundolevel, "s"); void editredo() { EDIT("redo"); bool mp = multiplayer(NULL); if(mp && redos.length() && redos.last()->xs * redos.last()->ys > MAXNETBLOCKSQR) { conoutf("\f3next redo area too big for multiplayer editing"); return; } if(redos.empty()) { conoutf("nothing more to redo"); return; } block *p = redos.pop(); undos.add(blockcopy(*p)); undolevel++; if(editmetakeydown) restoreposition(*p); blockpaste(*p); if(mp) netblockpaste(*p, p->x, p->y, true); freeblock(p); unsavededits++; } COMMANDN(redo, editredo, ""); extern int worldiodebug; void restoreeditundo(ucharbuf &q) { int type, len, explen; while(!q.overread() && (type = getuint(q))) { int bx = getuint(q), by = getuint(q), bxs = getuint(q), bys = getuint(q); short pp[5]; loopi(5) pp[i] = getint(q); len = getuint(q); if((bx | by | (bx + bxs) | (by + bys)) & ~(ssize - 1)) continue; explen = bxs * bys; block *b = (block *)new uchar[sizeof(block) + explen * sizeof(sqr)]; b->x = bx; b->y = by; b->xs = bxs; b->ys = bys; loopi(5) b->p[i] = pp[i]; ucharbuf p = q.subbuf(len); rldecodecubes(p, (sqr *)(b+1), explen, 6, true); switch(type) { case 10: undos.insert(0, b); break; case 20: redos.insert(0, b); break; default: freeblock(b); break; } #ifdef _DEBUG if(worldiodebug) switch(type) { case 10: case 20: clientlogf(" got %sdo x %d, y %d, xs %d, ys %d, remaining %d, overread %d", type == 10 ? "un" : "re", b->x, b->y, b->xs, b->ys, q.remaining(), int(q.overread())); break; } #endif } if(undos.length() || redos.length()) conoutf("restored editing history: %d undos and %d redos", undos.length(), redos.length()); } int rlencodeundo(int type, vector &t, block *s) { putuint(t, type); putuint(t, s->x); putuint(t, s->y); putuint(t, s->xs); putuint(t, s->ys); loopi(5) putint(t, s->p[i]); vector tmp; rlencodecubes(tmp, (sqr *)(s+1), s->xs * s->ys, true); putuint(t, tmp.length()); t.put(tmp.getbuf(), tmp.length()); #ifdef _DEBUG if(worldiodebug) clientlogf(" compressing redo/undo x %d, y %d, xs %d, ys %d, compressed length %d, cubes %d", s->x, s->y, s->xs, s->ys, tmp.length(), s->xs * s->ys); #endif return t.length(); } int backupeditundo(vector &buf, int undolimit, int redolimit) { int numundo = 0; vector tmp; loopvrev(undos) { tmp.setsize(0); undolimit -= rlencodeundo(10, tmp, undos[i]); if(undolimit < 0) break; buf.put(tmp.getbuf(), tmp.length()); numundo++; #ifdef _DEBUG if(worldiodebug) clientlogf(" written undo x %d, y %d, xs %d, ys %d, compressed length %d", undos[i]->x, undos[i]->y, undos[i]->xs, undos[i]->ys, tmp.length()); #endif } loopvrev(redos) { tmp.setsize(0); redolimit -= rlencodeundo(20, tmp, redos[i]); if(redolimit < 0) break; buf.put(tmp.getbuf(), tmp.length()); #ifdef _DEBUG if(worldiodebug) clientlogf(" written redo x %d, y %d, xs %d, ys %d, compressed length %d", redos[i]->x, redos[i]->y, redos[i]->xs, redos[i]->ys, tmp.length()); #endif } putuint(buf, 0); return numundo; } vector copybuffers; void *copytexconfig = NULL; void resetcopybuffers() { loopv(copybuffers) freeblock(copybuffers[i]); copybuffers.shrink(0); if(copytexconfig) { texconfig_delete(copytexconfig); copytexconfig = NULL; } } void copy() { EDITSEL("copy"); resetcopybuffers(); copytexconfig = texconfig_copy(); loopv(sels) { block *b = blockcopy(sels[i]); copybuffers.add(b); } } COMMAND(copy, ""); void paste() { EDITSEL("paste"); bool mp = multiplayer(NULL); if(mp) { loopv(copybuffers) if(copybuffers[i]->xs * copybuffers[i]->ys > MAXNETBLOCKSQR) { conoutf("\f3copied area too big for multiplayer pasting"); return; } } if(!copybuffers.length()) { conoutf("nothing to paste"); return; } uchar usedslots[256] = { 0 }, *texmap = NULL; if(!mp) { loopv(copybuffers) blocktexusage(*copybuffers[i], usedslots); if(sels.length() && copytexconfig) texmap = texconfig_paste(copytexconfig, usedslots); } loopv(sels) { block sel = sels[i]; int selx = sel.x; int sely = sel.y; loopvj(copybuffers) { block *copyblock = copybuffers[j]; int dx = copyblock->x - copybuffers[0]->x, dy = copyblock->y - copybuffers[0]->y; sel.xs = copyblock->xs; sel.ys = copyblock->ys; sel.x = selx + dx; sel.y = sely + dy; if(!correctsel(sel) || sel.xs!=copyblock->xs || sel.ys!=copyblock->ys) { conoutf("incorrect selection"); return; } makeundo(sel); blockpaste(*copyblock, sel.x, sel.y, true, texmap); if(mp) netblockpaste(*copyblock, sel.x, sel.y, true); } } } COMMAND(paste, ""); void tofronttex() // maintain most recently used of the texture lists when applying texture { loopi(3) { int c = curedittex[i]; if(c>=0) { uchar *p = hdr.texlists[i]; int t = p[c]; for(int a = c-1; a>=0; a--) p[a+1] = p[a]; p[0] = t; curedittex[i] = -1; } } } const char *texturestacktypes[] = { "floor", "wall", "ceiling", "" }; void edittexturestack(char *what, int *slot) // manually manipulate the "last-used" texture lists to put certain textures up front { tofronttex(); // keep laste edited texture int n = getlistindex(what, texturestacktypes, true, -1); if(n >= 0) { loopi(256) if(hdr.texlists[n][i] == *slot) curedittex[n] = i; // find stack index of wanted texture slot } tofronttex(); } COMMAND(edittexturestack, "si"); void editdrag(bool isdown) { if((dragging = isdown)) { lastx = cx; lasty = cy; lasth = ch; tofronttex(); if(!editmetakeydown) resetselections(); } makesel(isdown); if(!isdown) for(int i = sels.length() - 2; i >= 0; i--) { block &a = sels.last(), &b = sels[i]; if(a.x == b.x && a.y == b.y && a.xs == b.xs && a.ys == b.ys) { // making a selection twice will deselect both of it sels.drop(); sels.remove(i); break; } } } // the core editing function. all the *xy functions perform the core operations // and are also called directly from the network, the function below it is strictly // triggered locally. They all have very similar structure. void editheightxy(bool isfloor, int amount, block &sel) { loopselxy(sel, if(isfloor) { s->floor += amount; if(s->floor>=s->ceil) s->floor = s->ceil-1; } else { s->ceil += amount; if(s->ceil<=s->floor) s->ceil = s->floor+1; }); } void editheight(int *flr, int *amount) { EDITSEL("editheight"); bool isfloor = *flr==0; loopv(sels) { editheightxy(isfloor, *amount, sels[i]); addmsg(SV_EDITXY, "ri7", EDITXY_HEIGHT, sels[i].x, sels[i].y, sels[i].xs, sels[i].ys, isfloor, *amount); } } COMMAND(editheight, "ii"); // texture type : 0 floor, 1 wall, 2 ceil, 3 upper wall void renderhudtexturepreview(int slot, int pos, bool highlight) { Texture *pt = slot != DEFAULT_SKY ? lookupworldtexture(slot, false) : NULL; int hs = (highlight ? 0 : (FONTH / 3) * 2), bs = VIRTW / 8 - hs, border = FONTH / (highlight ? 2 : 4), x = 2 * VIRTW - VIRTW / 8 - FONTH + hs / 2, y = VIRTH * (6 - pos) / 4, xs, ys; blendbox(x - border, y - border, x + bs + border, y + bs + border, false); if(pt) { if(pt->xs > pt->ys) xs = bs, ys = (xs * pt->ys) / pt->xs; // keep aspect ratio of texture else ys = bs, xs = (ys * pt->xs) / pt->ys; int xt = x + (bs - xs) / 2, yt = y + (bs - ys) / 2; extern int fullbrightlevel; framedquadtexture(pt->id, xt, yt, xs, ys, 1, fullbrightlevel); } else { // sky slot: just show blue instead of the texture color c(0, 0, 0.6f, 1); blendbox(x, y, x + bs, y + bs, false, -1, &c); } if(highlight) { glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); border /= 2; box2d(x - border, y - border, x + bs + border, y + bs + border, 200); glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); } } static int lastedittex = 0; VARP(hudtexttl, 0, 2500, 10000); void renderhudtexturepreviews() { if(lastedittex && hudtexttl && (lastmillis - lastedittex) < hudtexttl) { int atype = lasttype == 3 ? 1 : lasttype; int idx = curedittex[atype]; if(idx < 0) idx = 0; int startidx = clamp(idx - 2, 0, 251); loopi(5) renderhudtexturepreview(hdr.texlists[atype][startidx + i], i, startidx + i == idx); } } void edittexxy(int type, int t, block &sel) { loopselxy(sel, switch(type) { case 0: s->ftex = t; break; case 1: s->wtex = t; break; case 2: s->ctex = t; break; case 3: s->utex = t; break; }); } void edittex(int *type, int *dir) { EDITSEL("edittex"); if(*type < 0 || *type > 3) return; if(*type != lasttype) { tofronttex(); lasttype = *type; } int atype = *type == 3 ? 1 : *type; int i = curedittex[atype]; i = i < 0 ? 0 : i + *dir; curedittex[atype] = i = min(max(i, 0), 255); int t = lasttex = hdr.texlists[atype][i]; loopv(sels) { edittexxy(*type, t, sels[i]); addmsg(SV_EDITXY, "ri7", EDITXY_TEX, sels[i].x, sels[i].y, sels[i].xs, sels[i].ys, *type, t, 0); } unsavededits++; lastedittex = lastmillis; } COMMAND(edittex, "ii"); void settex(int *texture, int *type) { EDITSEL("settex"); if(*type < 0 || *type > 3) return; int atype = *type == 3 ? 1 : *type; int t = -1; loopi(256) if(*texture == (int)hdr.texlists[atype][i]) { t = (int)hdr.texlists[atype][i]; break; } if(t < 0) { conoutf("invalid/unavaible texture"); return; } loopv(sels) { edittexxy(*type, t, sels[i]); addmsg(SV_EDITXY, "ri7", EDITXY_TEX, sels[i].x, sels[i].y, sels[i].xs, sels[i].ys, *type, t, 0); } unsavededits++; } COMMAND(settex, "ii"); void replace() { EDITSELMP("replace"); loop(x,ssize) loop(y,ssize) { sqr *s = S(x, y); switch(lasttype) { case 0: if(s->ftex == rtex.ftex) s->ftex = lasttex; break; case 1: if(s->wtex == rtex.wtex) s->wtex = lasttex; break; case 2: if(s->ctex == rtex.ctex) s->ctex = lasttex; break; case 3: if(s->utex == rtex.utex) s->utex = lasttex; break; } } block b = { 0, 0, ssize, ssize }; remip(b); unsavededits++; } COMMAND(replace, ""); void edittypexy(int type, block &sel) { loopselxy(sel, s->type = type); } void edittype(int type) { EDITSEL("solid|corner|heightfield"); loopv(sels) { block &sel = sels[i]; if(type == CORNER && (sel.xs != sel.ys || (sel.xs != 1 && sel.xs != 2 && sel.xs != 4 && sel.xs != 8 && sel.xs != 16) || (sel.x | sel.y) & (sel.xs - 1))) conoutf("corner selection must be power of 2 aligned"); else { edittypexy(type, sel); addmsg(SV_EDITXY, "ri7", EDITXY_TYPE, sel.x, sel.y, sel.xs, sel.ys, type, 0); } } } void heightfield(int *t) { edittype(*t==0 ? FHF : CHF); } void solid(int *t) { edittype(*t==0 ? SPACE : SOLID); } void corner() { edittype(CORNER); } COMMAND(heightfield, "i"); COMMAND(solid, "i"); COMMAND(corner, ""); void editequalisexy(bool isfloor, block &sel) { int low = 127, hi = -128; loopselxy(sel, { if(s->floorfloor; if(s->ceil>hi) hi = s->ceil; }); loopselxy(sel, { if(isfloor) s->floor = low; else s->ceil = hi; if(s->floor>=s->ceil) s->floor = s->ceil-1; }); } void equalize(int *flr) { bool isfloor = *flr==0; EDITSEL("equalize"); loopv(sels) { block &sel = sels[i]; editequalisexy(isfloor, sel); addmsg(SV_EDITXY, "ri7", EDITXY_EQUALISE, sel.x, sel.y, sel.xs, sel.ys, isfloor, 0); } } COMMAND(equalize, "i"); void setvdeltaxy(int delta, block &sel) { loopselxy(sel, s->vdelta = max(s->vdelta+delta, 0)); } void setvdelta(int *delta) { EDITSEL("vdelta"); loopv(sels) { setvdeltaxy(*delta, sels[i]); addmsg(SV_EDITXY, "ri7", EDITXY_VDELTA, sels[i].x, sels[i].y, sels[i].xs, sels[i].ys, *delta, 0); } } COMMANDN(vdelta, setvdelta, "i"); VARP(enlargearchslopeselections, 0, 0, 1); // "1" is classic behaviour const int MAXARCHVERT = 50; int archverts[MAXARCHVERT][MAXARCHVERT]; bool archvinit = false; void archvertex(int *span, int *vert, char *delta) { if(!archvinit) { archvinit = true; loop(s,MAXARCHVERT) loop(v,MAXARCHVERT) archverts[s][v] = 0; } if(*span>=MAXARCHVERT || *vert>=MAXARCHVERT || *span<0 || *vert<0) return; intret(archverts[*span][*vert]); if(*delta) archverts[*span][*vert] = ATOI(delta); } COMMAND(archvertex, "iis"); void archxy(int sidedelta, int *averts, block &sel) { loopselxy(sel, s->vdelta = sel.xs>sel.ys ? (averts[x] + (y==0 || y==sel.ys-1 ? sidedelta : 0)) : (averts[y] + (x==0 || x==sel.xs-1 ? sidedelta : 0))); } void arch(int *sidedelta) { EDITSEL("arch"); loopv(sels) { block &sel = sels[i]; sel.xs++; sel.ys++; if(sel.xs>MAXARCHVERT) sel.xs = MAXARCHVERT; if(sel.ys>MAXARCHVERT) sel.ys = MAXARCHVERT; int *averts = sel.xs > sel.ys ? &archverts[sel.xs-1][0] : &archverts[sel.ys-1][0]; addmsg(SV_EDITARCH, "ri5v", sel.x, sel.y, sel.xs, sel.ys, *sidedelta, MAXARCHVERT, averts); archxy(*sidedelta, averts, sel); if(!enlargearchslopeselections) { sel.xs--; sel.ys--; } } } COMMAND(arch, "i"); void slopexy(int xd, int yd, block &sel) { int off = 0; if(xd < 0) off -= xd * sel.xs; if(yd < 0) off -= yd * sel.ys; sel.xs++; sel.ys++; loopselxy(sel, s->vdelta = xd * x + yd * y + off); } void slope(int *xd, int *yd) { EDITSEL("slope"); loopv(sels) { block &sel = sels[i]; addmsg(SV_EDITXY, "ri7", EDITXY_SLOPE, sel.x, sel.y, sel.xs, sel.ys, *xd, *yd); slopexy(*xd, *yd, sel); // (changes xs and ys) if(!enlargearchslopeselections) { sel.xs--; sel.ys--; } } } COMMAND(slope, "ii"); void stairsxy(int xd, int yd, block &sel) { int off = xd || yd ? 1 : 0, xo = xd < 0 ? 1 - sel.xs : 0, yo = yd < 0 ? 1 - sel.ys : 0; loopselxy(sel, s->floor += (xd ? (x + xo) / xd : 0) + (yd ? (y + yo) / yd : 0) + off); } void stairs(int *xd, int *yd) { EDITSEL("stairs"); loopv(sels) { block &sel = sels[i]; addmsg(SV_EDITXY, "ri7", EDITXY_STAIRS, sel.x, sel.y, sel.xs, sel.ys, *xd, *yd); stairsxy(*xd, *yd, sel); } } COMMAND(stairs, "ii"); void perlin(int *scale, int *seed, int *psize) { EDITSELMP("perlin"); loopv(sels) { block sel = sels[i]; sel.xs++; sel.ys++; makeundo(sel); sel.xs--; sel.ys--; perlinarea(sel, *scale, *seed, *psize); sel.xs++; sel.ys++; remipgenerous(sel); if(!enlargearchslopeselections) { sel.xs--; sel.ys--; } } } COMMAND(perlin, "iii"); VARF(fullbright, 0, 0, 1, if(fullbright) { if(noteditmode("fullbright")) return; fullbrightlight(); } else calclight(); ); void edittagxy(int orv, int andv, block &sel) { loopselxy(sel, s->tag = (s->tag & andv) | orv); } void edittag(int *tag) { EDITSEL("edittag"); loopv(sels) { edittagxy(*tag, 0, sels[i]); addmsg(SV_EDITXY, "ri7", EDITXY_TAG, sels[i].x, sels[i].y, sels[i].xs, sels[i].ys, *tag, 0); } } COMMAND(edittag, "i"); void edittagclip(char *tag) { int nt = ((int) strtol(tag, NULL, 0)) & TAGANYCLIP; if(tolower(*tag) == 'n') nt = 0; // "none", "nil, "nop" else if(!strncasecmp(tag, "pl", 2)) nt = TAGPLCLIP; // "playerclip", "plclip", "pl" else if(isalpha(*tag)) nt = TAGCLIP; // "clip", "all", "full", "hippo" EDITSEL("edittagclip"); loopv(sels) { edittagxy(nt, TAGTRIGGERMASK, sels[i]); addmsg(SV_EDITXY, "ri7", EDITXY_TAG, sels[i].x, sels[i].y, sels[i].xs, sels[i].ys, nt, TAGTRIGGERMASK); } } COMMAND(edittagclip, "s"); void newent(char *what, float *a1, float *a2, float *a3, float *a4) { EDITSEL("newent"); loopv(sels) newentity(-1, sels[i].x, sels[i].y, (int)camera1->o.z, what, *a1, *a2, *a3, *a4); } COMMAND(newent, "sffff"); void movemap(int *xop, int *yop, int *zop) // move whole map { EDITMP("movemap"); int xo = *xop, yo = *yop, zo = *zop; if(!worldbordercheck(MINBORD + max(-xo, 0), MINBORD + max(xo, 0), MINBORD + max(-yo, 0), MINBORD + max(yo, 0), max(zo, 0), max(-zo, 0))) { conoutf("not enough space to move the map"); return; } if(xo || yo) { block b = { max(-xo, 0), max(-yo, 0), ssize - iabs(xo), ssize - iabs(yo) }, *cp = blockcopy(b); cp->x = max(xo, 0); cp->y = max(yo, 0); blockpaste(*cp); freeblock(cp); } if(zo) { loop(x, ssize) loop(y, ssize) { S(x,y)->floor = max(-128, S(x,y)->floor + zo); S(x,y)->ceil = min(127, S(x,y)->ceil + zo); } setfvar("waterlevel", waterlevel + zo, true); } loopv(ents) { ents[i].x += xo; ents[i].y += yo; ents[i].z += zo; if(OUTBORD(ents[i].x, ents[i].y)) ents[i].type = NOTUSED; } player1->o.x += xo; player1->o.y += yo; entinmap(player1); calclight(); resetmap(false); unsavededits++; } COMMAND(movemap, "iii"); void selfliprotate(block &sel, int dir) { makeundo(sel); block *org = blockcopy(sel); const sqr *q = (const sqr *)(org + 1); int x1 = sel.x, x2 = sel.x + sel.xs - 1, y1 = sel.y, y2 = sel.y + sel.ys - 1, x, y; switch(dir) { case 1: // 90 degree clockwise for(x = x2; x >= x1; x--) for(y = y1; y <= y2; y++) *S(x,y) = *q++; break; case 2: // 180 degree for(y = y2; y >= y1; y--) for(x = x2; x >= x1; x--) *S(x,y) = *q++; break; case 3: // 90 degree counterclockwise for(x = x1; x <= x2; x++) for(y = y2; y >= y1; y--) *S(x,y) = *q++; break; case 11: // flip x-axis for(y = y1; y <= y2; y++) for(x = x2; x >= x1; x--) *S(x,y) = *q++; break; case 12: // flip y-axis for(y = y2; y >= y1; y--) for(x = x1; x <= x2; x++) *S(x,y) = *q++; break; } remipgenerous(sel); freeblock(org); } void selectionrotate(int *dir) { EDITSEL("selectionrotate"); *dir &= 3; if(!*dir) return; loopv(sels) { block &sel = sels[i]; if(sel.xs == sel.ys || *dir == 2) { selfliprotate(sel, *dir); addmsg(SV_EDITXY, "ri7", EDITXY_FLIPROT, sel.x, sel.y, sel.xs, sel.ys, *dir, 0); } } } COMMAND(selectionrotate, "i"); void selectionflip(char *axis) { EDITSEL("selectionflip"); char c = toupper(*axis); if(c != 'X' && c != 'Y') return; int dir = c == 'X' ? 11 : 12; loopv(sels) { selfliprotate(sels[i], dir); addmsg(SV_EDITXY, "ri7", EDITXY_FLIPROT, sels[i].x, sels[i].y, sels[i].xs, sels[i].ys, dir, 0); } } COMMAND(selectionflip, "s"); void selectionwalk(char *action, char *beginsel, char *endsel) { EDITSEL("selectionwalk"); bool mp = multiplayer(NULL); const char *localvars[] = { "sw_cursel", "sw_abs_x", "sw_abs_y", "sw_rel_x", "sw_rel_y", "sw_type", "sw_floor", "sw_ceil", "sw_wtex", "sw_ftex", "sw_ctex", "sw_utex", "sw_vdelta", "sw_tag", "sw_r", "sw_g", "sw_b", "" }; for(int i = 0; *localvars[i]; i++) push(localvars[i], ""); int maxsels = sels.length(); loopv(sels) { if(i >= maxsels) break; // don't allow the script to add selections block sel = sels[i]; // (copy, not reference) defformatstring(tmp)("%d %d %d %d", sel.x, sel.y, sel.xs, sel.ys); alias("sw_cursel", tmp); if(*beginsel) execute(beginsel); bool haveundo = false, isro = mp && sel.xs * sel.ys > MAXNETBLOCKSQR, didwarn = false; loop(x, sel.xs) loop(y, sel.ys) { sqr *s = S(sel.x + x, sel.y + y), so = *s; formatstring(tmp)("%d", sel.x + x); alias("sw_abs_x", tmp); formatstring(tmp)("%d", sel.y + y); alias("sw_abs_y", tmp); formatstring(tmp)("%d", x); alias("sw_rel_x", tmp); formatstring(tmp)("%d", y); alias("sw_rel_y", tmp); #define AATTR(x) formatstring(tmp)("%d", s->x); alias("sw_"#x, tmp) AATTR(type); AATTR(floor); AATTR(ceil); AATTR(wtex); AATTR(ftex); AATTR(ctex); AATTR(utex); AATTR(vdelta); AATTR(tag); AATTR(r); AATTR(g); AATTR(b); #undef AATTR if(*action) execute(action); so.type = getlistindex(getalias("sw_type"), cubetypenames, true, int(SPACE)); #define GETA(x) so.x = ATOI(getalias("sw_"#x)) GETA(floor); GETA(ceil); GETA(wtex); GETA(ftex); GETA(ctex); GETA(utex); GETA(vdelta); GETA(tag); GETA(r); GETA(g); GETA(b); #undef GETA if(memcmp(s, &so, sizeof(sqr))) { if(isro) { if(!didwarn) conoutf("\f3selectionwalk: selected area %dx%d too big for multiplayer editing, changes ignored!", sel.xs, sel.ys); didwarn = true; } else { if(!haveundo) makeundo(sel); haveundo = true; *s = so; } } } if(haveundo) { if(mp) { block *b = blockcopy(sel); netblockpaste(*b, sel.x, sel.y, true); freeblockp(b); } remipgenerous(sel); } if(*endsel) execute(endsel); } for(int i = 0; *localvars[i]; i++) pop(localvars[i]); } COMMAND(selectionwalk, "sss"); void transformclipentities() // transforms all clip entities to tag clips, if they are big enough (so, that no player could be above or below them) { // (hardcoded factor ENTSCALE10 for attr1 and ENTSCALE5 for attr2-4) EDITMP("transformclipentities"); int total = 0, thisrun, bonus = 5; do { thisrun = 0; loopv(ents) { entity &e = ents[i]; if((e.type == CLIP || e.type == PLCLIP) && e.attr2 / ENTSCALE5 && e.attr3 / ENTSCALE5 && e.attr4 / ENTSCALE5) { int allowedspace = e.type == CLIP ? 1 : 4; int clipmask = e.type == CLIP ? TAGCLIP : TAGPLCLIP; int i2 = e.attr2 / ENTSCALE5, i3 = e.attr3 / ENTSCALE5; // floor values int r2 = (e.attr2 % ENTSCALE5) > 0, r3 = (e.attr3 % ENTSCALE5) > 0; // fractions int x1i = e.x - i2, x2i = e.x + i2 - 1, y1i = e.y - i3, y2i = e.y + i3 - 1; // inner rectangle (fully covered cubes) int x1o = x1i - r2, x2o = x2i + r2, y1o = y1i - r3, y2o = y2i + r3; // outer rectangle (partially covered cubes) float z1 = S(e.x, e.y)->floor + float(e.attr1) / ENTSCALE10, z2 = z1 + float(e.attr4) / ENTSCALE5; bool bigenough = true, nodelete = false; for(int xx = x1o; xx <= x2o; xx++) for(int yy = y1o; yy <= y2o; yy++) // loop over outer rectangle to check, if a clip has the required height { if(OUTBORD(xx,yy) || SOLID(S(xx,yy))) continue; bool inner = xx >= x1i && xx <= x2i && yy >= y1i && yy <= y2i; // flag: xx|yy is inner rectangle sqr *s[4] = { S(xx, yy), S(xx + 1, yy), S(xx, yy + 1), S(xx + 1, yy + 1) }; int vdeltamax = 0; loopj(4) if(s[j]->vdelta > vdeltamax) vdeltamax = s[j]->vdelta; int floor = s[0]->floor - (s[0]->type == FHF ? (vdeltamax + 3) / 4 : 0), ceil = s[0]->ceil - (s[0]->type == CHF ? (vdeltamax + 3) / 4 : 0); bool alreadytagged = (s[0]->tag & (TAGCLIP | clipmask)) != 0; if((z1 - floor > allowedspace || ceil - z2 > allowedspace) && !alreadytagged) bigenough = false; if(!inner && !alreadytagged) nodelete = true; // fractional part of the clip would not be covered: entity can not be deleted } if(bigenough) { for(int xx = x1i; xx <= x2i; xx++) for(int yy = y1i; yy <= y2i; yy++) // only convert inner rectangle to tag clips { if(!OUTBORD(xx,yy) && !SOLID(S(xx,yy))) S(xx, yy)->tag |= clipmask; } if(!nodelete) { deleted_ents.add(e); e.type = NOTUSED; // only delete entity, if it is now fully covered in tag clips thisrun++; } } } } total += thisrun; } while(thisrun || bonus-- > 0); loopi(ssize) loopj(ssize) { sqr *s = S(i,j); if(s->tag & TAGCLIP) s->tag &= ~TAGPLCLIP; } conoutf("changed %d clip entities to tagged clip areas", total); if(total) unsavededits++; } COMMAND(transformclipentities, ""); void reseteditor() // reset only stuff that would cause trouble editing the next map (don't reset selections, for example) { loopk(3) curedittex[k] = -1; pruneundos(0); undolevel = 0; pinnedclosestent = false; } assaultcube-1.2.0.2.1/source/src/entities.cpp000066400000000000000000000537251352165075300207660ustar00rootroot00000000000000// entities.cpp: map entity related functions (pickup etc.) #include "cube.h" VAR(showclips, 0, 1, 1); VARP(showmodelclipping, 0, 0, 1); VARP(showladderentities, 0, 0, 1); VARP(showplayerstarts, 0, 0, 1); VAR(edithideentmask, 0, 0, INT_MAX); vector ents; const char *entmdlnames[] = { "pickups/nades", "pickups/pistolclips", "pickups/ammobox", "pickups/nade", "pickups/health", "pickups/helmet", "pickups/kevlar", "pickups/akimbo", "" // doublenades + I_CLIPS..I_AKIMBO }; void renderent(entity &e) { const char *mdlname = entmdlnames[isitem(e.type) && !(m_lss && e.type == I_GRENADE) ? e.type - I_CLIPS + 1 : 0]; // render double nades in lss float z = (float)(1+sinf(lastmillis/100.0f+e.x+e.y)/20), yaw = lastmillis/10.0f; rendermodel(mdlname, ANIM_MAPMODEL|ANIM_LOOP|ANIM_DYNALLOC, 0, 0, vec(e.x, e.y, z+S(e.x, e.y)->floor + float(e.attr1) / ENTSCALE10), 0, yaw, 0); } void renderclip(int type, int x, int y, float xs, float ys, float h, float elev, float tilt, int shape) { if(xs < 0.05f) xs = 0.05f; if(ys < 0.05f) ys = 0.05f; if(h < 0.1f) h = 0.1f; vec bbmin(x - xs, y - ys, S(x, y)->floor + elev), bbmax(x + xs, y + ys, bbmin.z + h); vec bb[4]; loopi(4) bb[i] = bbmin; bb[2].x = bb[1].x = bbmax.x; bb[2].y = bb[3].y = bbmax.y; vec o(x, y, bbmin.z); float tx = 0, ty = 0, angle = 0; switch(shape & 3) { case 1: tx = tilt; break; // tilt x case 2: ty = tilt; break; // tilt y case 3: angle = PI/4; break; // rotate 45° } loopi(4) { bb[i].sub(o).rotate_around_z(angle); // rotate bb[i].z += bb[i].x * tx + bb[i].y * ty; // tilt bb[i].add(o); } glDisable(GL_TEXTURE_2D); switch(type) { case CLIP: linestyle(1, 0xFF, 0xFF, 0); break; // yellow case MAPMODEL: linestyle(1, 0, 0xFF, 0); break; // green case PLCLIP: linestyle(1, 0xFF, 0, 0xFF); break; // magenta case LADDER: linestyle(1, 0, 0, 0xFF); break; // blue } glBegin(GL_LINES); loopi(16) { int j = ((i + 1) % 8) / 2; glVertex3f(bb[j].x, bb[j].y, bb[j].z + (i > 7 ? h : 0)); } loopi(8) glVertex3f(bb[i / 2].x, bb[i / 2].y, bb[i / 2].z + (i & 1 ? h : 0)); glEnd(); glEnable(GL_TEXTURE_2D); } void rendermapmodels() { loopv(ents) { entity &e = ents[i]; if(e.type==MAPMODEL) { mapmodelinfo *mmi = getmminfo(e.attr2); if(!mmi) continue; rendermodel(mmi->name, ANIM_MAPMODEL|ANIM_LOOP, e.attr4, 0, vec(e.x, e.y, S(e.x, e.y)->floor + mmi->zoff + float(e.attr3) / ENTSCALE5), e.attr6, float(e.attr1) / ENTSCALE10, float(e.attr5) / ENTSCALE10, 10.0f, 0, NULL, NULL, mmi->scale); } } } void renderentarrow(const entity &e, const vec &dir, float radius) { if(radius <= 0) return; float arrowsize = min(radius/8, 0.5f); vec epos(e.x, e.y, e.z); vec target = vec(dir).mul(radius).add(epos), arrowbase = vec(dir).mul(radius - arrowsize).add(epos), spoke; spoke.orthogonal(dir); spoke.normalize(); spoke.mul(arrowsize); glDisable(GL_TEXTURE_2D); // this disables reaction to light, but also emphasizes shadows .. a nice effect, but should be independent glDisable(GL_CULL_FACE); glLineWidth(3); glBegin(GL_LINES); glVertex3fv(epos.v); glVertex3fv(target.v); glEnd(); glBegin(GL_TRIANGLE_FAN); glVertex3fv(target.v); loopi(5) { vec p(spoke); p.rotate(PI2 * i / 4.0f, dir); p.add(arrowbase); glVertex3fv(p.v); } glEnd(); glLineWidth(1); glEnable(GL_CULL_FACE); glEnable(GL_TEXTURE_2D); } void renderentities() { int closest = editmode ? closestent() : -1; if(editmode && !reflecting && !refracting && !stenciling) { static int lastsparkle = 0; if(lastmillis - lastsparkle >= 20) { lastsparkle = lastmillis - (lastmillis%20); loopv(ents) { entity &e = ents[i]; if(e.type==NOTUSED) continue; if(edithideentmask & (1 << (e.type - 1))) continue; vec v(e.x, e.y, e.z); if(vec(v).sub(camera1->o).dot(camdir) < 0) continue; int sc = PART_ECARROT; // use "carrot" for unknown types if(i == closest) { sc = PART_ECLOSEST; // blue } else switch(e.type) { case LIGHT: sc = PART_ELIGHT; break; // white case PLAYERSTART: sc = PART_ESPAWN; break; // green case I_CLIPS: case I_AMMO: case I_GRENADE: sc = PART_EAMMO; break; // red case I_HEALTH: case I_HELMET: case I_ARMOUR: case I_AKIMBO: sc = PART_EPICKUP; break; // yellow case MAPMODEL: case SOUND: sc = PART_EMODEL; break; // magenta case LADDER: case CLIP: case PLCLIP: sc = PART_ELADDER; break; // grey case CTF_FLAG: sc = PART_EFLAG; break; // turquoise default: break; } particle_splash(sc, i == closest ? 14 : 2, i == closest ? 50 : 40, v); } } } loopv(ents) { entity &e = ents[i]; if(isitem(e.type)) { if((!OUTBORD(e.x, e.y) && e.spawned) || editmode) { renderent(e); } } else if(editmode) { if(e.type==CTF_FLAG) { defformatstring(path)("pickups/flags/%s", team_basestring(e.attr2)); rendermodel(path, ANIM_FLAG|ANIM_LOOP, 0, 0, vec(e.x, e.y, (float)S(e.x, e.y)->floor), 0, float(e.attr1) / ENTSCALE10, 0, 120.0f); } else if((e.type == CLIP || e.type == PLCLIP) && showclips && !stenciling) { renderclip(e.type, e.x, e.y, float(e.attr2) / ENTSCALE5, float(e.attr3) / ENTSCALE5, float(e.attr4) / ENTSCALE5, float(e.attr1) / ENTSCALE10, float(e.attr6) / (4 * ENTSCALE10), e.attr7); } else if(e.type == MAPMODEL && showclips && showmodelclipping && !stenciling) { mapmodelinfo *mmi = getmminfo(e.attr2); if(mmi && mmi->h) { renderclip(e.type, e.x, e.y, mmi->rad, mmi->rad, mmi->h, mmi->zoff + float(e.attr3) / ENTSCALE5, 0, 0); } } else if(e.type == LADDER && showladderentities && !stenciling) { renderclip(e.type, e.x, e.y, 0, 0, e.attr1, 0, 0, 3); } else if(e.type == PLAYERSTART && showplayerstarts) { vec o(e.x, e.y, 0); if(!OUTBORD(e.x, e.y)) o.z += S(e.x, e.y)->floor; const char *skin; switch(e.attr2) { case 0: skin = "packages/models/playermodels/CLA/red.jpg"; break; case 1: skin = "packages/models/playermodels/RVSF/blue.jpg"; break; case 100: skin = "packages/models/playermodels/ffaspawn.jpg"; break; default: skin = "packages/models/playermodels/unknownspawn.jpg"; break; } rendermodel("playermodels", ANIM_IDLE, -(int)textureload(skin)->id, 1.5f, o, 0, e.attr1 / ENTSCALE10 + 90, 0); } } if(editmode && i == closest && !stenciling) { switch(e.type) { case PLAYERSTART: { glColor3f(0, 1, 1); vec dir(0, -1, 0); dir.rotate_around_z(float(e.attr1) / ENTSCALE10 * RAD); renderentarrow(e, dir, 4); glColor3f(1, 1, 1); } default: break; } } } if(m_flags && !editmode) loopi(2) { flaginfo &f = flaginfos[i]; switch(f.state) { case CTFF_STOLEN: if(f.actor && f.actor != player1) { if(OUTBORD(f.actor->o.x, f.actor->o.y)) break; defformatstring(path)("pickups/flags/small_%s%s", m_ktf ? "" : team_basestring(i), m_htf ? "_htf" : m_ktf ? "ktf" : ""); rendermodel(path, ANIM_FLAG|ANIM_START|ANIM_DYNALLOC, 0, 0, vec(f.actor->o).add(vec(0, 0, 0.3f+(sinf(lastmillis/100.0f)+1)/10)), 0, lastmillis/2.5f, 0, 120.0f); } break; case CTFF_INBASE: if(!clentstats.flags[i]) break; case CTFF_DROPPED: { if(OUTBORD(f.pos.x, f.pos.y)) break; entity &e = *f.flagent; defformatstring(path)("pickups/flags/%s%s", m_ktf ? "" : team_basestring(i), m_htf ? "_htf" : m_ktf ? "ktf" : ""); if(f.flagent->spawned) rendermodel(path, ANIM_FLAG|ANIM_LOOP, 0, 0, vec(f.pos.x, f.pos.y, f.state==CTFF_INBASE ? (float)S(int(f.pos.x), int(f.pos.y))->floor : f.pos.z), 0, float(e.attr1) / ENTSCALE10, 0, 120.0f); break; } case CTFF_IDLE: break; } } } // these two functions are called when the server acknowledges that you really // picked up the item (in multiplayer someone may grab it before you). void pickupeffects(int n, playerent *d) { if(!ents.inrange(n)) return; entity &e = ents[n]; e.spawned = false; if(!d) return; d->pickup(e.type); if (m_lss && e.type == I_GRENADE) d->pickup(e.type); // get 2 itemstat *is = d->itemstats(e.type); if(d!=player1 && d->type!=ENT_BOT) return; if(is) { if(d==player1) { audiomgr.playsoundc(is->sound); /* onPickup arg1 legend: 0 = pistol clips 1 = ammo box 2 = grenade 3 = health pack 4 = helmet 5 = armour 6 = akimbo */ if(identexists("onPickup")) { itemstat *tmp = NULL; switch(e.type) { case I_CLIPS: tmp = &ammostats[GUN_PISTOL]; break; case I_AMMO: tmp = &ammostats[player1->primary]; break; case I_GRENADE: tmp = &ammostats[GUN_GRENADE]; break; case I_AKIMBO: tmp = &ammostats[GUN_AKIMBO]; break; case I_HEALTH: case I_HELMET: case I_ARMOUR: tmp = &powerupstats[e.type-I_HEALTH]; break; default: break; } if(tmp) exechook(HOOK_SP, "onPickup", "%d %d", e.type - 3, m_lss && e.type == I_GRENADE ? 2 : tmp->add); } } else audiomgr.playsound(is->sound, d); } weapon *w = NULL; switch(e.type) { case I_AKIMBO: w = d->weapons[GUN_AKIMBO]; break; case I_CLIPS: w = d->weapons[GUN_PISTOL]; break; case I_AMMO: w = d->primweap; break; case I_GRENADE: w = d->weapons[GUN_GRENADE]; break; } if(w) w->onammopicked(); } // these functions are called when the client touches the item extern int lastspawn; void trypickup(int n, playerent *d) { entity &e = ents[n]; switch(e.type) { default: if( d->canpickup(e.type) && lastmillis > e.lastmillis + 250 && lastmillis > lastspawn + 500 ) { if(d->type==ENT_PLAYER) addmsg(SV_ITEMPICKUP, "ri", n); else if(d->type==ENT_BOT && serverpickup(n, -1)) pickupeffects(n, d); e.lastmillis = lastmillis; } break; case LADDER: if(!d->crouching) d->onladder = true; break; } } void trypickupflag(int flag, playerent *d) { if(d==player1) { flaginfo &f = flaginfos[flag]; flaginfo &of = flaginfos[team_opposite(flag)]; if(f.state == CTFF_STOLEN) return; bool own = flag == team_base(d->team); if(m_ctf) { if(own) // it's the own flag { if(f.state == CTFF_DROPPED) flagreturn(flag); else if(f.state == CTFF_INBASE && of.state == CTFF_STOLEN && of.actor == d && of.ack) flagscore(of.team); } else flagpickup(flag); } else if(m_htf) { if(own) { flagpickup(flag); } else { if(f.state == CTFF_DROPPED) flagscore(f.team); // may not count! } } else if(m_ktf) { if(f.state != CTFF_INBASE) return; flagpickup(flag); } } } void checkitems(playerent *d) { if(editmode || d->state!=CS_ALIVE) return; d->onladder = false; float eyeheight = d->eyeheight; loopv(ents) { entity &e = ents[i]; if(e.type==NOTUSED) continue; if(e.type==LADDER) { if(OUTBORD(e.x, e.y)) continue; vec v(e.x, e.y, d->o.z); float dist1 = d->o.dist(v); float dist2 = d->o.z - (S(e.x, e.y)->floor+eyeheight); if(dist1<1.5f && dist2floor+eyeheight); if(isitem(e.type)) v.z += float(e.attr1) / ENTSCALE10; if(d->o.dist(v)<2.5f) trypickup(i, d); } if(m_flags) loopi(2) { flaginfo &f = flaginfos[i]; entity &e = *f.flagent; if(!e.spawned || !f.ack || (f.state == CTFF_INBASE && !clentstats.flags[i])) continue; if(OUTBORD(f.pos.x, f.pos.y)) continue; if(f.state==CTFF_DROPPED) // 3d collision for dropped ctf flags { if(objcollide(d, f.pos, 2.5f, 8.0f)) trypickupflag(i, d); } else // simple 2d collision { vec v = f.pos; v.z = S(int(v.x), int(v.y))->floor + eyeheight; if(d->o.dist(v)<2.5f) trypickupflag(i, d); } } } void resetpickups(int type) { loopv(ents) if(type < 0 || type == ents[i].type) ents[i].spawned = false; if(m_noitemsnade || m_pistol) { loopv(ents) ents[i].transformtype(gamemode); } } void setpickupspawn(int i, bool on) { if(ents.inrange(i)) { ents[i].spawned = on; if (on) ents[i].lastmillis = lastmillis; // to control trypickup spam } } SVARFP(nextprimary, guns[GUN_ASSAULT].modelname, { int n = getlistindex(nextprimary, gunnames, true, -1); switch(n) { default: conoutf("\"%s\" is not a valid primary weapon", nextprimary); n = GUN_ASSAULT; case GUN_CARBINE: case GUN_SHOTGUN: case GUN_SUBGUN: case GUN_SNIPER: case GUN_ASSAULT: player1->setnextprimary(n); addmsg(SV_PRIMARYWEAP, "ri", player1->nextprimweap->type); nextprimary = exchangestr(nextprimary, gunnames[player1->nextprimweap->type]); break; } }); // flag ent actions done by the local player int flagdropmillis = 0; void flagpickup(int fln) { if(flagdropmillis && flagdropmillis>lastmillis) return; flaginfo &f = flaginfos[fln]; int action = f.state == CTFF_INBASE ? FA_STEAL : FA_PICKUP; f.flagent->spawned = false; f.state = CTFF_STOLEN; f.actor = player1; // do this although we don't know if we picked the flag to avoid getting it after a possible respawn f.actor_cn = getclientnum(); f.ack = false; addmsg(SV_FLAGACTION, "rii", action, f.team); } void tryflagdrop(bool manual) { loopi(2) { flaginfo &f = flaginfos[i]; if(f.state==CTFF_STOLEN && f.actor==player1) { f.flagent->spawned = false; f.state = CTFF_DROPPED; f.pos.x = floor(player1->o.x + 0.5f); f.pos.y = floor(player1->o.y + 0.5f); f.pos.z = floor(player1->o.z + 0.5f); f.ack = false; flagdropmillis = lastmillis+3000; addmsg(SV_FLAGACTION, "rii", manual ? FA_DROP : FA_LOST, f.team); } } } void flagreturn(int fln) { flaginfo &f = flaginfos[fln]; f.flagent->spawned = false; f.ack = false; addmsg(SV_FLAGACTION, "rii", FA_RETURN, f.team); } void flagscore(int fln) { flaginfo &f = flaginfos[fln]; f.ack = false; addmsg(SV_FLAGACTION, "rii", FA_SCORE, f.team); } // flag ent actions from the net void flagstolen(int flag, int act) { playerent *actor = getclient(act); flaginfo &f = flaginfos[flag]; f.actor = actor; // could be NULL if we just connected f.actor_cn = act; f.flagent->spawned = false; f.ack = true; } void flagdropped(int flag, float x, float y, float z) { flaginfo &f = flaginfos[flag]; if(OUTBORD(x, y)) return; // valid pos bounceent p; p.plclipped = true; p.rotspeed = 0.0f; p.o.x = x; p.o.y = y; p.o.z = z; p.vel.z = -0.8f; p.aboveeye = 1.0f; p.eyeheight = p.maxeyeheight = 0.1f; p.radius = 0.1f; bool oldcancollide = false; if(f.actor) { oldcancollide = f.actor->cancollide; f.actor->cancollide = false; // avoid collision with owner } loopi(100) // perform physics steps { moveplayer(&p, 10, true, 50); if(p.stuck) break; } if(p.o.z < waterlevel) { p.aboveeye = 6.7f; loopirev((waterlevel - p.o.z) / 0.2f + 1) { p.o.z += 0.2f; if(p.o.z > z) p.radius = 1.0f; // don't float through small holes in the ceiling if(collide(&p)) break; } if(p.o.z > waterlevel) p.o.z = waterlevel; } if(f.actor) f.actor->cancollide = oldcancollide; // restore settings f.pos.x = floor(p.o.x + 0.5f); f.pos.y = floor(p.o.y + 0.5f); f.pos.z = floor(p.o.z * 5 + 0.5f) / 5; f.flagent->spawned = true; f.ack = true; } void flaginbase(int flag) { flaginfo &f = flaginfos[flag]; f.actor = NULL; f.actor_cn = -1; f.pos = vec(f.flagent->x, f.flagent->y, f.flagent->z); f.flagent->spawned = true; f.ack = true; } void flagidle(int flag) { flaginbase(flag); flaginfos[flag].flagent->spawned = false; } void entstats_(void) { entitystats_s es; calcentitystats(es, NULL, 0); int clipents = 0, xmodels = 0, xsounds = 0; loopv(ents) { entity &e = ents[i]; if(e.type == MAPMODEL) { mapmodelinfo *mmi = getmminfo(e.attr2); if(!mmi) xmodels++; if(mmi && mmi->h) clipents++; } else if(e.type == SOUND) { if(!mapconfigdata.mapsoundlines.inrange(e.attr1)) xsounds++; } } string txt = "", clips = ""; loopi(MAXENTTYPES) if(es.entcnt[i]) switch(i) { case MAPMODEL: conoutf(" %d %s, %d clipped, %s%d unconfigured", es.entcnt[i], entnames[i], clipents, xmodels ? "\f3" : "", xmodels); break; case SOUND: conoutf(" %d %s, %s%d unconfigured", es.entcnt[i], entnames[i], xsounds ? "\f3" : "", xsounds); break; case PLAYERSTART: conoutf(" %d %s, %d CLA, %d RVSF, %d FFA%c \f3unknown %d", es.entcnt[i], entnames[i], es.spawns[0], es.spawns[1], es.spawns[2], es.unknownspawns ? ',' : '\0', es.unknownspawns); break; case CTF_FLAG: conoutf(" %d %s, %d CLA, %d RVSF%c \f3unknown %d", es.entcnt[i], entnames[i], es.flags[0], es.flags[1], es.unknownflags ? ',' : '\0', es.unknownflags); break; case CLIP: case PLCLIP: concatformatstring(clips, ", %d %s", es.entcnt[i], entnames[i]); break; case NOTUSED: conoutf(" %d deleted", es.entcnt[i]); break; default: if(isitem(i)) concatformatstring(txt, ", %d %s", es.entcnt[i], entnames[i]); else conoutf(" %d %s", es.entcnt[i], entnames[i]); break; } if(*clips) conoutf(" %s", clips + 2); if(es.pickups) { conoutf(" %d pickups:%s", es.pickups, txt + 1); *txt = '\0'; loopi(LARGEST_FACTOR + 1) concatformatstring(txt, " %d", es.pickupdistance[i]); conoutf(" pickupdistance:%s", txt); } if(es.entcnt[CTF_FLAG]) conoutf(" flag distance: %d", es.flagentdistance); conoutf(" map capabilities: has ffa spawns %d, has team spawns %d, has flags %d", es.hasffaspawns ? 1 : 0, es.hasteamspawns ? 1 : 0, es.hasflags ? 1 : 0); conoutf("total entities: %d", ents.length()); intret(xmodels + xsounds); } COMMANDN(entstats, entstats_, ""); vector changedents; int lastentsync = 0; void syncentchanges(bool force) { if(lastmillis - lastentsync < 1000 && !force) return; loopv(changedents) if(ents.inrange(changedents[i])) { entity &e = ents[changedents[i]]; addmsg(SV_EDITENT, "ri9i3", changedents[i], e.type, e.x, e.y, e.z, e.attr1, e.attr2, e.attr3, e.attr4, e.attr5, e.attr6, e.attr7); } changedents.setsize(0); lastentsync = lastmillis; } void clampentityattributes(persistent_entity &e) { if(e.type < MAXENTTYPES) { int c; #define CLAMPATTR(x) \ c = entwraparound[e.type][x - 1]; \ if(c > 0) e.attr##x = (e.attr##x % c + c) % c; /* fold value into range 0..c */ \ else if(c < 0) e.attr##x = e.attr##x % (-c) /* fold value into range -c..c */ CLAMPATTR(1); CLAMPATTR(2); CLAMPATTR(3); CLAMPATTR(4); CLAMPATTR(5); CLAMPATTR(6); CLAMPATTR(7); } } const char *formatentityattributes(const persistent_entity &e, bool withcomma) { static string res; int t = e.type < MAXENTTYPES ? e.type : 0; const char *c = withcomma ? "," : ""; #define AA(x) floatstr(float(e.attr##x) / entscale[t][x - 1], true) formatstring(res)("%s%s %s%s %s%s %s%s %s%s %s%s %s", AA(1), c, AA(2), c, AA(3), c, AA(4), c, AA(5), c, AA(6), c, AA(7)); #undef AA return res; } assaultcube-1.2.0.2.1/source/src/entity.h000066400000000000000000000512151352165075300201130ustar00rootroot00000000000000enum // static entity types { NOTUSED = 0, // entity slot not in use in map (usually seen at deleted entities) LIGHT, // lightsource, attr1 = radius, attr2 = intensity (or attr2..4 = r-g-b) PLAYERSTART, // attr1 = angle, attr2 = team I_CLIPS, I_AMMO, I_GRENADE, // attr1 = elevation I_HEALTH, I_HELMET, I_ARMOUR, I_AKIMBO, MAPMODEL, // attr1 = angle, attr2 = idx, attr3 = elevation, attr4 = texture, attr5 = pitch, attr6 = roll CARROT, // attr1 = tag, attr2 = type LADDER, // attr1 = height CTF_FLAG, // attr1 = angle, attr2 = red/blue SOUND, // attr1 = idx, attr2 = radius, attr3 = size, attr4 = volume CLIP, // attr1 = elevation, attr2 = xradius, attr3 = yradius, attr4 = height, attr6 = slope, attr7 = shape PLCLIP, // attr1 = elevation, attr2 = xradius, attr3 = yradius, attr4 = height, attr6 = slope, attr7 = shape DUMMYENT, // temporary entity without any function - will not be saved to map files, used to mark positions and for scripting MAXENTTYPES }; extern short entwraparound[MAXENTTYPES][7]; extern uchar entscale[MAXENTTYPES][7]; #define ENTSCALE10 10 #define ENTSCALE5 5 enum {MAP_IS_BAD, MAP_IS_EDITABLE, MAP_IS_GOOD}; extern const char *entnames[]; #define isitem(i) ((i) >= I_CLIPS && (i) <= I_AKIMBO) struct persistent_entity // map entity { short x, y, z; // cube aligned position short attr1; uchar type; // type is one of the above uchar attr2, attr3, attr4; short attr5; char attr6; unsigned char attr7; persistent_entity(short x, short y, short z, uchar type, short attr1, uchar attr2, uchar attr3, uchar attr4) : x(x), y(y), z(z), attr1(attr1), type(type), attr2(attr2), attr3(attr3), attr4(attr4), attr5(0), attr6(0), attr7(0) {} persistent_entity() {} }; struct entity : persistent_entity { bool spawned; //the dynamic states of a map entity int lastmillis; entity(short x, short y, short z, uchar type, short attr1, uchar attr2, uchar attr3, uchar attr4) : persistent_entity(x, y, z, type, attr1, attr2, attr3, attr4), spawned(false) {} entity() {} bool fitsmode(int gamemode) { return !m_noitems && isitem(type) && !(m_noitemsnade && type!=I_GRENADE) && !(m_pistol && type==I_AMMO); } void transformtype(int gamemode) { if(m_noitemsnade && type==I_CLIPS) type = I_GRENADE; else if(m_pistol && ( type==I_AMMO || type==I_GRENADE )) type = I_CLIPS; } }; enum { GUN_KNIFE = 0, GUN_PISTOL, GUN_CARBINE, GUN_SHOTGUN, GUN_SUBGUN, GUN_SNIPER, GUN_ASSAULT, GUN_CPISTOL, GUN_GRENADE, GUN_AKIMBO, NUMGUNS }; #define valid_weapon(g) ((g) >= GUN_KNIFE && (g) < NUMGUNS) #define reloadable_gun(g) ((g) != GUN_KNIFE && (g) != GUN_GRENADE) #define SGRAYS 21 #define SGDMGTOTAL 90 #define SGDMGBONUS 65 #define SGDMGDISTB 50 #define SGCCdmg 500 #define SGCCbase 0 #define SGCCrange 40 #define SGCMdmg 375 #define SGCMbase 25 #define SGCMrange 60 #define SGCOdmg 125 #define SGCObase 45 #define SGCOrange 75 #define SGMAXDMGABS 105 #define SGMAXDMGLOC 84 #define EXPDAMRAD 10 struct itemstat { int add, start, max, sound; }; extern itemstat ammostats[NUMGUNS]; extern itemstat powerupstats[I_ARMOUR-I_HEALTH+1]; struct guninfo { char modelname[23], title[42]; short sound, reload, reloadtime, attackdelay, damage, piercing, projspeed, part, spread, recoil, magsize, mdl_kick_rot, mdl_kick_back, recoilincrease, recoilbase, maxrecoil, recoilbackfade, pushfactor; bool isauto; }; extern guninfo guns[NUMGUNS]; extern const char *gunnames[]; static inline int reloadtime(int gun) { return guns[gun].reloadtime; } static inline int attackdelay(int gun) { return guns[gun].attackdelay; } static inline int magsize(int gun) { return guns[gun].magsize; } /** roseta stone: 0000, 0001, 0010, 0011, 0100, 0101, 0110 */ enum { TEAM_CLA = 0, TEAM_RVSF, TEAM_CLA_SPECT, TEAM_RVSF_SPECT, TEAM_SPECT, TEAM_NUM, TEAM_ANYACTIVE }; extern const char *teamnames[]; extern const char *teamnames_s[]; extern const char *killmessages[2][NUMGUNS]; #define TEAM_VOID TEAM_NUM #define isteam(a,b) (m_teammode && (a) == (b)) #define team_opposite(o) (team_isvalid(o) && (o) < TEAM_SPECT ? (o) ^ 1 : TEAM_SPECT) #define team_base(t) ((t) & 1) #define team_basestring(t) ((t) == 1 ? teamnames[1] : ((t) == 0 ? teamnames[0] : "SPECT")) #define team_isvalid(t) ((int(t)) >= 0 && (t) < TEAM_NUM) #define team_isactive(t) ((t) == TEAM_CLA || (t) == TEAM_RVSF) #define team_isspect(t) ((t) > TEAM_RVSF && (t) < TEAM_VOID) #define team_group(t) ((t) == TEAM_SPECT ? TEAM_SPECT : team_base(t)) #define team_tospec(t) ((t) == TEAM_SPECT ? TEAM_SPECT : team_base(t) + TEAM_CLA_SPECT - TEAM_CLA) // note: team_isactive and team_base can/should be used to check the limits for arrays of size '2' static inline const char *team_string(int t, bool abbr = false) { const char **n = abbr ? teamnames_s : teamnames; return team_isvalid(t) ? n[t] : n[TEAM_NUM + 1]; } enum { ENT_PLAYER = 0, ENT_BOT, ENT_CAMERA, ENT_BOUNCE }; enum { CS_ALIVE = 0, CS_DEAD, CS_SPAWNING, CS_LAGGED, CS_EDITING, CS_SPECTATE }; enum { CR_DEFAULT = 0, CR_ADMIN }; enum { SM_NONE = 0, SM_DEATHCAM, SM_FOLLOW1ST, SM_FOLLOW3RD, SM_FOLLOW3RD_TRANSPARENT, SM_FLY, SM_OVERVIEW, SM_NUM }; class worldobject { public: virtual ~worldobject() {}; }; class physent : public worldobject { public: vec o, vel, vel_t; // origin, velocity vec deltapos, newpos; // movement interpolation float yaw, pitch, roll; // used as vec in one place float pitchvel; float maxspeed; // cubes per second, 24 for player int timeinair; // used for fake gravity float radius, eyeheight, maxeyeheight, aboveeye; // bounding box size bool inwater; bool onfloor, onladder, jumpnext, crouching, crouchedinair, trycrouch, cancollide, stuck, scoping, shoot; int lastjump; float lastjumpheight; int lastsplash; char move, strafe; uchar state, type; float eyeheightvel; int last_pos; physent() : o(0, 0, 0), deltapos(0, 0, 0), newpos(0, 0, 0), yaw(270), pitch(0), roll(0), pitchvel(0), crouching(false), crouchedinair(false), trycrouch(false), cancollide(true), stuck(false), scoping(false), shoot(false), lastjump(0), lastjumpheight(200), lastsplash(0), state(CS_ALIVE), last_pos(0) { reset(); } virtual ~physent() {} void resetinterp() { newpos = o; newpos.z -= eyeheight; deltapos = vec(0, 0, 0); } void reset() { vel.x = vel.y = vel.z = eyeheightvel = vel_t.x = vel_t.y = vel_t.z = 0.0f; move = strafe = 0; timeinair = lastjump = lastsplash = 0; onfloor = onladder = inwater = jumpnext = crouching = crouchedinair = trycrouch = stuck = false; last_pos = 0; } virtual void oncollision() {} virtual void onmoved(const vec &dist) {} }; class dynent : public physent // animated ent { public: bool k_left, k_right, k_up, k_down; // see input code animstate prev[2], current[2]; // md2's need only [0], md3's need both for the lower&upper model int lastanimswitchtime[2]; void *lastmodel[2]; int lastrendered; void stopmoving() { k_left = k_right = k_up = k_down = jumpnext = false; move = strafe = 0; } void resetanim() { loopi(2) { prev[i].reset(); current[i].reset(); lastanimswitchtime[i] = -1; lastmodel[i] = NULL; } lastrendered = 0; } void reset() { physent::reset(); stopmoving(); } dynent() { reset(); resetanim(); } virtual ~dynent() {} }; #define MAXNAMELEN 15 class bounceent; #define POSHIST_SIZE 7 struct poshist { int nextupdate, curpos, numpos; vec pos[POSHIST_SIZE]; poshist() : nextupdate(0) { reset(); } const int size() const { return numpos; } void reset() { curpos = 0; numpos = 0; } void addpos(const vec &o) { pos[curpos] = o; curpos++; if(curpos>=POSHIST_SIZE) curpos = 0; if(numpos= 4.0f) addpos(o); nextupdate = lastmillis + 100; } }; class playerstate { public: int health, armour; int primary, nextprimary; int gunselect; bool akimbo; int ammo[NUMGUNS], mag[NUMGUNS], gunwait[NUMGUNS]; int pstatshots[NUMGUNS], pstatdamage[NUMGUNS]; playerstate() : armour(0), primary(GUN_ASSAULT), nextprimary(GUN_ASSAULT), akimbo(false) {} virtual ~playerstate() {} void resetstats() { loopi(NUMGUNS) pstatshots[i] = pstatdamage[i] = 0; } itemstat *itemstats(int type) { switch(type) { case I_CLIPS: return &ammostats[GUN_PISTOL]; case I_AMMO: return &ammostats[primary]; case I_GRENADE: return &ammostats[GUN_GRENADE]; case I_AKIMBO: return &ammostats[GUN_AKIMBO]; case I_HEALTH: case I_HELMET: case I_ARMOUR: return &powerupstats[type - I_HEALTH]; default: return NULL; } } bool canpickup(int type) { switch(type) { case I_CLIPS: return ammo[akimbo ? GUN_AKIMBO : GUN_PISTOL] is.max) v = is.max; } void pickup(int type) { switch(type) { case I_CLIPS: additem(ammostats[GUN_PISTOL], ammo[GUN_PISTOL]); additem(ammostats[GUN_AKIMBO], ammo[GUN_AKIMBO]); break; case I_AMMO: additem(ammostats[primary], ammo[primary]); break; case I_GRENADE: additem(ammostats[GUN_GRENADE], mag[GUN_GRENADE]); break; case I_HEALTH: additem(powerupstats[type-I_HEALTH], health); break; case I_HELMET: case I_ARMOUR: additem(powerupstats[type-I_HEALTH], armour); break; case I_AKIMBO: akimbo = true; mag[GUN_AKIMBO] = guns[GUN_AKIMBO].magsize; additem(ammostats[GUN_AKIMBO], ammo[GUN_AKIMBO]); break; } } void respawn() { health = 100; armour = 0; gunselect = GUN_PISTOL; akimbo = false; loopi(NUMGUNS) ammo[i] = mag[i] = gunwait[i] = 0; ammo[GUN_KNIFE] = mag[GUN_KNIFE] = 1; } virtual void spawnstate(int gamemode) { if(m_pistol) primary = GUN_PISTOL; else if(m_osok) primary = GUN_SNIPER; else if(m_lss) primary = GUN_KNIFE; else primary = nextprimary; if(!m_nopistol) { ammo[GUN_PISTOL] = ammostats[GUN_PISTOL].start-magsize(GUN_PISTOL);//ammostats[GUN_PISTOL].max-magsize(GUN_PISTOL); mag[GUN_PISTOL] = magsize(GUN_PISTOL); } if(!m_noprimary) { ammo[primary] = ammostats[primary].start-magsize(primary); mag[primary] = magsize(primary); } gunselect = primary; if(m_osok) health = 1; if(m_lms) // Survivor && Team-Survivor : 2010nov19 { health = 100; armour = 100; ammo[GUN_GRENADE] = 2; } } // just subtract damage here, can set death, etc. later in code calling this int dodamage(int damage, int gun) { guninfo gi = guns[gun]; if(damage == INT_MAX) { damage = health; armour = health = 0; return damage; } // 4-level armour - tiered approach: 16%, 33%, 37%, 41% // Please update ./ac_website/htdocs/docs/introduction.html if this changes. int armoursection = 0; int ad = damage; if(armour > 25) armoursection = 1; if(armour > 50) armoursection = 2; if(armour > 75) armoursection = 3; switch(armoursection) { case 0: ad = (int) (16.0f/25.0f * armour); break; // 16 case 1: ad = (int) (17.0f/25.0f * armour) - 1; break; // 33 case 2: ad = (int) (4.0f/25.0f * armour) + 25; break; // 37 case 3: ad = (int) (4.0f/25.0f * armour) + 25; break; // 41 default: break; } //ra - reduced armor //rd - reduced damage int ra = (int) (ad * damage/100.0f); int rd = ra-(ra*(gi.piercing/100.0f)); //Who cares about rounding errors anyways? armour -= ra; damage -= rd; health -= damage; return damage; } }; #ifndef STANDALONE #define HEADSIZE 0.4f #define ROLLMOVMAX 20 #define ROLLMOVDEF 0 #define ROLLEFFMAX 30 #define ROLLEFFDEF 0 class playerent : public dynent, public playerstate { private: int curskin, nextskin[2]; public: int clientnum, lastupdate, plag, ping; enet_uint32 address; int lifesequence; // sequence id for each respawn, used in damage test int frags, flagscore, deaths, points, tks; int lastaction, lastmove, lastpain, lastvoicecom, lastdeath; int clientrole; bool attacking; string name; int team; int weaponchanging; int nextweapon; // weapon we switch to int spectatemode, followplayercn; int eardamagemillis; float maxroll, maxrolleffect, movroll, effroll; // roll added by movement and damage bool allowmove() { return state!=CS_DEAD || spectatemode==SM_FLY; } weapon *weapons[NUMGUNS]; weapon *prevweaponsel, *weaponsel, *nextweaponsel, *primweap, *nextprimweap, *lastattackweapon; poshist history; // Previous stored locations of this player const char *skin_noteam, *skin_cla, *skin_rvsf; float deltayaw, deltapitch, newyaw, newpitch; int smoothmillis; vec head; bool ignored, muted; bool nocorpse; playerent() : curskin(0), clientnum(-1), lastupdate(0), plag(0), ping(0), address(0), lifesequence(0), frags(0), flagscore(0), deaths(0), points(0), tks(0), lastpain(0), lastvoicecom(0), lastdeath(0), clientrole(CR_DEFAULT), team(TEAM_SPECT), spectatemode(SM_NONE), eardamagemillis(0), maxroll(ROLLMOVDEF), maxrolleffect(ROLLEFFDEF), movroll(0), effroll(0), prevweaponsel(NULL), weaponsel(NULL), nextweaponsel(NULL), primweap(NULL), nextprimweap(NULL), lastattackweapon(NULL), smoothmillis(-1), head(-1, -1, -1), ignored(false), muted(false), nocorpse(false) { type = ENT_PLAYER; name[0] = 0; maxeyeheight = 4.5f; aboveeye = 0.7f; radius = 1.1f; maxspeed = 16.0f; skin_noteam = skin_cla = skin_rvsf = NULL; loopi(2) nextskin[i] = 0; respawn(); } virtual ~playerent() { extern void removebounceents(playerent *owner); extern void removedynlights(physent *owner); extern void zapplayerflags(playerent *owner); extern void cleanplayervotes(playerent *owner); extern physent *camera1; extern void spectatemode(int mode); removebounceents(this); audiomgr.detachsounds(this); removedynlights(this); zapplayerflags(this); cleanplayervotes(this); if(this==camera1) spectatemode(SM_FOLLOW1ST); } void damageroll(float damage) { damage *= effroll > 0.001f || (effroll > -0.001f && rnd(2)) ? 2.0f : -2.0f; // give player a kick effroll = clamp(effroll + damage, -maxrolleffect, maxrolleffect); } void hitpush(int damage, const vec &dir, playerent *actor, int gun) { if(!valid_weapon(gun)) return; vec push(dir); push.mul(damage/100.0f*guns[gun].pushfactor); vel.add(push); extern int lastmillis; if(gun==GUN_GRENADE && damage > 50) eardamagemillis = lastmillis+damage*100; } void resetspec() { spectatemode = SM_NONE; } void respawn() { dynent::reset(); playerstate::respawn(); history.reset(); if(weaponsel) weaponsel->reset(); lastaction = 0; lastattackweapon = NULL; attacking = false; extern int lastmillis; weaponchanging = lastmillis - weapons[gunselect]->weaponchangetime/2; // 2011jan16:ft: for a little no-shoot after spawn resetspec(); eardamagemillis = 0; eyeheight = maxeyeheight; curskin = nextskin[team_base(team)]; nocorpse = false; } void spawnstate(int gamemode) { playerstate::spawnstate(gamemode); prevweaponsel = weaponsel = weapons[gunselect]; primweap = weapons[primary]; nextprimweap = weapons[nextprimary]; curskin = nextskin[team_base(team)]; } void selectweapon(int w) { if (weaponsel) prevweaponsel = weaponsel; weaponsel = weapons[(gunselect = w)]; if (!prevweaponsel) prevweaponsel = weaponsel; } void setprimary(int w) { primweap = weapons[(primary = w)]; } void setnextprimary(int w) { nextprimweap = weapons[(nextprimary = w)]; } bool isspectating() { return state==CS_SPECTATE || (state==CS_DEAD && spectatemode > SM_NONE); } void weaponswitch(weapon *w) { if(!w) return; extern int lastmillis; weaponsel->ondeselecting(); weaponchanging = lastmillis; nextweaponsel = w; w->onselecting(); } int skin(int t = -1) { return nextskin[team_base(t < 0 ? team : t)]; } void setskin(int t, int s) { const int maxskin[2] = { 4, 6 }; t = team_base(t < 0 ? team : t); nextskin[t] = iabs(s) % maxskin[t]; } }; class CBot; class botent : public playerent { public: // Added by Rick CBot *pBot; // Only used if this is a bot, points to the bot class if we are the host, // for other clients its NULL // End add by Rick playerent *enemy; // monster wants to kill this entity // Added by Rick: targetpitch float targetpitch; // monster wants to look in this direction // End add float targetyaw; // monster wants to look in this direction botent() : pBot(NULL), enemy(NULL) { type = ENT_BOT; } ~botent() { } int deaths() { return lifesequence; } }; #endif //#ifndef STANDALONE // flag-mode entities enum { CTFF_INBASE = 0, CTFF_STOLEN, CTFF_DROPPED, CTFF_IDLE }; struct flaginfo { int team; entity *flagent; int actor_cn; playerent *actor; vec pos; int state; // one of CTFF_* bool ack; flaginfo() : flagent(0), actor(0), state(CTFF_INBASE), ack(false) {} }; // nades, gibs enum { BT_NONE, BT_NADE, BT_GIB }; class bounceent : public physent { public: int millis, timetolive, bouncetype; // see enum above float rotspeed; bool plclipped; playerent *owner; bounceent() : bouncetype(BT_NONE), rotspeed(1.0f), plclipped(false), owner(NULL) { type = ENT_BOUNCE; maxspeed = 40; radius = 0.2f; eyeheight = maxeyeheight = 0.3f; aboveeye = 0.0f; } virtual ~bounceent() {} bool isalive(int lastmillis) { return lastmillis - millis < timetolive; } virtual void destroy() {} virtual bool applyphysics() { return true; } }; struct hitmsg { int target, lifesequence, info; ivec dir; }; class grenadeent : public bounceent { public: bool local; int nadestate; float distsincebounce; grenadeent(playerent *owner, int millis = 0); ~grenadeent(); void activate(const vec &from, const vec &to); void _throw(const vec &from, const vec &vel); void explode(); void splash(); virtual void destroy(); virtual bool applyphysics(); void moveoutsidebbox(const vec &direction, playerent *boundingbox); void oncollision(); void onmoved(const vec &dist); }; enum {MD_FRAGS = 0, MD_DEATHS, END_MDS}; struct medalsst {bool assigned; int cn; int item;}; assaultcube-1.2.0.2.1/source/src/ge25519_base.data000066400000000000000000005105531352165075300212610ustar00rootroot00000000000000{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x1a, 0xd5, 0x25, 0x8f, 0x60, 0x2d, 0x56, 0xc9, 0xb2, 0xa7, 0x25, 0x95, 0x60, 0xc7, 0x2c, 0x69, 0x5c, 0xdc, 0xd6, 0xfd, 0x31, 0xe2, 0xa4, 0xc0, 0xfe, 0x53, 0x6e, 0xcd, 0xd3, 0x36, 0x69, 0x21}} , {{0x58, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66}}}, {{{0x0e, 0xce, 0x43, 0x28, 0x4e, 0xa1, 0xc5, 0x83, 0x5f, 0xa4, 0xd7, 0x15, 0x45, 0x8e, 0x0d, 0x08, 0xac, 0xe7, 0x33, 0x18, 0x7d, 0x3b, 0x04, 0x3d, 0x6c, 0x04, 0x5a, 0x9f, 0x4c, 0x38, 0xab, 0x36}} , {{0xc9, 0xa3, 0xf8, 0x6a, 0xae, 0x46, 0x5f, 0x0e, 0x56, 0x51, 0x38, 0x64, 0x51, 0x0f, 0x39, 0x97, 0x56, 0x1f, 0xa2, 0xc9, 0xe8, 0x5e, 0xa2, 0x1d, 0xc2, 0x29, 0x23, 0x09, 0xf3, 0xcd, 0x60, 0x22}}}, {{{0x5c, 0xe2, 0xf8, 0xd3, 0x5f, 0x48, 0x62, 0xac, 0x86, 0x48, 0x62, 0x81, 0x19, 0x98, 0x43, 0x63, 0x3a, 0xc8, 0xda, 0x3e, 0x74, 0xae, 0xf4, 0x1f, 0x49, 0x8f, 0x92, 0x22, 0x4a, 0x9c, 0xae, 0x67}} , {{0xd4, 0xb4, 0xf5, 0x78, 0x48, 0x68, 0xc3, 0x02, 0x04, 0x03, 0x24, 0x67, 0x17, 0xec, 0x16, 0x9f, 0xf7, 0x9e, 0x26, 0x60, 0x8e, 0xa1, 0x26, 0xa1, 0xab, 0x69, 0xee, 0x77, 0xd1, 0xb1, 0x67, 0x12}}}, {{{0x70, 0xf8, 0xc9, 0xc4, 0x57, 0xa6, 0x3a, 0x49, 0x47, 0x15, 0xce, 0x93, 0xc1, 0x9e, 0x73, 0x1a, 0xf9, 0x20, 0x35, 0x7a, 0xb8, 0xd4, 0x25, 0x83, 0x46, 0xf1, 0xcf, 0x56, 0xdb, 0xa8, 0x3d, 0x20}} , {{0x2f, 0x11, 0x32, 0xca, 0x61, 0xab, 0x38, 0xdf, 0xf0, 0x0f, 0x2f, 0xea, 0x32, 0x28, 0xf2, 0x4c, 0x6c, 0x71, 0xd5, 0x80, 0x85, 0xb8, 0x0e, 0x47, 0xe1, 0x95, 0x15, 0xcb, 0x27, 0xe8, 0xd0, 0x47}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xc8, 0x84, 0xa5, 0x08, 0xbc, 0xfd, 0x87, 0x3b, 0x99, 0x8b, 0x69, 0x80, 0x7b, 0xc6, 0x3a, 0xeb, 0x93, 0xcf, 0x4e, 0xf8, 0x5c, 0x2d, 0x86, 0x42, 0xb6, 0x71, 0xd7, 0x97, 0x5f, 0xe1, 0x42, 0x67}} , {{0xb4, 0xb9, 0x37, 0xfc, 0xa9, 0x5b, 0x2f, 0x1e, 0x93, 0xe4, 0x1e, 0x62, 0xfc, 0x3c, 0x78, 0x81, 0x8f, 0xf3, 0x8a, 0x66, 0x09, 0x6f, 0xad, 0x6e, 0x79, 0x73, 0xe5, 0xc9, 0x00, 0x06, 0xd3, 0x21}}}, {{{0xf8, 0xf9, 0x28, 0x6c, 0x6d, 0x59, 0xb2, 0x59, 0x74, 0x23, 0xbf, 0xe7, 0x33, 0x8d, 0x57, 0x09, 0x91, 0x9c, 0x24, 0x08, 0x15, 0x2b, 0xe2, 0xb8, 0xee, 0x3a, 0xe5, 0x27, 0x06, 0x86, 0xa4, 0x23}} , {{0xeb, 0x27, 0x67, 0xc1, 0x37, 0xab, 0x7a, 0xd8, 0x27, 0x9c, 0x07, 0x8e, 0xff, 0x11, 0x6a, 0xb0, 0x78, 0x6e, 0xad, 0x3a, 0x2e, 0x0f, 0x98, 0x9f, 0x72, 0xc3, 0x7f, 0x82, 0xf2, 0x96, 0x96, 0x70}}}, {{{0x81, 0x6b, 0x88, 0xe8, 0x1e, 0xc7, 0x77, 0x96, 0x0e, 0xa1, 0xa9, 0x52, 0xe0, 0xd8, 0x0e, 0x61, 0x9e, 0x79, 0x2d, 0x95, 0x9c, 0x8d, 0x96, 0xe0, 0x06, 0x40, 0x5d, 0x87, 0x28, 0x5f, 0x98, 0x70}} , {{0xf1, 0x79, 0x7b, 0xed, 0x4f, 0x44, 0xb2, 0xe7, 0x08, 0x0d, 0xc2, 0x08, 0x12, 0xd2, 0x9f, 0xdf, 0xcd, 0x93, 0x20, 0x8a, 0xcf, 0x33, 0xca, 0x6d, 0x89, 0xb9, 0x77, 0xc8, 0x93, 0x1b, 0x4e, 0x60}}}, {{{0x26, 0x4f, 0x7e, 0x97, 0xf6, 0x40, 0xdd, 0x4f, 0xfc, 0x52, 0x78, 0xf9, 0x90, 0x31, 0x03, 0xe6, 0x7d, 0x56, 0x39, 0x0b, 0x1d, 0x56, 0x82, 0x85, 0xf9, 0x1a, 0x42, 0x17, 0x69, 0x6c, 0xcf, 0x39}} , {{0x69, 0xd2, 0x06, 0x3a, 0x4f, 0x39, 0x2d, 0xf9, 0x38, 0x40, 0x8c, 0x4c, 0xe7, 0x05, 0x12, 0xb4, 0x78, 0x8b, 0xf8, 0xc0, 0xec, 0x93, 0xde, 0x7a, 0x6b, 0xce, 0x2c, 0xe1, 0x0e, 0xa9, 0x34, 0x44}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x0b, 0xa4, 0x3c, 0xb0, 0x0f, 0x7a, 0x51, 0xf1, 0x78, 0xd6, 0xd9, 0x6a, 0xfd, 0x46, 0xe8, 0xb8, 0xa8, 0x79, 0x1d, 0x87, 0xf9, 0x90, 0xf2, 0x9c, 0x13, 0x29, 0xf8, 0x0b, 0x20, 0x64, 0xfa, 0x05}} , {{0x26, 0x09, 0xda, 0x17, 0xaf, 0x95, 0xd6, 0xfb, 0x6a, 0x19, 0x0d, 0x6e, 0x5e, 0x12, 0xf1, 0x99, 0x4c, 0xaa, 0xa8, 0x6f, 0x79, 0x86, 0xf4, 0x72, 0x28, 0x00, 0x26, 0xf9, 0xea, 0x9e, 0x19, 0x3d}}}, {{{0x87, 0xdd, 0xcf, 0xf0, 0x5b, 0x49, 0xa2, 0x5d, 0x40, 0x7a, 0x23, 0x26, 0xa4, 0x7a, 0x83, 0x8a, 0xb7, 0x8b, 0xd2, 0x1a, 0xbf, 0xea, 0x02, 0x24, 0x08, 0x5f, 0x7b, 0xa9, 0xb1, 0xbe, 0x9d, 0x37}} , {{0xfc, 0x86, 0x4b, 0x08, 0xee, 0xe7, 0xa0, 0xfd, 0x21, 0x45, 0x09, 0x34, 0xc1, 0x61, 0x32, 0x23, 0xfc, 0x9b, 0x55, 0x48, 0x53, 0x99, 0xf7, 0x63, 0xd0, 0x99, 0xce, 0x01, 0xe0, 0x9f, 0xeb, 0x28}}}, {{{0x47, 0xfc, 0xab, 0x5a, 0x17, 0xf0, 0x85, 0x56, 0x3a, 0x30, 0x86, 0x20, 0x28, 0x4b, 0x8e, 0x44, 0x74, 0x3a, 0x6e, 0x02, 0xf1, 0x32, 0x8f, 0x9f, 0x3f, 0x08, 0x35, 0xe9, 0xca, 0x16, 0x5f, 0x6e}} , {{0x1c, 0x59, 0x1c, 0x65, 0x5d, 0x34, 0xa4, 0x09, 0xcd, 0x13, 0x9c, 0x70, 0x7d, 0xb1, 0x2a, 0xc5, 0x88, 0xaf, 0x0b, 0x60, 0xc7, 0x9f, 0x34, 0x8d, 0xd6, 0xb7, 0x7f, 0xea, 0x78, 0x65, 0x8d, 0x77}}}, {{{0x56, 0xa5, 0xc2, 0x0c, 0xdd, 0xbc, 0xb8, 0x20, 0x6d, 0x57, 0x61, 0xb5, 0xfb, 0x78, 0xb5, 0xd4, 0x49, 0x54, 0x90, 0x26, 0xc1, 0xcb, 0xe9, 0xe6, 0xbf, 0xec, 0x1d, 0x4e, 0xed, 0x07, 0x7e, 0x5e}} , {{0xc7, 0xf6, 0x6c, 0x56, 0x31, 0x20, 0x14, 0x0e, 0xa8, 0xd9, 0x27, 0xc1, 0x9a, 0x3d, 0x1b, 0x7d, 0x0e, 0x26, 0xd3, 0x81, 0xaa, 0xeb, 0xf5, 0x6b, 0x79, 0x02, 0xf1, 0x51, 0x5c, 0x75, 0x55, 0x0f}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x0a, 0x34, 0xcd, 0x82, 0x3c, 0x33, 0x09, 0x54, 0xd2, 0x61, 0x39, 0x30, 0x9b, 0xfd, 0xef, 0x21, 0x26, 0xd4, 0x70, 0xfa, 0xee, 0xf9, 0x31, 0x33, 0x73, 0x84, 0xd0, 0xb3, 0x81, 0xbf, 0xec, 0x2e}} , {{0xe8, 0x93, 0x8b, 0x00, 0x64, 0xf7, 0x9c, 0xb8, 0x74, 0xe0, 0xe6, 0x49, 0x48, 0x4d, 0x4d, 0x48, 0xb6, 0x19, 0xa1, 0x40, 0xb7, 0xd9, 0x32, 0x41, 0x7c, 0x82, 0x37, 0xa1, 0x2d, 0xdc, 0xd2, 0x54}}}, {{{0x68, 0x2b, 0x4a, 0x5b, 0xd5, 0xc7, 0x51, 0x91, 0x1d, 0xe1, 0x2a, 0x4b, 0xc4, 0x47, 0xf1, 0xbc, 0x7a, 0xb3, 0xcb, 0xc8, 0xb6, 0x7c, 0xac, 0x90, 0x05, 0xfd, 0xf3, 0xf9, 0x52, 0x3a, 0x11, 0x6b}} , {{0x3d, 0xc1, 0x27, 0xf3, 0x59, 0x43, 0x95, 0x90, 0xc5, 0x96, 0x79, 0xf5, 0xf4, 0x95, 0x65, 0x29, 0x06, 0x9c, 0x51, 0x05, 0x18, 0xda, 0xb8, 0x2e, 0x79, 0x7e, 0x69, 0x59, 0x71, 0x01, 0xeb, 0x1a}}}, {{{0x15, 0x06, 0x49, 0xb6, 0x8a, 0x3c, 0xea, 0x2f, 0x34, 0x20, 0x14, 0xc3, 0xaa, 0xd6, 0xaf, 0x2c, 0x3e, 0xbd, 0x65, 0x20, 0xe2, 0x4d, 0x4b, 0x3b, 0xeb, 0x9f, 0x4a, 0xc3, 0xad, 0xa4, 0x3b, 0x60}} , {{0xbc, 0x58, 0xe6, 0xc0, 0x95, 0x2a, 0x2a, 0x81, 0x9a, 0x7a, 0xf3, 0xd2, 0x06, 0xbe, 0x48, 0xbc, 0x0c, 0xc5, 0x46, 0xe0, 0x6a, 0xd4, 0xac, 0x0f, 0xd9, 0xcc, 0x82, 0x34, 0x2c, 0xaf, 0xdb, 0x1f}}}, {{{0xf7, 0x17, 0x13, 0xbd, 0xfb, 0xbc, 0xd2, 0xec, 0x45, 0xb3, 0x15, 0x31, 0xe9, 0xaf, 0x82, 0x84, 0x3d, 0x28, 0xc6, 0xfc, 0x11, 0xf5, 0x41, 0xb5, 0x8b, 0xd3, 0x12, 0x76, 0x52, 0xe7, 0x1a, 0x3c}} , {{0x4e, 0x36, 0x11, 0x07, 0xa2, 0x15, 0x20, 0x51, 0xc4, 0x2a, 0xc3, 0x62, 0x8b, 0x5e, 0x7f, 0xa6, 0x0f, 0xf9, 0x45, 0x85, 0x6c, 0x11, 0x86, 0xb7, 0x7e, 0xe5, 0xd7, 0xf9, 0xc3, 0x91, 0x1c, 0x05}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xea, 0xd6, 0xde, 0x29, 0x3a, 0x00, 0xb9, 0x02, 0x59, 0xcb, 0x26, 0xc4, 0xba, 0x99, 0xb1, 0x97, 0x2f, 0x8e, 0x00, 0x92, 0x26, 0x4f, 0x52, 0xeb, 0x47, 0x1b, 0x89, 0x8b, 0x24, 0xc0, 0x13, 0x7d}} , {{0xd5, 0x20, 0x5b, 0x80, 0xa6, 0x80, 0x20, 0x95, 0xc3, 0xe9, 0x9f, 0x8e, 0x87, 0x9e, 0x1e, 0x9e, 0x7a, 0xc7, 0xcc, 0x75, 0x6c, 0xa5, 0xf1, 0x91, 0x1a, 0xa8, 0x01, 0x2c, 0xab, 0x76, 0xa9, 0x59}}}, {{{0xde, 0xc9, 0xb1, 0x31, 0x10, 0x16, 0xaa, 0x35, 0x14, 0x6a, 0xd4, 0xb5, 0x34, 0x82, 0x71, 0xd2, 0x4a, 0x5d, 0x9a, 0x1f, 0x53, 0x26, 0x3c, 0xe5, 0x8e, 0x8d, 0x33, 0x7f, 0xff, 0xa9, 0xd5, 0x17}} , {{0x89, 0xaf, 0xf6, 0xa4, 0x64, 0xd5, 0x10, 0xe0, 0x1d, 0xad, 0xef, 0x44, 0xbd, 0xda, 0x83, 0xac, 0x7a, 0xa8, 0xf0, 0x1c, 0x07, 0xf9, 0xc3, 0x43, 0x6c, 0x3f, 0xb7, 0xd3, 0x87, 0x22, 0x02, 0x73}}}, {{{0x64, 0x1d, 0x49, 0x13, 0x2f, 0x71, 0xec, 0x69, 0x87, 0xd0, 0x42, 0xee, 0x13, 0xec, 0xe3, 0xed, 0x56, 0x7b, 0xbf, 0xbd, 0x8c, 0x2f, 0x7d, 0x7b, 0x9d, 0x28, 0xec, 0x8e, 0x76, 0x2f, 0x6f, 0x08}} , {{0x22, 0xf5, 0x5f, 0x4d, 0x15, 0xef, 0xfc, 0x4e, 0x57, 0x03, 0x36, 0x89, 0xf0, 0xeb, 0x5b, 0x91, 0xd6, 0xe2, 0xca, 0x01, 0xa5, 0xee, 0x52, 0xec, 0xa0, 0x3c, 0x8f, 0x33, 0x90, 0x5a, 0x94, 0x72}}}, {{{0x8a, 0x4b, 0xe7, 0x38, 0xbc, 0xda, 0xc2, 0xb0, 0x85, 0xe1, 0x4a, 0xfe, 0x2d, 0x44, 0x84, 0xcb, 0x20, 0x6b, 0x2d, 0xbf, 0x11, 0x9c, 0xd7, 0xbe, 0xd3, 0x3e, 0x5f, 0xbf, 0x68, 0xbc, 0xa8, 0x07}} , {{0x01, 0x89, 0x28, 0x22, 0x6a, 0x78, 0xaa, 0x29, 0x03, 0xc8, 0x74, 0x95, 0x03, 0x3e, 0xdc, 0xbd, 0x07, 0x13, 0xa8, 0xa2, 0x20, 0x2d, 0xb3, 0x18, 0x70, 0x42, 0xfd, 0x7a, 0xc4, 0xd7, 0x49, 0x72}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x02, 0xff, 0x32, 0x2b, 0x5c, 0x93, 0x54, 0x32, 0xe8, 0x57, 0x54, 0x1a, 0x8b, 0x33, 0x60, 0x65, 0xd3, 0x67, 0xa4, 0xc1, 0x26, 0xc4, 0xa4, 0x34, 0x1f, 0x9b, 0xa7, 0xa9, 0xf4, 0xd9, 0x4f, 0x5b}} , {{0x46, 0x8d, 0xb0, 0x33, 0x54, 0x26, 0x5b, 0x68, 0xdf, 0xbb, 0xc5, 0xec, 0xc2, 0xf9, 0x3c, 0x5a, 0x37, 0xc1, 0x8e, 0x27, 0x47, 0xaa, 0x49, 0x5a, 0xf8, 0xfb, 0x68, 0x04, 0x23, 0xd1, 0xeb, 0x40}}}, {{{0x65, 0xa5, 0x11, 0x84, 0x8a, 0x67, 0x9d, 0x9e, 0xd1, 0x44, 0x68, 0x7a, 0x34, 0xe1, 0x9f, 0xa3, 0x54, 0xcd, 0x07, 0xca, 0x79, 0x1f, 0x54, 0x2f, 0x13, 0x70, 0x4e, 0xee, 0xa2, 0xfa, 0xe7, 0x5d}} , {{0x36, 0xec, 0x54, 0xf8, 0xce, 0xe4, 0x85, 0xdf, 0xf6, 0x6f, 0x1d, 0x90, 0x08, 0xbc, 0xe8, 0xc0, 0x92, 0x2d, 0x43, 0x6b, 0x92, 0xa9, 0x8e, 0xab, 0x0a, 0x2e, 0x1c, 0x1e, 0x64, 0x23, 0x9f, 0x2c}}}, {{{0xa7, 0xd6, 0x2e, 0xd5, 0xcc, 0xd4, 0xcb, 0x5a, 0x3b, 0xa7, 0xf9, 0x46, 0x03, 0x1d, 0xad, 0x2b, 0x34, 0x31, 0x90, 0x00, 0x46, 0x08, 0x82, 0x14, 0xc4, 0xe0, 0x9c, 0xf0, 0xe3, 0x55, 0x43, 0x31}} , {{0x60, 0xd6, 0xdd, 0x78, 0xe6, 0xd4, 0x22, 0x42, 0x1f, 0x00, 0xf9, 0xb1, 0x6a, 0x63, 0xe2, 0x92, 0x59, 0xd1, 0x1a, 0xb7, 0x00, 0x54, 0x29, 0xc9, 0xc1, 0xf6, 0x6f, 0x7a, 0xc5, 0x3c, 0x5f, 0x65}}}, {{{0x27, 0x4f, 0xd0, 0x72, 0xb1, 0x11, 0x14, 0x27, 0x15, 0x94, 0x48, 0x81, 0x7e, 0x74, 0xd8, 0x32, 0xd5, 0xd1, 0x11, 0x28, 0x60, 0x63, 0x36, 0x32, 0x37, 0xb5, 0x13, 0x1c, 0xa0, 0x37, 0xe3, 0x74}} , {{0xf1, 0x25, 0x4e, 0x11, 0x96, 0x67, 0xe6, 0x1c, 0xc2, 0xb2, 0x53, 0xe2, 0xda, 0x85, 0xee, 0xb2, 0x9f, 0x59, 0xf3, 0xba, 0xbd, 0xfa, 0xcf, 0x6e, 0xf9, 0xda, 0xa4, 0xb3, 0x02, 0x8f, 0x64, 0x08}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x34, 0x94, 0xf2, 0x64, 0x54, 0x47, 0x37, 0x07, 0x40, 0x8a, 0x20, 0xba, 0x4a, 0x55, 0xd7, 0x3f, 0x47, 0xba, 0x25, 0x23, 0x14, 0xb0, 0x2c, 0xe8, 0x55, 0xa8, 0xa6, 0xef, 0x51, 0xbd, 0x6f, 0x6a}} , {{0x71, 0xd6, 0x16, 0x76, 0xb2, 0x06, 0xea, 0x79, 0xf5, 0xc4, 0xc3, 0x52, 0x7e, 0x61, 0xd1, 0xe1, 0xad, 0x70, 0x78, 0x1d, 0x16, 0x11, 0xf8, 0x7c, 0x2b, 0xfc, 0x55, 0x9f, 0x52, 0xf8, 0xf5, 0x16}}}, {{{0x34, 0x96, 0x9a, 0xf6, 0xc5, 0xe0, 0x14, 0x03, 0x24, 0x0e, 0x4c, 0xad, 0x9e, 0x9a, 0x70, 0x23, 0x96, 0xb2, 0xf1, 0x2e, 0x9d, 0xc3, 0x32, 0x9b, 0x54, 0xa5, 0x73, 0xde, 0x88, 0xb1, 0x3e, 0x24}} , {{0xf6, 0xe2, 0x4c, 0x1f, 0x5b, 0xb2, 0xaf, 0x82, 0xa5, 0xcf, 0x81, 0x10, 0x04, 0xef, 0xdb, 0xa2, 0xcc, 0x24, 0xb2, 0x7e, 0x0b, 0x7a, 0xeb, 0x01, 0xd8, 0x52, 0xf4, 0x51, 0x89, 0x29, 0x79, 0x37}}}, {{{0x74, 0xde, 0x12, 0xf3, 0x68, 0xb7, 0x66, 0xc3, 0xee, 0x68, 0xdc, 0x81, 0xb5, 0x55, 0x99, 0xab, 0xd9, 0x28, 0x63, 0x6d, 0x8b, 0x40, 0x69, 0x75, 0x6c, 0xcd, 0x5c, 0x2a, 0x7e, 0x32, 0x7b, 0x29}} , {{0x02, 0xcc, 0x22, 0x74, 0x4d, 0x19, 0x07, 0xc0, 0xda, 0xb5, 0x76, 0x51, 0x2a, 0xaa, 0xa6, 0x0a, 0x5f, 0x26, 0xd4, 0xbc, 0xaf, 0x48, 0x88, 0x7f, 0x02, 0xbc, 0xf2, 0xe1, 0xcf, 0xe9, 0xdd, 0x15}}}, {{{0xed, 0xb5, 0x9a, 0x8c, 0x9a, 0xdd, 0x27, 0xf4, 0x7f, 0x47, 0xd9, 0x52, 0xa7, 0xcd, 0x65, 0xa5, 0x31, 0x22, 0xed, 0xa6, 0x63, 0x5b, 0x80, 0x4a, 0xad, 0x4d, 0xed, 0xbf, 0xee, 0x49, 0xb3, 0x06}} , {{0xf8, 0x64, 0x8b, 0x60, 0x90, 0xe9, 0xde, 0x44, 0x77, 0xb9, 0x07, 0x36, 0x32, 0xc2, 0x50, 0xf5, 0x65, 0xdf, 0x48, 0x4c, 0x37, 0xaa, 0x68, 0xab, 0x9a, 0x1f, 0x3e, 0xff, 0x89, 0x92, 0xa0, 0x07}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x7d, 0x4f, 0x9c, 0x19, 0xc0, 0x4a, 0x31, 0xec, 0xf9, 0xaa, 0xeb, 0xb2, 0x16, 0x9c, 0xa3, 0x66, 0x5f, 0xd1, 0xd4, 0xed, 0xb8, 0x92, 0x1c, 0xab, 0xda, 0xea, 0xd9, 0x57, 0xdf, 0x4c, 0x2a, 0x48}} , {{0x4b, 0xb0, 0x4e, 0x6e, 0x11, 0x3b, 0x51, 0xbd, 0x6a, 0xfd, 0xe4, 0x25, 0xa5, 0x5f, 0x11, 0x3f, 0x98, 0x92, 0x51, 0x14, 0xc6, 0x5f, 0x3c, 0x0b, 0xa8, 0xf7, 0xc2, 0x81, 0x43, 0xde, 0x91, 0x73}}}, {{{0x3c, 0x8f, 0x9f, 0x33, 0x2a, 0x1f, 0x43, 0x33, 0x8f, 0x68, 0xff, 0x1f, 0x3d, 0x73, 0x6b, 0xbf, 0x68, 0xcc, 0x7d, 0x13, 0x6c, 0x24, 0x4b, 0xcc, 0x4d, 0x24, 0x0d, 0xfe, 0xde, 0x86, 0xad, 0x3b}} , {{0x79, 0x51, 0x81, 0x01, 0xdc, 0x73, 0x53, 0xe0, 0x6e, 0x9b, 0xea, 0x68, 0x3f, 0x5c, 0x14, 0x84, 0x53, 0x8d, 0x4b, 0xc0, 0x9f, 0x9f, 0x89, 0x2b, 0x8c, 0xba, 0x86, 0xfa, 0xf2, 0xcd, 0xe3, 0x2d}}}, {{{0x06, 0xf9, 0x29, 0x5a, 0xdb, 0x3d, 0x84, 0x52, 0xab, 0xcc, 0x6b, 0x60, 0x9d, 0xb7, 0x4a, 0x0e, 0x36, 0x63, 0x91, 0xad, 0xa0, 0x95, 0xb0, 0x97, 0x89, 0x4e, 0xcf, 0x7d, 0x3c, 0xe5, 0x7c, 0x28}} , {{0x2e, 0x69, 0x98, 0xfd, 0xc6, 0xbd, 0xcc, 0xca, 0xdf, 0x9a, 0x44, 0x7e, 0x9d, 0xca, 0x89, 0x6d, 0xbf, 0x27, 0xc2, 0xf8, 0xcd, 0x46, 0x00, 0x2b, 0xb5, 0x58, 0x4e, 0xb7, 0x89, 0x09, 0xe9, 0x2d}}}, {{{0x54, 0xbe, 0x75, 0xcb, 0x05, 0xb0, 0x54, 0xb7, 0xe7, 0x26, 0x86, 0x4a, 0xfc, 0x19, 0xcf, 0x27, 0x46, 0xd4, 0x22, 0x96, 0x5a, 0x11, 0xe8, 0xd5, 0x1b, 0xed, 0x71, 0xc5, 0x5d, 0xc8, 0xaf, 0x45}} , {{0x40, 0x7b, 0x77, 0x57, 0x49, 0x9e, 0x80, 0x39, 0x23, 0xee, 0x81, 0x0b, 0x22, 0xcf, 0xdb, 0x7a, 0x2f, 0x14, 0xb8, 0x57, 0x8f, 0xa1, 0x39, 0x1e, 0x77, 0xfc, 0x0b, 0xa6, 0xbf, 0x8a, 0x0c, 0x6c}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x77, 0x3a, 0xd4, 0xd8, 0x27, 0xcf, 0xe8, 0xa1, 0x72, 0x9d, 0xca, 0xdd, 0x0d, 0x96, 0xda, 0x79, 0xed, 0x56, 0x42, 0x15, 0x60, 0xc7, 0x1c, 0x6b, 0x26, 0x30, 0xf6, 0x6a, 0x95, 0x67, 0xf3, 0x0a}} , {{0xc5, 0x08, 0xa4, 0x2b, 0x2f, 0xbd, 0x31, 0x81, 0x2a, 0xa6, 0xb6, 0xe4, 0x00, 0x91, 0xda, 0x3d, 0xb2, 0xb0, 0x96, 0xce, 0x8a, 0xd2, 0x8d, 0x70, 0xb3, 0xd3, 0x34, 0x01, 0x90, 0x8d, 0x10, 0x21}}}, {{{0x33, 0x0d, 0xe7, 0xba, 0x4f, 0x07, 0xdf, 0x8d, 0xea, 0x7d, 0xa0, 0xc5, 0xd6, 0xb1, 0xb0, 0xe5, 0x57, 0x1b, 0x5b, 0xf5, 0x45, 0x13, 0x14, 0x64, 0x5a, 0xeb, 0x5c, 0xfc, 0x54, 0x01, 0x76, 0x2b}} , {{0x02, 0x0c, 0xc2, 0xaf, 0x96, 0x36, 0xfe, 0x4a, 0xe2, 0x54, 0x20, 0x6a, 0xeb, 0xb2, 0x9f, 0x62, 0xd7, 0xce, 0xa2, 0x3f, 0x20, 0x11, 0x34, 0x37, 0xe0, 0x42, 0xed, 0x6f, 0xf9, 0x1a, 0xc8, 0x7d}}}, {{{0xd8, 0xb9, 0x11, 0xe8, 0x36, 0x3f, 0x42, 0xc1, 0xca, 0xdc, 0xd3, 0xf1, 0xc8, 0x23, 0x3d, 0x4f, 0x51, 0x7b, 0x9d, 0x8d, 0xd8, 0xe4, 0xa0, 0xaa, 0xf3, 0x04, 0xd6, 0x11, 0x93, 0xc8, 0x35, 0x45}} , {{0x61, 0x36, 0xd6, 0x08, 0x90, 0xbf, 0xa7, 0x7a, 0x97, 0x6c, 0x0f, 0x84, 0xd5, 0x33, 0x2d, 0x37, 0xc9, 0x6a, 0x80, 0x90, 0x3d, 0x0a, 0xa2, 0xaa, 0xe1, 0xb8, 0x84, 0xba, 0x61, 0x36, 0xdd, 0x69}}}, {{{0x6b, 0xdb, 0x5b, 0x9c, 0xc6, 0x92, 0xbc, 0x23, 0xaf, 0xc5, 0xb8, 0x75, 0xf8, 0x42, 0xfa, 0xd6, 0xb6, 0x84, 0x94, 0x63, 0x98, 0x93, 0x48, 0x78, 0x38, 0xcd, 0xbb, 0x18, 0x34, 0xc3, 0xdb, 0x67}} , {{0x96, 0xf3, 0x3a, 0x09, 0x56, 0xb0, 0x6f, 0x7c, 0x51, 0x1e, 0x1b, 0x39, 0x48, 0xea, 0xc9, 0x0c, 0x25, 0xa2, 0x7a, 0xca, 0xe7, 0x92, 0xfc, 0x59, 0x30, 0xa3, 0x89, 0x85, 0xdf, 0x6f, 0x43, 0x38}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x79, 0x84, 0x44, 0x19, 0xbd, 0xe9, 0x54, 0xc4, 0xc0, 0x6e, 0x2a, 0xa8, 0xa8, 0x9b, 0x43, 0xd5, 0x71, 0x22, 0x5f, 0xdc, 0x01, 0xfa, 0xdf, 0xb3, 0xb8, 0x47, 0x4b, 0x0a, 0xa5, 0x44, 0xea, 0x29}} , {{0x05, 0x90, 0x50, 0xaf, 0x63, 0x5f, 0x9d, 0x9e, 0xe1, 0x9d, 0x38, 0x97, 0x1f, 0x6c, 0xac, 0x30, 0x46, 0xb2, 0x6a, 0x19, 0xd1, 0x4b, 0xdb, 0xbb, 0x8c, 0xda, 0x2e, 0xab, 0xc8, 0x5a, 0x77, 0x6c}}}, {{{0x2b, 0xbe, 0xaf, 0xa1, 0x6d, 0x2f, 0x0b, 0xb1, 0x8f, 0xe3, 0xe0, 0x38, 0xcd, 0x0b, 0x41, 0x1b, 0x4a, 0x15, 0x07, 0xf3, 0x6f, 0xdc, 0xb8, 0xe9, 0xde, 0xb2, 0xa3, 0x40, 0x01, 0xa6, 0x45, 0x1e}} , {{0x76, 0x0a, 0xda, 0x8d, 0x2c, 0x07, 0x3f, 0x89, 0x7d, 0x04, 0xad, 0x43, 0x50, 0x6e, 0xd2, 0x47, 0xcb, 0x8a, 0xe6, 0x85, 0x1a, 0x24, 0xf3, 0xd2, 0x60, 0xfd, 0xdf, 0x73, 0xa4, 0x0d, 0x73, 0x0e}}}, {{{0xfd, 0x67, 0x6b, 0x71, 0x9b, 0x81, 0x53, 0x39, 0x39, 0xf4, 0xb8, 0xd5, 0xc3, 0x30, 0x9b, 0x3b, 0x7c, 0xa3, 0xf0, 0xd0, 0x84, 0x21, 0xd6, 0xbf, 0xb7, 0x4c, 0x87, 0x13, 0x45, 0x2d, 0xa7, 0x55}} , {{0x5d, 0x04, 0xb3, 0x40, 0x28, 0x95, 0x2d, 0x30, 0x83, 0xec, 0x5e, 0xe4, 0xff, 0x75, 0xfe, 0x79, 0x26, 0x9d, 0x1d, 0x36, 0xcd, 0x0a, 0x15, 0xd2, 0x24, 0x14, 0x77, 0x71, 0xd7, 0x8a, 0x1b, 0x04}}}, {{{0x5d, 0x93, 0xc9, 0xbe, 0xaa, 0x90, 0xcd, 0x9b, 0xfb, 0x73, 0x7e, 0xb0, 0x64, 0x98, 0x57, 0x44, 0x42, 0x41, 0xb1, 0xaf, 0xea, 0xc1, 0xc3, 0x22, 0xff, 0x60, 0x46, 0xcb, 0x61, 0x81, 0x70, 0x61}} , {{0x0d, 0x82, 0xb9, 0xfe, 0x21, 0xcd, 0xc4, 0xf5, 0x98, 0x0c, 0x4e, 0x72, 0xee, 0x87, 0x49, 0xf8, 0xa1, 0x95, 0xdf, 0x8f, 0x2d, 0xbd, 0x21, 0x06, 0x7c, 0x15, 0xe8, 0x12, 0x6d, 0x93, 0xd6, 0x38}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x91, 0xf7, 0x51, 0xd9, 0xef, 0x7d, 0x42, 0x01, 0x13, 0xe9, 0xb8, 0x7f, 0xa6, 0x49, 0x17, 0x64, 0x21, 0x80, 0x83, 0x2c, 0x63, 0x4c, 0x60, 0x09, 0x59, 0x91, 0x92, 0x77, 0x39, 0x51, 0xf4, 0x48}} , {{0x60, 0xd5, 0x22, 0x83, 0x08, 0x2f, 0xff, 0x99, 0x3e, 0x69, 0x6d, 0x88, 0xda, 0xe7, 0x5b, 0x52, 0x26, 0x31, 0x2a, 0xe5, 0x89, 0xde, 0x68, 0x90, 0xb6, 0x22, 0x5a, 0xbd, 0xd3, 0x85, 0x53, 0x31}}}, {{{0xd8, 0xce, 0xdc, 0xf9, 0x3c, 0x4b, 0xa2, 0x1d, 0x2c, 0x2f, 0x36, 0xbe, 0x7a, 0xfc, 0xcd, 0xbc, 0xdc, 0xf9, 0x30, 0xbd, 0xff, 0x05, 0xc7, 0xe4, 0x8e, 0x17, 0x62, 0xf8, 0x4d, 0xa0, 0x56, 0x79}} , {{0x82, 0xe7, 0xf6, 0xba, 0x53, 0x84, 0x0a, 0xa3, 0x34, 0xff, 0x3c, 0xa3, 0x6a, 0xa1, 0x37, 0xea, 0xdd, 0xb6, 0x95, 0xb3, 0x78, 0x19, 0x76, 0x1e, 0x55, 0x2f, 0x77, 0x2e, 0x7f, 0xc1, 0xea, 0x5e}}}, {{{0x83, 0xe1, 0x6e, 0xa9, 0x07, 0x33, 0x3e, 0x83, 0xff, 0xcb, 0x1c, 0x9f, 0xb1, 0xa3, 0xb4, 0xc9, 0xe1, 0x07, 0x97, 0xff, 0xf8, 0x23, 0x8f, 0xce, 0x40, 0xfd, 0x2e, 0x5e, 0xdb, 0x16, 0x43, 0x2d}} , {{0xba, 0x38, 0x02, 0xf7, 0x81, 0x43, 0x83, 0xa3, 0x20, 0x4f, 0x01, 0x3b, 0x8a, 0x04, 0x38, 0x31, 0xc6, 0x0f, 0xc8, 0xdf, 0xd7, 0xfa, 0x2f, 0x88, 0x3f, 0xfc, 0x0c, 0x76, 0xc4, 0xa6, 0x45, 0x72}}}, {{{0xbb, 0x0c, 0xbc, 0x6a, 0xa4, 0x97, 0x17, 0x93, 0x2d, 0x6f, 0xde, 0x72, 0x10, 0x1c, 0x08, 0x2c, 0x0f, 0x80, 0x32, 0x68, 0x27, 0xd4, 0xab, 0xdd, 0xc5, 0x58, 0x61, 0x13, 0x6d, 0x11, 0x1e, 0x4d}} , {{0x1a, 0xb9, 0xc9, 0x10, 0xfb, 0x1e, 0x4e, 0xf4, 0x84, 0x4b, 0x8a, 0x5e, 0x7b, 0x4b, 0xe8, 0x43, 0x8c, 0x8f, 0x00, 0xb5, 0x54, 0x13, 0xc5, 0x5c, 0xb6, 0x35, 0x4e, 0x9d, 0xe4, 0x5b, 0x41, 0x6d}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x15, 0x7d, 0x12, 0x48, 0x82, 0x14, 0x42, 0xcd, 0x32, 0xd4, 0x4b, 0xc1, 0x72, 0x61, 0x2a, 0x8c, 0xec, 0xe2, 0xf8, 0x24, 0x45, 0x94, 0xe3, 0xbe, 0xdd, 0x67, 0xa8, 0x77, 0x5a, 0xae, 0x5b, 0x4b}} , {{0xcb, 0x77, 0x9a, 0x20, 0xde, 0xb8, 0x23, 0xd9, 0xa0, 0x0f, 0x8c, 0x7b, 0xa5, 0xcb, 0xae, 0xb6, 0xec, 0x42, 0x67, 0x0e, 0x58, 0xa4, 0x75, 0x98, 0x21, 0x71, 0x84, 0xb3, 0xe0, 0x76, 0x94, 0x73}}}, {{{0xdf, 0xfc, 0x69, 0x28, 0x23, 0x3f, 0x5b, 0xf8, 0x3b, 0x24, 0x37, 0xf3, 0x1d, 0xd5, 0x22, 0x6b, 0xd0, 0x98, 0xa8, 0x6c, 0xcf, 0xff, 0x06, 0xe1, 0x13, 0xdf, 0xb9, 0xc1, 0x0c, 0xa9, 0xbf, 0x33}} , {{0xd9, 0x81, 0xda, 0xb2, 0x4f, 0x82, 0x9d, 0x43, 0x81, 0x09, 0xf1, 0xd2, 0x01, 0xef, 0xac, 0xf4, 0x2d, 0x7d, 0x01, 0x09, 0xf1, 0xff, 0xa5, 0x9f, 0xe5, 0xca, 0x27, 0x63, 0xdb, 0x20, 0xb1, 0x53}}}, {{{0x67, 0x02, 0xe8, 0xad, 0xa9, 0x34, 0xd4, 0xf0, 0x15, 0x81, 0xaa, 0xc7, 0x4d, 0x87, 0x94, 0xea, 0x75, 0xe7, 0x4c, 0x94, 0x04, 0x0e, 0x69, 0x87, 0xe7, 0x51, 0x91, 0x10, 0x03, 0xc7, 0xbe, 0x56}} , {{0x32, 0xfb, 0x86, 0xec, 0x33, 0x6b, 0x2e, 0x51, 0x2b, 0xc8, 0xfa, 0x6c, 0x70, 0x47, 0x7e, 0xce, 0x05, 0x0c, 0x71, 0xf3, 0xb4, 0x56, 0xa6, 0xdc, 0xcc, 0x78, 0x07, 0x75, 0xd0, 0xdd, 0xb2, 0x6a}}}, {{{0xc6, 0xef, 0xb9, 0xc0, 0x2b, 0x22, 0x08, 0x1e, 0x71, 0x70, 0xb3, 0x35, 0x9c, 0x7a, 0x01, 0x92, 0x44, 0x9a, 0xf6, 0xb0, 0x58, 0x95, 0xc1, 0x9b, 0x02, 0xed, 0x2d, 0x7c, 0x34, 0x29, 0x49, 0x44}} , {{0x45, 0x62, 0x1d, 0x2e, 0xff, 0x2a, 0x1c, 0x21, 0xa4, 0x25, 0x7b, 0x0d, 0x8c, 0x15, 0x39, 0xfc, 0x8f, 0x7c, 0xa5, 0x7d, 0x1e, 0x25, 0xa3, 0x45, 0xd6, 0xab, 0xbd, 0xcb, 0xc5, 0x5e, 0x78, 0x77}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xd0, 0xd3, 0x42, 0xed, 0x1d, 0x00, 0x3c, 0x15, 0x2c, 0x9c, 0x77, 0x81, 0xd2, 0x73, 0xd1, 0x06, 0xd5, 0xc4, 0x7f, 0x94, 0xbb, 0x92, 0x2d, 0x2c, 0x4b, 0x45, 0x4b, 0xe9, 0x2a, 0x89, 0x6b, 0x2b}} , {{0xd2, 0x0c, 0x88, 0xc5, 0x48, 0x4d, 0xea, 0x0d, 0x4a, 0xc9, 0x52, 0x6a, 0x61, 0x79, 0xe9, 0x76, 0xf3, 0x85, 0x52, 0x5c, 0x1b, 0x2c, 0xe1, 0xd6, 0xc4, 0x0f, 0x18, 0x0e, 0x4e, 0xf6, 0x1c, 0x7f}}}, {{{0xb4, 0x04, 0x2e, 0x42, 0xcb, 0x1f, 0x2b, 0x11, 0x51, 0x7b, 0x08, 0xac, 0xaa, 0x3e, 0x9e, 0x52, 0x60, 0xb7, 0xc2, 0x61, 0x57, 0x8c, 0x84, 0xd5, 0x18, 0xa6, 0x19, 0xfc, 0xb7, 0x75, 0x91, 0x1b}} , {{0xe8, 0x68, 0xca, 0x44, 0xc8, 0x38, 0x38, 0xcc, 0x53, 0x0a, 0x32, 0x35, 0xcc, 0x52, 0xcb, 0x0e, 0xf7, 0xc5, 0xe7, 0xec, 0x3d, 0x85, 0xcc, 0x58, 0xe2, 0x17, 0x47, 0xff, 0x9f, 0xa5, 0x30, 0x17}}}, {{{0xe3, 0xae, 0xc8, 0xc1, 0x71, 0x75, 0x31, 0x00, 0x37, 0x41, 0x5c, 0x0e, 0x39, 0xda, 0x73, 0xa0, 0xc7, 0x97, 0x36, 0x6c, 0x5b, 0xf2, 0xee, 0x64, 0x0a, 0x3d, 0x89, 0x1e, 0x1d, 0x49, 0x8c, 0x37}} , {{0x4c, 0xe6, 0xb0, 0xc1, 0xa5, 0x2a, 0x82, 0x09, 0x08, 0xad, 0x79, 0x9c, 0x56, 0xf6, 0xf9, 0xc1, 0xd7, 0x7c, 0x39, 0x7f, 0x93, 0xca, 0x11, 0x55, 0xbf, 0x07, 0x1b, 0x82, 0x29, 0x69, 0x95, 0x5c}}}, {{{0x87, 0xee, 0xa6, 0x56, 0x9e, 0xc2, 0x9a, 0x56, 0x24, 0x42, 0x85, 0x4d, 0x98, 0x31, 0x1e, 0x60, 0x4d, 0x87, 0x85, 0x04, 0xae, 0x46, 0x12, 0xf9, 0x8e, 0x7f, 0xe4, 0x7f, 0xf6, 0x1c, 0x37, 0x01}} , {{0x73, 0x4c, 0xb6, 0xc5, 0xc4, 0xe9, 0x6c, 0x85, 0x48, 0x4a, 0x5a, 0xac, 0xd9, 0x1f, 0x43, 0xf8, 0x62, 0x5b, 0xee, 0x98, 0x2a, 0x33, 0x8e, 0x79, 0xce, 0x61, 0x06, 0x35, 0xd8, 0xd7, 0xca, 0x71}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x72, 0xd3, 0xae, 0xa6, 0xca, 0x8f, 0xcd, 0xcc, 0x78, 0x8e, 0x19, 0x4d, 0xa7, 0xd2, 0x27, 0xe9, 0xa4, 0x3c, 0x16, 0x5b, 0x84, 0x80, 0xf9, 0xd0, 0xcc, 0x6a, 0x1e, 0xca, 0x1e, 0x67, 0xbd, 0x63}} , {{0x7b, 0x6e, 0x2a, 0xd2, 0x87, 0x48, 0xff, 0xa1, 0xca, 0xe9, 0x15, 0x85, 0xdc, 0xdb, 0x2c, 0x39, 0x12, 0x91, 0xa9, 0x20, 0xaa, 0x4f, 0x29, 0xf4, 0x15, 0x7a, 0xd2, 0xf5, 0x32, 0xcc, 0x60, 0x04}}}, {{{0xe5, 0x10, 0x47, 0x3b, 0xfa, 0x90, 0xfc, 0x30, 0xb5, 0xea, 0x6f, 0x56, 0x8f, 0xfb, 0x0e, 0xa7, 0x3b, 0xc8, 0xb2, 0xff, 0x02, 0x7a, 0x33, 0x94, 0x93, 0x2a, 0x03, 0xe0, 0x96, 0x3a, 0x6c, 0x0f}} , {{0x5a, 0x63, 0x67, 0xe1, 0x9b, 0x47, 0x78, 0x9f, 0x38, 0x79, 0xac, 0x97, 0x66, 0x1d, 0x5e, 0x51, 0xee, 0x24, 0x42, 0xe8, 0x58, 0x4b, 0x8a, 0x03, 0x75, 0x86, 0x37, 0x86, 0xe2, 0x97, 0x4e, 0x3d}}}, {{{0x3f, 0x75, 0x8e, 0xb4, 0xff, 0xd8, 0xdd, 0xd6, 0x37, 0x57, 0x9d, 0x6d, 0x3b, 0xbd, 0xd5, 0x60, 0x88, 0x65, 0x9a, 0xb9, 0x4a, 0x68, 0x84, 0xa2, 0x67, 0xdd, 0x17, 0x25, 0x97, 0x04, 0x8b, 0x5e}} , {{0xbb, 0x40, 0x5e, 0xbc, 0x16, 0x92, 0x05, 0xc4, 0xc0, 0x4e, 0x72, 0x90, 0x0e, 0xab, 0xcf, 0x8a, 0xed, 0xef, 0xb9, 0x2d, 0x3b, 0xf8, 0x43, 0x5b, 0xba, 0x2d, 0xeb, 0x2f, 0x52, 0xd2, 0xd1, 0x5a}}}, {{{0x40, 0xb4, 0xab, 0xe6, 0xad, 0x9f, 0x46, 0x69, 0x4a, 0xb3, 0x8e, 0xaa, 0xea, 0x9c, 0x8a, 0x20, 0x16, 0x5d, 0x8c, 0x13, 0xbd, 0xf6, 0x1d, 0xc5, 0x24, 0xbd, 0x90, 0x2a, 0x1c, 0xc7, 0x13, 0x3b}} , {{0x54, 0xdc, 0x16, 0x0d, 0x18, 0xbe, 0x35, 0x64, 0x61, 0x52, 0x02, 0x80, 0xaf, 0x05, 0xf7, 0xa6, 0x42, 0xd3, 0x8f, 0x2e, 0x79, 0x26, 0xa8, 0xbb, 0xb2, 0x17, 0x48, 0xb2, 0x7a, 0x0a, 0x89, 0x14}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x20, 0xa8, 0x88, 0xe3, 0x91, 0xc0, 0x6e, 0xbb, 0x8a, 0x27, 0x82, 0x51, 0x83, 0xb2, 0x28, 0xa9, 0x83, 0xeb, 0xa6, 0xa9, 0x4d, 0x17, 0x59, 0x22, 0x54, 0x00, 0x50, 0x45, 0xcb, 0x48, 0x4b, 0x18}} , {{0x33, 0x7c, 0xe7, 0x26, 0xba, 0x4d, 0x32, 0xfe, 0x53, 0xf4, 0xfa, 0x83, 0xe3, 0xa5, 0x79, 0x66, 0x73, 0xef, 0x80, 0x23, 0x68, 0xc2, 0x60, 0xdd, 0xa9, 0x33, 0xdc, 0x03, 0x7a, 0xe0, 0xe0, 0x3e}}}, {{{0x34, 0x5c, 0x13, 0xfb, 0xc0, 0xe3, 0x78, 0x2b, 0x54, 0x58, 0x22, 0x9b, 0x76, 0x81, 0x7f, 0x93, 0x9c, 0x25, 0x3c, 0xd2, 0xe9, 0x96, 0x21, 0x26, 0x08, 0xf5, 0xed, 0x95, 0x11, 0xae, 0x04, 0x5a}} , {{0xb9, 0xe8, 0xc5, 0x12, 0x97, 0x1f, 0x83, 0xfe, 0x3e, 0x94, 0x99, 0xd4, 0x2d, 0xf9, 0x52, 0x59, 0x5c, 0x82, 0xa6, 0xf0, 0x75, 0x7e, 0xe8, 0xec, 0xcc, 0xac, 0x18, 0x21, 0x09, 0x67, 0x66, 0x67}}}, {{{0xb3, 0x40, 0x29, 0xd1, 0xcb, 0x1b, 0x08, 0x9e, 0x9c, 0xb7, 0x53, 0xb9, 0x3b, 0x71, 0x08, 0x95, 0x12, 0x1a, 0x58, 0xaf, 0x7e, 0x82, 0x52, 0x43, 0x4f, 0x11, 0x39, 0xf4, 0x93, 0x1a, 0x26, 0x05}} , {{0x6e, 0x44, 0xa3, 0xf9, 0x64, 0xaf, 0xe7, 0x6d, 0x7d, 0xdf, 0x1e, 0xac, 0x04, 0xea, 0x3b, 0x5f, 0x9b, 0xe8, 0x24, 0x9d, 0x0e, 0xe5, 0x2e, 0x3e, 0xdf, 0xa9, 0xf7, 0xd4, 0x50, 0x71, 0xf0, 0x78}}}, {{{0x3e, 0xa8, 0x38, 0xc2, 0x57, 0x56, 0x42, 0x9a, 0xb1, 0xe2, 0xf8, 0x45, 0xaa, 0x11, 0x48, 0x5f, 0x17, 0xc4, 0x54, 0x27, 0xdc, 0x5d, 0xaa, 0xdd, 0x41, 0xbc, 0xdf, 0x81, 0xb9, 0x53, 0xee, 0x52}} , {{0xc3, 0xf1, 0xa7, 0x6d, 0xb3, 0x5f, 0x92, 0x6f, 0xcc, 0x91, 0xb8, 0x95, 0x05, 0xdf, 0x3c, 0x64, 0x57, 0x39, 0x61, 0x51, 0xad, 0x8c, 0x38, 0x7b, 0xc8, 0xde, 0x00, 0x34, 0xbe, 0xa1, 0xb0, 0x7e}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x25, 0x24, 0x1d, 0x8a, 0x67, 0x20, 0xee, 0x42, 0xeb, 0x38, 0xed, 0x0b, 0x8b, 0xcd, 0x46, 0x9d, 0x5e, 0x6b, 0x1e, 0x24, 0x9d, 0x12, 0x05, 0x1a, 0xcc, 0x05, 0x4e, 0x92, 0x38, 0xe1, 0x1f, 0x50}} , {{0x4e, 0xee, 0x1c, 0x91, 0xe6, 0x11, 0xbd, 0x8e, 0x55, 0x1a, 0x18, 0x75, 0x66, 0xaf, 0x4d, 0x7b, 0x0f, 0xae, 0x6d, 0x85, 0xca, 0x82, 0x58, 0x21, 0x9c, 0x18, 0xe0, 0xed, 0xec, 0x22, 0x80, 0x2f}}}, {{{0x68, 0x3b, 0x0a, 0x39, 0x1d, 0x6a, 0x15, 0x57, 0xfc, 0xf0, 0x63, 0x54, 0xdb, 0x39, 0xdb, 0xe8, 0x5c, 0x64, 0xff, 0xa0, 0x09, 0x4f, 0x3b, 0xb7, 0x32, 0x60, 0x99, 0x94, 0xfd, 0x94, 0x82, 0x2d}} , {{0x24, 0xf6, 0x5a, 0x44, 0xf1, 0x55, 0x2c, 0xdb, 0xea, 0x7c, 0x84, 0x7c, 0x01, 0xac, 0xe3, 0xfd, 0xc9, 0x27, 0xc1, 0x5a, 0xb9, 0xde, 0x4f, 0x5a, 0x90, 0xdd, 0xc6, 0x67, 0xaa, 0x6f, 0x8a, 0x3a}}}, {{{0x78, 0x52, 0x87, 0xc9, 0x97, 0x63, 0xb1, 0xdd, 0x54, 0x5f, 0xc1, 0xf8, 0xf1, 0x06, 0xa6, 0xa8, 0xa3, 0x88, 0x82, 0xd4, 0xcb, 0xa6, 0x19, 0xdd, 0xd1, 0x11, 0x87, 0x08, 0x17, 0x4c, 0x37, 0x2a}} , {{0xa1, 0x0c, 0xf3, 0x08, 0x43, 0xd9, 0x24, 0x1e, 0x83, 0xa7, 0xdf, 0x91, 0xca, 0xbd, 0x69, 0x47, 0x8d, 0x1b, 0xe2, 0xb9, 0x4e, 0xb5, 0xe1, 0x76, 0xb3, 0x1c, 0x93, 0x03, 0xce, 0x5f, 0xb3, 0x5a}}}, {{{0x1d, 0xda, 0xe4, 0x61, 0x03, 0x50, 0xa9, 0x8b, 0x68, 0x18, 0xef, 0xb2, 0x1c, 0x84, 0x3b, 0xa2, 0x44, 0x95, 0xa3, 0x04, 0x3b, 0xd6, 0x99, 0x00, 0xaf, 0x76, 0x42, 0x67, 0x02, 0x7d, 0x85, 0x56}} , {{0xce, 0x72, 0x0e, 0x29, 0x84, 0xb2, 0x7d, 0xd2, 0x45, 0xbe, 0x57, 0x06, 0xed, 0x7f, 0xcf, 0xed, 0xcd, 0xef, 0x19, 0xd6, 0xbc, 0x15, 0x79, 0x64, 0xd2, 0x18, 0xe3, 0x20, 0x67, 0x3a, 0x54, 0x0b}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x52, 0xfd, 0x04, 0xc5, 0xfb, 0x99, 0xe7, 0xe8, 0xfb, 0x8c, 0xe1, 0x42, 0x03, 0xef, 0x9d, 0xd9, 0x9e, 0x4d, 0xf7, 0x80, 0xcf, 0x2e, 0xcc, 0x9b, 0x45, 0xc9, 0x7b, 0x7a, 0xbc, 0x37, 0xa8, 0x52}} , {{0x96, 0x11, 0x41, 0x8a, 0x47, 0x91, 0xfe, 0xb6, 0xda, 0x7a, 0x54, 0x63, 0xd1, 0x14, 0x35, 0x05, 0x86, 0x8c, 0xa9, 0x36, 0x3f, 0xf2, 0x85, 0x54, 0x4e, 0x92, 0xd8, 0x85, 0x01, 0x46, 0xd6, 0x50}}}, {{{0x53, 0xcd, 0xf3, 0x86, 0x40, 0xe6, 0x39, 0x42, 0x95, 0xd6, 0xcb, 0x45, 0x1a, 0x20, 0xc8, 0x45, 0x4b, 0x32, 0x69, 0x04, 0xb1, 0xaf, 0x20, 0x46, 0xc7, 0x6b, 0x23, 0x5b, 0x69, 0xee, 0x30, 0x3f}} , {{0x70, 0x83, 0x47, 0xc0, 0xdb, 0x55, 0x08, 0xa8, 0x7b, 0x18, 0x6d, 0xf5, 0x04, 0x5a, 0x20, 0x0c, 0x4a, 0x8c, 0x60, 0xae, 0xae, 0x0f, 0x64, 0x55, 0x55, 0x2e, 0xd5, 0x1d, 0x53, 0x31, 0x42, 0x41}}}, {{{0xca, 0xfc, 0x88, 0x6b, 0x96, 0x78, 0x0a, 0x8b, 0x83, 0xdc, 0xbc, 0xaf, 0x40, 0xb6, 0x8d, 0x7f, 0xef, 0xb4, 0xd1, 0x3f, 0xcc, 0xa2, 0x74, 0xc9, 0xc2, 0x92, 0x55, 0x00, 0xab, 0xdb, 0xbf, 0x4f}} , {{0x93, 0x1c, 0x06, 0x2d, 0x66, 0x65, 0x02, 0xa4, 0x97, 0x18, 0xfd, 0x00, 0xe7, 0xab, 0x03, 0xec, 0xce, 0xc1, 0xbf, 0x37, 0xf8, 0x13, 0x53, 0xa5, 0xe5, 0x0c, 0x3a, 0xa8, 0x55, 0xb9, 0xff, 0x68}}}, {{{0xe4, 0xe6, 0x6d, 0x30, 0x7d, 0x30, 0x35, 0xc2, 0x78, 0x87, 0xf9, 0xfc, 0x6b, 0x5a, 0xc3, 0xb7, 0x65, 0xd8, 0x2e, 0xc7, 0xa5, 0x0c, 0xc6, 0xdc, 0x12, 0xaa, 0xd6, 0x4f, 0xc5, 0x38, 0xbc, 0x0e}} , {{0xe2, 0x3c, 0x76, 0x86, 0x38, 0xf2, 0x7b, 0x2c, 0x16, 0x78, 0x8d, 0xf5, 0xa4, 0x15, 0xda, 0xdb, 0x26, 0x85, 0xa0, 0x56, 0xdd, 0x1d, 0xe3, 0xb3, 0xfd, 0x40, 0xef, 0xf2, 0xd9, 0xa1, 0xb3, 0x04}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xdb, 0x49, 0x0e, 0xe6, 0x58, 0x10, 0x7a, 0x52, 0xda, 0xb5, 0x7d, 0x37, 0x6a, 0x3e, 0xa1, 0x78, 0xce, 0xc7, 0x1c, 0x24, 0x23, 0xdb, 0x7d, 0xfb, 0x8c, 0x8d, 0xdc, 0x30, 0x67, 0x69, 0x75, 0x3b}} , {{0xa9, 0xea, 0x6d, 0x16, 0x16, 0x60, 0xf4, 0x60, 0x87, 0x19, 0x44, 0x8c, 0x4a, 0x8b, 0x3e, 0xfb, 0x16, 0x00, 0x00, 0x54, 0xa6, 0x9e, 0x9f, 0xef, 0xcf, 0xd9, 0xd2, 0x4c, 0x74, 0x31, 0xd0, 0x34}}}, {{{0xa4, 0xeb, 0x04, 0xa4, 0x8c, 0x8f, 0x71, 0x27, 0x95, 0x85, 0x5d, 0x55, 0x4b, 0xb1, 0x26, 0x26, 0xc8, 0xae, 0x6a, 0x7d, 0xa2, 0x21, 0xca, 0xce, 0x38, 0xab, 0x0f, 0xd0, 0xd5, 0x2b, 0x6b, 0x00}} , {{0xe5, 0x67, 0x0c, 0xf1, 0x3a, 0x9a, 0xea, 0x09, 0x39, 0xef, 0xd1, 0x30, 0xbc, 0x33, 0xba, 0xb1, 0x6a, 0xc5, 0x27, 0x08, 0x7f, 0x54, 0x80, 0x3d, 0xab, 0xf6, 0x15, 0x7a, 0xc2, 0x40, 0x73, 0x72}}}, {{{0x84, 0x56, 0x82, 0xb6, 0x12, 0x70, 0x7f, 0xf7, 0xf0, 0xbd, 0x5b, 0xa9, 0xd5, 0xc5, 0x5f, 0x59, 0xbf, 0x7f, 0xb3, 0x55, 0x22, 0x02, 0xc9, 0x44, 0x55, 0x87, 0x8f, 0x96, 0x98, 0x64, 0x6d, 0x15}} , {{0xb0, 0x8b, 0xaa, 0x1e, 0xec, 0xc7, 0xa5, 0x8f, 0x1f, 0x92, 0x04, 0xc6, 0x05, 0xf6, 0xdf, 0xa1, 0xcc, 0x1f, 0x81, 0xf5, 0x0e, 0x9c, 0x57, 0xdc, 0xe3, 0xbb, 0x06, 0x87, 0x1e, 0xfe, 0x23, 0x6c}}}, {{{0xd8, 0x2b, 0x5b, 0x16, 0xea, 0x20, 0xf1, 0xd3, 0x68, 0x8f, 0xae, 0x5b, 0xd0, 0xa9, 0x1a, 0x19, 0xa8, 0x36, 0xfb, 0x2b, 0x57, 0x88, 0x7d, 0x90, 0xd5, 0xa6, 0xf3, 0xdc, 0x38, 0x89, 0x4e, 0x1f}} , {{0xcc, 0x19, 0xda, 0x9b, 0x3b, 0x43, 0x48, 0x21, 0x2e, 0x23, 0x4d, 0x3d, 0xae, 0xf8, 0x8c, 0xfc, 0xdd, 0xa6, 0x74, 0x37, 0x65, 0xca, 0xee, 0x1a, 0x19, 0x8e, 0x9f, 0x64, 0x6f, 0x0c, 0x8b, 0x5a}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x25, 0xb9, 0xc2, 0xf0, 0x72, 0xb8, 0x15, 0x16, 0xcc, 0x8d, 0x3c, 0x6f, 0x25, 0xed, 0xf4, 0x46, 0x2e, 0x0c, 0x60, 0x0f, 0xe2, 0x84, 0x34, 0x55, 0x89, 0x59, 0x34, 0x1b, 0xf5, 0x8d, 0xfe, 0x08}} , {{0xf8, 0xab, 0x93, 0xbc, 0x44, 0xba, 0x1b, 0x75, 0x4b, 0x49, 0x6f, 0xd0, 0x54, 0x2e, 0x63, 0xba, 0xb5, 0xea, 0xed, 0x32, 0x14, 0xc9, 0x94, 0xd8, 0xc5, 0xce, 0xf4, 0x10, 0x68, 0xe0, 0x38, 0x27}}}, {{{0x74, 0x1c, 0x14, 0x9b, 0xd4, 0x64, 0x61, 0x71, 0x5a, 0xb6, 0x21, 0x33, 0x4f, 0xf7, 0x8e, 0xba, 0xa5, 0x48, 0x9a, 0xc7, 0xfa, 0x9a, 0xf0, 0xb4, 0x62, 0xad, 0xf2, 0x5e, 0xcc, 0x03, 0x24, 0x1a}} , {{0xf5, 0x76, 0xfd, 0xe4, 0xaf, 0xb9, 0x03, 0x59, 0xce, 0x63, 0xd2, 0x3b, 0x1f, 0xcd, 0x21, 0x0c, 0xad, 0x44, 0xa5, 0x97, 0xac, 0x80, 0x11, 0x02, 0x9b, 0x0c, 0xe5, 0x8b, 0xcd, 0xfb, 0x79, 0x77}}}, {{{0x15, 0xbe, 0x9a, 0x0d, 0xba, 0x38, 0x72, 0x20, 0x8a, 0xf5, 0xbe, 0x59, 0x93, 0x79, 0xb7, 0xf6, 0x6a, 0x0c, 0x38, 0x27, 0x1a, 0x60, 0xf4, 0x86, 0x3b, 0xab, 0x5a, 0x00, 0xa0, 0xce, 0x21, 0x7d}} , {{0x6c, 0xba, 0x14, 0xc5, 0xea, 0x12, 0x9e, 0x2e, 0x82, 0x63, 0xce, 0x9b, 0x4a, 0xe7, 0x1d, 0xec, 0xf1, 0x2e, 0x51, 0x1c, 0xf4, 0xd0, 0x69, 0x15, 0x42, 0x9d, 0xa3, 0x3f, 0x0e, 0xbf, 0xe9, 0x5c}}}, {{{0xe4, 0x0d, 0xf4, 0xbd, 0xee, 0x31, 0x10, 0xed, 0xcb, 0x12, 0x86, 0xad, 0xd4, 0x2f, 0x90, 0x37, 0x32, 0xc3, 0x0b, 0x73, 0xec, 0x97, 0x85, 0xa4, 0x01, 0x1c, 0x76, 0x35, 0xfe, 0x75, 0xdd, 0x71}} , {{0x11, 0xa4, 0x88, 0x9f, 0x3e, 0x53, 0x69, 0x3b, 0x1b, 0xe0, 0xf7, 0xba, 0x9b, 0xad, 0x4e, 0x81, 0x5f, 0xb5, 0x5c, 0xae, 0xbe, 0x67, 0x86, 0x37, 0x34, 0x8e, 0x07, 0x32, 0x45, 0x4a, 0x67, 0x39}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x90, 0x70, 0x58, 0x20, 0x03, 0x1e, 0x67, 0xb2, 0xc8, 0x9b, 0x58, 0xc5, 0xb1, 0xeb, 0x2d, 0x4a, 0xde, 0x82, 0x8c, 0xf2, 0xd2, 0x14, 0xb8, 0x70, 0x61, 0x4e, 0x73, 0xd6, 0x0b, 0x6b, 0x0d, 0x30}} , {{0x81, 0xfc, 0x55, 0x5c, 0xbf, 0xa7, 0xc4, 0xbd, 0xe2, 0xf0, 0x4b, 0x8f, 0xe9, 0x7d, 0x99, 0xfa, 0xd3, 0xab, 0xbc, 0xc7, 0x83, 0x2b, 0x04, 0x7f, 0x0c, 0x19, 0x43, 0x03, 0x3d, 0x07, 0xca, 0x40}}}, {{{0xf9, 0xc8, 0xbe, 0x8c, 0x16, 0x81, 0x39, 0x96, 0xf6, 0x17, 0x58, 0xc8, 0x30, 0x58, 0xfb, 0xc2, 0x03, 0x45, 0xd2, 0x52, 0x76, 0xe0, 0x6a, 0x26, 0x28, 0x5c, 0x88, 0x59, 0x6a, 0x5a, 0x54, 0x42}} , {{0x07, 0xb5, 0x2e, 0x2c, 0x67, 0x15, 0x9b, 0xfb, 0x83, 0x69, 0x1e, 0x0f, 0xda, 0xd6, 0x29, 0xb1, 0x60, 0xe0, 0xb2, 0xba, 0x69, 0xa2, 0x9e, 0xbd, 0xbd, 0xe0, 0x1c, 0xbd, 0xcd, 0x06, 0x64, 0x70}}}, {{{0x41, 0xfa, 0x8c, 0xe1, 0x89, 0x8f, 0x27, 0xc8, 0x25, 0x8f, 0x6f, 0x5f, 0x55, 0xf8, 0xde, 0x95, 0x6d, 0x2f, 0x75, 0x16, 0x2b, 0x4e, 0x44, 0xfd, 0x86, 0x6e, 0xe9, 0x70, 0x39, 0x76, 0x97, 0x7e}} , {{0x17, 0x62, 0x6b, 0x14, 0xa1, 0x7c, 0xd0, 0x79, 0x6e, 0xd8, 0x8a, 0xa5, 0x6d, 0x8c, 0x93, 0xd2, 0x3f, 0xec, 0x44, 0x8d, 0x6e, 0x91, 0x01, 0x8c, 0x8f, 0xee, 0x01, 0x8f, 0xc0, 0xb4, 0x85, 0x0e}}}, {{{0x02, 0x3a, 0x70, 0x41, 0xe4, 0x11, 0x57, 0x23, 0xac, 0xe6, 0xfc, 0x54, 0x7e, 0xcd, 0xd7, 0x22, 0xcb, 0x76, 0x9f, 0x20, 0xce, 0xa0, 0x73, 0x76, 0x51, 0x3b, 0xa4, 0xf8, 0xe3, 0x62, 0x12, 0x6c}} , {{0x7f, 0x00, 0x9c, 0x26, 0x0d, 0x6f, 0x48, 0x7f, 0x3a, 0x01, 0xed, 0xc5, 0x96, 0xb0, 0x1f, 0x4f, 0xa8, 0x02, 0x62, 0x27, 0x8a, 0x50, 0x8d, 0x9a, 0x8b, 0x52, 0x0f, 0x1e, 0xcf, 0x41, 0x38, 0x19}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xf5, 0x6c, 0xd4, 0x2f, 0x0f, 0x69, 0x0f, 0x87, 0x3f, 0x61, 0x65, 0x1e, 0x35, 0x34, 0x85, 0xba, 0x02, 0x30, 0xac, 0x25, 0x3d, 0xe2, 0x62, 0xf1, 0xcc, 0xe9, 0x1b, 0xc2, 0xef, 0x6a, 0x42, 0x57}} , {{0x34, 0x1f, 0x2e, 0xac, 0xd1, 0xc7, 0x04, 0x52, 0x32, 0x66, 0xb2, 0x33, 0x73, 0x21, 0x34, 0x54, 0xf7, 0x71, 0xed, 0x06, 0xb0, 0xff, 0xa6, 0x59, 0x6f, 0x8a, 0x4e, 0xfb, 0x02, 0xb0, 0x45, 0x6b}}}, {{{0xf5, 0x48, 0x0b, 0x03, 0xc5, 0x22, 0x7d, 0x80, 0x08, 0x53, 0xfe, 0x32, 0xb1, 0xa1, 0x8a, 0x74, 0x6f, 0xbd, 0x3f, 0x85, 0xf4, 0xcf, 0xf5, 0x60, 0xaf, 0x41, 0x7e, 0x3e, 0x46, 0xa3, 0x5a, 0x20}} , {{0xaa, 0x35, 0x87, 0x44, 0x63, 0x66, 0x97, 0xf8, 0x6e, 0x55, 0x0c, 0x04, 0x3e, 0x35, 0x50, 0xbf, 0x93, 0x69, 0xd2, 0x8b, 0x05, 0x55, 0x99, 0xbe, 0xe2, 0x53, 0x61, 0xec, 0xe8, 0x08, 0x0b, 0x32}}}, {{{0xb3, 0x10, 0x45, 0x02, 0x69, 0x59, 0x2e, 0x97, 0xd9, 0x64, 0xf8, 0xdb, 0x25, 0x80, 0xdc, 0xc4, 0xd5, 0x62, 0x3c, 0xed, 0x65, 0x91, 0xad, 0xd1, 0x57, 0x81, 0x94, 0xaa, 0xa1, 0x29, 0xfc, 0x68}} , {{0xdd, 0xb5, 0x7d, 0xab, 0x5a, 0x21, 0x41, 0x53, 0xbb, 0x17, 0x79, 0x0d, 0xd1, 0xa8, 0x0c, 0x0c, 0x20, 0x88, 0x09, 0xe9, 0x84, 0xe8, 0x25, 0x11, 0x67, 0x7a, 0x8b, 0x1a, 0xe4, 0x5d, 0xe1, 0x5d}}}, {{{0x37, 0xea, 0xfe, 0x65, 0x3b, 0x25, 0xe8, 0xe1, 0xc2, 0xc5, 0x02, 0xa4, 0xbe, 0x98, 0x0a, 0x2b, 0x61, 0xc1, 0x9b, 0xe2, 0xd5, 0x92, 0xe6, 0x9e, 0x7d, 0x1f, 0xca, 0x43, 0x88, 0x8b, 0x2c, 0x59}} , {{0xe0, 0xb5, 0x00, 0x1d, 0x2a, 0x6f, 0xaf, 0x79, 0x86, 0x2f, 0xa6, 0x5a, 0x93, 0xd1, 0xfe, 0xae, 0x3a, 0xee, 0xdb, 0x7c, 0x61, 0xbe, 0x7c, 0x01, 0xf9, 0xfe, 0x52, 0xdc, 0xd8, 0x52, 0xa3, 0x42}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x22, 0xaf, 0x13, 0x37, 0xbd, 0x37, 0x71, 0xac, 0x04, 0x46, 0x63, 0xac, 0xa4, 0x77, 0xed, 0x25, 0x38, 0xe0, 0x15, 0xa8, 0x64, 0x00, 0x0d, 0xce, 0x51, 0x01, 0xa9, 0xbc, 0x0f, 0x03, 0x1c, 0x04}} , {{0x89, 0xf9, 0x80, 0x07, 0xcf, 0x3f, 0xb3, 0xe9, 0xe7, 0x45, 0x44, 0x3d, 0x2a, 0x7c, 0xe9, 0xe4, 0x16, 0x5c, 0x5e, 0x65, 0x1c, 0xc7, 0x7d, 0xc6, 0x7a, 0xfb, 0x43, 0xee, 0x25, 0x76, 0x46, 0x72}}}, {{{0x02, 0xa2, 0xed, 0xf4, 0x8f, 0x6b, 0x0b, 0x3e, 0xeb, 0x35, 0x1a, 0xd5, 0x7e, 0xdb, 0x78, 0x00, 0x96, 0x8a, 0xa0, 0xb4, 0xcf, 0x60, 0x4b, 0xd4, 0xd5, 0xf9, 0x2d, 0xbf, 0x88, 0xbd, 0x22, 0x62}} , {{0x13, 0x53, 0xe4, 0x82, 0x57, 0xfa, 0x1e, 0x8f, 0x06, 0x2b, 0x90, 0xba, 0x08, 0xb6, 0x10, 0x54, 0x4f, 0x7c, 0x1b, 0x26, 0xed, 0xda, 0x6b, 0xdd, 0x25, 0xd0, 0x4e, 0xea, 0x42, 0xbb, 0x25, 0x03}}}, {{{0x51, 0x16, 0x50, 0x7c, 0xd5, 0x5d, 0xf6, 0x99, 0xe8, 0x77, 0x72, 0x4e, 0xfa, 0x62, 0xcb, 0x76, 0x75, 0x0c, 0xe2, 0x71, 0x98, 0x92, 0xd5, 0xfa, 0x45, 0xdf, 0x5c, 0x6f, 0x1e, 0x9e, 0x28, 0x69}} , {{0x0d, 0xac, 0x66, 0x6d, 0xc3, 0x8b, 0xba, 0x16, 0xb5, 0xe2, 0xa0, 0x0d, 0x0c, 0xbd, 0xa4, 0x8e, 0x18, 0x6c, 0xf2, 0xdc, 0xf9, 0xdc, 0x4a, 0x86, 0x25, 0x95, 0x14, 0xcb, 0xd8, 0x1a, 0x04, 0x0f}}}, {{{0x97, 0xa5, 0xdb, 0x8b, 0x2d, 0xaa, 0x42, 0x11, 0x09, 0xf2, 0x93, 0xbb, 0xd9, 0x06, 0x84, 0x4e, 0x11, 0xa8, 0xa0, 0x25, 0x2b, 0xa6, 0x5f, 0xae, 0xc4, 0xb4, 0x4c, 0xc8, 0xab, 0xc7, 0x3b, 0x02}} , {{0xee, 0xc9, 0x29, 0x0f, 0xdf, 0x11, 0x85, 0xed, 0xce, 0x0d, 0x62, 0x2c, 0x8f, 0x4b, 0xf9, 0x04, 0xe9, 0x06, 0x72, 0x1d, 0x37, 0x20, 0x50, 0xc9, 0x14, 0xeb, 0xec, 0x39, 0xa7, 0x97, 0x2b, 0x4d}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x69, 0xd1, 0x39, 0xbd, 0xfb, 0x33, 0xbe, 0xc4, 0xf0, 0x5c, 0xef, 0xf0, 0x56, 0x68, 0xfc, 0x97, 0x47, 0xc8, 0x72, 0xb6, 0x53, 0xa4, 0x0a, 0x98, 0xa5, 0xb4, 0x37, 0x71, 0xcf, 0x66, 0x50, 0x6d}} , {{0x17, 0xa4, 0x19, 0x52, 0x11, 0x47, 0xb3, 0x5c, 0x5b, 0xa9, 0x2e, 0x22, 0xb4, 0x00, 0x52, 0xf9, 0x57, 0x18, 0xb8, 0xbe, 0x5a, 0xe3, 0xab, 0x83, 0xc8, 0x87, 0x0a, 0x2a, 0xd8, 0x8c, 0xbb, 0x54}}}, {{{0xa9, 0x62, 0x93, 0x85, 0xbe, 0xe8, 0x73, 0x4a, 0x0e, 0xb0, 0xb5, 0x2d, 0x94, 0x50, 0xaa, 0xd3, 0xb2, 0xea, 0x9d, 0x62, 0x76, 0x3b, 0x07, 0x34, 0x4e, 0x2d, 0x70, 0xc8, 0x9a, 0x15, 0x66, 0x6b}} , {{0xc5, 0x96, 0xca, 0xc8, 0x22, 0x1a, 0xee, 0x5f, 0xe7, 0x31, 0x60, 0x22, 0x83, 0x08, 0x63, 0xce, 0xb9, 0x32, 0x44, 0x58, 0x5d, 0x3a, 0x9b, 0xe4, 0x04, 0xd5, 0xef, 0x38, 0xef, 0x4b, 0xdd, 0x19}}}, {{{0x4d, 0xc2, 0x17, 0x75, 0xa1, 0x68, 0xcd, 0xc3, 0xc6, 0x03, 0x44, 0xe3, 0x78, 0x09, 0x91, 0x47, 0x3f, 0x0f, 0xe4, 0x92, 0x58, 0xfa, 0x7d, 0x1f, 0x20, 0x94, 0x58, 0x5e, 0xbc, 0x19, 0x02, 0x6f}} , {{0x20, 0xd6, 0xd8, 0x91, 0x54, 0xa7, 0xf3, 0x20, 0x4b, 0x34, 0x06, 0xfa, 0x30, 0xc8, 0x6f, 0x14, 0x10, 0x65, 0x74, 0x13, 0x4e, 0xf0, 0x69, 0x26, 0xce, 0xcf, 0x90, 0xf4, 0xd0, 0xc5, 0xc8, 0x64}}}, {{{0x26, 0xa2, 0x50, 0x02, 0x24, 0x72, 0xf1, 0xf0, 0x4e, 0x2d, 0x93, 0xd5, 0x08, 0xe7, 0xae, 0x38, 0xf7, 0x18, 0xa5, 0x32, 0x34, 0xc2, 0xf0, 0xa6, 0xec, 0xb9, 0x61, 0x7b, 0x64, 0x99, 0xac, 0x71}} , {{0x25, 0xcf, 0x74, 0x55, 0x1b, 0xaa, 0xa9, 0x38, 0x41, 0x40, 0xd5, 0x95, 0x95, 0xab, 0x1c, 0x5e, 0xbc, 0x41, 0x7e, 0x14, 0x30, 0xbe, 0x13, 0x89, 0xf4, 0xe5, 0xeb, 0x28, 0xc0, 0xc2, 0x96, 0x3a}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x2b, 0x77, 0x45, 0xec, 0x67, 0x76, 0x32, 0x4c, 0xb9, 0xdf, 0x25, 0x32, 0x6b, 0xcb, 0xe7, 0x14, 0x61, 0x43, 0xee, 0xba, 0x9b, 0x71, 0xef, 0xd2, 0x48, 0x65, 0xbb, 0x1b, 0x8a, 0x13, 0x1b, 0x22}} , {{0x84, 0xad, 0x0c, 0x18, 0x38, 0x5a, 0xba, 0xd0, 0x98, 0x59, 0xbf, 0x37, 0xb0, 0x4f, 0x97, 0x60, 0x20, 0xb3, 0x9b, 0x97, 0xf6, 0x08, 0x6c, 0xa4, 0xff, 0xfb, 0xb7, 0xfa, 0x95, 0xb2, 0x51, 0x79}}}, {{{0x28, 0x5c, 0x3f, 0xdb, 0x6b, 0x18, 0x3b, 0x5c, 0xd1, 0x04, 0x28, 0xde, 0x85, 0x52, 0x31, 0xb5, 0xbb, 0xf6, 0xa9, 0xed, 0xbe, 0x28, 0x4f, 0xb3, 0x7e, 0x05, 0x6a, 0xdb, 0x95, 0x0d, 0x1b, 0x1c}} , {{0xd5, 0xc5, 0xc3, 0x9a, 0x0a, 0xd0, 0x31, 0x3e, 0x07, 0x36, 0x8e, 0xc0, 0x8a, 0x62, 0xb1, 0xca, 0xd6, 0x0e, 0x1e, 0x9d, 0xef, 0xab, 0x98, 0x4d, 0xbb, 0x6c, 0x05, 0xe0, 0xe4, 0x5d, 0xbd, 0x57}}}, {{{0xcc, 0x21, 0x27, 0xce, 0xfd, 0xa9, 0x94, 0x8e, 0xe1, 0xab, 0x49, 0xe0, 0x46, 0x26, 0xa1, 0xa8, 0x8c, 0xa1, 0x99, 0x1d, 0xb4, 0x27, 0x6d, 0x2d, 0xc8, 0x39, 0x30, 0x5e, 0x37, 0x52, 0xc4, 0x6e}} , {{0xa9, 0x85, 0xf4, 0xe7, 0xb0, 0x15, 0x33, 0x84, 0x1b, 0x14, 0x1a, 0x02, 0xd9, 0x3b, 0xad, 0x0f, 0x43, 0x6c, 0xea, 0x3e, 0x0f, 0x7e, 0xda, 0xdd, 0x6b, 0x4c, 0x7f, 0x6e, 0xd4, 0x6b, 0xbf, 0x0f}}}, {{{0x47, 0x9f, 0x7c, 0x56, 0x7c, 0x43, 0x91, 0x1c, 0xbb, 0x4e, 0x72, 0x3e, 0x64, 0xab, 0xa0, 0xa0, 0xdf, 0xb4, 0xd8, 0x87, 0x3a, 0xbd, 0xa8, 0x48, 0xc9, 0xb8, 0xef, 0x2e, 0xad, 0x6f, 0x84, 0x4f}} , {{0x2d, 0x2d, 0xf0, 0x1b, 0x7e, 0x2a, 0x6c, 0xf8, 0xa9, 0x6a, 0xe1, 0xf0, 0x99, 0xa1, 0x67, 0x9a, 0xd4, 0x13, 0xca, 0xca, 0xba, 0x27, 0x92, 0xaa, 0xa1, 0x5d, 0x50, 0xde, 0xcc, 0x40, 0x26, 0x0a}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x9f, 0x3e, 0xf2, 0xb2, 0x90, 0xce, 0xdb, 0x64, 0x3e, 0x03, 0xdd, 0x37, 0x36, 0x54, 0x70, 0x76, 0x24, 0xb5, 0x69, 0x03, 0xfc, 0xa0, 0x2b, 0x74, 0xb2, 0x05, 0x0e, 0xcc, 0xd8, 0x1f, 0x6a, 0x1f}} , {{0x19, 0x5e, 0x60, 0x69, 0x58, 0x86, 0xa0, 0x31, 0xbd, 0x32, 0xe9, 0x2c, 0x5c, 0xd2, 0x85, 0xba, 0x40, 0x64, 0xa8, 0x74, 0xf8, 0x0e, 0x1c, 0xb3, 0xa9, 0x69, 0xe8, 0x1e, 0x40, 0x64, 0x99, 0x77}}}, {{{0x6c, 0x32, 0x4f, 0xfd, 0xbb, 0x5c, 0xbb, 0x8d, 0x64, 0x66, 0x4a, 0x71, 0x1f, 0x79, 0xa3, 0xad, 0x8d, 0xf9, 0xd4, 0xec, 0xcf, 0x67, 0x70, 0xfa, 0x05, 0x4a, 0x0f, 0x6e, 0xaf, 0x87, 0x0a, 0x6f}} , {{0xc6, 0x36, 0x6e, 0x6c, 0x8c, 0x24, 0x09, 0x60, 0xbe, 0x26, 0xd2, 0x4c, 0x5e, 0x17, 0xca, 0x5f, 0x1d, 0xcc, 0x87, 0xe8, 0x42, 0x6a, 0xcb, 0xcb, 0x7d, 0x92, 0x05, 0x35, 0x81, 0x13, 0x60, 0x6b}}}, {{{0xf4, 0x15, 0xcd, 0x0f, 0x0a, 0xaf, 0x4e, 0x6b, 0x51, 0xfd, 0x14, 0xc4, 0x2e, 0x13, 0x86, 0x74, 0x44, 0xcb, 0x66, 0x6b, 0xb6, 0x9d, 0x74, 0x56, 0x32, 0xac, 0x8d, 0x8e, 0x8c, 0x8c, 0x8c, 0x39}} , {{0xca, 0x59, 0x74, 0x1a, 0x11, 0xef, 0x6d, 0xf7, 0x39, 0x5c, 0x3b, 0x1f, 0xfa, 0xe3, 0x40, 0x41, 0x23, 0x9e, 0xf6, 0xd1, 0x21, 0xa2, 0xbf, 0xad, 0x65, 0x42, 0x6b, 0x59, 0x8a, 0xe8, 0xc5, 0x7f}}}, {{{0x64, 0x05, 0x7a, 0x84, 0x4a, 0x13, 0xc3, 0xf6, 0xb0, 0x6e, 0x9a, 0x6b, 0x53, 0x6b, 0x32, 0xda, 0xd9, 0x74, 0x75, 0xc4, 0xba, 0x64, 0x3d, 0x3b, 0x08, 0xdd, 0x10, 0x46, 0xef, 0xc7, 0x90, 0x1f}} , {{0x7b, 0x2f, 0x3a, 0xce, 0xc8, 0xa1, 0x79, 0x3c, 0x30, 0x12, 0x44, 0x28, 0xf6, 0xbc, 0xff, 0xfd, 0xf4, 0xc0, 0x97, 0xb0, 0xcc, 0xc3, 0x13, 0x7a, 0xb9, 0x9a, 0x16, 0xe4, 0xcb, 0x4c, 0x34, 0x63}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x07, 0x4e, 0xd3, 0x2d, 0x09, 0x33, 0x0e, 0xd2, 0x0d, 0xbe, 0x3e, 0xe7, 0xe4, 0xaa, 0xb7, 0x00, 0x8b, 0xe8, 0xad, 0xaa, 0x7a, 0x8d, 0x34, 0x28, 0xa9, 0x81, 0x94, 0xc5, 0xe7, 0x42, 0xac, 0x47}} , {{0x24, 0x89, 0x7a, 0x8f, 0xb5, 0x9b, 0xf0, 0xc2, 0x03, 0x64, 0xd0, 0x1e, 0xf5, 0xa4, 0xb2, 0xf3, 0x74, 0xe9, 0x1a, 0x16, 0xfd, 0xcb, 0x15, 0xea, 0xeb, 0x10, 0x6c, 0x35, 0xd1, 0xc1, 0xa6, 0x28}}}, {{{0xcc, 0xd5, 0x39, 0xfc, 0xa5, 0xa4, 0xad, 0x32, 0x15, 0xce, 0x19, 0xe8, 0x34, 0x2b, 0x1c, 0x60, 0x91, 0xfc, 0x05, 0xa9, 0xb3, 0xdc, 0x80, 0x29, 0xc4, 0x20, 0x79, 0x06, 0x39, 0xc0, 0xe2, 0x22}} , {{0xbb, 0xa8, 0xe1, 0x89, 0x70, 0x57, 0x18, 0x54, 0x3c, 0xf6, 0x0d, 0x82, 0x12, 0x05, 0x87, 0x96, 0x06, 0x39, 0xe3, 0xf8, 0xb3, 0x95, 0xe5, 0xd7, 0x26, 0xbf, 0x09, 0x5a, 0x94, 0xf9, 0x1c, 0x63}}}, {{{0x2b, 0x8c, 0x2d, 0x9a, 0x8b, 0x84, 0xf2, 0x56, 0xfb, 0xad, 0x2e, 0x7f, 0xb7, 0xfc, 0x30, 0xe1, 0x35, 0x89, 0xba, 0x4d, 0xa8, 0x6d, 0xce, 0x8c, 0x8b, 0x30, 0xe0, 0xda, 0x29, 0x18, 0x11, 0x17}} , {{0x19, 0xa6, 0x5a, 0x65, 0x93, 0xc3, 0xb5, 0x31, 0x22, 0x4f, 0xf3, 0xf6, 0x0f, 0xeb, 0x28, 0xc3, 0x7c, 0xeb, 0xce, 0x86, 0xec, 0x67, 0x76, 0x6e, 0x35, 0x45, 0x7b, 0xd8, 0x6b, 0x92, 0x01, 0x65}}}, {{{0x3d, 0xd5, 0x9a, 0x64, 0x73, 0x36, 0xb1, 0xd6, 0x86, 0x98, 0x42, 0x3f, 0x8a, 0xf1, 0xc7, 0xf5, 0x42, 0xa8, 0x9c, 0x52, 0xa8, 0xdc, 0xf9, 0x24, 0x3f, 0x4a, 0xa1, 0xa4, 0x5b, 0xe8, 0x62, 0x1a}} , {{0xc5, 0xbd, 0xc8, 0x14, 0xd5, 0x0d, 0xeb, 0xe1, 0xa5, 0xe6, 0x83, 0x11, 0x09, 0x00, 0x1d, 0x55, 0x83, 0x51, 0x7e, 0x75, 0x00, 0x81, 0xb9, 0xcb, 0xd8, 0xc5, 0xe5, 0xa1, 0xd9, 0x17, 0x6d, 0x1f}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xea, 0xf9, 0xe4, 0xe9, 0xe1, 0x52, 0x3f, 0x51, 0x19, 0x0d, 0xdd, 0xd9, 0x9d, 0x93, 0x31, 0x87, 0x23, 0x09, 0xd5, 0x83, 0xeb, 0x92, 0x09, 0x76, 0x6e, 0xe3, 0xf8, 0xc0, 0xa2, 0x66, 0xb5, 0x36}} , {{0x3a, 0xbb, 0x39, 0xed, 0x32, 0x02, 0xe7, 0x43, 0x7a, 0x38, 0x14, 0x84, 0xe3, 0x44, 0xd2, 0x5e, 0x94, 0xdd, 0x78, 0x89, 0x55, 0x4c, 0x73, 0x9e, 0xe1, 0xe4, 0x3e, 0x43, 0xd0, 0x4a, 0xde, 0x1b}}}, {{{0xb2, 0xe7, 0x8f, 0xe3, 0xa3, 0xc5, 0xcb, 0x72, 0xee, 0x79, 0x41, 0xf8, 0xdf, 0xee, 0x65, 0xc5, 0x45, 0x77, 0x27, 0x3c, 0xbd, 0x58, 0xd3, 0x75, 0xe2, 0x04, 0x4b, 0xbb, 0x65, 0xf3, 0xc8, 0x0f}} , {{0x24, 0x7b, 0x93, 0x34, 0xb5, 0xe2, 0x74, 0x48, 0xcd, 0xa0, 0x0b, 0x92, 0x97, 0x66, 0x39, 0xf4, 0xb0, 0xe2, 0x5d, 0x39, 0x6a, 0x5b, 0x45, 0x17, 0x78, 0x1e, 0xdb, 0x91, 0x81, 0x1c, 0xf9, 0x16}}}, {{{0x16, 0xdf, 0xd1, 0x5a, 0xd5, 0xe9, 0x4e, 0x58, 0x95, 0x93, 0x5f, 0x51, 0x09, 0xc3, 0x2a, 0xc9, 0xd4, 0x55, 0x48, 0x79, 0xa4, 0xa3, 0xb2, 0xc3, 0x62, 0xaa, 0x8c, 0xe8, 0xad, 0x47, 0x39, 0x1b}} , {{0x46, 0xda, 0x9e, 0x51, 0x3a, 0xe6, 0xd1, 0xa6, 0xbb, 0x4d, 0x7b, 0x08, 0xbe, 0x8c, 0xd5, 0xf3, 0x3f, 0xfd, 0xf7, 0x44, 0x80, 0x2d, 0x53, 0x4b, 0xd0, 0x87, 0x68, 0xc1, 0xb5, 0xd8, 0xf7, 0x07}}}, {{{0xf4, 0x10, 0x46, 0xbe, 0xb7, 0xd2, 0xd1, 0xce, 0x5e, 0x76, 0xa2, 0xd7, 0x03, 0xdc, 0xe4, 0x81, 0x5a, 0xf6, 0x3c, 0xde, 0xae, 0x7a, 0x9d, 0x21, 0x34, 0xa5, 0xf6, 0xa9, 0x73, 0xe2, 0x8d, 0x60}} , {{0xfa, 0x44, 0x71, 0xf6, 0x41, 0xd8, 0xc6, 0x58, 0x13, 0x37, 0xeb, 0x84, 0x0f, 0x96, 0xc7, 0xdc, 0xc8, 0xa9, 0x7a, 0x83, 0xb2, 0x2f, 0x31, 0xb1, 0x1a, 0xd8, 0x98, 0x3f, 0x11, 0xd0, 0x31, 0x3b}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x81, 0xd5, 0x34, 0x16, 0x01, 0xa3, 0x93, 0xea, 0x52, 0x94, 0xec, 0x93, 0xb7, 0x81, 0x11, 0x2d, 0x58, 0xf9, 0xb5, 0x0a, 0xaa, 0x4f, 0xf6, 0x2e, 0x3f, 0x36, 0xbf, 0x33, 0x5a, 0xe7, 0xd1, 0x08}} , {{0x1a, 0xcf, 0x42, 0xae, 0xcc, 0xb5, 0x77, 0x39, 0xc4, 0x5b, 0x5b, 0xd0, 0x26, 0x59, 0x27, 0xd0, 0x55, 0x71, 0x12, 0x9d, 0x88, 0x3d, 0x9c, 0xea, 0x41, 0x6a, 0xf0, 0x50, 0x93, 0x93, 0xdd, 0x47}}}, {{{0x6f, 0xc9, 0x51, 0x6d, 0x1c, 0xaa, 0xf5, 0xa5, 0x90, 0x3f, 0x14, 0xe2, 0x6e, 0x8e, 0x64, 0xfd, 0xac, 0xe0, 0x4e, 0x22, 0xe5, 0xc1, 0xbc, 0x29, 0x0a, 0x6a, 0x9e, 0xa1, 0x60, 0xcb, 0x2f, 0x0b}} , {{0xdc, 0x39, 0x32, 0xf3, 0xa1, 0x44, 0xe9, 0xc5, 0xc3, 0x78, 0xfb, 0x95, 0x47, 0x34, 0x35, 0x34, 0xe8, 0x25, 0xde, 0x93, 0xc6, 0xb4, 0x76, 0x6d, 0x86, 0x13, 0xc6, 0xe9, 0x68, 0xb5, 0x01, 0x63}}}, {{{0x1f, 0x9a, 0x52, 0x64, 0x97, 0xd9, 0x1c, 0x08, 0x51, 0x6f, 0x26, 0x9d, 0xaa, 0x93, 0x33, 0x43, 0xfa, 0x77, 0xe9, 0x62, 0x9b, 0x5d, 0x18, 0x75, 0xeb, 0x78, 0xf7, 0x87, 0x8f, 0x41, 0xb4, 0x4d}} , {{0x13, 0xa8, 0x82, 0x3e, 0xe9, 0x13, 0xad, 0xeb, 0x01, 0xca, 0xcf, 0xda, 0xcd, 0xf7, 0x6c, 0xc7, 0x7a, 0xdc, 0x1e, 0x6e, 0xc8, 0x4e, 0x55, 0x62, 0x80, 0xea, 0x78, 0x0c, 0x86, 0xb9, 0x40, 0x51}}}, {{{0x27, 0xae, 0xd3, 0x0d, 0x4c, 0x8f, 0x34, 0xea, 0x7d, 0x3c, 0xe5, 0x8a, 0xcf, 0x5b, 0x92, 0xd8, 0x30, 0x16, 0xb4, 0xa3, 0x75, 0xff, 0xeb, 0x27, 0xc8, 0x5c, 0x6c, 0xc2, 0xee, 0x6c, 0x21, 0x0b}} , {{0xc3, 0xba, 0x12, 0x53, 0x2a, 0xaa, 0x77, 0xad, 0x19, 0x78, 0x55, 0x8a, 0x2e, 0x60, 0x87, 0xc2, 0x6e, 0x91, 0x38, 0x91, 0x3f, 0x7a, 0xc5, 0x24, 0x8f, 0x51, 0xc5, 0xde, 0xb0, 0x53, 0x30, 0x56}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x02, 0xfe, 0x54, 0x12, 0x18, 0xca, 0x7d, 0xa5, 0x68, 0x43, 0xa3, 0x6d, 0x14, 0x2a, 0x6a, 0xa5, 0x8e, 0x32, 0xe7, 0x63, 0x4f, 0xe3, 0xc6, 0x44, 0x3e, 0xab, 0x63, 0xca, 0x17, 0x86, 0x74, 0x3f}} , {{0x1e, 0x64, 0xc1, 0x7d, 0x52, 0xdc, 0x13, 0x5a, 0xa1, 0x9c, 0x4e, 0xee, 0x99, 0x28, 0xbb, 0x4c, 0xee, 0xac, 0xa9, 0x1b, 0x89, 0xa2, 0x38, 0x39, 0x7b, 0xc4, 0x0f, 0x42, 0xe6, 0x89, 0xed, 0x0f}}}, {{{0xf3, 0x3c, 0x8c, 0x80, 0x83, 0x10, 0x8a, 0x37, 0x50, 0x9c, 0xb4, 0xdf, 0x3f, 0x8c, 0xf7, 0x23, 0x07, 0xd6, 0xff, 0xa0, 0x82, 0x6c, 0x75, 0x3b, 0xe4, 0xb5, 0xbb, 0xe4, 0xe6, 0x50, 0xf0, 0x08}} , {{0x62, 0xee, 0x75, 0x48, 0x92, 0x33, 0xf2, 0xf4, 0xad, 0x15, 0x7a, 0xa1, 0x01, 0x46, 0xa9, 0x32, 0x06, 0x88, 0xb6, 0x36, 0x47, 0x35, 0xb9, 0xb4, 0x42, 0x85, 0x76, 0xf0, 0x48, 0x00, 0x90, 0x38}}}, {{{0x51, 0x15, 0x9d, 0xc3, 0x95, 0xd1, 0x39, 0xbb, 0x64, 0x9d, 0x15, 0x81, 0xc1, 0x68, 0xd0, 0xb6, 0xa4, 0x2c, 0x7d, 0x5e, 0x02, 0x39, 0x00, 0xe0, 0x3b, 0xa4, 0xcc, 0xca, 0x1d, 0x81, 0x24, 0x10}} , {{0xe7, 0x29, 0xf9, 0x37, 0xd9, 0x46, 0x5a, 0xcd, 0x70, 0xfe, 0x4d, 0x5b, 0xbf, 0xa5, 0xcf, 0x91, 0xf4, 0xef, 0xee, 0x8a, 0x29, 0xd0, 0xe7, 0xc4, 0x25, 0x92, 0x8a, 0xff, 0x36, 0xfc, 0xe4, 0x49}}}, {{{0xbd, 0x00, 0xb9, 0x04, 0x7d, 0x35, 0xfc, 0xeb, 0xd0, 0x0b, 0x05, 0x32, 0x52, 0x7a, 0x89, 0x24, 0x75, 0x50, 0xe1, 0x63, 0x02, 0x82, 0x8e, 0xe7, 0x85, 0x0c, 0xf2, 0x56, 0x44, 0x37, 0x83, 0x25}} , {{0x8f, 0xa1, 0xce, 0xcb, 0x60, 0xda, 0x12, 0x02, 0x1e, 0x29, 0x39, 0x2a, 0x03, 0xb7, 0xeb, 0x77, 0x40, 0xea, 0xc9, 0x2b, 0x2c, 0xd5, 0x7d, 0x7e, 0x2c, 0xc7, 0x5a, 0xfd, 0xff, 0xc4, 0xd1, 0x62}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x1d, 0x88, 0x98, 0x5b, 0x4e, 0xfc, 0x41, 0x24, 0x05, 0xe6, 0x50, 0x2b, 0xae, 0x96, 0x51, 0xd9, 0x6b, 0x72, 0xb2, 0x33, 0x42, 0x98, 0x68, 0xbb, 0x10, 0x5a, 0x7a, 0x8c, 0x9d, 0x07, 0xb4, 0x05}} , {{0x2f, 0x61, 0x9f, 0xd7, 0xa8, 0x3f, 0x83, 0x8c, 0x10, 0x69, 0x90, 0xe6, 0xcf, 0xd2, 0x63, 0xa3, 0xe4, 0x54, 0x7e, 0xe5, 0x69, 0x13, 0x1c, 0x90, 0x57, 0xaa, 0xe9, 0x53, 0x22, 0x43, 0x29, 0x23}}}, {{{0xe5, 0x1c, 0xf8, 0x0a, 0xfd, 0x2d, 0x7e, 0xf5, 0xf5, 0x70, 0x7d, 0x41, 0x6b, 0x11, 0xfe, 0xbe, 0x99, 0xd1, 0x55, 0x29, 0x31, 0xbf, 0xc0, 0x97, 0x6c, 0xd5, 0x35, 0xcc, 0x5e, 0x8b, 0xd9, 0x69}} , {{0x8e, 0x4e, 0x9f, 0x25, 0xf8, 0x81, 0x54, 0x2d, 0x0e, 0xd5, 0x54, 0x81, 0x9b, 0xa6, 0x92, 0xce, 0x4b, 0xe9, 0x8f, 0x24, 0x3b, 0xca, 0xe0, 0x44, 0xab, 0x36, 0xfe, 0xfb, 0x87, 0xd4, 0x26, 0x3e}}}, {{{0x0f, 0x93, 0x9c, 0x11, 0xe7, 0xdb, 0xf1, 0xf0, 0x85, 0x43, 0x28, 0x15, 0x37, 0xdd, 0xde, 0x27, 0xdf, 0xad, 0x3e, 0x49, 0x4f, 0xe0, 0x5b, 0xf6, 0x80, 0x59, 0x15, 0x3c, 0x85, 0xb7, 0x3e, 0x12}} , {{0xf5, 0xff, 0xcc, 0xf0, 0xb4, 0x12, 0x03, 0x5f, 0xc9, 0x84, 0xcb, 0x1d, 0x17, 0xe0, 0xbc, 0xcc, 0x03, 0x62, 0xa9, 0x8b, 0x94, 0xa6, 0xaa, 0x18, 0xcb, 0x27, 0x8d, 0x49, 0xa6, 0x17, 0x15, 0x07}}}, {{{0xd9, 0xb6, 0xd4, 0x9d, 0xd4, 0x6a, 0xaf, 0x70, 0x07, 0x2c, 0x10, 0x9e, 0xbd, 0x11, 0xad, 0xe4, 0x26, 0x33, 0x70, 0x92, 0x78, 0x1c, 0x74, 0x9f, 0x75, 0x60, 0x56, 0xf4, 0x39, 0xa8, 0xa8, 0x62}} , {{0x3b, 0xbf, 0x55, 0x35, 0x61, 0x8b, 0x44, 0x97, 0xe8, 0x3a, 0x55, 0xc1, 0xc8, 0x3b, 0xfd, 0x95, 0x29, 0x11, 0x60, 0x96, 0x1e, 0xcb, 0x11, 0x9d, 0xc2, 0x03, 0x8a, 0x1b, 0xc6, 0xd6, 0x45, 0x3d}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x7e, 0x0e, 0x50, 0xb2, 0xcc, 0x0d, 0x6b, 0xa6, 0x71, 0x5b, 0x42, 0xed, 0xbd, 0xaf, 0xac, 0xf0, 0xfc, 0x12, 0xa2, 0x3f, 0x4e, 0xda, 0xe8, 0x11, 0xf3, 0x23, 0xe1, 0x04, 0x62, 0x03, 0x1c, 0x4e}} , {{0xc8, 0xb1, 0x1b, 0x6f, 0x73, 0x61, 0x3d, 0x27, 0x0d, 0x7d, 0x7a, 0x25, 0x5f, 0x73, 0x0e, 0x2f, 0x93, 0xf6, 0x24, 0xd8, 0x4f, 0x90, 0xac, 0xa2, 0x62, 0x0a, 0xf0, 0x61, 0xd9, 0x08, 0x59, 0x6a}}}, {{{0x6f, 0x2d, 0x55, 0xf8, 0x2f, 0x8e, 0xf0, 0x18, 0x3b, 0xea, 0xdd, 0x26, 0x72, 0xd1, 0xf5, 0xfe, 0xe5, 0xb8, 0xe6, 0xd3, 0x10, 0x48, 0x46, 0x49, 0x3a, 0x9f, 0x5e, 0x45, 0x6b, 0x90, 0xe8, 0x7f}} , {{0xd3, 0x76, 0x69, 0x33, 0x7b, 0xb9, 0x40, 0x70, 0xee, 0xa6, 0x29, 0x6b, 0xdd, 0xd0, 0x5d, 0x8d, 0xc1, 0x3e, 0x4a, 0xea, 0x37, 0xb1, 0x03, 0x02, 0x03, 0x35, 0xf1, 0x28, 0x9d, 0xff, 0x00, 0x13}}}, {{{0x7a, 0xdb, 0x12, 0xd2, 0x8a, 0x82, 0x03, 0x1b, 0x1e, 0xaf, 0xf9, 0x4b, 0x9c, 0xbe, 0xae, 0x7c, 0xe4, 0x94, 0x2a, 0x23, 0xb3, 0x62, 0x86, 0xe7, 0xfd, 0x23, 0xaa, 0x99, 0xbd, 0x2b, 0x11, 0x6c}} , {{0x8d, 0xa6, 0xd5, 0xac, 0x9d, 0xcc, 0x68, 0x75, 0x7f, 0xc3, 0x4d, 0x4b, 0xdd, 0x6c, 0xbb, 0x11, 0x5a, 0x60, 0xe5, 0xbd, 0x7d, 0x27, 0x8b, 0xda, 0xb4, 0x95, 0xf6, 0x03, 0x27, 0xa4, 0x92, 0x3f}}}, {{{0x22, 0xd6, 0xb5, 0x17, 0x84, 0xbf, 0x12, 0xcc, 0x23, 0x14, 0x4a, 0xdf, 0x14, 0x31, 0xbc, 0xa1, 0xac, 0x6e, 0xab, 0xfa, 0x57, 0x11, 0x53, 0xb3, 0x27, 0xe6, 0xf9, 0x47, 0x33, 0x44, 0x34, 0x1e}} , {{0x79, 0xfc, 0xa6, 0xb4, 0x0b, 0x35, 0x20, 0xc9, 0x4d, 0x22, 0x84, 0xc4, 0xa9, 0x20, 0xec, 0x89, 0x94, 0xba, 0x66, 0x56, 0x48, 0xb9, 0x87, 0x7f, 0xca, 0x1e, 0x06, 0xed, 0xa5, 0x55, 0x59, 0x29}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x56, 0xe1, 0xf5, 0xf1, 0xd5, 0xab, 0xa8, 0x2b, 0xae, 0x89, 0xf3, 0xcf, 0x56, 0x9f, 0xf2, 0x4b, 0x31, 0xbc, 0x18, 0xa9, 0x06, 0x5b, 0xbe, 0xb4, 0x61, 0xf8, 0xb2, 0x06, 0x9c, 0x81, 0xab, 0x4c}} , {{0x1f, 0x68, 0x76, 0x01, 0x16, 0x38, 0x2b, 0x0f, 0x77, 0x97, 0x92, 0x67, 0x4e, 0x86, 0x6a, 0x8b, 0xe5, 0xe8, 0x0c, 0xf7, 0x36, 0x39, 0xb5, 0x33, 0xe6, 0xcf, 0x5e, 0xbd, 0x18, 0xfb, 0x10, 0x1f}}}, {{{0x83, 0xf0, 0x0d, 0x63, 0xef, 0x53, 0x6b, 0xb5, 0x6b, 0xf9, 0x83, 0xcf, 0xde, 0x04, 0x22, 0x9b, 0x2c, 0x0a, 0xe0, 0xa5, 0xd8, 0xc7, 0x9c, 0xa5, 0xa3, 0xf6, 0x6f, 0xcf, 0x90, 0x6b, 0x68, 0x7c}} , {{0x33, 0x15, 0xd7, 0x7f, 0x1a, 0xd5, 0x21, 0x58, 0xc4, 0x18, 0xa5, 0xf0, 0xcc, 0x73, 0xa8, 0xfd, 0xfa, 0x18, 0xd1, 0x03, 0x91, 0x8d, 0x52, 0xd2, 0xa3, 0xa4, 0xd3, 0xb1, 0xea, 0x1d, 0x0f, 0x00}}}, {{{0xcc, 0x48, 0x83, 0x90, 0xe5, 0xfd, 0x3f, 0x84, 0xaa, 0xf9, 0x8b, 0x82, 0x59, 0x24, 0x34, 0x68, 0x4f, 0x1c, 0x23, 0xd9, 0xcc, 0x71, 0xe1, 0x7f, 0x8c, 0xaf, 0xf1, 0xee, 0x00, 0xb6, 0xa0, 0x77}} , {{0xf5, 0x1a, 0x61, 0xf7, 0x37, 0x9d, 0x00, 0xf4, 0xf2, 0x69, 0x6f, 0x4b, 0x01, 0x85, 0x19, 0x45, 0x4d, 0x7f, 0x02, 0x7c, 0x6a, 0x05, 0x47, 0x6c, 0x1f, 0x81, 0x20, 0xd4, 0xe8, 0x50, 0x27, 0x72}}}, {{{0x2c, 0x3a, 0xe5, 0xad, 0xf4, 0xdd, 0x2d, 0xf7, 0x5c, 0x44, 0xb5, 0x5b, 0x21, 0xa3, 0x89, 0x5f, 0x96, 0x45, 0xca, 0x4d, 0xa4, 0x21, 0x99, 0x70, 0xda, 0xc4, 0xc4, 0xa0, 0xe5, 0xf4, 0xec, 0x0a}} , {{0x07, 0x68, 0x21, 0x65, 0xe9, 0x08, 0xa0, 0x0b, 0x6a, 0x4a, 0xba, 0xb5, 0x80, 0xaf, 0xd0, 0x1b, 0xc5, 0xf5, 0x4b, 0x73, 0x50, 0x60, 0x2d, 0x71, 0x69, 0x61, 0x0e, 0xc0, 0x20, 0x40, 0x30, 0x19}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xd0, 0x75, 0x57, 0x3b, 0xeb, 0x5c, 0x14, 0x56, 0x50, 0xc9, 0x4f, 0xb8, 0xb8, 0x1e, 0xa3, 0xf4, 0xab, 0xf5, 0xa9, 0x20, 0x15, 0x94, 0x82, 0xda, 0x96, 0x1c, 0x9b, 0x59, 0x8c, 0xff, 0xf4, 0x51}} , {{0xc1, 0x3a, 0x86, 0xd7, 0xb0, 0x06, 0x84, 0x7f, 0x1b, 0xbd, 0xd4, 0x07, 0x78, 0x80, 0x2e, 0xb1, 0xb4, 0xee, 0x52, 0x38, 0xee, 0x9a, 0xf9, 0xf6, 0xf3, 0x41, 0x6e, 0xd4, 0x88, 0x95, 0xac, 0x35}}}, {{{0x41, 0x97, 0xbf, 0x71, 0x6a, 0x9b, 0x72, 0xec, 0xf3, 0xf8, 0x6b, 0xe6, 0x0e, 0x6c, 0x69, 0xa5, 0x2f, 0x68, 0x52, 0xd8, 0x61, 0x81, 0xc0, 0x63, 0x3f, 0xa6, 0x3c, 0x13, 0x90, 0xe6, 0x8d, 0x56}} , {{0xe8, 0x39, 0x30, 0x77, 0x23, 0xb1, 0xfd, 0x1b, 0x3d, 0x3e, 0x74, 0x4d, 0x7f, 0xae, 0x5b, 0x3a, 0xb4, 0x65, 0x0e, 0x3a, 0x43, 0xdc, 0xdc, 0x41, 0x47, 0xe6, 0xe8, 0x92, 0x09, 0x22, 0x48, 0x4c}}}, {{{0x85, 0x57, 0x9f, 0xb5, 0xc8, 0x06, 0xb2, 0x9f, 0x47, 0x3f, 0xf0, 0xfa, 0xe6, 0xa9, 0xb1, 0x9b, 0x6f, 0x96, 0x7d, 0xf9, 0xa4, 0x65, 0x09, 0x75, 0x32, 0xa6, 0x6c, 0x7f, 0x47, 0x4b, 0x2f, 0x4f}} , {{0x34, 0xe9, 0x59, 0x93, 0x9d, 0x26, 0x80, 0x54, 0xf2, 0xcc, 0x3c, 0xc2, 0x25, 0x85, 0xe3, 0x6a, 0xc1, 0x62, 0x04, 0xa7, 0x08, 0x32, 0x6d, 0xa1, 0x39, 0x84, 0x8a, 0x3b, 0x87, 0x5f, 0x11, 0x13}}}, {{{0xda, 0x03, 0x34, 0x66, 0xc4, 0x0c, 0x73, 0x6e, 0xbc, 0x24, 0xb5, 0xf9, 0x70, 0x81, 0x52, 0xe9, 0xf4, 0x7c, 0x23, 0xdd, 0x9f, 0xb8, 0x46, 0xef, 0x1d, 0x22, 0x55, 0x7d, 0x71, 0xc4, 0x42, 0x33}} , {{0xc5, 0x37, 0x69, 0x5b, 0xa8, 0xc6, 0x9d, 0xa4, 0xfc, 0x61, 0x6e, 0x68, 0x46, 0xea, 0xd7, 0x1c, 0x67, 0xd2, 0x7d, 0xfa, 0xf1, 0xcc, 0x54, 0x8d, 0x36, 0x35, 0xc9, 0x00, 0xdf, 0x6c, 0x67, 0x50}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x9a, 0x4d, 0x42, 0x29, 0x5d, 0xa4, 0x6b, 0x6f, 0xa8, 0x8a, 0x4d, 0x91, 0x7b, 0xd2, 0xdf, 0x36, 0xef, 0x01, 0x22, 0xc5, 0xcc, 0x8d, 0xeb, 0x58, 0x3d, 0xb3, 0x50, 0xfc, 0x8b, 0x97, 0x96, 0x33}} , {{0x93, 0x33, 0x07, 0xc8, 0x4a, 0xca, 0xd0, 0xb1, 0xab, 0xbd, 0xdd, 0xa7, 0x7c, 0xac, 0x3e, 0x45, 0xcb, 0xcc, 0x07, 0x91, 0xbf, 0x35, 0x9d, 0xcb, 0x7d, 0x12, 0x3c, 0x11, 0x59, 0x13, 0xcf, 0x5c}}}, {{{0x45, 0xb8, 0x41, 0xd7, 0xab, 0x07, 0x15, 0x00, 0x8e, 0xce, 0xdf, 0xb2, 0x43, 0x5c, 0x01, 0xdc, 0xf4, 0x01, 0x51, 0x95, 0x10, 0x5a, 0xf6, 0x24, 0x24, 0xa0, 0x19, 0x3a, 0x09, 0x2a, 0xaa, 0x3f}} , {{0xdc, 0x8e, 0xeb, 0xc6, 0xbf, 0xdd, 0x11, 0x7b, 0xe7, 0x47, 0xe6, 0xce, 0xe7, 0xb6, 0xc5, 0xe8, 0x8a, 0xdc, 0x4b, 0x57, 0x15, 0x3b, 0x66, 0xca, 0x89, 0xa3, 0xfd, 0xac, 0x0d, 0xe1, 0x1d, 0x7a}}}, {{{0x89, 0xef, 0xbf, 0x03, 0x75, 0xd0, 0x29, 0x50, 0xcb, 0x7d, 0xd6, 0xbe, 0xad, 0x5f, 0x7b, 0x00, 0x32, 0xaa, 0x98, 0xed, 0x3f, 0x8f, 0x92, 0xcb, 0x81, 0x56, 0x01, 0x63, 0x64, 0xa3, 0x38, 0x39}} , {{0x8b, 0xa4, 0xd6, 0x50, 0xb4, 0xaa, 0x5d, 0x64, 0x64, 0x76, 0x2e, 0xa1, 0xa6, 0xb3, 0xb8, 0x7c, 0x7a, 0x56, 0xf5, 0x5c, 0x4e, 0x84, 0x5c, 0xfb, 0xdd, 0xca, 0x48, 0x8b, 0x48, 0xb9, 0xba, 0x34}}}, {{{0xc5, 0xe3, 0xe8, 0xae, 0x17, 0x27, 0xe3, 0x64, 0x60, 0x71, 0x47, 0x29, 0x02, 0x0f, 0x92, 0x5d, 0x10, 0x93, 0xc8, 0x0e, 0xa1, 0xed, 0xba, 0xa9, 0x96, 0x1c, 0xc5, 0x76, 0x30, 0xcd, 0xf9, 0x30}} , {{0x95, 0xb0, 0xbd, 0x8c, 0xbc, 0xa7, 0x4f, 0x7e, 0xfd, 0x4e, 0x3a, 0xbf, 0x5f, 0x04, 0x79, 0x80, 0x2b, 0x5a, 0x9f, 0x4f, 0x68, 0x21, 0x19, 0x71, 0xc6, 0x20, 0x01, 0x42, 0xaa, 0xdf, 0xae, 0x2c}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x90, 0x6e, 0x7e, 0x4b, 0x71, 0x93, 0xc0, 0x72, 0xed, 0xeb, 0x71, 0x24, 0x97, 0x26, 0x9c, 0xfe, 0xcb, 0x3e, 0x59, 0x19, 0xa8, 0x0f, 0x75, 0x7d, 0xbe, 0x18, 0xe6, 0x96, 0x1e, 0x95, 0x70, 0x60}} , {{0x89, 0x66, 0x3e, 0x1d, 0x4c, 0x5f, 0xfe, 0xc0, 0x04, 0x43, 0xd6, 0x44, 0x19, 0xb5, 0xad, 0xc7, 0x22, 0xdc, 0x71, 0x28, 0x64, 0xde, 0x41, 0x38, 0x27, 0x8f, 0x2c, 0x6b, 0x08, 0xb8, 0xb8, 0x7b}}}, {{{0x3d, 0x70, 0x27, 0x9d, 0xd9, 0xaf, 0xb1, 0x27, 0xaf, 0xe3, 0x5d, 0x1e, 0x3a, 0x30, 0x54, 0x61, 0x60, 0xe8, 0xc3, 0x26, 0x3a, 0xbc, 0x7e, 0xf5, 0x81, 0xdd, 0x64, 0x01, 0x04, 0xeb, 0xc0, 0x1e}} , {{0xda, 0x2c, 0xa4, 0xd1, 0xa1, 0xc3, 0x5c, 0x6e, 0x32, 0x07, 0x1f, 0xb8, 0x0e, 0x19, 0x9e, 0x99, 0x29, 0x33, 0x9a, 0xae, 0x7a, 0xed, 0x68, 0x42, 0x69, 0x7c, 0x07, 0xb3, 0x38, 0x2c, 0xf6, 0x3d}}}, {{{0x64, 0xaa, 0xb5, 0x88, 0x79, 0x65, 0x38, 0x8c, 0x94, 0xd6, 0x62, 0x37, 0x7d, 0x64, 0xcd, 0x3a, 0xeb, 0xff, 0xe8, 0x81, 0x09, 0xc7, 0x6a, 0x50, 0x09, 0x0d, 0x28, 0x03, 0x0d, 0x9a, 0x93, 0x0a}} , {{0x42, 0xa3, 0xf1, 0xc5, 0xb4, 0x0f, 0xd8, 0xc8, 0x8d, 0x15, 0x31, 0xbd, 0xf8, 0x07, 0x8b, 0xcd, 0x08, 0x8a, 0xfb, 0x18, 0x07, 0xfe, 0x8e, 0x52, 0x86, 0xef, 0xbe, 0xec, 0x49, 0x52, 0x99, 0x08}}}, {{{0x0f, 0xa9, 0xd5, 0x01, 0xaa, 0x48, 0x4f, 0x28, 0x66, 0x32, 0x1a, 0xba, 0x7c, 0xea, 0x11, 0x80, 0x17, 0x18, 0x9b, 0x56, 0x88, 0x25, 0x06, 0x69, 0x12, 0x2c, 0xea, 0x56, 0x69, 0x41, 0x24, 0x19}} , {{0xde, 0x21, 0xf0, 0xda, 0x8a, 0xfb, 0xb1, 0xb8, 0xcd, 0xc8, 0x6a, 0x82, 0x19, 0x73, 0xdb, 0xc7, 0xcf, 0x88, 0xeb, 0x96, 0xee, 0x6f, 0xfb, 0x06, 0xd2, 0xcd, 0x7d, 0x7b, 0x12, 0x28, 0x8e, 0x0c}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x93, 0x44, 0x97, 0xce, 0x28, 0xff, 0x3a, 0x40, 0xc4, 0xf5, 0xf6, 0x9b, 0xf4, 0x6b, 0x07, 0x84, 0xfb, 0x98, 0xd8, 0xec, 0x8c, 0x03, 0x57, 0xec, 0x49, 0xed, 0x63, 0xb6, 0xaa, 0xff, 0x98, 0x28}} , {{0x3d, 0x16, 0x35, 0xf3, 0x46, 0xbc, 0xb3, 0xf4, 0xc6, 0xb6, 0x4f, 0xfa, 0xf4, 0xa0, 0x13, 0xe6, 0x57, 0x45, 0x93, 0xb9, 0xbc, 0xd6, 0x59, 0xe7, 0x77, 0x94, 0x6c, 0xab, 0x96, 0x3b, 0x4f, 0x09}}}, {{{0x5a, 0xf7, 0x6b, 0x01, 0x12, 0x4f, 0x51, 0xc1, 0x70, 0x84, 0x94, 0x47, 0xb2, 0x01, 0x6c, 0x71, 0xd7, 0xcc, 0x17, 0x66, 0x0f, 0x59, 0x5d, 0x5d, 0x10, 0x01, 0x57, 0x11, 0xf5, 0xdd, 0xe2, 0x34}} , {{0x26, 0xd9, 0x1f, 0x5c, 0x58, 0xac, 0x8b, 0x03, 0xd2, 0xc3, 0x85, 0x0f, 0x3a, 0xc3, 0x7f, 0x6d, 0x8e, 0x86, 0xcd, 0x52, 0x74, 0x8f, 0x55, 0x77, 0x17, 0xb7, 0x8e, 0xb7, 0x88, 0xea, 0xda, 0x1b}}}, {{{0xb6, 0xea, 0x0e, 0x40, 0x93, 0x20, 0x79, 0x35, 0x6a, 0x61, 0x84, 0x5a, 0x07, 0x6d, 0xf9, 0x77, 0x6f, 0xed, 0x69, 0x1c, 0x0d, 0x25, 0x76, 0xcc, 0xf0, 0xdb, 0xbb, 0xc5, 0xad, 0xe2, 0x26, 0x57}} , {{0xcf, 0xe8, 0x0e, 0x6b, 0x96, 0x7d, 0xed, 0x27, 0xd1, 0x3c, 0xa9, 0xd9, 0x50, 0xa9, 0x98, 0x84, 0x5e, 0x86, 0xef, 0xd6, 0xf0, 0xf8, 0x0e, 0x89, 0x05, 0x2f, 0xd9, 0x5f, 0x15, 0x5f, 0x73, 0x79}}}, {{{0xc8, 0x5c, 0x16, 0xfe, 0xed, 0x9f, 0x26, 0x56, 0xf6, 0x4b, 0x9f, 0xa7, 0x0a, 0x85, 0xfe, 0xa5, 0x8c, 0x87, 0xdd, 0x98, 0xce, 0x4e, 0xc3, 0x58, 0x55, 0xb2, 0x7b, 0x3d, 0xd8, 0x6b, 0xb5, 0x4c}} , {{0x65, 0x38, 0xa0, 0x15, 0xfa, 0xa7, 0xb4, 0x8f, 0xeb, 0xc4, 0x86, 0x9b, 0x30, 0xa5, 0x5e, 0x4d, 0xea, 0x8a, 0x9a, 0x9f, 0x1a, 0xd8, 0x5b, 0x53, 0x14, 0x19, 0x25, 0x63, 0xb4, 0x6f, 0x1f, 0x5d}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xac, 0x8f, 0xbc, 0x1e, 0x7d, 0x8b, 0x5a, 0x0b, 0x8d, 0xaf, 0x76, 0x2e, 0x71, 0xe3, 0x3b, 0x6f, 0x53, 0x2f, 0x3e, 0x90, 0x95, 0xd4, 0x35, 0x14, 0x4f, 0x8c, 0x3c, 0xce, 0x57, 0x1c, 0x76, 0x49}} , {{0xa8, 0x50, 0xe1, 0x61, 0x6b, 0x57, 0x35, 0xeb, 0x44, 0x0b, 0x0c, 0x6e, 0xf9, 0x25, 0x80, 0x74, 0xf2, 0x8f, 0x6f, 0x7a, 0x3e, 0x7f, 0x2d, 0xf3, 0x4e, 0x09, 0x65, 0x10, 0x5e, 0x03, 0x25, 0x32}}}, {{{0xa9, 0x60, 0xdc, 0x0f, 0x64, 0xe5, 0x1d, 0xe2, 0x8d, 0x4f, 0x79, 0x2f, 0x0e, 0x24, 0x02, 0x00, 0x05, 0x77, 0x43, 0x25, 0x3d, 0x6a, 0xc7, 0xb7, 0xbf, 0x04, 0x08, 0x65, 0xf4, 0x39, 0x4b, 0x65}} , {{0x96, 0x19, 0x12, 0x6b, 0x6a, 0xb7, 0xe3, 0xdc, 0x45, 0x9b, 0xdb, 0xb4, 0xa8, 0xae, 0xdc, 0xa8, 0x14, 0x44, 0x65, 0x62, 0xce, 0x34, 0x9a, 0x84, 0x18, 0x12, 0x01, 0xf1, 0xe2, 0x7b, 0xce, 0x50}}}, {{{0x41, 0x21, 0x30, 0x53, 0x1b, 0x47, 0x01, 0xb7, 0x18, 0xd8, 0x82, 0x57, 0xbd, 0xa3, 0x60, 0xf0, 0x32, 0xf6, 0x5b, 0xf0, 0x30, 0x88, 0x91, 0x59, 0xfd, 0x90, 0xa2, 0xb9, 0x55, 0x93, 0x21, 0x34}} , {{0x97, 0x67, 0x9e, 0xeb, 0x6a, 0xf9, 0x6e, 0xd6, 0x73, 0xe8, 0x6b, 0x29, 0xec, 0x63, 0x82, 0x00, 0xa8, 0x99, 0x1c, 0x1d, 0x30, 0xc8, 0x90, 0x52, 0x90, 0xb6, 0x6a, 0x80, 0x4e, 0xff, 0x4b, 0x51}}}, {{{0x0f, 0x7d, 0x63, 0x8c, 0x6e, 0x5c, 0xde, 0x30, 0xdf, 0x65, 0xfa, 0x2e, 0xb0, 0xa3, 0x25, 0x05, 0x54, 0xbd, 0x25, 0xba, 0x06, 0xae, 0xdf, 0x8b, 0xd9, 0x1b, 0xea, 0x38, 0xb3, 0x05, 0x16, 0x09}} , {{0xc7, 0x8c, 0xbf, 0x64, 0x28, 0xad, 0xf8, 0xa5, 0x5a, 0x6f, 0xc9, 0xba, 0xd5, 0x7f, 0xd5, 0xd6, 0xbd, 0x66, 0x2f, 0x3d, 0xaa, 0x54, 0xf6, 0xba, 0x32, 0x22, 0x9a, 0x1e, 0x52, 0x05, 0xf4, 0x1d}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xaa, 0x1f, 0xbb, 0xeb, 0xfe, 0xe4, 0x87, 0xfc, 0xb1, 0x2c, 0xb7, 0x88, 0xf4, 0xc6, 0xb9, 0xf5, 0x24, 0x46, 0xf2, 0xa5, 0x9f, 0x8f, 0x8a, 0x93, 0x70, 0x69, 0xd4, 0x56, 0xec, 0xfd, 0x06, 0x46}} , {{0x4e, 0x66, 0xcf, 0x4e, 0x34, 0xce, 0x0c, 0xd9, 0xa6, 0x50, 0xd6, 0x5e, 0x95, 0xaf, 0xe9, 0x58, 0xfa, 0xee, 0x9b, 0xb8, 0xa5, 0x0f, 0x35, 0xe0, 0x43, 0x82, 0x6d, 0x65, 0xe6, 0xd9, 0x00, 0x0f}}}, {{{0x7b, 0x75, 0x3a, 0xfc, 0x64, 0xd3, 0x29, 0x7e, 0xdd, 0x49, 0x9a, 0x59, 0x53, 0xbf, 0xb4, 0xa7, 0x52, 0xb3, 0x05, 0xab, 0xc3, 0xaf, 0x16, 0x1a, 0x85, 0x42, 0x32, 0xa2, 0x86, 0xfa, 0x39, 0x43}} , {{0x0e, 0x4b, 0xa3, 0x63, 0x8a, 0xfe, 0xa5, 0x58, 0xf1, 0x13, 0xbd, 0x9d, 0xaa, 0x7f, 0x76, 0x40, 0x70, 0x81, 0x10, 0x75, 0x99, 0xbb, 0xbe, 0x0b, 0x16, 0xe9, 0xba, 0x62, 0x34, 0xcc, 0x07, 0x6d}}}, {{{0xc3, 0xf1, 0xc6, 0x93, 0x65, 0xee, 0x0b, 0xbc, 0xea, 0x14, 0xf0, 0xc1, 0xf8, 0x84, 0x89, 0xc2, 0xc9, 0xd7, 0xea, 0x34, 0xca, 0xa7, 0xc4, 0x99, 0xd5, 0x50, 0x69, 0xcb, 0xd6, 0x21, 0x63, 0x7c}} , {{0x99, 0xeb, 0x7c, 0x31, 0x73, 0x64, 0x67, 0x7f, 0x0c, 0x66, 0xaa, 0x8c, 0x69, 0x91, 0xe2, 0x26, 0xd3, 0x23, 0xe2, 0x76, 0x5d, 0x32, 0x52, 0xdf, 0x5d, 0xc5, 0x8f, 0xb7, 0x7c, 0x84, 0xb3, 0x70}}}, {{{0xeb, 0x01, 0xc7, 0x36, 0x97, 0x4e, 0xb6, 0xab, 0x5f, 0x0d, 0x2c, 0xba, 0x67, 0x64, 0x55, 0xde, 0xbc, 0xff, 0xa6, 0xec, 0x04, 0xd3, 0x8d, 0x39, 0x56, 0x5e, 0xee, 0xf8, 0xe4, 0x2e, 0x33, 0x62}} , {{0x65, 0xef, 0xb8, 0x9f, 0xc8, 0x4b, 0xa7, 0xfd, 0x21, 0x49, 0x9b, 0x92, 0x35, 0x82, 0xd6, 0x0a, 0x9b, 0xf2, 0x79, 0xf1, 0x47, 0x2f, 0x6a, 0x7e, 0x9f, 0xcf, 0x18, 0x02, 0x3c, 0xfb, 0x1b, 0x3e}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x2f, 0x8b, 0xc8, 0x40, 0x51, 0xd1, 0xac, 0x1a, 0x0b, 0xe4, 0xa9, 0xa2, 0x42, 0x21, 0x19, 0x2f, 0x7b, 0x97, 0xbf, 0xf7, 0x57, 0x6d, 0x3f, 0x3d, 0x4f, 0x0f, 0xe2, 0xb2, 0x81, 0x00, 0x9e, 0x7b}} , {{0x8c, 0x85, 0x2b, 0xc4, 0xfc, 0xf1, 0xab, 0xe8, 0x79, 0x22, 0xc4, 0x84, 0x17, 0x3a, 0xfa, 0x86, 0xa6, 0x7d, 0xf9, 0xf3, 0x6f, 0x03, 0x57, 0x20, 0x4d, 0x79, 0xf9, 0x6e, 0x71, 0x54, 0x38, 0x09}}}, {{{0x40, 0x29, 0x74, 0xa8, 0x2f, 0x5e, 0xf9, 0x79, 0xa4, 0xf3, 0x3e, 0xb9, 0xfd, 0x33, 0x31, 0xac, 0x9a, 0x69, 0x88, 0x1e, 0x77, 0x21, 0x2d, 0xf3, 0x91, 0x52, 0x26, 0x15, 0xb2, 0xa6, 0xcf, 0x7e}} , {{0xc6, 0x20, 0x47, 0x6c, 0xa4, 0x7d, 0xcb, 0x63, 0xea, 0x5b, 0x03, 0xdf, 0x3e, 0x88, 0x81, 0x6d, 0xce, 0x07, 0x42, 0x18, 0x60, 0x7e, 0x7b, 0x55, 0xfe, 0x6a, 0xf3, 0xda, 0x5c, 0x8b, 0x95, 0x10}}}, {{{0x62, 0xe4, 0x0d, 0x03, 0xb4, 0xd7, 0xcd, 0xfa, 0xbd, 0x46, 0xdf, 0x93, 0x71, 0x10, 0x2c, 0xa8, 0x3b, 0xb6, 0x09, 0x05, 0x70, 0x84, 0x43, 0x29, 0xa8, 0x59, 0xf5, 0x8e, 0x10, 0xe4, 0xd7, 0x20}} , {{0x57, 0x82, 0x1c, 0xab, 0xbf, 0x62, 0x70, 0xe8, 0xc4, 0xcf, 0xf0, 0x28, 0x6e, 0x16, 0x3c, 0x08, 0x78, 0x89, 0x85, 0x46, 0x0f, 0xf6, 0x7f, 0xcf, 0xcb, 0x7e, 0xb8, 0x25, 0xe9, 0x5a, 0xfa, 0x03}}}, {{{0xfb, 0x95, 0x92, 0x63, 0x50, 0xfc, 0x62, 0xf0, 0xa4, 0x5e, 0x8c, 0x18, 0xc2, 0x17, 0x24, 0xb7, 0x78, 0xc2, 0xa9, 0xe7, 0x6a, 0x32, 0xd6, 0x29, 0x85, 0xaf, 0xcb, 0x8d, 0x91, 0x13, 0xda, 0x6b}} , {{0x36, 0x0a, 0xc2, 0xb6, 0x4b, 0xa5, 0x5d, 0x07, 0x17, 0x41, 0x31, 0x5f, 0x62, 0x46, 0xf8, 0x92, 0xf9, 0x66, 0x48, 0x73, 0xa6, 0x97, 0x0d, 0x7d, 0x88, 0xee, 0x62, 0xb1, 0x03, 0xa8, 0x3f, 0x2c}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x4a, 0xb1, 0x70, 0x8a, 0xa9, 0xe8, 0x63, 0x79, 0x00, 0xe2, 0x25, 0x16, 0xca, 0x4b, 0x0f, 0xa4, 0x66, 0xad, 0x19, 0x9f, 0x88, 0x67, 0x0c, 0x8b, 0xc2, 0x4a, 0x5b, 0x2b, 0x6d, 0x95, 0xaf, 0x19}} , {{0x8b, 0x9d, 0xb6, 0xcc, 0x60, 0xb4, 0x72, 0x4f, 0x17, 0x69, 0x5a, 0x4a, 0x68, 0x34, 0xab, 0xa1, 0x45, 0x32, 0x3c, 0x83, 0x87, 0x72, 0x30, 0x54, 0x77, 0x68, 0xae, 0xfb, 0xb5, 0x8b, 0x22, 0x5e}}}, {{{0xf1, 0xb9, 0x87, 0x35, 0xc5, 0xbb, 0xb9, 0xcf, 0xf5, 0xd6, 0xcd, 0xd5, 0x0c, 0x7c, 0x0e, 0xe6, 0x90, 0x34, 0xfb, 0x51, 0x42, 0x1e, 0x6d, 0xac, 0x9a, 0x46, 0xc4, 0x97, 0x29, 0x32, 0xbf, 0x45}} , {{0x66, 0x9e, 0xc6, 0x24, 0xc0, 0xed, 0xa5, 0x5d, 0x88, 0xd4, 0xf0, 0x73, 0x97, 0x7b, 0xea, 0x7f, 0x42, 0xff, 0x21, 0xa0, 0x9b, 0x2f, 0x9a, 0xfd, 0x53, 0x57, 0x07, 0x84, 0x48, 0x88, 0x9d, 0x52}}}, {{{0xc6, 0x96, 0x48, 0x34, 0x2a, 0x06, 0xaf, 0x94, 0x3d, 0xf4, 0x1a, 0xcf, 0xf2, 0xc0, 0x21, 0xc2, 0x42, 0x5e, 0xc8, 0x2f, 0x35, 0xa2, 0x3e, 0x29, 0xfa, 0x0c, 0x84, 0xe5, 0x89, 0x72, 0x7c, 0x06}} , {{0x32, 0x65, 0x03, 0xe5, 0x89, 0xa6, 0x6e, 0xb3, 0x5b, 0x8e, 0xca, 0xeb, 0xfe, 0x22, 0x56, 0x8b, 0x5d, 0x14, 0x4b, 0x4d, 0xf9, 0xbe, 0xb5, 0xf5, 0xe6, 0x5c, 0x7b, 0x8b, 0xf4, 0x13, 0x11, 0x34}}}, {{{0x07, 0xc6, 0x22, 0x15, 0xe2, 0x9c, 0x60, 0xa2, 0x19, 0xd9, 0x27, 0xae, 0x37, 0x4e, 0xa6, 0xc9, 0x80, 0xa6, 0x91, 0x8f, 0x12, 0x49, 0xe5, 0x00, 0x18, 0x47, 0xd1, 0xd7, 0x28, 0x22, 0x63, 0x39}} , {{0xe8, 0xe2, 0x00, 0x7e, 0xf2, 0x9e, 0x1e, 0x99, 0x39, 0x95, 0x04, 0xbd, 0x1e, 0x67, 0x7b, 0xb2, 0x26, 0xac, 0xe6, 0xaa, 0xe2, 0x46, 0xd5, 0xe4, 0xe8, 0x86, 0xbd, 0xab, 0x7c, 0x55, 0x59, 0x6f}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x24, 0x64, 0x6e, 0x9b, 0x35, 0x71, 0x78, 0xce, 0x33, 0x03, 0x21, 0x33, 0x36, 0xf1, 0x73, 0x9b, 0xb9, 0x15, 0x8b, 0x2c, 0x69, 0xcf, 0x4d, 0xed, 0x4f, 0x4d, 0x57, 0x14, 0x13, 0x82, 0xa4, 0x4d}} , {{0x65, 0x6e, 0x0a, 0xa4, 0x59, 0x07, 0x17, 0xf2, 0x6b, 0x4a, 0x1f, 0x6e, 0xf6, 0xb5, 0xbc, 0x62, 0xe4, 0xb6, 0xda, 0xa2, 0x93, 0xbc, 0x29, 0x05, 0xd2, 0xd2, 0x73, 0x46, 0x03, 0x16, 0x40, 0x31}}}, {{{0x4c, 0x73, 0x6d, 0x15, 0xbd, 0xa1, 0x4d, 0x5c, 0x13, 0x0b, 0x24, 0x06, 0x98, 0x78, 0x1c, 0x5b, 0xeb, 0x1f, 0x18, 0x54, 0x43, 0xd9, 0x55, 0x66, 0xda, 0x29, 0x21, 0xe8, 0xb8, 0x3c, 0x42, 0x22}} , {{0xb4, 0xcd, 0x08, 0x6f, 0x15, 0x23, 0x1a, 0x0b, 0x22, 0xed, 0xd1, 0xf1, 0xa7, 0xc7, 0x73, 0x45, 0xf3, 0x9e, 0xce, 0x76, 0xb7, 0xf6, 0x39, 0xb6, 0x8e, 0x79, 0xbe, 0xe9, 0x9b, 0xcf, 0x7d, 0x62}}}, {{{0x92, 0x5b, 0xfc, 0x72, 0xfd, 0xba, 0xf1, 0xfd, 0xa6, 0x7c, 0x95, 0xe3, 0x61, 0x3f, 0xe9, 0x03, 0xd4, 0x2b, 0xd4, 0x20, 0xd9, 0xdb, 0x4d, 0x32, 0x3e, 0xf5, 0x11, 0x64, 0xe3, 0xb4, 0xbe, 0x32}} , {{0x86, 0x17, 0x90, 0xe7, 0xc9, 0x1f, 0x10, 0xa5, 0x6a, 0x2d, 0x39, 0xd0, 0x3b, 0xc4, 0xa6, 0xe9, 0x59, 0x13, 0xda, 0x1a, 0xe6, 0xa0, 0xb9, 0x3c, 0x50, 0xb8, 0x40, 0x7c, 0x15, 0x36, 0x5a, 0x42}}}, {{{0xb4, 0x0b, 0x32, 0xab, 0xdc, 0x04, 0x51, 0x55, 0x21, 0x1e, 0x0b, 0x75, 0x99, 0x89, 0x73, 0x35, 0x3a, 0x91, 0x2b, 0xfe, 0xe7, 0x49, 0xea, 0x76, 0xc1, 0xf9, 0x46, 0xb9, 0x53, 0x02, 0x23, 0x04}} , {{0xfc, 0x5a, 0x1e, 0x1d, 0x74, 0x58, 0x95, 0xa6, 0x8f, 0x7b, 0x97, 0x3e, 0x17, 0x3b, 0x79, 0x2d, 0xa6, 0x57, 0xef, 0x45, 0x02, 0x0b, 0x4d, 0x6e, 0x9e, 0x93, 0x8d, 0x2f, 0xd9, 0x9d, 0xdb, 0x04}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xc0, 0xd7, 0x56, 0x97, 0x58, 0x91, 0xde, 0x09, 0x4f, 0x9f, 0xbe, 0x63, 0xb0, 0x83, 0x86, 0x43, 0x5d, 0xbc, 0xe0, 0xf3, 0xc0, 0x75, 0xbf, 0x8b, 0x8e, 0xaa, 0xf7, 0x8b, 0x64, 0x6e, 0xb0, 0x63}} , {{0x16, 0xae, 0x8b, 0xe0, 0x9b, 0x24, 0x68, 0x5c, 0x44, 0xc2, 0xd0, 0x08, 0xb7, 0x7b, 0x62, 0xfd, 0x7f, 0xd8, 0xd4, 0xb7, 0x50, 0xfd, 0x2c, 0x1b, 0xbf, 0x41, 0x95, 0xd9, 0x8e, 0xd8, 0x17, 0x1b}}}, {{{0x86, 0x55, 0x37, 0x8e, 0xc3, 0x38, 0x48, 0x14, 0xb5, 0x97, 0xd2, 0xa7, 0x54, 0x45, 0xf1, 0x35, 0x44, 0x38, 0x9e, 0xf1, 0x1b, 0xb6, 0x34, 0x00, 0x3c, 0x96, 0xee, 0x29, 0x00, 0xea, 0x2c, 0x0b}} , {{0xea, 0xda, 0x99, 0x9e, 0x19, 0x83, 0x66, 0x6d, 0xe9, 0x76, 0x87, 0x50, 0xd1, 0xfd, 0x3c, 0x60, 0x87, 0xc6, 0x41, 0xd9, 0x8e, 0xdb, 0x5e, 0xde, 0xaa, 0x9a, 0xd3, 0x28, 0xda, 0x95, 0xea, 0x47}}}, {{{0xd0, 0x80, 0xba, 0x19, 0xae, 0x1d, 0xa9, 0x79, 0xf6, 0x3f, 0xac, 0x5d, 0x6f, 0x96, 0x1f, 0x2a, 0xce, 0x29, 0xb2, 0xff, 0x37, 0xf1, 0x94, 0x8f, 0x0c, 0xb5, 0x28, 0xba, 0x9a, 0x21, 0xf6, 0x66}} , {{0x02, 0xfb, 0x54, 0xb8, 0x05, 0xf3, 0x81, 0x52, 0x69, 0x34, 0x46, 0x9d, 0x86, 0x76, 0x8f, 0xd7, 0xf8, 0x6a, 0x66, 0xff, 0xe6, 0xa7, 0x90, 0xf7, 0x5e, 0xcd, 0x6a, 0x9b, 0x55, 0xfc, 0x9d, 0x48}}}, {{{0xbd, 0xaa, 0x13, 0xe6, 0xcd, 0x45, 0x4a, 0xa4, 0x59, 0x0a, 0x64, 0xb1, 0x98, 0xd6, 0x34, 0x13, 0x04, 0xe6, 0x97, 0x94, 0x06, 0xcb, 0xd4, 0x4e, 0xbb, 0x96, 0xcd, 0xd1, 0x57, 0xd1, 0xe3, 0x06}} , {{0x7a, 0x6c, 0x45, 0x27, 0xc4, 0x93, 0x7f, 0x7d, 0x7c, 0x62, 0x50, 0x38, 0x3a, 0x6b, 0xb5, 0x88, 0xc6, 0xd9, 0xf1, 0x78, 0x19, 0xb9, 0x39, 0x93, 0x3d, 0xc9, 0xe0, 0x9c, 0x3c, 0xce, 0xf5, 0x72}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x24, 0xea, 0x23, 0x7d, 0x56, 0x2c, 0xe2, 0x59, 0x0e, 0x85, 0x60, 0x04, 0x88, 0x5a, 0x74, 0x1e, 0x4b, 0xef, 0x13, 0xda, 0x4c, 0xff, 0x83, 0x45, 0x85, 0x3f, 0x08, 0x95, 0x2c, 0x20, 0x13, 0x1f}} , {{0x48, 0x5f, 0x27, 0x90, 0x5c, 0x02, 0x42, 0xad, 0x78, 0x47, 0x5c, 0xb5, 0x7e, 0x08, 0x85, 0x00, 0xfa, 0x7f, 0xfd, 0xfd, 0xe7, 0x09, 0x11, 0xf2, 0x7e, 0x1b, 0x38, 0x6c, 0x35, 0x6d, 0x33, 0x66}}}, {{{0x93, 0x03, 0x36, 0x81, 0xac, 0xe4, 0x20, 0x09, 0x35, 0x4c, 0x45, 0xb2, 0x1e, 0x4c, 0x14, 0x21, 0xe6, 0xe9, 0x8a, 0x7b, 0x8d, 0xfe, 0x1e, 0xc6, 0x3e, 0xc1, 0x35, 0xfa, 0xe7, 0x70, 0x4e, 0x1d}} , {{0x61, 0x2e, 0xc2, 0xdd, 0x95, 0x57, 0xd1, 0xab, 0x80, 0xe8, 0x63, 0x17, 0xb5, 0x48, 0xe4, 0x8a, 0x11, 0x9e, 0x72, 0xbe, 0x85, 0x8d, 0x51, 0x0a, 0xf2, 0x9f, 0xe0, 0x1c, 0xa9, 0x07, 0x28, 0x7b}}}, {{{0xbb, 0x71, 0x14, 0x5e, 0x26, 0x8c, 0x3d, 0xc8, 0xe9, 0x7c, 0xd3, 0xd6, 0xd1, 0x2f, 0x07, 0x6d, 0xe6, 0xdf, 0xfb, 0x79, 0xd6, 0x99, 0x59, 0x96, 0x48, 0x40, 0x0f, 0x3a, 0x7b, 0xb2, 0xa0, 0x72}} , {{0x4e, 0x3b, 0x69, 0xc8, 0x43, 0x75, 0x51, 0x6c, 0x79, 0x56, 0xe4, 0xcb, 0xf7, 0xa6, 0x51, 0xc2, 0x2c, 0x42, 0x0b, 0xd4, 0x82, 0x20, 0x1c, 0x01, 0x08, 0x66, 0xd7, 0xbf, 0x04, 0x56, 0xfc, 0x02}}}, {{{0x24, 0xe8, 0xb7, 0x60, 0xae, 0x47, 0x80, 0xfc, 0xe5, 0x23, 0xe7, 0xc2, 0xc9, 0x85, 0xe6, 0x98, 0xa0, 0x29, 0x4e, 0xe1, 0x84, 0x39, 0x2d, 0x95, 0x2c, 0xf3, 0x45, 0x3c, 0xff, 0xaf, 0x27, 0x4c}} , {{0x6b, 0xa6, 0xf5, 0x4b, 0x11, 0xbd, 0xba, 0x5b, 0x9e, 0xc4, 0xa4, 0x51, 0x1e, 0xbe, 0xd0, 0x90, 0x3a, 0x9c, 0xc2, 0x26, 0xb6, 0x1e, 0xf1, 0x95, 0x7d, 0xc8, 0x6d, 0x52, 0xe6, 0x99, 0x2c, 0x5f}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x85, 0xe0, 0x24, 0x32, 0xb4, 0xd1, 0xef, 0xfc, 0x69, 0xa2, 0xbf, 0x8f, 0x72, 0x2c, 0x95, 0xf6, 0xe4, 0x6e, 0x7d, 0x90, 0xf7, 0x57, 0x81, 0xa0, 0xf7, 0xda, 0xef, 0x33, 0x07, 0xe3, 0x6b, 0x78}} , {{0x36, 0x27, 0x3e, 0xc6, 0x12, 0x07, 0xab, 0x4e, 0xbe, 0x69, 0x9d, 0xb3, 0xbe, 0x08, 0x7c, 0x2a, 0x47, 0x08, 0xfd, 0xd4, 0xcd, 0x0e, 0x27, 0x34, 0x5b, 0x98, 0x34, 0x2f, 0x77, 0x5f, 0x3a, 0x65}}}, {{{0x13, 0xaa, 0x2e, 0x4c, 0xf0, 0x22, 0xb8, 0x6c, 0xb3, 0x19, 0x4d, 0xeb, 0x6b, 0xd0, 0xa4, 0xc6, 0x9c, 0xdd, 0xc8, 0x5b, 0x81, 0x57, 0x89, 0xdf, 0x33, 0xa9, 0x68, 0x49, 0x80, 0xe4, 0xfe, 0x21}} , {{0x00, 0x17, 0x90, 0x30, 0xe9, 0xd3, 0x60, 0x30, 0x31, 0xc2, 0x72, 0x89, 0x7a, 0x36, 0xa5, 0xbd, 0x39, 0x83, 0x85, 0x50, 0xa1, 0x5d, 0x6c, 0x41, 0x1d, 0xb5, 0x2c, 0x07, 0x40, 0x77, 0x0b, 0x50}}}, {{{0x64, 0x34, 0xec, 0xc0, 0x9e, 0x44, 0x41, 0xaf, 0xa0, 0x36, 0x05, 0x6d, 0xea, 0x30, 0x25, 0x46, 0x35, 0x24, 0x9d, 0x86, 0xbd, 0x95, 0xf1, 0x6a, 0x46, 0xd7, 0x94, 0x54, 0xf9, 0x3b, 0xbd, 0x5d}} , {{0x77, 0x5b, 0xe2, 0x37, 0xc7, 0xe1, 0x7c, 0x13, 0x8c, 0x9f, 0x7b, 0x7b, 0x2a, 0xce, 0x42, 0xa3, 0xb9, 0x2a, 0x99, 0xa8, 0xc0, 0xd8, 0x3c, 0x86, 0xb0, 0xfb, 0xe9, 0x76, 0x77, 0xf7, 0xf5, 0x56}}}, {{{0xdf, 0xb3, 0x46, 0x11, 0x6e, 0x13, 0xb7, 0x28, 0x4e, 0x56, 0xdd, 0xf1, 0xac, 0xad, 0x58, 0xc3, 0xf8, 0x88, 0x94, 0x5e, 0x06, 0x98, 0xa1, 0xe4, 0x6a, 0xfb, 0x0a, 0x49, 0x5d, 0x8a, 0xfe, 0x77}} , {{0x46, 0x02, 0xf5, 0xa5, 0xaf, 0xc5, 0x75, 0x6d, 0xba, 0x45, 0x35, 0x0a, 0xfe, 0xc9, 0xac, 0x22, 0x91, 0x8d, 0x21, 0x95, 0x33, 0x03, 0xc0, 0x8a, 0x16, 0xf3, 0x39, 0xe0, 0x01, 0x0f, 0x53, 0x3c}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x34, 0x75, 0x37, 0x1f, 0x34, 0x4e, 0xa9, 0x1d, 0x68, 0x67, 0xf8, 0x49, 0x98, 0x96, 0xfc, 0x4c, 0x65, 0x97, 0xf7, 0x02, 0x4a, 0x52, 0x6c, 0x01, 0xbd, 0x48, 0xbb, 0x1b, 0xed, 0xa4, 0xe2, 0x53}} , {{0x59, 0xd5, 0x9b, 0x5a, 0xa2, 0x90, 0xd3, 0xb8, 0x37, 0x4c, 0x55, 0x82, 0x28, 0x08, 0x0f, 0x7f, 0xaa, 0x81, 0x65, 0xe0, 0x0c, 0x52, 0xc9, 0xa3, 0x32, 0x27, 0x64, 0xda, 0xfd, 0x34, 0x23, 0x5a}}}, {{{0xb5, 0xb0, 0x0c, 0x4d, 0xb3, 0x7b, 0x23, 0xc8, 0x1f, 0x8a, 0x39, 0x66, 0xe6, 0xba, 0x4c, 0x10, 0x37, 0xca, 0x9c, 0x7c, 0x05, 0x9e, 0xff, 0xc0, 0xf8, 0x8e, 0xb1, 0x8f, 0x6f, 0x67, 0x18, 0x26}} , {{0x4b, 0x41, 0x13, 0x54, 0x23, 0x1a, 0xa4, 0x4e, 0xa9, 0x8b, 0x1e, 0x4b, 0xfc, 0x15, 0x24, 0xbb, 0x7e, 0xcb, 0xb6, 0x1e, 0x1b, 0xf5, 0xf2, 0xc8, 0x56, 0xec, 0x32, 0xa2, 0x60, 0x5b, 0xa0, 0x2a}}}, {{{0xa4, 0x29, 0x47, 0x86, 0x2e, 0x92, 0x4f, 0x11, 0x4f, 0xf3, 0xb2, 0x5c, 0xd5, 0x3e, 0xa6, 0xb9, 0xc8, 0xe2, 0x33, 0x11, 0x1f, 0x01, 0x8f, 0xb0, 0x9b, 0xc7, 0xa5, 0xff, 0x83, 0x0f, 0x1e, 0x28}} , {{0x1d, 0x29, 0x7a, 0xa1, 0xec, 0x8e, 0xb5, 0xad, 0xea, 0x02, 0x68, 0x60, 0x74, 0x29, 0x1c, 0xa5, 0xcf, 0xc8, 0x3b, 0x7d, 0x8b, 0x2b, 0x7c, 0xad, 0xa4, 0x40, 0x17, 0x51, 0x59, 0x7c, 0x2e, 0x5d}}}, {{{0x0a, 0x6c, 0x4f, 0xbc, 0x3e, 0x32, 0xe7, 0x4a, 0x1a, 0x13, 0xc1, 0x49, 0x38, 0xbf, 0xf7, 0xc2, 0xd3, 0x8f, 0x6b, 0xad, 0x52, 0xf7, 0xcf, 0xbc, 0x27, 0xcb, 0x40, 0x67, 0x76, 0xcd, 0x6d, 0x56}} , {{0xe5, 0xb0, 0x27, 0xad, 0xbe, 0x9b, 0xf2, 0xb5, 0x63, 0xde, 0x3a, 0x23, 0x95, 0xb7, 0x0a, 0x7e, 0xf3, 0x9e, 0x45, 0x6f, 0x19, 0x39, 0x75, 0x8f, 0x39, 0x3d, 0x0f, 0xc0, 0x9f, 0xf1, 0xe9, 0x51}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x88, 0xaa, 0x14, 0x24, 0x86, 0x94, 0x11, 0x12, 0x3e, 0x1a, 0xb5, 0xcc, 0xbb, 0xe0, 0x9c, 0xd5, 0x9c, 0x6d, 0xba, 0x58, 0x72, 0x8d, 0xfb, 0x22, 0x7b, 0x9f, 0x7c, 0x94, 0x30, 0xb3, 0x51, 0x21}} , {{0xf6, 0x74, 0x3d, 0xf2, 0xaf, 0xd0, 0x1e, 0x03, 0x7c, 0x23, 0x6b, 0xc9, 0xfc, 0x25, 0x70, 0x90, 0xdc, 0x9a, 0xa4, 0xfb, 0x49, 0xfc, 0x3d, 0x0a, 0x35, 0x38, 0x6f, 0xe4, 0x7e, 0x50, 0x01, 0x2a}}}, {{{0xd6, 0xe3, 0x96, 0x61, 0x3a, 0xfd, 0xef, 0x9b, 0x1f, 0x90, 0xa4, 0x24, 0x14, 0x5b, 0xc8, 0xde, 0x50, 0xb1, 0x1d, 0xaf, 0xe8, 0x55, 0x8a, 0x87, 0x0d, 0xfe, 0xaa, 0x3b, 0x82, 0x2c, 0x8d, 0x7b}} , {{0x85, 0x0c, 0xaf, 0xf8, 0x83, 0x44, 0x49, 0xd9, 0x45, 0xcf, 0xf7, 0x48, 0xd9, 0x53, 0xb4, 0xf1, 0x65, 0xa0, 0xe1, 0xc3, 0xb3, 0x15, 0xed, 0x89, 0x9b, 0x4f, 0x62, 0xb3, 0x57, 0xa5, 0x45, 0x1c}}}, {{{0x8f, 0x12, 0xea, 0xaf, 0xd1, 0x1f, 0x79, 0x10, 0x0b, 0xf6, 0xa3, 0x7b, 0xea, 0xac, 0x8b, 0x57, 0x32, 0x62, 0xe7, 0x06, 0x12, 0x51, 0xa0, 0x3b, 0x43, 0x5e, 0xa4, 0x20, 0x78, 0x31, 0xce, 0x0d}} , {{0x84, 0x7c, 0xc2, 0xa6, 0x91, 0x23, 0xce, 0xbd, 0xdc, 0xf9, 0xce, 0xd5, 0x75, 0x30, 0x22, 0xe6, 0xf9, 0x43, 0x62, 0x0d, 0xf7, 0x75, 0x9d, 0x7f, 0x8c, 0xff, 0x7d, 0xe4, 0x72, 0xac, 0x9f, 0x1c}}}, {{{0x88, 0xc1, 0x99, 0xd0, 0x3c, 0x1c, 0x5d, 0xb4, 0xef, 0x13, 0x0f, 0x90, 0xb9, 0x36, 0x2f, 0x95, 0x95, 0xc6, 0xdc, 0xde, 0x0a, 0x51, 0xe2, 0x8d, 0xf3, 0xbc, 0x51, 0xec, 0xdf, 0xb1, 0xa2, 0x5f}} , {{0x2e, 0x68, 0xa1, 0x23, 0x7d, 0x9b, 0x40, 0x69, 0x85, 0x7b, 0x42, 0xbf, 0x90, 0x4b, 0xd6, 0x40, 0x2f, 0xd7, 0x52, 0x52, 0xb2, 0x21, 0xde, 0x64, 0xbd, 0x88, 0xc3, 0x6d, 0xa5, 0xfa, 0x81, 0x3f}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xfb, 0xfd, 0x47, 0x7b, 0x8a, 0x66, 0x9e, 0x79, 0x2e, 0x64, 0x82, 0xef, 0xf7, 0x21, 0xec, 0xf6, 0xd8, 0x86, 0x09, 0x31, 0x7c, 0xdd, 0x03, 0x6a, 0x58, 0xa0, 0x77, 0xb7, 0x9b, 0x8c, 0x87, 0x1f}} , {{0x55, 0x47, 0xe4, 0xa8, 0x3d, 0x55, 0x21, 0x34, 0xab, 0x1d, 0xae, 0xe0, 0xf4, 0xea, 0xdb, 0xc5, 0xb9, 0x58, 0xbf, 0xc4, 0x2a, 0x89, 0x31, 0x1a, 0xf4, 0x2d, 0xe1, 0xca, 0x37, 0x99, 0x47, 0x59}}}, {{{0xc7, 0xca, 0x63, 0xc1, 0x49, 0xa9, 0x35, 0x45, 0x55, 0x7e, 0xda, 0x64, 0x32, 0x07, 0x50, 0xf7, 0x32, 0xac, 0xde, 0x75, 0x58, 0x9b, 0x11, 0xb2, 0x3a, 0x1f, 0xf5, 0xf7, 0x79, 0x04, 0xe6, 0x08}} , {{0x46, 0xfa, 0x22, 0x4b, 0xfa, 0xe1, 0xfe, 0x96, 0xfc, 0x67, 0xba, 0x67, 0x97, 0xc4, 0xe7, 0x1b, 0x86, 0x90, 0x5f, 0xee, 0xf4, 0x5b, 0x11, 0xb2, 0xcd, 0xad, 0xee, 0xc2, 0x48, 0x6c, 0x2b, 0x1b}}}, {{{0xe3, 0x39, 0x62, 0xb4, 0x4f, 0x31, 0x04, 0xc9, 0xda, 0xd5, 0x73, 0x51, 0x57, 0xc5, 0xb8, 0xf3, 0xa3, 0x43, 0x70, 0xe4, 0x61, 0x81, 0x84, 0xe2, 0xbb, 0xbf, 0x4f, 0x9e, 0xa4, 0x5e, 0x74, 0x06}} , {{0x29, 0xac, 0xff, 0x27, 0xe0, 0x59, 0xbe, 0x39, 0x9c, 0x0d, 0x83, 0xd7, 0x10, 0x0b, 0x15, 0xb7, 0xe1, 0xc2, 0x2c, 0x30, 0x73, 0x80, 0x3a, 0x7d, 0x5d, 0xab, 0x58, 0x6b, 0xc1, 0xf0, 0xf4, 0x22}}}, {{{0xfe, 0x7f, 0xfb, 0x35, 0x7d, 0xc6, 0x01, 0x23, 0x28, 0xc4, 0x02, 0xac, 0x1f, 0x42, 0xb4, 0x9d, 0xfc, 0x00, 0x94, 0xa5, 0xee, 0xca, 0xda, 0x97, 0x09, 0x41, 0x77, 0x87, 0x5d, 0x7b, 0x87, 0x78}} , {{0xf5, 0xfb, 0x90, 0x2d, 0x81, 0x19, 0x9e, 0x2f, 0x6d, 0x85, 0x88, 0x8c, 0x40, 0x5c, 0x77, 0x41, 0x4d, 0x01, 0x19, 0x76, 0x60, 0xe8, 0x4c, 0x48, 0xe4, 0x33, 0x83, 0x32, 0x6c, 0xb4, 0x41, 0x03}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xff, 0x10, 0xc2, 0x09, 0x4f, 0x6e, 0xf4, 0xd2, 0xdf, 0x7e, 0xca, 0x7b, 0x1c, 0x1d, 0xba, 0xa3, 0xb6, 0xda, 0x67, 0x33, 0xd4, 0x87, 0x36, 0x4b, 0x11, 0x20, 0x05, 0xa6, 0x29, 0xc1, 0x87, 0x17}} , {{0xf6, 0x96, 0xca, 0x2f, 0xda, 0x38, 0xa7, 0x1b, 0xfc, 0xca, 0x7d, 0xfe, 0x08, 0x89, 0xe2, 0x47, 0x2b, 0x6a, 0x5d, 0x4b, 0xfa, 0xa1, 0xb4, 0xde, 0xb6, 0xc2, 0x31, 0x51, 0xf5, 0xe0, 0xa4, 0x0b}}}, {{{0x5c, 0xe5, 0xc6, 0x04, 0x8e, 0x2b, 0x57, 0xbe, 0x38, 0x85, 0x23, 0xcb, 0xb7, 0xbe, 0x4f, 0xa9, 0xd3, 0x6e, 0x12, 0xaa, 0xd5, 0xb2, 0x2e, 0x93, 0x29, 0x9a, 0x4a, 0x88, 0x18, 0x43, 0xf5, 0x01}} , {{0x50, 0xfc, 0xdb, 0xa2, 0x59, 0x21, 0x8d, 0xbd, 0x7e, 0x33, 0xae, 0x2f, 0x87, 0x1a, 0xd0, 0x97, 0xc7, 0x0d, 0x4d, 0x63, 0x01, 0xef, 0x05, 0x84, 0xec, 0x40, 0xdd, 0xa8, 0x0a, 0x4f, 0x70, 0x0b}}}, {{{0x41, 0x69, 0x01, 0x67, 0x5c, 0xd3, 0x8a, 0xc5, 0xcf, 0x3f, 0xd1, 0x57, 0xd1, 0x67, 0x3e, 0x01, 0x39, 0xb5, 0xcb, 0x81, 0x56, 0x96, 0x26, 0xb6, 0xc2, 0xe7, 0x5c, 0xfb, 0x63, 0x97, 0x58, 0x06}} , {{0x0c, 0x0e, 0xf3, 0xba, 0xf0, 0xe5, 0xba, 0xb2, 0x57, 0x77, 0xc6, 0x20, 0x9b, 0x89, 0x24, 0xbe, 0xf2, 0x9c, 0x8a, 0xba, 0x69, 0xc1, 0xf1, 0xb0, 0x4f, 0x2a, 0x05, 0x9a, 0xee, 0x10, 0x7e, 0x36}}}, {{{0x3f, 0x26, 0xe9, 0x40, 0xe9, 0x03, 0xad, 0x06, 0x69, 0x91, 0xe0, 0xd1, 0x89, 0x60, 0x84, 0x79, 0xde, 0x27, 0x6d, 0xe6, 0x76, 0xbd, 0xea, 0xe6, 0xae, 0x48, 0xc3, 0x67, 0xc0, 0x57, 0xcd, 0x2f}} , {{0x7f, 0xc1, 0xdc, 0xb9, 0xc7, 0xbc, 0x86, 0x3d, 0x55, 0x4b, 0x28, 0x7a, 0xfb, 0x4d, 0xc7, 0xf8, 0xbc, 0x67, 0x2a, 0x60, 0x4d, 0x8f, 0x07, 0x0b, 0x1a, 0x17, 0xbf, 0xfa, 0xac, 0xa7, 0x3d, 0x1a}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x91, 0x3f, 0xed, 0x5e, 0x18, 0x78, 0x3f, 0x23, 0x2c, 0x0d, 0x8c, 0x44, 0x00, 0xe8, 0xfb, 0xe9, 0x8e, 0xd6, 0xd1, 0x36, 0x58, 0x57, 0x9e, 0xae, 0x4b, 0x5c, 0x0b, 0x07, 0xbc, 0x6b, 0x55, 0x2b}} , {{0x6f, 0x4d, 0x17, 0xd7, 0xe1, 0x84, 0xd9, 0x78, 0xb1, 0x90, 0xfd, 0x2e, 0xb3, 0xb5, 0x19, 0x3f, 0x1b, 0xfa, 0xc0, 0x68, 0xb3, 0xdd, 0x00, 0x2e, 0x89, 0xbd, 0x7e, 0x80, 0x32, 0x13, 0xa0, 0x7b}}}, {{{0x1a, 0x6f, 0x40, 0xaf, 0x44, 0x44, 0xb0, 0x43, 0x8f, 0x0d, 0xd0, 0x1e, 0xc4, 0x0b, 0x19, 0x5d, 0x8e, 0xfe, 0xc1, 0xf3, 0xc5, 0x5c, 0x91, 0xf8, 0x04, 0x4e, 0xbe, 0x90, 0xb4, 0x47, 0x5c, 0x3f}} , {{0xb0, 0x3b, 0x2c, 0xf3, 0xfe, 0x32, 0x71, 0x07, 0x3f, 0xaa, 0xba, 0x45, 0x60, 0xa8, 0x8d, 0xea, 0x54, 0xcb, 0x39, 0x10, 0xb4, 0xf2, 0x8b, 0xd2, 0x14, 0x82, 0x42, 0x07, 0x8e, 0xe9, 0x7c, 0x53}}}, {{{0xb0, 0xae, 0xc1, 0x8d, 0xc9, 0x8f, 0xb9, 0x7a, 0x77, 0xef, 0xba, 0x79, 0xa0, 0x3c, 0xa8, 0xf5, 0x6a, 0xe2, 0x3f, 0x5d, 0x00, 0xe3, 0x4b, 0x45, 0x24, 0x7b, 0x43, 0x78, 0x55, 0x1d, 0x2b, 0x1e}} , {{0x01, 0xb8, 0xd6, 0x16, 0x67, 0xa0, 0x15, 0xb9, 0xe1, 0x58, 0xa4, 0xa7, 0x31, 0x37, 0x77, 0x2f, 0x8b, 0x12, 0x9f, 0xf4, 0x3f, 0xc7, 0x36, 0x66, 0xd2, 0xa8, 0x56, 0xf7, 0x7f, 0x74, 0xc6, 0x41}}}, {{{0x5d, 0xf8, 0xb4, 0xa8, 0x30, 0xdd, 0xcc, 0x38, 0xa5, 0xd3, 0xca, 0xd8, 0xd1, 0xf8, 0xb2, 0x31, 0x91, 0xd4, 0x72, 0x05, 0x57, 0x4a, 0x3b, 0x82, 0x4a, 0xc6, 0x68, 0x20, 0xe2, 0x18, 0x41, 0x61}} , {{0x19, 0xd4, 0x8d, 0x47, 0x29, 0x12, 0x65, 0xb0, 0x11, 0x78, 0x47, 0xb5, 0xcb, 0xa3, 0xa5, 0xfa, 0x05, 0x85, 0x54, 0xa9, 0x33, 0x97, 0x8d, 0x2b, 0xc2, 0xfe, 0x99, 0x35, 0x28, 0xe5, 0xeb, 0x63}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xb1, 0x3f, 0x3f, 0xef, 0xd8, 0xf4, 0xfc, 0xb3, 0xa0, 0x60, 0x50, 0x06, 0x2b, 0x29, 0x52, 0x70, 0x15, 0x0b, 0x24, 0x24, 0xf8, 0x5f, 0x79, 0x18, 0xcc, 0xff, 0x89, 0x99, 0x84, 0xa1, 0xae, 0x13}} , {{0x44, 0x1f, 0xb8, 0xc2, 0x01, 0xc1, 0x30, 0x19, 0x55, 0x05, 0x60, 0x10, 0xa4, 0x6c, 0x2d, 0x67, 0x70, 0xe5, 0x25, 0x1b, 0xf2, 0xbf, 0xdd, 0xfb, 0x70, 0x2b, 0xa1, 0x8c, 0x9c, 0x94, 0x84, 0x08}}}, {{{0xe7, 0xc4, 0x43, 0x4d, 0xc9, 0x2b, 0x69, 0x5d, 0x1d, 0x3c, 0xaf, 0xbb, 0x43, 0x38, 0x4e, 0x98, 0x3d, 0xed, 0x0d, 0x21, 0x03, 0xfd, 0xf0, 0x99, 0x47, 0x04, 0xb0, 0x98, 0x69, 0x55, 0x72, 0x0f}} , {{0x5e, 0xdf, 0x15, 0x53, 0x3b, 0x86, 0x80, 0xb0, 0xf1, 0x70, 0x68, 0x8f, 0x66, 0x7c, 0x0e, 0x49, 0x1a, 0xd8, 0x6b, 0xfe, 0x4e, 0xef, 0xca, 0x47, 0xd4, 0x03, 0xc1, 0x37, 0x50, 0x9c, 0xc1, 0x16}}}, {{{0xcd, 0x24, 0xc6, 0x3e, 0x0c, 0x82, 0x9b, 0x91, 0x2b, 0x61, 0x4a, 0xb2, 0x0f, 0x88, 0x55, 0x5f, 0x5a, 0x57, 0xff, 0xe5, 0x74, 0x0b, 0x13, 0x43, 0x00, 0xd8, 0x6b, 0xcf, 0xd2, 0x15, 0x03, 0x2c}} , {{0xdc, 0xff, 0x15, 0x61, 0x2f, 0x4a, 0x2f, 0x62, 0xf2, 0x04, 0x2f, 0xb5, 0x0c, 0xb7, 0x1e, 0x3f, 0x74, 0x1a, 0x0f, 0xd7, 0xea, 0xcd, 0xd9, 0x7d, 0xf6, 0x12, 0x0e, 0x2f, 0xdb, 0x5a, 0x3b, 0x16}}}, {{{0x1b, 0x37, 0x47, 0xe3, 0xf5, 0x9e, 0xea, 0x2c, 0x2a, 0xe7, 0x82, 0x36, 0xf4, 0x1f, 0x81, 0x47, 0x92, 0x4b, 0x69, 0x0e, 0x11, 0x8c, 0x5d, 0x53, 0x5b, 0x81, 0x27, 0x08, 0xbc, 0xa0, 0xae, 0x25}} , {{0x69, 0x32, 0xa1, 0x05, 0x11, 0x42, 0x00, 0xd2, 0x59, 0xac, 0x4d, 0x62, 0x8b, 0x13, 0xe2, 0x50, 0x5d, 0xa0, 0x9d, 0x9b, 0xfd, 0xbb, 0x12, 0x41, 0x75, 0x41, 0x9e, 0xcc, 0xdc, 0xc7, 0xdc, 0x5d}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xd9, 0xe3, 0x38, 0x06, 0x46, 0x70, 0x82, 0x5e, 0x28, 0x49, 0x79, 0xff, 0x25, 0xd2, 0x4e, 0x29, 0x8d, 0x06, 0xb0, 0x23, 0xae, 0x9b, 0x66, 0xe4, 0x7d, 0xc0, 0x70, 0x91, 0xa3, 0xfc, 0xec, 0x4e}} , {{0x62, 0x12, 0x37, 0x6a, 0x30, 0xf6, 0x1e, 0xfb, 0x14, 0x5c, 0x0d, 0x0e, 0xb7, 0x81, 0x6a, 0xe7, 0x08, 0x05, 0xac, 0xaa, 0x38, 0x46, 0xe2, 0x73, 0xea, 0x4b, 0x07, 0x81, 0x43, 0x7c, 0x9e, 0x5e}}}, {{{0xfc, 0xf9, 0x21, 0x4f, 0x2e, 0x76, 0x9b, 0x1f, 0x28, 0x60, 0x77, 0x43, 0x32, 0x9d, 0xbe, 0x17, 0x30, 0x2a, 0xc6, 0x18, 0x92, 0x66, 0x62, 0x30, 0x98, 0x40, 0x11, 0xa6, 0x7f, 0x18, 0x84, 0x28}} , {{0x3f, 0xab, 0xd3, 0xf4, 0x8a, 0x76, 0xa1, 0x3c, 0xca, 0x2d, 0x49, 0xc3, 0xea, 0x08, 0x0b, 0x85, 0x17, 0x2a, 0xc3, 0x6c, 0x08, 0xfd, 0x57, 0x9f, 0x3d, 0x5f, 0xdf, 0x67, 0x68, 0x42, 0x00, 0x32}}}, {{{0x51, 0x60, 0x1b, 0x06, 0x4f, 0x8a, 0x21, 0xba, 0x38, 0xa8, 0xba, 0xd6, 0x40, 0xf6, 0xe9, 0x9b, 0x76, 0x4d, 0x56, 0x21, 0x5b, 0x0a, 0x9b, 0x2e, 0x4f, 0x3d, 0x81, 0x32, 0x08, 0x9f, 0x97, 0x5b}} , {{0xe5, 0x44, 0xec, 0x06, 0x9d, 0x90, 0x79, 0x9f, 0xd3, 0xe0, 0x79, 0xaf, 0x8f, 0x10, 0xfd, 0xdd, 0x04, 0xae, 0x27, 0x97, 0x46, 0x33, 0x79, 0xea, 0xb8, 0x4e, 0xca, 0x5a, 0x59, 0x57, 0xe1, 0x0e}}}, {{{0x1a, 0xda, 0xf3, 0xa5, 0x41, 0x43, 0x28, 0xfc, 0x7e, 0xe7, 0x71, 0xea, 0xc6, 0x3b, 0x59, 0xcc, 0x2e, 0xd3, 0x40, 0xec, 0xb3, 0x13, 0x6f, 0x44, 0xcd, 0x13, 0xb2, 0x37, 0xf2, 0x6e, 0xd9, 0x1c}} , {{0xe3, 0xdb, 0x60, 0xcd, 0x5c, 0x4a, 0x18, 0x0f, 0xef, 0x73, 0x36, 0x71, 0x8c, 0xf6, 0x11, 0xb4, 0xd8, 0xce, 0x17, 0x5e, 0x4f, 0x26, 0x77, 0x97, 0x5f, 0xcb, 0xef, 0x91, 0xeb, 0x6a, 0x62, 0x7a}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x18, 0x4a, 0xa2, 0x97, 0x08, 0x81, 0x2d, 0x83, 0xc4, 0xcc, 0xf0, 0x83, 0x7e, 0xec, 0x0d, 0x95, 0x4c, 0x5b, 0xfb, 0xfa, 0x98, 0x80, 0x4a, 0x66, 0x56, 0x0c, 0x51, 0xb3, 0xf2, 0x04, 0x5d, 0x27}} , {{0x3b, 0xb9, 0xb8, 0x06, 0x5a, 0x2e, 0xfe, 0xc3, 0x82, 0x37, 0x9c, 0xa3, 0x11, 0x1f, 0x9c, 0xa6, 0xda, 0x63, 0x48, 0x9b, 0xad, 0xde, 0x2d, 0xa6, 0xbc, 0x6e, 0x32, 0xda, 0x27, 0x65, 0xdd, 0x57}}}, {{{0x84, 0x4f, 0x37, 0x31, 0x7d, 0x2e, 0xbc, 0xad, 0x87, 0x07, 0x2a, 0x6b, 0x37, 0xfc, 0x5f, 0xeb, 0x4e, 0x75, 0x35, 0xa6, 0xde, 0xab, 0x0a, 0x19, 0x3a, 0xb7, 0xb1, 0xef, 0x92, 0x6a, 0x3b, 0x3c}} , {{0x3b, 0xb2, 0x94, 0x6d, 0x39, 0x60, 0xac, 0xee, 0xe7, 0x81, 0x1a, 0x3b, 0x76, 0x87, 0x5c, 0x05, 0x94, 0x2a, 0x45, 0xb9, 0x80, 0xe9, 0x22, 0xb1, 0x07, 0xcb, 0x40, 0x9e, 0x70, 0x49, 0x6d, 0x12}}}, {{{0xfd, 0x18, 0x78, 0x84, 0xa8, 0x4c, 0x7d, 0x6e, 0x59, 0xa6, 0xe5, 0x74, 0xf1, 0x19, 0xa6, 0x84, 0x2e, 0x51, 0xc1, 0x29, 0x13, 0xf2, 0x14, 0x6b, 0x5d, 0x53, 0x51, 0xf7, 0xef, 0xbf, 0x01, 0x22}} , {{0xa4, 0x4b, 0x62, 0x4c, 0xe6, 0xfd, 0x72, 0x07, 0xf2, 0x81, 0xfc, 0xf2, 0xbd, 0x12, 0x7c, 0x68, 0x76, 0x2a, 0xba, 0xf5, 0x65, 0xb1, 0x1f, 0x17, 0x0a, 0x38, 0xb0, 0xbf, 0xc0, 0xf8, 0xf4, 0x2a}}}, {{{0x55, 0x60, 0x55, 0x5b, 0xe4, 0x1d, 0x71, 0x4c, 0x9d, 0x5b, 0x9f, 0x70, 0xa6, 0x85, 0x9a, 0x2c, 0xa0, 0xe2, 0x32, 0x48, 0xce, 0x9e, 0x2a, 0xa5, 0x07, 0x3b, 0xc7, 0x6c, 0x86, 0x77, 0xde, 0x3c}} , {{0xf7, 0x18, 0x7a, 0x96, 0x7e, 0x43, 0x57, 0xa9, 0x55, 0xfc, 0x4e, 0xb6, 0x72, 0x00, 0xf2, 0xe4, 0xd7, 0x52, 0xd3, 0xd3, 0xb6, 0x85, 0xf6, 0x71, 0xc7, 0x44, 0x3f, 0x7f, 0xd7, 0xb3, 0xf2, 0x79}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x46, 0xca, 0xa7, 0x55, 0x7b, 0x79, 0xf3, 0xca, 0x5a, 0x65, 0xf6, 0xed, 0x50, 0x14, 0x7b, 0xe4, 0xc4, 0x2a, 0x65, 0x9e, 0xe2, 0xf9, 0xca, 0xa7, 0x22, 0x26, 0x53, 0xcb, 0x21, 0x5b, 0xa7, 0x31}} , {{0x90, 0xd7, 0xc5, 0x26, 0x08, 0xbd, 0xb0, 0x53, 0x63, 0x58, 0xc3, 0x31, 0x5e, 0x75, 0x46, 0x15, 0x91, 0xa6, 0xf8, 0x2f, 0x1a, 0x08, 0x65, 0x88, 0x2f, 0x98, 0x04, 0xf1, 0x7c, 0x6e, 0x00, 0x77}}}, {{{0x81, 0x21, 0x61, 0x09, 0xf6, 0x4e, 0xf1, 0x92, 0xee, 0x63, 0x61, 0x73, 0x87, 0xc7, 0x54, 0x0e, 0x42, 0x4b, 0xc9, 0x47, 0xd1, 0xb8, 0x7e, 0x91, 0x75, 0x37, 0x99, 0x28, 0xb8, 0xdd, 0x7f, 0x50}} , {{0x89, 0x8f, 0xc0, 0xbe, 0x5d, 0xd6, 0x9f, 0xa0, 0xf0, 0x9d, 0x81, 0xce, 0x3a, 0x7b, 0x98, 0x58, 0xbb, 0xd7, 0x78, 0xc8, 0x3f, 0x13, 0xf1, 0x74, 0x19, 0xdf, 0xf8, 0x98, 0x89, 0x5d, 0xfa, 0x5f}}}, {{{0x9e, 0x35, 0x85, 0x94, 0x47, 0x1f, 0x90, 0x15, 0x26, 0xd0, 0x84, 0xed, 0x8a, 0x80, 0xf7, 0x63, 0x42, 0x86, 0x27, 0xd7, 0xf4, 0x75, 0x58, 0xdc, 0x9c, 0xc0, 0x22, 0x7e, 0x20, 0x35, 0xfd, 0x1f}} , {{0x68, 0x0e, 0x6f, 0x97, 0xba, 0x70, 0xbb, 0xa3, 0x0e, 0xe5, 0x0b, 0x12, 0xf4, 0xa2, 0xdc, 0x47, 0xf8, 0xe6, 0xd0, 0x23, 0x6c, 0x33, 0xa8, 0x99, 0x46, 0x6e, 0x0f, 0x44, 0xba, 0x76, 0x48, 0x0f}}}, {{{0xa3, 0x2a, 0x61, 0x37, 0xe2, 0x59, 0x12, 0x0e, 0x27, 0xba, 0x64, 0x43, 0xae, 0xc0, 0x42, 0x69, 0x79, 0xa4, 0x1e, 0x29, 0x8b, 0x15, 0xeb, 0xf8, 0xaf, 0xd4, 0xa2, 0x68, 0x33, 0xb5, 0x7a, 0x24}} , {{0x2c, 0x19, 0x33, 0xdd, 0x1b, 0xab, 0xec, 0x01, 0xb0, 0x23, 0xf8, 0x42, 0x2b, 0x06, 0x88, 0xea, 0x3d, 0x2d, 0x00, 0x2a, 0x78, 0x45, 0x4d, 0x38, 0xed, 0x2e, 0x2e, 0x44, 0x49, 0xed, 0xcb, 0x33}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xa0, 0x68, 0xe8, 0x41, 0x8f, 0x91, 0xf8, 0x11, 0x13, 0x90, 0x2e, 0xa7, 0xab, 0x30, 0xef, 0xad, 0xa0, 0x61, 0x00, 0x88, 0xef, 0xdb, 0xce, 0x5b, 0x5c, 0xbb, 0x62, 0xc8, 0x56, 0xf9, 0x00, 0x73}} , {{0x3f, 0x60, 0xc1, 0x82, 0x2d, 0xa3, 0x28, 0x58, 0x24, 0x9e, 0x9f, 0xe3, 0x70, 0xcc, 0x09, 0x4e, 0x1a, 0x3f, 0x11, 0x11, 0x15, 0x07, 0x3c, 0xa4, 0x41, 0xe0, 0x65, 0xa3, 0x0a, 0x41, 0x6d, 0x11}}}, {{{0x31, 0x40, 0x01, 0x52, 0x56, 0x94, 0x5b, 0x28, 0x8a, 0xaa, 0x52, 0xee, 0xd8, 0x0a, 0x05, 0x8d, 0xcd, 0xb5, 0xaa, 0x2e, 0x38, 0xaa, 0xb7, 0x87, 0xf7, 0x2b, 0xfb, 0x04, 0xcb, 0x84, 0x3d, 0x54}} , {{0x20, 0xef, 0x59, 0xde, 0xa4, 0x2b, 0x93, 0x6e, 0x2e, 0xec, 0x42, 0x9a, 0xd4, 0x2d, 0xf4, 0x46, 0x58, 0x27, 0x2b, 0x18, 0x8f, 0x83, 0x3d, 0x69, 0x9e, 0xd4, 0x3e, 0xb6, 0xc5, 0xfd, 0x58, 0x03}}}, {{{0x33, 0x89, 0xc9, 0x63, 0x62, 0x1c, 0x17, 0xb4, 0x60, 0xc4, 0x26, 0x68, 0x09, 0xc3, 0x2e, 0x37, 0x0f, 0x7b, 0xb4, 0x9c, 0xb6, 0xf9, 0xfb, 0xd4, 0x51, 0x78, 0xc8, 0x63, 0xea, 0x77, 0x47, 0x07}} , {{0x32, 0xb4, 0x18, 0x47, 0x79, 0xcb, 0xd4, 0x5a, 0x07, 0x14, 0x0f, 0xa0, 0xd5, 0xac, 0xd0, 0x41, 0x40, 0xab, 0x61, 0x23, 0xe5, 0x2a, 0x2a, 0x6f, 0xf7, 0xa8, 0xd4, 0x76, 0xef, 0xe7, 0x45, 0x6c}}}, {{{0xa1, 0x5e, 0x60, 0x4f, 0xfb, 0xe1, 0x70, 0x6a, 0x1f, 0x55, 0x4f, 0x09, 0xb4, 0x95, 0x33, 0x36, 0xc6, 0x81, 0x01, 0x18, 0x06, 0x25, 0x27, 0xa4, 0xb4, 0x24, 0xa4, 0x86, 0x03, 0x4c, 0xac, 0x02}} , {{0x77, 0x38, 0xde, 0xd7, 0x60, 0x48, 0x07, 0xf0, 0x74, 0xa8, 0xff, 0x54, 0xe5, 0x30, 0x43, 0xff, 0x77, 0xfb, 0x21, 0x07, 0xff, 0xb2, 0x07, 0x6b, 0xe4, 0xe5, 0x30, 0xfc, 0x19, 0x6c, 0xa3, 0x01}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x13, 0xc5, 0x2c, 0xac, 0xd3, 0x83, 0x82, 0x7c, 0x29, 0xf7, 0x05, 0xa5, 0x00, 0xb6, 0x1f, 0x86, 0x55, 0xf4, 0xd6, 0x2f, 0x0c, 0x99, 0xd0, 0x65, 0x9b, 0x6b, 0x46, 0x0d, 0x43, 0xf8, 0x16, 0x28}} , {{0x1e, 0x7f, 0xb4, 0x74, 0x7e, 0xb1, 0x89, 0x4f, 0x18, 0x5a, 0xab, 0x64, 0x06, 0xdf, 0x45, 0x87, 0xe0, 0x6a, 0xc6, 0xf0, 0x0e, 0xc9, 0x24, 0x35, 0x38, 0xea, 0x30, 0x54, 0xb4, 0xc4, 0x52, 0x54}}}, {{{0xe9, 0x9f, 0xdc, 0x3f, 0xc1, 0x89, 0x44, 0x74, 0x27, 0xe4, 0xc1, 0x90, 0xff, 0x4a, 0xa7, 0x3c, 0xee, 0xcd, 0xf4, 0x1d, 0x25, 0x94, 0x7f, 0x63, 0x16, 0x48, 0xbc, 0x64, 0xfe, 0x95, 0xc4, 0x0c}} , {{0x8b, 0x19, 0x75, 0x6e, 0x03, 0x06, 0x5e, 0x6a, 0x6f, 0x1a, 0x8c, 0xe3, 0xd3, 0x28, 0xf2, 0xe0, 0xb9, 0x7a, 0x43, 0x69, 0xe6, 0xd3, 0xc0, 0xfe, 0x7e, 0x97, 0xab, 0x6c, 0x7b, 0x8e, 0x13, 0x42}}}, {{{0xd4, 0xca, 0x70, 0x3d, 0xab, 0xfb, 0x5f, 0x5e, 0x00, 0x0c, 0xcc, 0x77, 0x22, 0xf8, 0x78, 0x55, 0xae, 0x62, 0x35, 0xfb, 0x9a, 0xc6, 0x03, 0xe4, 0x0c, 0xee, 0xab, 0xc7, 0xc0, 0x89, 0x87, 0x54}} , {{0x32, 0xad, 0xae, 0x85, 0x58, 0x43, 0xb8, 0xb1, 0xe6, 0x3e, 0x00, 0x9c, 0x78, 0x88, 0x56, 0xdb, 0x9c, 0xfc, 0x79, 0xf6, 0xf9, 0x41, 0x5f, 0xb7, 0xbc, 0x11, 0xf9, 0x20, 0x36, 0x1c, 0x53, 0x2b}}}, {{{0x5a, 0x20, 0x5b, 0xa1, 0xa5, 0x44, 0x91, 0x24, 0x02, 0x63, 0x12, 0x64, 0xb8, 0x55, 0xf6, 0xde, 0x2c, 0xdb, 0x47, 0xb8, 0xc6, 0x0a, 0xc3, 0x00, 0x78, 0x93, 0xd8, 0xf5, 0xf5, 0x18, 0x28, 0x0a}} , {{0xd6, 0x1b, 0x9a, 0x6c, 0xe5, 0x46, 0xea, 0x70, 0x96, 0x8d, 0x4e, 0x2a, 0x52, 0x21, 0x26, 0x4b, 0xb1, 0xbb, 0x0f, 0x7c, 0xa9, 0x9b, 0x04, 0xbb, 0x51, 0x08, 0xf1, 0x9a, 0xa4, 0x76, 0x7c, 0x18}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xfa, 0x94, 0xf7, 0x40, 0xd0, 0xd7, 0xeb, 0xa9, 0x82, 0x36, 0xd5, 0x15, 0xb9, 0x33, 0x7a, 0xbf, 0x8a, 0xf2, 0x63, 0xaa, 0x37, 0xf5, 0x59, 0xac, 0xbd, 0xbb, 0x32, 0x36, 0xbe, 0x73, 0x99, 0x38}} , {{0x2c, 0xb3, 0xda, 0x7a, 0xd8, 0x3d, 0x99, 0xca, 0xd2, 0xf4, 0xda, 0x99, 0x8e, 0x4f, 0x98, 0xb7, 0xf4, 0xae, 0x3e, 0x9f, 0x8e, 0x35, 0x60, 0xa4, 0x33, 0x75, 0xa4, 0x04, 0x93, 0xb1, 0x6b, 0x4d}}}, {{{0x97, 0x9d, 0xa8, 0xcd, 0x97, 0x7b, 0x9d, 0xb9, 0xe7, 0xa5, 0xef, 0xfd, 0xa8, 0x42, 0x6b, 0xc3, 0x62, 0x64, 0x7d, 0xa5, 0x1b, 0xc9, 0x9e, 0xd2, 0x45, 0xb9, 0xee, 0x03, 0xb0, 0xbf, 0xc0, 0x68}} , {{0xed, 0xb7, 0x84, 0x2c, 0xf6, 0xd3, 0xa1, 0x6b, 0x24, 0x6d, 0x87, 0x56, 0x97, 0x59, 0x79, 0x62, 0x9f, 0xac, 0xed, 0xf3, 0xc9, 0x89, 0x21, 0x2e, 0x04, 0xb3, 0xcc, 0x2f, 0xbe, 0xd6, 0x0a, 0x4b}}}, {{{0x39, 0x61, 0x05, 0xed, 0x25, 0x89, 0x8b, 0x5d, 0x1b, 0xcb, 0x0c, 0x55, 0xf4, 0x6a, 0x00, 0x8a, 0x46, 0xe8, 0x1e, 0xc6, 0x83, 0xc8, 0x5a, 0x76, 0xdb, 0xcc, 0x19, 0x7a, 0xcc, 0x67, 0x46, 0x0b}} , {{0x53, 0xcf, 0xc2, 0xa1, 0xad, 0x6a, 0xf3, 0xcd, 0x8f, 0xc9, 0xde, 0x1c, 0xf8, 0x6c, 0x8f, 0xf8, 0x76, 0x42, 0xe7, 0xfe, 0xb2, 0x72, 0x21, 0x0a, 0x66, 0x74, 0x8f, 0xb7, 0xeb, 0xe4, 0x6f, 0x01}}}, {{{0x22, 0x8c, 0x6b, 0xbe, 0xfc, 0x4d, 0x70, 0x62, 0x6e, 0x52, 0x77, 0x99, 0x88, 0x7e, 0x7b, 0x57, 0x7a, 0x0d, 0xfe, 0xdc, 0x72, 0x92, 0xf1, 0x68, 0x1d, 0x97, 0xd7, 0x7c, 0x8d, 0x53, 0x10, 0x37}} , {{0x53, 0x88, 0x77, 0x02, 0xca, 0x27, 0xa8, 0xe5, 0x45, 0xe2, 0xa8, 0x48, 0x2a, 0xab, 0x18, 0xca, 0xea, 0x2d, 0x2a, 0x54, 0x17, 0x37, 0x32, 0x09, 0xdc, 0xe0, 0x4a, 0xb7, 0x7d, 0x82, 0x10, 0x7d}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x8a, 0x64, 0x1e, 0x14, 0x0a, 0x57, 0xd4, 0xda, 0x5c, 0x96, 0x9b, 0x01, 0x4c, 0x67, 0xbf, 0x8b, 0x30, 0xfe, 0x08, 0xdb, 0x0d, 0xd5, 0xa8, 0xd7, 0x09, 0x11, 0x85, 0xa2, 0xd3, 0x45, 0xfb, 0x7e}} , {{0xda, 0x8c, 0xc2, 0xd0, 0xac, 0x18, 0xe8, 0x52, 0x36, 0xd4, 0x21, 0xa3, 0xdd, 0x57, 0x22, 0x79, 0xb7, 0xf8, 0x71, 0x9d, 0xc6, 0x91, 0x70, 0x86, 0x56, 0xbf, 0xa1, 0x11, 0x8b, 0x19, 0xe1, 0x0f}}}, {{{0x18, 0x32, 0x98, 0x2c, 0x8f, 0x91, 0xae, 0x12, 0xf0, 0x8c, 0xea, 0xf3, 0x3c, 0xb9, 0x5d, 0xe4, 0x69, 0xed, 0xb2, 0x47, 0x18, 0xbd, 0xce, 0x16, 0x52, 0x5c, 0x23, 0xe2, 0xa5, 0x25, 0x52, 0x5d}} , {{0xb9, 0xb1, 0xe7, 0x5d, 0x4e, 0xbc, 0xee, 0xbb, 0x40, 0x81, 0x77, 0x82, 0x19, 0xab, 0xb5, 0xc6, 0xee, 0xab, 0x5b, 0x6b, 0x63, 0x92, 0x8a, 0x34, 0x8d, 0xcd, 0xee, 0x4f, 0x49, 0xe5, 0xc9, 0x7e}}}, {{{0x21, 0xac, 0x8b, 0x22, 0xcd, 0xc3, 0x9a, 0xe9, 0x5e, 0x78, 0xbd, 0xde, 0xba, 0xad, 0xab, 0xbf, 0x75, 0x41, 0x09, 0xc5, 0x58, 0xa4, 0x7d, 0x92, 0xb0, 0x7f, 0xf2, 0xa1, 0xd1, 0xc0, 0xb3, 0x6d}} , {{0x62, 0x4f, 0xd0, 0x75, 0x77, 0xba, 0x76, 0x77, 0xd7, 0xb8, 0xd8, 0x92, 0x6f, 0x98, 0x34, 0x3d, 0xd6, 0x4e, 0x1c, 0x0f, 0xf0, 0x8f, 0x2e, 0xf1, 0xb3, 0xbd, 0xb1, 0xb9, 0xec, 0x99, 0xb4, 0x07}}}, {{{0x60, 0x57, 0x2e, 0x9a, 0x72, 0x1d, 0x6b, 0x6e, 0x58, 0x33, 0x24, 0x8c, 0x48, 0x39, 0x46, 0x8e, 0x89, 0x6a, 0x88, 0x51, 0x23, 0x62, 0xb5, 0x32, 0x09, 0x36, 0xe3, 0x57, 0xf5, 0x98, 0xde, 0x6f}} , {{0x8b, 0x2c, 0x00, 0x48, 0x4a, 0xf9, 0x5b, 0x87, 0x69, 0x52, 0xe5, 0x5b, 0xd1, 0xb1, 0xe5, 0x25, 0x25, 0xe0, 0x9c, 0xc2, 0x13, 0x44, 0xe8, 0xb9, 0x0a, 0x70, 0xad, 0xbd, 0x0f, 0x51, 0x94, 0x69}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xa2, 0xdc, 0xab, 0xa9, 0x25, 0x2d, 0xac, 0x5f, 0x03, 0x33, 0x08, 0xe7, 0x7e, 0xfe, 0x95, 0x36, 0x3c, 0x5b, 0x3a, 0xd3, 0x05, 0x82, 0x1c, 0x95, 0x2d, 0xd8, 0x77, 0x7e, 0x02, 0xd9, 0x5b, 0x70}} , {{0xc2, 0xfe, 0x1b, 0x0c, 0x67, 0xcd, 0xd6, 0xe0, 0x51, 0x8e, 0x2c, 0xe0, 0x79, 0x88, 0xf0, 0xcf, 0x41, 0x4a, 0xad, 0x23, 0xd4, 0x46, 0xca, 0x94, 0xa1, 0xc3, 0xeb, 0x28, 0x06, 0xfa, 0x17, 0x14}}}, {{{0x7b, 0xaa, 0x70, 0x0a, 0x4b, 0xfb, 0xf5, 0xbf, 0x80, 0xc5, 0xcf, 0x08, 0x7a, 0xdd, 0xa1, 0xf4, 0x9d, 0x54, 0x50, 0x53, 0x23, 0x77, 0x23, 0xf5, 0x34, 0xa5, 0x22, 0xd1, 0x0d, 0x96, 0x2e, 0x47}} , {{0xcc, 0xb7, 0x32, 0x89, 0x57, 0xd0, 0x98, 0x75, 0xe4, 0x37, 0x99, 0xa9, 0xe8, 0xba, 0xed, 0xba, 0xeb, 0xc7, 0x4f, 0x15, 0x76, 0x07, 0x0c, 0x4c, 0xef, 0x9f, 0x52, 0xfc, 0x04, 0x5d, 0x58, 0x10}}}, {{{0xce, 0x82, 0xf0, 0x8f, 0x79, 0x02, 0xa8, 0xd1, 0xda, 0x14, 0x09, 0x48, 0xee, 0x8a, 0x40, 0x98, 0x76, 0x60, 0x54, 0x5a, 0xde, 0x03, 0x24, 0xf5, 0xe6, 0x2f, 0xe1, 0x03, 0xbf, 0x68, 0x82, 0x7f}} , {{0x64, 0xe9, 0x28, 0xc7, 0xa4, 0xcf, 0x2a, 0xf9, 0x90, 0x64, 0x72, 0x2c, 0x8b, 0xeb, 0xec, 0xa0, 0xf2, 0x7d, 0x35, 0xb5, 0x90, 0x4d, 0x7f, 0x5b, 0x4a, 0x49, 0xe4, 0xb8, 0x3b, 0xc8, 0xa1, 0x2f}}}, {{{0x8b, 0xc5, 0xcc, 0x3d, 0x69, 0xa6, 0xa1, 0x18, 0x44, 0xbc, 0x4d, 0x77, 0x37, 0xc7, 0x86, 0xec, 0x0c, 0xc9, 0xd6, 0x44, 0xa9, 0x23, 0x27, 0xb9, 0x03, 0x34, 0xa7, 0x0a, 0xd5, 0xc7, 0x34, 0x37}} , {{0xf9, 0x7e, 0x3e, 0x66, 0xee, 0xf9, 0x99, 0x28, 0xff, 0xad, 0x11, 0xd8, 0xe2, 0x66, 0xc5, 0xcd, 0x0f, 0x0d, 0x0b, 0x6a, 0xfc, 0x7c, 0x24, 0xa8, 0x4f, 0xa8, 0x5e, 0x80, 0x45, 0x8b, 0x6c, 0x41}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xef, 0x1e, 0xec, 0xf7, 0x8d, 0x77, 0xf2, 0xea, 0xdb, 0x60, 0x03, 0x21, 0xc0, 0xff, 0x5e, 0x67, 0xc3, 0x71, 0x0b, 0x21, 0xb4, 0x41, 0xa0, 0x68, 0x38, 0xc6, 0x01, 0xa3, 0xd3, 0x51, 0x3c, 0x3c}} , {{0x92, 0xf8, 0xd6, 0x4b, 0xef, 0x42, 0x13, 0xb2, 0x4a, 0xc4, 0x2e, 0x72, 0x3f, 0xc9, 0x11, 0xbd, 0x74, 0x02, 0x0e, 0xf5, 0x13, 0x9d, 0x83, 0x1a, 0x1b, 0xd5, 0x54, 0xde, 0xc4, 0x1e, 0x16, 0x6c}}}, {{{0x27, 0x52, 0xe4, 0x63, 0xaa, 0x94, 0xe6, 0xc3, 0x28, 0x9c, 0xc6, 0x56, 0xac, 0xfa, 0xb6, 0xbd, 0xe2, 0xcc, 0x76, 0xc6, 0x27, 0x27, 0xa2, 0x8e, 0x78, 0x2b, 0x84, 0x72, 0x10, 0xbd, 0x4e, 0x2a}} , {{0xea, 0xa7, 0x23, 0xef, 0x04, 0x61, 0x80, 0x50, 0xc9, 0x6e, 0xa5, 0x96, 0xd1, 0xd1, 0xc8, 0xc3, 0x18, 0xd7, 0x2d, 0xfd, 0x26, 0xbd, 0xcb, 0x7b, 0x92, 0x51, 0x0e, 0x4a, 0x65, 0x57, 0xb8, 0x49}}}, {{{0xab, 0x55, 0x36, 0xc3, 0xec, 0x63, 0x55, 0x11, 0x55, 0xf6, 0xa5, 0xc7, 0x01, 0x5f, 0xfe, 0x79, 0xd8, 0x0a, 0xf7, 0x03, 0xd8, 0x98, 0x99, 0xf5, 0xd0, 0x00, 0x54, 0x6b, 0x66, 0x28, 0xf5, 0x25}} , {{0x7a, 0x8d, 0xa1, 0x5d, 0x70, 0x5d, 0x51, 0x27, 0xee, 0x30, 0x65, 0x56, 0x95, 0x46, 0xde, 0xbd, 0x03, 0x75, 0xb4, 0x57, 0x59, 0x89, 0xeb, 0x02, 0x9e, 0xcc, 0x89, 0x19, 0xa7, 0xcb, 0x17, 0x67}}}, {{{0x6a, 0xeb, 0xfc, 0x9a, 0x9a, 0x10, 0xce, 0xdb, 0x3a, 0x1c, 0x3c, 0x6a, 0x9d, 0xea, 0x46, 0xbc, 0x45, 0x49, 0xac, 0xe3, 0x41, 0x12, 0x7c, 0xf0, 0xf7, 0x4f, 0xf9, 0xf7, 0xff, 0x2c, 0x89, 0x04}} , {{0x30, 0x31, 0x54, 0x1a, 0x46, 0xca, 0xe6, 0xc6, 0xcb, 0xe2, 0xc3, 0xc1, 0x8b, 0x75, 0x81, 0xbe, 0xee, 0xf8, 0xa3, 0x11, 0x1c, 0x25, 0xa3, 0xa7, 0x35, 0x51, 0x55, 0xe2, 0x25, 0xaa, 0xe2, 0x3a}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xb4, 0x48, 0x10, 0x9f, 0x8a, 0x09, 0x76, 0xfa, 0xf0, 0x7a, 0xb0, 0x70, 0xf7, 0x83, 0x80, 0x52, 0x84, 0x2b, 0x26, 0xa2, 0xc4, 0x5d, 0x4f, 0xba, 0xb1, 0xc8, 0x40, 0x0d, 0x78, 0x97, 0xc4, 0x60}} , {{0xd4, 0xb1, 0x6c, 0x08, 0xc7, 0x40, 0x38, 0x73, 0x5f, 0x0b, 0xf3, 0x76, 0x5d, 0xb2, 0xa5, 0x2f, 0x57, 0x57, 0x07, 0xed, 0x08, 0xa2, 0x6c, 0x4f, 0x08, 0x02, 0xb5, 0x0e, 0xee, 0x44, 0xfa, 0x22}}}, {{{0x0f, 0x00, 0x3f, 0xa6, 0x04, 0x19, 0x56, 0x65, 0x31, 0x7f, 0x8b, 0xeb, 0x0d, 0xe1, 0x47, 0x89, 0x97, 0x16, 0x53, 0xfa, 0x81, 0xa7, 0xaa, 0xb2, 0xbf, 0x67, 0xeb, 0x72, 0x60, 0x81, 0x0d, 0x48}} , {{0x7e, 0x13, 0x33, 0xcd, 0xa8, 0x84, 0x56, 0x1e, 0x67, 0xaf, 0x6b, 0x43, 0xac, 0x17, 0xaf, 0x16, 0xc0, 0x52, 0x99, 0x49, 0x5b, 0x87, 0x73, 0x7e, 0xb5, 0x43, 0xda, 0x6b, 0x1d, 0x0f, 0x2d, 0x55}}}, {{{0xe9, 0x58, 0x1f, 0xff, 0x84, 0x3f, 0x93, 0x1c, 0xcb, 0xe1, 0x30, 0x69, 0xa5, 0x75, 0x19, 0x7e, 0x14, 0x5f, 0xf8, 0xfc, 0x09, 0xdd, 0xa8, 0x78, 0x9d, 0xca, 0x59, 0x8b, 0xd1, 0x30, 0x01, 0x13}} , {{0xff, 0x76, 0x03, 0xc5, 0x4b, 0x89, 0x99, 0x70, 0x00, 0x59, 0x70, 0x9c, 0xd5, 0xd9, 0x11, 0x89, 0x5a, 0x46, 0xfe, 0xef, 0xdc, 0xd9, 0x55, 0x2b, 0x45, 0xa7, 0xb0, 0x2d, 0xfb, 0x24, 0xc2, 0x29}}}, {{{0x38, 0x06, 0xf8, 0x0b, 0xac, 0x82, 0xc4, 0x97, 0x2b, 0x90, 0xe0, 0xf7, 0xa8, 0xab, 0x6c, 0x08, 0x80, 0x66, 0x90, 0x46, 0xf7, 0x26, 0x2d, 0xf8, 0xf1, 0xc4, 0x6b, 0x4a, 0x82, 0x98, 0x8e, 0x37}} , {{0x8e, 0xb4, 0xee, 0xb8, 0xd4, 0x3f, 0xb2, 0x1b, 0xe0, 0x0a, 0x3d, 0x75, 0x34, 0x28, 0xa2, 0x8e, 0xc4, 0x92, 0x7b, 0xfe, 0x60, 0x6e, 0x6d, 0xb8, 0x31, 0x1d, 0x62, 0x0d, 0x78, 0x14, 0x42, 0x11}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x5e, 0xa8, 0xd8, 0x04, 0x9b, 0x73, 0xc9, 0xc9, 0xdc, 0x0d, 0x73, 0xbf, 0x0a, 0x0a, 0x73, 0xff, 0x18, 0x1f, 0x9c, 0x51, 0xaa, 0xc6, 0xf1, 0x83, 0x25, 0xfd, 0xab, 0xa3, 0x11, 0xd3, 0x01, 0x24}} , {{0x4d, 0xe3, 0x7e, 0x38, 0x62, 0x5e, 0x64, 0xbb, 0x2b, 0x53, 0xb5, 0x03, 0x68, 0xc4, 0xf2, 0x2b, 0x5a, 0x03, 0x32, 0x99, 0x4a, 0x41, 0x9a, 0xe1, 0x1a, 0xae, 0x8c, 0x48, 0xf3, 0x24, 0x32, 0x65}}}, {{{0xe8, 0xdd, 0xad, 0x3a, 0x8c, 0xea, 0xf4, 0xb3, 0xb2, 0xe5, 0x73, 0xf2, 0xed, 0x8b, 0xbf, 0xed, 0xb1, 0x0c, 0x0c, 0xfb, 0x2b, 0xf1, 0x01, 0x48, 0xe8, 0x26, 0x03, 0x8e, 0x27, 0x4d, 0x96, 0x72}} , {{0xc8, 0x09, 0x3b, 0x60, 0xc9, 0x26, 0x4d, 0x7c, 0xf2, 0x9c, 0xd4, 0xa1, 0x3b, 0x26, 0xc2, 0x04, 0x33, 0x44, 0x76, 0x3c, 0x02, 0xbb, 0x11, 0x42, 0x0c, 0x22, 0xb7, 0xc6, 0xe1, 0xac, 0xb4, 0x0e}}}, {{{0x6f, 0x85, 0xe7, 0xef, 0xde, 0x67, 0x30, 0xfc, 0xbf, 0x5a, 0xe0, 0x7b, 0x7a, 0x2a, 0x54, 0x6b, 0x5d, 0x62, 0x85, 0xa1, 0xf8, 0x16, 0x88, 0xec, 0x61, 0xb9, 0x96, 0xb5, 0xef, 0x2d, 0x43, 0x4d}} , {{0x7c, 0x31, 0x33, 0xcc, 0xe4, 0xcf, 0x6c, 0xff, 0x80, 0x47, 0x77, 0xd1, 0xd8, 0xe9, 0x69, 0x97, 0x98, 0x7f, 0x20, 0x57, 0x1d, 0x1d, 0x4f, 0x08, 0x27, 0xc8, 0x35, 0x57, 0x40, 0xc6, 0x21, 0x0c}}}, {{{0xd2, 0x8e, 0x9b, 0xfa, 0x42, 0x8e, 0xdf, 0x8f, 0xc7, 0x86, 0xf9, 0xa4, 0xca, 0x70, 0x00, 0x9d, 0x21, 0xbf, 0xec, 0x57, 0x62, 0x30, 0x58, 0x8c, 0x0d, 0x35, 0xdb, 0x5d, 0x8b, 0x6a, 0xa0, 0x5a}} , {{0xc1, 0x58, 0x7c, 0x0d, 0x20, 0xdd, 0x11, 0x26, 0x5f, 0x89, 0x3b, 0x97, 0x58, 0xf8, 0x8b, 0xe3, 0xdf, 0x32, 0xe2, 0xfc, 0xd8, 0x67, 0xf2, 0xa5, 0x37, 0x1e, 0x6d, 0xec, 0x7c, 0x27, 0x20, 0x79}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xd0, 0xe9, 0xc0, 0xfa, 0x95, 0x45, 0x23, 0x96, 0xf1, 0x2c, 0x79, 0x25, 0x14, 0xce, 0x40, 0x14, 0x44, 0x2c, 0x36, 0x50, 0xd9, 0x63, 0x56, 0xb7, 0x56, 0x3b, 0x9e, 0xa7, 0xef, 0x89, 0xbb, 0x0e}} , {{0xce, 0x7f, 0xdc, 0x0a, 0xcc, 0x82, 0x1c, 0x0a, 0x78, 0x71, 0xe8, 0x74, 0x8d, 0x01, 0x30, 0x0f, 0xa7, 0x11, 0x4c, 0xdf, 0x38, 0xd7, 0xa7, 0x0d, 0xf8, 0x48, 0x52, 0x00, 0x80, 0x7b, 0x5f, 0x0e}}}, {{{0x25, 0x83, 0xe6, 0x94, 0x7b, 0x81, 0xb2, 0x91, 0xae, 0x0e, 0x05, 0xc9, 0xa3, 0x68, 0x2d, 0xd9, 0x88, 0x25, 0x19, 0x2a, 0x61, 0x61, 0x21, 0x97, 0x15, 0xa1, 0x35, 0xa5, 0x46, 0xc8, 0xa2, 0x0e}} , {{0x1b, 0x03, 0x0d, 0x8b, 0x5a, 0x1b, 0x97, 0x4b, 0xf2, 0x16, 0x31, 0x3d, 0x1f, 0x33, 0xa0, 0x50, 0x3a, 0x18, 0xbe, 0x13, 0xa1, 0x76, 0xc1, 0xba, 0x1b, 0xf1, 0x05, 0x7b, 0x33, 0xa8, 0x82, 0x3b}}}, {{{0xba, 0x36, 0x7b, 0x6d, 0xa9, 0xea, 0x14, 0x12, 0xc5, 0xfa, 0x91, 0x00, 0xba, 0x9b, 0x99, 0xcc, 0x56, 0x02, 0xe9, 0xa0, 0x26, 0x40, 0x66, 0x8c, 0xc4, 0xf8, 0x85, 0x33, 0x68, 0xe7, 0x03, 0x20}} , {{0x50, 0x5b, 0xff, 0xa9, 0xb2, 0xf1, 0xf1, 0x78, 0xcf, 0x14, 0xa4, 0xa9, 0xfc, 0x09, 0x46, 0x94, 0x54, 0x65, 0x0d, 0x9c, 0x5f, 0x72, 0x21, 0xe2, 0x97, 0xa5, 0x2d, 0x81, 0xce, 0x4a, 0x5f, 0x79}}}, {{{0x3d, 0x5f, 0x5c, 0xd2, 0xbc, 0x7d, 0x77, 0x0e, 0x2a, 0x6d, 0x22, 0x45, 0x84, 0x06, 0xc4, 0xdd, 0xc6, 0xa6, 0xc6, 0xd7, 0x49, 0xad, 0x6d, 0x87, 0x91, 0x0e, 0x3a, 0x67, 0x1d, 0x2c, 0x1d, 0x56}} , {{0xfe, 0x7a, 0x74, 0xcf, 0xd4, 0xd2, 0xe5, 0x19, 0xde, 0xd0, 0xdb, 0x70, 0x23, 0x69, 0xe6, 0x6d, 0xec, 0xec, 0xcc, 0x09, 0x33, 0x6a, 0x77, 0xdc, 0x6b, 0x22, 0x76, 0x5d, 0x92, 0x09, 0xac, 0x2d}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x23, 0x15, 0x17, 0xeb, 0xd3, 0xdb, 0x12, 0x5e, 0x01, 0xf0, 0x91, 0xab, 0x2c, 0x41, 0xce, 0xac, 0xed, 0x1b, 0x4b, 0x2d, 0xbc, 0xdb, 0x17, 0x66, 0x89, 0x46, 0xad, 0x4b, 0x1e, 0x6f, 0x0b, 0x14}} , {{0x11, 0xce, 0xbf, 0xb6, 0x77, 0x2d, 0x48, 0x22, 0x18, 0x4f, 0xa3, 0x5d, 0x4a, 0xb0, 0x70, 0x12, 0x3e, 0x54, 0xd7, 0xd8, 0x0e, 0x2b, 0x27, 0xdc, 0x53, 0xff, 0xca, 0x8c, 0x59, 0xb3, 0x4e, 0x44}}}, {{{0x07, 0x76, 0x61, 0x0f, 0x66, 0xb2, 0x21, 0x39, 0x7e, 0xc0, 0xec, 0x45, 0x28, 0x82, 0xa1, 0x29, 0x32, 0x44, 0x35, 0x13, 0x5e, 0x61, 0x5e, 0x54, 0xcb, 0x7c, 0xef, 0xf6, 0x41, 0xcf, 0x9f, 0x0a}} , {{0xdd, 0xf9, 0xda, 0x84, 0xc3, 0xe6, 0x8a, 0x9f, 0x24, 0xd2, 0x96, 0x5d, 0x39, 0x6f, 0x58, 0x8c, 0xc1, 0x56, 0x93, 0xab, 0xb5, 0x79, 0x3b, 0xd2, 0xa8, 0x73, 0x16, 0xed, 0xfa, 0xb4, 0x2f, 0x73}}}, {{{0x8b, 0xb1, 0x95, 0xe5, 0x92, 0x50, 0x35, 0x11, 0x76, 0xac, 0xf4, 0x4d, 0x24, 0xc3, 0x32, 0xe6, 0xeb, 0xfe, 0x2c, 0x87, 0xc4, 0xf1, 0x56, 0xc4, 0x75, 0x24, 0x7a, 0x56, 0x85, 0x5a, 0x3a, 0x13}} , {{0x0d, 0x16, 0xac, 0x3c, 0x4a, 0x58, 0x86, 0x3a, 0x46, 0x7f, 0x6c, 0xa3, 0x52, 0x6e, 0x37, 0xe4, 0x96, 0x9c, 0xe9, 0x5c, 0x66, 0x41, 0x67, 0xe4, 0xfb, 0x79, 0x0c, 0x05, 0xf6, 0x64, 0xd5, 0x7c}}}, {{{0x28, 0xc1, 0xe1, 0x54, 0x73, 0xf2, 0xbf, 0x76, 0x74, 0x19, 0x19, 0x1b, 0xe4, 0xb9, 0xa8, 0x46, 0x65, 0x73, 0xf3, 0x77, 0x9b, 0x29, 0x74, 0x5b, 0xc6, 0x89, 0x6c, 0x2c, 0x7c, 0xf8, 0xb3, 0x0f}} , {{0xf7, 0xd5, 0xe9, 0x74, 0x5d, 0xb8, 0x25, 0x16, 0xb5, 0x30, 0xbc, 0x84, 0xc5, 0xf0, 0xad, 0xca, 0x12, 0x28, 0xbc, 0x9d, 0xd4, 0xfa, 0x82, 0xe6, 0xe3, 0xbf, 0xa2, 0x15, 0x2c, 0xd4, 0x34, 0x10}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x61, 0xb1, 0x46, 0xba, 0x0e, 0x31, 0xa5, 0x67, 0x6c, 0x7f, 0xd6, 0xd9, 0x27, 0x85, 0x0f, 0x79, 0x14, 0xc8, 0x6c, 0x2f, 0x5f, 0x5b, 0x9c, 0x35, 0x3d, 0x38, 0x86, 0x77, 0x65, 0x55, 0x6a, 0x7b}} , {{0xd3, 0xb0, 0x3a, 0x66, 0x60, 0x1b, 0x43, 0xf1, 0x26, 0x58, 0x99, 0x09, 0x8f, 0x2d, 0xa3, 0x14, 0x71, 0x85, 0xdb, 0xed, 0xf6, 0x26, 0xd5, 0x61, 0x9a, 0x73, 0xac, 0x0e, 0xea, 0xac, 0xb7, 0x0c}}}, {{{0x5e, 0xf4, 0xe5, 0x17, 0x0e, 0x10, 0x9f, 0xe7, 0x43, 0x5f, 0x67, 0x5c, 0xac, 0x4b, 0xe5, 0x14, 0x41, 0xd2, 0xbf, 0x48, 0xf5, 0x14, 0xb0, 0x71, 0xc6, 0x61, 0xc1, 0xb2, 0x70, 0x58, 0xd2, 0x5a}} , {{0x2d, 0xba, 0x16, 0x07, 0x92, 0x94, 0xdc, 0xbd, 0x50, 0x2b, 0xc9, 0x7f, 0x42, 0x00, 0xba, 0x61, 0xed, 0xf8, 0x43, 0xed, 0xf5, 0xf9, 0x40, 0x60, 0xb2, 0xb0, 0x82, 0xcb, 0xed, 0x75, 0xc7, 0x65}}}, {{{0x80, 0xba, 0x0d, 0x09, 0x40, 0xa7, 0x39, 0xa6, 0x67, 0x34, 0x7e, 0x66, 0xbe, 0x56, 0xfb, 0x53, 0x78, 0xc4, 0x46, 0xe8, 0xed, 0x68, 0x6c, 0x7f, 0xce, 0xe8, 0x9f, 0xce, 0xa2, 0x64, 0x58, 0x53}} , {{0xe8, 0xc1, 0xa9, 0xc2, 0x7b, 0x59, 0x21, 0x33, 0xe2, 0x43, 0x73, 0x2b, 0xac, 0x2d, 0xc1, 0x89, 0x3b, 0x15, 0xe2, 0xd5, 0xc0, 0x97, 0x8a, 0xfd, 0x6f, 0x36, 0x33, 0xb7, 0xb9, 0xc3, 0x88, 0x09}}}, {{{0xd0, 0xb6, 0x56, 0x30, 0x5c, 0xae, 0xb3, 0x75, 0x44, 0xa4, 0x83, 0x51, 0x6e, 0x01, 0x65, 0xef, 0x45, 0x76, 0xe6, 0xf5, 0xa2, 0x0d, 0xd4, 0x16, 0x3b, 0x58, 0x2f, 0xf2, 0x2f, 0x36, 0x18, 0x3f}} , {{0xfd, 0x2f, 0xe0, 0x9b, 0x1e, 0x8c, 0xc5, 0x18, 0xa9, 0xca, 0xd4, 0x2b, 0x35, 0xb6, 0x95, 0x0a, 0x9f, 0x7e, 0xfb, 0xc4, 0xef, 0x88, 0x7b, 0x23, 0x43, 0xec, 0x2f, 0x0d, 0x0f, 0x7a, 0xfc, 0x5c}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x8d, 0xd2, 0xda, 0xc7, 0x44, 0xd6, 0x7a, 0xdb, 0x26, 0x7d, 0x1d, 0xb8, 0xe1, 0xde, 0x9d, 0x7a, 0x7d, 0x17, 0x7e, 0x1c, 0x37, 0x04, 0x8d, 0x2d, 0x7c, 0x5e, 0x18, 0x38, 0x1e, 0xaf, 0xc7, 0x1b}} , {{0x33, 0x48, 0x31, 0x00, 0x59, 0xf6, 0xf2, 0xca, 0x0f, 0x27, 0x1b, 0x63, 0x12, 0x7e, 0x02, 0x1d, 0x49, 0xc0, 0x5d, 0x79, 0x87, 0xef, 0x5e, 0x7a, 0x2f, 0x1f, 0x66, 0x55, 0xd8, 0x09, 0xd9, 0x61}}}, {{{0x54, 0x83, 0x02, 0x18, 0x82, 0x93, 0x99, 0x07, 0xd0, 0xa7, 0xda, 0xd8, 0x75, 0x89, 0xfa, 0xf2, 0xd9, 0xa3, 0xb8, 0x6b, 0x5a, 0x35, 0x28, 0xd2, 0x6b, 0x59, 0xc2, 0xf8, 0x45, 0xe2, 0xbc, 0x06}} , {{0x65, 0xc0, 0xa3, 0x88, 0x51, 0x95, 0xfc, 0x96, 0x94, 0x78, 0xe8, 0x0d, 0x8b, 0x41, 0xc9, 0xc2, 0x58, 0x48, 0x75, 0x10, 0x2f, 0xcd, 0x2a, 0xc9, 0xa0, 0x6d, 0x0f, 0xdd, 0x9c, 0x98, 0x26, 0x3d}}}, {{{0x2f, 0x66, 0x29, 0x1b, 0x04, 0x89, 0xbd, 0x7e, 0xee, 0x6e, 0xdd, 0xb7, 0x0e, 0xef, 0xb0, 0x0c, 0xb4, 0xfc, 0x7f, 0xc2, 0xc9, 0x3a, 0x3c, 0x64, 0xef, 0x45, 0x44, 0xaf, 0x8a, 0x90, 0x65, 0x76}} , {{0xa1, 0x4c, 0x70, 0x4b, 0x0e, 0xa0, 0x83, 0x70, 0x13, 0xa4, 0xaf, 0xb8, 0x38, 0x19, 0x22, 0x65, 0x09, 0xb4, 0x02, 0x4f, 0x06, 0xf8, 0x17, 0xce, 0x46, 0x45, 0xda, 0x50, 0x7c, 0x8a, 0xd1, 0x4e}}}, {{{0xf7, 0xd4, 0x16, 0x6c, 0x4e, 0x95, 0x9d, 0x5d, 0x0f, 0x91, 0x2b, 0x52, 0xfe, 0x5c, 0x34, 0xe5, 0x30, 0xe6, 0xa4, 0x3b, 0xf3, 0xf3, 0x34, 0x08, 0xa9, 0x4a, 0xa0, 0xb5, 0x6e, 0xb3, 0x09, 0x0a}} , {{0x26, 0xd9, 0x5e, 0xa3, 0x0f, 0xeb, 0xa2, 0xf3, 0x20, 0x3b, 0x37, 0xd4, 0xe4, 0x9e, 0xce, 0x06, 0x3d, 0x53, 0xed, 0xae, 0x2b, 0xeb, 0xb6, 0x24, 0x0a, 0x11, 0xa3, 0x0f, 0xd6, 0x7f, 0xa4, 0x3a}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xdb, 0x9f, 0x2c, 0xfc, 0xd6, 0xb2, 0x1e, 0x2e, 0x52, 0x7a, 0x06, 0x87, 0x2d, 0x86, 0x72, 0x2b, 0x6d, 0x90, 0x77, 0x46, 0x43, 0xb5, 0x7a, 0xf8, 0x60, 0x7d, 0x91, 0x60, 0x5b, 0x9d, 0x9e, 0x07}} , {{0x97, 0x87, 0xc7, 0x04, 0x1c, 0x38, 0x01, 0x39, 0x58, 0xc7, 0x85, 0xa3, 0xfc, 0x64, 0x00, 0x64, 0x25, 0xa2, 0xbf, 0x50, 0x94, 0xca, 0x26, 0x31, 0x45, 0x0a, 0x24, 0xd2, 0x51, 0x29, 0x51, 0x16}}}, {{{0x4d, 0x4a, 0xd7, 0x98, 0x71, 0x57, 0xac, 0x7d, 0x8b, 0x37, 0xbd, 0x63, 0xff, 0x87, 0xb1, 0x49, 0x95, 0x20, 0x7c, 0xcf, 0x7c, 0x59, 0xc4, 0x91, 0x9c, 0xef, 0xd0, 0xdb, 0x60, 0x09, 0x9d, 0x46}} , {{0xcb, 0x78, 0x94, 0x90, 0xe4, 0x45, 0xb3, 0xf6, 0xd9, 0xf6, 0x57, 0x74, 0xd5, 0xf8, 0x83, 0x4f, 0x39, 0xc9, 0xbd, 0x88, 0xc2, 0x57, 0x21, 0x1f, 0x24, 0x32, 0x68, 0xf8, 0xc7, 0x21, 0x5f, 0x0b}}}, {{{0x2a, 0x36, 0x68, 0xfc, 0x5f, 0xb6, 0x4f, 0xa5, 0xe3, 0x9d, 0x24, 0x2f, 0xc0, 0x93, 0x61, 0xcf, 0xf8, 0x0a, 0xed, 0xe1, 0xdb, 0x27, 0xec, 0x0e, 0x14, 0x32, 0x5f, 0x8e, 0xa1, 0x62, 0x41, 0x16}} , {{0x95, 0x21, 0x01, 0xce, 0x95, 0x5b, 0x0e, 0x57, 0xc7, 0xb9, 0x62, 0xb5, 0x28, 0xca, 0x11, 0xec, 0xb4, 0x46, 0x06, 0x73, 0x26, 0xff, 0xfb, 0x66, 0x7d, 0xee, 0x5f, 0xb2, 0x56, 0xfd, 0x2a, 0x08}}}, {{{0x92, 0x67, 0x77, 0x56, 0xa1, 0xff, 0xc4, 0xc5, 0x95, 0xf0, 0xe3, 0x3a, 0x0a, 0xca, 0x94, 0x4d, 0x9e, 0x7e, 0x3d, 0xb9, 0x6e, 0xb6, 0xb0, 0xce, 0xa4, 0x30, 0x89, 0x99, 0xe9, 0xad, 0x11, 0x59}} , {{0xf6, 0x48, 0x95, 0xa1, 0x6f, 0x5f, 0xb7, 0xa5, 0xbb, 0x30, 0x00, 0x1c, 0xd2, 0x8a, 0xd6, 0x25, 0x26, 0x1b, 0xb2, 0x0d, 0x37, 0x6a, 0x05, 0xf4, 0x9d, 0x3e, 0x17, 0x2a, 0x43, 0xd2, 0x3a, 0x06}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x32, 0x99, 0x93, 0xd1, 0x9a, 0x72, 0xf3, 0xa9, 0x16, 0xbd, 0xb4, 0x4c, 0xdd, 0xf9, 0xd4, 0xb2, 0x64, 0x9a, 0xd3, 0x05, 0xe4, 0xa3, 0x73, 0x1c, 0xcb, 0x7e, 0x57, 0x67, 0xff, 0x04, 0xb3, 0x10}} , {{0xb9, 0x4b, 0xa4, 0xad, 0xd0, 0x6d, 0x61, 0x23, 0xb4, 0xaf, 0x34, 0xa9, 0xaa, 0x65, 0xec, 0xd9, 0x69, 0xe3, 0x85, 0xcd, 0xcc, 0xe7, 0xb0, 0x9b, 0x41, 0xc1, 0x1c, 0xf9, 0xa0, 0xfa, 0xb7, 0x13}}}, {{{0x04, 0xfd, 0x88, 0x3c, 0x0c, 0xd0, 0x09, 0x52, 0x51, 0x4f, 0x06, 0x19, 0xcc, 0xc3, 0xbb, 0xde, 0x80, 0xc5, 0x33, 0xbc, 0xf9, 0xf3, 0x17, 0x36, 0xdd, 0xc6, 0xde, 0xe8, 0x9b, 0x5d, 0x79, 0x1b}} , {{0x65, 0x0a, 0xbe, 0x51, 0x57, 0xad, 0x50, 0x79, 0x08, 0x71, 0x9b, 0x07, 0x95, 0x8f, 0xfb, 0xae, 0x4b, 0x38, 0xba, 0xcf, 0x53, 0x2a, 0x86, 0x1e, 0xc0, 0x50, 0x5c, 0x67, 0x1b, 0xf6, 0x87, 0x6c}}}, {{{0x4f, 0x00, 0xb2, 0x66, 0x55, 0xed, 0x4a, 0xed, 0x8d, 0xe1, 0x66, 0x18, 0xb2, 0x14, 0x74, 0x8d, 0xfd, 0x1a, 0x36, 0x0f, 0x26, 0x5c, 0x8b, 0x89, 0xf3, 0xab, 0xf2, 0xf3, 0x24, 0x67, 0xfd, 0x70}} , {{0xfd, 0x4e, 0x2a, 0xc1, 0x3a, 0xca, 0x8f, 0x00, 0xd8, 0xec, 0x74, 0x67, 0xef, 0x61, 0xe0, 0x28, 0xd0, 0x96, 0xf4, 0x48, 0xde, 0x81, 0xe3, 0xef, 0xdc, 0xaa, 0x7d, 0xf3, 0xb6, 0x55, 0xa6, 0x65}}}, {{{0xeb, 0xcb, 0xc5, 0x70, 0x91, 0x31, 0x10, 0x93, 0x0d, 0xc8, 0xd0, 0xef, 0x62, 0xe8, 0x6f, 0x82, 0xe3, 0x69, 0x3d, 0x91, 0x7f, 0x31, 0xe1, 0x26, 0x35, 0x3c, 0x4a, 0x2f, 0xab, 0xc4, 0x9a, 0x5e}} , {{0xab, 0x1b, 0xb5, 0xe5, 0x2b, 0xc3, 0x0e, 0x29, 0xb0, 0xd0, 0x73, 0xe6, 0x4f, 0x64, 0xf2, 0xbc, 0xe4, 0xe4, 0xe1, 0x9a, 0x52, 0x33, 0x2f, 0xbd, 0xcc, 0x03, 0xee, 0x8a, 0xfa, 0x00, 0x5f, 0x50}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xf6, 0xdb, 0x0d, 0x22, 0x3d, 0xb5, 0x14, 0x75, 0x31, 0xf0, 0x81, 0xe2, 0xb9, 0x37, 0xa2, 0xa9, 0x84, 0x11, 0x9a, 0x07, 0xb5, 0x53, 0x89, 0x78, 0xa9, 0x30, 0x27, 0xa1, 0xf1, 0x4e, 0x5c, 0x2e}} , {{0x8b, 0x00, 0x54, 0xfb, 0x4d, 0xdc, 0xcb, 0x17, 0x35, 0x40, 0xff, 0xb7, 0x8c, 0xfe, 0x4a, 0xe4, 0x4e, 0x99, 0x4e, 0xa8, 0x74, 0x54, 0x5d, 0x5c, 0x96, 0xa3, 0x12, 0x55, 0x36, 0x31, 0x17, 0x5c}}}, {{{0xce, 0x24, 0xef, 0x7b, 0x86, 0xf2, 0x0f, 0x77, 0xe8, 0x5c, 0x7d, 0x87, 0x38, 0x2d, 0xef, 0xaf, 0xf2, 0x8c, 0x72, 0x2e, 0xeb, 0xb6, 0x55, 0x4b, 0x6e, 0xf1, 0x4e, 0x8a, 0x0e, 0x9a, 0x6c, 0x4c}} , {{0x25, 0xea, 0x86, 0xc2, 0xd1, 0x4f, 0xb7, 0x3e, 0xa8, 0x5c, 0x8d, 0x66, 0x81, 0x25, 0xed, 0xc5, 0x4c, 0x05, 0xb9, 0xd8, 0xd6, 0x70, 0xbe, 0x73, 0x82, 0xe8, 0xa1, 0xe5, 0x1e, 0x71, 0xd5, 0x26}}}, {{{0x4e, 0x6d, 0xc3, 0xa7, 0x4f, 0x22, 0x45, 0x26, 0xa2, 0x7e, 0x16, 0xf7, 0xf7, 0x63, 0xdc, 0x86, 0x01, 0x2a, 0x71, 0x38, 0x5c, 0x33, 0xc3, 0xce, 0x30, 0xff, 0xf9, 0x2c, 0x91, 0x71, 0x8a, 0x72}} , {{0x8c, 0x44, 0x09, 0x28, 0xd5, 0x23, 0xc9, 0x8f, 0xf3, 0x84, 0x45, 0xc6, 0x9a, 0x5e, 0xff, 0xd2, 0xc7, 0x57, 0x93, 0xa3, 0xc1, 0x69, 0xdd, 0x62, 0x0f, 0xda, 0x5c, 0x30, 0x59, 0x5d, 0xe9, 0x4c}}}, {{{0x92, 0x7e, 0x50, 0x27, 0x72, 0xd7, 0x0c, 0xd6, 0x69, 0x96, 0x81, 0x35, 0x84, 0x94, 0x35, 0x8b, 0x6c, 0xaa, 0x62, 0x86, 0x6e, 0x1c, 0x15, 0xf3, 0x6c, 0xb3, 0xff, 0x65, 0x1b, 0xa2, 0x9b, 0x59}} , {{0xe2, 0xa9, 0x65, 0x88, 0xc4, 0x50, 0xfa, 0xbb, 0x3b, 0x6e, 0x5f, 0x44, 0x01, 0xca, 0x97, 0xd4, 0xdd, 0xf6, 0xcd, 0x3f, 0x3f, 0xe5, 0x97, 0x67, 0x2b, 0x8c, 0x66, 0x0f, 0x35, 0x9b, 0xf5, 0x07}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xf1, 0x59, 0x27, 0xd8, 0xdb, 0x5a, 0x11, 0x5e, 0x82, 0xf3, 0x38, 0xff, 0x1c, 0xed, 0xfe, 0x3f, 0x64, 0x54, 0x3f, 0x7f, 0xd1, 0x81, 0xed, 0xef, 0x65, 0xc5, 0xcb, 0xfd, 0xe1, 0x80, 0xcd, 0x11}} , {{0xe0, 0xdb, 0x22, 0x28, 0xe6, 0xff, 0x61, 0x9d, 0x41, 0x14, 0x2d, 0x3b, 0x26, 0x22, 0xdf, 0xf1, 0x34, 0x81, 0xe9, 0x45, 0xee, 0x0f, 0x98, 0x8b, 0xa6, 0x3f, 0xef, 0xf7, 0x43, 0x19, 0xf1, 0x43}}}, {{{0xee, 0xf3, 0x00, 0xa1, 0x50, 0xde, 0xc0, 0xb6, 0x01, 0xe3, 0x8c, 0x3c, 0x4d, 0x31, 0xd2, 0xb0, 0x58, 0xcd, 0xed, 0x10, 0x4a, 0x7a, 0xef, 0x80, 0xa9, 0x19, 0x32, 0xf3, 0xd8, 0x33, 0x8c, 0x06}} , {{0xcb, 0x7d, 0x4f, 0xff, 0x30, 0xd8, 0x12, 0x3b, 0x39, 0x1c, 0x06, 0xf9, 0x4c, 0x34, 0x35, 0x71, 0xb5, 0x16, 0x94, 0x67, 0xdf, 0xee, 0x11, 0xde, 0xa4, 0x1d, 0x88, 0x93, 0x35, 0xa9, 0x32, 0x10}}}, {{{0xe9, 0xc3, 0xbc, 0x7b, 0x5c, 0xfc, 0xb2, 0xf9, 0xc9, 0x2f, 0xe5, 0xba, 0x3a, 0x0b, 0xab, 0x64, 0x38, 0x6f, 0x5b, 0x4b, 0x93, 0xda, 0x64, 0xec, 0x4d, 0x3d, 0xa0, 0xf5, 0xbb, 0xba, 0x47, 0x48}} , {{0x60, 0xbc, 0x45, 0x1f, 0x23, 0xa2, 0x3b, 0x70, 0x76, 0xe6, 0x97, 0x99, 0x4f, 0x77, 0x54, 0x67, 0x30, 0x9a, 0xe7, 0x66, 0xd6, 0xcd, 0x2e, 0x51, 0x24, 0x2c, 0x42, 0x4a, 0x11, 0xfe, 0x6f, 0x7e}}}, {{{0x87, 0xc0, 0xb1, 0xf0, 0xa3, 0x6f, 0x0c, 0x93, 0xa9, 0x0a, 0x72, 0xef, 0x5c, 0xbe, 0x65, 0x35, 0xa7, 0x6a, 0x4e, 0x2c, 0xbf, 0x21, 0x23, 0xe8, 0x2f, 0x97, 0xc7, 0x3e, 0xc8, 0x17, 0xac, 0x1e}} , {{0x7b, 0xef, 0x21, 0xe5, 0x40, 0xcc, 0x1e, 0xdc, 0xd6, 0xbd, 0x97, 0x7a, 0x7c, 0x75, 0x86, 0x7a, 0x25, 0x5a, 0x6e, 0x7c, 0xe5, 0x51, 0x3c, 0x1b, 0x5b, 0x82, 0x9a, 0x07, 0x60, 0xa1, 0x19, 0x04}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x96, 0x88, 0xa6, 0xab, 0x8f, 0xe3, 0x3a, 0x49, 0xf8, 0xfe, 0x34, 0xe7, 0x6a, 0xb2, 0xfe, 0x40, 0x26, 0x74, 0x57, 0x4c, 0xf6, 0xd4, 0x99, 0xce, 0x5d, 0x7b, 0x2f, 0x67, 0xd6, 0x5a, 0xe4, 0x4e}} , {{0x5c, 0x82, 0xb3, 0xbd, 0x55, 0x25, 0xf6, 0x6a, 0x93, 0xa4, 0x02, 0xc6, 0x7d, 0x5c, 0xb1, 0x2b, 0x5b, 0xff, 0xfb, 0x56, 0xf8, 0x01, 0x41, 0x90, 0xc6, 0xb6, 0xac, 0x4f, 0xfe, 0xa7, 0x41, 0x70}}}, {{{0xdb, 0xfa, 0x9b, 0x2c, 0xd4, 0x23, 0x67, 0x2c, 0x8a, 0x63, 0x6c, 0x07, 0x26, 0x48, 0x4f, 0xc2, 0x03, 0xd2, 0x53, 0x20, 0x28, 0xed, 0x65, 0x71, 0x47, 0xa9, 0x16, 0x16, 0x12, 0xbc, 0x28, 0x33}} , {{0x39, 0xc0, 0xfa, 0xfa, 0xcd, 0x33, 0x43, 0xc7, 0x97, 0x76, 0x9b, 0x93, 0x91, 0x72, 0xeb, 0xc5, 0x18, 0x67, 0x4c, 0x11, 0xf0, 0xf4, 0xe5, 0x73, 0xb2, 0x5c, 0x1b, 0xc2, 0x26, 0x3f, 0xbf, 0x2b}}}, {{{0x86, 0xe6, 0x8c, 0x1d, 0xdf, 0xca, 0xfc, 0xd5, 0xf8, 0x3a, 0xc3, 0x44, 0x72, 0xe6, 0x78, 0x9d, 0x2b, 0x97, 0xf8, 0x28, 0x45, 0xb4, 0x20, 0xc9, 0x2a, 0x8c, 0x67, 0xaa, 0x11, 0xc5, 0x5b, 0x2f}} , {{0x17, 0x0f, 0x86, 0x52, 0xd7, 0x9d, 0xc3, 0x44, 0x51, 0x76, 0x32, 0x65, 0xb4, 0x37, 0x81, 0x99, 0x46, 0x37, 0x62, 0xed, 0xcf, 0x64, 0x9d, 0x72, 0x40, 0x7a, 0x4c, 0x0b, 0x76, 0x2a, 0xfb, 0x56}}}, {{{0x33, 0xa7, 0x90, 0x7c, 0xc3, 0x6f, 0x17, 0xa5, 0xa0, 0x67, 0x72, 0x17, 0xea, 0x7e, 0x63, 0x14, 0x83, 0xde, 0xc1, 0x71, 0x2d, 0x41, 0x32, 0x7a, 0xf3, 0xd1, 0x2b, 0xd8, 0x2a, 0xa6, 0x46, 0x36}} , {{0xac, 0xcc, 0x6b, 0x7c, 0xf9, 0xb8, 0x8b, 0x08, 0x5c, 0xd0, 0x7d, 0x8f, 0x73, 0xea, 0x20, 0xda, 0x86, 0xca, 0x00, 0xc7, 0xad, 0x73, 0x4d, 0xe9, 0xe8, 0xa9, 0xda, 0x1f, 0x03, 0x06, 0xdd, 0x24}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x9c, 0xb2, 0x61, 0x0a, 0x98, 0x2a, 0xa5, 0xd7, 0xee, 0xa9, 0xac, 0x65, 0xcb, 0x0a, 0x1e, 0xe2, 0xbe, 0xdc, 0x85, 0x59, 0x0f, 0x9c, 0xa6, 0x57, 0x34, 0xa5, 0x87, 0xeb, 0x7b, 0x1e, 0x0c, 0x3c}} , {{0x2f, 0xbd, 0x84, 0x63, 0x0d, 0xb5, 0xa0, 0xf0, 0x4b, 0x9e, 0x93, 0xc6, 0x34, 0x9a, 0x34, 0xff, 0x73, 0x19, 0x2f, 0x6e, 0x54, 0x45, 0x2c, 0x92, 0x31, 0x76, 0x34, 0xf1, 0xb2, 0x26, 0xe8, 0x74}}}, {{{0x0a, 0x67, 0x90, 0x6d, 0x0c, 0x4c, 0xcc, 0xc0, 0xe6, 0xbd, 0xa7, 0x5e, 0x55, 0x8c, 0xcd, 0x58, 0x9b, 0x11, 0xa2, 0xbb, 0x4b, 0xb1, 0x43, 0x04, 0x3c, 0x55, 0xed, 0x23, 0xfe, 0xcd, 0xb1, 0x53}} , {{0x05, 0xfb, 0x75, 0xf5, 0x01, 0xaf, 0x38, 0x72, 0x58, 0xfc, 0x04, 0x29, 0x34, 0x7a, 0x67, 0xa2, 0x08, 0x50, 0x6e, 0xd0, 0x2b, 0x73, 0xd5, 0xb8, 0xe4, 0x30, 0x96, 0xad, 0x45, 0xdf, 0xa6, 0x5c}}}, {{{0x0d, 0x88, 0x1a, 0x90, 0x7e, 0xdc, 0xd8, 0xfe, 0xc1, 0x2f, 0x5d, 0x67, 0xee, 0x67, 0x2f, 0xed, 0x6f, 0x55, 0x43, 0x5f, 0x87, 0x14, 0x35, 0x42, 0xd3, 0x75, 0xae, 0xd5, 0xd3, 0x85, 0x1a, 0x76}} , {{0x87, 0xc8, 0xa0, 0x6e, 0xe1, 0xb0, 0xad, 0x6a, 0x4a, 0x34, 0x71, 0xed, 0x7c, 0xd6, 0x44, 0x03, 0x65, 0x4a, 0x5c, 0x5c, 0x04, 0xf5, 0x24, 0x3f, 0xb0, 0x16, 0x5e, 0x8c, 0xb2, 0xd2, 0xc5, 0x20}}}, {{{0x98, 0x83, 0xc2, 0x37, 0xa0, 0x41, 0xa8, 0x48, 0x5c, 0x5f, 0xbf, 0xc8, 0xfa, 0x24, 0xe0, 0x59, 0x2c, 0xbd, 0xf6, 0x81, 0x7e, 0x88, 0xe6, 0xca, 0x04, 0xd8, 0x5d, 0x60, 0xbb, 0x74, 0xa7, 0x0b}} , {{0x21, 0x13, 0x91, 0xbf, 0x77, 0x7a, 0x33, 0xbc, 0xe9, 0x07, 0x39, 0x0a, 0xdd, 0x7d, 0x06, 0x10, 0x9a, 0xee, 0x47, 0x73, 0x1b, 0x15, 0x5a, 0xfb, 0xcd, 0x4d, 0xd0, 0xd2, 0x3a, 0x01, 0xba, 0x54}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x48, 0xd5, 0x39, 0x4a, 0x0b, 0x20, 0x6a, 0x43, 0xa0, 0x07, 0x82, 0x5e, 0x49, 0x7c, 0xc9, 0x47, 0xf1, 0x7c, 0x37, 0xb9, 0x23, 0xef, 0x6b, 0x46, 0x45, 0x8c, 0x45, 0x76, 0xdf, 0x14, 0x6b, 0x6e}} , {{0x42, 0xc9, 0xca, 0x29, 0x4c, 0x76, 0x37, 0xda, 0x8a, 0x2d, 0x7c, 0x3a, 0x58, 0xf2, 0x03, 0xb4, 0xb5, 0xb9, 0x1a, 0x13, 0x2d, 0xde, 0x5f, 0x6b, 0x9d, 0xba, 0x52, 0xc9, 0x5d, 0xb3, 0xf3, 0x30}}}, {{{0x4c, 0x6f, 0xfe, 0x6b, 0x0c, 0x62, 0xd7, 0x48, 0x71, 0xef, 0xb1, 0x85, 0x79, 0xc0, 0xed, 0x24, 0xb1, 0x08, 0x93, 0x76, 0x8e, 0xf7, 0x38, 0x8e, 0xeb, 0xfe, 0x80, 0x40, 0xaf, 0x90, 0x64, 0x49}} , {{0x4a, 0x88, 0xda, 0xc1, 0x98, 0x44, 0x3c, 0x53, 0x4e, 0xdb, 0x4b, 0xb9, 0x12, 0x5f, 0xcd, 0x08, 0x04, 0xef, 0x75, 0xe7, 0xb1, 0x3a, 0xe5, 0x07, 0xfa, 0xca, 0x65, 0x7b, 0x72, 0x10, 0x64, 0x7f}}}, {{{0x3d, 0x81, 0xf0, 0xeb, 0x16, 0xfd, 0x58, 0x33, 0x8d, 0x7c, 0x1a, 0xfb, 0x20, 0x2c, 0x8a, 0xee, 0x90, 0xbb, 0x33, 0x6d, 0x45, 0xe9, 0x8e, 0x99, 0x85, 0xe1, 0x08, 0x1f, 0xc5, 0xf1, 0xb5, 0x46}} , {{0xe4, 0xe7, 0x43, 0x4b, 0xa0, 0x3f, 0x2b, 0x06, 0xba, 0x17, 0xae, 0x3d, 0xe6, 0xce, 0xbd, 0xb8, 0xed, 0x74, 0x11, 0x35, 0xec, 0x96, 0xfe, 0x31, 0xe3, 0x0e, 0x7a, 0x4e, 0xc9, 0x1d, 0xcb, 0x20}}}, {{{0xe0, 0x67, 0xe9, 0x7b, 0xdb, 0x96, 0x5c, 0xb0, 0x32, 0xd0, 0x59, 0x31, 0x90, 0xdc, 0x92, 0x97, 0xac, 0x09, 0x38, 0x31, 0x0f, 0x7e, 0xd6, 0x5d, 0xd0, 0x06, 0xb6, 0x1f, 0xea, 0xf0, 0x5b, 0x07}} , {{0x81, 0x9f, 0xc7, 0xde, 0x6b, 0x41, 0x22, 0x35, 0x14, 0x67, 0x77, 0x3e, 0x90, 0x81, 0xb0, 0xd9, 0x85, 0x4c, 0xca, 0x9b, 0x3f, 0x04, 0x59, 0xd6, 0xaa, 0x17, 0xc3, 0x88, 0x34, 0x37, 0xba, 0x43}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x4c, 0xb6, 0x69, 0xc8, 0x81, 0x95, 0x94, 0x33, 0x92, 0x34, 0xe9, 0x3c, 0x84, 0x0d, 0x3d, 0x5a, 0x37, 0x9c, 0x22, 0xa0, 0xaa, 0x65, 0xce, 0xb4, 0xc2, 0x2d, 0x66, 0x67, 0x02, 0xff, 0x74, 0x10}} , {{0x22, 0xb0, 0xd5, 0xe6, 0xc7, 0xef, 0xb1, 0xa7, 0x13, 0xda, 0x60, 0xb4, 0x80, 0xc1, 0x42, 0x7d, 0x10, 0x70, 0x97, 0x04, 0x4d, 0xda, 0x23, 0x89, 0xc2, 0x0e, 0x68, 0xcb, 0xde, 0xe0, 0x9b, 0x29}}}, {{{0x33, 0xfe, 0x42, 0x2a, 0x36, 0x2b, 0x2e, 0x36, 0x64, 0x5c, 0x8b, 0xcc, 0x81, 0x6a, 0x15, 0x08, 0xa1, 0x27, 0xe8, 0x57, 0xe5, 0x78, 0x8e, 0xf2, 0x58, 0x19, 0x12, 0x42, 0xae, 0xc4, 0x63, 0x3e}} , {{0x78, 0x96, 0x9c, 0xa7, 0xca, 0x80, 0xae, 0x02, 0x85, 0xb1, 0x7c, 0x04, 0x5c, 0xc1, 0x5b, 0x26, 0xc1, 0xba, 0xed, 0xa5, 0x59, 0x70, 0x85, 0x8c, 0x8c, 0xe8, 0x87, 0xac, 0x6a, 0x28, 0x99, 0x35}}}, {{{0x9f, 0x04, 0x08, 0x28, 0xbe, 0x87, 0xda, 0x80, 0x28, 0x38, 0xde, 0x9f, 0xcd, 0xe4, 0xe3, 0x62, 0xfb, 0x2e, 0x46, 0x8d, 0x01, 0xb3, 0x06, 0x51, 0xd4, 0x19, 0x3b, 0x11, 0xfa, 0xe2, 0xad, 0x1e}} , {{0xa0, 0x20, 0x99, 0x69, 0x0a, 0xae, 0xa3, 0x70, 0x4e, 0x64, 0x80, 0xb7, 0x85, 0x9c, 0x87, 0x54, 0x43, 0x43, 0x55, 0x80, 0x6d, 0x8d, 0x7c, 0xa9, 0x64, 0xca, 0x6c, 0x2e, 0x21, 0xd8, 0xc8, 0x6c}}}, {{{0x91, 0x4a, 0x07, 0xad, 0x08, 0x75, 0xc1, 0x4f, 0xa4, 0xb2, 0xc3, 0x6f, 0x46, 0x3e, 0xb1, 0xce, 0x52, 0xab, 0x67, 0x09, 0x54, 0x48, 0x6b, 0x6c, 0xd7, 0x1d, 0x71, 0x76, 0xcb, 0xff, 0xdd, 0x31}} , {{0x36, 0x88, 0xfa, 0xfd, 0xf0, 0x36, 0x6f, 0x07, 0x74, 0x88, 0x50, 0xd0, 0x95, 0x38, 0x4a, 0x48, 0x2e, 0x07, 0x64, 0x97, 0x11, 0x76, 0x01, 0x1a, 0x27, 0x4d, 0x8e, 0x25, 0x9a, 0x9b, 0x1c, 0x22}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xbe, 0x57, 0xbd, 0x0e, 0x0f, 0xac, 0x5e, 0x76, 0xa3, 0x71, 0xad, 0x2b, 0x10, 0x45, 0x02, 0xec, 0x59, 0xd5, 0x5d, 0xa9, 0x44, 0xcc, 0x25, 0x4c, 0xb3, 0x3c, 0x5b, 0x69, 0x07, 0x55, 0x26, 0x6b}} , {{0x30, 0x6b, 0xd4, 0xa7, 0x51, 0x29, 0xe3, 0xf9, 0x7a, 0x75, 0x2a, 0x82, 0x2f, 0xd6, 0x1d, 0x99, 0x2b, 0x80, 0xd5, 0x67, 0x1e, 0x15, 0x9d, 0xca, 0xfd, 0xeb, 0xac, 0x97, 0x35, 0x09, 0x7f, 0x3f}}}, {{{0x35, 0x0d, 0x34, 0x0a, 0xb8, 0x67, 0x56, 0x29, 0x20, 0xf3, 0x19, 0x5f, 0xe2, 0x83, 0x42, 0x73, 0x53, 0xa8, 0xc5, 0x02, 0x19, 0x33, 0xb4, 0x64, 0xbd, 0xc3, 0x87, 0x8c, 0xd7, 0x76, 0xed, 0x25}} , {{0x47, 0x39, 0x37, 0x76, 0x0d, 0x1d, 0x0c, 0xf5, 0x5a, 0x6d, 0x43, 0x88, 0x99, 0x15, 0xb4, 0x52, 0x0f, 0x2a, 0xb3, 0xb0, 0x3f, 0xa6, 0xb3, 0x26, 0xb3, 0xc7, 0x45, 0xf5, 0x92, 0x5f, 0x9b, 0x17}}}, {{{0x9d, 0x23, 0xbd, 0x15, 0xfe, 0x52, 0x52, 0x15, 0x26, 0x79, 0x86, 0xba, 0x06, 0x56, 0x66, 0xbb, 0x8c, 0x2e, 0x10, 0x11, 0xd5, 0x4a, 0x18, 0x52, 0xda, 0x84, 0x44, 0xf0, 0x3e, 0xe9, 0x8c, 0x35}} , {{0xad, 0xa0, 0x41, 0xec, 0xc8, 0x4d, 0xb9, 0xd2, 0x6e, 0x96, 0x4e, 0x5b, 0xc5, 0xc2, 0xa0, 0x1b, 0xcf, 0x0c, 0xbf, 0x17, 0x66, 0x57, 0xc1, 0x17, 0x90, 0x45, 0x71, 0xc2, 0xe1, 0x24, 0xeb, 0x27}}}, {{{0x2c, 0xb9, 0x42, 0xa4, 0xaf, 0x3b, 0x42, 0x0e, 0xc2, 0x0f, 0xf2, 0xea, 0x83, 0xaf, 0x9a, 0x13, 0x17, 0xb0, 0xbd, 0x89, 0x17, 0xe3, 0x72, 0xcb, 0x0e, 0x76, 0x7e, 0x41, 0x63, 0x04, 0x88, 0x71}} , {{0x75, 0x78, 0x38, 0x86, 0x57, 0xdd, 0x9f, 0xee, 0x54, 0x70, 0x65, 0xbf, 0xf1, 0x2c, 0xe0, 0x39, 0x0d, 0xe3, 0x89, 0xfd, 0x8e, 0x93, 0x4f, 0x43, 0xdc, 0xd5, 0x5b, 0xde, 0xf9, 0x98, 0xe5, 0x7b}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xe7, 0x3b, 0x65, 0x11, 0xdf, 0xb2, 0xf2, 0x63, 0x94, 0x12, 0x6f, 0x5c, 0x9e, 0x77, 0xc1, 0xb6, 0xd8, 0xab, 0x58, 0x7a, 0x1d, 0x95, 0x73, 0xdd, 0xe7, 0xe3, 0x6f, 0xf2, 0x03, 0x1d, 0xdb, 0x76}} , {{0xae, 0x06, 0x4e, 0x2c, 0x52, 0x1b, 0xbc, 0x5a, 0x5a, 0xa5, 0xbe, 0x27, 0xbd, 0xeb, 0xe1, 0x14, 0x17, 0x68, 0x26, 0x07, 0x03, 0xd1, 0x18, 0x0b, 0xdf, 0xf1, 0x06, 0x5c, 0xa6, 0x1b, 0xb9, 0x24}}}, {{{0xc5, 0x66, 0x80, 0x13, 0x0e, 0x48, 0x8c, 0x87, 0x31, 0x84, 0xb4, 0x60, 0xed, 0xc5, 0xec, 0xb6, 0xc5, 0x05, 0x33, 0x5f, 0x2f, 0x7d, 0x40, 0xb6, 0x32, 0x1d, 0x38, 0x74, 0x1b, 0xf1, 0x09, 0x3d}} , {{0xd4, 0x69, 0x82, 0xbc, 0x8d, 0xf8, 0x34, 0x36, 0x75, 0x55, 0x18, 0x55, 0x58, 0x3c, 0x79, 0xaf, 0x26, 0x80, 0xab, 0x9b, 0x95, 0x00, 0xf1, 0xcb, 0xda, 0xc1, 0x9f, 0xf6, 0x2f, 0xa2, 0xf4, 0x45}}}, {{{0x17, 0xbe, 0xeb, 0x85, 0xed, 0x9e, 0xcd, 0x56, 0xf5, 0x17, 0x45, 0x42, 0xb4, 0x1f, 0x44, 0x4c, 0x05, 0x74, 0x15, 0x47, 0x00, 0xc6, 0x6a, 0x3d, 0x24, 0x09, 0x0d, 0x58, 0xb1, 0x42, 0xd7, 0x04}} , {{0x8d, 0xbd, 0xa3, 0xc4, 0x06, 0x9b, 0x1f, 0x90, 0x58, 0x60, 0x74, 0xb2, 0x00, 0x3b, 0x3c, 0xd2, 0xda, 0x82, 0xbb, 0x10, 0x90, 0x69, 0x92, 0xa9, 0xb4, 0x30, 0x81, 0xe3, 0x7c, 0xa8, 0x89, 0x45}}}, {{{0x3f, 0xdc, 0x05, 0xcb, 0x41, 0x3c, 0xc8, 0x23, 0x04, 0x2c, 0x38, 0x99, 0xe3, 0x68, 0x55, 0xf9, 0xd3, 0x32, 0xc7, 0xbf, 0xfa, 0xd4, 0x1b, 0x5d, 0xde, 0xdc, 0x10, 0x42, 0xc0, 0x42, 0xd9, 0x75}} , {{0x2d, 0xab, 0x35, 0x4e, 0x87, 0xc4, 0x65, 0x97, 0x67, 0x24, 0xa4, 0x47, 0xad, 0x3f, 0x8e, 0xf3, 0xcb, 0x31, 0x17, 0x77, 0xc5, 0xe2, 0xd7, 0x8f, 0x3c, 0xc1, 0xcd, 0x56, 0x48, 0xc1, 0x6c, 0x69}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x14, 0xae, 0x5f, 0x88, 0x7b, 0xa5, 0x90, 0xdf, 0x10, 0xb2, 0x8b, 0x5e, 0x24, 0x17, 0xc3, 0xa3, 0xd4, 0x0f, 0x92, 0x61, 0x1a, 0x19, 0x5a, 0xad, 0x76, 0xbd, 0xd8, 0x1c, 0xdd, 0xe0, 0x12, 0x6d}} , {{0x8e, 0xbd, 0x70, 0x8f, 0x02, 0xa3, 0x24, 0x4d, 0x5a, 0x67, 0xc4, 0xda, 0xf7, 0x20, 0x0f, 0x81, 0x5b, 0x7a, 0x05, 0x24, 0x67, 0x83, 0x0b, 0x2a, 0x80, 0xe7, 0xfd, 0x74, 0x4b, 0x9e, 0x5c, 0x0d}}}, {{{0x94, 0xd5, 0x5f, 0x1f, 0xa2, 0xfb, 0xeb, 0xe1, 0x07, 0x34, 0xf8, 0x20, 0xad, 0x81, 0x30, 0x06, 0x2d, 0xa1, 0x81, 0x95, 0x36, 0xcf, 0x11, 0x0b, 0xaf, 0xc1, 0x2b, 0x9a, 0x6c, 0x55, 0xc1, 0x16}} , {{0x36, 0x4f, 0xf1, 0x5e, 0x74, 0x35, 0x13, 0x28, 0xd7, 0x11, 0xcf, 0xb8, 0xde, 0x93, 0xb3, 0x05, 0xb8, 0xb5, 0x73, 0xe9, 0xeb, 0xad, 0x19, 0x1e, 0x89, 0x0f, 0x8b, 0x15, 0xd5, 0x8c, 0xe3, 0x23}}}, {{{0x33, 0x79, 0xe7, 0x18, 0xe6, 0x0f, 0x57, 0x93, 0x15, 0xa0, 0xa7, 0xaa, 0xc4, 0xbf, 0x4f, 0x30, 0x74, 0x95, 0x5e, 0x69, 0x4a, 0x5b, 0x45, 0xe4, 0x00, 0xeb, 0x23, 0x74, 0x4c, 0xdf, 0x6b, 0x45}} , {{0x97, 0x29, 0x6c, 0xc4, 0x42, 0x0b, 0xdd, 0xc0, 0x29, 0x5c, 0x9b, 0x34, 0x97, 0xd0, 0xc7, 0x79, 0x80, 0x63, 0x74, 0xe4, 0x8e, 0x37, 0xb0, 0x2b, 0x7c, 0xe8, 0x68, 0x6c, 0xc3, 0x82, 0x97, 0x57}}}, {{{0x22, 0xbe, 0x83, 0xb6, 0x4b, 0x80, 0x6b, 0x43, 0x24, 0x5e, 0xef, 0x99, 0x9b, 0xa8, 0xfc, 0x25, 0x8d, 0x3b, 0x03, 0x94, 0x2b, 0x3e, 0xe7, 0x95, 0x76, 0x9b, 0xcc, 0x15, 0xdb, 0x32, 0xe6, 0x66}} , {{0x84, 0xf0, 0x4a, 0x13, 0xa6, 0xd6, 0xfa, 0x93, 0x46, 0x07, 0xf6, 0x7e, 0x5c, 0x6d, 0x5e, 0xf6, 0xa6, 0xe7, 0x48, 0xf0, 0x06, 0xea, 0xff, 0x90, 0xc1, 0xcc, 0x4c, 0x19, 0x9c, 0x3c, 0x4e, 0x53}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x2a, 0x50, 0xe3, 0x07, 0x15, 0x59, 0xf2, 0x8b, 0x81, 0xf2, 0xf3, 0xd3, 0x6c, 0x99, 0x8c, 0x70, 0x67, 0xec, 0xcc, 0xee, 0x9e, 0x59, 0x45, 0x59, 0x7d, 0x47, 0x75, 0x69, 0xf5, 0x24, 0x93, 0x5d}} , {{0x6a, 0x4f, 0x1b, 0xbe, 0x6b, 0x30, 0xcf, 0x75, 0x46, 0xe3, 0x7b, 0x9d, 0xfc, 0xcd, 0xd8, 0x5c, 0x1f, 0xb4, 0xc8, 0xe2, 0x24, 0xec, 0x1a, 0x28, 0x05, 0x32, 0x57, 0xfd, 0x3c, 0x5a, 0x98, 0x10}}}, {{{0xa3, 0xdb, 0xf7, 0x30, 0xd8, 0xc2, 0x9a, 0xe1, 0xd3, 0xce, 0x22, 0xe5, 0x80, 0x1e, 0xd9, 0xe4, 0x1f, 0xab, 0xc0, 0x71, 0x1a, 0x86, 0x0e, 0x27, 0x99, 0x5b, 0xfa, 0x76, 0x99, 0xb0, 0x08, 0x3c}} , {{0x2a, 0x93, 0xd2, 0x85, 0x1b, 0x6a, 0x5d, 0xa6, 0xee, 0xd1, 0xd1, 0x33, 0xbd, 0x6a, 0x36, 0x73, 0x37, 0x3a, 0x44, 0xb4, 0xec, 0xa9, 0x7a, 0xde, 0x83, 0x40, 0xd7, 0xdf, 0x28, 0xba, 0xa2, 0x30}}}, {{{0xd3, 0xb5, 0x6d, 0x05, 0x3f, 0x9f, 0xf3, 0x15, 0x8d, 0x7c, 0xca, 0xc9, 0xfc, 0x8a, 0x7c, 0x94, 0xb0, 0x63, 0x36, 0x9b, 0x78, 0xd1, 0x91, 0x1f, 0x93, 0xd8, 0x57, 0x43, 0xde, 0x76, 0xa3, 0x43}} , {{0x9b, 0x35, 0xe2, 0xa9, 0x3d, 0x32, 0x1e, 0xbb, 0x16, 0x28, 0x70, 0xe9, 0x45, 0x2f, 0x8f, 0x70, 0x7f, 0x08, 0x7e, 0x53, 0xc4, 0x7a, 0xbf, 0xf7, 0xe1, 0xa4, 0x6a, 0xd8, 0xac, 0x64, 0x1b, 0x11}}}, {{{0xb2, 0xeb, 0x47, 0x46, 0x18, 0x3e, 0x1f, 0x99, 0x0c, 0xcc, 0xf1, 0x2c, 0xe0, 0xe7, 0x8f, 0xe0, 0x01, 0x7e, 0x65, 0xb8, 0x0c, 0xd0, 0xfb, 0xc8, 0xb9, 0x90, 0x98, 0x33, 0x61, 0x3b, 0xd8, 0x27}} , {{0xa0, 0xbe, 0x72, 0x3a, 0x50, 0x4b, 0x74, 0xab, 0x01, 0xc8, 0x93, 0xc5, 0xe4, 0xc7, 0x08, 0x6c, 0xb4, 0xca, 0xee, 0xeb, 0x8e, 0xd7, 0x4e, 0x26, 0xc6, 0x1d, 0xe2, 0x71, 0xaf, 0x89, 0xa0, 0x2a}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x98, 0x0b, 0xe4, 0xde, 0xdb, 0xa8, 0xfa, 0x82, 0x74, 0x06, 0x52, 0x6d, 0x08, 0x52, 0x8a, 0xff, 0x62, 0xc5, 0x6a, 0x44, 0x0f, 0x51, 0x8c, 0x1f, 0x6e, 0xb6, 0xc6, 0x2c, 0x81, 0xd3, 0x76, 0x46}} , {{0xf4, 0x29, 0x74, 0x2e, 0x80, 0xa7, 0x1a, 0x8f, 0xf6, 0xbd, 0xd6, 0x8e, 0xbf, 0xc1, 0x95, 0x2a, 0xeb, 0xa0, 0x7f, 0x45, 0xa0, 0x50, 0x14, 0x05, 0xb1, 0x57, 0x4c, 0x74, 0xb7, 0xe2, 0x89, 0x7d}}}, {{{0x07, 0xee, 0xa7, 0xad, 0xb7, 0x09, 0x0b, 0x49, 0x4e, 0xbf, 0xca, 0xe5, 0x21, 0xe6, 0xe6, 0xaf, 0xd5, 0x67, 0xf3, 0xce, 0x7e, 0x7c, 0x93, 0x7b, 0x5a, 0x10, 0x12, 0x0e, 0x6c, 0x06, 0x11, 0x75}} , {{0xd5, 0xfc, 0x86, 0xa3, 0x3b, 0xa3, 0x3e, 0x0a, 0xfb, 0x0b, 0xf7, 0x36, 0xb1, 0x5b, 0xda, 0x70, 0xb7, 0x00, 0xa7, 0xda, 0x88, 0x8f, 0x84, 0xa8, 0xbc, 0x1c, 0x39, 0xb8, 0x65, 0xf3, 0x4d, 0x60}}}, {{{0x96, 0x9d, 0x31, 0xf4, 0xa2, 0xbe, 0x81, 0xb9, 0xa5, 0x59, 0x9e, 0xba, 0x07, 0xbe, 0x74, 0x58, 0xd8, 0xeb, 0xc5, 0x9f, 0x3d, 0xd1, 0xf4, 0xae, 0xce, 0x53, 0xdf, 0x4f, 0xc7, 0x2a, 0x89, 0x4d}} , {{0x29, 0xd8, 0xf2, 0xaa, 0xe9, 0x0e, 0xf7, 0x2e, 0x5f, 0x9d, 0x8a, 0x5b, 0x09, 0xed, 0xc9, 0x24, 0x22, 0xf4, 0x0f, 0x25, 0x8f, 0x1c, 0x84, 0x6e, 0x34, 0x14, 0x6c, 0xea, 0xb3, 0x86, 0x5d, 0x04}}}, {{{0x07, 0x98, 0x61, 0xe8, 0x6a, 0xd2, 0x81, 0x49, 0x25, 0xd5, 0x5b, 0x18, 0xc7, 0x35, 0x52, 0x51, 0xa4, 0x46, 0xad, 0x18, 0x0d, 0xc9, 0x5f, 0x18, 0x91, 0x3b, 0xb4, 0xc0, 0x60, 0x59, 0x8d, 0x66}} , {{0x03, 0x1b, 0x79, 0x53, 0x6e, 0x24, 0xae, 0x57, 0xd9, 0x58, 0x09, 0x85, 0x48, 0xa2, 0xd3, 0xb5, 0xe2, 0x4d, 0x11, 0x82, 0xe6, 0x86, 0x3c, 0xe9, 0xb1, 0x00, 0x19, 0xc2, 0x57, 0xf7, 0x66, 0x7a}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x0f, 0xe3, 0x89, 0x03, 0xd7, 0x22, 0x95, 0x9f, 0xca, 0xb4, 0x8d, 0x9e, 0x6d, 0x97, 0xff, 0x8d, 0x21, 0x59, 0x07, 0xef, 0x03, 0x2d, 0x5e, 0xf8, 0x44, 0x46, 0xe7, 0x85, 0x80, 0xc5, 0x89, 0x50}} , {{0x8b, 0xd8, 0x53, 0x86, 0x24, 0x86, 0x29, 0x52, 0x01, 0xfa, 0x20, 0xc3, 0x4e, 0x95, 0xcb, 0xad, 0x7b, 0x34, 0x94, 0x30, 0xb7, 0x7a, 0xfa, 0x96, 0x41, 0x60, 0x2b, 0xcb, 0x59, 0xb9, 0xca, 0x50}}}, {{{0xc2, 0x5b, 0x9b, 0x78, 0x23, 0x1b, 0x3a, 0x88, 0x94, 0x5f, 0x0a, 0x9b, 0x98, 0x2b, 0x6e, 0x53, 0x11, 0xf6, 0xff, 0xc6, 0x7d, 0x42, 0xcc, 0x02, 0x80, 0x40, 0x0d, 0x1e, 0xfb, 0xaf, 0x61, 0x07}} , {{0xb0, 0xe6, 0x2f, 0x81, 0x70, 0xa1, 0x2e, 0x39, 0x04, 0x7c, 0xc4, 0x2c, 0x87, 0x45, 0x4a, 0x5b, 0x69, 0x97, 0xac, 0x6d, 0x2c, 0x10, 0x42, 0x7c, 0x3b, 0x15, 0x70, 0x60, 0x0e, 0x11, 0x6d, 0x3a}}}, {{{0x9b, 0x18, 0x80, 0x5e, 0xdb, 0x05, 0xbd, 0xc6, 0xb7, 0x3c, 0xc2, 0x40, 0x4d, 0x5d, 0xce, 0x97, 0x8a, 0x34, 0x15, 0xab, 0x28, 0x5d, 0x10, 0xf0, 0x37, 0x0c, 0xcc, 0x16, 0xfa, 0x1f, 0x33, 0x0d}} , {{0x19, 0xf9, 0x35, 0xaa, 0x59, 0x1a, 0x0c, 0x5c, 0x06, 0xfc, 0x6a, 0x0b, 0x97, 0x53, 0x36, 0xfc, 0x2a, 0xa5, 0x5a, 0x9b, 0x30, 0xef, 0x23, 0xaf, 0x39, 0x5d, 0x9a, 0x6b, 0x75, 0x57, 0x48, 0x0b}}}, {{{0x26, 0xdc, 0x76, 0x3b, 0xfc, 0xf9, 0x9c, 0x3f, 0x89, 0x0b, 0x62, 0x53, 0xaf, 0x83, 0x01, 0x2e, 0xbc, 0x6a, 0xc6, 0x03, 0x0d, 0x75, 0x2a, 0x0d, 0xe6, 0x94, 0x54, 0xcf, 0xb3, 0xe5, 0x96, 0x25}} , {{0xfe, 0x82, 0xb1, 0x74, 0x31, 0x8a, 0xa7, 0x6f, 0x56, 0xbd, 0x8d, 0xf4, 0xe0, 0x94, 0x51, 0x59, 0xde, 0x2c, 0x5a, 0xf4, 0x84, 0x6b, 0x4a, 0x88, 0x93, 0xc0, 0x0c, 0x9a, 0xac, 0xa7, 0xa0, 0x68}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x25, 0x0d, 0xd6, 0xc7, 0x23, 0x47, 0x10, 0xad, 0xc7, 0x08, 0x5c, 0x87, 0x87, 0x93, 0x98, 0x18, 0xb8, 0xd3, 0x9c, 0xac, 0x5a, 0x3d, 0xc5, 0x75, 0xf8, 0x49, 0x32, 0x14, 0xcc, 0x51, 0x96, 0x24}} , {{0x65, 0x9c, 0x5d, 0xf0, 0x37, 0x04, 0xf0, 0x34, 0x69, 0x2a, 0xf0, 0xa5, 0x64, 0xca, 0xde, 0x2b, 0x5b, 0x15, 0x10, 0xd2, 0xab, 0x06, 0xdd, 0xc4, 0xb0, 0xb6, 0x5b, 0xc1, 0x17, 0xdf, 0x8f, 0x02}}}, {{{0xbd, 0x59, 0x3d, 0xbf, 0x5c, 0x31, 0x44, 0x2c, 0x32, 0x94, 0x04, 0x60, 0x84, 0x0f, 0xad, 0x00, 0xb6, 0x8f, 0xc9, 0x1d, 0xcc, 0x5c, 0xa2, 0x49, 0x0e, 0x50, 0x91, 0x08, 0x9a, 0x43, 0x55, 0x05}} , {{0x5d, 0x93, 0x55, 0xdf, 0x9b, 0x12, 0x19, 0xec, 0x93, 0x85, 0x42, 0x9e, 0x66, 0x0f, 0x9d, 0xaf, 0x99, 0xaf, 0x26, 0x89, 0xbc, 0x61, 0xfd, 0xff, 0xce, 0x4b, 0xf4, 0x33, 0x95, 0xc9, 0x35, 0x58}}}, {{{0x12, 0x55, 0xf9, 0xda, 0xcb, 0x44, 0xa7, 0xdc, 0x57, 0xe2, 0xf9, 0x9a, 0xe6, 0x07, 0x23, 0x60, 0x54, 0xa7, 0x39, 0xa5, 0x9b, 0x84, 0x56, 0x6e, 0xaa, 0x8b, 0x8f, 0xb0, 0x2c, 0x87, 0xaf, 0x67}} , {{0x00, 0xa9, 0x4c, 0xb2, 0x12, 0xf8, 0x32, 0xa8, 0x7a, 0x00, 0x4b, 0x49, 0x32, 0xba, 0x1f, 0x5d, 0x44, 0x8e, 0x44, 0x7a, 0xdc, 0x11, 0xfb, 0x39, 0x08, 0x57, 0x87, 0xa5, 0x12, 0x42, 0x93, 0x0e}}}, {{{0x17, 0xb4, 0xae, 0x72, 0x59, 0xd0, 0xaa, 0xa8, 0x16, 0x8b, 0x63, 0x11, 0xb3, 0x43, 0x04, 0xda, 0x0c, 0xa8, 0xb7, 0x68, 0xdd, 0x4e, 0x54, 0xe7, 0xaf, 0x5d, 0x5d, 0x05, 0x76, 0x36, 0xec, 0x0d}} , {{0x6d, 0x7c, 0x82, 0x32, 0x38, 0x55, 0x57, 0x74, 0x5b, 0x7d, 0xc3, 0xc4, 0xfb, 0x06, 0x29, 0xf0, 0x13, 0x55, 0x54, 0xc6, 0xa7, 0xdc, 0x4c, 0x9f, 0x98, 0x49, 0x20, 0xa8, 0xc3, 0x8d, 0xfa, 0x48}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x87, 0x47, 0x9d, 0xe9, 0x25, 0xd5, 0xe3, 0x47, 0x78, 0xdf, 0x85, 0xa7, 0x85, 0x5e, 0x7a, 0x4c, 0x5f, 0x79, 0x1a, 0xf3, 0xa2, 0xb2, 0x28, 0xa0, 0x9c, 0xdd, 0x30, 0x40, 0xd4, 0x38, 0xbd, 0x28}} , {{0xfc, 0xbb, 0xd5, 0x78, 0x6d, 0x1d, 0xd4, 0x99, 0xb4, 0xaa, 0x44, 0x44, 0x7a, 0x1b, 0xd8, 0xfe, 0xb4, 0x99, 0xb9, 0xcc, 0xe7, 0xc4, 0xd3, 0x3a, 0x73, 0x83, 0x41, 0x5c, 0x40, 0xd7, 0x2d, 0x55}}}, {{{0x26, 0xe1, 0x7b, 0x5f, 0xe5, 0xdc, 0x3f, 0x7d, 0xa1, 0xa7, 0x26, 0x44, 0x22, 0x23, 0xc0, 0x8f, 0x7d, 0xf1, 0xb5, 0x11, 0x47, 0x7b, 0x19, 0xd4, 0x75, 0x6f, 0x1e, 0xa5, 0x27, 0xfe, 0xc8, 0x0e}} , {{0xd3, 0x11, 0x3d, 0xab, 0xef, 0x2c, 0xed, 0xb1, 0x3d, 0x7c, 0x32, 0x81, 0x6b, 0xfe, 0xf8, 0x1c, 0x3c, 0x7b, 0xc0, 0x61, 0xdf, 0xb8, 0x75, 0x76, 0x7f, 0xaa, 0xd8, 0x93, 0xaf, 0x3d, 0xe8, 0x3d}}}, {{{0xfd, 0x5b, 0x4e, 0x8d, 0xb6, 0x7e, 0x82, 0x9b, 0xef, 0xce, 0x04, 0x69, 0x51, 0x52, 0xff, 0xef, 0xa0, 0x52, 0xb5, 0x79, 0x17, 0x5e, 0x2f, 0xde, 0xd6, 0x3c, 0x2d, 0xa0, 0x43, 0xb4, 0x0b, 0x19}} , {{0xc0, 0x61, 0x48, 0x48, 0x17, 0xf4, 0x9e, 0x18, 0x51, 0x2d, 0xea, 0x2f, 0xf2, 0xf2, 0xe0, 0xa3, 0x14, 0xb7, 0x8b, 0x3a, 0x30, 0xf5, 0x81, 0xc1, 0x5d, 0x71, 0x39, 0x62, 0x55, 0x1f, 0x60, 0x5a}}}, {{{0xe5, 0x89, 0x8a, 0x76, 0x6c, 0xdb, 0x4d, 0x0a, 0x5b, 0x72, 0x9d, 0x59, 0x6e, 0x63, 0x63, 0x18, 0x7c, 0xe3, 0xfa, 0xe2, 0xdb, 0xa1, 0x8d, 0xf4, 0xa5, 0xd7, 0x16, 0xb2, 0xd0, 0xb3, 0x3f, 0x39}} , {{0xce, 0x60, 0x09, 0x6c, 0xf5, 0x76, 0x17, 0x24, 0x80, 0x3a, 0x96, 0xc7, 0x94, 0x2e, 0xf7, 0x6b, 0xef, 0xb5, 0x05, 0x96, 0xef, 0xd3, 0x7b, 0x51, 0xda, 0x05, 0x44, 0x67, 0xbc, 0x07, 0x21, 0x4e}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xe9, 0x73, 0x6f, 0x21, 0xb9, 0xde, 0x22, 0x7d, 0xeb, 0x97, 0x31, 0x10, 0xa3, 0xea, 0xe1, 0xc6, 0x37, 0xeb, 0x8f, 0x43, 0x58, 0xde, 0x41, 0x64, 0x0e, 0x3e, 0x07, 0x99, 0x3d, 0xf1, 0xdf, 0x1e}} , {{0xf8, 0xad, 0x43, 0xc2, 0x17, 0x06, 0xe2, 0xe4, 0xa9, 0x86, 0xcd, 0x18, 0xd7, 0x78, 0xc8, 0x74, 0x66, 0xd2, 0x09, 0x18, 0xa5, 0xf1, 0xca, 0xa6, 0x62, 0x92, 0xc1, 0xcb, 0x00, 0xeb, 0x42, 0x2e}}}, {{{0x7b, 0x34, 0x24, 0x4c, 0xcf, 0x38, 0xe5, 0x6c, 0x0a, 0x01, 0x2c, 0x22, 0x0b, 0x24, 0x38, 0xad, 0x24, 0x7e, 0x19, 0xf0, 0x6c, 0xf9, 0x31, 0xf4, 0x35, 0x11, 0xf6, 0x46, 0x33, 0x3a, 0x23, 0x59}} , {{0x20, 0x0b, 0xa1, 0x08, 0x19, 0xad, 0x39, 0x54, 0xea, 0x3e, 0x23, 0x09, 0xb6, 0xe2, 0xd2, 0xbc, 0x4d, 0xfc, 0x9c, 0xf0, 0x13, 0x16, 0x22, 0x3f, 0xb9, 0xd2, 0x11, 0x86, 0x90, 0x55, 0xce, 0x3c}}}, {{{0xc4, 0x0b, 0x4b, 0x62, 0x99, 0x37, 0x84, 0x3f, 0x74, 0xa2, 0xf9, 0xce, 0xe2, 0x0b, 0x0f, 0x2a, 0x3d, 0xa3, 0xe3, 0xdb, 0x5a, 0x9d, 0x93, 0xcc, 0xa5, 0xef, 0x82, 0x91, 0x1d, 0xe6, 0x6c, 0x68}} , {{0xa3, 0x64, 0x17, 0x9b, 0x8b, 0xc8, 0x3a, 0x61, 0xe6, 0x9d, 0xc6, 0xed, 0x7b, 0x03, 0x52, 0x26, 0x9d, 0x3a, 0xb3, 0x13, 0xcc, 0x8a, 0xfd, 0x2c, 0x1a, 0x1d, 0xed, 0x13, 0xd0, 0x55, 0x57, 0x0e}}}, {{{0x1a, 0xea, 0xbf, 0xfd, 0x4a, 0x3c, 0x8e, 0xec, 0x29, 0x7e, 0x77, 0x77, 0x12, 0x99, 0xd7, 0x84, 0xf9, 0x55, 0x7f, 0xf1, 0x8b, 0xb4, 0xd2, 0x95, 0xa3, 0x8d, 0xf0, 0x8a, 0xa7, 0xeb, 0x82, 0x4b}} , {{0x2c, 0x28, 0xf4, 0x3a, 0xf6, 0xde, 0x0a, 0xe0, 0x41, 0x44, 0x23, 0xf8, 0x3f, 0x03, 0x64, 0x9f, 0xc3, 0x55, 0x4c, 0xc6, 0xc1, 0x94, 0x1c, 0x24, 0x5d, 0x5f, 0x92, 0x45, 0x96, 0x57, 0x37, 0x14}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xc1, 0xcd, 0x90, 0x66, 0xb9, 0x76, 0xa0, 0x5b, 0xa5, 0x85, 0x75, 0x23, 0xf9, 0x89, 0xa5, 0x82, 0xb2, 0x6f, 0xb1, 0xeb, 0xc4, 0x69, 0x6f, 0x18, 0x5a, 0xed, 0x94, 0x3d, 0x9d, 0xd9, 0x2c, 0x1a}} , {{0x35, 0xb0, 0xe6, 0x73, 0x06, 0xb7, 0x37, 0xe0, 0xf8, 0xb0, 0x22, 0xe8, 0xd2, 0xed, 0x0b, 0xef, 0xe6, 0xc6, 0x5a, 0x99, 0x9e, 0x1a, 0x9f, 0x04, 0x97, 0xe4, 0x4d, 0x0b, 0xbe, 0xba, 0x44, 0x40}}}, {{{0xc1, 0x56, 0x96, 0x91, 0x5f, 0x1f, 0xbb, 0x54, 0x6f, 0x88, 0x89, 0x0a, 0xb2, 0xd6, 0x41, 0x42, 0x6a, 0x82, 0xee, 0x14, 0xaa, 0x76, 0x30, 0x65, 0x0f, 0x67, 0x39, 0xa6, 0x51, 0x7c, 0x49, 0x24}} , {{0x35, 0xa3, 0x78, 0xd1, 0x11, 0x0f, 0x75, 0xd3, 0x70, 0x46, 0xdb, 0x20, 0x51, 0xcb, 0x92, 0x80, 0x54, 0x10, 0x74, 0x36, 0x86, 0xa9, 0xd7, 0xa3, 0x08, 0x78, 0xf1, 0x01, 0x29, 0xf8, 0x80, 0x3b}}}, {{{0xdb, 0xa7, 0x9d, 0x9d, 0xbf, 0xa0, 0xcc, 0xed, 0x53, 0xa2, 0xa2, 0x19, 0x39, 0x48, 0x83, 0x19, 0x37, 0x58, 0xd1, 0x04, 0x28, 0x40, 0xf7, 0x8a, 0xc2, 0x08, 0xb7, 0xa5, 0x42, 0xcf, 0x53, 0x4c}} , {{0xa7, 0xbb, 0xf6, 0x8e, 0xad, 0xdd, 0xf7, 0x90, 0xdd, 0x5f, 0x93, 0x89, 0xae, 0x04, 0x37, 0xe6, 0x9a, 0xb7, 0xe8, 0xc0, 0xdf, 0x16, 0x2a, 0xbf, 0xc4, 0x3a, 0x3c, 0x41, 0xd5, 0x89, 0x72, 0x5a}}}, {{{0x1f, 0x96, 0xff, 0x34, 0x2c, 0x13, 0x21, 0xcb, 0x0a, 0x89, 0x85, 0xbe, 0xb3, 0x70, 0x9e, 0x1e, 0xde, 0x97, 0xaf, 0x96, 0x30, 0xf7, 0x48, 0x89, 0x40, 0x8d, 0x07, 0xf1, 0x25, 0xf0, 0x30, 0x58}} , {{0x1e, 0xd4, 0x93, 0x57, 0xe2, 0x17, 0xe7, 0x9d, 0xab, 0x3c, 0x55, 0x03, 0x82, 0x2f, 0x2b, 0xdb, 0x56, 0x1e, 0x30, 0x2e, 0x24, 0x47, 0x6e, 0xe6, 0xff, 0x33, 0x24, 0x2c, 0x75, 0x51, 0xd4, 0x67}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0x2b, 0x06, 0xd9, 0xa1, 0x5d, 0xe1, 0xf4, 0xd1, 0x1e, 0x3c, 0x9a, 0xc6, 0x29, 0x2b, 0x13, 0x13, 0x78, 0xc0, 0xd8, 0x16, 0x17, 0x2d, 0x9e, 0xa9, 0xc9, 0x79, 0x57, 0xab, 0x24, 0x91, 0x92, 0x19}} , {{0x69, 0xfb, 0xa1, 0x9c, 0xa6, 0x75, 0x49, 0x7d, 0x60, 0x73, 0x40, 0x42, 0xc4, 0x13, 0x0a, 0x95, 0x79, 0x1e, 0x04, 0x83, 0x94, 0x99, 0x9b, 0x1e, 0x0c, 0xe8, 0x1f, 0x54, 0xef, 0xcb, 0xc0, 0x52}}}, {{{0x14, 0x89, 0x73, 0xa1, 0x37, 0x87, 0x6a, 0x7a, 0xcf, 0x1d, 0xd9, 0x2e, 0x1a, 0x67, 0xed, 0x74, 0xc0, 0xf0, 0x9c, 0x33, 0xdd, 0xdf, 0x08, 0xbf, 0x7b, 0xd1, 0x66, 0xda, 0xe6, 0xc9, 0x49, 0x08}} , {{0xe9, 0xdd, 0x5e, 0x55, 0xb0, 0x0a, 0xde, 0x21, 0x4c, 0x5a, 0x2e, 0xd4, 0x80, 0x3a, 0x57, 0x92, 0x7a, 0xf1, 0xc4, 0x2c, 0x40, 0xaf, 0x2f, 0xc9, 0x92, 0x03, 0xe5, 0x5a, 0xbc, 0xdc, 0xf4, 0x09}}}, {{{0xf3, 0xe1, 0x2b, 0x7c, 0x05, 0x86, 0x80, 0x93, 0x4a, 0xad, 0xb4, 0x8f, 0x7e, 0x99, 0x0c, 0xfd, 0xcd, 0xef, 0xd1, 0xff, 0x2c, 0x69, 0x34, 0x13, 0x41, 0x64, 0xcf, 0x3b, 0xd0, 0x90, 0x09, 0x1e}} , {{0x9d, 0x45, 0xd6, 0x80, 0xe6, 0x45, 0xaa, 0xf4, 0x15, 0xaa, 0x5c, 0x34, 0x87, 0x99, 0xa2, 0x8c, 0x26, 0x84, 0x62, 0x7d, 0xb6, 0x29, 0xc0, 0x52, 0xea, 0xf5, 0x81, 0x18, 0x0f, 0x35, 0xa9, 0x0e}}}, {{{0xe7, 0x20, 0x72, 0x7c, 0x6d, 0x94, 0x5f, 0x52, 0x44, 0x54, 0xe3, 0xf1, 0xb2, 0xb0, 0x36, 0x46, 0x0f, 0xae, 0x92, 0xe8, 0x70, 0x9d, 0x6e, 0x79, 0xb1, 0xad, 0x37, 0xa9, 0x5f, 0xc0, 0xde, 0x03}} , {{0x15, 0x55, 0x37, 0xc6, 0x1c, 0x27, 0x1c, 0x6d, 0x14, 0x4f, 0xca, 0xa4, 0xc4, 0x88, 0x25, 0x46, 0x39, 0xfc, 0x5a, 0xe5, 0xfe, 0x29, 0x11, 0x69, 0xf5, 0x72, 0x84, 0x4d, 0x78, 0x9f, 0x94, 0x15}}}, {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, {{{0xec, 0xd3, 0xff, 0x57, 0x0b, 0xb0, 0xb2, 0xdc, 0xf8, 0x4f, 0xe2, 0x12, 0xd5, 0x36, 0xbe, 0x6b, 0x09, 0x43, 0x6d, 0xa3, 0x4d, 0x90, 0x2d, 0xb8, 0x74, 0xe8, 0x71, 0x45, 0x19, 0x8b, 0x0c, 0x6a}} , {{0xb8, 0x42, 0x1c, 0x03, 0xad, 0x2c, 0x03, 0x8e, 0xac, 0xd7, 0x98, 0x29, 0x13, 0xc6, 0x02, 0x29, 0xb5, 0xd4, 0xe7, 0xcf, 0xcc, 0x8b, 0x83, 0xec, 0x35, 0xc7, 0x9c, 0x74, 0xb7, 0xad, 0x85, 0x5f}}}, {{{0x78, 0x84, 0xe1, 0x56, 0x45, 0x69, 0x68, 0x5a, 0x4f, 0xb8, 0xb1, 0x29, 0xff, 0x33, 0x03, 0x31, 0xb7, 0xcb, 0x96, 0x25, 0xe6, 0xe6, 0x41, 0x98, 0x1a, 0xbb, 0x03, 0x56, 0xf2, 0xb2, 0x91, 0x34}} , {{0x2c, 0x6c, 0xf7, 0x66, 0xa4, 0x62, 0x6b, 0x39, 0xb3, 0xba, 0x65, 0xd3, 0x1c, 0xf8, 0x11, 0xaa, 0xbe, 0xdc, 0x80, 0x59, 0x87, 0xf5, 0x7b, 0xe5, 0xe3, 0xb3, 0x3e, 0x39, 0xda, 0xbe, 0x88, 0x09}}}, {{{0x8b, 0xf1, 0xa0, 0xf5, 0xdc, 0x29, 0xb4, 0xe2, 0x07, 0xc6, 0x7a, 0x00, 0xd0, 0x89, 0x17, 0x51, 0xd4, 0xbb, 0xd4, 0x22, 0xea, 0x7e, 0x7d, 0x7c, 0x24, 0xea, 0xf2, 0xe8, 0x22, 0x12, 0x95, 0x06}} , {{0xda, 0x7c, 0xa4, 0x0c, 0xf4, 0xba, 0x6e, 0xe1, 0x89, 0xb5, 0x59, 0xca, 0xf1, 0xc0, 0x29, 0x36, 0x09, 0x44, 0xe2, 0x7f, 0xd1, 0x63, 0x15, 0x99, 0xea, 0x25, 0xcf, 0x0c, 0x9d, 0xc0, 0x44, 0x6f}}}, {{{0x1d, 0x86, 0x4e, 0xcf, 0xf7, 0x37, 0x10, 0x25, 0x8f, 0x12, 0xfb, 0x19, 0xfb, 0xe0, 0xed, 0x10, 0xc8, 0xe2, 0xf5, 0x75, 0xb1, 0x33, 0xc0, 0x96, 0x0d, 0xfb, 0x15, 0x6c, 0x0d, 0x07, 0x5f, 0x05}} , {{0x69, 0x3e, 0x47, 0x97, 0x2c, 0xaf, 0x52, 0x7c, 0x78, 0x83, 0xad, 0x1b, 0x39, 0x82, 0x2f, 0x02, 0x6f, 0x47, 0xdb, 0x2a, 0xb0, 0xe1, 0x91, 0x99, 0x55, 0xb8, 0x99, 0x3a, 0xa0, 0x44, 0x11, 0x51}}} assaultcube-1.2.0.2.1/source/src/geom.h000066400000000000000000000260211352165075300175230ustar00rootroot00000000000000 struct vec { union { struct { float x, y, z; }; float v[3]; int i[3]; }; vec() {x=y=z=0;} vec(float a, float b, float c) : x(a), y(b), z(c) {} vec(float *v) : x(v[0]), y(v[1]), z(v[2]) {} float &operator[](int i) { return v[i]; } float operator[](int i) const { return v[i]; } bool iszero() const { return x==0 && y==0 && z==0; } bool operator==(const vec &o) const { return x == o.x && y == o.y && z == o.z; } bool operator!=(const vec &o) const { return x != o.x || y != o.y || z != o.z; } vec operator-() const { return vec(-x, -y, -z); } vec &mul(float f) { x *= f; y *= f; z *= f; return *this; } vec &div(float f) { x /= f; y /= f; z /= f; return *this; } vec &add(float f) { x += f; y += f; z += f; return *this; } vec &sub(float f) { x -= f; y -= f; z -= f; return *this; } vec &add(const vec &o) { x += o.x; y += o.y; z += o.z; return *this; } vec &sub(const vec &o) { x -= o.x; y -= o.y; z -= o.z; return *this; } float squaredlen() const { return x*x + y*y + z*z; } float sqrxy() const { return x*x + y*y; } float dot(const vec &o) const { return x*o.x + y*o.y + z*o.z; } float dotxy(const vec &o) const { return x*o.x + y*o.y; } float magnitude() const { return sqrtf(squaredlen()); } vec &normalize() { div(magnitude()); return *this; } float dist(const vec &e) const { vec t; return dist(e, t); } float dist(const vec &e, vec &t) const { t = *this; t.sub(e); return t.magnitude(); } float squareddist(const vec &e) const { vec t = *this; t.sub(e); return t.squaredlen(); } float distxy(const vec &e) const { float dx = e.x - x, dy = e.y - y; return sqrtf(dx*dx + dy*dy); } float magnitudexy() const { return sqrtf(x*x + y*y); } float anglexy() const { return atan2f(x, y) / RAD; } bool reject(const vec &o, float max) const { return x>o.x+max || xo.y+max || y fabs(d.y) ? (fabs(d.x) > fabs(d.z) ? 0 : 2) : (fabs(d.y) > fabs(d.z) ? 1 : 2); v[i] = d[(i+1)%3]; v[(i+1)%3] = -d[i]; v[(i+2)%3] = 0; } }; static inline bool htcmp(const vec &x, const vec &y) { return x == y; } static inline uint hthash(const vec &k) { return k.i[0]^k.i[1]^k.i[2]; } struct vec4 { union { struct { float x, y, z, w; }; float v[4]; }; vec4() {} explicit vec4(const vec &p, float w = 0) : x(p.x), y(p.y), z(p.z), w(w) {} vec4(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) {} float &operator[](int i) { return v[i]; } float operator[](int i) const { return v[i]; } }; struct ivec { union { struct { int x, y, z; }; int v[3]; }; ivec() {} ivec(const vec &v) : x(int(v.x)), y(int(v.y)), z(int(v.z)) {} ivec(int a, int b, int c) : x(a), y(b), z(c) {} vec tovec() const { return vec(x, y, z); } int &operator[](int i) { return v[i]; } int operator[](int i) const { return v[i]; } bool operator==(const ivec &v) const { return x==v.x && y==v.y && z==v.z; } bool operator!=(const ivec &v) const { return x!=v.x || y!=v.y || z!=v.z; } ivec &mul(int n) { x *= n; y *= n; z *= n; return *this; } ivec &div(int n) { x /= n; y /= n; z /= n; return *this; } ivec &add(int n) { x += n; y += n; z += n; return *this; } ivec &sub(int n) { x -= n; y -= n; z -= n; return *this; } ivec &add(const ivec &v) { x += v.x; y += v.y; z += v.z; return *this; } ivec &sub(const ivec &v) { x -= v.x; y -= v.y; z -= v.z; return *this; } ivec &mask(int n) { x &= n; y &= n; z &= n; return *this; } ivec &cross(const ivec &a, const ivec &b) { x = a.y*b.z-a.z*b.y; y = a.z*b.x-a.x*b.z; z = a.x*b.y-a.y*b.x; return *this; } int dot(const ivec &o) const { return x*o.x + y*o.y + z*o.z; } }; static inline bool htcmp(const ivec &x, const ivec &y) { return x == y; } static inline uint hthash(const ivec &k) { return k.x^k.y^k.z; } struct bvec { union { struct { uchar x, y, z; }; uchar v[3]; }; bvec() {} bvec(uchar x, uchar y, uchar z) : x(x), y(y), z(z) {} bvec(const vec &v) : x((uchar)((v.x+1)*255/2)), y((uchar)((v.y+1)*255/2)), z((uchar)((v.z+1)*255/2)) {} uchar &operator[](int i) { return v[i]; } uchar operator[](int i) const { return v[i]; } bool operator==(const bvec &v) const { return x==v.x && y==v.y && z==v.z; } bool operator!=(const bvec &v) const { return x!=v.x || y!=v.y || z!=v.z; } bool iszero() const { return x==0 && y==0 && z==0; } vec tovec() const { return vec(x*(2.0f/255.0f)-1.0f, y*(2.0f/255.0f)-1.0f, z*(2.0f/255.0f)-1.0f); } }; struct quat { float x, y, z, w; quat(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) {} quat(const vec &axis, float angle) { w = cosf(angle/2); float s = sinf(angle/2); x = s*axis.x; y = s*axis.y; z = s*axis.z; } quat(float yaw, float pitch) // quat(vec(0, 1, 0), pitch).mul(quat((vec(0, 0, 1), yaw)) { yaw *= RAD / 2; pitch *= RAD / 2; float yw = cosf(yaw), ys = sinf(yaw); float pw = cosf(pitch), ps = sinf(pitch); x = ps * ys; y = ps * yw; z = pw * ys; w = pw * yw; } quat &roll(float roll) // quat(sinf(roll), 0, 0, cosf(roll)).mul(*this)); { roll *= RAD / 2; float px = sinf(roll), pw = cosf(roll); quat o(*this); x = pw * o.x + px * o.w; y = pw * o.y - px * o.z; z = pw * o.z + px * o.y; w = pw * o.w - px * o.x; return *this; } /* quat &mul(const quat &p, const quat &o) { x = p.w*o.x + p.x*o.w + p.y*o.z - p.z*o.y; y = p.w*o.y - p.x*o.z + p.y*o.w + p.z*o.x; z = p.w*o.z + p.x*o.y - p.y*o.x + p.z*o.w; w = p.w*o.w - p.x*o.x - p.y*o.y - p.z*o.z; return *this; } quat &mul(const quat &o) { return mul(quat(*this), o); } */ }; struct glmatrixf { float v[16]; float operator[](int i) const { return v[i]; } float &operator[](int i) { return v[i]; } #define ROTVEC(A, B) \ { \ float a = A, b = B; \ A = a*c + b*s; \ B = b*c - a*s; \ } void rotate_around_x(float angle) { float c = cosf(angle), s = sinf(angle); ROTVEC(v[4], v[8]); ROTVEC(v[5], v[9]); ROTVEC(v[6], v[10]); } void rotate_around_y(float angle) { float c = cosf(angle), s = sinf(angle); ROTVEC(v[8], v[0]); ROTVEC(v[9], v[1]); ROTVEC(v[10], v[2]); } void rotate_around_z(float angle) { float c = cosf(angle), s = sinf(angle); ROTVEC(v[0], v[4]); ROTVEC(v[1], v[5]); ROTVEC(v[2], v[6]); } #undef ROTVEC #define MULMAT(row, col) \ v[col + row] = x[row]*y[col] + x[row + 4]*y[col + 1] + x[row + 8]*y[col + 2] + x[row + 12]*y[col + 3]; template void mul(const XT x[16], const YT y[16]) { MULMAT(0, 0); MULMAT(1, 0); MULMAT(2, 0); MULMAT(3, 0); MULMAT(0, 4); MULMAT(1, 4); MULMAT(2, 4); MULMAT(3, 4); MULMAT(0, 8); MULMAT(1, 8); MULMAT(2, 8); MULMAT(3, 8); MULMAT(0, 12); MULMAT(1, 12); MULMAT(2, 12); MULMAT(3, 12); } #undef MULMAT void mul(const glmatrixf &x, const glmatrixf &y) { mul(x.v, y.v); } void identity() { static const float m[16] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; memcpy(v, m, sizeof(v)); } void translate(float x, float y, float z) { v[12] += x; v[13] += y; v[14] += z; } void translate(const vec &o) { translate(o.x, o.y, o.z); } void scale(float x, float y, float z) { v[0] *= x; v[1] *= x; v[2] *= x; v[3] *= x; v[4] *= y; v[5] *= y; v[6] *= y; v[7] *= y; v[8] *= z; v[9] *= z; v[10] *= z; v[11] *= z; } void projective() { loopi(2) loopj(4) v[i + j*4] = 0.5f*(v[i + j*4] + v[3 + j*4]); } void invertnormal(vec &dir) const { vec n(dir); dir.x = n.x*v[0] + n.y*v[1] + n.z*v[2]; dir.y = n.x*v[4] + n.y*v[5] + n.z*v[6]; dir.z = n.x*v[8] + n.y*v[9] + n.z*v[10]; } void invertvertex(vec &pos) const { vec p(pos); p.x -= v[12]; p.y -= v[13]; p.z -= v[14]; pos.x = p.x*v[0] + p.y*v[1] + p.z*v[2]; pos.y = p.x*v[4] + p.y*v[5] + p.z*v[6]; pos.z = p.x*v[8] + p.y*v[9] + p.z*v[10]; } float transformx(const vec &p) const { return p.x*v[0] + p.y*v[4] + p.z*v[8] + v[12]; } float transformy(const vec &p) const { return p.x*v[1] + p.y*v[5] + p.z*v[9] + v[13]; } float transformz(const vec &p) const { return p.x*v[2] + p.y*v[6] + p.z*v[10] + v[14]; } float transformw(const vec &p) const { return p.x*v[3] + p.y*v[7] + p.z*v[11] + v[15]; } void transform(const vec &in, vec4 &out) const { out.x = transformx(in); out.y = transformy(in); out.z = transformz(in); out.w = transformw(in); } vec gettranslation() const { return vec(v[12], v[13], v[14]); } float determinant() const; void adjoint(const glmatrixf &m); bool invert(const glmatrixf &m, float mindet = 1.0e-10f); void fromquat(quat &q) { float xx = q.x * q.x, xy = q.x * q.y, xz = q.x * q.z, xw = q.x * q.w, yy = q.y * q.y, yz = q.y * q.z, yw = q.y * q.w, zz = q.z * q.z, zw = q.z * q.w; v[0] = 1 - 2 * ( yy + zz ); v[1] = 2 * ( xy - zw ); v[2] = 2 * ( xz + yw ); v[4] = 2 * ( xy + zw ); v[5] = 1 - 2 * ( xx + zz ); v[6] = 2 * ( yz - xw ); v[8] = 2 * ( xz - yw ); v[9] = 2 * ( yz + xw ); v[10] = 1 - 2 * ( xx + yy ); v[3] = v[7] = v[11] = v[12] = v[13] = v[14] = 0; v[15] = 1; } }; assaultcube-1.2.0.2.1/source/src/http.cpp000066400000000000000000000416261352165075300201160ustar00rootroot00000000000000// very simple http get function #include "cube.h" #include #define CR 13 #define LF 10 #define TCP_TIMEOUT 5678 // only re-use quite fresh connections #define GETERROR(msg) { err = msg; goto geterror; } const char lfcrlf[] = { LF, CR, LF, 0x00 }, *crlf = lfcrlf + 1; void httpget::reset(int keep) // keep == 0: delete all, keep == 1: keep connection, keep == 2: keep connection and url { if(keep < 1) { // reset connection DELSTRING(hostname); ip.host = ENET_HOST_ANY; ip.port = 80; // change manually, if needed maxredirects = 3; maxtransfer = maxsize = 1<<20; // 1 MB (caps transfer size and unzipped size) connecttimeout = 6000; disconnect(); } err = NULL; response = chunked = gzipped = contentlength = offset = elapsedtime = traffic = 0; if(keep < 2) DELSTRING(url); DELSTRING(header); rawsnd.setsize(0); rawrec.setsize(0); datarec.setsize(0); } bool httpget::set_host(const char *newhostname) // set and resolve host { if(!hostname || strcmp(hostname, newhostname)) { DELSTRING(hostname); disconnect(); // new or different host name -> close connection (if still open) ENetAddress newhost; if(enet_address_set_host(&newhost, newhostname) < 0) { err = "failed to resolve hostname"; return false; } ip.host = newhost.host; hostname = newstring(newhostname); } return ip.host != ENET_HOST_ANY; } void httpget::set_port(int port) // set port (disconnect, if different to previous) { port &= 65535; if(port < 80) port = 80; if(port != ip.port) disconnect(); ip.port = port; } bool httpget::execcallback(float progress) { if(callbackfunc && (*callbackfunc)(callbackdata, progress)) { err = "manual abort"; return true; } return false; } void httpget::disconnect() { if(tcp != ENET_SOCKET_NULL) { enet_socket_destroy(tcp); tcp = ENET_SOCKET_NULL; } } struct connectinfo { ENetSocket sock; ENetAddress address; volatile char running; }; int hcont(void *data) { connectinfo ci = *((connectinfo *)data); ((connectinfo *)data)->running = 1; // now the calling thread may as well vanish return enet_socket_connect(ci.sock, &ci.address); } bool httpget::connect(bool force) { if(force || tcp_age.elapsed() > TCP_TIMEOUT) disconnect(); if(tcp == ENET_SOCKET_NULL) { connectinfo ci = { enet_socket_create(ENET_SOCKET_TYPE_STREAM), ip, 0 }; tcp_age.start(); if(ci.sock == ENET_SOCKET_NULL) { err = "could not open socket"; return false; } void *ti = sl_createthread(hcont, &ci); loopk(connecttimeout / 250 + 1) { sl_detachthread(NULL); // cleanup call sl_sleep(250); if(ci.running) // wait for the connect thread to copy its data { if(sl_pollthread(ti)) { if(sl_waitthread(ti) < 0) { err = "could not connect"; ti = NULL; break; } else { tcp = ci.sock; return true; } } if(execcallback(-float(tcp_age.elapsed()) / (connecttimeout| 1))) break; // esc pressed } } sl_detachthread(ti); if(!err) err = "could not connect in time"; enet_socket_destroy(ci.sock); ASSERT(ci.running); return false; } return true; } int httpget::get(const char *url1, uint timeout, uint totaltimeout, int range, bool head) { int redirects = 0, res = 0, transferred = 0; vector *content = NULL; ASSERT(timeout && totaltimeout); // zero is not allowed stopwatch to; to.start(); uint lastresponse = 0; reset(1); // clear old response values and url url = newstring(url1); bool reconnected = false, retry = false; for(;;) { // (in a loop because of possible redirects) if(!connect()) goto geterror; // assemble GET request cvecprintf(rawsnd, "%s %s HTTP/1.1%s", head ? "HEAD" : "GET", url, crlf); cvecprintf(rawsnd, "Host: %s%s", hostname, crlf); cvecprintf(rawsnd, "Accept: */*%s", crlf); if(referrer) cvecprintf(rawsnd, "Referer: %s%s", referrer, crlf); if(useragent) cvecprintf(rawsnd, "User-Agent: %s%s", useragent, crlf); if(range > 0) cvecprintf(rawsnd, "Range: bytes=%d-%sTE: gzip%s", range, crlf, crlf); // content-encoding gzip for range requests is nonsense, so we'll ask for transfer-encoding instead (not that any server will deliver that...) else if(!head) cvecprintf(rawsnd, "Accept-Encoding: gzip%s", crlf); // ask for gzip only for full requests, because we intend to unzip instantly cvecprintf(rawsnd, "%s", crlf); // send request execcallback(0); ENetBuffer buf; buf.data = rawsnd.getbuf(); buf.dataLength = rawsnd.length(); while(buf.dataLength > 0) { enet_uint32 events = ENET_SOCKET_WAIT_SEND; if(enet_socket_wait(tcp, &events, 250) >= 0 && events) { int sent = enet_socket_send(tcp, NULL, &buf, 1); if(sent < 0) { if(!reconnected) { // line went dead, maybe the server closed it - try reconnecting once retry = true; break; } else GETERROR("connection failed"); } buf.data = (char *)buf.data + sent; buf.dataLength -= sent; tcp_age.start(); traffic += sent; lastresponse = to.elapsed(); } elapsedtime = to.elapsed(); if(elapsedtime > totaltimeout || elapsedtime > lastresponse + timeout) GETERROR("timeout 1"); if(execcallback(-float(elapsedtime - lastresponse) / timeout)) goto geterror; // show progress bar, check for user interrupt } // get response bool again = false, haveheader = false; if(!retry) for(;;) { elapsedtime = to.elapsed(); if(elapsedtime > totaltimeout || elapsedtime > lastresponse + timeout) GETERROR(elapsedtime > totaltimeout ? "timeout 2" : "timeout 3"); float progress = -float(elapsedtime - lastresponse) / timeout; enet_uint32 events = ENET_SOCKET_WAIT_RECEIVE; if(rawrec.length() > maxsize || datarec.length() > maxsize) break; if(enet_socket_wait(tcp, &events, 250) >= 0 && events) { if(rawrec.length() >= rawrec.capacity()) rawrec.reserve(4096); buf.data = rawrec.getbuf() + rawrec.length(); buf.dataLength = rawrec.capacity() - rawrec.length(); int recv = enet_socket_receive(tcp, NULL, &buf, 1); if(recv <= 0) { if(!haveheader && !reconnected) retry = true; // line may be half dead - retry once break; } rawrec.advance(recv); tcp_age.start(); traffic += recv; if((transferred += recv) > maxtransfer) GETERROR("transfer size exceeds limit"); lastresponse = to.elapsed(); // parsing received data rawrec.add('\0'); // append '\0' to use string functions safely - will be removed again if(!haveheader) { // still getting header size_t headendlen = strlen(lfcrlf); const char *endhead = strstr((const char *)rawrec.getbuf(), lfcrlf); if(!endhead && --headendlen) endhead = strstr((const char *)rawrec.getbuf(), "\n\n"); // we're tolerant to LF only line endings if(endhead) { size_t headlen = endhead - rawrec.getbuf() + headendlen; header = newstring(rawrec.getbuf(), headlen); rawrec.remove(0, headlen); haveheader = true; // parse header char *header_uc = filtertext(newstring(headlen), header, FTXT_TOUPPER, headlen); char *p = strstr(header, "HTTP/"); if(p) p = strchr(p, ' '); response = p ? atoi(p + 1) : -1; if(p) p = strchr(p, '\n'); if(!p) GETERROR("server error"); // header frame error if(response >= 300 && response < 308) // handle redirects { p = strstr(header_uc + (p - header), "LOCATION: "); if(p) p = header + (p - header_uc); DELSTRING(header_uc); if(++redirects > maxredirects || !p) GETERROR(p ? "too many redirects" : "redirect error"); // read redirect url disconnect(); p = strchr(p, ' ') + 1; char *r = strstr(p, "://"); if(r) p = r + 3; if((r = strchr(p, '/'))) { *r = '\0'; again = set_host(p); *r = '/'; p = r + strcspn(r, " \n\r"); *p = '\0'; const char *nurl = newstring(r); reset(1); url = nurl; } if(!again) GETERROR("bad redirect url"); break; // done receiving } // response was 2xx, check for some extras char *u = header_uc + (p - header), *f, *n; if((f = strstr(u, "TRANSFER-ENCODING: ")) && (n = strchr(f, LF))) { if((f = strstr(f, "CHUNKED")) && f < n) chunked = 1; if((f = strstr(f, "GZIP")) && f < n) gzipped = 1; // untested: I could not find a server who delivers that } if((f = strstr(u, "CONTENT-ENCODING: ")) && (n = strchr(f, LF)) && (f = strstr(f, "GZIP")) && f < n) gzipped = 1; if((f = strstr(u, "CONTENT-LENGTH: ")) && (f = strchr(f, ' '))) contentlength = atoi(f + 1); if((f = strstr(u, "CONTENT-RANGE: ")) && (n = strchr(f, LF)) && (f = strstr(f, "BYTES ")) && (f = strchr(f, ' ')) && f < n) offset = atoi(f + 1); DELSTRING(header_uc); } } if(haveheader) { // check if data is complete const char *d = rawrec.getbuf(), *e = d; if(chunked) { // n * "chunksize\r\nchunkdata\r\n" + "0\r\n\r\n" while(strchr(d, LF)) { int chunklen = (int) strtol(d, (char**) &e, 16); if(*e == CR) e++; if(*e == LF && rawrec.length() >= chunklen + (e - d) + 2 && (e[chunklen + 1] == LF || (e[chunklen + 1] == CR && e[chunklen + 2] == LF))) { // chunk is fully in buffer e++; loopi(chunklen) datarec.add(*e++); if(*e == CR) e++; if(*e++ != LF) GETERROR("chunk frame error"); rawrec.remove(0, int(e - d)); if(chunklen == 0) { contentlength = datarec.length(); content = &datarec; } } else break; } progress = float(datarec.length()) / (maxtransfer | 1); // not accurate, but moving } else { if(contentlength > 0) { progress = float(rawrec.length() - 1) / contentlength; // get a real progress bar if(rawrec.length() - 1 >= contentlength) content = &rawrec; } else progress = float(rawrec.length() - 1) / (maxtransfer | 1); // not accurate, but moving } } rawrec.drop(); } if(execcallback(progress)) goto geterror; // show progress bar, check for user interrupt if(content || (haveheader && head)) break; } if(retry && !reconnected) { // TCP connection showed some error before the response header was fully received: retry the connection once, it may have just been a timeout again = reconnected = true; reset(2); // only clear response values, not url disconnect(); // but close the socket retry = false; } if(again) continue; // redirect else break; } if(!content) content = &rawrec; // end by "server close connection" - this should maybe be flagged as error instead if(gzipped) { z_stream zs; memset(&zs, 0, sizeof(zs)); if(inflateInit2(&zs, 15 + 32) == Z_OK) { zs.next_in = (Bytef*)content->getbuf(); zs.avail_in = content->length(); uchar outbuf[1<<15]; int zstat; do { zs.next_out = (Bytef*)outbuf; zs.avail_out = sizeof(outbuf); zstat = inflate(&zs, Z_NO_FLUSH); if(zstat == Z_OK || zstat == Z_STREAM_END) { int got = sizeof(outbuf) - zs.avail_out; if(got > 0) { res += got; if(outvec) loopi(got) outvec->add(outbuf[i]); if(outstream) outstream->write(outbuf, got); } } else GETERROR("gunzip error"); if(res > maxsize) break; } while(zstat == Z_OK); inflateEnd(&zs); } } else { res = content->length(); if(outvec) outvec->insert(outvec->length(), (const uchar *)content->getbuf(), res); if(outstream) outstream->write(content->getbuf(), res); } geterror: if(res > maxsize) err = "output truncated"; elapsedtime = to.elapsed(); if(err) disconnect(); return err ? -1 : res; } char *urlencode(const char *s, bool strict) { vector d; while(*s) { if(isalnum(*s) || strchr("-_.~", *s) || (!strict && strchr(":/?#[]@!$&'()*+,;=", *s))) d.add(*s++); // see RFC 3986 2.2 else cvecprintf(d, "%%%02X", *s++); } d.add('\0'); return newstring(d.getbuf()); } // parse URLs: scheme:[//[user:password@]domain[:port]][/]path[?query][#fragment] void urlparse::set(const char *newurl) { DELSTRING(buf); char *p, *s = buf = newstring(newurl, strlen(newurl) + 3); scheme = userpassword = port = path = query = fragment = ""; filtertext(s, s, FTXT_NOWHITE); if((p = strstr(s, "://"))) // domain part is mandatory, which makes the double slash a given - if a scheme is specified { // scheme found scheme = s; *p = '\0'; s = p + 3; } if((p = strchr(s, '@'))) { // user:password found userpassword = s; *p = '\0'; s = p + 1; } domain = s; if(*s == '[' && (p = strchr(s, ']'))) s = p + 1; // [....] else while(isalnum(*s) || *s == '.' || *s == '-') s++; // skip domain if(*s == ':') { // port found *s = '\0'; port = ++s; while(isdigit(*s)) s++; } if(*s) { memmove(s + 2, s, strlen(s) + 1); *s++ = '\0'; // end domain or port string *s++ = '/'; // add mandatory slash for path if(*s != '/') s--; path = s; if((p = strchr(s, '?'))) { // query found *p++ = '\0'; query = s = p; } if((p = strchr(s, '#'))) { // fragment found *p++ = '\0'; fragment = s = p; } // fix path, if necessary size_t pl = strlen(path); if(pl < 2) path = ""; // ignore single slash else { p = (char *)path; unixpath(p); p += pl - 1; if(*p == '/') *p = '\0'; // remove trailing slash } } } assaultcube-1.2.0.2.1/source/src/hudgun.h000066400000000000000000000075031352165075300200720ustar00rootroot00000000000000VARP(nosway, 0, 0, 1); VARP(swayspeeddiv, 1, 105, 1000); VARP(swaymovediv, 1, 200, 1000); VARP(swayupspeeddiv, 1, 105, 1000); VARP(swayupmovediv, 1, 200, 1000); struct weaponmove { static vec swaydir; static int swaymillis, lastsway; float k_rot, kick; vec pos; int anim, basetime; weaponmove() : k_rot(0), kick(0), anim(0), basetime(0) { pos.x = pos.y = pos.z = 0.0f; } void calcmove(vec aimdir, int lastaction, playerent *p) { kick = k_rot = 0.0f; pos = p->o; if(!nosway) { float k = pow(0.7f, (lastmillis-lastsway)/10.0f); swaydir.mul(k); vec dv(p->vel); dv.mul((1-k)/max(p->vel.magnitude(), p->maxspeed)); dv.x *= 1.5f; dv.y *= 1.5f; dv.z *= 0.4f; swaydir.add(dv); pos.add(swaydir); } if(p->onfloor || p->onladder || p->inwater) swaymillis += lastmillis-lastsway; lastsway = lastmillis; if(p->weaponchanging) { anim = ANIM_GUN_RELOAD; basetime = p->weaponchanging; float progress = clamp((lastmillis - p->weaponchanging)/(float)weapon::weaponchangetime, 0.0f, 1.0f); k_rot = -90*sinf(progress*PI); } else if(p->weaponsel->reloading) { anim = ANIM_GUN_RELOAD; basetime = p->weaponsel->reloading; float reloadtime = (float)p->weaponsel->info.reloadtime, progress = clamp((lastmillis - p->weaponsel->reloading)/reloadtime, 0.0f, clamp(1.0f - (p->lastaction + p->weaponsel->gunwait - lastmillis)/reloadtime, 0.5f, 1.0f)); k_rot = -90*sinf(progress*PI); } else { anim = ANIM_GUN_IDLE; basetime = lastaction; int timediff = lastmillis-lastaction, animtime = min(p->weaponsel->gunwait, (int)p->weaponsel->info.attackdelay); vec sway = aimdir; float progress = 0.0f; float k_back = 0.0f; if(p->weaponsel==p->lastattackweapon) { progress = max(0.0f, min(1.0f, timediff/(float)animtime)); // f(x) = -sin(x-1.5)^3 kick = -sinf(pow((1.5f*progress)-1.5f,3)); if(p->crouching) kick *= 0.75f; if(p->lastaction) anim = p->weaponsel->modelanim(); } if(p->weaponsel->info.mdl_kick_rot || p->weaponsel->info.mdl_kick_back) { k_rot = p->weaponsel->info.mdl_kick_rot*kick; k_back = p->weaponsel->info.mdl_kick_back*kick/10; } if(nosway) sway.x = sway.y = sway.z = 0; else { float swayspeed = sinf((float)swaymillis/swayspeeddiv)/(swaymovediv/10.0f); float swayupspeed = cosf((float)swaymillis/swayupspeeddiv)/(swayupmovediv/10.0f); float plspeed = min(1.0f, sqrtf(p->vel.x*p->vel.x + p->vel.y*p->vel.y)); swayspeed *= plspeed/2; swayupspeed *= plspeed/2; swap(sway.x, sway.y); sway.y = -sway.y; swayupspeed = fabs(swayupspeed); // sway a semicirle only sway.z = 1.0f; sway.x *= swayspeed; sway.y *= swayspeed; sway.z *= swayupspeed; if(p->crouching) sway.mul(0.75f); } pos.x -= aimdir.x*k_back+sway.x; pos.y -= aimdir.y*k_back+sway.y; pos.z -= aimdir.z*k_back+sway.z; } } }; vec weaponmove::swaydir(0, 0, 0); int weaponmove::lastsway = 0, weaponmove::swaymillis = 0; void preload_hudguns() { loopi(NUMGUNS) { if(i == GUN_CPISTOL) continue; defformatstring(path)("weapons/%s", guns[i].modelname); loadmodel(path); } } assaultcube-1.2.0.2.1/source/src/jpegenc.h000066400000000000000000000612261352165075300202150ustar00rootroot00000000000000#ifndef JPEGENC #define JPEGENC // Toca: JPEG encoder, jpeglib independent ***EXPERIMENTAL*** // Based on work by Cristian Cuturicu // http://www.wotsit.org/download.asp?f=jpeg&sc=335837440 typedef uint8_t BYTE; typedef int8_t SBYTE; typedef int16_t SWORD; typedef uint16_t WORD; typedef int32_t SDWORD; typedef struct { BYTE length; WORD value;} bitstring; #define Y(R,G,B) ((BYTE)( (YRtab[(R)]+YGtab[(G)]+YBtab[(B)])>>16 ) - 128); #define Cb(R,G,B) ((BYTE)( (CbRtab[(R)]+CbGtab[(G)]+CbBtab[(B)])>>16 )); #define Cr(R,G,B) ((BYTE)( (CrRtab[(R)]+CrGtab[(G)]+CrBtab[(B)])>>16 )); #define writebyte(b) fp_jpeg_stream->putchar(b); #define writeword(w) writebyte((w)/256);writebyte((w)%256); struct APP0infotype { WORD marker; WORD length; BYTE JFIFsignature[5]; BYTE versionhi; BYTE versionlo; BYTE xyunits; WORD xdensity; WORD ydensity; BYTE thumbnwidth; BYTE thumbnheight; APP0infotype() { marker = 0xFFE0; length = 16; JFIFsignature[0] ='J'; JFIFsignature[1] ='F'; JFIFsignature[2] ='I'; JFIFsignature[3] ='F'; JFIFsignature[4] = 0; versionhi = 1; versionlo = 1; xyunits = 0; xdensity = 1; ydensity = 1; thumbnwidth = 0; thumbnheight = 0; }; }; struct APP1infotype { WORD marker; WORD length; const char *sig1, *sig2; APP1infotype() { marker = 0xFFE1; length = 46; sig1 = "Exif\0\0MM"; sig2 = "\0\x2a\0\0\0\10\0\1\1\x31\0\2\0\0\0\14" "\0\0\0\x1a\0\0\0\0\101\x73\x73\141\165" "\154\164\103\165\142\145"; }; }; struct SOF0infotype { WORD marker; WORD length; BYTE precision ; WORD height ; WORD width; BYTE nrofcomponents; BYTE IdY; BYTE HVY; BYTE QTY; BYTE IdCb; BYTE HVCb; BYTE QTCb; BYTE IdCr; BYTE HVCr; BYTE QTCr; SOF0infotype() { marker = 0xFFC0; length = 17; precision = 8; height = 0; width = 0; nrofcomponents = 3; IdY = 1; HVY = 0x11; QTY = 0; IdCb = 2; HVCb = 0x11; QTCb = 1; IdCr = 3; HVCr = 0x11; QTCr = 1; } }; struct DQTinfotype { WORD marker; WORD length; BYTE QTYinfo; BYTE Ytable[64]; BYTE QTCbinfo; BYTE Cbtable[64]; DQTinfotype() { marker = 0xFFDB; length = 132; QTYinfo = 0; Ytable[0] = 0; QTCbinfo = 1; Cbtable[0] = 0; } }; struct DHTinfotype { WORD marker; WORD length; BYTE HTYDCinfo; BYTE YDC_nrcodes[16]; BYTE YDC_values[12]; BYTE HTYACinfo; BYTE YAC_nrcodes[16]; BYTE YAC_values[162]; BYTE HTCbDCinfo; BYTE CbDC_nrcodes[16]; BYTE CbDC_values[12]; BYTE HTCbACinfo; BYTE CbAC_nrcodes[16]; BYTE CbAC_values[162]; DHTinfotype() { marker = 0xFFC4; length = 0x01A2; HTYDCinfo = 0; YDC_nrcodes[0] = 0; YDC_values[0] = 0; HTYACinfo = 0x10; YAC_nrcodes[0] = 0; YAC_values[0] = 0; HTCbDCinfo = 1; CbDC_nrcodes[0] = 0; CbDC_values[0] = 0; HTCbACinfo = 0x11; CbAC_nrcodes[0] = 0; CbAC_values[0] = 0; } }; struct SOSinfotype { WORD marker; WORD length; BYTE nrofcomponents; BYTE IdY; BYTE HTY; BYTE IdCb; BYTE HTCb; BYTE IdCr; BYTE HTCr; BYTE Ss,Se,Bf; SOSinfotype() { marker = 0xFFDA; length = 12; nrofcomponents = 3; IdY = 1; HTY = 0; IdCb = 2; HTCb = 0x11; IdCr = 3; HTCr = 0x11; Ss = 0; Se = 0x3F; Bf = 0; } }; class jpegenc { private: static BYTE zigzag[]; static BYTE std_luminance_qt[]; static BYTE std_chrominance_qt[]; static BYTE std_dc_luminance_nrcodes[]; static BYTE std_dc_luminance_values[]; static BYTE std_dc_chrominance_nrcodes[]; static BYTE std_dc_chrominance_values[]; static BYTE std_ac_luminance_nrcodes[]; static BYTE std_ac_luminance_values[]; static BYTE std_ac_chrominance_nrcodes[]; static BYTE std_ac_chrominance_values[]; static WORD mask[]; APP0infotype APP0info; APP1infotype APP1info; SOF0infotype SOF0info; DQTinfotype DQTinfo; SOSinfotype SOSinfo; DHTinfotype DHTinfo; BYTE bytenew; SBYTE bytepos; void write_APP0info(void); void write_APP1info(void); void write_SOF0info(void); void write_DQTinfo(void); void set_quant_table(BYTE *basic_table, BYTE scale_factor, BYTE *newtable); void set_DQTinfo(int quality); void write_DHTinfo(void); void set_DHTinfo(void); void write_SOSinfo(void); void write_comment(const char *comment); void writebits(bitstring bs); void compute_Huffman_table(BYTE *nrcodes, BYTE *std_table, bitstring *HT); void init_Huffman_tables(void); int set_numbers_category_and_bitcode(); void precalculate_YCbCr_tables(); void prepare_quant_tables(); void fdct_and_quantization(SBYTE *data, float *fdtbl, SWORD *outdata); void process_DU(SBYTE *ComponentDU, float *fdtbl,SWORD *DC, bitstring *HTDC, bitstring *HTAC); void load_data_units_from_RGB_buffer(WORD xpos, WORD ypos); void main_encoder(void); void init_all(int qfactor); public: jpegenc() { bytenew = 0; bytepos = 7; } bitstring YDC_HT[12]; bitstring CbDC_HT[12]; bitstring YAC_HT[256]; bitstring CbAC_HT[256]; BYTE *category_alloc; BYTE *category; bitstring *bitcode_alloc; bitstring *bitcode; SDWORD YRtab[256], YGtab[256], YBtab[256]; SDWORD CbRtab[256], CbGtab[256], CbBtab[256]; SDWORD CrRtab[256], CrGtab[256], CrBtab[256]; float fdtbl_Y[64]; float fdtbl_Cb[64]; SBYTE YDU[64]; SBYTE CbDU[64]; SBYTE CrDU[64]; SWORD DU_DCT[64]; SWORD DU[64]; BYTE *RGB_buffer; //image to be encoded WORD width, height; //image dimensions divisible by 8 int pitch; stream *fp_jpeg_stream; int encode(const char *filename, SDL_Surface *image, int jpegquality, const char *comment); }; BYTE jpegenc::zigzag[64] = { 0, 1, 5, 6,14,15,27,28, 2, 4, 7,13,16,26,29,42, 3, 8,12,17,25,30,41,43, 9,11,18,24,31,40,44,53, 10,19,23,32,39,45,52,54, 20,22,33,38,46,51,55,60, 21,34,37,47,50,56,59,61, 35,36,48,49,57,58,62,63 }; BYTE jpegenc::std_luminance_qt[64] = { 16, 11, 10, 16, 24, 40, 51, 61, 12, 12, 14, 19, 26, 58, 60, 55, 14, 13, 16, 24, 40, 57, 69, 56, 14, 17, 22, 29, 51, 87, 80, 62, 18, 22, 37, 56, 68, 109, 103, 77, 24, 35, 55, 64, 81, 104, 113, 92, 49, 64, 78, 87, 103, 121, 120, 101, 72, 92, 95, 98, 112, 100, 103, 99 }; BYTE jpegenc::std_chrominance_qt[64] = { 17, 18, 24, 47, 99, 99, 99, 99, 18, 21, 26, 66, 99, 99, 99, 99, 24, 26, 56, 99, 99, 99, 99, 99, 47, 66, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99 }; BYTE jpegenc::std_dc_luminance_nrcodes[17] = {0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0}; BYTE jpegenc::std_dc_luminance_values[12] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; BYTE jpegenc::std_dc_chrominance_nrcodes[17] = {0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0}; BYTE jpegenc::std_dc_chrominance_values[12] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; BYTE jpegenc::std_ac_luminance_nrcodes[17] = {0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,0x7d }; BYTE jpegenc::std_ac_luminance_values[162] = { 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa }; BYTE jpegenc::std_ac_chrominance_nrcodes[17] = {0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,0x77}; BYTE jpegenc::std_ac_chrominance_values[162] = { 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa }; WORD jpegenc::mask[16] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768}; void jpegenc::write_APP0info() //Nothing to overwrite for APP0info { writeword(APP0info.marker); writeword(APP0info.length); writebyte('J'); writebyte('F'); writebyte('I'); writebyte('F'); writebyte(0); writebyte(APP0info.versionhi); writebyte(APP0info.versionlo); writebyte(APP0info.xyunits); writeword(APP0info.xdensity); writeword(APP0info.ydensity); writebyte(APP0info.thumbnwidth); writebyte(APP0info.thumbnheight); } void jpegenc::write_APP1info() { writeword(APP1info.marker); writeword(APP1info.length); loopi(8) writebyte(APP1info.sig1[i]); loopi(APP1info.length - 10) writebyte(APP1info.sig2[i]); } void jpegenc::write_SOF0info() { writeword(SOF0info.marker); writeword(SOF0info.length); writebyte(SOF0info.precision); writeword(SOF0info.height); //Image height writeword(SOF0info.width); //Image width writebyte(SOF0info.nrofcomponents); writebyte(SOF0info.IdY); writebyte(SOF0info.HVY); writebyte(SOF0info.QTY); writebyte(SOF0info.IdCb); writebyte(SOF0info.HVCb); writebyte(SOF0info.QTCb); writebyte(SOF0info.IdCr); writebyte(SOF0info.HVCr); writebyte(SOF0info.QTCr); } void jpegenc::write_DQTinfo() { BYTE i; writeword(DQTinfo.marker); writeword(DQTinfo.length); writebyte(DQTinfo.QTYinfo); for (i=0; i<64; i++) writebyte(DQTinfo.Ytable[i]); writebyte(DQTinfo.QTCbinfo); for (i=0; i<64; i++) writebyte(DQTinfo.Cbtable[i]); } void jpegenc::set_quant_table(BYTE *basic_table, BYTE scale_factor, BYTE *newtable) { BYTE i; long temp; for (i=0; i<64; i++) { temp = ((long) basic_table[i] * scale_factor + 50L) / 100L; if (temp <= 0L) temp = 1L; if (temp > 255L) temp = 255L; newtable[zigzag[i]] = (BYTE) temp; } } void jpegenc::set_DQTinfo(int quality) { // Convert user 0-100 rating to percentage scaling if (quality <= 0) quality = 1; if (quality > 100) quality = 100; if (quality < 50) quality = 5000 / quality; else quality = 200 - quality*2; DQTinfo.marker = 0xFFDB; DQTinfo.length = 132; DQTinfo.QTYinfo = 0; DQTinfo.QTCbinfo = 1; set_quant_table(std_luminance_qt, quality, DQTinfo.Ytable); set_quant_table(std_chrominance_qt, quality, DQTinfo.Cbtable); } void jpegenc::write_DHTinfo() { BYTE i; writeword(DHTinfo.marker); writeword(DHTinfo.length); writebyte(DHTinfo.HTYDCinfo); for (i=0; i<16; i++) writebyte(DHTinfo.YDC_nrcodes[i]); for (i=0; i<12; i++) writebyte(DHTinfo.YDC_values[i]); writebyte(DHTinfo.HTYACinfo); for (i=0; i<16; i++) writebyte(DHTinfo.YAC_nrcodes[i]); for (i=0; i<162; i++) writebyte(DHTinfo.YAC_values[i]); writebyte(DHTinfo.HTCbDCinfo); for (i=0; i<16; i++) writebyte(DHTinfo.CbDC_nrcodes[i]); for (i=0; i<12; i++) writebyte(DHTinfo.CbDC_values[i]); writebyte(DHTinfo.HTCbACinfo); for (i=0; i<16; i++) writebyte(DHTinfo.CbAC_nrcodes[i]); for (i=0; i<162; i++) writebyte(DHTinfo.CbAC_values[i]); } void jpegenc::set_DHTinfo() { BYTE i; DHTinfo.marker = 0xFFC4; DHTinfo.length = 0x01A2; DHTinfo.HTYDCinfo = 0; for (i=0; i<16; i++) DHTinfo.YDC_nrcodes[i] = std_dc_luminance_nrcodes[i+1]; for (i=0; i<12; i++) DHTinfo.YDC_values[i] = std_dc_luminance_values[i]; DHTinfo.HTYACinfo = 0x10; for (i=0; i<16; i++) DHTinfo.YAC_nrcodes[i] = std_ac_luminance_nrcodes[i+1]; for (i=0; i<162; i++) DHTinfo.YAC_values[i] = std_ac_luminance_values[i]; DHTinfo.HTCbDCinfo = 1; for (i=0; i<16; i++) DHTinfo.CbDC_nrcodes[i] = std_dc_chrominance_nrcodes[i+1]; for (i=0; i<12; i++) DHTinfo.CbDC_values[i] = std_dc_chrominance_values[i]; DHTinfo.HTCbACinfo = 0x11; for (i=0; i<16; i++) DHTinfo.CbAC_nrcodes[i] = std_ac_chrominance_nrcodes[i+1]; for (i=0; i<162; i++) DHTinfo.CbAC_values[i] = std_ac_chrominance_values[i]; } void jpegenc::write_SOSinfo() //Nothing to overwrite for SOSinfo { writeword(SOSinfo.marker); writeword(SOSinfo.length); writebyte(SOSinfo.nrofcomponents); writebyte(SOSinfo.IdY); writebyte(SOSinfo.HTY); writebyte(SOSinfo.IdCb); writebyte(SOSinfo.HTCb); writebyte(SOSinfo.IdCr); writebyte(SOSinfo.HTCr); writebyte(SOSinfo.Ss); writebyte(SOSinfo.Se); writebyte(SOSinfo.Bf); } void jpegenc::write_comment(const char *comment) { WORD i, length; writeword(0xFFFE); length = (WORD) strlen((const char *)comment); writeword(length + 2); for (i=0; i= 0) { if (value & mask[posval]) bytenew |= mask[bytepos]; posval--; bytepos--; if (bytepos < 0) { if (bytenew == 0xFF) { writebyte(0xFF); writebyte(0); } else writebyte(bytenew); bytepos = 7; bytenew = 0; } } } void jpegenc::compute_Huffman_table(BYTE *nrcodes, BYTE *std_table, bitstring *HT) { BYTE k,j; BYTE pos_in_table; WORD codevalue; codevalue = 0; pos_in_table = 0; for (k=1; k<=16; k++) { for (j=1; j<=nrcodes[k]; j++) { HT[std_table[pos_in_table]].value = codevalue; HT[std_table[pos_in_table]].length = k; pos_in_table++; codevalue++; } codevalue <<= 1; } } void jpegenc::init_Huffman_tables() { compute_Huffman_table(std_dc_luminance_nrcodes, std_dc_luminance_values, YDC_HT); compute_Huffman_table(std_ac_luminance_nrcodes, std_ac_luminance_values, YAC_HT); compute_Huffman_table(std_dc_chrominance_nrcodes, std_dc_chrominance_values, CbDC_HT); compute_Huffman_table(std_ac_chrominance_nrcodes, std_ac_chrominance_values, CbAC_HT); } int jpegenc::set_numbers_category_and_bitcode() { SDWORD nr; SDWORD nrlower, nrupper; BYTE cat; category_alloc = (BYTE *)malloc(65535*sizeof(BYTE)); if (category_alloc == NULL) return -1; category = category_alloc + 32767; bitcode_alloc=(bitstring *)malloc(65535*sizeof(bitstring)); if (bitcode_alloc==NULL) { free(category_alloc); return -1; } bitcode = bitcode_alloc + 32767; nrlower = 1; nrupper = 2; for (cat=1; cat<=15; cat++) { for (nr=nrlower; nr= 0; ctr--) { tmp0 = dataptr[0] + dataptr[7]; tmp7 = dataptr[0] - dataptr[7]; tmp1 = dataptr[1] + dataptr[6]; tmp6 = dataptr[1] - dataptr[6]; tmp2 = dataptr[2] + dataptr[5]; tmp5 = dataptr[2] - dataptr[5]; tmp3 = dataptr[3] + dataptr[4]; tmp4 = dataptr[3] - dataptr[4]; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp1 + tmp2; tmp12 = tmp1 - tmp2; dataptr[0] = tmp10 + tmp11; dataptr[4] = tmp10 - tmp11; z1 = (tmp12 + tmp13) * ((float) 0.707106781); dataptr[2] = tmp13 + z1; dataptr[6] = tmp13 - z1; tmp10 = tmp4 + tmp5; tmp11 = tmp5 + tmp6; tmp12 = tmp6 + tmp7; z5 = (tmp10 - tmp12) * ((float) 0.382683433); z2 = ((float) 0.541196100) * tmp10 + z5; z4 = ((float) 1.306562965) * tmp12 + z5; z3 = tmp11 * ((float) 0.707106781); z11 = tmp7 + z3; z13 = tmp7 - z3; dataptr[5] = z13 + z2; dataptr[3] = z13 - z2; dataptr[1] = z11 + z4; dataptr[7] = z11 - z4; dataptr += 8; } dataptr = datafloat; for (ctr = 7; ctr >= 0; ctr--) { tmp0 = dataptr[0] + dataptr[56]; tmp7 = dataptr[0] - dataptr[56]; tmp1 = dataptr[8] + dataptr[48]; tmp6 = dataptr[8] - dataptr[48]; tmp2 = dataptr[16] + dataptr[40]; tmp5 = dataptr[16] - dataptr[40]; tmp3 = dataptr[24] + dataptr[32]; tmp4 = dataptr[24] - dataptr[32]; tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; tmp11 = tmp1 + tmp2; tmp12 = tmp1 - tmp2; dataptr[0] = tmp10 + tmp11; dataptr[32] = tmp10 - tmp11; z1 = (tmp12 + tmp13) * ((float) 0.707106781); dataptr[16] = tmp13 + z1; dataptr[48] = tmp13 - z1; tmp10 = tmp4 + tmp5; tmp11 = tmp5 + tmp6; tmp12 = tmp6 + tmp7; z5 = (tmp10 - tmp12) * ((float) 0.382683433); z2 = ((float) 0.541196100) * tmp10 + z5; z4 = ((float) 1.306562965) * tmp12 + z5; z3 = tmp11 * ((float) 0.707106781); z11 = tmp7 + z3; z13 = tmp7 - z3; dataptr[40] = z13 + z2; dataptr[24] = z13 - z2; dataptr[8] = z11 + z4; dataptr[56] = z11 - z4; dataptr++; } for (i = 0; i < 64; i++) { temp = datafloat[i] * fdtbl[i]; outdata[i] = (SWORD) ((SWORD)(temp + 16384.5) - 16384); } } void jpegenc::process_DU(SBYTE *ComponentDU,float *fdtbl,SWORD *DC, bitstring *HTDC,bitstring *HTAC) { bitstring EOB = HTAC[0x00]; bitstring M16zeroes = HTAC[0xF0]; BYTE i; BYTE startpos; BYTE end0pos; BYTE nrzeroes; BYTE nrmarker; SWORD Diff; fdct_and_quantization(ComponentDU, fdtbl, DU_DCT); for (i=0; i<64; i++) DU[zigzag[i]]=DU_DCT[i]; Diff = DU[0] - *DC; *DC = DU[0]; if (Diff == 0) writebits(HTDC[0]); else { writebits(HTDC[category[Diff]]); writebits(bitcode[Diff]); } for (end0pos=63; (end0pos>0)&&(DU[end0pos]==0); end0pos--) ; i = 1; while (i <= end0pos) { startpos = i; for (; (DU[i]==0) && (i<=end0pos); i++) ; nrzeroes = i - startpos; if (nrzeroes >= 16) { for (nrmarker=1; nrmarker<=nrzeroes/16; nrmarker++) writebits(M16zeroes); nrzeroes = nrzeroes%16; } writebits(HTAC[nrzeroes*16+category[DU[i]]]); writebits(bitcode[DU[i]]); i++; } if (end0pos != 63) writebits(EOB); } void jpegenc::load_data_units_from_RGB_buffer(WORD xpos, WORD ypos) { BYTE x, y; BYTE pos = 0; BYTE R, G, B, *location0 = RGB_buffer + (ypos * pitch + xpos * 3); WORD width8 = width - xpos, height8 = height - ypos; for (y=0; y<8; y++) { BYTE *location = location0; for (x=0; x<8; x++) { if(x < width8 && y < height8) { R = *location++; G = *location++; B = *location++; } else R = G = B = 0; YDU[pos] = Y(R,G,B); CbDU[pos] = Cb(R,G,B); CrDU[pos] = Cr(R,G,B); pos++; } location0 += pitch; } } void jpegenc::main_encoder() { SWORD DCY = 0, DCCb = 0, DCCr = 0; WORD xpos, ypos; for (ypos=0; ypospixels; width = image->w; height = image->h; pitch = image->pitch; fp_jpeg_stream = openfile(filename,"wb"); if(!fp_jpeg_stream) { return -1; } bitstring fillbits; set_DQTinfo(jpegquality); set_DHTinfo(); init_Huffman_tables(); if(set_numbers_category_and_bitcode() < 0) { delete fp_jpeg_stream; return -2; } precalculate_YCbCr_tables(); prepare_quant_tables(); SOF0info.width = width; SOF0info.height = height; writeword(0xFFD8); write_APP0info(); write_APP1info(); if(comment) write_comment(comment); write_DQTinfo(); write_SOF0info(); write_DHTinfo(); write_SOSinfo(); bytenew = 0; // current byte bytepos = 7; // bit position in this byte main_encoder(); if (bytepos >= 0) { fillbits.length = bytepos + 1; fillbits.value = (1<<(bytepos+1)) - 1; writebits(fillbits); } writeword(0xFFD9); free(category_alloc); free(bitcode_alloc); delete fp_jpeg_stream; return 0; }; #endif assaultcube-1.2.0.2.1/source/src/log.cpp000066400000000000000000000100731352165075300177100ustar00rootroot00000000000000// server-side logging of events #include "cube.h" #if !defined(WIN32) && !defined(__APPLE__) #include #include #define AC_USE_SYSLOG static const int facilities[] = { LOG_LOCAL0, LOG_LOCAL1, LOG_LOCAL2, LOG_LOCAL3, LOG_LOCAL4, LOG_LOCAL5, LOG_LOCAL6, LOG_LOCAL7 }; static const int levels[] = { LOG_DEBUG, LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERR }; #else static const int levels[] = { 7, 7, 6, 4, 3 }; ENetSocket logsock = ENET_SOCKET_NULL; ENetAddress logdest = { ENET_HOST_ANY, 514 }; #endif static const char *levelprefix[] = { "", "", "", "WARNING: ", "ERROR: " }; static const char *levelname[] = { "DEBUG", "VERBOSE", "INFO", "WARNING", "ERROR", "DISABLED" }; static FILE *fp = NULL; static string filepath, ident; static int facility = -1, #ifdef AC_USE_SYSLOG filethreshold = ACLOG_NUM, syslogthreshold = ACLOG_INFO, #else filethreshold = ACLOG_INFO, syslogthreshold = ACLOG_NUM, #endif consolethreshold = ACLOG_INFO; static bool timestamp = false, enabled = false; bool initlogging(const char *identity, int facility_, int consolethres, int filethres, int syslogthres, bool logtimestamp) { facility = facility_; timestamp = logtimestamp; if(consolethres >= 0) consolethreshold = min(consolethres, (int)ACLOG_NUM); if(filethres >= 0) filethreshold = min(filethres, (int)ACLOG_NUM); if(syslogthres >= 0) syslogthreshold = min(syslogthres, (int)ACLOG_NUM); facility &= 7; formatstring(ident)("AssaultCube[%s]", identity); if(syslogthreshold < ACLOG_NUM) { #ifdef AC_USE_SYSLOG openlog(ident, LOG_NDELAY, facilities[facility]); #else if((logsock = enet_socket_create(ENET_SOCKET_TYPE_DATAGRAM)) == ENET_SOCKET_NULL || enet_address_set_host(&logdest, "localhost") < 0) syslogthreshold = ACLOG_NUM; #endif } formatstring(filepath)("serverlog_%s_%s.txt", timestring(true), identity); if(fp) { fclose(fp); fp = NULL; } if(filethreshold < ACLOG_NUM) { fp = fopen(filepath, "w"); if(!fp) printf("failed to open \"%s\" for writing\n", filepath); } defformatstring(msg)("logging started: console(%s), file(%s", levelname[consolethreshold], levelname[fp ? filethreshold : ACLOG_NUM]); if(fp) concatformatstring(msg, ", \"%s\"", filepath); concatformatstring(msg, "), syslog(%s", levelname[syslogthreshold]); if(syslogthreshold < ACLOG_NUM) concatformatstring(msg, ", \"%s\", local%d", ident, facility); concatformatstring(msg, "), timestamp(%s)", timestamp ? "ENABLED" : "DISABLED"); enabled = consolethreshold < ACLOG_NUM || fp || syslogthreshold < ACLOG_NUM; if(enabled) printf("%s\n", msg); return enabled; } void exitlogging() { if(fp) { fclose(fp); fp = NULL; } #ifdef AC_USE_SYSLOG if(syslogthreshold < ACLOG_NUM) closelog(); #endif syslogthreshold = ACLOG_NUM; enabled = false; } bool logline(int level, const char *msg, ...) { if(!enabled) return false; if(level < 0 || level >= ACLOG_NUM) return false; defvformatstring(sf, msg, msg); filtertext(sf, sf, FTXT__LOG); bool logtocon = consolethreshold <= level, logtofile = fp && filethreshold <= level, logtosyslog = syslogthreshold <= level; const char *ts = timestamp ? timestring(true, "%b %d %H:%M:%S ") : "", *ld = levelprefix[level]; char *p, *l = sf; do { // break into single lines first if((p = strchr(l, '\n'))) *p = '\0'; if(logtocon) printf("%s%s%s\n", ts, ld, l); if(logtofile) fprintf(fp, "%s%s%s\n", ts, ld, l); if(logtosyslog) #ifdef AC_USE_SYSLOG syslog(levels[level], "%s", l); #else { defformatstring(text)("<%d>%s: %s", (16 + facility) * 8 + levels[level], ident, l); // no TIMESTAMP, no hostname: syslog will add this ENetBuffer buf; buf.data = text; buf.dataLength = strlen(text); enet_socket_send(logsock, &logdest, &buf, 1); } #endif l = p + 1; } while(p); #ifdef _DEBUG if(logtocon) fflush(stdout); if(logtofile) fflush(fp); #endif return logtocon; } assaultcube-1.2.0.2.1/source/src/main.cpp000066400000000000000000001401601352165075300200540ustar00rootroot00000000000000// main.cpp: initialisation & main loop #include "cube.h" void cleanup(char *msg) // single program exit point; { if(clientlogfile) clientlogfile->fflush(); if(!msg) { cleanupclient(); audiomgr.soundcleanup(); cleanupserver(); extern void cleargamma(); cleargamma(); } SDL_ShowCursor(SDL_TRUE); SDL_SetRelativeMouseMode(SDL_FALSE); if(msg) { #ifdef WIN32 MessageBox(NULL, msg, "AssaultCube fatal error", MB_OK|MB_SYSTEMMODAL|MB_ICONERROR); #else printf("%s", msg); #endif if(clientlogfile) { clientlogfile->printf("%s\n", msg); dumpexecutionstack(clientlogfile); } } SDL_Quit(); } VAR(resetcfg, 0, 0, 1); void quit() // normal exit { if(clientlogfile) clientlogfile->fflush(); const char *onquit = getalias("onQuit"); setcontext("hook", "onQuit"); if(onquit && onquit[0]) execute(onquit); resetcontext(); alias("onQuit", ""); alias("mapstartonce", ""); extern void writeinitcfg(); writeinitcfg(); writeservercfg(); writepcksourcecfg(); if(resetcfg) deletecfg(); else writecfg(); savehistory(); writemapmodelattributes(); entropy_save(); writeallxmaps(); cleanup(NULL); popscontext(); DELETEP(clientlogfile); exit(EXIT_SUCCESS); } COMMAND(quit, ""); void fatal(const char *s, ...) // failure exit { static int errors = 0; errors++; if(errors <= 2) { defvformatstring(msg,s,s); if(errors <= 1) { defvformatstring(msg,s,s); defformatstring(msgerr)("%s (%s)\n", msg, SDL_GetError()); cleanup(msgerr); } else puts(msg); } DELETEP(clientlogfile); exit(EXIT_FAILURE); } static int initing = NOT_INITING; static bool restoredinits = false; bool initwarning(const char *desc, int level, int type) { if(initing < level) { addchange(desc, type); return true; } return false; } SDL_Window *screen = NULL; SDL_GLContext glcontext = 0; VAR(screenw, 1, 0, 0); // actual current resolution of screen/window VAR(screenh, 1, 0, 0); #define SCR_MINW 320 #define SCR_MINH 200 #define SCR_MAXW 10000 #define SCR_MAXH 10000 VARF(scr_w, SCR_MINW, -1, SCR_MAXW, initwarning("screen resolution")); // screen or window resolution, except for "fullscreen desktop" mode VARF(scr_h, SCR_MINH, -1, SCR_MAXH, initwarning("screen resolution")); VARF(depthbits, 0, 0, 32, initwarning("depth-buffer precision")); VARF(stencilbits, 0, 0, 32, initwarning("stencil-buffer precision")); VARF(fsaa, -1, -1, 16, initwarning("anti-aliasing")); VARF(vsync, -1, -1, 1, initwarning("vertical sync")); VAR(desktopw, 1, 0, 0); // resolution of desktop (assumed to be maximum resolution) VAR(desktoph, 1, 0, 0); static bool grabinput = false, minimized = false, emulaterelativemouse = false, centerwindow = true; void inputgrab(bool on) { bool wasemul = emulaterelativemouse; emulaterelativemouse = SDL_SetRelativeMouseMode(on ? SDL_TRUE : SDL_FALSE) < 0 && on; // if SDL_SetRelativeMouseMode fails, try the old fashioned way if(wasemul || emulaterelativemouse) SDL_ShowCursor(on ? SDL_DISABLE : SDL_ENABLE); } void setfullscreen(bool enable) { if(!screen) return; if(enable == !(SDL_GetWindowFlags(screen) & SDL_WINDOW_FULLSCREEN)) { extern int fullscreendesktop; SDL_SetWindowFullscreen(screen, enable ? (fullscreendesktop ? SDL_WINDOW_FULLSCREEN_DESKTOP : SDL_WINDOW_FULLSCREEN) : 0); inputgrab(grabinput = enable || grabinput); if(!enable) SDL_SetWindowSize(screen, scr_w, scr_h); if(!enable && centerwindow) SDL_SetWindowPosition(screen, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); } } VARF(fullscreen, 0, 0, 1, setfullscreen(fullscreen != 0)); void resetfullscreen() { setfullscreen(false); setfullscreen(true); } VARF(fullscreendesktop, 0, 0, 1, if(fullscreen) resetfullscreen()); SVARFP(lang, "en", filterlang(lang, lang)); void writeinitcfg() { if(!restoredinits) return; filerotate("config/init", "cfg", CONFIGROTATEMAX); // keep five old init config sets stream *f = openfile(path("config/init.cfg", true), "w"); if(!f) return; f->printf("// automatically written on exit, DO NOT MODIFY\n// modify settings in game\n"); f->printf("fullscreen %d\n", fullscreen); f->printf("fullscreendesktop %d\n", fullscreendesktop); f->printf("scr_w %d\n", scr_w); f->printf("scr_h %d\n", scr_h); f->printf("depthbits %d\n", depthbits); f->printf("stencilbits %d\n", stencilbits); f->printf("fsaa %d\n", fsaa); f->printf("vsync %d\n", vsync); extern int audio, soundchannels, igraphdefaultframetime; f->printf("audio %d\n", audio > 0 ? 1 : 0); f->printf("soundchannels %d\n", soundchannels); f->printf("igraphdefaultframetime %d\n", igraphdefaultframetime); if(lang && *lang) f->printf("lang %s\n", lang); extern void writezipmodconfig(stream *f); writezipmodconfig(f); delete f; } #if 0 VARP(highprocesspriority, 0, 1, 1); void setprocesspriority(bool high) { #if defined(WIN32) && !defined(_DEBUG) SetPriorityClass(GetCurrentProcess(), high && highprocesspriority && fullscreen ? HIGH_PRIORITY_CLASS : NORMAL_PRIORITY_CLASS); #endif } #endif VARP(pngcompress, 0, 9, 9); void writepngchunk(stream *f, const char *type, const void *data = NULL, uint len = 0) { f->putbig(len); f->write(type, 4); if(data) f->write(data, len); uint crc = crc32(0, Z_NULL, 0); crc = ~crc32(crc, (const Bytef *)type, 4); if(data) loopi(len) enet_crc32_inc(&crc, ((const uchar *)data)[i]); f->putbig(~crc); } int save_png(const char *filename, SDL_Surface *image) { uchar *data = (uchar *)image->pixels; int iw = image->w, ih = image->h, pitch = image->pitch; stream *f = openfile(filename, "wb"); if(!f) { conoutf("could not write to %s", filename); return -1; } const char *scores = asciiscores(true); uchar signature[] = { 137, 80, 78, 71, 13, 10, 26, 10 }; f->write(signature, sizeof(signature)); struct pngihdr { uint width, height; uchar bitdepth, colortype, compress, filter, interlace; } ihdr = { bigswap(iw), bigswap(ih), 8, 2, 0, 0, 0 }; writepngchunk(f, "IHDR", (uchar *)&ihdr, 13); int idat = f->tell(); uint len = 0; f->write("\0\0\0\0IDAT", 8); uint crc = crc32(0, Z_NULL, 0); crc = crc32(crc, (const Bytef *)"IDAT", 4); z_stream z; z.zalloc = NULL; z.zfree = NULL; z.opaque = NULL; if(deflateInit(&z, pngcompress) != Z_OK) goto error; uchar buf[1<<12]; z.next_out = (Bytef *)buf; z.avail_out = sizeof(buf); loopi(ih) { uchar filter = 0; loopj(2) { z.next_in = j ? (Bytef *)data + i*pitch : (Bytef *)&filter; z.avail_in = j ? iw*3 : 1; while(z.avail_in > 0) { if(deflate(&z, Z_NO_FLUSH) != Z_OK) goto cleanuperror; #define FLUSHZ do { \ int flush = sizeof(buf) - z.avail_out; \ crc = crc32(crc, buf, flush); \ len += flush; \ f->write(buf, flush); \ z.next_out = (Bytef *)buf; \ z.avail_out = sizeof(buf); \ } while(0) FLUSHZ; } } } for(;;) { int err = deflate(&z, Z_FINISH); if(err != Z_OK && err != Z_STREAM_END) goto cleanuperror; FLUSHZ; if(err == Z_STREAM_END) break; } deflateEnd(&z); f->seek(idat, SEEK_SET); f->putbig(len); f->seek(0, SEEK_END); f->putbig(crc); writepngchunk(f, "tEXt", "\123o\165rc\145\0\101ss\141" "\165\154\164\103\165\142\145", 18); writepngchunk(f, "tEXt", scores - 8, strlen(scores) + 8); writepngchunk(f, "IEND"); delete f; return 0; cleanuperror: deflateEnd(&z); error: delete f; return -1; } #include "jpegenc.h" void mapscreenshot(const char *imagepath, bool mapshot, int fileformat, float scale, int height, int quality) { extern int minimaplastsize; int src_w = mapshot ? minimaplastsize : screenw; int src_h = mapshot ? minimaplastsize : screenh; int dst_w = mapshot ? src_w : src_w * scale, img_w = dst_w; int dst_h = mapshot ? src_h : src_h * scale, img_h = dst_h; if(height) { // create 4:3 of exact height if(dst_w >= (dst_h * 4) / 3) { // 4:3 or wider: crop width dst_w = (src_w * height) / src_h; img_h = dst_h = height; img_w = (img_h * 4) / 3; } else { // probably 5:4: crop height img_h = height; dst_w = img_w = (img_h * 4) / 3; dst_h = (src_h * dst_w) / src_w; } } SDL_Surface *image = creatergbsurface(img_w, img_h); if(!image) return; int tmpdstsize = dst_w * dst_h * 3, tmpdstpitch = dst_w * 3; uchar *tmpdst = new uchar[tmpdstsize], *dst = (uchar *)image->pixels; if(mapshot) { extern GLuint minimaptex; if(minimaptex) { glPixelStorei(GL_PACK_ALIGNMENT, 1); glBindTexture(GL_TEXTURE_2D, minimaptex); glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, tmpdst); } else { conoutf("no mapshot prepared!"); SDL_FreeSurface(image); delete[] tmpdst; return; } loopi(img_h) { // copy image memcpy(dst, &tmpdst[tmpdstpitch * i], image->pitch); dst += image->pitch; } } else { glPixelStorei(GL_PACK_ALIGNMENT, 1); if(src_w != dst_w || src_h != dst_h) { // scale image uchar *tmpsrc = new uchar[src_w * src_h * 3]; glReadPixels(0, 0, src_w, src_h, GL_RGB, GL_UNSIGNED_BYTE, tmpsrc); scaletexture(tmpsrc, src_w, src_h, 3, tmpdst, dst_w, dst_h); delete[] tmpsrc; } else glReadPixels(0, 0, dst_w, dst_h, GL_RGB, GL_UNSIGNED_BYTE, tmpdst); int crop_w = height ? ((dst_w - img_w) / 2) * 3 : 0; int crop_h = height ? (dst_h - img_h) / 2 : 0; loopirev(img_h) { // flip image memcpy(dst, &tmpdst[tmpdstpitch * (i + crop_h) + crop_w], image->pitch); dst += image->pitch; } } entropy_add_block(tmpdst, tmpdstsize); delete[] tmpdst; if(!mapshot && imagepath) audiomgr.playsound(S_CAMERA); switch(fileformat) { case 0: // bmp { stream *file = openfile(imagepath, "wb"); if(!file) conoutf("failed to create: %s", imagepath); else { SDL_SaveBMP_RW(image, file->rwops(), 1); delete file; } break; } case 1: // jpeg { jpegenc jpegencoder; jpegencoder.encode(imagepath, image, quality, asciiscores(true)); break; } case 2: // png if(save_png(imagepath, image) < 0) conoutf("\f3Error saving png file"); break; } SDL_FreeSurface(image); } FVARP(screenshotscale, 0.1f, 1.0f, 1.0f); VARP(jpegquality, 10, 85, 100); // best: 100 - good: 85 [default] - bad: 70 - terrible: 50 VARP(screenshottype, 0, 1, 2); const char *getscrext() { const char *screxts[] = { ".bmp", ".jpg", ".png" }; return screxts[screenshottype % 3]; } COMMANDF(getscrext, "", () { result(getscrext()); }); void screenshot(const char *filename) { static string buf; if(filename && filename[0]) formatstring(buf)("screenshots/%s%s", filename, getscrext()); else if(getclientmap()[0]) formatstring(buf)("screenshots/%s_%s_%s%s", timestring(), behindpath(getclientmap()), modestr(gamemode, true), getscrext()); else formatstring(buf)("screenshots/%s%s", timestring(), getscrext()); path(buf); mapscreenshot(buf, false, screenshottype, screenshotscale, 0, jpegquality); } COMMAND(screenshot, "s"); void mapshot() { defformatstring(buf)("screenshots" PATHDIVS "mapshot_%s_%s%s", behindpath(getclientmap()), timestring(), getscrext()); mapscreenshot(buf, true, screenshottype, screenshotscale, 0, jpegquality); } COMMAND(mapshot, ""); void screenshotpreview(int *res) { static int lastres = 240; defformatstring(buf)("packages" PATHDIVS "maps" PATHDIVS "%spreview" PATHDIVS "%s.jpg", securemapcheck(getclientmap(), false) ? "official" PATHDIVS : "", behindpath(getclientmap())); mapscreenshot(buf, false, 1, 1.0f, (lastres = clamp(((*res ? *res : lastres) / 48) * 48, 144, 480)), 80); reloadtexture(*textureload(buf, 3)); } COMMAND(screenshotpreview, "i"); bool needsautoscreenshot = false; void updatescreensize() { SDL_GetWindowSize(screen, &screenw, &screenh); if(screenh < 1) screenh = 1; VIRTW = screenw * VIRTH / screenh; glViewport(0, 0, screenw, screenh); } void screenres(int w, int h) { if(!screen) return; scr_w = clamp(w, SCR_MINW, SCR_MAXW); scr_h = clamp(h, SCR_MINH, SCR_MAXH); if(fullscreendesktop) { scr_w = min(scr_w, desktopw); scr_h = min(scr_h, desktoph); } if(!(SDL_GetWindowFlags(screen) & SDL_WINDOW_FULLSCREEN)) SDL_SetWindowSize(screen, scr_w, scr_h); else if(!fullscreendesktop) initwarning("screen resolution"); } #if defined(WIN32) || defined(__APPLE__) || !defined(WIN32) void setresdata(char *s, enet_uint32 c) { extern hashtable &resdata; resdata[newstring(s)] = c; } #endif COMMANDF(screenres, "ii", (int *w, int *h) { screenres(*w, *h); }); int setgamma(int newgamma) // replacement for SDL_SetGamma { return screen ? SDL_SetWindowBrightness(screen, newgamma/100.0f) : -1; } static int curgamma = 100; VARNFP(gamma, vgamma, 30, 100, 300, { if(vgamma != curgamma) { if(setgamma(vgamma) == -1) conoutf("Could not set gamma: %s", SDL_GetError()); curgamma = vgamma; } }); void cleargamma() { if(curgamma != 100) setgamma(100); } void restoregamma() { if(curgamma != 100) { setgamma(100); setgamma(curgamma); } } void getdisplayresolutions() { string res = ""; int lh = 0, lw = 0, n = SDL_GetNumDisplayModes(0); SDL_DisplayMode mode; loopi(n) { if(SDL_GetDisplayMode(0, i, &mode) == 0 && lw != mode.w && lh != mode.h) concatformatstring(res, "%s%d %d", *res ? " " : "", (lw = mode.w), (lh = mode.h)); } result(res); } COMMAND(getdisplayresolutions, ""); void setupscreen(int &useddepthbits, int &usedfsaa) { if(glcontext) { SDL_GL_DeleteContext(glcontext); glcontext = NULL; } if(screen) { SDL_DestroyWindow(screen); screen = NULL; } SDL_Rect desktop; if(SDL_GetDisplayBounds(0, &desktop) < 0) fatal("failed querying desktop bounds: %s", SDL_GetError()); desktopw = desktop.w; desktoph = desktop.h; if(scr_w < 0 || scr_h < 0) { scr_w = desktopw; scr_h = desktoph; } // first run: set to fullscreen res int modes = SDL_GetNumDisplayModes(0); if(modes >= 1) { bool hasmode = false; SDL_DisplayMode mode; loopi(modes) { if(SDL_GetDisplayMode(0, i, &mode) == 0 && scr_w <= mode.w && scr_h <= mode.h) { hasmode = true; break; } } if(!hasmode && SDL_GetDisplayMode(0, 0, &mode) == 0) { scr_w = mode.w; scr_h = mode.h; } } int winw = fullscreen && fullscreendesktop ? desktopw : scr_w; int winh = fullscreen && fullscreendesktop ? desktoph : scr_h; int flags = SDL_WINDOW_RESIZABLE; if(fullscreen) flags |= fullscreendesktop ? SDL_WINDOW_FULLSCREEN_DESKTOP : SDL_WINDOW_FULLSCREEN; static int configs[] = { 0x7, /* try everything */ 0x6, 0x5, 0x3, /* try disabling one at a time */ 0x4, 0x2, 0x1, /* try disabling two at a time */ 0 /* try disabling everything */ }; int config = 0; SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 0); if(!depthbits) SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); if(!fsaa) { SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0); } loopi(sizeof(configs)/sizeof(configs[0])) { config = configs[i]; if(!depthbits && config&1) continue; if(!stencilbits && config&2) continue; if(fsaa<=0 && config&4) continue; if(depthbits) SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, config&1 ? depthbits : 16); if(stencilbits) { SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, config&2 ? stencilbits : 0); hasstencil = (config&2)!=0; } else hasstencil = false; if(fsaa>0) { SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, config&4 ? 1 : 0); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, config&4 ? fsaa : 0); } SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); screen = SDL_CreateWindow("AssaultCube", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, winw, winh, SDL_WINDOW_OPENGL | flags); if(screen) { glcontext = SDL_GL_CreateContext(screen); if(glcontext) break; SDL_DestroyWindow(screen); } } if(!screen) fatal("Unable to create OpenGL screen"); else { if(depthbits && (config&1)==0) conoutf("%d bit z-buffer not supported - disabling", depthbits); if(stencilbits && (config&2)==0) conoutf("%d bit stencil buffer not supported - disabling", stencilbits); if(fsaa>0 && (config&4)==0) conoutf("%dx anti-aliasing not supported - disabling", fsaa); } if(vsync>=0) SDL_GL_SetSwapInterval(vsync); updatescreensize(); inputgrab(grabinput = fullscreen ? true : false); useddepthbits = config&1 ? depthbits : 0; usedfsaa = config&2 ? fsaa : 0; } extern int hirestextures; void resetgl() { clearchanges(CHANGE_GFX); loadingscreen(); extern void cleanupparticles(); extern void cleanupmodels(); extern void cleanuptextures(); extern void cleanuptmus(); extern void cleanupgl(); cleanupparticles(); cleanupmodels(); cleanuptextures(); cleanuptmus(); cleanupgl(); uniformtexres = !hirestextures; c2skeepalive(); int useddepthbits = 0, usedfsaa = 0; setupscreen(useddepthbits, usedfsaa); gl_init(screenw, screenh, useddepthbits, usedfsaa); extern void reloadfonts(); extern Texture *startscreen; c2skeepalive(); if(!reloadtexture(*notexture) || !reloadtexture(*startscreen)) fatal("failed to reload core texture"); loadingscreen(); c2skeepalive(); restoregamma(); c2skeepalive(); reloadfonts(); reloadtextures(); c2skeepalive(); drawscope(true); preload_playermodels(); c2skeepalive(); preload_hudguns(); c2skeepalive(); preload_entmodels(); c2skeepalive(); preload_mapmodels(); c2skeepalive(); } COMMAND(resetgl, ""); VARFP(maxfps, 0, 200, 1000, if(maxfps && maxfps < 25) maxfps = 25); void limitfps(int &millis, int curmillis) { if(!maxfps) return; static int fpserror = 0; int delay = 1000/maxfps - (millis-curmillis); if(delay < 0) fpserror = 0; else { fpserror += 1000%maxfps; if(fpserror >= maxfps) { ++delay; fpserror -= maxfps; } if(delay > 0) { SDL_Delay(delay); millis += delay; } } } int lowfps = 30, highfps = 40; void fpsrange(int *low, int *high) { if(*low>*high || *low<1) return; lowfps = *low; highfps = *high; } COMMAND(fpsrange, "ii"); int keyrepeatmask = 0, textinputmask = 0; // bunches of flags for the same functions Uint32 textinputtime = 0; void keyrepeat(bool on, int mask) { if(on) keyrepeatmask |= mask; else keyrepeatmask &= ~mask; } void textinput(bool on, int mask) { if(on) { if(!textinputmask) { SDL_StartTextInput(); textinputtime = SDL_GetTicks(); } textinputmask |= mask; } else { textinputmask &= ~mask; if(!textinputmask) SDL_StopTextInput(); } } vector events; void pushevent(const SDL_Event &e) { events.add(e); } bool interceptkey(int sym) { static int lastintercept = SDLK_UNKNOWN; int len = lastintercept == sym ? events.length() : 0; SDL_Event event; while(SDL_PollEvent(&event)) switch(event.type) { case SDL_MOUSEMOTION: break; default: pushevent(event); break; } lastintercept = sym; if(sym != SDLK_UNKNOWN) for(int i = len; i < events.length(); i++) { if(events[i].type == SDL_KEYDOWN && events[i].key.keysym.sym == sym) { events.remove(i); return true; } } return false; } static void resetmousemotion() { if(emulaterelativemouse && !(SDL_GetWindowFlags(screen) & SDL_WINDOW_FULLSCREEN)) { SDL_WarpMouseInWindow(screen, screenw / 2, screenh / 2); } } static inline bool skipmousemotion(SDL_Event &event) { if(event.type != SDL_MOUSEMOTION) return true; if(!(SDL_GetWindowFlags(screen) & SDL_WINDOW_FULLSCREEN)) { if(event.motion.x == screenw / 2 && event.motion.y == screenh / 2) return true; // ignore any motion events generated SDL_WarpMouse } return false; } static void checkmousemotion(int &dx, int &dy) { loopv(events) { SDL_Event &event = events[i]; if(skipmousemotion(event)) { if(i > 0) events.remove(0, i); return; } dx += event.motion.xrel; dy += event.motion.yrel; } events.setsize(0); SDL_Event event; while(SDL_PollEvent(&event)) { if(skipmousemotion(event)) { events.add(event); return; } dx += event.motion.xrel; dy += event.motion.yrel; } } int ignoremouse = 5, bootstrapentropy = 2; #define EVENTDEBUG(x) x //#define EVENTDEBUG(x) EVENTDEBUG(VAR(debugevents, 0, 0, 2)); void checkinput() { SDL_Event event; Uint32 lasttype = 0, lastbut = 0; int tdx=0,tdy=0; while(events.length() || SDL_PollEvent(&event)) { if(events.length()) event = events.remove(0); EVENTDEBUG(int thres = 1; defformatstring(eb)("EVENT %d", event.type)); switch(event.type) { case SDL_QUIT: quit(); break; case SDL_KEYDOWN: if(bootstrapentropy > 0 && (--bootstrapentropy & 2)) mapscreenshot(NULL, false, -1, 1000.0f / (1000 + rnd(400)), 0, 0); case SDL_KEYUP: EVENTDEBUG(thres = 2; concatstring(eb, event.type == SDL_KEYUP ? "(SDL_KEYUP)" : "(SDL_KEYDOWN)")); entropy_add_byte(event.key.keysym.sym ^ totalmillis); EVENTDEBUG(concatformatstring(eb, " sym %d (%Xh), scancode %d (%Xh), state %d, repeat %d", event.key.keysym.sym, event.key.keysym.sym, event.key.keysym.scancode, event.key.keysym.scancode, event.key.state, event.key.repeat)); if(event.key.keysym.sym == SDLK_SCANCODE_MASK) event.key.keysym.sym |= event.key.keysym.scancode; // workaround SDL 2.0.5 bug which returns sym == 40000000h for all dead keys if(!event.key.repeat || keyrepeatmask) keypress(event.key.keysym.sym, event.key.keysym.scancode, event.key.state==SDL_PRESSED, (SDL_Keymod)event.key.keysym.mod); break; case SDL_TEXTINPUT: EVENTDEBUG(thres = 2; concatformatstring(eb, "(SDL_TEXTINPUT) %s %d %d", escapestring(event.text.text), textinputmask, int(event.text.timestamp - textinputtime))); if(textinputmask && int(event.text.timestamp - textinputtime) >= 5) // mute textinput for a few milliseconds, to avoid receiving the "t" that switched on the console { processtextinput(event.text.text); } break; case SDL_WINDOWEVENT: { EVENTDEBUG(concatstring(eb, "(SDL_WINDOWEVENT) ")); switch(event.window.event) { case SDL_WINDOWEVENT_SHOWN: // window has been shown EVENTDEBUG(concatstring(eb, " SDL_WINDOWEVENT_SHOWN")); break; case SDL_WINDOWEVENT_HIDDEN: // window has been hidden EVENTDEBUG(concatstring(eb, " SDL_WINDOWEVENT_HIDDEN")); break; case SDL_WINDOWEVENT_EXPOSED: // window has been exposed and should be redrawn EVENTDEBUG(concatstring(eb, " SDL_WINDOWEVENT_EXPOSED")); break; case SDL_WINDOWEVENT_MOVED: // window has been moved to data1, data2 EVENTDEBUG(concatformatstring(eb, " SDL_WINDOWEVENT_MOVED x %d, y %d", event.window.data1, event.window.data2)); if(!(SDL_GetWindowFlags(screen) & SDL_WINDOW_FULLSCREEN)) centerwindow = false; break; case SDL_WINDOWEVENT_RESIZED: // window has been resized to data1 x data2; this is event is always preceded by SDL_WINDOWEVENT_SIZE_CHANGED EVENTDEBUG(concatformatstring(eb, " SDL_WINDOWEVENT_RESIZED %d x %d", event.window.data1, event.window.data2)); if(!fullscreendesktop || !(SDL_GetWindowFlags(screen) & SDL_WINDOW_FULLSCREEN)) { scr_w = clamp(event.window.data1, SCR_MINW, SCR_MAXW); scr_h = clamp(event.window.data2, SCR_MINH, SCR_MAXH); } break; case SDL_WINDOWEVENT_SIZE_CHANGED: // window size has changed, either as a result of an API call or through the system or user changing the window size; this event is followed by SDL_WINDOWEVENT_RESIZED if the size was changed by an external event, i.e. the user or the window manager updatescreensize(); EVENTDEBUG(concatformatstring(eb, " SDL_WINDOWEVENT_SIZE_CHANGED %dx%d", screenw, screenh)); break; case SDL_WINDOWEVENT_MINIMIZED: // window has been minimized EVENTDEBUG(concatstring(eb, " SDL_WINDOWEVENT_MINIMIZED")); inputgrab(false); minimized = 1; break; case SDL_WINDOWEVENT_MAXIMIZED: // window has been maximized case SDL_WINDOWEVENT_RESTORED: // window has been restored to normal size and position EVENTDEBUG(concatstring(eb, event.window.event == SDL_WINDOWEVENT_RESTORED ? "SDL_WINDOWEVENT_RESTORED" : "SDL_WINDOWEVENT_MAXIMIZED")); minimized = 0; inputgrab(grabinput); break; case SDL_WINDOWEVENT_ENTER: // window has gained mouse focus EVENTDEBUG(concatstring(eb, " SDL_WINDOWEVENT_ENTER")); break; case SDL_WINDOWEVENT_LEAVE: // window has lost mouse focus EVENTDEBUG(concatstring(eb, " SDL_WINDOWEVENT_LEAVE")); break; case SDL_WINDOWEVENT_FOCUS_GAINED: // window has gained keyboard focus EVENTDEBUG(concatstring(eb, " SDL_WINDOWEVENT_FOCUS_GAINED")); if(fullscreen) inputgrab(grabinput = true); // click-to-grab for windowed mode break; case SDL_WINDOWEVENT_FOCUS_LOST: // window has lost keyboard focus EVENTDEBUG(concatstring(eb, " SDL_WINDOWEVENT_FOCUS_LOST")); inputgrab(grabinput = false); break; } break; } case SDL_MOUSEMOTION: EVENTDEBUG(thres = 2; concatformatstring(eb, "(SDL_MOUSEMOTION) x %d, y %d, dx %d, dy %d", event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel)); if(ignoremouse) { ignoremouse--; break; } if(grabinput && !skipmousemotion(event)) { int dx = event.motion.xrel, dy = event.motion.yrel; entropy_add_byte(dx ^ (256 - dy)); checkmousemotion(dx, dy); resetmousemotion(); tdx+=dx;tdy+=dy; } break; case SDL_MOUSEBUTTONDOWN: if(!grabinput) // click-to-grab { EVENTDEBUG(concatformatstring(eb, "(SDL_MOUSEBUTTONDOWN) button %d, state %d, clicks %d, x %d, y %d", event.button.button, event.button.state, event.button.clicks, event.button.x, event.button.y)); inputgrab(grabinput = true); break; } case SDL_MOUSEBUTTONUP: EVENTDEBUG(concatformatstring(eb, "(SDL_MOUSEBUTTON%s) button %d, state %d, clicks %d, x %d, y %d", event.type == SDL_MOUSEBUTTONUP ? "UP" : "DOWN", event.button.button, event.button.state, event.button.clicks, event.button.x, event.button.y)); if(lasttype==event.type && lastbut==event.button.button) break; keypress(-(event.button.button > 3 ? (event.button.button + 4) : event.button.button), 0, event.button.state != SDL_RELEASED); lasttype = event.type; lastbut = event.button.button; break; case SDL_MOUSEWHEEL: EVENTDEBUG(concatformatstring(eb, "(SDL_MOUSEWHEEL) x %d, y %d", event.wheel.x, event.wheel.y)); if(event.wheel.y) { int key = event.wheel.y > 0 ? SDL_AC_BUTTON_WHEELUP : SDL_AC_BUTTON_WHEELDOWN; keypress(key, 0, true); // Emulate SDL1-style mouse wheel events by immediately "releasing" the wheel "button" keypress(key, 0, false); } if(event.wheel.x) { int key = event.wheel.x > 0 ? SDL_AC_BUTTON_RIGHT : SDL_AC_BUTTON_LEFT; keypress(key, 0, true); keypress(key, 0, false); } break; } EVENTDEBUG(if(debugevents >= thres) conoutf("%s", eb)); } if(tdx || tdy) { entropy_add_byte(tdy + 5 * tdx); mousemove(tdx, tdy); } } VARF(gamespeed, 10, 100, 1000, if(multiplayer()) gamespeed = 100); VARF(paused, 0, 0, 1, if(multiplayer()) paused = 0); bool inmainloop = false; static int clockrealbase = 0, clockvirtbase = 0; static void clockreset() { clockrealbase = SDL_GetTicks(); clockvirtbase = totalmillis; } VARFP(clockerror, 990000, 1000000, 1010000, clockreset()); VARFP(clockfix, 0, 0, 1, clockreset()); const char *rndmapname() { vector maps; listfiles("packages/maps/official", "cgz", maps); if (maps.length() > 0) { char *map = newstring(maps[rnd(maps.length())]); maps.deletearrays(); return map; } else return ""; } #define AUTOSTARTPATH "config" PATHDIVS "autostart" PATHDIVS void autostartscripts(const char *prefix) { static vector *files = NULL; if(!files) { // first run: fetch file names and sort them files = new vector; listfiles(AUTOSTARTPATH, "cfg", *files, stringsort); } loopv(*files) { if(*prefix && strncmp((*files)[i], prefix, strlen(prefix))) continue; defformatstring(p)(AUTOSTARTPATH "%s.cfg", (*files)[i]); execfile(p); delstring(files->remove(i--)); } } void createconfigtemplates(const char *templatezip) // create customisable config files in homedir - only if missing { vector files; void *mz = zipmanualopen(openfile(templatezip, "rb"), files); if(mz) { loopv(files) { const char *filename = behindpath(files[i]); // only look for config files in the zip file, ignore all paths in the zip if(strlen(filename) > 4 && !strcmp(filename + strlen(filename) - 4, ".cfg")) { defformatstring(fname)("config" PATHDIVS "%s", files[i]); if(getfilesize(fname) <= 0) // config does not exist or is empty { stream *zf = openfile(fname, "wb"); if(zf) { zipmanualread(mz, i, zf, MAXCFGFILESIZE); // fetch file content from zip, write to new config file delete zf; conoutf("created %s from template %s", fname, templatezip); } } } } zipmanualclose(mz); } findfile(AUTOSTARTPATH "dummy", "w"); // create empty autostart directory, if it doesn't exist yet } void connectprotocol(char *protocolstring) // assaultcube://example.org[:28763][/][?[port=28763][&password=secret]] { urlparse u; u.set(protocolstring); if(strcmp(u.scheme, "assaultcube") || !*u.domain) { conoutf("\f3bad commandline syntax (\"%s\")", protocolstring); return; } if(*u.userpassword) clientlogf(" ignoring user:password part of url (%s)", u.userpassword); if(*u.fragment) clientlogf(" ignoring fragment part of url (%s)", u.fragment); if(*u.path) clientlogf(" ignoring path part of url (%s)", u.path); int port = ATOI(u.port); const char *q = u.query, *passwd = NULL; while(q && *q) { if(*q == '&') q++; if(!strncmp(q, "port=", 5)) { q += 5; port = ATOI(q); q = strchr(q, '&'); } else if(!strncmp(q, "password=", 9)) { q += 9; const char *e = strchr(q, '&'); passwd = e ? newstring(q, e - q) : newstring(q); q = e; } else break; } defformatstring(cmd)("connect %s %d %s", u.domain, port, passwd ? passwd : ""); DEBUGCODE(clientlogf("connectprotocol: %s", cmd)); addsleep(5, cmd, true); DELSTRING(passwd); } #ifdef THISISNOTDEFINED //WIN32 static char *parsecommandline(const char *src, vector &args) { char *buf = new char[strlen(src) + 1], *dst = buf; for(;;) { while(isspace(*src)) src++; if(!*src) break; args.add(dst); for(bool quoted = false; *src && (quoted || !isspace(*src)); src++) { if(*src != '"') *dst++ = *src; else if(dst > buf && src[-1] == '\\') dst[-1] = '"'; else quoted = !quoted; } *dst++ = '\0'; } args.add(NULL); return buf; } int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) { vector args; char *buf = parsecommandline(GetCommandLine(), args); SDL_SetModuleHandle(hInst); int status = SDL_main(args.length()-1, args.getbuf()); delete[] buf; exit(status); return 0; } #endif void initclientlog() // rotate old logfiles and create new one { filerotate("clientlog", "txt", 5); // keep five old logfiles clientlogfile = openfile("clientlog.txt", "w"); if(clientlogfile) { if(bootclientlog && bootclientlog->length()) clientlogfile->write(bootclientlog->getbuf(), bootclientlog->length()); } else conoutf("could not create logfile \"%s\"", findfile("clientlog.txt", "w")); DELETEP(bootclientlog); } #ifdef _DEBUG void sanitychecks() { ASSERT((GMMASK__BOT ^ GMMASK__MP ^ GMMASK__TEAM ^ GMMASK__FFA ^ GMMASK__TEAMSPAWN ^ GMMASK__FFASPAWN) == GMMASK__ALL); float fa = 1 << LARGEST_FACTOR, fb = fa; while(fa != fa + fb) fb /= 2; ASSERT(2 * fb < NEARZERO); } #endif #define DEFAULTPROFILEPATH "profile" int main(int argc, char **argv) { DEBUGCODE(sanitychecks()); extern struct servercommandline scl; #ifdef WIN32 //atexit((void (__cdecl *)(void))_CrtDumpMemoryLeaks); #ifndef _DEBUG #ifndef __GNUC__ __try { #endif #endif #endif bool dedicated = false; bool quitdirectly = false; char *initscript = NULL; char *initdemo = NULL; if(bootclientlog) cvecprintf(*bootclientlog, "######## start logging: %s\n", timestring(true)); const char *initmap = rndmapname(); loopi(NUMGUNS) crosshairnames[i] = gunnames[i] = guns[i].modelname; crosshairnames[GUN_AKIMBO] = gunnames[GUN_AKIMBO] = "akimbo"; crosshairnames[CROSSHAIR_DEFAULT] = "default"; crosshairnames[CROSSHAIR_TEAMMATE] = "teammate"; crosshairnames[CROSSHAIR_SCOPE] = "scope"; crosshairnames[CROSSHAIR_EDIT] = "edit"; crosshairnames[CROSSHAIR_NUM] = gunnames[NUMGUNS] = ""; pushscontext(IEXC_CFG); persistidents = false; #define initlog(s) clientlogf("init: " s) if(*stream_capabilities()) clientlogf("info: %s", stream_capabilities()); initing = INIT_RESET; for(int i = 1; igetlil(); loopi(n) { string s; f->read(s, sizeof(string)); enet_uint32 c = f->getlil(); setresdata(s, c); } delete f; } autostartscripts("_beforesaved_"); initing = INIT_LOAD; if(!execfile("config/saved.cfg")) { exec("config/defaults.cfg"); bootstrapentropy += 5 + rnd(7); } autostartscripts("_aftersaved_"); exechook(HOOK_SP_MP, "afterinit", ""); autostartscripts(""); // all remaining scripts execfile("config/autoexec.cfg"); exechook(HOOK_SP_MP, "autoexec", ""); initing = NOT_INITING; uniformtexres = !hirestextures; initlog("models"); preload_playermodels(); preload_hudguns(); preload_entmodels(); initlog("docs"); persistidents = false; execfile("config/docs.cfg"); persistidents = true; initlog("localconnect"); extern string clientmap; if(initdemo) { extern int gamemode; gamemode = -1; copystring(clientmap, initdemo); } else copystring(clientmap, initmap); // ac_complex for 1.0, ac_shine for 1.1, .. localconnect(); if(initscript) execute(initscript); initlog("mainloop"); inputgrab(grabinput = true); inmainloop = true; #ifdef _DEBUG int lastflush = 0; #endif if(scl.logident[0]) { // "-Nxxx" sets the number of client log lines to xxx (after init) extern int clientloglinesremaining; clientloglinesremaining = atoi(scl.logident); // dual-use for scl.logident } for(;;) { static int frames = 0; static float fps = 10.0f; int millis = SDL_GetTicks() - clockrealbase; if(clockfix) millis = int(millis*(double(clockerror)/1000000)); millis += clockvirtbase; if(millis 5000 ? skipmillis - 5000 : min(1000, skipmillis); curtime += skipmillisnow; skipmillis -= skipmillisnow; } if(paused) curtime = 0; } lastmillis += curtime; totalmillis = millis; checkinput(); if(lastmillis) updateworld(curtime, lastmillis); if(needsautoscreenshot) showscores(true); serverslice(0); if(elapsed) fps = (1000.0f/elapsed+fps*10)/11; // avoid DIV-by-0 frames++; audiomgr.updateaudio(); computeraytable(camera1->o.x, camera1->o.y, dynfov()); if(frames>3 && !minimized) { gl_drawframe(screenw, screenh, fpshighfps ? fps/highfps : 1.0f), fps, elapsed); if(frames>4) SDL_GL_SwapWindow(screen); } if(needsautoscreenshot) { showscores(true); // draw again after swapping buffers, to make sure menu is captured // in the screenshot regardless of which frame buffer is current if(!minimized) { gl_drawframe(screenw, screenh, fpshighfps ? fps/highfps : 1.0f), fps, elapsed); } addsleep(0, "screenshot"); needsautoscreenshot = false; } #ifdef _DEBUG if(millis>lastflush+60000) { fflush(stdout); lastflush = millis; } #endif pollautodownloadresponse(); } quit(); return EXIT_SUCCESS; #if defined(WIN32) && !defined(_DEBUG) && !defined(__GNUC__) } __except(stackdumper(0, GetExceptionInformation()), EXCEPTION_CONTINUE_SEARCH) { return 0; } #endif } VAR(version, 1, AC_VERSION, 0); VAR(protocol, 1, PROTOCOL_VERSION, 0); assaultcube-1.2.0.2.1/source/src/master.cpp000066400000000000000000000467621352165075300204400ustar00rootroot00000000000000#include "cube.h" #include #include #define INPUT_LIMIT 4096 #define OUTPUT_LIMIT (64*1024) #define CLIENT_TIME (3*60*1000) #define AUTH_TIME (60*1000) #define AUTH_LIMIT 100 #define AUTH_THROTTLE 1000 #define CLIENT_LIMIT 8192 #define DUP_LIMIT 16 #define PING_TIME 3000 #define PING_RETRY 5 #define KEEPALIVE_TIME (65*60*1000) #define SERVER_LIMIT (10*1024) FILE *logfile = NULL; // for AUTH: struct userinfo { char *name; void *pubkey; }; hashtable users; void adduser(char *name, char *pubkey) { name = newstring(name); userinfo &u = users[name]; u.name = name; u.pubkey = parsepubkey(pubkey); } COMMAND(adduser, "ss"); void clearusers() { enumerate(users, userinfo, u, { delete[] u.name; freepubkey(u.pubkey); }); users.clear(); } COMMAND(clearusers, ""); // :for AUTH struct baninfo { enet_uint32 ip, mask; }; vector bans, servbans, gbans; void clearbans() { bans.shrink(0); servbans.shrink(0); gbans.shrink(0); } COMMAND(clearbans, ""); void addban(vector &bans, const char *name) { union { uchar b[sizeof(enet_uint32)]; enet_uint32 i; } ip, mask; ip.i = 0; mask.i = 0; loopi(4) { char *end = NULL; int n = strtol(name, &end, 10); if(!end) break; if(end > name) { ip.b[i] = n; mask.b[i] = 0xFF; } name = end; while(*name && *name++ != '.'); } baninfo &ban = bans.add(); ban.ip = ip.i; ban.mask = mask.i; } COMMANDF(ban, "s", (char *name) { addban(bans, name); }); COMMANDF(servban, "s", (char *name) { addban(servbans, name); }); COMMANDF(gban, "s", (char *name) { addban(gbans, name); }); char *printban(const baninfo &ban, char *buf) { union { uchar b[sizeof(enet_uint32)]; enet_uint32 i; } ip, mask; ip.i = ban.ip; mask.i = ban.mask; int lastdigit = -1; loopi(4) if(mask.b[i]) { if(lastdigit >= 0) *buf++ = '.'; loopj(i - lastdigit - 1) { *buf++ = '*'; *buf++ = '.'; } buf += sprintf(buf, "%d", ip.b[i]); lastdigit = i; } return buf; } bool checkban(vector &bans, enet_uint32 host) { loopv(bans) if((host & bans[i].mask) == bans[i].ip) return true; return false; } // for AUTH: struct authreq { enet_uint32 reqtime; uint id; void *answer; }; // :for AUTH struct gameserver { ENetAddress address; string ip; int port, numpings; enet_uint32 lastping, lastpong; }; vector gameservers; struct messagebuf { vector &owner; vector buf; int refs; messagebuf(vector &owner) : owner(owner), refs(0) {} const char *getbuf() { return buf.getbuf(); } int length() { return buf.length(); } void purge(); bool equals(const messagebuf &m) const { return buf.length() == m.buf.length() && !memcmp(buf.getbuf(), m.buf.getbuf(), buf.length()); } bool endswith(const messagebuf &m) const { return buf.length() >= m.buf.length() && !memcmp(&buf[buf.length() - m.buf.length()], m.buf.getbuf(), m.buf.length()); } void concat(const messagebuf &m) { if(buf.length() && buf.last() == '\0') buf.pop(); buf.put(m.buf.getbuf(), m.buf.length()); } }; vector gameserverlists, gbanlists; bool updateserverlist = true; struct client { ENetAddress address; ENetSocket socket; char input[INPUT_LIMIT]; messagebuf *message; vector output; int inputpos, outputpos; enet_uint32 connecttime, lastinput; int servport; enet_uint32 lastauth; // for AUTH vector authreqs; // for AUTH bool shouldpurge; bool registeredserver; client() : message(NULL), inputpos(0), outputpos(0), servport(-1), lastauth(0), shouldpurge(false), registeredserver(false) {} }; vector clients; ENetSocket serversocket = ENET_SOCKET_NULL; time_t starttime; enet_uint32 servtime = 0; void fatal(const char *fmt, ...) { va_list args; va_start(args, fmt); vfprintf(logfile, fmt, args); fputc('\n', logfile); va_end(args); exit(EXIT_FAILURE); } void conoutfv(const char *fmt, va_list args) { vfprintf(logfile, fmt, args); fputc('\n', logfile); } void conoutf(const char *fmt, ...) { va_list args; va_start(args, fmt); conoutfv(fmt, args); va_end(args); } void purgeclient(int n) { client &c = *clients[n]; if(c.message) c.message->purge(); enet_socket_destroy(c.socket); delete clients[n]; clients.remove(n); } void output(client &c, const char *msg, int len = 0) { if(!len) len = strlen(msg); c.output.put(msg, len); } void outputf(client &c, const char *fmt, ...) { string msg; va_list args; va_start(args, fmt); vformatstring(msg, fmt, args); va_end(args); output(c, msg); } ENetSocket pingsocket = ENET_SOCKET_NULL; bool setuppingsocket() { if(pingsocket != ENET_SOCKET_NULL) return true; pingsocket = enet_socket_create(ENET_SOCKET_TYPE_DATAGRAM); if(pingsocket == ENET_SOCKET_NULL) return false; enet_socket_set_option(pingsocket, ENET_SOCKOPT_NONBLOCK, 1); return true; } void setupserver(int port, const char *ip = NULL) { ENetAddress address; address.host = ENET_HOST_ANY; address.port = port; if(ip) { if(enet_address_set_host(&address, ip)<0) fatal("failed to resolve server address: %s", ip); } serversocket = enet_socket_create(ENET_SOCKET_TYPE_STREAM); if(serversocket==ENET_SOCKET_NULL || enet_socket_set_option(serversocket, ENET_SOCKOPT_REUSEADDR, 1) < 0 || enet_socket_bind(serversocket, &address) < 0 || enet_socket_listen(serversocket, -1) < 0) fatal("failed to create server socket"); if(enet_socket_set_option(serversocket, ENET_SOCKOPT_NONBLOCK, 1)<0) fatal("failed to make server socket non-blocking"); if(!setuppingsocket()) fatal("failed to create ping socket"); enet_time_set(0); starttime = time(NULL); char *ct = ctime(&starttime); if(strchr(ct, '\n')) *strchr(ct, '\n') = '\0'; conoutf("*** Starting master server on %s %d at %s ***", ip ? ip : "localhost", port, ct); } void genserverlist() { if(!updateserverlist) return; while(gameserverlists.length() && gameserverlists.last()->refs<=0) delete gameserverlists.pop(); messagebuf *l = new messagebuf(gameserverlists); loopv(gameservers) { gameserver &s = *gameservers[i]; if(!s.lastpong) continue; defformatstring(cmd)("addserver %s %d\n", s.ip, s.port); l->buf.put(cmd, strlen(cmd)); } l->buf.add('\0'); gameserverlists.add(l); updateserverlist = false; } void gengbanlist() { messagebuf *l = new messagebuf(gbanlists); const char *header = "cleargbans\n"; l->buf.put(header, strlen(header)); string cmd = "addgban "; int cmdlen = strlen(cmd); loopv(gbans) { baninfo &b = gbans[i]; l->buf.put(cmd, printban(b, &cmd[cmdlen]) - cmd); l->buf.add('\n'); } if(gbanlists.length() && gbanlists.last()->equals(*l)) { delete l; return; } while(gbanlists.length() && gbanlists.last()->refs<=0) delete gbanlists.pop(); loopv(gbanlists) { messagebuf *m = gbanlists[i]; if(m->refs > 0 && !m->endswith(*l)) m->concat(*l); } gbanlists.add(l); loopv(clients) { client &c = *clients[i]; if(c.servport >= 0 && !c.message) { c.message = l; c.message->refs++; } } } void addgameserver(client &c) { if(gameservers.length() >= SERVER_LIMIT) return; loopv(gameservers) { gameserver &s = *gameservers[i]; if(s.address.host == c.address.host && s.port == c.servport) { s.lastping = 0; s.numpings = 0; return; } } string hostname; if(enet_address_get_host_ip(&c.address, hostname, sizeof(hostname)) < 0) { outputf(c, "failreg failed resolving ip\n"); return; } gameserver &s = *gameservers.add(new gameserver); s.address.host = c.address.host; s.address.port = c.servport+1; copystring(s.ip, hostname); s.port = c.servport; s.numpings = 0; s.lastping = s.lastpong = 0; } client *findclient(gameserver &s) { loopv(clients) { client &c = *clients[i]; if(s.address.host == c.address.host && s.port == c.servport) return &c; } return NULL; } void servermessage(gameserver &s, const char *msg) { client *c = findclient(s); if(c) outputf(*c, msg); } void checkserverpongs() { ENetBuffer buf; ENetAddress addr; static uchar pong[MAXTRANS]; for(;;) { buf.data = pong; buf.dataLength = sizeof(pong); int len = enet_socket_receive(pingsocket, &addr, &buf, 1); if(len <= 0) break; loopv(gameservers) { gameserver &s = *gameservers[i]; if(s.address.host == addr.host && s.address.port == addr.port) { if(s.lastping && (!s.lastpong || ENET_TIME_GREATER(s.lastping, s.lastpong))) { client *c = findclient(s); if(c) { c->registeredserver = true; outputf(*c, "succreg\n"); if(!c->message && gbanlists.length()) { c->message = gbanlists.last(); c->message->refs++; } } } if(!s.lastpong) updateserverlist = true; s.lastpong = servtime ? servtime : 1; break; } } } } void bangameservers() { loopvrev(gameservers) if(checkban(servbans, gameservers[i]->address.host)) { delete gameservers.remove(i); updateserverlist = true; } } void checkgameservers() { ENetBuffer buf; loopv(gameservers) { gameserver &s = *gameservers[i]; if(s.lastping && s.lastpong && ENET_TIME_LESS_EQUAL(s.lastping, s.lastpong)) { if(ENET_TIME_DIFFERENCE(servtime, s.lastpong) > KEEPALIVE_TIME) { delete gameservers.remove(i--); updateserverlist = true; } } else if(!s.lastping || ENET_TIME_DIFFERENCE(servtime, s.lastping) > PING_TIME) { if(s.numpings >= PING_RETRY) { servermessage(s, "failreg failed pinging server\n"); delete gameservers.remove(i--); updateserverlist = true; } else { static const uchar ping[] = { 1 }; buf.data = (void *)ping; buf.dataLength = sizeof(ping); s.numpings++; s.lastping = servtime ? servtime : 1; enet_socket_send(pingsocket, &s.address, &buf, 1); } } } } void messagebuf::purge() { refs = max(refs - 1, 0); if(refs<=0 && owner.last()!=this) { owner.removeobj(this); delete this; } } // for AUTH: void purgeauths(client &c) { int expired = 0; loopv(c.authreqs) { if(ENET_TIME_DIFFERENCE(servtime, c.authreqs[i].reqtime) >= AUTH_TIME) { outputf(c, "failauth %u\n", c.authreqs[i].id); freechallenge(c.authreqs[i].answer); expired = i + 1; } else break; } if(expired > 0) c.authreqs.remove(0, expired); } void reqauth(client &c, uint id, char *name) { if(ENET_TIME_DIFFERENCE(servtime, c.lastauth) < AUTH_THROTTLE) return; c.lastauth = servtime; purgeauths(c); time_t t = time(NULL); char *ct = ctime(&t); if(ct) { char *newline = strchr(ct, '\n'); if(newline) *newline = '\0'; } string ip; if(enet_address_get_host_ip(&c.address, ip, sizeof(ip)) < 0) copystring(ip, "-"); conoutf("%s: attempting \"%s\" as %u from %s", ct ? ct : "-", name, id, ip); userinfo *u = users.access(name); if(!u) { outputf(c, "failauth %u\n", id); return; } if(c.authreqs.length() >= AUTH_LIMIT) { outputf(c, "failauth %u\n", c.authreqs[0].id); freechallenge(c.authreqs[0].answer); c.authreqs.remove(0); } authreq &a = c.authreqs.add(); a.reqtime = servtime; a.id = id; uint seed[3] = { (uint)starttime, (uint)servtime, randomMT() }; static vector buf; buf.setsize(0); a.answer = genchallenge(u->pubkey, seed, sizeof(seed), buf); outputf(c, "chalauth %u %s\n", id, buf.getbuf()); } void confauth(client &c, uint id, const char *val) { purgeauths(c); loopv(c.authreqs) if(c.authreqs[i].id == id) { string ip; if(enet_address_get_host_ip(&c.address, ip, sizeof(ip)) < 0) copystring(ip, "-"); if(checkchallenge(val, c.authreqs[i].answer)) { outputf(c, "succauth %u\n", id); conoutf("succeeded %u from %s", id, ip); } else { outputf(c, "failauth %u\n", id); conoutf("failed %u from %s", id, ip); } freechallenge(c.authreqs[i].answer); c.authreqs.remove(i--); return; } outputf(c, "failauth %u\n", id); } // :for AUTH bool checkclientinput(client &c) { if(c.inputpos<0) return true; char *end = (char *)memchr(c.input, '\n', c.inputpos); while(end) { *end++ = '\0'; c.lastinput = servtime; uint id; // for AUTH string user, val; // for AUTH int port; if(!strncmp(c.input, "list", 4) && (!c.input[4] || isspace(c.input[4]))) { genserverlist(); if(gameserverlists.empty() || c.message) return false; c.message = gameserverlists.last(); c.message->refs++; c.output.setsize(0); c.outputpos = 0; c.shouldpurge = true; return true; } else if(sscanf(c.input, "regserv %d", &port) == 1) { if(checkban(servbans, c.address.host)) return false; if(port < 0 || port + 1 < 0 || (c.servport >= 0 && port != c.servport)) outputf(c, "failreg invalid port\n"); else { c.servport = port; addgameserver(c); } } // for AUTH: else if(sscanf(c.input, "reqauth %u %100s", &id, user) == 2) { reqauth(c, id, user); } else if(sscanf(c.input, "confauth %u %100s", &id, val) == 2) { confauth(c, id, val); } // :for AUTH c.inputpos = &c.input[c.inputpos] - end; memmove(c.input, end, c.inputpos); end = (char *)memchr(c.input, '\n', c.inputpos); } return c.inputpos<(int)sizeof(c.input); } ENetSocketSet readset, writeset; void checkclients() { ENetSocketSet readset, writeset; ENetSocket maxsock = max(serversocket, pingsocket); ENET_SOCKETSET_EMPTY(readset); ENET_SOCKETSET_EMPTY(writeset); ENET_SOCKETSET_ADD(readset, serversocket); ENET_SOCKETSET_ADD(readset, pingsocket); loopv(clients) { client &c = *clients[i]; if(c.message || c.output.length()) ENET_SOCKETSET_ADD(writeset, c.socket); else ENET_SOCKETSET_ADD(readset, c.socket); maxsock = max(maxsock, c.socket); } if(enet_socketset_select(maxsock, &readset, &writeset, 1000)<=0) return; if(ENET_SOCKETSET_CHECK(readset, pingsocket)) checkserverpongs(); if(ENET_SOCKETSET_CHECK(readset, serversocket)) { ENetAddress address; ENetSocket clientsocket = enet_socket_accept(serversocket, &address); if(clients.length()>=CLIENT_LIMIT || checkban(bans, address.host)) enet_socket_destroy(clientsocket); else if(clientsocket!=ENET_SOCKET_NULL) { int dups = 0, oldest = -1; loopv(clients) if(clients[i]->address.host == address.host) { dups++; if(oldest<0 || clients[i]->connecttime < clients[oldest]->connecttime) oldest = i; } if(dups >= DUP_LIMIT) purgeclient(oldest); client *c = new client; c->address = address; c->socket = clientsocket; c->connecttime = servtime; c->lastinput = servtime; clients.add(c); } } loopv(clients) { client &c = *clients[i]; if((c.message || c.output.length()) && ENET_SOCKETSET_CHECK(writeset, c.socket)) { const char *data = c.output.length() ? c.output.getbuf() : c.message->getbuf(); int len = c.output.length() ? c.output.length() : c.message->length(); ENetBuffer buf; buf.data = (void *)&data[c.outputpos]; buf.dataLength = len-c.outputpos; int res = enet_socket_send(c.socket, NULL, &buf, 1); if(res>=0) { c.outputpos += res; if(c.outputpos>=len) { if(c.output.length()) c.output.setsize(0); else { c.message->purge(); c.message = NULL; } c.outputpos = 0; if(!c.message && c.output.empty() && c.shouldpurge) { purgeclient(i--); continue; } } } else { purgeclient(i--); continue; } } if(ENET_SOCKETSET_CHECK(readset, c.socket)) { ENetBuffer buf; buf.data = &c.input[c.inputpos]; buf.dataLength = sizeof(c.input) - c.inputpos; int res = enet_socket_receive(c.socket, NULL, &buf, 1); if(res>0) { c.inputpos += res; c.input[min(c.inputpos, (int)sizeof(c.input)-1)] = '\0'; if(!checkclientinput(c)) { purgeclient(i--); continue; } } else { purgeclient(i--); continue; } } if(c.output.length() > OUTPUT_LIMIT) { purgeclient(i--); continue; } if(ENET_TIME_DIFFERENCE(servtime, c.lastinput) >= (c.registeredserver ? KEEPALIVE_TIME : CLIENT_TIME)) { purgeclient(i--); continue; } } } void banclients() { loopvrev(clients) if(checkban(bans, clients[i]->address.host)) purgeclient(i); } volatile bool reloadcfg = true; void reloadsignal(int signum) { reloadcfg = true; } int main(int argc, char **argv) { if(enet_initialize()<0) fatal("Unable to initialise network module"); atexit(enet_deinitialize); const char *dir = "", *ip = AC_MASTER_URI; int port = AC_MASTER_PORT; if(argc>=2) dir = argv[1]; if(argc>=3 && argv[2][0]) port = atoi(argv[2]); if(argc>=4) ip = argv[3][0] ? argv[3] : NULL; defformatstring(logname)("%smaster.log", dir); defformatstring(cfgname)("%smaster.cfg", dir); path(logname); path(cfgname); logfile = fopen(logname, "a"); if(!logfile) logfile = stdout; setvbuf(logfile, NULL, _IOLBF, 0); #ifndef WIN32 signal(SIGUSR1, reloadsignal); #endif setupserver(port, ip); for(;;) { if(reloadcfg) { conoutf("reloading master.cfg"); execfile(cfgname); bangameservers(); banclients(); gengbanlist(); reloadcfg = false; } servtime = enet_time_get(); checkclients(); checkgameservers(); } return EXIT_SUCCESS; } assaultcube-1.2.0.2.1/source/src/md2.h000066400000000000000000000300271352165075300172570ustar00rootroot00000000000000struct md2; md2 *loadingmd2 = 0; struct md2 : vertmodel { struct md2_header { int magic; int version; int skinwidth, skinheight; int framesize; int numskins, numvertices, numtexcoords; int numtriangles, numglcommands, numframes; int offsetskins, offsettexcoords, offsettriangles; int offsetframes, offsetglcommands, offsetend; }; struct md2_vertex { uchar vertex[3], normalindex; }; struct md2_frame { float scale[3]; float translate[3]; char name[16]; }; md2(const char *name) : vertmodel(name) {} int type() { return MDL_MD2; } struct md2part : part { void gentcverts(int *glcommands, vector &tcverts, vector &vindexes, vector &tris) { hashtable tchash; vector idxs; for(int *command = glcommands; (*command)!=0;) { int numvertex = *command++; bool isfan = numvertex<0; if(isfan) numvertex = -numvertex; idxs.setsize(0); loopi(numvertex) { union { int i; float f; } u, v; u.i = *command++; v.i = *command++; int vindex = *command++; ivec tckey(u.i, v.i, vindex); int *idx = tchash.access(tckey); if(!idx) { idx = &tchash[tckey]; *idx = tcverts.length(); tcvert &tc = tcverts.add(); tc.u = u.f; tc.v = v.f; vindexes.add((ushort)vindex); } idxs.add(*idx); } loopi(numvertex-2) { tri &t = tris.add(); if(isfan) { t.vert[0] = idxs[0]; t.vert[1] = idxs[i+1]; t.vert[2] = idxs[i+2]; } else loopk(3) t.vert[k] = idxs[i&1 && k ? i+(1-(k-1))+1 : i+k]; } } } bool load(char *path) { if(filename) return true; stream *file = openfile(path, "rb"); if(!file) return false; md2_header header; file->read(&header, sizeof(md2_header)); lilswap((int *)&header, sizeof(md2_header)/sizeof(int)); if(header.magic!=844121161 || header.version!=8) { delete file; return false; } numframes = header.numframes; mesh &m = *new mesh; meshes.add(&m); m.owner = this; int *glcommands = new int[header.numglcommands]; file->seek(header.offsetglcommands, SEEK_SET); int numglcommands = (int)file->read(glcommands, sizeof(int)*header.numglcommands)/sizeof(int); lilswap(glcommands, numglcommands); if(numglcommands < header.numglcommands) memset(&glcommands[numglcommands], 0, (header.numglcommands-numglcommands)*sizeof(int)); vector tcgen; vector vgen; vector trigen; gentcverts(glcommands, tcgen, vgen, trigen); delete[] glcommands; m.numverts = tcgen.length(); m.tcverts = new tcvert[m.numverts]; memcpy(m.tcverts, tcgen.getbuf(), m.numverts*sizeof(tcvert)); m.numtris = trigen.length(); m.tris = new tri[m.numtris]; memcpy(m.tris, trigen.getbuf(), m.numtris*sizeof(tri)); m.verts = new vec[m.numverts*numframes+1]; md2_vertex *tmpverts = new md2_vertex[header.numvertices]; int frame_offset = header.offsetframes; vec *curvert = m.verts; loopi(header.numframes) { md2_frame frame; file->seek(frame_offset, SEEK_SET); file->read(&frame, sizeof(md2_frame)); lilswap((float *)&frame, 6); file->read(tmpverts, sizeof(md2_vertex)*header.numvertices); loopj(m.numverts) { const md2_vertex &v = tmpverts[vgen[j]]; *curvert++ = vec(v.vertex[0]*frame.scale[0]+frame.translate[0], -(v.vertex[1]*frame.scale[1]+frame.translate[1]), v.vertex[2]*frame.scale[2]+frame.translate[2]); } frame_offset += header.framesize; } delete[] tmpverts; delete file; filename = newstring(path); return true; } void getdefaultanim(animstate &as, int anim, int varseed) { // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 21 23 24 // I R A P P P J L F S T W P CI CW CA CP CD D D D LD LD LD F static int frame[] = { 0, 40, 46, 54, 58, 62, 66, 69, 72, 84, 95, 112,123,135,154,160,169,173,178,184,190,183,189,197, 0 }; static int range[] = { 40, 6, 8, 4, 4, 4, 3, 3, 12, 11, 17, 11, 12, 19, 6, 9, 4, 5, 6, 6, 8, 1, 1, 1, 7 }; static int animfr[] = { 0, 1, 2, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 21, 24 }; if((size_t)anim >= sizeof(animfr)/sizeof(animfr[0])) { as.frame = 0; as.range = 1; return; } int n = animfr[anim]; if(anim==ANIM_PAIN || anim==ANIM_DEATH || anim==ANIM_LYING_DEAD) n += uint(varseed)%3; as.frame = frame[n]; as.range = range[n]; } void begingenshadow() { matrixpos = 0; matrixstack[0].identity(); matrixstack[0].rotate_around_z(180*RAD); } }; void render(int anim, int varseed, float speed, int basetime, const vec &o, float roll, float yaw, float pitch, dynent *d, modelattach *a, float scale) { if(!loaded) return; if(a) for(int i = 0; a[i].tag; i++) { if(a[i].pos) link(NULL, a[i].tag, a[i].pos); } if(!cullface) glDisable(GL_CULL_FACE); else if(anim&ANIM_MIRROR) glCullFace(GL_BACK); if(stenciling && !parts[0]->index) { shadowdir = vec(0, 1/SQRT2, -1/SQRT2); shadowdir.rotate_around_z((-shadowyaw-yaw-180.0f)*RAD); shadowdir.rotate_around_y(-pitch*RAD); shadowdir.rotate_around_x(roll*RAD); (shadowpos = shadowdir).mul(shadowdist); } modelpos = o; modelroll = roll; modelyaw = yaw; modelpitch = pitch; matrixpos = 0; quat q(- yaw - 180, pitch); matrixstack[0].fromquat(roll == 0.0f ? q : q.roll(roll)); matrixstack[0].translate(o); if(anim&ANIM_MIRROR || scale!=1) matrixstack[0].scale(scale, anim&ANIM_MIRROR ? -scale : scale, scale); parts[0]->render(anim, varseed, speed, basetime, d); if(!cullface) glEnable(GL_CULL_FACE); else if(anim&ANIM_MIRROR) glCullFace(GL_FRONT); if(a) for(int i = 0; a[i].tag; i++) { if(a[i].pos) link(NULL, a[i].tag, NULL); vertmodel *m = (vertmodel *)a[i].m; if(!m) continue; m->parts[0]->index = parts.length()+i; m->setskin(); m->render(anim, varseed, speed, basetime, o, roll, yaw, pitch, d, NULL, scale); } if(d) d->lastrendered = lastmillis; } void rendershadow(int anim, int varseed, float speed, int basetime, const vec &o, float yaw, modelattach *a) { parts[0]->rendershadow(anim, varseed, speed, basetime, o, yaw); if(a) for(int i = 0; a[i].tag; i++) { vertmodel *m = (vertmodel *)a[i].m; if(!m) continue; part *p = m->parts[0]; p->rendershadow(anim, varseed, speed, basetime, o, yaw); } } bool load() { if(loaded) return true; md2part &mdl = *new md2part; parts.add(&mdl); mdl.model = this; mdl.index = 0; const char *pname = parentdir(loadname); defformatstring(name1)("packages/models/%s/tris.md2", loadname); if(!mdl.load(path(name1))) { formatstring(name1)("packages/models/%s/tris.md2", pname); // try md2 in parent folder (vert sharing) if(!mdl.load(path(name1))) return false; } Texture *skin; loadskin(loadname, pname, skin); loopv(mdl.meshes) mdl.meshes[i]->skin = skin; if(skin==notexture) { conoutf("could not load model skin for %s", name1); flagmapconfigerror(LWW_MODELERR); } loadingmd2 = this; ASSERT(execcontext == IEXC_MDLCFG); defformatstring(name2)("packages/models/%s/md2.cfg", loadname); if(!execfile(name2)) { formatstring(name2)("packages/models/%s/md2.cfg", pname); execfile(name2); } loadingmd2 = NULL; loopv(parts) parts[i]->scaleverts(scale/16.0f, vec(translate.x, -translate.y, translate.z)); radius = calcradius(zradius); if(shadowdist) calcneighbors(); calcbbs(); return loaded = true; } }; void md2anim(char *anim, int *frame, int *range, float *speed) { if(!loadingmd2 || loadingmd2->parts.empty()) { conoutf("not loading an md2"); flagmapconfigerror(LWW_MODELERR); scripterr(); return; } int num = findanim(anim); if(num<0) { conoutf("could not find animation %s", anim); flagmapconfigerror(LWW_MODELERR); scripterr(); return; } loadingmd2->parts.last()->setanim(num, *frame, *range, *speed); } COMMAND(md2anim, "siif"); void md2tag(char *name, char *vert1, char *vert2, char *vert3, char *vert4) { if(!loadingmd2 || loadingmd2->parts.empty()) { conoutf("not loading an md2"); flagmapconfigerror(LWW_MODELERR); scripterr(); return; } md2::part &mdl = *loadingmd2->parts.last(); int indexes[4] = { -1, -1, -1, -1 }, numverts = 0; loopi(4) { char *vert = NULL; switch(i) { case 0: vert = vert1; break; case 1: vert = vert2; break; case 2: vert = vert3; break; case 3: vert = vert4; break; } if(!vert[0]) break; if(isdigit(vert[0])) indexes[i] = ATOI(vert); else { int axis = 0, dir = 1; for(char *s = vert; *s; s++) switch(*s) { case '+': dir = 1; break; case '-': dir = -1; break; case 'x': case 'X': axis = 0; break; case 'y': case 'Y': axis = 1; break; case 'z': case 'Z': axis = 2; break; } if(!mdl.meshes.empty()) indexes[i] = mdl.meshes[0]->findvert(axis, dir); } if(indexes[i] < 0) { conoutf("could not find vertex %s", vert); flagmapconfigerror(LWW_MODELERR); scripterr(); return; } numverts = i + 1; } if(!mdl.gentag(name, indexes, numverts)) { conoutf("could not generate tag %s", name); flagmapconfigerror(LWW_MODELERR); scripterr(); return; } } COMMAND(md2tag, "sssss"); void md2emit(char *tag, char *_type, int *arg1, int *arg2) { if(!loadingmd2 || loadingmd2->parts.empty()) { conoutf("not loading an md2"); flagmapconfigerror(LWW_MODELERR); scripterr(); return; }; int type = getlistindex(_type, particletypenames, true, -1); if(type < 0 || type >= MAXPARTYPES) { conoutf("unknown particle type %s", _type); flagmapconfigerror(LWW_MODELERR); scripterr(); return; }; md2::part &mdl = *loadingmd2->parts.last(); if(!mdl.addemitter(tag, type, *arg1, *arg2)) { conoutf("could not find tag %s", tag); flagmapconfigerror(LWW_MODELERR); scripterr(); return; } } COMMAND(md2emit, "ssii"); assaultcube-1.2.0.2.1/source/src/md3.h000066400000000000000000000260221352165075300172600ustar00rootroot00000000000000struct md3; md3 *loadingmd3 = NULL; string md3dir; struct md3tag { char name[64]; vec pos; float rotation[3][3]; }; struct md3vertex { short vertex[3]; short normal; }; struct md3triangle { int vertexindices[3]; }; struct md3header { char id[4]; int version; char name[64]; int flags; int numframes, numtags, nummeshes, numskins; int ofs_frames, ofs_tags, ofs_meshes, ofs_eof; // offsets }; struct md3meshheader { char id[4]; char name[64]; int flags; int numframes, numshaders, numvertices, numtriangles; int ofs_triangles, ofs_shaders, ofs_uv, ofs_vertices, meshsize; // offsets }; struct md3 : vertmodel { md3(const char *name) : vertmodel(name) {} int type() { return MDL_MD3; } struct md3part : part { bool load(char *path) { if(filename) return true; stream *f = openfile(path, "rb"); if(!f) return false; md3header header; f->read(&header, sizeof(md3header)); lilswap(&header.version, 1); lilswap(&header.flags, 9); if(strncmp(header.id, "IDP3", 4) != 0 || header.version != 15) // header check { delete f; conoutf("md3: corrupted header"); flagmapconfigerror(LWW_MODELERR); return false; } numframes = header.numframes; numtags = header.numtags; if(numtags) { tags = new tag[numframes*numtags]; f->seek(header.ofs_tags, SEEK_SET); md3tag tag; loopi(header.numframes*header.numtags) { f->read(&tag, sizeof(md3tag)); lilswap((float *)&tag.pos, 12); if(tag.name[0] && iseek(mesh_offset, SEEK_SET); f->read(&mheader, sizeof(md3meshheader)); lilswap(&mheader.flags, 10); if(mheader.numtriangles <= 0) { mesh_offset += mheader.meshsize; continue; } mesh &m = *meshes.add(new mesh); m.owner = this; m.name = newstring(mheader.name); m.numtris = mheader.numtriangles; m.tris = new tri[m.numtris]; f->seek(mesh_offset + mheader.ofs_triangles, SEEK_SET); loopj(mheader.numtriangles) { md3triangle tri; f->read(&tri, sizeof(md3triangle)); // read the triangles lilswap((int *)&tri, 3); loopk(3) m.tris[j].vert[k] = (ushort)tri.vertexindices[k]; } m.numverts = mheader.numvertices; m.tcverts = new tcvert[m.numverts]; f->seek(mesh_offset + mheader.ofs_uv , SEEK_SET); f->read(m.tcverts, 2*sizeof(float)*m.numverts); // read the UV data lilswap(&m.tcverts[0].u, 2*m.numverts); m.verts = new vec[numframes*m.numverts + 1]; f->seek(mesh_offset + mheader.ofs_vertices, SEEK_SET); loopj(numframes*mheader.numvertices) { md3vertex v; f->read(&v, sizeof(md3vertex)); // read the vertices lilswap((short *)&v, 4); m.verts[j].x = v.vertex[1]/64.0f; m.verts[j].y = v.vertex[0]/64.0f; m.verts[j].z = v.vertex[2]/64.0f; } mesh_offset += mheader.meshsize; } delete f; filename = newstring(path); return true; } void begingenshadow() { matrixpos = 0; matrixstack[0].identity(); matrixstack[0].rotate_around_z(180*RAD); } }; void render(int anim, int varseed, float speed, int basetime, const vec &o, float roll, float yaw, float pitch, dynent *d, modelattach *a, float scale) { if(!loaded) return; if(a) for(int i = 0; a[i].tag; i++) { vertmodel *m = (vertmodel *)a[i].m; if(!m) { if(a[i].pos) link(NULL, a[i].tag); continue; } part *p = m->parts[0]; if(link(p, a[i].tag, a[i].pos)) p->index = parts.length()+i; } if(!cullface) glDisable(GL_CULL_FACE); else if(anim&ANIM_MIRROR) glCullFace(GL_BACK); if(stenciling) { shadowdir = vec(0, 1/SQRT2, -1/SQRT2); shadowdir.rotate_around_z((-shadowyaw-yaw-180.0f)*RAD); shadowdir.rotate_around_y(-pitch*RAD); shadowdir.rotate_around_x(roll*RAD); (shadowpos = shadowdir).mul(shadowdist); } modelpos = o; modelroll = roll; modelyaw = yaw; modelpitch = pitch; matrixpos = 0; quat q(- yaw - 180, pitch); matrixstack[0].fromquat(roll == 0.0f ? q : q.roll(roll)); matrixstack[0].translate(o); if(anim&ANIM_MIRROR || scale!=1) matrixstack[0].scale(scale, anim&ANIM_MIRROR ? -scale : scale, scale); parts[0]->render(anim, varseed, speed, basetime, d); if(!cullface) glEnable(GL_CULL_FACE); else if(anim&ANIM_MIRROR) glCullFace(GL_FRONT); if(a) for(int i = 0; a[i].tag; i++) link(NULL, a[i].tag); if(d) d->lastrendered = lastmillis; } void rendershadow(int anim, int varseed, float speed, int basetime, const vec &o, float yaw, modelattach *a) { if(parts.length()>1) return; parts[0]->rendershadow(anim, varseed, speed, basetime, o, yaw); } bool load() { if(loaded) return true; formatstring(md3dir)("packages/models/%s", loadname); const char *pname = parentdir(loadname); defformatstring(cfgname)("packages/models/%s/md3.cfg", loadname); loadingmd3 = this; ASSERT(execcontext == IEXC_MDLCFG); if(execfile(cfgname) && parts.length()) // configured md3, will call the md3* commands below { loadingmd3 = NULL; if(parts.empty()) return false; loopv(parts) if(!parts[i]->filename) return false; } else // md3 without configuration, try default tris and skin { loadingmd3 = NULL; md3part &mdl = *new md3part; parts.add(&mdl); mdl.model = this; mdl.index = 0; defformatstring(name1)("packages/models/%s/tris.md3", loadname); if(!mdl.load(path(name1))) { formatstring(name1)("packages/models/%s/tris.md3", pname); // try md3 in parent folder (vert sharing) if(!mdl.load(path(name1))) return false; }; Texture *skin; loadskin(loadname, pname, skin); loopv(mdl.meshes) mdl.meshes[i]->skin = skin; if(skin==notexture) { conoutf("could not load model skin for %s", name1); flagmapconfigerror(LWW_MODELERR); } } loopv(parts) parts[i]->scaleverts(scale/16.0f, vec(translate.x, -translate.y, translate.z)); radius = calcradius(zradius); if(shadowdist) calcneighbors(); calcbbs(); return loaded = true; } }; void md3load(char *model) { if(!loadingmd3) { conoutf("not loading an md3"); flagmapconfigerror(LWW_MODELERR); scripterr(); return; }; filtertext(model, model, FTXT__MEDIAFILEPATH); defformatstring(filename)("%s/%s", md3dir, model); md3::md3part &mdl = *new md3::md3part; loadingmd3->parts.add(&mdl); mdl.model = loadingmd3; mdl.index = loadingmd3->parts.length()-1; if(!mdl.load(path(filename))) { conoutf("could not load %s", filename); flagmapconfigerror(LWW_MODELERR); scripterr(); } // ignore failure } COMMAND(md3load, "s"); void md3skin(char *objname, char *skin) { filtertext(skin, skin, FTXT__MEDIAFILEPATH); if(!loadingmd3 || loadingmd3->parts.empty()) { conoutf("not loading an md3"); flagmapconfigerror(LWW_MODELERR); scripterr(); return; }; md3::part &mdl = *loadingmd3->parts.last(); bool used = false; loopv(mdl.meshes) { md3::mesh &m = *mdl.meshes[i]; if(!strcmp(objname, "*") || !strcmp(m.name, objname)) { defformatstring(spath)("%s/%s", md3dir, skin); m.skin = textureload(spath); used = true; } } if(!used) { defformatstring(s)(", possibilities are: *"); loopv(mdl.meshes) concatformatstring(s, "|%s", mdl.meshes[i]->name); conoutf("mesh \"%s\" not found in model %s, skin %s not loaded%s", objname, loadingmd3->loadname, skin, mdl.meshes.length() ? s : ""); flagmapconfigerror(LWW_MODELERR); scripterr(); } } COMMAND(md3skin, "ss"); void md3anim(char *anim, int *startframe, int *range, float *speed) { if(!loadingmd3 || loadingmd3->parts.empty()) { conoutf("not loading an md3"); flagmapconfigerror(LWW_MODELERR); scripterr(); return; }; int num = findanim(anim); if(num<0) { conoutf("could not find animation %s", anim); flagmapconfigerror(LWW_MODELERR); scripterr(); return; }; loadingmd3->parts.last()->setanim(num, *startframe, *range, *speed); } COMMAND(md3anim, "siif"); void md3link(int *parent, int *child, char *tagname) { if(!loadingmd3) { conoutf("not loading an md3"); return; }; if(!loadingmd3->parts.inrange(*parent) || !loadingmd3->parts.inrange(*child)) { conoutf("no models loaded to link"); flagmapconfigerror(LWW_MODELERR); scripterr(); return; } if(!loadingmd3->parts[*parent]->link(loadingmd3->parts[*child], tagname)) { conoutf("could not link model %s", loadingmd3->loadname); flagmapconfigerror(LWW_MODELERR); scripterr(); } } COMMAND(md3link, "iis"); void md3emit(char *tag, char *_type, int *arg1, int *arg2) { if(!loadingmd3 || loadingmd3->parts.empty()) { conoutf("not loading an md3"); flagmapconfigerror(LWW_MODELERR); scripterr(); return; }; int type = getlistindex(_type, particletypenames, true, -1); if(type < 0 || type >= MAXPARTYPES) { conoutf("unknown particle type %s", _type); flagmapconfigerror(LWW_MODELERR); scripterr(); return; }; md3::part &mdl = *loadingmd3->parts.last(); if(!mdl.addemitter(tag, type, *arg1, *arg2)) { conoutf("could not find tag %s", tag); flagmapconfigerror(LWW_MODELERR); scripterr(); return; } } COMMAND(md3emit, "ssii"); assaultcube-1.2.0.2.1/source/src/menus.cpp000066400000000000000000001426061352165075300202660ustar00rootroot00000000000000// menus.cpp: ingame menu system (also used for scores and serverlist) #include "cube.h" hashtable menus; gmenu *curmenu = NULL, *lastmenu = NULL; color *menuselbgcolor, *menuseldescbgcolor = NULL; static int menurighttabwidth = 888; // width of sliders and text input fields (is adapted to font and screen size later) vector menustack; COMMANDF(curmenu, "", () {result(curmenu ? curmenu->name : "");} ); inline gmenu *setcurmenu(gmenu *newcurmenu) // only change curmenu through here! { curmenu = newcurmenu; keyrepeat(curmenu && curmenu->allowinput && !curmenu->hotkeys, KR_MENU); return curmenu; } void menuset(void *m, bool save) { if(curmenu==m) return; if(curmenu) { if(save && curmenu->allowinput) menustack.add(curmenu); else curmenu->close(); } if(setcurmenu((gmenu *)m)) curmenu->open(); } void showmenu(const char *name, bool top) { menurighttabwidth = max(VIRTW/4, 15 * text_width("w")); // adapt to screen and font size every time a menu opens if(!name) { setcurmenu(NULL); return; } gmenu *m = menus.access(name); if(!m) return; if(!top && curmenu) { if(curmenu==m) return; loopv(menustack) if(menustack[i]==m) return; menustack.insert(0, m); return; } menuset(m); } void closemenu(const char *name) { gmenu *m; if(!name) { if(curmenu) curmenu->close(); while(!menustack.empty()) { m = menustack.pop(); if(m) m->close(); } setcurmenu(NULL); return; } m = menus.access(name); if(!m) return; if(curmenu==m) menuset(menustack.empty() ? NULL : menustack.pop(), false); else loopv(menustack) { if(menustack[i]==m) { menustack.remove(i); return; } } } COMMAND(closemenu, "s"); void showmenu_(const char *name) { showmenu(name, true); } COMMANDN(showmenu, showmenu_, "s"); const char *persistentmenuselectionalias(const char *name) { static defformatstring(al)("__lastmenusel_%s", name); filtertext(al, al, FTXT__ALIAS); return al; } void menuselect(void *menu, int sel) { gmenu &m = *(gmenu *)menu; if(sel<0) sel = m.items.length()>0 ? m.items.length()-1 : 0; else if(sel>=m.items.length()) sel = 0; if(m.items.inrange(sel)) { int oldsel = m.menusel; m.menusel = sel; if(m.allowinput) { if(sel!=oldsel) { if(m.items.inrange(oldsel)) m.items[oldsel]->focus(false); if(!m.items[sel]->greyedout) m.items[sel]->focus(true); audiomgr.playsound(S_MENUSELECT, SP_HIGHEST); if(m.persistentselection) { defformatstring(val)("%d", sel); alias(persistentmenuselectionalias(m.name), val); } } } } } void drawarrow(int dir, int x, int y, int size, float r = 1.0f, float g = 1.0f, float b = 1.0f) { glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); glColor3f(r, g, b); glBegin(GL_TRIANGLES); glVertex2f(x, dir ? y+size : y); glVertex2f(x+size/2, dir ? y : y+size); glVertex2f(x+size, dir ? y+size : y); glEnd(); xtraverts += 3; glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); } #define MAXMENU 34 bool menuvisible() { if(!curmenu) return false; return true; } extern void *scoremenu; void rendermenu() { if(curmenu != scoremenu) setscope(false); gmenu &m = *curmenu; m.refresh(); m.render(); } void mitem::render(int x, int y, int w) { if(isselection()) renderbg(x, y, w, menuselbgcolor); else if(bgcolor) renderbg(x, y, w, bgcolor); } void mitem::renderbg(int x, int y, int w, color *c) { if(isselection()) blendbox(x-FONTH/4, y-FONTH/6, x+w+FONTH/4, y+FONTH+FONTH/6, false, -1, c); else blendbox(x, y, x+w, y+FONTH, false, -1, c); } int mitem::execaction(const char *arg1) { int result = 0; if(getaction()) { if(curmenu) setcontext("menu", curmenu->name); push("arg1", arg1); result = execute(getaction()); pop("arg1"); resetcontext(); } return result; } bool mitem::isselection() { return parent->allowinput && !parent->hotkeys && parent->items.inrange(parent->menusel) && parent->items[parent->menusel]==this; } color mitem::gray(0.2f, 0.2f, 0.2f); color mitem::white(1.0f, 1.0f, 1.0f); color mitem::whitepulse(1.0f, 1.0f, 1.0f); bool mitem::menugreyedout = false; // text item struct mitemmanual : mitem { const char *text, *action, *hoveraction, *desc; mitemmanual(gmenu *parent, char *text, char *action, char *hoveraction, color *bgcolor, const char *desc) : mitem(parent, bgcolor, mitem::TYPE_MANUAL), text(text), action(action), hoveraction(hoveraction), desc(desc) {} virtual int width() { return text_width(text) + (strchr(text, '\n') ? menurighttabwidth : 0); } virtual void render(int x, int y, int w) { int c = greyedout ? 128 : 255; mitem::render(x, y, w); const char *nl = strchr(text, '\n'); if(nl) { string l; copystring(l, text, min(MAXSTRLEN, (int)strcspn(text, "\n") + 1)); draw_text(l, x, y, c, c, c); draw_text(nl + 1, x + w - max(menurighttabwidth, text_width(nl + 1)), y, c, c, c); } else draw_text(text, x, y, c, c, c); } virtual void focus(bool on) { if(on && hoveraction) execute(hoveraction); } virtual int select() { int result = 0; if(action && action[0]) { gmenu *oldmenu = curmenu; result = execaction(text); if(result >= 0 && oldmenu == curmenu) { menuset(NULL, false); menustack.shrink(0); } } return result; } virtual const char *getdesc() { return desc; } virtual const char *gettext() { return text; } virtual const char *getaction() { return action; } }; struct mitemtext : mitemmanual { mitemtext(gmenu *parent, char *text, char *action, char *hoveraction, color *bgcolor, const char *desc = NULL) : mitemmanual(parent, text, action, hoveraction, bgcolor, desc) {} virtual ~mitemtext() { DELETEA(text); DELETEA(action); DELETEA(hoveraction); DELETEA(desc); } }; VARP(hidebigmenuimages, 0, 0, 1); struct mitemimagemanual : mitemmanual { Texture *image; font *altfont; mitemimagemanual(gmenu *parent, const char *filename, const char *altfontname, char *text, char *action, char *hoveraction, color *bgcolor, const char *desc = NULL) : mitemmanual(parent, text, action, hoveraction, bgcolor, desc) { image = filename ? textureload(filename, 3) : NULL; altfont = altfontname ? getfont(altfontname) : NULL; } virtual ~mitemimagemanual() {} virtual int width() { if(image && *text != '\t') return (FONTH*image->xs)/image->ys + FONTH/2 + mitemmanual::width(); return mitemmanual::width(); } virtual void render(int x, int y, int w) { mitem::render(x, y, w); if(image || altfont) { int xs = 0, c = greyedout ? 128 : 255; if(image) { xs = (FONTH*image->xs)/image->ys; framedquadtexture(image->id, x, y, xs, FONTH, 0, 255, true); } draw_text(text, !image || *text == '\t' ? x : x+xs + FONTH/2, y, c, c, c); if(altfont && strchr(text, '\a')) { char *r = newstring(text), *re, *l = r; while((re = strchr(l, '\a')) && re[1]) { *re = '\0'; x += text_width(l); l = re + 2; pushfont(altfont->name); draw_textf("%s%c", x, y, greyedout ? "\f4" : "", re[1]); popfont(); } delete[] r; } if(image && isselection() && !hidebigmenuimages && image->ys > FONTH) { w += FONTH; int xs = (2 * VIRTW - w) / 5, ys = (xs * image->ys) / image->xs; x = (6 * VIRTW + w - 2 * xs) / 4; y = VIRTH - ys / 2; framedquadtexture(image->id, x, y, xs, ys, FONTH); } } else mitemmanual::render(x, y, w); } }; struct mitemimage : mitemimagemanual { mitemimage(gmenu *parent, const char *filename, char *text, char *action, char *hoveraction, color *bgcolor, const char *desc = NULL, const char *altfont = NULL) : mitemimagemanual(parent, filename, altfont, text, action, hoveraction, bgcolor, desc) {} virtual ~mitemimage() { DELETEA(text); DELETEA(action); DELETEA(hoveraction); DELETEA(desc); } }; VARP(browsefiledesc, 0, 1, 1); struct mitemmapload : mitemmanual { const char *filename, *mapmessage; Texture *image; mitemmapload(gmenu *parent, const char *filename, char *text, char *action, char *hoveraction, const char *desc) : mitemmanual(parent, text, action, hoveraction, NULL, desc), filename(filename), mapmessage(NULL), image(NULL) {} virtual ~mitemmapload() { delstring(filename); DELETEA(mapmessage); DELETEA(text); DELETEA(action); DELETEA(hoveraction); DELETEA(desc); } virtual void key(int code, bool isdown) { if(code == SDLK_LEFT && parent->xoffs > -50) parent->xoffs -= 2; else if(code == SDLK_RIGHT && parent->xoffs < 50) parent->xoffs += 2; } virtual void render(int x, int y, int w) { int c = greyedout ? 128 : 255; mitem::render(x, y, w); draw_text(text, x, y, c, c, c); if(isselection()) { if(!image && !mapmessage) { // load map description and preview picture silent_texture_load = true; const char *cgzpath = "packages" PATHDIVS "maps"; if(browsefiledesc) { // checking map messages is slow and may be disabled mapmessage = getfiledesc(cgzpath, behindpath(filename), "cgz"); // check for regular map if(!mapmessage) mapmessage = getfiledesc((cgzpath = "packages" PATHDIVS "maps" PATHDIVS "official"), behindpath(filename), "cgz"); // check for official map } defformatstring(p2p)("%s/preview/%s.jpg", cgzpath, filename); if(!hidebigmenuimages) image = textureload(p2p, 3); if(!image || image == notexture) image = textureload("packages/misc/nopreview.jpg", 3); silent_texture_load = false; } w += FONTH; int xs = (2 * VIRTW - w - x) / 2, xp = x + w + xs / 2, ym = VIRTH - FONTH/2; if(image && !hidebigmenuimages && image->ys > FONTH) { int ys = (xs * image->ys) / image->xs, yp = VIRTH - ys / 2; ym = yp + ys + 2 * FONTH; framedquadtexture(image->id, xp, yp, xs, ys, FONTH); draw_text(text, xp + xs/2 - text_width(text)/2, yp + ys); } if(mapmessage && *mapmessage) draw_text(mapmessage, xp - FONTH, ym, 0xFF, 0xFF, 0xFF, 0xFF, -1, 2 * VIRTW - (xp - FONTH) - FONTH/2); } } }; // text input item struct mitemtextinput : mitemtext { textinputbuffer input; char *defaultvalueexp; bool modified, hideinput; mitemtextinput(gmenu *parent, char *text, char *value, char *action, char *hoveraction, color *bgcolor, int maxchars, int maskinput) : mitemtext(parent, text, action, hoveraction, bgcolor), defaultvalueexp(value), modified(false), hideinput(false) { mitemtype = TYPE_TEXTINPUT; copystring(input.buf, value); input.max = maxchars > 0 ? min(maxchars, MAXSTRLEN - 1) : 15; hideinput = (maskinput != 0); } virtual int width() { return text_width(text) + menurighttabwidth; } virtual void render(int x, int y, int w) { int c = greyedout ? 128 : 255; bool sel = isselection(); if(sel) { renderbg(x+w-menurighttabwidth, y-FONTH/6, menurighttabwidth, menuselbgcolor); renderbg(x, y-FONTH/6, w-menurighttabwidth-FONTH/2, menuseldescbgcolor); } draw_text(text, x, y, c, c, c); int cibl = (int)strlen(input.buf); // current input-buffer length int iboff = input.pos > 14 ? (input.pos < cibl ? input.pos - 14 : cibl - 14) : (input.pos == -1 ? (cibl > 14 ? cibl - 14 : 0) : 0); // input-buffer offset string showinput, tempinputbuf; int sc = 14; copystring(tempinputbuf, input.buf); if(hideinput && !(SDL_GetModState() & MOD_KEYS_CTRL)) { // "mask" user input with asterisks, use for menuitemtextinputs that take passwords for(char *c = tempinputbuf; *c; c++) *c = '*'; } while(iboff > 0) { copystring(showinput, tempinputbuf + iboff - 1, sc + 2); if(text_width(showinput) > menurighttabwidth) break; iboff--; sc++; } while(iboff + sc < cibl) { copystring(showinput, tempinputbuf + iboff, sc + 2); if(text_width(showinput) > menurighttabwidth) break; sc++; } copystring(showinput, tempinputbuf + iboff, sc + 1); draw_text(showinput, x+w-menurighttabwidth, y, c, c, c, 255, sel && !greyedout ? (input.pos>=0 ? (input.pos > sc ? sc : input.pos) : cibl) : -1); } virtual void focus(bool on) { if(on && hoveraction) execute(hoveraction); textinput(on, TI_MENU); if(action && !on && modified && parent->items.find(this) != parent->items.length() - 1) { modified = false; execaction(input.buf); } } virtual void key(int code, bool isdown) { if(input.key(code)) modified = true; if(action && code == SDLK_RETURN && modified && parent->items.find(this) != parent->items.length() - 1) { modified = false; execaction(input.buf); } } void say(const char *text) { if(input.say(text)) modified = true; } virtual void init() { setdefaultvalue(); modified = false; } virtual int select() { int result = 0; if(parent->menusel == parent->items.length() - 1) { const char *tmp = text; text = input.buf; result = mitemmanual::select(); text = tmp; } return result; } void setdefaultvalue() { const char *p = defaultvalueexp; char *r = executeret(p); copystring(input.buf, r ? r : ""); if(r) delete[] r; } }; // slider item VARP(wrapslider, 0, 0, 1); struct mitemslider : mitem { int min_, max_, step, value, maxvaluewidth; char *text, *valueexp, *action; string curval; vector opts; bool wrap, isradio; mitemslider(gmenu *parent, char *text, int _min, int _max, char *value, char *display, char *action, color *bgcolor, bool wrap, bool isradio) : mitem(parent, bgcolor, mitem::TYPE_SLIDER), min_(_min), max_(_max), value(_min), maxvaluewidth(0), text(text), valueexp(value), action(action), wrap(wrap), isradio(isradio) { char *enddigits; step = (int) strtol(display, &enddigits, 10); if(!*display || *enddigits) { step = 1; explodelist(display, opts); if(max_ - min_ + 1 != opts.length()) { if(max_ != -1) clientlogf("menuitemslider: display string length (%d) doesn't match max-min (%d) \"%s\" [%s]", opts.length(), max_ - min_ + 1, text, display); max_ = min_ + opts.length() - 1; } } getmaxvaluewidth(); } virtual ~mitemslider() { opts.deletearrays(); DELETEA(text); DELETEA(valueexp); DELETEA(action); } virtual int width() { return text_width(text) + (isradio ? 0 : menurighttabwidth) + maxvaluewidth + 2*FONTH; } virtual void render(int x, int y, int w) { bool sel = isselection(); int range = max_-min_; int cval = value-min_; int tw = text_width(text), ow = isradio ? text_width(curval) : menurighttabwidth, pos = !isradio || ow < menurighttabwidth ? menurighttabwidth : ow; if(sel) { renderbg(x + w - pos, y, ow, menuselbgcolor); renderbg(x, y, w - pos - FONTH/2, menuseldescbgcolor); if(pos - ow > FONTH/2) renderbg(x + w - pos + ow + FONTH/2, y, pos - ow - FONTH/2, menuseldescbgcolor); } int c = greyedout ? 128 : 255; draw_text(text, x, y, c, c, c); draw_text(curval, x + (isradio ? w - pos : tw), y, c, c, c); if(!isradio) { blendbox(x+w-menurighttabwidth, y+FONTH/3, x+w, y+FONTH*2/3, false, -1, &gray); int offset = (int)(cval/((float)range)*menurighttabwidth); blendbox(x+w-menurighttabwidth+offset-FONTH/6, y, x+w-menurighttabwidth+offset+FONTH/6, y+FONTH, false, -1, greyedout ? &gray : (sel ? &whitepulse : &white)); } } virtual void key(int code, bool isdown) { if(code == SDLK_LEFT) slide(false); else if(code == SDLK_RIGHT) slide(true); } virtual void init() { const char *p = valueexp; char *v = executeret(p); if(v) { value = clamp(int(ATOI(v)), min_, max_); delete[] v; } displaycurvalue(); } void slide(bool right) { value += right ? step : -step; if (wrapslider || wrap) { if (value > max_) value = min_; if (value < min_) value = max_; } else value = min(max_, max(min_, value)); displaycurvalue(); if(action) { string v; itoa(v, value); execaction(v); } } void displaycurvalue() { if(isradio) { *curval = '\0'; loopv(opts) concatformatstring(curval, "%s\1%c %s", i ? " " : "", (i + min_ == value) ? '\11' : '\10', opts[i]); } else if(opts.length()) // extract display name from list { int idx = value - min_; copystring(curval, opts.inrange(idx) ? opts[idx] : ""); } else itoa(curval, value); // display number only } void getmaxvaluewidth() { int oldvalue = value; maxvaluewidth = 0; for(int v = min_; v <= max_; v++) { value = v; displaycurvalue(); maxvaluewidth = max(text_width(curval), maxvaluewidth); } value = oldvalue; displaycurvalue(); } virtual const char *getaction() { return action; } }; // key input item struct mitemkeyinput : mitem { char *text, *bindcmd; const char *keyname; vector newkeys; int isup, bindtype; string keynames; static const char *unknown, *empty; bool capture; mitemkeyinput(gmenu *parent, char *text, char *bindcmd, color *bgcolor, int bindtype) : mitem(parent, bgcolor, mitem::TYPE_KEYINPUT), text(text), bindcmd(bindcmd), keyname(NULL), isup(0), bindtype(bindtype), capture(false) {}; ~mitemkeyinput() { DELETEA(text); DELETEA(bindcmd); } virtual int width() { return text_width(text)+text_width(keyname ? keyname : " "); } virtual void render(int x, int y, int w) { int tw = text_width(keyname ? keyname : " "), c = greyedout ? 128 : 255; static color capturec(0.4f, 0, 0); if(isselection()) { blendbox(x+w-tw-FONTH, y-FONTH/6, x+w+FONTH, y+FONTH+FONTH/6, false, -1, capture ? &capturec : NULL); blendbox(x, y-FONTH/6, x+w-tw-FONTH, y+FONTH+FONTH/6, false, -1, menuseldescbgcolor); } draw_text(text, x, y, c, c, c); draw_text(keyname, x+w-tw, y, c, c, c); } virtual void init() { keynames[0] = 0; for(keym **km = findbinda(bindcmd, bindtype); *km; km++) concatformatstring(keynames, " or %s", (*km)->name); keyname = *keynames ? keynames + 4 : unknown; capture = false; menuheader(parent, NULL, NULL); } virtual int select() { capture = true; isup = 0; keyname = empty; newkeys.setsize(0); keynames[0] = '\0'; return 0; } virtual void key(int code, bool isdown) { keym *km; if(!capture || !((km = findbindc(code)))) return; if(code == SDLK_ESCAPE) { capture = false; parent->init(); return; } bool known = newkeys.find(code) >= 0; if(isdown) { if(!known) { if(km->actions[bindtype][0] && strcmp(km->actions[bindtype], bindcmd)) { static defformatstring(keybound)("\f3Warning: \"%s\" key is already in use. You can press ESC to cancel.", km->name); menuheader(parent, NULL, keybound); } newkeys.add(code); concatformatstring(keynames, "%s or ", km->name); keyname = keynames; } } else { if(known && ++isup == newkeys.length()) { for(keym **km = findbinda(bindcmd, bindtype); *km; km++) bindkey(*km, "", bindtype); // clear existing binds to this cmd bool bindfailed = false; loopv(newkeys) bindfailed = !bindc(newkeys[i], bindcmd, bindtype) || bindfailed; if(bindfailed) conoutf("\f3could not bind key"); else parent->init(); // show new keys } } } }; const char *mitemkeyinput::unknown = "?"; const char *mitemkeyinput::empty = " "; // checkbox menu item struct mitemcheckbox : mitem { char *text, *valueexp, *action; int pos; bool checked; mitemcheckbox(gmenu *parent, char *text, char *value, char *action, int pos, color *bgcolor) : mitem(parent, bgcolor, mitem::TYPE_CHECKBOX), text(text), valueexp(value), action(action), pos(pos), checked(false) {} ~mitemcheckbox() { DELETEA(text); DELETEA(valueexp); DELETEA(action); } virtual int width() { return text_width(text) + (pos ? menurighttabwidth : FONTH + FONTH/3); } virtual int select() { checked = !checked; return execaction(checked ? "1" : "0"); } virtual void init() { const char *p = valueexp; char *r = executeret(p); checked = (r && atoi(r) > 0); if(r) delete[] r; } virtual void render(int x, int y, int w) { bool sel = isselection(); const static int boxsize = FONTH; int offs = ((menurighttabwidth - FONTH) * ((msctrl % 41) ? pos : (50 + 50 * sinf(totalmillis / 300.0f + y)))) / 100; int c = greyedout ? 128 : 255; if(sel) { renderbg(x, y, w-boxsize-offs-FONTH/2, menuseldescbgcolor); renderbg(x+w-boxsize-offs, y, boxsize, menuselbgcolor); if(offs > FONTH/2) renderbg(x+w-offs+FONTH/2, y, offs-FONTH/2, menuseldescbgcolor); } draw_text(text, x, y, c, c, c); x -= offs; blendbox(x+w-boxsize, y, x+w, y+boxsize, false, -1, &gray); color *col = greyedout ? &gray : (sel ? &whitepulse : &white); if(checked) { int x1 = x+w-boxsize-FONTH/6, x2 = x+w+FONTH/6, y1 = y-FONTH/6, y2 = y+boxsize+FONTH/6; line(x1, y1, x2, y2, col); line(x2, y1, x1, y2, col); } } virtual const char *getaction() { return action; } }; // console iface void *addmenu(const char *name, const char *title, bool allowinput, void (__cdecl *refreshfunc)(void *, bool), bool (__cdecl *keyfunc)(void *, int, bool), bool hotkeys, bool forwardkeys) { gmenu *m = menus.access(name); if(!m) { name = newstring(name); m = &menus[name]; m->name = name; m->initaction = NULL; m->header = m->footer = NULL; m->menusel = 0; } m->title = title; DELSTRING(m->mdl); m->allowinput = allowinput; m->inited = false; m->hotkeys = hotkeys; m->refreshfunc = refreshfunc; m->keyfunc = keyfunc; DELSTRING(m->usefont); m->allowblink = false; m->forwardkeys = forwardkeys; lastmenu = m; mitem::menugreyedout = false; return m; } void newmenu(char *name, int *hotkeys, int *forwardkeys) { addmenu(name, NULL, true, NULL, NULL, *hotkeys > 0, *forwardkeys > 0); } COMMAND(newmenu, "sii"); void menureset(void *menu) { gmenu &m = *(gmenu *)menu; m.items.deletecontents(); } void delmenu(const char *name) { if (!name) return; gmenu *m = menus.access(name); if (!m) return; else menureset(m); } COMMAND(delmenu, "s"); void menuitemmanual(void *menu, char *text, char *action, color *bgcolor, const char *desc) { gmenu &m = *(gmenu *)menu; m.items.add(new mitemmanual(&m, text, action, NULL, bgcolor, desc)); } void menuimagemanual(void *menu, const char *filename, const char *altfontname, char *text, char *action, color *bgcolor, const char *desc) { gmenu &m = *(gmenu *)menu; m.items.add(new mitemimagemanual(&m, filename, altfontname, text, action, NULL, bgcolor, desc)); } void menutitlemanual(void *menu, const char *title) { gmenu &m = *(gmenu *)menu; m.title = title; } void menuheader(void *menu, char *header, char *footer, bool heap) { gmenu &m = *(gmenu *)menu; if(m.headfootheap) { DELSTRING(m.header); DELSTRING(m.footer); } m.header = (header && *header) || heap ? header : NULL; m.footer = (footer && *footer) || heap ? footer : NULL; m.headfootheap = heap; // false: "manual" } COMMANDF(menuheader, "ss", (char *header, char *footer) { if(lastmenu) menuheader(lastmenu, *header ? newstring(header) : NULL, *footer ? newstring(footer) : NULL, true); }); void menufont(char *menu, const char *usefont) { gmenu *m = *menu ? menus.access(menu) : lastmenu; if(m) { DELSTRING(m->usefont); m->usefont = usefont && *usefont ? newstring(usefont) : NULL; } } COMMAND(menufont, "ss"); void setmenublink(int *truth) { if(!lastmenu) return; gmenu &m = *(gmenu *)lastmenu; m.allowblink = *truth != 0; } COMMANDN(menucanblink, setmenublink, "i"); void menuinit(char *initaction) { if(!lastmenu) return; DELSTRING(lastmenu->initaction); lastmenu->initaction = newstring(initaction); } COMMAND(menuinit, "s"); void menuinitselection(int *line) { if(!lastmenu) return; if(lastmenu->items.inrange(*line)) lastmenu->menusel = *line; else lastmenu->menuselinit = *line; } COMMAND(menuinitselection, "i"); void menuselectionpersistent() { if(!curmenu) return; curmenu->persistentselection = true; const char *val = getalias(persistentmenuselectionalias(curmenu->name)); if(val) menuselect(curmenu, ATOI(val)); } COMMAND(menuselectionpersistent, ""); void menusynctabstops(int *onoff) { if(curmenu) curmenu->synctabstops = *onoff != 0; } COMMAND(menusynctabstops, "i"); void menurenderoffset(int *xoff, int *yoff) { if(!lastmenu) return; lastmenu->xoffs = *xoff; lastmenu->yoffs = *yoff; } COMMAND(menurenderoffset, "ii"); void menuselection(char *menu, int *line) { if(!menu || !menus.access(menu)) return; gmenu &m = menus[menu]; menuselect(&m, *line); } COMMAND(menuselection, "si"); void menuitemgreyedout(int *onoff) { mitem::menugreyedout = *onoff != 0; } COMMAND(menuitemgreyedout, "i"); void menuitem(char *text, char *action, char *hoveraction, char *desc) { if(!lastmenu) return; lastmenu->items.add(new mitemtext(lastmenu, newstring(text), newstring(action[0] ? action : text), hoveraction[0] ? newstring(hoveraction) : NULL, NULL, *desc ? newstring(desc) : NULL)); } COMMAND(menuitem, "ssss"); void menuitemimage(char *name, char *text, char *action, char *hoveraction) { if(!lastmenu) return; if(fileexists(name, "r") || findfile(name, "r") != name) lastmenu->items.add(new mitemimage(lastmenu, name, newstring(text), action[0] ? newstring(action) : NULL, hoveraction[0] ? newstring(hoveraction) : NULL, NULL)); else lastmenu->items.add(new mitemtext(lastmenu, newstring(text), newstring(action[0] ? action : text), hoveraction[0] ? newstring(hoveraction) : NULL, NULL)); } COMMAND(menuitemimage, "ssss"); void menuitemaltfont(char *altfont, char *text, char *action, char *hoveraction, char *desc) { if(!lastmenu) return; lastmenu->items.add(new mitemimage(lastmenu, NULL, newstring(text), action[0] ? newstring(action) : NULL, hoveraction[0] ? newstring(hoveraction) : NULL, NULL, desc[0] ? newstring(desc) : NULL, altfont)); } COMMAND(menuitemaltfont, "sssss"); void menuitemmapload(char *name, char *action, char *hoveraction, char *desc) { if(!lastmenu) return; lastmenu->items.add(new mitemmapload(lastmenu, newstring(name), newstring(name), *action ? newstring(action) : NULL, *hoveraction ? newstring(hoveraction) : NULL, *desc ? newstring(desc) : NULL)); } COMMAND(menuitemmapload, "ssss"); void menuitemtextinput(char *text, char *value, char *action, char *hoveraction, int *maxchars, int *maskinput) { if(!lastmenu || !text || !value) return; lastmenu->items.add(new mitemtextinput(lastmenu, newstring(text), newstring(value), action[0] ? newstring(action) : NULL, hoveraction[0] ? newstring(hoveraction) : NULL, NULL, *maxchars, *maskinput)); } COMMAND(menuitemtextinput, "ssssii"); void menuitemslider(char *text, int *min_, int *max_, char *value, char *display, char *action, int *wrap) { if(!lastmenu) return; lastmenu->items.add(new mitemslider(lastmenu, newstring(text), *min_, *max_, newstring(value), display, action[0] ? newstring(action) : NULL, NULL, *wrap != 0, false)); } COMMAND(menuitemslider, "siisssi"); void menuitemradio(char *text, int *min_, int *max_, char *value, char *display, char *action) { if(!lastmenu) return; lastmenu->items.add(new mitemslider(lastmenu, newstring(text), *min_, *max_, newstring(value), display, action[0] ? newstring(action) : NULL, NULL, true, true)); } COMMAND(menuitemradio, "siisss"); void menuitemcheckbox(char *text, char *value, char *action, int *pos) { if(!lastmenu) return; lastmenu->items.add(new mitemcheckbox(lastmenu, newstring(text), newstring(value), action[0] ? newstring(action) : NULL, clamp(*pos, 0, 100), NULL)); } COMMAND(menuitemcheckbox, "sssi"); void menuitemkeyinput(char *text, char *bindcmd) { if(!lastmenu) return; lastmenu->items.add(new mitemkeyinput(lastmenu, newstring(text), newstring(bindcmd), NULL, keym::ACTION_DEFAULT)); } COMMAND(menuitemkeyinput, "ss"); void menuitemeditkeyinput(char *text, char *bindcmd) { if(!lastmenu) return; lastmenu->items.add(new mitemkeyinput(lastmenu, newstring(text), newstring(bindcmd), NULL, keym::ACTION_EDITING)); } COMMAND(menuitemeditkeyinput, "ss"); void menuitemspectkeyinput(char *text, char *bindcmd) { if(!lastmenu) return; lastmenu->items.add(new mitemkeyinput(lastmenu, newstring(text), newstring(bindcmd), NULL, keym::ACTION_SPECTATOR)); } COMMAND(menuitemspectkeyinput, "ss"); void menumdl(char *menu, char *mdl, char *anim, int *rotspeed, int *scale) { gmenu *m = *menu ? menus.access(menu) : lastmenu; if(!m) return; DELETEA(m->mdl); if(!*mdl) return; m->mdl = newstring(mdl); m->anim = findanim(anim)|ANIM_LOOP; m->rotspeed = clamp(*rotspeed, 0, 100); m->scale = clamp(*scale, 0, 100); } COMMAND(menumdl, "sssii"); void menudirlist(char *dir, char *ext, char *action, int *image, char *searchfile) { if(!lastmenu || !*action) return; if(lastmenu->dirlist) delete lastmenu->dirlist; mdirlist *d = lastmenu->dirlist = new mdirlist; d->dir = newstring(dir); d->ext = ext[0] ? newstring(ext): NULL; d->action = action[0] ? newstring(action) : NULL; d->image = *image!=0; d->searchfile = searchfile[0] ? newstring(searchfile) : NULL; d->subdiraction = NULL; d->subdirdots = false; } COMMAND(menudirlist, "sssis"); void menudirlistsub(char *action, int *dots) { if(!lastmenu || !lastmenu->dirlist || !*action) return; mdirlist *d = lastmenu->dirlist; d->subdirdots = *dots != 0; DELETEA(d->subdiraction); d->subdiraction = *action ? newstring(action) : NULL; } COMMAND(menudirlistsub, "si"); void chmenutexture(char *menu, char *texname, char *title) { gmenu *m = *menu ? menus.access(menu) : NULL; if(!m) return; DELETEA(m->previewtexture); if(*texname) m->previewtexture = newstring(texname); DELETEA(m->previewtexturetitle); if(*title) m->previewtexturetitle = newstring(title); } COMMAND(chmenutexture, "sss"); bool parsecolor(color *col, const char *r, const char *g, const char *b, const char *a) { if(!r[0] || !col) return false; // four possible parameter schemes: if(!g[0]) g = b = r; // grey if(!b[0]) { a = g; g = b = r; } // grey alpha col->r = ((float) atoi(r)) / 100; // red green blue col->g = ((float) atoi(g)) / 100; // red green blue alpha col->b = ((float) atoi(b)) / 100; col->alpha = a[0] ? ((float) atoi(a)) / 100 : 1.0; return true; } void menuselectionbgcolor(char *r, char *g, char *b, char *a) { if(!menuselbgcolor) menuselbgcolor = new color; if(!r[0]) { DELETEP(menuselbgcolor); return; } parsecolor(menuselbgcolor, r, g, b, a); } COMMAND(menuselectionbgcolor, "ssss"); void menuselectiondescbgcolor(char *r, char *g, char *b, char *a) { if(!menuseldescbgcolor) menuseldescbgcolor = new color; if(!r[0]) { DELETEP(menuseldescbgcolor); return; } parsecolor(menuseldescbgcolor, r, g, b, a); } COMMAND(menuselectiondescbgcolor, "ssss"); static bool iskeypressed(int key) { int numkeys = 0; Uint8 const* state = SDL_GetKeyboardState(&numkeys); return key < numkeys && state[key] != 0; } void menusay(const char *text) { if(curmenu && curmenu->allowinput && curmenu->items.inrange(curmenu->menusel)) curmenu->items[curmenu->menusel]->say(text); } bool menukey(int code, bool isdown, SDL_Keymod mod) { if(!curmenu) return false; int n = curmenu->items.length(), menusel = curmenu->menusel; if(curmenu->items.inrange(menusel) && !curmenu->items[menusel]->greyedout) { mitem *m = curmenu->items[menusel]; if(m->mitemtype == mitem::TYPE_KEYINPUT && ((mitemkeyinput *)m)->capture) { m->key(code, isdown); return true; } } if(isdown) { int pagesize = MAXMENU - curmenu->headeritems(); switch(code) { case SDLK_PAGEUP: menusel -= pagesize; break; case SDLK_PAGEDOWN: if(menusel+pagesize>=n && menusel/pagesize!=(n-1)/pagesize) menusel = n-1; else menusel += pagesize; break; case SDLK_ESCAPE: case SDL_AC_BUTTON_RIGHT: if(!curmenu->allowinput) return false; menuset(menustack.empty() ? NULL : menustack.pop(), false); return true; break; case SDLK_UP: case SDL_AC_BUTTON_WHEELUP: if(iskeypressed(SDL_SCANCODE_LCTRL)) return menukey(SDLK_LEFT); if(iskeypressed(SDL_SCANCODE_LALT)) return menukey(SDLK_RIGHTBRACKET); if(!curmenu->allowinput) return false; menusel--; break; case SDLK_DOWN: case SDL_AC_BUTTON_WHEELDOWN: if(iskeypressed(SDL_SCANCODE_LCTRL)) return menukey(SDLK_RIGHT); if(iskeypressed(SDL_SCANCODE_LALT)) return menukey(SDLK_LEFTBRACKET); if(!curmenu->allowinput) return false; menusel++; break; case SDLK_TAB: if(!curmenu->allowinput) return false; if(mod & KMOD_LSHIFT) menusel--; else menusel++; break; case SDLK_1: case SDLK_2: case SDLK_3: case SDLK_4: case SDLK_5: case SDLK_6: case SDLK_7: case SDLK_8: case SDLK_9: if(curmenu->allowinput && curmenu->hotkeys) { int idx = code-SDLK_1; if(curmenu->items.inrange(idx) && !curmenu->items[idx]->greyedout) { menuselect(curmenu, idx); mitem &m = *curmenu->items[idx]; m.select(); } return true; } default: { if(!curmenu->allowinput) return false; if(curmenu->keyfunc && (*curmenu->keyfunc)(curmenu, code, isdown)) return true; if(!curmenu->items.inrange(menusel)) return false; mitem &m = *curmenu->items[menusel]; if(!m.greyedout) m.key(code, isdown); if(code == SDLK_HOME && m.mitemtype != mitem::TYPE_TEXTINPUT) menuselect(curmenu, (menusel = 0)); return !curmenu->forwardkeys; } } if(!curmenu->hotkeys) menuselect(curmenu, menusel); return true; } else { switch(code) // action on keyup to avoid repeats { case SDLK_PRINTSCREEN: curmenu->conprintmenu(); return true; case SDLK_F12: if(curmenu->allowinput) { extern void screenshot(const char *filename); screenshot(NULL); } break; } if(!curmenu->allowinput || !curmenu->items.inrange(menusel)) return false; mitem &m = *curmenu->items[menusel]; if(code==SDLK_RETURN || code==SDLK_SPACE || code==SDL_AC_BUTTON_LEFT || code==SDL_AC_BUTTON_MIDDLE) { if(!m.greyedout && m.select() != -1) audiomgr.playsound(S_MENUENTER, SP_HIGHEST); return true; } return false; } } bool rendermenumdl() { if(!curmenu) return false; gmenu &m = *curmenu; if(!m.mdl) return false; glPushMatrix(); glLoadIdentity(); glRotatef(90+180, 0, -1, 0); glRotatef(90, -1, 0, 0); glScalef(1, -1, 1); bool isplayermodel = !strncmp(m.mdl, "playermodels", strlen("playermodels")); bool isweapon = !strncmp(m.mdl, "weapons", strlen("weapons")); vec pos; if(!isweapon) pos = vec(2.0f, 1.2f, -0.4f); else pos = vec(2.0f, 0, 1.7f); float yaw = 1.0f, pitch = isplayermodel || isweapon ? 0.0f : camera1->pitch; if(m.rotspeed) yaw += lastmillis/5.0f/100.0f*m.rotspeed; if(fabs(pitch) < 10.0f) pitch = 0.0f; else pitch += 10.0f * (pitch < 0 ? 1 : -1); int tex = 0; if(isplayermodel) { defformatstring(skin)("packages/models/%s.jpg", m.mdl); tex = -(int)textureload(skin)->id; } modelattach a[2]; if(isplayermodel) { a[0].name = "weapons/subgun/world"; a[0].tag = "tag_weapon"; } rendermodel(isplayermodel ? "playermodels" : m.mdl, m.anim|ANIM_DYNALLOC, tex, -1, pos, 0, yaw, pitch, 0, 0, NULL, a, m.scale ? m.scale/25.0f : 1.0f); glPopMatrix(); dimeditinfopanel = 0; return !(isplayermodel || isweapon); } void gmenu::refresh() { if(refreshfunc) { (*refreshfunc)(this, !inited); inited = true; } if(menusel>=items.length()) menusel = max(items.length()-1, 0); } void gmenu::open() { inited = false; if(!allowinput) menusel = 0; if(!forwardkeys) player1->stopmoving(); setcontext("menu", name); if(initaction) { gmenu *oldlastmenu = lastmenu; lastmenu = this; execute(initaction); lastmenu = oldlastmenu; } if(items.inrange(menuselinit)) { menusel = menuselinit; menuselinit = -1; } if(items.inrange(menusel) && !items[menusel]->greyedout) items[menusel]->focus(true); init(); resetcontext(); } void gmenu::close() { if(items.inrange(menusel)) items[menusel]->focus(false); } void gmenu::conprintmenu() { if(title) conoutf( "[:: %s ::]", title);//if(items.length()) conoutf( " %03d items", items.length()); loopv(items) { conoutf("%03d: %s%s%s", 1+i, items[i]->gettext(), items[i]->getaction()?"|\t|":"", items[i]->getaction()?items[i]->getaction():""); } } const char *menufilesortorders[] = { "normal", "reverse", "ignorecase", "ignorecase_reverse", "" }; int (*menufilesortcmp[])(const char **, const char **) = { stringsort, stringsortrev, stringsortignorecase, stringsortignorecaserev }; void gmenu::init() { if(!menuseldescbgcolor) menuseldescbgcolor = new color(0.2f, 0.2f, 0.2f, 0.2f); if(dirlist && dirlist->dir && dirlist->ext) { items.deletecontents(); if(dirlist->subdiraction) { vector subdirs; if(dirlist->subdirdots) subdirs.add(newstring("..")); listsubdirs(dirlist->dir, subdirs, stringsort); loopv(subdirs) { defformatstring(cdir)("\fs\f1[%s]\fr", subdirs[i]); defformatstring(act)("%s %s", dirlist->subdiraction, escapestring(subdirs[i])); items.add(new mitemtext(this, newstring(cdir), newstring(act), NULL, NULL, NULL)); } } defformatstring(sortorderalias)("menufilesort_%s", dirlist->ext); int sortorderindex = 0; const char *customsortorder = getalias(sortorderalias); if(customsortorder) sortorderindex = getlistindex(customsortorder, menufilesortorders, true, 0); vector files; listfiles(dirlist->dir, dirlist->ext, files, menufilesortcmp[sortorderindex]); string searchfileuc; if(dirlist->searchfile) { const char *searchfilealias = getalias(dirlist->searchfile); copystring(searchfileuc, searchfilealias ? searchfilealias : dirlist->searchfile); strtoupper(searchfileuc); } loopv(files) { char *f = files[i], *d = (strcmp(dirlist->ext, "cgz") || dirlist->searchfile) && browsefiledesc ? getfiledesc(dirlist->dir, f, dirlist->ext) : NULL; bool filefound = false; if(dirlist->searchfile) { string fuc, duc; copystring(fuc, f); strtoupper(fuc); copystring(duc, d ? d : ""); strtoupper(duc); if(strstr(fuc, searchfileuc) || strstr(duc, searchfileuc)) filefound = true; } if(dirlist->image) { string fullname = ""; if(dirlist->dir[0]) formatstring(fullname)("%s/%s", dirlist->dir, f); else copystring(fullname, f); if(dirlist->ext) { concatstring(fullname, "."); concatstring(fullname, dirlist->ext); } items.add(new mitemimage (this, newstring(fullname), f, newstring(dirlist->action), NULL, NULL, d)); } else if(!strcmp(dirlist->ext, "cgz")) { if(!dirlist->searchfile || filefound) { items.add(new mitemmapload(this, newstring(f), newstring(f), newstring(dirlist->action), NULL, NULL)); } DELSTRING(d); } else if(!strcmp(dirlist->ext, "dmo")) { if(!dirlist->searchfile || filefound) items.add(new mitemtext(this, f, newstring(dirlist->action), NULL, NULL, d)); } else items.add(new mitemtext(this, f, newstring(dirlist->action), NULL, NULL, d)); } } loopv(items) items[i]->init(); } int gmenu::headeritems() // returns number of header and footer lines (and also recalculates hasdesc) { hasdesc = false; loopv(items) if(items[i]->getdesc()) { hasdesc = true; break; } return (header ? 2 : 0) + (footer || hasdesc ? (footlen ? (footlen + 1) : 2) : 0); } FVAR(menutexturesize, 0.1f, 1.0f, 5.0f); FVAR(menupicturesize, 0.1f, 1.6f, 5.0f); void rendermenutexturepreview(char *previewtexture, int w, const char *title) { static Texture *pt = NULL; static uint last_pt = 0; bool ispicture = title != NULL; uint cur_pt = hthash(previewtexture); if(cur_pt != last_pt) { silent_texture_load = ispicture; defformatstring(texpath)("packages/textures/%s", previewtexture); pt = textureload(texpath, ispicture ? 3 : 0); last_pt = cur_pt; silent_texture_load = false; } if(pt && pt != notexture && pt->xs && pt->ys) { int xs = (VIRTW * (ispicture ? menupicturesize : menutexturesize)) / 4, ys = (xs * pt->ys) / pt->xs, ysmax = (3 * VIRTH) / 2; if(ys > ysmax) ys = ysmax, xs = (ys * pt->xs) / pt->ys; int x = (6 * VIRTW + w - 2 * xs) / 4, y = VIRTH - ys / 2 - 2 * FONTH; extern int fullbrightlevel; framedquadtexture(pt->id, x, y, xs, ys, FONTH / 2, fullbrightlevel); defformatstring(res)("%dx%d", pt->xs, pt->ys); draw_text(title ? title : res, x, y + ys + 2 * FONTH); } } void gmenu::render() { extern bool ignoreblinkingbit; if(usefont) pushfont(usefont); if(!allowblink) ignoreblinkingbit = true; bool synctabs = title != NULL || synctabstops; const char *t = title; if(!t) { static string buf; if(hotkeys) formatstring(buf)("%s hotkeys", name); else formatstring(buf)("[ %s menu ]", name); t = buf; } int w = 0, footermaxw = 2 * VIRTW - 6 * FONTH, hitems = headeritems(), footwidth, footheight, maxfootheight = 0; if(hasdesc) loopv(items) if(items[i]->getdesc()) { text_bounds(items[i]->getdesc(), footwidth, footheight, footermaxw); w = max(w, footwidth); maxfootheight = max(maxfootheight, footheight); } if(synctabs) text_startcolumns(); loopv(items) w = max(w, items[i]->width()); int pagesize = MAXMENU - hitems, offset = menusel - (menusel%pagesize), mdisp = min(items.length(), pagesize), cdisp = min(items.length()-offset, pagesize), pages = (items.length() - 1) / pagesize; mitem::whitepulse.alpha = (sinf(lastmillis/200.0f)+1.0f)/2.0f; defformatstring(menupages)("%d/%d", (offset / pagesize) + 1, pages + 1); int menupageswidth = pages ? text_width(menupages) : 0; // adds to topmost line, either menu title or header w = max(w, text_width(t) + (header ? 0 : menupageswidth)); if(header) w = max(w, text_width(header) + menupageswidth); int step = (FONTH*5)/4; int h = (mdisp+hitems+2)*step; int y = (2*VIRTH-h)/2; int x = hotkeys ? (2*VIRTW-w)/6 : (2*VIRTW-w)/2; x = clamp(x + (VIRTW * xoffs) / 100, 3 * FONTH, 2 * VIRTW - w - 3 * FONTH); y = clamp(y + (VIRTH * yoffs) / 100, 3 * FONTH, 2 * VIRTH - h - 3 * FONTH); if(!hotkeys) renderbg(x - FONTH*3/2, y - FONTH, x + w + FONTH*3/2, y + h + FONTH, true); if(pages) { if(offset > 0) drawarrow(1, x + w + FONTH*3/2 - FONTH*5/6, y - FONTH*5/6, FONTH*2/3); if(offset + pagesize < items.length()) drawarrow(0, x + w + FONTH*3/2 - FONTH*5/6, y + h + FONTH/6, FONTH*2/3); draw_text(menupages, x + w + FONTH*3/2 - FONTH*5/6 - menupageswidth, y); } if(header) { draw_text(header, x, y); y += step*2; } draw_text(t, x, y); y += step*2; loopj(cdisp) { items[offset+j]->render(x, y, w); y += step; } if(synctabs) text_endcolumns(); if(footer || hasdesc) { y += ((mdisp-cdisp)+1)*step; const char *usefoot = hasdesc && items.inrange(menusel) ? items[menusel]->getdesc() : footer; if(!hasdesc) text_bounds(footer, footwidth, maxfootheight, w); if(maxfootheight) footlen = min(MAXMENU / 4, (maxfootheight + step / 2) / step); if(usefoot) draw_text(usefoot, x, y, 0xFF, 0xFF, 0xFF, 0xFF, -1, w); } if(previewtexture && *previewtexture) rendermenutexturepreview(previewtexture, w, previewtexturetitle); if(usefont) popfont(); // setfont("default"); ignoreblinkingbit = false; } void gmenu::renderbg(int x1, int y1, int x2, int y2, bool border) { static Texture *tex = NULL; if(!tex) tex = textureload("packages/misc/menu.jpg"); static color transparent(1, 1, 1, 0.75f); blendbox(x1, y1, x2, y2, border, tex->id, allowinput ? NULL : &transparent); } // apply changes menu void *applymenu = NULL; static vector needsapply; VARP(applydialog, 0, 1, 1); void addchange(const char *desc, int type) { if(!applydialog) return; if(type!=CHANGE_GFX) { conoutf("..restart AssaultCube for this setting to take effect"); return; } bool changed = false; loopv(needsapply) if(!strcmp(needsapply[i], desc)) { changed = true; break; } if(!changed) needsapply.add(desc); showmenu("apply", false); } void clearchanges(int type) { if(type!=CHANGE_GFX) return; needsapply.shrink(0); closemenu("apply"); } void refreshapplymenu(void *menu, bool init) { gmenu *m = (gmenu *) menu; if(!m || (!init && needsapply.length() != m->items.length()-3)) return; m->items.deletecontents(); loopv(needsapply) m->items.add(new mitemtext(m, newstring(needsapply[i]), NULL, NULL, NULL)); m->items.add(new mitemtext(m, newstring(""), NULL, NULL, NULL)); m->items.add(new mitemtext(m, newstring("Yes"), newstring("resetgl"), NULL, NULL)); m->items.add(new mitemtext(m, newstring("No"), newstring("echo [..restart AssaultCube to apply the new settings]"), NULL, NULL)); if(init) m->menusel = m->items.length()-2; // select OK } assaultcube-1.2.0.2.1/source/src/mingw.bat000066400000000000000000000000641352165075300202330ustar00rootroot00000000000000mingw32-make PLATFORM=MINGW MV=copy RM=del %* PAUSEassaultcube-1.2.0.2.1/source/src/model.h000066400000000000000000000065251352165075300177030ustar00rootroot00000000000000enum { ANIM_IDLE = 0, ANIM_RUN, ANIM_ATTACK, ANIM_PAIN, ANIM_JUMP, ANIM_LAND, ANIM_FLIPOFF, ANIM_SALUTE, ANIM_TAUNT, ANIM_WAVE, ANIM_POINT, ANIM_CROUCH_IDLE, ANIM_CROUCH_WALK, ANIM_CROUCH_ATTACK, ANIM_CROUCH_PAIN, ANIM_CROUCH_DEATH, ANIM_DEATH, ANIM_LYING_DEAD, ANIM_FLAG, ANIM_GUN_IDLE, ANIM_GUN_SHOOT, ANIM_GUN_RELOAD, ANIM_GUN_THROW, ANIM_MAPMODEL, ANIM_TRIGGER, ANIM_DECAY, ANIM_ALL, NUMANIMS }; #define ANIM_INDEX 0xFF #define ANIM_LOOP (1<<8) #define ANIM_START (1<<9) #define ANIM_END (1<<10) #define ANIM_REVERSE (1<<11) #define ANIM_NOINTERP (1<<12) #define ANIM_MIRROR (1<<13) #define ANIM_NOSKIN (1<<14) #define ANIM_TRANSLUCENT (1<<15) #define ANIM_PARTICLE (1<<16) #define ANIM_DYNALLOC (1<<17) struct animstate // used for animation blending of animated characters { int anim, frame, range, basetime; float speed; animstate() { reset(); } void reset() { anim = frame = range = basetime = 0; speed = 100.0f; }; bool operator==(const animstate &o) const { return frame==o.frame && range==o.range && basetime==o.basetime && speed==o.speed; } bool operator!=(const animstate &o) const { return frame!=o.frame || range!=o.range || basetime!=o.basetime || speed!=o.speed; } }; enum { MDL_MD2 = 1, MDL_MD3 }; struct model; struct modelattach { const char *tag, *name; vec *pos; model *m; modelattach() : tag(NULL), name(NULL), pos(NULL), m(NULL) {} modelattach(const char *tag, const char *name) : tag(tag), name(name), pos(NULL), m(NULL) {} modelattach(const char *tag, vec *pos) : tag(tag), name(NULL), pos(pos), m(NULL) {} }; class dynent; struct model { bool cullface, vertexlight, alphablend; //ALX Alpha channel models float alphatest, translucency, scale, radius, zradius, shadowdist; vec translate; int cachelimit, batch; //model() : cullface(true), vertexlight(false), alphatest(0.9f), translucency(0.25f), scale(1), radius(0), shadowdist(0), translate(0, 0, 0), cachelimit(8), batch(-1) {} model() : cullface(true), vertexlight(false), alphablend(false), alphatest(0.9f), translucency(0.25f), scale(1), radius(0), zradius(0), shadowdist(0), translate(0, 0, 0), cachelimit(8), batch(-1) {} virtual ~model() {} virtual bool load() = 0; virtual char *name() = 0; virtual int type() = 0; virtual void cleanup() = 0; virtual void render(int anim, int varseed, float speed, int basetime, const vec &o, float roll, float yaw, float pitch, dynent *d, modelattach *a = NULL, float scale = 1.0f) = 0; virtual void setskin(int tex = 0) = 0; virtual void genshadows(float height, float rad) {} virtual void rendershadow(int anim, int varseed, float speed, int basetime, const vec &o, float yaw, modelattach *a = NULL) {} virtual bool hasshadows() { return false; } virtual void startrender() {} virtual void endrender() {} }; struct mapmodelinfo { int rad, h, zoff; float scale; string name; model *m; int flags; }; enum { MMA_KEYWORDS = 0, MMA_DESC, MMA_DEFAULTPARAMS, MMA_USAGE, MMA_AUTHOR, MMA_LICENSE, MMA_DISTRIBUTION, MMA_VERSION, MMA_REQUIRES, MMA_NUM }; enum { MMF_REQUIRED = 1<<0, MMF_TEMP_USED = 1<<30, MMF_CONFIGMASK = 0xff }; struct mapmodelattributes { string name; const char *n[MMA_NUM]; int tmp; mapmodelattributes() { memset(this, 0, sizeof(*this)); } }; assaultcube-1.2.0.2.1/source/src/modelcache.h000066400000000000000000000071551352165075300206670ustar00rootroot00000000000000template struct modelcacheentry { typedef modelcacheentry entry; T *prev, *next, *nextalloc; size_t size; bool locked; modelcacheentry(T *prev = NULL, T *next = NULL) : prev(prev), next(next), nextalloc(NULL), size(0), locked(false) {} bool empty() const { return prev==next; } void linkbefore(T *pos) { next = pos; prev = pos->entry::prev; prev->entry::next = (T *)this; next->entry::prev = (T *)this; } void linkafter(T *pos) { next = pos->entry::next; prev = pos; prev->entry::next = (T *)this; next->entry::prev = (T *)this; } void unlink() { prev->modelcacheentry::next = next; next->modelcacheentry::prev = prev; prev = next = (T *)this; } void *getdata() { return (T *)this + 1; } }; template struct modelcachelist : modelcacheentry { typedef modelcacheentry entry; modelcachelist() : entry((T *)this, (T *)this) {} T *start() { return entry::next; } T *end() { return (T *)this; } void addfirst(entry *e) { e->linkafter((T *)this); } void addlast(entry *e) { e->linkbefore((T *)this); } void removefirst() { if(!entry::empty()) entry::next->unlink(); } void removelast() { if(!entry::empty()) entry::prev->unlink(); } }; struct modelcache { struct entry : modelcacheentry {}; uchar *buf; size_t size; entry *curalloc; modelcache(size_t size = 0) : buf(size ? new uchar[size] : NULL), size(size), curalloc(NULL) {} ~modelcache() { DELETEA(buf); } void resize(size_t nsize) { if(curalloc) { for(curalloc = (entry *)buf; curalloc; curalloc = curalloc->nextalloc) curalloc->unlink(); } DELETEA(buf); buf = nsize ? new uchar[nsize] : 0; size = nsize; } template T *allocate(size_t reqsize) { reqsize += sizeof(T); if(reqsize > size) return NULL; if(!curalloc) { curalloc = (entry *)buf; curalloc->size = reqsize; curalloc->locked = false; curalloc->nextalloc = NULL; return (T *)curalloc; } if(curalloc) for(bool failed = false;;) { uchar *nextfree = curalloc ? (uchar *)curalloc + curalloc->size : (uchar *)buf; entry *nextused = curalloc ? curalloc->nextalloc : (entry *)buf; for(;;) { if(!nextused) { if(size_t(&buf[size] - nextfree) >= reqsize) goto success; break; } else if(size_t((uchar *)nextused - nextfree) >= reqsize) goto success; else if(nextused->locked) break; nextused->unlink(); nextused = nextused->nextalloc; } if(curalloc) curalloc->nextalloc = nextused; else if(failed) { curalloc = nextused; break; } else failed = true; curalloc = nextused; continue; success: entry *result = (entry *)nextfree; result->size = reqsize; result->locked = false; result->nextalloc = nextused; if(curalloc) curalloc->nextalloc = result; curalloc = result; return (T *)curalloc; } curalloc = (entry *)buf; return NULL; } template void release(modelcacheentry *e) { e->unlink(); } }; assaultcube-1.2.0.2.1/source/src/oggstream.cpp000066400000000000000000000144701352165075300211240ustar00rootroot00000000000000// audio streaming #include "cube.h" #define DEBUGCOND (audiodebug==1) // ogg compat static size_t oggcallbackread(void *ptr, size_t size, size_t nmemb, void *datasource) { stream *s = (stream *)datasource; return s ? s->read(ptr, int(size*nmemb))/size : 0; } static int oggcallbackseek(void *datasource, ogg_int64_t offset, int whence) { stream *s = (stream *)datasource; return s && s->seek(long(offset), whence) ? 0 : -1; } static int oggcallbackclose(void *datasource) { stream *s = (stream *)datasource; if(!s) return -1; delete s; return 0; } static long oggcallbacktell(void *datasource) { stream *s = (stream *)datasource; return s ? s->tell() : -1; } ov_callbacks oggcallbacks = { oggcallbackread, oggcallbackseek, oggcallbackclose, oggcallbacktell }; // ogg audio streaming oggstream::oggstream() : valid(false), isopen(false), src(NULL) { reset(); // grab a source and keep it during the whole lifetime src = sourcescheduler::instance().newsource(SP_HIGHEST, camera1->o); if(src) { if(src->valid) { src->init(this); src->sourcerelative(true); } else { sourcescheduler::instance().releasesource(src); src = NULL; } } if(!src) return; alclearerr(); alGenBuffers(2, bufferids); valid = !ALERR; } oggstream::~oggstream() { reset(); if(src) sourcescheduler::instance().releasesource(src); if(alIsBuffer(bufferids[0]) || alIsBuffer(bufferids[1])) { alclearerr(); alDeleteBuffers(2, bufferids); ALERR; } } void oggstream::reset() { name[0] = '\0'; // stop playing if(src) { src->stop(); src->unqueueallbuffers(); src->buffer(0); } format = AL_NONE; // reset file handler if(isopen) { isopen = !ov_clear(&oggfile); } info = NULL; totalseconds = 0.0f; // default settings startmillis = endmillis = startfademillis = endfademillis = 0; gain = 1.0f; // reset gain but not volume setting looping = false; } bool oggstream::open(const char *f) { ASSERT(valid); if(!f) return false; if(playing() || isopen) reset(); const char *exts[] = { "", ".wav", ".ogg" }; string filepath; loopi(sizeof(exts)/sizeof(exts[0])) { formatstring(filepath)("packages/audio/soundtracks/%s%s", f, exts[i]); ::stream *file = openfile(path(filepath), "rb"); if(!file) continue; isopen = !ov_open_callbacks(file, &oggfile, NULL, 0, oggcallbacks); if(!isopen) { delete file; continue; } info = ov_info(&oggfile, -1); format = info->channels == 2 ? AL_FORMAT_STEREO16 : AL_FORMAT_MONO16; totalseconds = ov_time_total(&oggfile, -1); copystring(name, f); return true; } return false; } void oggstream::onsourcereassign(source *s) { // should NEVER happen because streams do have the highest priority, see constructor ASSERT(0); if(src && src==s) { reset(); src = NULL; } } bool oggstream::stream(ALuint bufid) { ASSERT(valid); loopi(2) { char pcm[BUFSIZE]; ALsizei size = 0; int bitstream; while(size < BUFSIZE) { long bytes = ov_read(&oggfile, pcm + size, BUFSIZE - size, isbigendian(), 2, 1, &bitstream); if(bytes > 0) size += bytes; else if (bytes < 0) return false; else break; // done } if(size==0) { if(looping && !ov_pcm_seek(&oggfile, 0)) continue; // try again to replay else return false; } alclearerr(); alBufferData(bufid, format, pcm, size, info->rate); return !ALERR; } return false; } bool oggstream::update() { ASSERT(valid); if(!isopen || !playing()) return false; // update buffer queue ALint processed; bool active = true; alGetSourcei(src->id, AL_BUFFERS_PROCESSED, &processed); loopi(processed) { ALuint buffer; alSourceUnqueueBuffers(src->id, 1, &buffer); active = stream(buffer); if(active) alSourceQueueBuffers(src->id, 1, &buffer); } if(active) { // fade in if(startmillis > 0) { const float start = (lastmillis-startmillis)/(float)startfademillis; if(start>=0.00f && start<=1.00001f) { setgain(start); return true; } } // fade out if(endmillis > 0) { if(lastmillis<=endmillis) // set gain { const float end = (endmillis-lastmillis)/(float)endfademillis; if(end>=-0.00001f && end<=1.00f) { setgain(end); return true; } } else // stop { active = false; } } } if(!active) reset(); // reset stream if the end is reached return active; } bool oggstream::playing() { ASSERT(valid); return src->playing(); } void oggstream::updategain() { ASSERT(valid); src->gain(gain*volume); } void oggstream::setgain(float g) { ASSERT(valid); gain = g; updategain(); } void oggstream::setvolume(float v) { ASSERT(valid); volume = v; updategain(); } void oggstream::fadein(int startmillis, int fademillis) { ASSERT(valid); setgain(0.01f); this->startmillis = startmillis; this->startfademillis = fademillis; } void oggstream::fadeout(int endmillis, int fademillis) { ASSERT(valid); this->endmillis = (endmillis || totalseconds > 0.0f) ? endmillis : lastmillis+(int)totalseconds; this->endfademillis = fademillis; } bool oggstream::playback(bool looping) { ASSERT(valid); if(playing()) return true; this->looping = looping; if(!stream(bufferids[0]) || !stream(bufferids[1])) return false; if(!startmillis && !endmillis && !startfademillis && !endfademillis) setgain(1.0f); updategain(); src->queuebuffers(2, bufferids); src->play(); return true; } void oggstream::seek(double offset) { ASSERT(valid); if(!totalseconds) return; ov_time_seek_page(&oggfile, fmod(totalseconds-5.0f, totalseconds)); } assaultcube-1.2.0.2.1/source/src/openal.cpp000066400000000000000000000216311352165075300204070ustar00rootroot00000000000000// simple OpenAL call wrappers #include "cube.h" #define DEBUGCOND (audiodebug==1) VAR(al_referencedistance, 0, 400, 1000000); VAR(al_rollofffactor, 0, 100, 1000000); // represents an OpenAL source, an audio emitter in the 3D world source::source() : id(0), owner(NULL), locked(false), valid(false), priority(SP_NORMAL) { valid = generate(); ASSERT(!valid || alIsSource(id)); } source::~source() { if(valid) delete_(); } void source::lock() { locked = true; DEBUG("source locked, " << lastmillis); } void source::unlock() { locked = false; owner = NULL; stop(); buffer(0); DEBUG("source unlocked, " << lastmillis); } void source::reset() { ASSERT(alIsSource(id)); owner = NULL; locked = false; priority = SP_NORMAL; // restore default settings stop(); buffer(0); pitch(1.0f); gain(1.0f); position(0.0f, 0.0f, 0.0f); velocity(0.0f, 0.0f, 0.0f); looping(false); sourcerelative(false); // fit into distance model alSourcef(id, AL_REFERENCE_DISTANCE, al_referencedistance/100.0f); alSourcef(id, AL_ROLLOFF_FACTOR, al_rollofffactor/100.0f); } void source::init(sourceowner *o) { ASSERT(o); owner = o; } void source::onreassign() { if(owner) { owner->onsourcereassign(this); owner = NULL; } } bool source::generate() { alclearerr(); alGenSources(1, &id); return !alerr(false); } bool source::delete_() { alclearerr(); alDeleteSources(1, &id); return !ALERR; } bool source::buffer(ALuint buf_id) { alclearerr(); #ifdef __APPLE__ // weird bug if (buf_id) #endif alSourcei(id, AL_BUFFER, buf_id); return !ALERR; } bool source::looping(bool enable) { alclearerr(); alSourcei(id, AL_LOOPING, enable ? 1 : 0); return !ALERR; } bool source::queuebuffers(ALsizei n, const ALuint *buffer_ids) { alclearerr(); alSourceQueueBuffers(id, n, buffer_ids); return !ALERR; } bool source::unqueueallbuffers() { alclearerr(); ALint queued; alGetSourcei(id, AL_BUFFERS_QUEUED, &queued); ALERR; loopi(queued) { ALuint buffer; alSourceUnqueueBuffers(id, 1, &buffer); } return !ALERR; } bool source::gain(float g) { alclearerr(); alSourcef(id, AL_GAIN, g); return !ALERRF("gain: %f", g); } bool source::pitch(float p) { alclearerr(); alSourcef(id, AL_PITCH, p); return !ALERRF("pitch: %f", p); } bool source::position(const vec &pos) { return position(pos.x, pos.y, pos.z); } bool source::position(float x, float y, float z) { alclearerr(); alSource3f(id, AL_POSITION, x, y, z); if(x < 0 || y < 0 || z < -128 || x > ssize || y > ssize || z > 128) clientlogf("warning: sound position out of range (%f,%f,%f)", x, y, z); return !ALERRF("id %u, %d, x: %f, y: %f, z: %f", id, alIsSource(id) == AL_TRUE ? 1 : 0, x, y, z); // return !ALERRF("x: %f, y: %f, z: %f", x, y, z); // when sound bug has been absent for a while, switch to this version } bool source::velocity(float x, float y, float z) { alclearerr(); alSource3f(id, AL_VELOCITY, x, y, z); return !ALERRF("dx: %f, dy: %f, dz: %f", x, y, z); } vec source::position() { alclearerr(); ALfloat v[3]; alGetSourcefv(id, AL_POSITION, v); if(ALERR) return vec(0,0,0); else return vec(v[0], v[1], v[2]); } bool source::sourcerelative(bool enable) { alclearerr(); alSourcei(id, AL_SOURCE_RELATIVE, enable ? AL_TRUE : AL_FALSE); return !ALERR; } int source::state() { ALint s; alGetSourcei(id, AL_SOURCE_STATE, &s); return s; } bool source::secoffset(float secs) { alclearerr(); alSourcef(id, AL_SEC_OFFSET, secs); // some openal implementations seem to spam invalid enum on this // return !ALERR; return !alerr(false); } float source::secoffset() { alclearerr(); ALfloat s; alGetSourcef(id, AL_SEC_OFFSET, &s); // some openal implementations seem to spam invalid enum on this // ALERR; alerr(false); return s; } bool source::playing() { return (state() == AL_PLAYING); } bool source::play() { alclearerr(); alSourcePlay(id); return !ALERR; } bool source::stop() { alclearerr(); alSourceStop(id); return !ALERR; } bool source::rewind() { alclearerr(); alSourceRewind(id); return !ALERR; } void source::printposition() { alclearerr(); vec v = position(); ALint s; alGetSourcei(id, AL_SOURCE_TYPE, &s); conoutf("sound %d: pos(%f,%f,%f) t(%d) ", id, v.x, v.y, v.z, s); ALERR; } // represents an OpenAL sound buffer sbuffer::sbuffer() : id(0), name(NULL) { } sbuffer::~sbuffer() { unload(); } bool sbuffer::load(bool trydl) { if(!name) return false; if(id) return true; alclearerr(); alGenBuffers(1, &id); if(!ALERR) { const char *exts[] = { "", ".wav", ".ogg" }; string filepath; loopi(sizeof(exts)/sizeof(exts[0])) { formatstring(filepath)("packages/audio/%s%s", name, exts[i]); stream *f = openfile(path(filepath), "rb"); if(!f) continue; size_t len = strlen(filepath); if(len >= 4 && !strcasecmp(filepath + len - 4, ".ogg")) { OggVorbis_File oggfile; if(!ov_open_callbacks(f, &oggfile, NULL, 0, oggcallbacks)) { vorbis_info *info = ov_info(&oggfile, -1); const size_t BUFSIZE = 32*1024; vector buf; int bitstream; long bytes; do { char buffer[BUFSIZE]; bytes = ov_read(&oggfile, buffer, BUFSIZE, isbigendian(), 2, 1, &bitstream); loopi(bytes) buf.add(buffer[i]); } while(bytes > 0); alBufferData(id, info->channels == 2 ? AL_FORMAT_STEREO16 : AL_FORMAT_MONO16, buf.getbuf(), buf.length(), info->rate); ov_clear(&oggfile); } else { delete f; continue; } } else { SDL_AudioSpec wavspec; uint32_t wavlen; uint8_t *wavbuf; if(!SDL_LoadWAV_RW(f->rwops(), 1, &wavspec, &wavbuf, &wavlen)) { SDL_ClearError(); continue; } ALenum format; switch(wavspec.format) // map wav header to openal format { case AUDIO_U8: case AUDIO_S8: format = wavspec.channels==2 ? AL_FORMAT_STEREO8 : AL_FORMAT_MONO8; break; case AUDIO_U16: case AUDIO_S16: format = wavspec.channels==2 ? AL_FORMAT_STEREO16 : AL_FORMAT_MONO16; break; default: SDL_FreeWAV(wavbuf); delete f; unload(); return false; } alBufferData(id, format, wavbuf, wavlen, wavspec.freq); SDL_FreeWAV(wavbuf); delete f; if(ALERR) { unload(); return false; }; } return true; } if(trydl) requirepackage(PCK_AUDIO, name); // only try donwloading after trying all extensions } unload(); // loading failed return false; } void sbuffer::unload() { if(!id) return; alclearerr(); if(alIsBuffer(id)) alDeleteBuffers(1, &id); id = 0; ALERR; } // buffer collection, find or load data bufferhashtable::~bufferhashtable() {} sbuffer *bufferhashtable::find(const char *name) { sbuffer *b = access(name); if(!b) { name = newstring(name); b = &(*this)[name]; b->name = name; } return b; } // OpenAL error handling void alclearerr() { alGetError(); } bool alerr(bool msg, int line, const char *s, ...) { ALenum er = alGetError(); if(er && msg) { const char *desc = "unknown"; switch(er) { case AL_INVALID_NAME: desc = "invalid name"; break; case AL_INVALID_ENUM: desc = "invalid enum"; break; case AL_INVALID_VALUE: desc = "invalid value"; break; case AL_INVALID_OPERATION: desc = "invalid operation"; break; case AL_OUT_OF_MEMORY: desc = "out of memory"; break; } if(s) { defvformatstring(p, s, s); conoutf("\f3OpenAL Error (%X): %s, line %d, (%s)", er, desc, line, p); } else if(line) conoutf("\f3OpenAL Error (%X): %s, line %d", er, desc, line); else conoutf("\f3OpenAL Error (%X): %s", er, desc); } return er > 0; } assaultcube-1.2.0.2.1/source/src/packetqueue.cpp000066400000000000000000000026061352165075300214460ustar00rootroot00000000000000// supports buffering Enet packets for logging purposes #include "cube.h" packetqueue::packetqueue() { } packetqueue::~packetqueue() { clear(); } // adds packet to log buffer void packetqueue::queue(ENetPacket *p) { if(packets.length() >= packets.maxsize()) enet_packet_destroy(packets.remove()); packets.add(p); } // writes all currently queued packets to disk and clears the queue bool packetqueue::flushtolog(const char *logfile) { if(packets.empty()) return false; stream *f = NULL; if(logfile && logfile[0]) f = openfile(logfile, "w"); if(!f) return false; // header f->printf("AC v%d PACKET LOG : proto %d : @ %11s\n", AC_VERSION, PROTOCOL_VERSION, numtime()); // serialize each packet loopv(packets) { ENetPacket *p = packets[i]; f->printf("\nENET PACKET\n"); f->printf("flags == %d\n", p->flags); f->printf("referenceCount == %d\n", (int)p->referenceCount); f->printf("dataLength == %d\n", (int)p->dataLength); f->printf("data == \n"); // print whole buffer char-wise loopj(p->dataLength) { f->printf("%6d 0x%02x '%c'\n", p->data[j], p->data[j], isprint(p->data[j]) ? p->data[j] : '-'); } } delete f; clear(); return true; } // clear queue void packetqueue::clear() { while(!packets.empty()) enet_packet_destroy(packets.remove()); } assaultcube-1.2.0.2.1/source/src/pch.cpp000066400000000000000000000000221352165075300176720ustar00rootroot00000000000000#include "cube.h" assaultcube-1.2.0.2.1/source/src/physics.cpp000066400000000000000000001134721352165075300206200ustar00rootroot00000000000000// physics.cpp: no physics books were hurt nor consulted in the construction of this code. // All physics computations and constants were invented on the fly and simply tweaked until // they "felt right", and have no basis in reality. Collision detection is simplistic but // very robust (uses discrete steps at fixed fps). #include "cube.h" float raycube(const vec &o, const vec &ray, vec &surface) { surface = vec(0, 0, 0); if(ray.iszero()) return -1; vec v = o; float dist = 0, dx = 0, dy = 0, dz = 0; int nr; for(nr=0;nr<512;nr++) // sam's suggestion :: I found no map which got nr > 350 { int x = int(v.x), y = int(v.y); if(x < 0 || y < 0 || x >= ssize || y >= ssize) return -1; sqr *s = S(x, y); float floor = s->floor, ceil = s->ceil; if(s->type==FHF) floor -= s->vdelta/4.0f; if(s->type==CHF) ceil += s->vdelta/4.0f; if(SOLID(s) || v.z < floor || v.z > ceil) { if((!dx && !dy) || s->wtex==DEFAULT_SKY || (!SOLID(s) && v.z > ceil && s->ctex==DEFAULT_SKY)) return -1; if(s->type!=CORNER)// && s->type!=FHF && s->type!=CHF) { if(dx0 ? -1 : 1; else surface.y = ray.y>0 ? -1 : 1; sqr *n = S(x+(int)surface.x, y+(int)surface.y); if(SOLID(n) || (v.z < floor && v.z < n->floor) || (v.z > ceil && v.z > n->ceil)) { surface = dx0 ? -1 : 1, 0) : vec(ray.x>0 ? -1 : 1, 0, 0); n = S(x+(int)surface.x, y+(int)surface.y); if(SOLID(n) || (v.z < floor && v.z < n->floor) || (v.z > ceil && v.z > n->ceil)) surface = vec(0, 0, ray.z>0 ? -1 : 1); } } dist = max(dist-0.1f, 0.0f); break; } dx = ray.x ? (x + (ray.x > 0 ? 1 : 0) - v.x)/ray.x : 1e16f; dy = ray.y ? (y + (ray.y > 0 ? 1 : 0) - v.y)/ray.y : 1e16f; dz = ray.z ? ((ray.z > 0 ? ceil : floor) - v.z)/ray.z : 1e16f; if(dz < dx && dz < dy) { if(ray.z>0 && s->ctex==DEFAULT_SKY) return -1; if(s->type!=FHF && s->type!=CHF) surface.z = ray.z>0 ? -1 : 1; dist += dz; break; } float disttonext = 0.1f + min(dx, dy); v.add(vec(ray).mul(disttonext)); dist += disttonext; } if (nr == 512) return -1; return dist; } bool raycubelos(const vec &from, const vec &to, float margin) { vec dir(to); dir.sub(from); float limit = dir.magnitude(); dir.mul(1.0f/limit); vec surface; float dist = raycube(from, dir, surface); return dist > max(limit - margin, 0.0f); } physent *hitplayer = NULL; bool plcollide(physent *d, physent *o, float &headspace, float &hi, float &lo) // collide with physent { if(o->state!=CS_ALIVE || !o->cancollide) return false; const float r = o->radius+d->radius; const vec dr = vec(o->o.x-d->o.x,o->o.y-d->o.y,0); const float deyeheight = d->eyeheight, oeyeheight = o->eyeheight; if((d->type==ENT_PLAYER && o->type==ENT_PLAYER ? dr.sqrxy() < r*r : fabs(dr.x)vel) >= 0.0f) { if(d->o.z-deyeheighto.z-oeyeheight) { if(o->o.z-oeyeheighto.z-oeyeheight-1; } else if(o->o.z+o->aboveeye>lo) lo = o->o.z+o->aboveeye+1; if(fabs(o->o.z-d->o.z)aboveeye+deyeheight) { hitplayer = o; return true; } headspace = d->o.z-o->o.z-o->aboveeye-deyeheight; if(headspace<0) headspace = 10; } return false; } int cornertest(int x, int y, int &bx, int &by, int &bs, sqr *&s, sqr *&h) // iteratively collide with a mipmapped corner cube { int mip = 1, res = -1; while(SWS(wmip[mip], x>>mip, y>>mip, sfactor-mip)->type==CORNER) mip++; mip--; x >>= mip; y >>= mip; int mfactor = sfactor - mip; bx = x<ceil-w->floor < v->ceil-v->floor; h = wv ? v : w; // in front of the corner, use floor and ceil from h if(z->ceil-z->floor < t->ceil-t->floor) res = wv ? 2 : 3; else res = wv ? 1 : 0; } // 03 return res; // 12 } static int cornersurface = 0; bool mmcollide(physent *d, float &hi, float &lo) // collide with a mapmodel { const float eyeheight = d->eyeheight, SQRT2HALF = SQRT2 / 2.0f; const float playerheight = eyeheight + d->aboveeye; if(editmode) clentstats.firstclip = 0; for(int i = clentstats.firstclip; i < ents.length(); i++) { entity &e = ents[i]; // if(e.type==CLIP || (e.type == PLCLIP && d->type == ENT_PLAYER)) if (e.type==CLIP || (e.type == PLCLIP && (d->type == ENT_BOT || d->type == ENT_PLAYER || (d->type == ENT_BOUNCE && ((bounceent *)d)->plclipped)))) // don't allow bots to hack themselves into plclips - Bukz 2011/04/14 { bool hitarea = false; switch(e.attr7 & 3) { default: // classic unrotated clip, possibly tilted hitarea = fabs(e.x - d->o.x) < float(e.attr2) / ENTSCALE5 + d->radius && fabs(e.y - d->o.y) < float(e.attr3) / ENTSCALE5 + d->radius; break; case 3: // clip rotated 45° { float rx = (e.x - d->o.x) * SQRT2HALF, ry = (e.y - d->o.y) * SQRT2HALF, rr = d->radius * SQRT2; // rotate player instead of clip (adjust player radius to compensate) float a1 = fabs(rx - ry) - float(e.attr3) / ENTSCALE5 - rr, a2 = fabs(rx + ry) - float(e.attr2) / ENTSCALE5 - rr; if(a1 < 0 && a2 < 0) { float a3 = a1 + a2 + rr; if(a3 < 0) hitarea = true; if(a3 < -1e-2 && (a3 < -rr || a1 * a2 < 0.42f)) cornersurface = a1 > a2 ? 1 : 2; } break; } } if(hitarea) { float cz = float(S(e.x, e.y)->floor + float(e.attr1) / ENTSCALE10), ch = float(e.attr4) / ENTSCALE5; if(e.attr6) switch(e.attr7 & 3) { // incredibly ugly solution - but it only applies on the one tilted clip we stand on case 1: cz += (floor(0.5f + clamp(d->o.x - e.x + d->radius * (e.attr6 > 0 ? 1 : -1), -float(e.attr2) / ENTSCALE5, float(e.attr2) / ENTSCALE5))) * float(e.attr6) / (4 * ENTSCALE10); break; // tilt x case 2: cz += (floor(0.5f + clamp(d->o.y - e.y + d->radius * (e.attr6 > 0 ? 1 : -1), -float(e.attr3) / ENTSCALE5, float(e.attr3) / ENTSCALE5))) * float(e.attr6) / (4 * ENTSCALE10); break; // tilt y } const float dz = d->o.z - d->eyeheight; if(dz < cz - 0.42) { if(czlo) lo = cz+ch; if(hi-lo < playerheight) return true; if(dz + (d->type != ENT_BOUNCE ? 1.26 : 0) > cz + ch || dz + playerheight < cz) cornersurface = 0; } } else if(e.type==MAPMODEL) { mapmodelinfo *mmi = getmminfo(e.attr2); if(!mmi || !mmi->h) continue; const float r = mmi->rad + d->radius; if(fabs(e.x-d->o.x)o.y)floor + mmi->zoff + float(e.attr3) / ENTSCALE5); const float dz = d->o.z-eyeheight; if(dz < mmz - 0.42) { if(mmz < hi) hi = mmz; } else if(mmz + mmi->h > lo) lo = mmz + mmi->h; if(hi-lo < playerheight) return true; } } } return false; } bool objcollide(physent *d, const vec &objpos, float objrad, float objheight) // collide with custom/typeless objects { const float r = d->radius+objrad; if(fabs(objpos.x-d->o.x)o.y)eyeheight+d->aboveeye+objheight)/2.0f; const float dz = d->o.z+(-d->eyeheight+d->aboveeye)/2.0f; const float objz = objpos.z+objheight/2.0f; return dz-objz <= maxdist && dz-objz >= -maxdist; } return false; } // all collision happens here // spawn is a dirty side effect used in spawning // drop & rise are supplied by the physics below to indicate gravity/push for current mini-timestep bool collide(physent *d, bool spawn, float drop, float rise) { cornersurface = 0; const float fx1 = d->o.x-d->radius; // figure out integer cube rectangle this entity covers in map const float fy1 = d->o.y-d->radius; const float fx2 = d->o.x+d->radius; const float fy2 = d->o.y+d->radius; const int x1 = int(fx1); const int y1 = int(fy1); const int x2 = int(fx2); const int y2 = int(fy2); float hi = 127, lo = -128; const float eyeheight = d->eyeheight; const float playerheight = eyeheight + d->aboveeye; float z1 = d->o.z-eyeheight, z2 = z1 + playerheight; if(d->type != ENT_BOUNCE) z1 += 1.26; const int applyclip = d->type == ENT_BOT || d->type == ENT_PLAYER || (d->type == ENT_BOUNCE && ((bounceent *)d)->plclipped) ? TAGANYCLIP : TAGCLIP; for(int y = y1; y<=y2; y++) for(int x = x1; x<=x2; x++) // collide with map { if(OUTBORD(x,y)) return true; sqr *s = S(x,y); bool tagclipped = (s->tag & applyclip) != 0; float ceil = s->ceil; float floor = s->floor; switch(s->type) { case SOLID: return true; case CORNER: { sqr *ns, *h = NULL; int bx, by, bs; int q = cornertest(x, y, bx, by, bs, ns, h); bool matter = false, match = false; switch(q) // 0XX3 { // XXXX case 0: // 1XX2 match = x==x2 && y==y2; matter = fx2-bx+fy2-by>=bs; break; case 1: match = x==x2 && y==y1; matter = fx2-bx>=fy1-by; break; case 2: match = x==x1 && y==y1; matter = fx1-bx+fy1-by<=bs; break; case 3: match = x==x1 && y==y2; matter = fx1-bx<=fy2-by; break; default: return true; // mapper's fault: corner with unsufficient solids: renderer can't handle those anyway: treat as solid } cornersurface = (q & 1) ? 5 : 6; sqr *n = h && !matter ? h : ns; ceil = n->ceil; // use floor & ceil from higher mips (like the renderer) floor = n->floor; if(!match && d->type == ENT_BOUNCE) match = q == (d->vel.x < 0) * 2 + (d->vel.y * d->vel.x < 0); // when coming towards corner surface: prefer corner bounce if(match && matter) { if(!h) return true; // we hit a corner between solids... else if(z1 < ns->floor || z2 > ns->ceil || tagclipped) return true; // corner is not between solids, but we hit it... } if(h) tagclipped = false; // for corners between non-solids, tagclips extend the corner (visualisation does not reflect that, yet) // tagclipped corners between solids are fully clipped cornersurface = 0; break; } case FHF: // FIXME: too simplistic collision with slopes, makes it feels like tiny stairs floor -= (s->vdelta+S(x+1,y)->vdelta+S(x,y+1)->vdelta+S(x+1,y+1)->vdelta)/16.0f; break; case CHF: ceil += (s->vdelta+S(x+1,y)->vdelta+S(x,y+1)->vdelta+S(x+1,y+1)->vdelta)/16.0f; } if(tagclipped) return true; // tagged clips feel like solids if(ceillo) lo = floor; } if(hi - lo < playerheight) return true; float headspace = 10.0f; if(d->type!=ENT_CAMERA) { loopv(players) // collide with other players { playerent *o = players[i]; if(!o || o==d || (o==player1 && d->type==ENT_CAMERA)) continue; if(plcollide(d, o, headspace, hi, lo)) return true; } if(d!=player1) if(plcollide(d, player1, headspace, hi, lo)) return true; } headspace -= 0.01f; if(mmcollide(d, hi, lo)) return true; // collide with map models if(spawn) { d->o.z = lo+eyeheight; // just drop to floor (sideeffect) d->onfloor = true; } else { const float spacelo = d->o.z-eyeheight-lo; if(spacelo<0) { if(spacelo>-0.01 || (spacelo>-0.1 && d==player1 && player1->spectatemode==SM_FLY)) { d->o.z = lo+eyeheight; // stick on step } else if(spacelo>-1.26f && d->type!=ENT_BOUNCE) d->o.z += rise; // rise thru stair else return true; } else { d->o.z -= min(min(drop, spacelo), headspace); // gravity } const float spacehi = hi-(d->o.z+d->aboveeye); if(spacehi<0) { if(spacehi<-0.1) return true; // hack alert! if(spacelo>0.1f) d->o.z = hi-d->aboveeye; // glue to ceiling if in midair d->vel.z = 0; // cancel out jumping velocity } const float floorclamp = d->crouching && (!d->lastjump || lastmillis - d->lastjump > 250) ? 0.1f : 0.01f; d->onfloor = d->o.z-eyeheight-lo < floorclamp; } return false; } VARFP(maxroll, 0, ROLLMOVDEF, ROLLMOVMAX, player1->maxroll = maxroll); VARFP(maxrolleffect, 0, ROLLEFFDEF, ROLLEFFMAX, player1->maxrolleffect = maxrolleffect); VARP(maxrollremote, 0, ROLLMOVDEF + ROLLEFFDEF, ROLLMOVMAX + ROLLEFFMAX); //VAR(recoilbackfade, 0, 100, 1000); void resizephysent(physent *pl, int moveres, int curtime, float min, float max) { if(pl->eyeheightvel==0.0f) return; const bool water = waterlevel > pl->o.z; const float speed = curtime*pl->maxspeed/(water ? 2000.0f : 1000.0f); float h = pl->eyeheightvel * speed / moveres; loopi(moveres) { pl->eyeheight += h; pl->o.z += h; if(collide(pl) && !(pl != player1 && player1->isspectating() && player1->spectatemode==SM_FOLLOW1ST)) // don't check collision during spectating in 1st person view { pl->eyeheight -= h; // collided, revert mini-step pl->o.z -= h; break; } if(pl->eyeheighto.z += min - pl->eyeheight; pl->eyeheight = min; pl->eyeheightvel = 0.0f; break; } if(pl->eyeheight>max) { pl->o.z -= pl->eyeheight - max; pl->eyeheight = max; pl->eyeheightvel = 0.0f; break; } } } // main physics routine, moves a player/monster for a curtime step // moveres indicated the physics precision (which is lower for monsters and multiplayer prediction) // local is false for multiplayer prediction FVARP(flyspeed, 1.0, 2.0, 5.0); void moveplayer(physent *pl, int moveres, bool local, int curtime) { bool water = false; const bool editfly = pl->state==CS_EDITING; const bool specfly = pl->type==ENT_PLAYER && ((playerent *)pl)->spectatemode==SM_FLY; const bool isfly = editfly || specfly; vec d; // vector of direction we ideally want to move in float drop = 0, rise = 0; if(pl->type==ENT_BOUNCE) { bounceent* bounce = (bounceent *) pl; water = waterlevel > pl->o.z; const float speed = curtime*pl->maxspeed/(water ? 2000.0f : 1000.0f); const float friction = water ? 20.0f : (pl->onfloor || isfly ? 6.0f : 30.0f); const float fpsfric = max(friction*20.0f/curtime, 1.0f); if(pl->onfloor) // apply friction { pl->vel.mul(fpsfric-1); pl->vel.div(fpsfric); } else // apply gravity { const float CUBES_PER_METER = 4; // assumes 4 cubes make up 1 meter const float BOUNCE_MASS = 0.5f; // sane default mass of 0.5 kg const float GRAVITY = BOUNCE_MASS*9.81f/CUBES_PER_METER/1000.0f; bounce->vel.z -= GRAVITY*curtime; } d = bounce->vel; d.mul(speed); if(water) d.div(6.0f); // incorrect // rotate float rotspeed = bounce->rotspeed*d.magnitude(); pl->pitch = fmod(pl->pitch+rotspeed, 360.0f); pl->yaw = fmod(pl->yaw+rotspeed, 360.0f); } else // fake physics for player ents to create _the_ cube movement (tm) { const int timeinair = pl->timeinair; int move = pl->onladder && !pl->onfloor && pl->move == -1 ? 0 : pl->move; // movement on ladder if(!editfly) water = waterlevel > pl->o.z - 0.5f; float chspeed = (pl->onfloor || pl->onladder || !pl->crouchedinair) ? 0.4f : 1.0f; const bool crouching = pl->crouching || (pl->eyeheight < pl->maxeyeheight && pl->eyeheight > 1.1f); const float speed = curtime/(water ? 2000.0f : 1000.0f)*pl->maxspeed*(crouching && pl->state != CS_EDITING ? chspeed : 1.0f)*(pl==player1 && isfly ? flyspeed : 1.0f); const float friction = water ? 20.0f : (pl->onfloor || isfly ? 6.0f : (pl->onladder ? 1.5f : 30.0f)); const float fpsfric = max(friction/curtime*20.0f, 1.0f); d.x = (float)(move*cosf(RAD*(pl->yaw-90))); d.y = (float)(move*sinf(RAD*(pl->yaw-90))); d.z = 0.0f; if(isfly || water) { d.x *= (float)cosf(RAD*(pl->pitch)); d.y *= (float)cosf(RAD*(pl->pitch)); d.z = (float)(move*sinf(RAD*(pl->pitch))); } d.x += (float)(pl->strafe*cosf(RAD*(pl->yaw-180))); d.y += (float)(pl->strafe*sinf(RAD*(pl->yaw-180))); float curfullspeed = d.magnitudexy(); pl->vel.mul(fpsfric-1.0f); // slowly apply friction and direction to velocity, gives a smooth movement pl->vel.add(d); pl->vel.div(fpsfric); d = pl->vel; d.mul(speed); if(editfly) // just apply velocity { pl->o.add(d); if(pl->jumpnext && !pl->trycrouch) { pl->vel.z = 0.5f; // fly directly upwards while holding jump keybinds } else if (pl->trycrouch && !pl->jumpnext) { pl->vel.z = -0.5f; // fly directly down while holding crouch keybinds } } else if(specfly) { rise = speed/moveres/1.2f; if(pl->jumpnext) { pl->jumpnext = false; pl->vel.z = 2; } } else // apply velocity with collisions { if(pl->type!=ENT_CAMERA) { if(pl->onladder) { const float climbspeed = 1.0f; if(pl->type==ENT_BOT && pl->state == CS_ALIVE) pl->vel.z = climbspeed; // bots climb upwards only else if(pl->type==ENT_PLAYER && pl->state == CS_ALIVE) { if(((playerent *)pl)->k_up && pl->move > 0) pl->vel.z = climbspeed; else if(((playerent *)pl)->k_down && pl->move < 0) pl->vel.z = -climbspeed; } pl->timeinair = 0; } else { if(pl->onfloor || water) { if(pl->jumpnext) { pl->jumpnext = false; bool doublejump = pl->lastjump && lastmillis - pl->lastjump < 250 && pl->strafe != 0 && pl->o.z - pl->eyeheight - pl->lastjumpheight > 0.2f; pl->lastjumpheight = pl->o.z - pl->eyeheight; pl->vel.z = 2.0f; // physics impulse upwards if(doublejump && curfullspeed > 0.1f) // more velocity on double jump { pl->vel.mul(1.25f / max(pl->vel.magnitudexy() / curfullspeed, 1.0f)); } if(water) // dampen velocity change even harder, gives correct water feel { pl->vel.x /= 8.0f; pl->vel.y /= 8.0f; } else if(pl==player1 || pl->type!=ENT_PLAYER) audiomgr.playsoundc(S_JUMP, pl); pl->lastjump = lastmillis; } pl->timeinair = 0; pl->crouchedinair = false; } else { pl->timeinair += curtime; if (pl->trycrouch && !pl->crouching && !pl->crouchedinair && pl->state!=CS_EDITING) { pl->vel.z += 0.3f; pl->crouchedinair = true; } } } if(timeinair > 200 && !pl->timeinair && pl->inwater == water) { int sound = timeinair > 800 ? S_HARDLAND : S_SOFTLAND; if(pl->state!=CS_DEAD) { if(pl==player1 || pl->type!=ENT_PLAYER) audiomgr.playsoundc(sound, pl); } } } const float gravity = 20.0f; float dropf = (gravity-1)+pl->timeinair/15.0f; // incorrect, but works fine if(water) { dropf = 5; pl->timeinair = 0; } // float slowly down in water if(pl->onladder) { dropf = 0; pl->timeinair = 0; } drop = dropf*curtime/gravity/100/moveres; // at high fps, gravity kicks in too fast rise = speed/moveres/1.2f; // extra smoothness when lifting up stairs if(pl->maxspeed-16.0f>0.5f) pl += 0xF0F0; } } bool collided = false; vec oldorigin = pl->o; if(!editfly) loopi(moveres) // discrete steps collision detection & sliding { const float f = 1.0f/moveres; // try move forward vec o_null = pl->o; pl->o.x += f*d.x; pl->o.y += f*d.y; pl->o.z += f*d.z; volatile vec gcco3(pl->o.x, pl->o.y, pl->o.z); // force capping the o-values to float-representables (avoid player stuck conditions on 32-bit g++ builds) pl->o = vec(gcco3.x, gcco3.y, gcco3.z); hitplayer = NULL; bool spect3rd = player1->spectatemode > SM_FOLLOW1ST && player1->spectatemode <= SM_FOLLOW3RD_TRANSPARENT; if((pl->type == ENT_CAMERA && pl == camera1 && spect3rd) || !collide(pl, false, drop, rise)) continue; int cornersurface1 = cornersurface; vec o_trying = pl->o; // o_trying = o_null + f * d (= one microstep in desired direction) if(!cornersurface1) { // brute-force check, if it is a corner hit after all if(pl->type != ENT_BOUNCE) { int collx = 0, colly = 0; pl->o.x = o_null.x; if(collide(pl, false, drop, rise)) collx = cornersurface; pl->o = o_trying; pl->o.y = o_null.y; if(collide(pl, false, drop, rise)) colly = cornersurface; cornersurface1 = collx | colly; if((cornersurface1 & 3) == 3) cornersurface1 = 0; } else { // try really, really hard to detect corners for bounces (to compensate for the not-so-micro bounceent-microsteps) vec vd(d.x, d.y, 0); static const float a = 3.0f*PI2/10.0f, ca = cosf(a), sa = sinf(a); // 10 probe points, stretched over three turns loopj(10) { if(j) vd = vec(ca * vd.x - sa * vd.y, ca * vd.y + sa *vd.x, 0); pl->o = o_trying; pl->o.add(vd); if(collide(pl, false, drop, rise) && cornersurface) break; } cornersurface1 = cornersurface; } pl->o = o_trying; } collided = true; if(pl->type==ENT_BOUNCE && cornersurface1) { // try corner bounce float ct2f = cornersurface1 & 2 ? -1.0 : 1.0; vec xd = d; xd.x = d.y * ct2f; xd.y = d.x * ct2f; pl->o.x += f * (-d.x + xd.x); pl->o.y += f * (-d.y + xd.y); if(!collide(pl, false, drop, rise)) { d = xd; float sw = pl->vel.x * ct2f; pl->vel.x = pl->vel.y * ct2f; pl->vel.y = sw; pl->vel.mul(0.7f); continue; } pl->o = o_trying; } if(pl->type==ENT_CAMERA || (pl->type==ENT_PLAYER && pl->state==CS_DEAD && ((playerent *)pl)->spectatemode != SM_FLY)) { pl->o = o_null; break; } if(pl->type!=ENT_BOUNCE && hitplayer) { vec dr(hitplayer->o.x-pl->o.x,hitplayer->o.y-pl->o.y,0); float invdist = 1.0f / dr.magnitudexy(), push = (invdist < 10.0f ? dr.dotxy(d)*1.1f*invdist : dr.dotxy(d) * 11.0f); pl->o.x -= f*d.x*push; pl->o.y -= f*d.y*push; if(i==0 && pl->type==ENT_BOT) pl->yaw += (dr.cxy(d)>0 ? 2:-2); // force the bots to change direction if( !collide(pl, false, drop, rise) ) continue; pl->o.x += f*d.x*push; pl->o.y += f*d.y*push; } // the desired direction didn't work pl->o.x = o_null.x; pl->o.y = o_null.y; vec o_nullxy = pl->o; // x and y from o_null but z from o_trying (possibly altered by collide() as well) // try sliding if(cornersurface1) { // along a corner wall float ct2f = cornersurface1 & 2 ? -1.0 : 1.0; float diag = fabs(d.x + ct2f * d.y) * 0.5f; vec vd = vec((d.y*ct2f+d.x >= 0.0f ? diag : -diag), (d.x*ct2f+d.y >= 0.0f ? diag : -diag), 0); float ff = f / (cornersurface1 & 4 ? 42.0f : 333.0f); pl->o.x += f*vd.x - ff*d.x; pl->o.y += f*vd.y - ff*d.y; if(!collide(pl, false, drop, rise)) { d.x = vd.x; d.y = vd.y; continue; } pl->o = o_nullxy; } // try slide along y axis pl->o.y = o_trying.y; if(!collide(pl, false, drop, rise)) { d.x = 0; if(pl->type==ENT_BOUNCE) { pl->vel.x = -pl->vel.x; pl->vel.mul(0.7f); } continue; } pl->o = o_nullxy; // try x axis pl->o.x = o_trying.x; if(!collide(pl, false, drop, rise)) { d.y = 0; if(pl->type==ENT_BOUNCE) { pl->vel.y = -pl->vel.y; pl->vel.mul(0.7f); } continue; } pl->o = o_nullxy; // try just dropping down if(!collide(pl, false, drop, rise)) { d.y = d.x = 0; continue; } pl->o = o_null; if(pl->type==ENT_BOUNCE) { pl->vel.z = -pl->vel.z; pl->vel.mul(0.5f); } break; } pl->stuck = (oldorigin==pl->o); if(collided) pl->oncollision(); else pl->onmoved(oldorigin.sub(pl->o)); if(pl->type==ENT_CAMERA) return; if(pl->type!=ENT_BOUNCE) { if(pl->type == ENT_PLAYER) { // automatically apply smooth roll when strafing playerent *p = (playerent *)pl; float iir = 1.0f + sqrtf((float)curtime) / 25.0f; if(pl->strafe==0) { p->movroll /= iir; } else { p->movroll = clamp(p->movroll + pl->strafe * curtime / -30.0f, -p->maxroll, p->maxroll); } p->effroll /= iir; // fade damage roll pl->roll = p->movroll + p->effroll; if(pl != player1) pl->roll = clamp(pl->roll, (float)-maxrollremote, (float)maxrollremote); } // smooth pitch const float fric = 6.0f/curtime*20.0f; pl->pitch += pl->pitchvel*(curtime/1000.0f)*pl->maxspeed*(pl->crouching ? 0.75f : 1.0f); pl->pitchvel *= fric-3; pl->pitchvel /= fric; /*extern int recoiltest; if(recoiltest) { if(pl->pitchvel < 0.05f && pl->pitchvel > 0.001f) pl->pitchvel -= recoilbackfade/100.0f; // slide back } else*/ if(pl->pitchvel < 0.05f && pl->pitchvel > 0.001f) pl->pitchvel -= ((playerent *)pl)->weaponsel->info.recoilbackfade/100.0f; // slide back if(pl->pitchvel) fixcamerarange(pl); // fix pitch if necessary } // play sounds on water transitions if(pl->type!=ENT_CAMERA) { if(!pl->inwater && water) { if(!pl->lastsplash || lastmillis-pl->lastsplash>500) { audiomgr.playsound(S_SPLASH2, &pl->o); pl->lastsplash = lastmillis; } if(pl==player1) pl->vel.z = 0; } else if(pl->inwater && !water) { audiomgr.playsound(S_SPLASH1, &pl->o); if(pl->type == ENT_BOUNCE) pl->maxspeed /= 8; // prevent nades from jumping out of water } pl->inwater = water; } // store previous locations of all players/bots if(pl->type==ENT_PLAYER || pl->type==ENT_BOT) { ((playerent *)pl)->history.update(pl->o, lastmillis); } // apply volume-resize when crouching if(pl->type==ENT_PLAYER || pl->type==ENT_BOT) { // if(pl==player1 && !(intermission || player1->onladder || (pl->trycrouch && !player1->onfloor && player1->timeinair > 50))) updatecrouch(player1, player1->trycrouch); if(!intermission && (pl == player1 || pl->type == ENT_BOT)) updatecrouch((playerent *)pl, pl->trycrouch); const float croucheyeheight = pl->maxeyeheight*3.0f/4.0f; resizephysent(pl, moveres, curtime, croucheyeheight, pl->maxeyeheight); } } const int PHYSFPS = 200; const int PHYSFRAMETIME = 1000 / PHYSFPS; int physsteps = 0, physframetime = PHYSFRAMETIME, lastphysframe = 0; void physicsframe() // optimally schedule physics frames inside the graphics frames { int diff = lastmillis - lastphysframe; if(diff <= 0) physsteps = 0; else { extern int gamespeed; physframetime = clamp((PHYSFRAMETIME*gamespeed)/100, 1, PHYSFRAMETIME); physsteps = (diff + physframetime - 1)/physframetime; lastphysframe += physsteps * physframetime; if(!multiplayer(NULL) && physsteps > 1000) physsteps = 1000; } } VAR(physinterp, 0, 1, 1); void interppos(physent *pl) { pl->o = pl->newpos; pl->o.z += pl->eyeheight; int diff = lastphysframe - lastmillis; if(diff <= 0 || !physinterp) return; vec deltapos(pl->deltapos); deltapos.mul(min(diff, physframetime)/float(physframetime)); pl->o.add(deltapos); } void moveplayer(physent *pl, int moveres, bool local) { if(physsteps <= 0) { if(local) interppos(pl); return; } if(local) { pl->o = pl->newpos; pl->o.z += pl->eyeheight; } loopi(physsteps-1) moveplayer(pl, moveres, local, physframetime); if(local) pl->deltapos = pl->o; moveplayer(pl, moveres, local, physframetime); if(local) { pl->newpos = pl->o; pl->deltapos.sub(pl->newpos); pl->newpos.z -= pl->eyeheight; interppos(pl); } } void movebounceent(bounceent *p, int moveres, bool local) { moveplayer(p, moveres, local); } // movement input code #define dir(name,v,d,s,os) void name(bool isdown) { player1->s = isdown; player1->v = isdown ? d : (player1->os ? -(d) : 0); player1->lastmove = lastmillis; } dir(backward, move, -1, k_down, k_up) dir(forward, move, 1, k_up, k_down) dir(left, strafe, 1, k_left, k_right) dir(right, strafe, -1, k_right, k_left) void attack(bool on) { if(intermission) return; if(editmode) editdrag(on); else if(player1->state==CS_DEAD || player1->state==CS_SPECTATE) { if(!on) tryrespawn(); } else player1->attacking = on; } void jumpn(bool on) { static bool wason = false; player1->jumpnext = on && !wason && !player1->crouching && !intermission && !player1->isspectating(); wason = on; if(player1->isspectating()) { if(lastmillis - player1->lastdeath > 1000 && on) togglespect(); } } void updatecrouch(playerent *p, bool on) { if(p->crouching == on) return; if(p->state == CS_EDITING) return; // don't apply regular crouch physics in editfly const float crouchspeed = 0.6f; p->crouching = on; p->eyeheightvel = on ? -crouchspeed : crouchspeed; if(p==player1) audiomgr.playsoundc(on ? S_CROUCH : S_UNCROUCH); } void crouch(bool on) { if(player1->isspectating() && on) return; player1->trycrouch = on; } COMMAND(backward, "d"); COMMAND(forward, "d"); COMMAND(left, "d"); COMMAND(right, "d"); COMMANDN(jump, jumpn, "d"); COMMAND(attack, "d"); COMMAND(crouch, "d"); void fixcamerarange(physent *cam) { const float MAXPITCH = 90.0f; if(cam->pitch>MAXPITCH) cam->pitch = MAXPITCH; if(cam->pitch<-MAXPITCH) cam->pitch = -MAXPITCH; while(cam->yaw<0.0f) cam->yaw += 360.0f; while(cam->yaw>=360.0f) cam->yaw -= 360.0f; } FVARP(sensitivity, 1e-3f, 3.0f, 1000.0f); // general mouse sensitivity ("unscoped") FVARP(scopesens, 0, 0, 1000); // scoped mouse sensitivity (if zero, autoscopesens determines, how sensitivity is changed during scoping) FVARP(sensitivityscale, 1e-3f, 1, 1000); // scale all sensitivity values (if unsure, keep at default value "1"- this parameter achieves cosmetic value changes only) VARP(autoscopesens, 0, 0, 1); // switches between scopesensscale and autoscopesensscale to calculate a scoped sensitivity (if scopesens is 0) FVARP(scopesensscale, 1e-3f, 0.5f, 1000.0f); // if scoped, sens = sensitivity * scopesensscale (roughly) float autoscopesensscale = 0.4663077f; // roughly scopefov/fov, recalculated if fov or scopefov changes (init value fits defaults fov 90 and scopefov 50, update, if defaults change) VARP(invmouse, 0, 0, 1); // invert y-axis movement (if "1") FVARP(mouseaccel, 0, 0, 1000); // make fast movement even faster (zero deactivates the feature) FVARP(mfilter, 0.0f, 0.0f, 6.0f); // simple lowpass filtering (zero deactivates the feature) void mousemove(int idx, int idy) { if(intermission || (player1->isspectating() && player1->spectatemode==SM_FOLLOW1ST)) return; bool zooming = player1->weaponsel->type == GUN_SNIPER && ((sniperrifle *)player1->weaponsel)->scoped; // check if player uses scope float dx = idx, dy = idy; if(mfilter > 0.0001f) { // simple IIR-like filter (1st order lowpass) static float fdx = 0, fdy = 0; float k = mfilter * 0.1f; dx = fdx = dx * ( 1.0f - k ) + fdx * k; dy = fdy = dy * ( 1.0f - k ) + fdy * k; } double cursens = sensitivity; // basic unscoped sensitivity if(mouseaccel > 0.0001f && curtime && (idx || idy)) cursens += 0.02f * mouseaccel * sqrtf(dx*dx + dy*dy)/curtime; // optionally accelerated if(zooming) { // when scoped: if(scopesens > 0.0001f) cursens = scopesens; // if specified, use dedicated (fixed) scope sensitivity else cursens *= autoscopesens ? autoscopesensscale : scopesensscale; // or adjust sensitivity by given (fixed) factor or based on scopefov/fov } cursens /= 33.0f * sensitivityscale; // final scaling camera1->yaw += (float) (dx * cursens); camera1->pitch -= (float) (dy * cursens * (invmouse ? -1 : 1)); fixcamerarange(); if(camera1!=player1 && player1->spectatemode!=SM_DEATHCAM) { player1->yaw = camera1->yaw; player1->pitch = camera1->pitch; } } void entinmap(physent *d) // brute force but effective way to find a free spawn spot in the map { vec orig(d->o); loopi(100) // try max 100 times { float dx = (rnd(21)-10)/10.0f*i; // increasing distance float dy = (rnd(21)-10)/10.0f*i; d->o.x += dx; d->o.y += dy; if(!collide(d, true)) { d->resetinterp(); return; } d->o = orig; } // leave ent at original pos, possibly stuck d->resetinterp(); conoutf("can't find entity spawn spot! (%d, %d)", int(d->o.x), int(d->o.y)); } assaultcube-1.2.0.2.1/source/src/platform.h000066400000000000000000000025751352165075300204300ustar00rootroot00000000000000#ifdef __GNUC__ #ifdef _FORTIFY_SOURCE #undef _FORTIFY_SOURCE #endif #endif #include #include #include #include #include #include #include #include #include #ifdef __GNUC__ #include #include #else #include #endif #include #include #ifdef WIN32 #define WIN32_LEAN_AND_MEAN #include "windows.h" #ifndef _WINDOWS #define _WINDOWS #endif #include #ifndef __GNUC__ #include #endif #define ZLIB_DLL #define NO_POSIX_R #endif #ifndef STANDALONE #include #include #define GL_GLEXT_LEGACY #define __glext_h__ #define NO_SDL_GLEXT #include #undef __glext_h__ #include "GL/glext.h" #ifdef __APPLE__ #include "OpenAL/al.h" #include "OpenAL/alc.h" #include "Vorbis/vorbisfile.h" #define MOD_KEYS_CTRL (KMOD_LGUI|KMOD_RGUI) #else #include "AL/al.h" #include "AL/alc.h" #include "vorbis/vorbisfile.h" #define MOD_KEYS_CTRL (KMOD_LCTRL|KMOD_RCTRL) #endif #include #endif #if defined(WIN32) || defined(__APPLE__) || !defined(STANDALONE) || defined(AC_FORCE_SDL_THREADS) #define AC_USE_SDL_THREADS #endif assaultcube-1.2.0.2.1/source/src/protocol.cpp000066400000000000000000000373021352165075300207740ustar00rootroot00000000000000// misc useful functions used by the server #include "cube.h" #ifdef _DEBUG bool protocoldbg = false; void protocoldebug(bool enable) { protocoldbg = enable; } #define DEBUGCOND (protocoldbg) #endif // all network traffic is in 32bit ints, which are then compressed using the following simple scheme (assumes that most values are small). template static inline void putint_(T &p, int n) { DEBUGVAR(n); if(n<128 && n>-127) p.put(n); else if(n<0x8000 && n>=-0x8000) { p.put(0x80); p.put(n); p.put(n>>8); } else { p.put(0x81); p.put(n); p.put(n>>8); p.put(n>>16); p.put(n>>24); } } void putint(ucharbuf &p, int n) { putint_(p, n); } void putint(packetbuf &p, int n) { putint_(p, n); } void putint(vector &p, int n) { putint_(p, n); } int getint(ucharbuf &p) { int c = (char)p.get(); if(c==-128) { int n = p.get(); n |= char(p.get())<<8; DEBUGVAR(n); return n; } else if(c==-127) { int n = p.get(); n |= p.get()<<8; n |= p.get()<<16; n |= (p.get()<<24); DEBUGVAR(n); return n; } else { DEBUGVAR(c); return c; } } // special encoding for asymmetric small integers: -1..252 go into one byte, -256..65279 go into three bytes and any other int goes into five bytes // (the network encoding is compatible with basic getint) template static inline void putaint_(T &p, int n) { DEBUGVAR(n); if(n<253 && n>-2) p.put(n - 125); else if(n<0xFF00 && n>=-256) { n += 256; p.put(0x80); p.put(n); p.put(n>>8); } else { p.put(0x81); p.put(n); p.put(n>>8); p.put(n>>16); p.put(n>>24); } } void putaint(ucharbuf &p, int n) { putaint_(p, n); } void putaint(packetbuf &p, int n) { putaint_(p, n); } void putaint(vector &p, int n) { putaint_(p, n); } int getaint(ucharbuf &p) { int c = ((char)p.get()) + 125; if(c==-128) { int n = p.get(); n |= p.get()<<8; n -= 256; DEBUGVAR(n); return n; } else if(c==-127) { int n = p.get(); n |= p.get()<<8; n |= p.get()<<16; n |= (p.get()<<24); DEBUGVAR(n); return n; } else { DEBUGVAR(c); return c; } } // much smaller encoding for unsigned integers up to 28 bits, but can handle signed template static inline void putuint_(T &p, int n) { DEBUGVAR(n); if(n < 0 || n >= (1<<21)) { p.put(0x80 | (n & 0x7F)); p.put(0x80 | ((n >> 7) & 0x7F)); p.put(0x80 | ((n >> 14) & 0x7F)); p.put(n >> 21); } else if(n < (1<<7)) p.put(n); else if(n < (1<<14)) { p.put(0x80 | (n & 0x7F)); p.put(n >> 7); } else { p.put(0x80 | (n & 0x7F)); p.put(0x80 | ((n >> 7) & 0x7F)); p.put(n >> 14); } } void putuint(ucharbuf &p, int n) { putuint_(p, n); } void putuint(packetbuf &p, int n) { putuint_(p, n); } void putuint(vector &p, int n) { putuint_(p, n); } int getuint(ucharbuf &p) { int n = p.get(); if(n & 0x80) { n += (p.get() << 7) - 0x80; if(n & (1<<14)) n += (p.get() << 14) - (1<<14); if(n & (1<<21)) n += (p.get() << 21) - (1<<21); if(n & (1<<28)) n |= 0xF0000000; } DEBUGVAR(n); return n; } template static inline void putfloat_(T &p, float f) { lilswap(&f, 1); p.put((uchar *)&f, sizeof(float)); } void putfloat(ucharbuf &p, float f) { putfloat_(p, f); } void putfloat(packetbuf &p, float f) { putfloat_(p, f); } void putfloat(vector &p, float f) { putfloat_(p, f); } float getfloat(ucharbuf &p) { float f; p.get((uchar *)&f, sizeof(float)); return lilswap(f); } template static inline void sendstring_(const char *text, T &p) { const char *t = text; if(t) { while(*t) putint(p, *t++); } putint(p, 0); DEBUGVAR(text); } void sendstring(const char *t, ucharbuf &p) { sendstring_(t, p); } void sendstring(const char *t, packetbuf &p) { sendstring_(t, p); } void sendstring(const char *t, vector &p) { sendstring_(t, p); } void getstring(char *text, ucharbuf &p, int len) { char *t = text; do { if(t>=&text[len]) { text[len-1] = 0; return; } if(!p.remaining()) { *t = 0; return; } *t = getint(p); } while(*t++); DEBUGVAR(text); } #define GZMSGBUFSIZE ((MAXGZMSGSIZE * 11) / 10) static uchar *gzbuf = new uchar[GZMSGBUFSIZE]; // not thread-safe, but nesting is no problem void putgzbuf(vector &d, vector &s) // zips a vector into a stream, stored in another vector; adds a header to simplify decompression { int size = s.length(); if(size < 1 || size > MAXGZMSGSIZE) size = 0; uLongf gzbufsize = GZMSGBUFSIZE; if(size && compress2(gzbuf, &gzbufsize, s.getbuf(), size, 9) == Z_OK) { if(gzbufsize > (uint)size) { // use zipped putuint(d, size); putuint(d, (int) gzbufsize); d.put(gzbuf, (int) gzbufsize); return; } } // use raw because it's smaller or because zipping failed putuint(d, size); putuint(d, 0); if(size) d.put(s.getbuf(), size); } ucharbuf *getgzbuf(ucharbuf &p) // fetch a gzipped buffer; needs to be freed properly later { int size = getuint(p); int sizegz = getuint(p); if(sizegz == 0) sizegz = size; // uncompressed was smaller if(sizegz > 0 && p.remaining() >= sizegz && sizegz <= MAXGZMSGSIZE && size >= 0 && size <= MAXGZMSGSIZE) { uchar *data = new uchar[size + 1]; uLongf rawsize = size; if(data) { if(size == sizegz) { memcpy(data, &p.buf[p.len], size); } else if(uncompress(data, &rawsize, &p.buf[p.len], sizegz) != Z_OK || rawsize - size != 0) { p.forceoverread(); delete[] data; return NULL; } p.len += sizegz; return new ucharbuf(data, size); } } p.forceoverread(); return NULL; } void freegzbuf(ucharbuf *p) // free a ucharbuf created by getgzbuf() { if(p) { delete[] p->buf; delete p; } } // filter text according to rules // dst can be identical to src; dst needs to be of size "min(len, strlen(s)) + 1" // returns dst //#define FILENAMESALLLOWERCASE char *filtertext(char *dst, const char *src, int flags, int len) { char *res = dst; bool nowhite = (flags & FTXT_NOWHITE) != 0, // removes all whitespace; adding ALLOWBLANKS, ALLOWNL or ALLOWTAB enables exceptions allowblanks = (flags & FTXT_ALLOWBLANKS) != 0, // only in combination with FTXT_NOWHITE allownl = (flags & FTXT_ALLOWNL) != 0, // only in combination with FTXT_NOWHITE allowtab = (flags & FTXT_ALLOWTAB) != 0, // only in combination with FTXT_NOWHITE nocolor = (flags & FTXT_NOCOLOR) != 0, // removes all '\f' + following char tabtoblank = (flags & FTXT_TABTOBLANK) != 0, // replaces \t with single blanks fillblanks = (flags & FTXT_FILLBLANKS) != 0, // convert ' ' to '_' safecs = (flags & FTXT_SAFECS) != 0, // removes all special chars that may execute commands when evaluate arguments; the argument still requires encapsulation by "" leet = (flags & FTXT_LEET) != 0, // translates leetspeak toupp = (flags & FTXT_TOUPPER) != 0, // translates to all-uppercase tolow = (flags & FTXT_TOLOWER) != 0, // translates to all-lowercase filename = (flags & FTXT_FILENAME) != 0, // strict a-z, 0-9 and "-_.()" (also translates "[]" and "{}" to "()"), removes everything between '<' and '>' allowslash = (flags & FTXT_ALLOWSLASH) != 0, // only in combination with FTXT_FILENAME mapname = (flags & FTXT_MAPNAME) != 0, // only allows lowercase chars, digits, '_', '-' and '.'; probably should be used in combination with TOLOWER cropwhite = (flags & FTXT_CROPWHITE) != 0, // removes leading and trailing whitespace pass = false; if(leet || mapname) nocolor = true; #ifdef FILENAMESALLLOWERCASE if(filename) tolow = true; #endif bool trans = toupp || tolow || leet || filename || fillblanks; bool leadingwhite = cropwhite; char *lastwhite = NULL; bool insidepointybrackets = false; for(int c = *src; c; c = *++src) { c &= 0x7F; // 7-bit ascii. not negotiable. pass = false; if(trans) { if(leet) { const char *org = "1374@5$2!*#%80|+", *asc = "letaassziohzhoit", *a = strchr(org, c); if(a) c = asc[a - org]; } if(filename) { if(c == '>') insidepointybrackets = false; else if(c == '<') insidepointybrackets = true; if(insidepointybrackets || c == '>') continue; // filter anything between '<' and '>' as this may contain commands for texture loading const char *org = "[]{}\\", *asc = "()()/", *a = strchr(org, c); if(a) c = asc[a - org]; } if(tolow) c = tolower(c); else if(toupp) c = toupper(c); if(fillblanks && c == ' ') c = '_'; } if(filename && !(islower(c) #ifndef FILENAMESALLLOWERCASE || isupper(c) #endif || isdigit(c) || strchr("._-()", c) || (allowslash && c == '/'))) continue; if(safecs && strchr("($)\"", c)) continue; if(c == '\t') { if(tabtoblank) c = ' '; else if(allowtab) pass = true; } if(c == '\f') { if(nocolor) { if(src[1]) ++src; continue; } pass = true; } if(c == '\1') { // always filter encoded igraphs if(src[1]) ++src; continue; } if(mapname && !isalnum(c) && !strchr("_-./\\", c)) continue; if(isspace(c)) { if(leadingwhite) continue; if(nowhite && !((c == ' ' && allowblanks) || (c == '\n' && allownl)) && !pass) continue; if(!lastwhite) lastwhite = dst; } else { lastwhite = NULL; if(!pass && !isprint(c)) continue; } leadingwhite = false; *dst++ = c; if(!--len || !*src) break; } if(cropwhite && lastwhite) *lastwhite = '\0'; *dst = '\0'; return res; } // translate certain escape sequences // dst can be identical to src; dst needs to be of size "min(len, strlen(s)) + 1" void filterrichtext(char *dst, const char *src, int len) { int b, c; unsigned long ul; for(c = *src; c; c = *++src) { c &= 0x7F; // 7-bit ascii if(c == '\\') { b = 0; c = *++src; switch(c) { case '\0': --src; continue; case 'f': c = '\f'; break; case 'i': c = '\1'; break; case 'a': c = '\a'; break; case 't': c = '\t'; break; case 'n': c = '\n'; break; case 'x': b = 16; c = *++src; default: if(isspace(c)) continue; if(b == 0 && !isdigit(c)) break; ul = strtoul(src, (char **) &src, b); --src; c = (int) ul & 0x7f; if(!c) continue; // number conversion failed break; } } *dst++ = c; if(!--len || !*src) break; } *dst = '\0'; } // ensures, that d is either two lowercase chars or "" void filterlang(char *d, const char *s) { if(strlen(s) == 2) { filtertext(d, s, FTXT_TOLOWER, 2); if(islower(d[0]) && islower(d[1])) return; } *d = '\0'; } void trimtrailingwhitespace(char *s) { for(int n = (int)strlen(s) - 1; n >= 0 && isspace(s[n]); n--) s[n] = '\0'; } const char *modefullnames[] = { "demo playback", "team deathmatch", "coopedit", "deathmatch", "survivor", "team survivor", "capture the flag", "pistol frenzy", "bot team deathmatch", "bot deathmatch", "last swiss standing", "one shot, one kill", "team one shot, one kill", "bot one shot, one kill", "hunt the flag", "team keep the flag", "keep the flag", "team pistol frenzy", "team last swiss standing", "bot pistol frenzy", "bot last swiss standing", "bot team survivor", "bot team one shot, one kill" }; const char *modeacronymnames[] = { "DEMO", "TDM", "coop", "DM", "SURV", "TSURV", "CTF", "PF", "BTDM", "BDM", "LSS", "OSOK", "TOSOK", "BOSOK", "HTF", "TKTF", "KTF", "TPF", "TLSS", "BPF", "BLSS", "BTSURV", "BTOSOK" }; const char *voteerrors[] = { "voting is currently disabled", "there is already a vote pending", "already voted", "can't vote that often", "this vote is not allowed in the current environment (singleplayer/multiplayer)", "no permission", "invalid vote", "server denied your call", "the next map/mode is already set" }; const char *mmfullnames[] = { "open", "private", "match" }; const char *fullmodestr(int n) { return (n>=-1 && size_t(n+1) < sizeof(modefullnames)/sizeof(modefullnames[0])) ? modefullnames[n+1] : "unknown"; } const char *acronymmodestr(int n) { return (n>=-1 && size_t(n+1) < sizeof(modeacronymnames)/sizeof(modeacronymnames[0])) ? modeacronymnames[n+1] : "UNK"; } // 'n/a' bad on *nix filesystem (demonameformat) const char *modestr(int n, bool acronyms) { return acronyms ? acronymmodestr (n) : fullmodestr(n); } const char *voteerrorstr(int n) { return (n>=0 && (size_t)n < sizeof(voteerrors)/sizeof(voteerrors[0])) ? voteerrors[n] : "unknown"; } const char *mmfullname(int n) { return (n>=0 && n < MM_NUM) ? mmfullnames[n] : "unknown"; } int defaultgamelimit(int gamemode) { return m_teammode ? 15 : 10; } static const int msgsizes[] = // size inclusive message token, 0 for variable or not-checked sizes { SV_SERVINFO, 5, SV_WELCOME, 2, SV_INITCLIENT, 0, SV_POS, 0, SV_POSC, 0, SV_POSN, 0, SV_TEXT, 0, SV_TEAMTEXT, 0, SV_TEXTME, 0, SV_TEAMTEXTME, 0, SV_TEXTPRIVATE, 0, SV_SOUND, 2, SV_VOICECOM, 2, SV_VOICECOMTEAM, 2, SV_CDIS, 2, SV_SHOOT, 0, SV_EXPLODE, 0, SV_SUICIDE, 1, SV_AKIMBO, 2, SV_RELOAD, 3, SV_AUTHT, 0, SV_AUTHREQ, 0, SV_AUTHTRY, 0, SV_AUTHANS, 0, SV_AUTHCHAL, 0, SV_GIBDIED, 5, SV_DIED, 5, SV_GIBDAMAGE, 7, SV_DAMAGE, 7, SV_HITPUSH, 6, SV_SHOTFX, 6, SV_THROWNADE, 8, SV_TRYSPAWN, 1, SV_SPAWNSTATE, 23, SV_SPAWN, 3, SV_SPAWNDENY, 2, SV_FORCEDEATH, 2, SV_RESUME, 0, SV_DISCSCORES, 0, SV_TIMEUP, 3, SV_EDITENT, 13, SV_ITEMACC, 2, SV_MAPCHANGE, 0, SV_ITEMSPAWN, 2, SV_ITEMPICKUP, 2, SV_PING, 2, SV_PONG, 2, SV_CLIENTPING, 2, SV_GAMEMODE, 2, SV_EDITMODE, 2, SV_EDITXY, 8, SV_EDITARCH, 56, SV_EDITBLOCK, 0, SV_EDITD, 6, SV_EDITE, 6, SV_NEWMAP, 2, SV_SENDMAP, 0, SV_RECVMAP, 1, SV_REMOVEMAP, 0, SV_SERVMSG, 0, SV_ITEMLIST, 0, SV_WEAPCHANGE, 2, SV_PRIMARYWEAP, 2, SV_FLAGACTION, 3, SV_FLAGINFO, 0, SV_FLAGMSG, 0, SV_FLAGCNT, 3, SV_ARENAWIN, 2, SV_SETADMIN, 0, SV_SERVOPINFO, 3, SV_CALLVOTE, 0, SV_CALLVOTESUC, 1, SV_CALLVOTEERR, 2, SV_VOTE, 2, SV_VOTERESULT, 2, SV_SETTEAM, 3, SV_TEAMDENY, 2, SV_SERVERMODE, 2, SV_IPLIST, 0, SV_LISTDEMOS, 1, SV_SENDDEMOLIST, 0, SV_GETDEMO, 2, SV_SENDDEMO, 0, SV_DEMOPLAYBACK, 3, SV_CONNECT, 0, SV_SWITCHNAME, 0, SV_SWITCHSKIN, 0, SV_SWITCHTEAM, 0, SV_CLIENT, 0, SV_EXTENSION, 0, SV_MAPIDENT, 3, SV_HUDEXTRAS, 2, SV_POINTS, 0, -1 }; int msgsizelookup(int msg) { static int sizetable[SV_NUM] = { -1 }; if(sizetable[0] < 0) { memset(sizetable, -1, sizeof(sizetable)); for(const int *p = msgsizes; *p >= 0; p += 2) sizetable[p[0]] = p[1]; } return msg >= 0 && msg < SV_NUM ? sizetable[msg] : -1; } assaultcube-1.2.0.2.1/source/src/protocol.h000066400000000000000000000312701352165075300204370ustar00rootroot00000000000000#define MAXCLIENTS 256 // in a multiplayer game, can be arbitrarily changed #define DEFAULTCLIENTS 6 #define MAXTRANS 5000 // max amount of data to swallow in 1 go #define CUBE_DEFAULT_SERVER_PORT 28763 #define CUBE_SERVINFO_PORT_LAN 28762 #define CUBE_SERVINFO_PORT(serverport) (serverport+1) #define CUBE_SERVINFO_TO_SERV_PORT(servinfoport) (servinfoport-1) #define PROTOCOL_VERSION 1201 // bump when protocol changes (use negative numbers for mods!) #define DEMO_VERSION 2 // bump when demo format changes #define DEMO_MAGIC "ASSAULTCUBE_DEMO" #define DEMO_MINTIME 10000 // don't keep demo recordings with less than 10 seconds #define MAXMAPSENDSIZE 65536 #define MAXCFGFILESIZE 65536 #define MAXGZMSGSIZE 65536 #define MAXMEDIADOWNLOADFILESIZE 1024000 // hard cap on filesizes (raw and unzipped) - to limit the effect of zip bombs - no nice error messages: just cap #define MAXMODDOWNLOADSIZE 1024000 // hard cap on the filesize of downloaded mod packages - to keep stuff reasonable #define MAXFILESINADZIP 21 // max number of files extracted from a zip by autodownload extern bool modprotocol; #define CUR_PROTOCOL_VERSION (modprotocol ? -PROTOCOL_VERSION : PROTOCOL_VERSION) // network messages codes, c2s, c2c, s2c enum { SV_SERVINFO = 0, SV_WELCOME, SV_INITCLIENT, SV_POS, SV_POSC, SV_POSN, SV_TEXT, SV_TEAMTEXT, SV_TEXTME, SV_TEAMTEXTME, SV_TEXTPRIVATE, SV_SOUND, SV_VOICECOM, SV_VOICECOMTEAM, SV_CDIS, SV_SHOOT, SV_EXPLODE, SV_SUICIDE, SV_AKIMBO, SV_RELOAD, SV_AUTHT, SV_AUTHREQ, SV_AUTHTRY, SV_AUTHANS, SV_AUTHCHAL, SV_GIBDIED, SV_DIED, SV_GIBDAMAGE, SV_DAMAGE, SV_HITPUSH, SV_SHOTFX, SV_THROWNADE, SV_TRYSPAWN, SV_SPAWNSTATE, SV_SPAWN, SV_SPAWNDENY, SV_FORCEDEATH, SV_RESUME, SV_DISCSCORES, SV_TIMEUP, SV_EDITENT, SV_ITEMACC, SV_MAPCHANGE, SV_ITEMSPAWN, SV_ITEMPICKUP, SV_PING, SV_PONG, SV_CLIENTPING, SV_GAMEMODE, SV_EDITMODE, SV_EDITXY, SV_EDITARCH, SV_EDITBLOCK, SV_EDITD, SV_EDITE, SV_NEWMAP, SV_SENDMAP, SV_RECVMAP, SV_REMOVEMAP, SV_SERVMSG, SV_ITEMLIST, SV_WEAPCHANGE, SV_PRIMARYWEAP, SV_FLAGACTION, SV_FLAGINFO, SV_FLAGMSG, SV_FLAGCNT, SV_ARENAWIN, SV_SETADMIN, SV_SERVOPINFO, SV_CALLVOTE, SV_CALLVOTESUC, SV_CALLVOTEERR, SV_VOTE, SV_VOTERESULT, SV_SETTEAM, SV_TEAMDENY, SV_SERVERMODE, SV_IPLIST, SV_LISTDEMOS, SV_SENDDEMOLIST, SV_GETDEMO, SV_SENDDEMO, SV_DEMOPLAYBACK, SV_CONNECT, SV_SWITCHNAME, SV_SWITCHSKIN, SV_SWITCHTEAM, SV_CLIENT, SV_EXTENSION, SV_MAPIDENT, SV_HUDEXTRAS, SV_POINTS, SV_NUM }; #ifdef _DEBUG extern void protocoldebug(bool enable); // converts message code to char extern const char *messagenames[SV_NUM]; #endif enum { SA_KICK = 0, SA_BAN, SA_REMBANS, SA_MASTERMODE, SA_AUTOTEAM, SA_FORCETEAM, SA_GIVEADMIN, SA_MAP, SA_RECORDDEMO, SA_STOPDEMO, SA_CLEARDEMOS, SA_SERVERDESC, SA_SHUFFLETEAMS, SA_NUM}; enum { VOTE_NEUTRAL = 0, VOTE_YES, VOTE_NO, VOTE_NUM }; enum { VOTEE_DISABLED = 0, VOTEE_CUR, VOTEE_MUL, VOTEE_MAX, VOTEE_AREA, VOTEE_PERMISSION, VOTEE_INVALID, VOTEE_WEAK, VOTEE_NEXT, VOTEE_NUM }; enum { MM_OPEN = 0, MM_PRIVATE, MM_MATCH, MM_NUM }; enum { MM_MASK = 0x03 }; enum { AT_DISABLED = 0, AT_ENABLED = 1, AT_SHUFFLE = 2, AT_NUM }; enum { FA_PICKUP = 0, FA_STEAL, FA_DROP, FA_LOST, FA_RETURN, FA_SCORE, FA_NUM, FA_RESET }; enum { FM_PICKUP = 0, FM_DROP, FM_LOST, FM_RETURN, FM_SCORE, FM_KTFSCORE, FM_SCOREFAIL, FM_RESET, FM_NUM }; enum { FTR_INFO = 0, FTR_PLAYERWISH, FTR_AUTOTEAM, FTR_SILENTFORCE, FTR_NUM }; // forceteam-reasons enum { SP_OK = 0, SP_REFILLMATCH, SP_OK_NUM, SP_WRONGMAP, SP_SPECT, SP_NUM }; // spawn permission (=10 && gamemode<=12) || gamemode==21) #define m_htf (gamemode==13) #define m_ktf (gamemode==14 || gamemode==15) #define m_noitems (m_lms || m_osok) #define m_noitemsnade (m_lss) #define m_nopistol (m_osok || m_lss) #define m_noprimary (m_pistol || m_lss) #define m_noguns (m_nopistol && m_noprimary) #define m_arena (m_lms || m_lss || m_osok) #define m_autospawn (gamemode == 0 || gamemode == 2 || gamemode == 6 || gamemode == 13 || gamemode == 16) #define m_teammode (gamemode==0 || gamemode==4 || gamemode==5 || gamemode==7 || gamemode==11 || gamemode==13 || gamemode==14 || gamemode==16 || gamemode==17 || gamemode==20 || gamemode==21) #define m_tarena (m_arena && m_teammode) #define m_botmode (gamemode==7 || gamemode == 8 || gamemode==12 || (gamemode>=18 && gamemode<=21)) #define m_valid(mode) (((mode)>=0 && (mode)=0 && (mode)!=7 && (mode)!=8 && (mode)!=12 && ((mode)<18 || (mode)>21)) #define m_demo (gamemode==-1) #define m_coop (gamemode==1) #define m_flags (m_ctf || m_htf || m_ktf) #define m_isdemo(x) ((x) == -1) // single filter modes #define FTXT_NOWHITE (1<<8) #define FTXT_ALLOWBLANKS (1<<9) #define FTXT_ALLOWNL (1<<10) #define FTXT_ALLOWTAB (1<<11) #define FTXT_NOCOLOR (1<<12) #define FTXT_TABTOBLANK (1<<13) #define FTXT_FILLBLANKS (1<<14) #define FTXT_SAFECS (1<<15) #define FTXT_LEET (1<<16) #define FTXT_TOUPPER (1<<17) #define FTXT_TOLOWER (1<<18) #define FTXT_FILENAME (1<<19) #define FTXT_ALLOWSLASH (1<<20) #define FTXT_MAPNAME (1<<21) #define FTXT_CROPWHITE (1<<22) // character classes #define FTXT__ALIAS (FTXT_NOWHITE | FTXT_NOCOLOR | FTXT_SAFECS | FTXT_MAPNAME) #define FTXT__SERVDESC (FTXT_NOWHITE | FTXT_ALLOWBLANKS | FTXT_TABTOBLANK) #define FTXT__MAPMSG (FTXT_NOWHITE | FTXT_ALLOWBLANKS | FTXT_TABTOBLANK) #define FTXT__MAPINFO_LICENSE (FTXT_NOWHITE | FTXT_NOCOLOR | FTXT_TOLOWER | FTXT_MAPNAME) #define FTXT__MAPINFO_COMMENT (FTXT_NOWHITE | FTXT_NOCOLOR | FTXT_ALLOWBLANKS | FTXT_TABTOBLANK) #define FTXT__MAPNAME (FTXT_NOCOLOR | FTXT_MAPNAME | FTXT_TOLOWER) #define FTXT__MDLATTR (FTXT_NOWHITE | FTXT_ALLOWBLANKS | FTXT_TABTOBLANK | FTXT_NOCOLOR | FTXT_SAFECS) #define FTXT__DEMONAME (FTXT_NOCOLOR | FTXT_MAPNAME) #define FTXT__PLAYERNAME (FTXT_NOWHITE | FTXT_NOCOLOR) #define FTXT__SERVERINFO (FTXT_ALLOWTAB) #define FTXT__MOTD (FTXT_TABTOBLANK) #define FTXT__CHAT (FTXT_NOWHITE | FTXT_ALLOWBLANKS | FTXT_NOCOLOR | FTXT_TABTOBLANK) #define FTXT__LOG (FTXT_NOCOLOR | FTXT_TABTOBLANK) #define FTXT__LOGIDENT (FTXT_NOCOLOR | FTXT_NOWHITE | FTXT_FILENAME) #define FTXT__PREFERENCES (FTXT_NOCOLOR | FTXT_NOWHITE | FTXT_FILENAME) #define FTXT__AUTH (FTXT_NOCOLOR | FTXT_NOWHITE) #define FTXT__KICKBANREASON (FTXT_NOWHITE | FTXT_ALLOWBLANKS | FTXT_NOCOLOR | FTXT_TABTOBLANK) #define FTXT__FAVCATEGORY (FTXT_NOWHITE | FTXT_ALLOWBLANKS | FTXT_NOCOLOR) #define FTXT__GLOBALNAME (FTXT_NOWHITE | FTXT_NOCOLOR | FTXT_FILLBLANKS) #define FTXT__MEDIAFILENAME (FTXT_FILENAME) #define FTXT__MEDIAFILEPATH (FTXT_FILENAME | FTXT_ALLOWSLASH) #define FTXT__ZIPDESC (FTXT_NOWHITE | FTXT_ALLOWBLANKS | FTXT_TABTOBLANK | FTXT_NOCOLOR | FTXT_SAFECS) #define FTXT__CERTFILENAME (FTXT_MAPNAME | FTXT_TOLOWER) #define FTXT__CONSOLEPASTE (FTXT_TABTOBLANK) #define FTXT__AUTOKEYMAPNAME (FTXT_SAFECS) assaultcube-1.2.0.2.1/source/src/protos.h000066400000000000000000001443651352165075300201360ustar00rootroot00000000000000// protos for ALL external functions in cube... struct authkey { const char *name; uchar sk[64]; authkey(const char *aname, const char *privkey); ~authkey() { if(name) printf("deleting %s\n", name); DELSTRING(name); } }; enum { CERT_MISC = 0, CERT_DEV, CERT_MASTER, CERT_SERVER, CERT_PLAYER, CERT_CLANBOSS, CERT_CLAN, CERT_NUM }; // keep the lists of certtype-attributes in crypto.cpp in sync with this! struct certline { char *key, *val, *comment; }; struct cert { char *orgmsg, // original file content, unchanged *workmsg, // copy of orgmsg, with changes *name, // name of the cert (player name, clan name, etc), needs to be unique (in combination with type) *orgfilename; // name of the file, the cert was loaded from - without path or extension uchar *signedby, // public key the cert was signed with *pubkey; // public key of the cert int orglen, // original filesize signeddate, // date, the cert was signed, in _minutes_ since the epoch days2expire, days2renew; struct cert *parent, // cert of the signedby-key, if in tree *next; // used to chain certs vector lines; uchar rank, // hierarchy level of the cert, 0 if not in tree type; // parsed type (value has to be in range all the time!) bool isvalid, // signature is valid and cert is not expired ischecked, // signature is checked valid needsrenewal, // cert is valid, but should be renewed expired, // true, if the cert type does expire and the cert is properly signed, but the expired-date is passed superseded, // a newer valid cert of same type and name exists blacklisted, // pubkey of the cert is listed on the blacklist illegal; // cert has too high rank for its type bool parse(); struct certline *getline(const char *key); const char *getval(const char *key); char *getcertfilename(const char *subpath); char *getnewcertfilename(const char *subpath); void movecertfile(const char *subpath); cert(const char *filename) : orgmsg(NULL), workmsg(NULL), name(NULL), signedby(NULL), pubkey(NULL), signeddate(0), parent(NULL), next(NULL), rank(0), type(CERT_MISC), isvalid(false), ischecked(false), needsrenewal(false), expired(false), superseded(false), blacklisted(false), illegal(false) { orgfilename = filename ? newstring(filename) : NULL; if(orgfilename) { char *ofn = getcertfilename(NULL); orgmsg = loadfile(ofn, &orglen); if(orgmsg) parse(); if(!ischecked) movecertfile("invalid"); // move invalid certs out of the way delstring(ofn); } } ~cert() { DELETEA(workmsg); DELETEA(orgmsg); DELSTRING(orgfilename); } }; struct makecert { char *buf, *curbuf, *endbuf; cert *c; makecert(int bufsize = 10); ~makecert(); void addline(const char *key, const char *val, const char *com); char *sign(const uchar *keypair, const char *com); }; #ifndef STANDALONE extern bool hasTE, hasMT, hasMDA, hasDRE, hasstencil, hasST2, hasSTW, hasSTS, hasAF; // GL_ARB_multitexture extern PFNGLACTIVETEXTUREARBPROC glActiveTexture_; extern PFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTexture_; extern PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2f_; extern PFNGLMULTITEXCOORD3FARBPROC glMultiTexCoord3f_; // GL_EXT_multi_draw_arrays extern PFNGLMULTIDRAWARRAYSEXTPROC glMultiDrawArrays_; extern PFNGLMULTIDRAWELEMENTSEXTPROC glMultiDrawElements_; // GL_EXT_draw_range_elements extern PFNGLDRAWRANGEELEMENTSEXTPROC glDrawRangeElements_; // GL_EXT_stencil_two_side extern PFNGLACTIVESTENCILFACEEXTPROC glActiveStencilFace_; // GL_ATI_separate_stencil extern PFNGLSTENCILOPSEPARATEATIPROC glStencilOpSeparate_; extern PFNGLSTENCILFUNCSEPARATEATIPROC glStencilFuncSeparate_; struct color { float r, g, b, alpha; color(){} color(float r, float g, float b) : r(r), g(g), b(b), alpha(1.0f) {} color(float r, float g, float b, float a) : r(r), g(g), b(b), alpha(a) {} }; // console extern stream *clientlogfile; extern vector *bootclientlog; extern void keypress(int keycode, int scancode, bool isdown, SDL_Keymod mod = KMOD_NONE); extern int rendercommand(int x, int y, int w); extern void renderconsole(); extern char *getcurcommand(int *pos); extern char *addreleaseaction(const char *s); extern void savehistory(); extern void loadhistory(); extern void processtextinput(const char *text); extern void writebinds(stream *f); extern void clientlogf(const char *s, ...) PRINTFARGS(1, 2); struct keym { int code; enum { ACTION_DEFAULT = 0, ACTION_EDITING, ACTION_SPECTATOR, NUMACTIONS }; char *name, *actions[NUMACTIONS]; bool pressed, unchangeddefault[NUMACTIONS]; keym() : code(-1), name(NULL), pressed(false) { loopi(NUMACTIONS) { actions[i] = newstring(""); unchangeddefault[i] = false; } } ~keym() { DELETEA(name); loopi(NUMACTIONS) DELETEA(actions[i]); } }; extern keym *keypressed; extern bool bindkey(keym *km, const char *action, int state = keym::ACTION_DEFAULT); extern keym **findbinda(const char *action, int type = keym::ACTION_DEFAULT); extern bool bindc(int code, const char *action, int type = keym::ACTION_DEFAULT); extern keym *findbindc(int code); // menus extern void rendermenu(); extern bool menuvisible(); extern void menureset(void *menu); extern void menuitemmanual(void *menu, char *text, char *action = NULL, color *bgcolor = NULL, const char *desc = NULL); extern void menuimagemanual(void *menu, const char *filename1, const char *filename2, char *text, char *action = NULL, color *bgcolor = NULL, const char *desc = NULL); extern void menutitlemanual(void *menu, const char *title); extern bool needscoresreorder; extern void menuheader(void *menu, char *header, char *footer, bool heap = false); extern void menusay(const char *text); extern bool menukey(int code, bool isdown = true, SDL_Keymod mod = KMOD_NONE); extern void *addmenu(const char *name, const char *title = NULL, bool allowinput = true, void (__cdecl *refreshfunc)(void *, bool) = NULL, bool (__cdecl *keyfunc)(void *, int, bool) = NULL, bool hotkeys = false, bool forwardkeys = false); extern bool rendermenumdl(); extern void menuset(void *m, bool save = true); extern void menuselect(void *menu, int sel); extern void showmenu(const char *name, bool top = true); extern void closemenu(const char *name); extern void addchange(const char *desc, int type); extern void clearchanges(int type); extern void refreshapplymenu(void *menu, bool init); struct mitem { struct gmenu *parent; color *bgcolor; bool greyedout; static bool menugreyedout; mitem(gmenu *parent, color *bgcolor, int type) : parent(parent), bgcolor(bgcolor), greyedout(menugreyedout), mitemtype(type) {} virtual ~mitem() {} virtual void render(int x, int y, int w); virtual int width() = 0; virtual int select() { return 0; } virtual void focus(bool on) { } virtual void say(const char *text) { } virtual void key(int code, bool isdown) { } virtual void init() {} virtual const char *getdesc() { return NULL; } virtual const char *gettext() { return NULL; } virtual const char *getaction() { return NULL; } bool isselection(); void renderbg(int x, int y, int w, color *c); int execaction(const char *arg1); static color gray, white, whitepulse; int mitemtype; enum { TYPE_TEXTINPUT, TYPE_KEYINPUT, TYPE_CHECKBOX, TYPE_MANUAL, TYPE_SLIDER }; }; struct mdirlist { char *dir, *ext, *action, *searchfile, *subdiraction; bool image, subdirdots; ~mdirlist() { DELETEA(dir); DELETEA(ext); DELETEA(action); DELETEA(searchfile); DELETEA(subdiraction); } }; struct gmenu { const char *name, *title, *header, *footer; vector items; int menusel, menuselinit; bool allowinput, inited, hotkeys, forwardkeys; void (__cdecl *refreshfunc)(void *, bool); bool (__cdecl *keyfunc)(void *, int, bool); char *initaction; char *usefont; bool allowblink; bool persistentselection; bool synctabstops; bool hasdesc; bool headfootheap; const char *mdl; int anim, rotspeed, scale; int footlen; int xoffs, yoffs; char *previewtexture, *previewtexturetitle; mdirlist *dirlist; gmenu() : name(NULL), title(NULL), header(NULL), footer(NULL), menuselinit(-1), initaction(NULL), usefont(NULL), allowblink(false), persistentselection(false), synctabstops(false), hasdesc(false), headfootheap(false), mdl(NULL), footlen(0), xoffs(0), yoffs(0), previewtexture(NULL), previewtexturetitle(NULL), dirlist(NULL) {} virtual ~gmenu() { DELETEA(name); DELETEA(mdl); DELETEP(dirlist); DELETEA(initaction); DELETEA(usefont); items.deletecontents(); } void render(); void renderbg(int x1, int y1, int x2, int y2, bool border); void conprintmenu(); void refresh(); void open(); void close(); void init(); int headeritems(); }; struct mline { string name, cmd; }; // serverbrowser extern void addserver(const char *servername, int serverport, int weight); extern bool resolverwait(const char *name, ENetAddress *address); extern int connectwithtimeout(ENetSocket sock, const char *hostname, ENetAddress &remoteaddress); extern void writeservercfg(); extern void refreshservers(void *menu, bool init); extern bool serverskey(void *menu, int code, bool isdown); extern bool serverinfokey(void *menu, int code, bool isdown); struct serverinfo { enum { UNRESOLVED = 0, RESOLVING, RESOLVED }; string name; string full; string map; string sdesc; string description; string cmd; int mode, numplayers, maxclients, ping, protocol, minremain, resolved, port, lastpingmillis, pongflags, getinfo, menuline_from, menuline_to; ENetAddress address; vector playernames; uchar namedata[MAXTRANS]; vector infotexts; uchar textdata[MAXTRANS]; char lang[3]; color *bgcolor; int favcat, msweight, weight; int uplinkqual, uplinkqual_age; unsigned char uplinkstats[MAXCLIENTS + 1]; serverinfo() : mode(0), numplayers(0), maxclients(0), ping(9999), protocol(0), minremain(0), resolved(UNRESOLVED), port(-1), lastpingmillis(0), pongflags(0), getinfo(EXTPING_NOP), bgcolor(NULL), favcat(-1), msweight(0), weight(0), uplinkqual(0), uplinkqual_age(0) { name[0] = full[0] = map[0] = sdesc[0] = description[0] = '\0'; loopi(3) lang[i] = '\0'; loopi(MAXCLIENTS + 1) uplinkstats[i] = 0; } }; extern serverinfo *getconnectedserverinfo(); extern void pingservers(); extern void updatefrommaster(int *force); // http struct httpget { // parameters const char *hostname, *url; // set by set_host() and get() const char *useragent, *referrer; // can be set manually with "newstrings", deleted automatically const char *err; // read-only ENetAddress ip; // set by set_host() int maxredirects, maxtransfer, maxsize, connecttimeout; // set manually int (__cdecl *callbackfunc)(void *data, float progress); void *callbackdata; // internal ENetSocket tcp; stopwatch tcp_age; vector rawsnd, rawrec, datarec; // result char *header; int response, chunked, gzipped, contentlength, offset, traffic; uint elapsedtime; vector *outvec; // receives data, if not NULL (must be set up manually) stream *outstream; // receives data, if not NULL (must be set up manually) httpget() { memset(&hostname, 0, sizeof(struct httpget)); tcp = ENET_SOCKET_NULL; reset(); } ~httpget() { reset(); DELSTRING(useragent); DELSTRING(referrer); DELETEP(outvec); DELETEP(outstream); } void reset(int keep = 0); // cleanup bool set_host(const char *newhostname); // set and resolve host void set_port(int port); // set port (disconnect, if different to previous) bool execcallback(float progress); void disconnect(); bool connect(bool force = false); int get(const char *url1, uint timeout, uint totaltimeout, int range = 0, bool head = false); // get web ressource }; struct urlparse { char *buf; // result (scheme:[//[user:password@]domain[:port]][/]path[?query][#fragment]) const char *scheme, *userpassword, *domain, *port, *path, *query, *fragment; urlparse() { memset(&buf, 0, sizeof(struct urlparse)); } ~urlparse() { DELSTRING(buf); } void set(const char *newurl); // set and parse url }; extern char *urlencode(const char *s, bool strict = false); struct packetqueue { ringbuf packets; packetqueue(); ~packetqueue(); void queue(ENetPacket *p); bool flushtolog(const char *logfile); void clear(); }; // rendergl extern glmatrixf mvmatrix, projmatrix, clipmatrix, mvpmatrix, invmvmatrix, invmvpmatrix; extern void resetcamera(); extern void gl_checkextensions(); extern void gl_init(int w, int h, int depth, int fsaa); extern void enablepolygonoffset(GLenum type); extern void disablepolygonoffset(GLenum type, bool restore = true); extern void line(int x1, int y1, float z1, int x2, int y2, float z2); extern void line(int x1, int y1, int x2, int y2, color *c = NULL); extern void box(block &b, float z1, float z2, float z3, float z4); extern void box2d(int x1, int y1, int x2, int y2, int gray); extern void dot(int x, int y, float z); extern void linestyle(float width, int r, int g, int b); extern void blendbox(int x1, int y1, int x2, int y2, bool border, int tex = -1, color *c = NULL); extern void quad(GLuint tex, float x, float y, float s, float tx, float ty, float tsx, float tsy = 0); extern void quad(GLuint tex, vec &c1, vec &c2, float tx, float ty, float tsx, float tsy); extern void circle(GLuint tex, float x, float y, float r, float tx, float ty, float tr, int subdiv = 32); extern void framedquadtexture(GLuint tex, int x, int y, int xs, int ys, int border = 0, int backlight = 255, bool blend = false); extern void setperspective(float fovy, float aspect, float nearplane, float farplane); extern void sethudgunperspective(bool on); extern void gl_drawframe(int w, int h, float changelod, float curfps, int elapsed); extern void clearminimap(); extern void resetzones(); extern void rendercursor(int x, int y, int w); extern void renderaboveheadicon(playerent *p); extern void drawscope(bool preload = false); extern float dynfov(); extern int fog; // shadow extern bool addshadowbox(const vec &bbmin, const vec &bbmax, const vec &extrude, const glmatrixf &mat); extern void drawstencilshadows(); // texture struct Texture { char *name; int xs, ys, bpp, clamp; float scale; bool mipmap, canreduce; GLuint id; }; extern Texture *notexture, *noworldtexture; extern bool silent_texture_load; extern bool uniformtexres; extern void scaletexture(uchar *src, uint sw, uint sh, uint bpp, uchar *dst, uint dw, uint dh); extern void createtexture(int tnum, int w, int h, void *pixels, int clamp, bool mipmap, bool canreduce, GLenum format); extern SDL_Surface *wrapsurface(void *data, int width, int height, int bpp); extern SDL_Surface *creatergbsurface(int width, int height); extern SDL_Surface *creatergbasurface(int width, int height); extern SDL_Surface *forcergbsurface(SDL_Surface *os); extern SDL_Surface *forcergbasurface(SDL_Surface *os); extern Texture *textureload(const char *name, int clamp = 0, bool mipmap = true, bool canreduce = false, float scale = 1.0f, bool trydl = false); extern Texture *lookuptexture(int tex, Texture *failtex = notexture, bool trydl = false); extern const char *gettextureslot(int i); extern bool reloadtexture(Texture &t); extern void reloadtextures(); extern bool loadskymap(bool reload); extern void *texconfig_copy(); extern void texconfig_delete(void *s); extern uchar *texconfig_paste(void *_s, uchar *usedslots); static inline Texture *lookupworldtexture(int tex, bool trydl = true) { return lookuptexture(tex, noworldtexture, trydl); } extern float skyfloor; extern void draw_envbox(int fogdist); extern int maxtmus; extern void inittmus(); extern void resettmu(int n); extern void scaletmu(int n, int rgbscale, int alphascale = 0); extern void colortmu(int n, float r = 0, float g = 0, float b = 0, float a = 0); extern void setuptmu(int n, const char *rgbfunc = NULL, const char *alphafunc = NULL); struct igraph { const char *fname; struct Texture *tex; vector frames; int used; }; extern void updateigraphs(); extern igraph *getusedigraph(int i); extern int getigraph(const char *mnem); extern void encodeigraphs(char *d, const char *s, int len); extern void enumigraphs(vector &igs, const char *s, int len); // renderhud enum { CROSSHAIR_DEFAULT = NUMGUNS, CROSSHAIR_TEAMMATE, CROSSHAIR_SCOPE, CROSSHAIR_EDIT, CROSSHAIR_NUM }; extern const char *crosshairnames[]; extern Texture *crosshairs[]; extern void drawcrosshair(playerent *p, int n, struct color *c = NULL, float size = -1.0f); // autodownload enum { PCK_TEXTURE = 0, PCK_SKYBOX, PCK_MAPMODEL, PCK_AUDIO, PCK_MAP, PCK_MOD, PCK_NUM }; extern int autodownload; extern void setupautodownload(); extern void pollautodownloadresponse(); extern bool requirepackage(int type, const char *name, const char *host = NULL); extern int downloadpackages(bool loadscr = true); extern void sortpckservers(); extern void writepcksourcecfg(); struct zone { int x1, x2, y1, y2, color; }; // zones (drawn on the minimap) // rendercubes extern void mipstats(const int a[]); extern const char *cubetypenames[]; extern bool editfocusdetails(sqr *s); extern int lighterror; extern void render_flat(int tex, int x, int y, int size, int h, sqr *l1, sqr *l2, sqr *l3, sqr *l4, bool isceil); extern void render_flatdelta(int wtex, int x, int y, int size, float h1, float h2, float h3, float h4, sqr *l1, sqr *l2, sqr *l3, sqr *l4, bool isceil); extern void render_square(int wtex, float floor1, float floor2, float ceil1, float ceil2, int x1, int y1, int x2, int y2, int size, sqr *l1, sqr *l2, bool topleft, int dir); extern void render_tris(int x, int y, int size, bool topleft, sqr *h1, sqr *h2, sqr *s, sqr *t, sqr *u, sqr *v); extern void resetcubes(); extern void setupstrips(); extern void renderstripssky(); extern void renderstrips(); extern void rendershadow(int x, int y, int xs, int ys, const vec &texgenS, const vec &texgenT); // water extern void setwatercolor(const char *r = "", const char *g = "", const char *b = "", const char *a = ""); extern void calcwaterscissor(); extern void addwaterquad(int x, int y, int size); extern int renderwater(float hf, GLuint reflecttex, GLuint refracttex); extern void resetwater(); // client extern void abortconnect(); extern void disconnect(int onlyclean = 0, int async = 0); extern void cleanupclient(); extern void toserver(char *text); extern void addmsg(int type, const char *fmt = NULL, ...); extern bool multiplayer(const char *op = ""); extern bool allowedittoggle(); extern void sendpackettoserv(int chan, ENetPacket *packet); extern void gets2c(); extern void c2sinfo(playerent *d); extern void c2skeepalive(); extern void neterr(const char *s); extern int getclientnum(); extern void getmap(char *name = NULL, char *callback = NULL); extern void newteam(char *name); extern bool securemapcheck(const char *map, bool msg = true); extern int getbuildtype(); extern void sendintro(); extern void getdemo(int *idx, char *dsp); extern void listdemos(); // serverms bool requestmasterf(const char *fmt, ...); // for AUTH et al // clientgame extern flaginfo flaginfos[2]; extern entitystats_s clentstats; extern mapdim_s clmapdims; extern int sessionid; extern int gametimecurrent; extern int gametimemaximum; extern int lastgametimeupdate; struct serverstate { int autoteam; int mastermode; int matchteamsize; void reset() { autoteam = mastermode = matchteamsize = 0; }}; extern struct serverstate servstate; extern void updateworld(int curtime, int lastmillis); extern void resetmap(bool mrproper = true); extern void startmap(const char *name, bool reset = true, bool norespawn = false); extern void changemap(const char *name); extern void initclient(); extern void deathstate(playerent *pl); extern void spawnplayer(playerent *d); extern void dodamage(int damage, playerent *pl, playerent *actor, int gun = -1, bool gib = false, bool local = true); extern void dokill(playerent *pl, playerent *act, bool gib = false, int gun = 0); extern playerent *newplayerent(); extern botent *newbotent(); extern void freebotent(botent *d); extern char *getclientmap(); extern int getclientmode(); extern int teamatoi(const char *name); extern void zapplayer(playerent *&d); extern playerent *getclient(int cn); extern playerent *newclient(int cn); extern void timeupdate(int milliscur, int millismax); // was (int timeremain); extern void respawnself(); extern void setskin(playerent *pl, int skin, int team = -1); extern void callvote(int type, const char *arg1 = NULL, const char *arg2 = NULL, const char *arg3 = NULL); extern void addsleep(int msec, const char *cmd, bool persist = false); extern void resetsleep(bool force = false); extern int lastpm; //game mode extras extern void flagpickup(int fln); extern void tryflagdrop(bool manual = false); extern void flagreturn(int fln); extern void flagscore(int fln); extern void flagstolen(int flag, int act); extern void flagdropped(int flag, float x, float y, float z); extern void flaginbase(int flag); extern void flagidle(int flag); extern void flagmsg(int flag, int message, int actor, int flagtime); extern bool tryrespawn(); extern void gotoplayerstart(playerent *d, entity *e); extern void findplayerstart(playerent *d, bool mapcenter = false, int arenaspawn = -1); extern void refreshsopmenu(void *menu, bool init); extern char *colorname(playerent *d, char *name = NULL, const char *prefix = ""); extern char *colorping(int ping); extern char *colorpj(int pj); extern const char *highlight(const char *text); extern void togglespect(); extern playerent *updatefollowplayer(int shiftdirection = 0); extern void spectatemode(int mode); struct votedisplayinfo { playerent *owner; int type, stats[VOTE_NUM], result, millis; string desc; bool localplayervoted; votedisplayinfo() : owner(NULL), result(VOTE_NEUTRAL), millis(0), localplayervoted(false) { loopi(VOTE_NUM) stats[i] = VOTE_NEUTRAL; } }; extern votedisplayinfo *newvotedisplayinfo(playerent *owner, int type, const char *arg1, const char *arg2, const char *arg3 = ""); extern void callvotesuc(); extern void callvoteerr(int e); extern void displayvote(votedisplayinfo *v); extern void voteresult(int v); extern void votecount(int v); extern void clearvote(); // scoreboard struct discscore { int team, flags, frags, deaths, points; char name[MAXNAMELEN + 1]; }; extern vector discscores; extern void showscores(bool on); extern void renderscores(void *menu, bool init); extern const char *asciiscores(bool destjpg = false); extern void consolescores(); extern void calcteamscores(int scores[4]); // world extern void setupworld(int factor); extern void sqrdefault(sqr *s); extern bool worldbordercheck(int x1, int x2, int y1, int y2, int z1, int z2); extern bool empty_world(int factor, bool force); extern void remip(const block &b, int level = 0); extern void remipmore(const block &b, int level = 0); extern void remipgenerous(const block &b); extern bool pinnedclosestent; extern int closestent(); extern void deletesoundentity(entity &e); extern vector todoents; extern vector todoentdescs; extern void cleartodoentities(const char *n = NULL); extern void addtodoentity(int n, const char *desc); extern int findtype(const char *what); extern int findentity(int type, int index = 0); extern int findentity(int type, int index, uchar attr2); extern void newentity(int index, int x, int y, int z, const char *what, float v1, float v2, float v3, float v4); extern void mapmrproper(bool manual); extern void clearworldvisibility(); extern void calcworldvisibility(); extern vector deleted_ents; // worldlight extern int lastcalclight; extern void fullbrightlight(int level = -1); extern void calclight(); extern void adddynlight(physent *owner, const vec &o, int reach, int expire, int fade, uchar r, uchar g = 0, uchar b = 0); extern void dodynlights(); extern void undodynlights(); extern void cleardynlights(); extern void removedynlights(physent *owner); extern block *blockcopy(const block &b); extern void blocktexusage(const block &b, uchar *used); extern void blockpaste(const block &b, int bx, int by, bool light, uchar *texmap); extern void blockpaste(const block &b); extern void freeblockp(block *b); extern void freeblock(block *&b); // worldrender extern void render_world(float vx, float vy, float vh, float changelod, int yaw, int pitch, float fov, float fovy, int w, int h); extern int lod_factor(); // worldocull extern void disableraytable(); extern void computeraytable(float vx, float vy, float fov); extern int isoccluded(float vx, float vy, float cx, float cy, float csize); // main extern char *lang; extern SDL_Window *screen; extern int stencilbits; enum { KR_CONSOLE = 1<<0, KR_MENU = 1<<1, KR_EDITMODE = 1<<2 }; extern void keyrepeat(bool on, int mask = ~0); enum { TI_CONSOLE = 1<<0, TI_MENU = 1<<1 }; extern void textinput(bool on, int mask = ~0); extern bool interceptkey(int sym); extern bool inmainloop; enum { NOT_INITING = 0, INIT_LOAD, INIT_RESET }; enum { CHANGE_GFX = 1<<0, CHANGE_SOUND = 1<<1 }; extern bool initwarning(const char *desc, int level = INIT_RESET, int type = CHANGE_GFX); // rendertext struct font { struct charinfo { short w, h; float left, right, top, bottom; }; char *name; Texture *tex; vector chars; int defaultw, defaulth; int offsetx, offsety, offsetw, offseth; int skip; }; #define VIRTH 1800 #define FONTH (curfont->defaulth) #define PIXELTAB (10*curfont->defaultw) extern int VIRTW; // virtual screen size for text & HUD extern bool ignoreblinkingbit; extern font *curfont; extern bool setfont(const char *name); extern font *getfont(const char *name); extern void pushfont(const char *name); extern void popfont(); extern void draw_text(const char *str, int left, int top, int r = 255, int g = 255, int b = 255, int a = 255, int cursor = -1, int maxwidth = -1); extern void draw_textf(const char *fstr, int left, int top, ...) PRINTFARGS(1, 4); extern int text_width(const char *str); extern int text_visible(const char *str, int max); extern void text_bounds(const char *str, int &width, int &height, int maxwidth = -1); extern int text_visible(const char *str, int hitx, int hity, int maxwidth); extern void text_pos(const char *str, int cursor, int &cx, int &cy, int maxwidth); extern void text_startcolumns(); extern void text_endcolumns(); extern void cutcolorstring(char *text, int len); extern bool filterunrenderables(char *s); // editing #define EDITSEL(x) if(noteditmode(x) || noselection()) return #define EDITSELMP(x) if(noteditmode(x) || noselection() || multiplayer(x)) return #define EDITMP(x) if(noteditmode(x) || multiplayer(x)) return #define EDIT(x) if(noteditmode(x)) return extern void cursorupdate(); extern void toggleedit(bool force = false); extern void reseteditor(); extern char *editinfo(); extern void makeundo(block &sel); extern void editdrag(bool isdown); extern void checkselections(); extern void netblockpastexy(ucharbuf *p, int bx, int by, int bxs, int bys, int light); extern void setvdeltaxy(int delta, block &sel); extern void editequalisexy(bool isfloor, block &sel); extern void edittypexy(int type, block &sel); extern void edittexxy(int type, int t, block &sel); extern void editheightxy(bool isfloor, int amount, block &sel); extern void archxy(int sidedelta, int *averts, block &sel); extern void slopexy(int xd, int yd, block &sel); extern void stairsxy(int xd, int yd, block &sel); extern void edittagxy(int orv, int andv, block &sel); extern void selfliprotate(block &sel, int dir); extern bool noteditmode(const char* func = NULL); extern void storeposition(short p[]); extern void restoreposition(short p[]); extern void restoreeditundo(ucharbuf &q); extern int backupeditundo(vector &buf, int undolimit, int redolimit); // renderhud #define HUDPOS_X_BOTTOMLEFT 20 #define HUDPOS_Y_BOTTOMLEFT 1570 #define HUDPOS_ICONSPACING 235 #define HUDPOS_HEALTH (HUDPOS_X_BOTTOMLEFT / 2) #define HUDPOS_ARMOUR (HUDPOS_HEALTH + HUDPOS_ICONSPACING) #define HUDPOS_WEAPON (HUDPOS_ARMOUR + HUDPOS_ICONSPACING) #define HUDPOS_GRENADE (HUDPOS_WEAPON + HUDPOS_ICONSPACING) #define HUDPOS_NUMBERSPACING 70 enum { HUDMSG_INFO = 0, HUDMSG_TIMER, HUDMSG_MIPSTATS, HUDMSG_EDITFOCUS, HUDMSG_TYPE = 0xFF, HUDMSG_OVERWRITE = 1<<8 }; extern int dimeditinfopanel; extern void damageblend(int n, void *p); extern void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwater, int elapsed); extern void loadingscreen(const char *fmt = NULL, ...) PRINTFARGS(1, 2); extern void hudoutf(const char *s, ...) PRINTFARGS(1, 2); extern void hudonlyf(const char *s, ...) PRINTFARGS(1, 2); extern void hudeditf(int type, const char *s, ...) PRINTFARGS(2, 3); extern void show_out_of_renderloop_progress(float bar1, const char *text1, float bar2 = 0, const char *text2 = NULL); extern void updatedmgindicator(playerent *p, vec &attack); extern vec getradarpos(); // renderparticles enum { PT_PART = 0, PT_FIREBALL, PT_SHOTLINE, PT_DECAL, PT_BULLETHOLE, PT_BLOOD, PT_STAIN, PT_FLASH, PT_HUDFLASH }; #define PT_DECAL_MASK ((1< &f, sqr *s, int len, bool preservesolids); extern bool rldecodecubes(ucharbuf &f, sqr *s, int len, int version, bool silent); extern void clearheaderextras(); extern void automapconfig(); extern void flagmapconfigchange(); extern void flagmapconfigerror(int what); extern void getcurrentmapconfig(vector &f, bool onlysounds); extern char *mapinfo_license, *mapinfo_comment; extern void setmapinfo(const char *newlicense = NULL, const char *newcomment = NULL); extern void xmapbackup(const char *nickprefix, const char *nick); extern void writeallxmaps(); extern int loadallxmaps(); // physics extern float raycube(const vec &o, const vec &ray, vec &surface); extern bool raycubelos(const vec &from, const vec &to, float margin = 0); extern int cornertest(int x, int y, int &bx, int &by, int &bs, sqr *&s, sqr *&h); extern void moveplayer(physent *pl, int moveres, bool local); extern void moveplayer(physent *pl, int moveres, bool local, int curtime); extern void movebounceent(bounceent *p, int moveres, bool local); extern void entinmap(physent *d); extern void physicsframe(); extern void mousemove(int idx, int idy); extern void fixcamerarange(physent *cam = camera1); extern void updatecrouch(playerent *p, bool on); extern bool objcollide(physent *d, const vec &objpos, float objrad, float objheight); extern bool collide(physent *d, bool spawn = false, float drop = 0, float rise = 0); extern void attack(bool on); // rendermodel extern void rendermodel(const char *mdl, int anim, int tex, float rad, const vec &o, float roll, float yaw, float pitch, float speed = 0, int basetime = 0, playerent *d = NULL, modelattach *a = NULL, float scale = 1.0f); extern void startmodelbatches(); extern void endmodelbatches(bool flush = true); extern void clearmodelbatches(); extern mapmodelinfo *getmminfo(int i); extern int findanim(const char *name); extern void loadskin(const char *dir, const char *altdir, Texture *&skin); extern model *loadmodel(const char *name, int i = -1, bool trydl = false); extern void resetmdlnotfound(); extern void preload_playermodels(); extern void preload_entmodels(); extern void preload_hudguns(); extern bool preload_mapmodels(bool trydl = false); extern void renderclients(); extern void renderclientp(playerent *d); extern void renderclient(playerent *d, const char *mdlname, const char *vwepname, int tex = 0); extern void updateclientname(playerent *d); extern void updatemapmodeldependencies(); extern void writemapmodelattributes(); extern const char *mmshortname(const char *name); // weapon extern void shoot(playerent *d, vec &to); extern void createrays(const vec &from, const vec &to); extern void removebounceents(playerent *owner); extern void movebounceents(); extern void clearbounceents(); extern void renderbounceents(); extern void addgib(playerent *d); extern playerent *playerincrosshair(); extern int magsize(int gun); extern void setscope(bool activate); extern void setburst(bool activate); extern void intersectgeometry(const vec &from, vec &to); extern int intersect(playerent *d, const vec &from, const vec &to, vec *end = NULL); extern bool intersect(entity *e, const vec &from, const vec &to, vec *end = NULL); extern void damageeffect(int damage, playerent *d); extern void tryreload(playerent *p); extern void checkweaponstate(); extern int burstshotssettings[NUMGUNS]; // entities extern int edithideentmask; extern void pickupeffects(int n, playerent *d); extern void renderentities(); extern void rendermapmodels(); extern void resetpickups(int type = -1); extern void setpickupspawn(int i, bool on); extern void checkitems(playerent *d); extern vector changedents; extern void syncentchanges(bool force = false); extern void clampentityattributes(persistent_entity &e); extern const char *formatentityattributes(const persistent_entity &e, bool withcomma = false); // rndmap extern void perlinarea(block &b, int scale, int seed, int psize); // doc extern void renderdoc(int x, int y, int doch); extern void renderdocmenu(void *menu, bool init); extern void toggledoc(); extern void scrolldoc(int i); extern const char *docgetdesc(const char *name); #endif // protocol [client and server] extern const char *acronymmodestr(int n); extern const char *fullmodestr(int n); extern int defaultgamelimit(int gamemode); // crypto #define TIGERHASHSIZE 24 extern void tigerhash(uchar *hash, const uchar *msg, int len); extern void *tigerhash_init(uchar *hash); extern void tigerhash_add(uchar *hash, const void *msg, int len, void *state); extern void tigerhash_finish(uchar *hash, void *state); extern void loadcertdir(); // load all certs in "config/certs" #if 0 // crypto // for AUTH extern void genprivkey(const char *seed, vector &privstr, vector &pubstr); extern bool hashstring(const char *str, char *result, int maxlen); extern void answerchallenge(const char *privstr, const char *challenge, vector &answerstr); extern void *parsepubkey(const char *pubstr); extern void freepubkey(void *pubkey); extern void *genchallenge(void *pubkey, const void *seed, int seedlen, vector &challengestr); extern void freechallenge(void *answer); extern bool checkchallenge(const char *answerstr, void *correct); #endif // console extern void conoutf(const char *s, ...) PRINTFARGS(1, 2); // command extern bool persistidents; extern char *exchangestr(char *o, const char *n); extern int variable(const char *name, int min, int cur, int max, int *storage, void (*fun)(), bool persist); extern float fvariable(const char *name, float min, float cur, float max, float *storage, void (*fun)(), bool persist); extern char *svariable(const char *name, const char *cur, char **storage, void (*fun)(), void (*getfun)(), bool persist); extern void setvar(const char *name, int i, bool dofunc = false); extern void setfvar(const char *name, float f, bool dofunc = false); extern void setsvar(const char *name, const char *str, bool dofunc = false); extern bool identexists(const char *name); extern bool addcommand(const char *name, void (*fun)(), const char *sig); extern int execute(const char *p); enum { HOOK_MP = 1, HOOK_SP, HOOK_SP_MP, HOOK_FLAGMASK = 0xff, HOOK_TEAM = 0x100, HOOK_NOTEAM = 0x200, HOOK_BOTMODE = 0x400, HOOK_FLAGMODE = 0x800, HOOK_ARENA = 0x1000 }; extern bool exechook(int context, const char *ident, const char *body,...) PRINTFARGS(3, 4); // execute cubescript hook if available and allowed in current context/gamemode extern void identhash(uint64_t *d); extern char *executeret(const char *p); extern char *conc(const char **w, int n, bool space); extern void intret(int v); extern const char *floatstr(float v, bool neat = false); extern void floatret(float v, bool neat = false); extern void result(const char *s); extern void resultcharvector(const vector &res, int adj); extern void exec(const char *cfgfile); extern bool execfile(const char *cfgfile); extern int listlen(const char *s); extern void resetcomplete(); extern void complete(char *s, bool reversedirection); extern void push(const char *name, const char *action); extern void pop(const char *name); extern void alias(const char *name, const char *action, bool temp = false, bool constant = false); extern const char *getalias(const char *name); extern void writecfg(); extern void deletecfg(); extern void identnames(vector &names, bool builtinonly); extern void explodelist(const char *s, vector &elems); extern const char *escapestring(const char *s, bool force = true, bool noquotes = false); extern int execcontext; extern void pushscontext(int newcontext); extern int popscontext(); extern void scripterr(); extern void setcontext(const char *context, const char *info); extern void resetcontext(); extern void dumpexecutionstack(stream *f); extern const char *currentserver(int i); // server extern int modeacronyms; extern void servertoclient(int chan, uchar *buf, int len, bool demo = false); extern void localservertoclient(int chan, uchar *buf, int len, bool demo = false); extern const char *modestr(int n, bool acronyms = false); extern const char *voteerrorstr(int n); extern const char *mmfullname(int n); extern void fatal(const char *s, ...) PRINTFARGS(1, 2); extern void initserver(bool dedicated, int argc = 0, char **argv = NULL); extern void cleanupserver(); extern void localconnect(); extern void localdisconnect(); extern void localclienttoserver(int chan, ENetPacket *); extern void serverslice(uint timeout); extern void putint(ucharbuf &p, int n); extern void putint(packetbuf &p, int n); extern void putint(vector &p, int n); extern int getint(ucharbuf &p); extern void putaint(ucharbuf &p, int n); extern void putaint(packetbuf &p, int n); extern void putaint(vector &p, int n); extern int getaint(ucharbuf &p); extern void putuint(ucharbuf &p, int n); extern void putuint(packetbuf &p, int n); extern void putuint(vector &p, int n); extern int getuint(ucharbuf &p); extern void putfloat(ucharbuf &p, float f); extern void putfloat(packetbuf &p, float f); extern void putfloat(vector &p, float f); extern float getfloat(ucharbuf &p); extern void sendstring(const char *t, ucharbuf &p); extern void sendstring(const char *t, packetbuf &p); extern void sendstring(const char *t, vector &p); extern void getstring(char *t, ucharbuf &p, int len = MAXTRANS); extern void putgzbuf(vector &d, vector &s); // zips a vector into a stream, stored in another vector extern ucharbuf *getgzbuf(ucharbuf &p); // fetch a gzipped buffer; needs to be freed properly later extern void freegzbuf(ucharbuf *p); // free a ucharbuf created by getgzbuf() extern char *filtertext(char *dst, const char *src, int flags, int len = sizeof(string)-1); extern void filterrichtext(char *dst, const char *src, int len = sizeof(string)-1); extern void filterlang(char *d, const char *s); extern void trimtrailingwhitespace(char *s); extern string mastername; extern int masterport; extern ENetSocket connectmaster(); extern void serverms(int mode, int numplayers, int minremain, char *smapname, int millis, const ENetAddress &localaddr, int *mnum, int *msend, int *mrec, int *cnum, int *csend, int *crec, int protocol_version); extern int msgsizelookup(int msg); extern const char *genpwdhash(const char *name, const char *pwd, int salt); extern void servermsinit(const char *master, const char *ip, int serverport, bool listen); extern bool serverpickup(int i, int sender); extern bool valid_client(int cn); extern void extinfo_cnbuf(ucharbuf &p, int cn); extern void extinfo_statsbuf(ucharbuf &p, int pid, int bpos, ENetSocket &pongsock, ENetAddress &addr, ENetBuffer &buf, int len, int *csend); extern void extinfo_teamscorebuf(ucharbuf &p); extern char *votestring(int type, char *arg1, char *arg2, char *arg3); extern int wizardmain(int argc, char **argv); // some tools extern servsqr *createservworld(const sqr *s, int _cubicsize); extern int calcmapdims(mapdim_s &md, const servsqr *s, int _ssize); extern int calcmapareastats(mapareastats_s &ms, servsqr *s, int _ssize, const mapdim_s &md); extern void calcentitystats(entitystats_s &es, const persistent_entity *pents, int pentsize); // demo #define DHDR_DESCCHARS 80 #define DHDR_PLISTCHARS 322 struct demoheader { char magic[16]; int version, protocol; char desc[DHDR_DESCCHARS]; char plist[DHDR_PLISTCHARS]; }; #define DEFDEMOFILEFMT "%w_%h_%n_%Mmin_%G" #define DEFDEMOTIMEFMT "%Y%m%d_%H%M" extern bool watchingdemo; extern int demoprotocol; extern void enddemoplayback(); // logging enum { ACLOG_DEBUG = 0, ACLOG_VERBOSE, ACLOG_INFO, ACLOG_WARNING, ACLOG_ERROR, ACLOG_NUM }; extern bool initlogging(const char *identity, int facility_, int consolethres, int filethres, int syslogthres, bool logtimestamp); extern void exitlogging(); extern bool logline(int level, const char *msg, ...) PRINTFARGS(2, 3); // server config struct serverconfigfile { string filename; int filelen; char *buf; serverconfigfile() : filelen(0), buf(NULL) { filename[0] = '\0'; } virtual ~serverconfigfile() { DELETEA(buf); } virtual void read() {} void init(const char *name); bool load(); }; // server commandline parsing struct servercommandline { int uprate, serverport, syslogfacility, filethres, syslogthres, maxdemos, maxclients, kickthreshold, banthreshold, verbose, incoming_limit, afk_limit, ban_time, demotimelocal; const char *ip, *master, *logident, *serverpassword, *adminpasswd, *demopath, *maprot, *pwdfile, *blfile, *nbfile, *infopath, *motdpath, *forbidden, *demofilenameformat, *demotimestampformat; bool logtimestamp, demo_interm, loggamestatus; string motd, servdesc_full, servdesc_pre, servdesc_suf, voteperm, mapperm; int clfilenesting; vector adminonlymaps; servercommandline() : uprate(0), serverport(CUBE_DEFAULT_SERVER_PORT), syslogfacility(6), filethres(-1), syslogthres(-1), maxdemos(5), maxclients(DEFAULTCLIENTS), kickthreshold(-5), banthreshold(-6), verbose(0), incoming_limit(10), afk_limit(45000), ban_time(20*60*1000), demotimelocal(0), ip(""), master(NULL), logident(""), serverpassword(""), adminpasswd(""), demopath(""), maprot("config/maprot.cfg"), pwdfile("config/serverpwd.cfg"), blfile("config/serverblacklist.cfg"), nbfile("config/nicknameblacklist.cfg"), infopath("config/serverinfo"), motdpath("config/motd"), forbidden("config/forbidden.cfg"), logtimestamp(false), demo_interm(false), loggamestatus(true), clfilenesting(0) { motd[0] = servdesc_full[0] = servdesc_pre[0] = servdesc_suf[0] = voteperm[0] = mapperm[0] = '\0'; demofilenameformat = DEFDEMOFILEFMT; demotimestampformat = DEFDEMOTIMEFMT; } bool checkarg(const char *arg) { if(!strncmp(arg, "assaultcube://", 13)) return false; else if(arg[0] != '-' || arg[1] == '\0') return false; const char *a = arg + 2 + strspn(arg + 2, " "); int ai = atoi(a); // client: dtwhzbsave switch(arg[1]) { // todo: gjlqEGHJQUYZ case '-': if(!strncmp(arg, "--demofilenameformat=", 21)) { demofilenameformat = arg+21; } else if(!strncmp(arg, "--demotimestampformat=", 22)) { demotimestampformat = arg+22; } else if(!strncmp(arg, "--demotimelocal=", 16)) { int ai = atoi(arg+16); demotimelocal = ai == 0 ? 0 : 1; } else if(!strncmp(arg, "--masterport=", 13)) { int ai = atoi(arg+13); masterport = ai == 0 ? AC_MASTER_PORT : ai; } else return false; break; case 'u': uprate = ai; break; case 'f': if(ai > 0 && ai < 65536) serverport = ai; break; case 'i': ip = a; break; case 'm': master = a; break; case 'N': logident = a; break; case 'l': loggamestatus = ai != 0; break; case 'F': if(isdigit(*a) && ai >= 0 && ai <= 7) syslogfacility = ai; break; case 'T': logtimestamp = true; break; case 'L': switch(*a) { case 'F': filethres = atoi(a + 1); break; case 'S': syslogthres = atoi(a + 1); break; } break; case 'A': if(*a) adminonlymaps.add(a); break; case 'c': if(ai > 0) maxclients = min(ai, MAXCLIENTS); break; case 'k': { if(arg[2]=='A' && arg[3]!='\0') { if ((ai = atoi(&arg[3])) >= 30) afk_limit = ai * 1000; else afk_limit = 0; } else if(arg[2]=='B' && arg[3]!='\0') { if ((ai = atoi(&arg[3])) >= 0) ban_time = ai * 60 * 1000; else ban_time = 0; } else if(ai < 0) kickthreshold = ai; break; } case 'y': if(ai < 0) banthreshold = ai; break; case 'x': adminpasswd = a; break; case 'p': serverpassword = a; break; case 'D': { if(arg[2]=='I') { demo_interm = true; } else if(ai > 0) maxdemos = ai; break; } case 'W': demopath = a; break; case 'r': maprot = a; break; case 'X': pwdfile = a; break; case 'B': blfile = a; break; case 'K': nbfile = a; break; case 'I': infopath = a; break; case 'o': filterrichtext(motd, a); break; case 'O': motdpath = a; break; case 'g': forbidden = a; break; case 'n': { char *t = servdesc_full; switch(*a) { case '1': t = servdesc_pre; a += 1 + strspn(a + 1, " "); break; case '2': t = servdesc_suf; a += 1 + strspn(a + 1, " "); break; } filterrichtext(t, a); filtertext(t, t, FTXT__SERVDESC); break; } case 'P': concatstring(voteperm, a); break; case 'M': concatstring(mapperm, a); break; case 'Z': if(ai >= 0) incoming_limit = ai; break; case 'V': verbose++; break; case 'C': if(*a && clfilenesting < 3) { serverconfigfile cfg; cfg.init(a); cfg.load(); int line = 1; clfilenesting++; if(cfg.buf) { printf("reading commandline parameters from file '%s'\n", a); for(char *p = cfg.buf, *l; p < cfg.buf + cfg.filelen; line++) { l = p; p += strlen(p) + 1; for(char *c = p - 2; c > l; c--) { if(*c == ' ') *c = '\0'; else break; } l += strspn(l, " \t"); if(*l && !this->checkarg(newstring(l))) printf("unknown parameter in file '%s', line %d: '%s'\n", cfg.filename, line, l); } } else printf("failed to read file '%s'\n", a); clfilenesting--; break; } default: return false; } return true; } }; assaultcube-1.2.0.2.1/source/src/rendercubes.cpp000066400000000000000000000411061352165075300214310ustar00rootroot00000000000000// rendercubes.cpp: sits in between worldrender.cpp and rendergl.cpp and fills the vertex array for different cube surfaces. #include "cube.h" vector verts; void finishstrips(); void setupstrips() { finishstrips(); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); vertex *buf = verts.getbuf(); glVertexPointer(3, GL_FLOAT, sizeof(vertex), &buf->x); glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(vertex), &buf->r); glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), &buf->u); } struct strips { vector first; vector count; }; struct stripbatch { int tex; strips tris, tristrips, quads; }; stripbatch skystrips = { DEFAULT_SKY }; stripbatch stripbatches[256]; uchar renderedtex[256]; int renderedtexs = 0; extern int ati_mda_bug; #define RENDERSTRIPS(strips, type) \ if(strips.first.length()) \ { \ if(hasMDA && !ati_mda_bug) glMultiDrawArrays_(type, strips.first.getbuf(), strips.count.getbuf(), strips.first.length()); \ else loopv(strips.first) glDrawArrays(type, strips.first[i], strips.count[i]); \ strips.first.setsize(0); \ strips.count.setsize(0); \ } void renderstripssky() { if(skystrips.tris.first.empty() && skystrips.tristrips.first.empty() && skystrips.quads.first.empty()) return; glDisable(GL_TEXTURE_2D); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); RENDERSTRIPS(skystrips.tris, GL_TRIANGLES); RENDERSTRIPS(skystrips.tristrips, GL_TRIANGLE_STRIP); RENDERSTRIPS(skystrips.quads, GL_QUADS); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glEnable(GL_TEXTURE_2D); } void renderstrips() { loopj(renderedtexs) { stripbatch &sb = stripbatches[j]; glBindTexture(GL_TEXTURE_2D, lookupworldtexture(sb.tex)->id); RENDERSTRIPS(sb.tris, GL_TRIANGLES); RENDERSTRIPS(sb.tristrips, GL_TRIANGLE_STRIP); RENDERSTRIPS(sb.quads, GL_QUADS); } renderedtexs = 0; glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); } void addstrip(int type, int tex, int start, int n) { stripbatch *sb = NULL; if(tex==DEFAULT_SKY) { if(minimap) return; sb = &skystrips; loopi(n) skyfloor = min(skyfloor, verts[start + i].z); } else { sb = &stripbatches[renderedtex[tex]]; if(sb->tex!=tex || sb>=&stripbatches[renderedtexs]) { sb = &stripbatches[renderedtex[tex] = renderedtexs++]; sb->tex = tex; } } strips &s = (type==GL_QUADS ? sb->quads : (type==GL_TRIANGLES ? sb->tris : sb->tristrips)); if(type!=GL_TRIANGLE_STRIP && s.first.length() && s.first.last()+s.count.last() == start) { s.count.last() += n; return; } s.first.add(start); s.count.add(n); } // generating the actual vertices is done dynamically every frame and sits at the // leaves of all these functions, and are part of the cpu bottleneck on really slow // machines, hence the macros. #define vert(v1, v2, v3, ls, t1, t2) \ { \ vertex &v = verts.add(); \ v.u = t1; v.v = t2; \ v.x = (float)(v1); v.y = (float)(v2); v.z = (float)(v3); \ v.r = ls->r; v.g = ls->g; v.b = ls->b; v.a = 255; \ } enum { STRIP_FLOOR = 1, STRIP_DELTA, STRIP_WALL }; int nquads; // for testing purpose. UNDOME on release. const float texturescale = 32.0f; //VARP(texturescale, 16, 32, 64); #define TEXTURESCALE (float(texturescale) * ((uniformtexres && t->scale>1.0f) ? 1.0f : t->scale)) int striptype = 0, striptex, oh, oy, ox, odir; // the o* vars are used by the stripification int ol1r, ol1g, ol1b, ol2r, ol2g, ol2b; float ofloor, oceil; bool ohf; int firstindex; bool showm = false, showef = false; COMMANDF(showmip, "",() { showm = !showm; }); COMMANDF(showfocuscubedetails, "",() { showef = !showef; }); const char *cubetypenames[] = {"SOLID", "CORNER", "FHF", "CHF", "SPACE", ""}; const char *cubetypename(int t) { return t >= 0 && t < SEMISOLID ? cubetypenames[t] : "unknown"; } void mipstats(const int a[]) { if(showm && !showef) hudeditf(HUDMSG_MIPSTATS, "1x1/2x2/4x4/8x8: %d / %d / %d / %d", a[0], a[1], a[2], a[3]); } bool editfocusdetails(sqr *s) { if(showef) { const char *g = SOLID(s) ? "\f4" : ""; hudeditf(HUDMSG_EDITFOCUS, "%s: \fs%s%d..%d\fr W:%d \fs%sU:%d F:%d C:%d v:%d t:0x%X (%02X%02X%02X)\fr", cubetypename(s->type), g, s->floor, s->ceil, s->wtex, g, s->utex, s->ftex, s->ctex, s->vdelta, s->tag, s->r, s->g, s->b); return true; } return false; } VAR(mergestrips, 0, 1, 1); #define stripend(verts) \ if(striptype) \ { \ int type = GL_TRIANGLE_STRIP, len = verts.length()-firstindex; \ if(mergestrips) switch(len) \ { \ case 3: type = GL_TRIANGLES; break; \ case 4: type = GL_QUADS; swap(verts.last(), verts[verts.length()-2]); break; \ } \ addstrip(type, striptex, firstindex, len); \ striptype = 0; \ } void finishstrips() { stripend(verts); } sqr sbright, sdark; VARP(lighterror, 1, 4, 100); void render_flat(int wtex, int x, int y, int size, int h, sqr *l1, sqr *l4, sqr *l3, sqr *l2, bool isceil) // floor/ceil quads { if(showm) { l3 = l1 = &sbright; l4 = l2 = &sdark; } Texture *t = lookupworldtexture(wtex); float xf = TEXTURESCALE/t->xs; float yf = TEXTURESCALE/t->ys; float xs = size*xf; float ys = size*yf; float xo = xf*x; float yo = yf*y; bool first = striptype!=STRIP_FLOOR || x!=ox+size || striptex!=wtex || h!=oh || y!=oy; if(first) // start strip here { stripend(verts); firstindex = verts.length(); striptex = wtex; oh = h; oy = y; striptype = STRIP_FLOOR; if(isceil) { vert(x, y, h, l1, xo, yo); vert(x, y+size, h, l2, xo, yo+ys); } else { vert(x, y+size, h, l2, xo, yo+ys); vert(x, y, h, l1, xo, yo); } ol1r = l1->r; ol1g = l1->g; ol1b = l1->b; ol2r = l2->r; ol2g = l2->g; ol2b = l2->b; } else // continue strip { int lighterr = lighterror*2; if((iabs(ol1r-l3->r)r)g)g)b)b)xs; float yf = TEXTURESCALE/t->ys; float xs = size*xf; float ys = size*yf; float xo = xf*x; float yo = yf*y; bool first = striptype!=STRIP_DELTA || x!=ox+size || striptex!=wtex || y!=oy; if(first) { stripend(verts); firstindex = verts.length(); striptex = wtex; oy = y; striptype = STRIP_DELTA; if(isceil) { vert(x, y, h1, l1, xo, yo); vert(x, y+size, h2, l2, xo, yo+ys); } else { vert(x, y+size, h2, l2, xo, yo+ys); vert(x, y, h1, l1, xo, yo); } } if(isceil) { vert(x+size, y, h4, l4, xo+xs, yo); vert(x+size, y+size, h3, l3, xo+xs, yo+ys); } else { vert(x+size, y+size, h3, l3, xo+xs, yo+ys); vert(x+size, y, h4, l4, xo+xs, yo); } ox = x; nquads++; } void render_2tris(sqr *h, sqr *s, int x1, int y1, int x2, int y2, int x3, int y3, sqr *l1, sqr *l2, sqr *l3) // floor/ceil tris on a corner cube { stripend(verts); Texture *t = lookupworldtexture(h->ftex); float xf = TEXTURESCALE/t->xs; float yf = TEXTURESCALE/t->ys; vert(x1, y1, h->floor, l1, xf*x1, yf*y1); vert(x2, y2, h->floor, l2, xf*x2, yf*y2); vert(x3, y3, h->floor, l3, xf*x3, yf*y3); addstrip(mergestrips ? GL_TRIANGLES : GL_TRIANGLE_STRIP, h->ftex, verts.length()-3, 3); t = lookupworldtexture(h->ctex); xf = TEXTURESCALE/t->xs; yf = TEXTURESCALE/t->ys; vert(x3, y3, h->ceil, l3, xf*x3, yf*y3); vert(x2, y2, h->ceil, l2, xf*x2, yf*y2); vert(x1, y1, h->ceil, l1, xf*x1, yf*y1); addstrip(mergestrips ? GL_TRIANGLES : GL_TRIANGLE_STRIP, h->ctex, verts.length()-3, 3); nquads++; } void render_tris(int x, int y, int size, bool topleft, sqr *h1, sqr *h2, sqr *s, sqr *t, sqr *u, sqr *v) { if(topleft) { if(h1) render_2tris(h1, s, x+size, y+size, x, y+size, x, y, u, v, s); if(h2) render_2tris(h2, s, x, y, x+size, y, x+size, y+size, s, t, v); } else { if(h1) render_2tris(h1, s, x, y, x+size, y, x, y+size, s, t, u); if(h2) render_2tris(h2, s, x+size, y, x+size, y+size, x, y+size, t, u, v); } } void render_square(int wtex, float floor1, float floor2, float ceil1, float ceil2, int x1, int y1, int x2, int y2, int size, sqr *l1, sqr *l2, bool flip, int dir) // wall quads { if(showm) { l1 = &sbright; l2 = &sdark; } Texture *t = lookupworldtexture(wtex); float xf = TEXTURESCALE/t->xs; float yf = -TEXTURESCALE/t->ys; float xs = size*xf; float xo = xf*(x1==x2 ? min(y1,y2) : min(x1,x2)); bool first = striptype!=STRIP_WALL || striptex!=wtex || ox!=x1 || oy!=y1 || ofloor!=floor1 || oceil!=ceil1 || odir!=dir, hf = floor1!=floor2 || ceil1!=ceil2; if(first) { stripend(verts); firstindex = verts.length(); striptex = wtex; striptype = STRIP_WALL; if(!flip) { vert(x1, y1, ceil1, l1, xo, yf*ceil1); vert(x1, y1, floor1, l1, xo, yf*floor1); } else { vert(x1, y1, floor1, l1, xo, yf*floor1); vert(x1, y1, ceil1, l1, xo, yf*ceil1); } ol1r = l1->r; ol1g = l1->g; ol1b = l1->b; } else // continue strip { int lighterr = lighterror*2; if((!hf && !ohf) && ((iabs(ol1r-l2->r)g)b) shadowverts; static void resetshadowverts() { shadowverts.setsize(0); striptype = 0; } static void rendershadowstrips() { glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); shadowvertex *buf = shadowverts.getbuf(); glVertexPointer(3, GL_FLOAT, sizeof(shadowvertex), &buf->x); glTexCoordPointer(2, GL_FLOAT, sizeof(shadowvertex), &buf->u); loopj(renderedtexs) { stripbatch &sb = stripbatches[j]; RENDERSTRIPS(sb.tris, GL_TRIANGLES); RENDERSTRIPS(sb.tristrips, GL_TRIANGLE_STRIP); RENDERSTRIPS(sb.quads, GL_QUADS); } renderedtexs = 0; glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); xtraverts += shadowverts.length(); } #define shadowvert(v1, v2, v3) \ { \ shadowvertex &v = shadowverts.add(); \ v.x = (float)(v1); v.y = (float)(v2); v.z = (float)(v3); \ } void rendershadow_tri(sqr *h, int x1, int y1, int x2, int y2, int x3, int y3) // floor tris on a corner cube { stripend(shadowverts); shadowvert(x1, y1, h->floor); shadowvert(x2, y2, h->floor); shadowvert(x3, y3, h->floor); addstrip(mergestrips ? GL_TRIANGLES : GL_TRIANGLE_STRIP, DEFAULT_FLOOR, shadowverts.length()-3, 3); } void rendershadow_tris(int x, int y, bool topleft, sqr *h1, sqr *h2) { if(topleft) { if(h1) rendershadow_tri(h1, x+1, y+1, x, y+1, x, y); if(h2) rendershadow_tri(h2, x, y, x+1, y, x+1, y+1); } else { if(h1) rendershadow_tri(h1, x, y, x+1, y, x, y+1); if(h2) rendershadow_tri(h2, x+1, y, x+1, y+1, x, y+1); } } static void rendershadow_flat(int x, int y, int h) // floor quads { bool first = striptype!=STRIP_FLOOR || x!=ox+1 || h!=oh || y!=oy; if(first) // start strip here { stripend(shadowverts); firstindex = shadowverts.length(); striptex = DEFAULT_FLOOR; oh = h; oy = y; striptype = STRIP_FLOOR; shadowvert(x, y+1, h); shadowvert(x, y, h); } else // continue strip { shadowverts.setsize(shadowverts.length()-2); } shadowvert(x+1, y+1, h); shadowvert(x+1, y, h); ox = x; } static void rendershadow_flatdelta(int x, int y, float h1, float h4, float h3, float h2) // floor quads on a slope { bool first = striptype!=STRIP_DELTA || x!=ox+1 || y!=oy; if(first) { stripend(shadowverts); firstindex = shadowverts.length(); striptex = DEFAULT_FLOOR; oy = y; striptype = STRIP_DELTA; shadowvert(x, y+1, h2); shadowvert(x, y, h1); } shadowvert(x+1, y+1, h3); shadowvert(x+1, y, h4); ox = x; } void rendershadow(int x, int y, int xs, int ys, const vec &texgenS, const vec &texgenT) { x = max(x, 1); y = max(y, 1); xs = min(xs, ssize-1); ys = min(ys, ssize-1); resetshadowverts(); #define df(x) s->floor-(x->vdelta/4.0f) sqr *w = wmip[0]; for(int yy = y; yytype==SPACE || s->type==CHF) { rendershadow_flat(xx, yy, s->floor); } else if(s->type==FHF) { sqr *t = SW(s,1,0), *u = SW(s,1,1), *v = SW(s,0,1); rendershadow_flatdelta(xx, yy, df(s), df(t), df(u), df(v)); } else if(s->type==CORNER) { sqr *t = SW(s,1,0), *v = SW(s,0,1), *w = SW(s,0,-1), *z = SW(s,-1,0); bool topleft = true; sqr *h1 = NULL, *h2 = NULL; if(SOLID(z)) { if(SOLID(w)) { h2 = s; topleft = false; } else if(SOLID(v)) { h2 = s; } } else if(SOLID(t)) { if(SOLID(w)) { h1 = s; } else if(SOLID(v)) { h1 = s; topleft = false; } } else { bool wv = w->ceil-w->floor < v->ceil-v->floor; if(z->ceil-z->floor < t->ceil-t->floor) { if(wv) { h1 = s; h2 = v; topleft = false; } else { h1 = s; h2 = w; } } else { if(wv) { h2 = s; h1 = v; } else { h2 = s; h1 = w; topleft = false; } } } rendershadow_tris(xx, yy, topleft, h1, h2); } } stripend(shadowverts); for(shadowvertex *v = shadowverts.getbuf(), *end = &v[shadowverts.length()]; v < end; v++) { float vx = v->x, vy = v->y; v->u = vx*texgenS.x + vy*texgenS.y + texgenS.z; v->v = vx*texgenT.x + vy*texgenT.y + texgenT.z; } rendershadowstrips(); } assaultcube-1.2.0.2.1/source/src/rendergl.cpp000066400000000000000000001036611352165075300207370ustar00rootroot00000000000000// rendergl.cpp: core opengl rendering stuff #include "cube.h" #include "bot/bot.h" bool hasTE = false, hasMT = false, hasMDA = false, hasDRE = false, hasstencil = false, hasST2 = false, hasSTW = false, hasSTS = false, hasAF; // GL_ARB_multitexture PFNGLACTIVETEXTUREARBPROC glActiveTexture_ = NULL; PFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTexture_ = NULL; PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2f_ = NULL; PFNGLMULTITEXCOORD3FARBPROC glMultiTexCoord3f_ = NULL; // GL_EXT_multi_draw_arrays PFNGLMULTIDRAWARRAYSEXTPROC glMultiDrawArrays_ = NULL; PFNGLMULTIDRAWELEMENTSEXTPROC glMultiDrawElements_ = NULL; // GL_EXT_draw_range_elements PFNGLDRAWRANGEELEMENTSEXTPROC glDrawRangeElements_ = NULL; // GL_EXT_stencil_two_side PFNGLACTIVESTENCILFACEEXTPROC glActiveStencilFace_ = NULL; // GL_ATI_separate_stencil PFNGLSTENCILOPSEPARATEATIPROC glStencilOpSeparate_ = NULL; PFNGLSTENCILFUNCSEPARATEATIPROC glStencilFuncSeparate_ = NULL; void *getprocaddress(const char *name) { return SDL_GL_GetProcAddress(name); } bool hasext(const char *exts, const char *ext) { int len = strlen(ext); if(len) for(const char *cur = exts; (cur = strstr(cur, ext)); cur += len) { if((cur == exts || cur[-1] == ' ') && (cur[len] == ' ' || !cur[len])) return true; } return false; } void glext(char *ext) { const char *exts = (const char *)glGetString(GL_EXTENSIONS); intret(hasext(exts, ext) ? 1 : 0); } COMMAND(glext, "s"); VAR(ati_mda_bug, 0, 0, 1); void gl_checkextensions() { const char *vendor = (const char *)glGetString(GL_VENDOR); const char *exts = (const char *)glGetString(GL_EXTENSIONS); const char *renderer = (const char *)glGetString(GL_RENDERER); const char *version = (const char *)glGetString(GL_VERSION); conoutf("Renderer: %s (%s)", renderer, vendor); conoutf("Driver: %s", version); if(hasext(exts, "GL_EXT_texture_env_combine") || hasext(exts, "GL_ARB_texture_env_combine")) hasTE = true; else conoutf("WARNING: cannot use overbright lighting, using old lighting model!"); if(hasext(exts, "GL_ARB_multitexture")) { glActiveTexture_ = (PFNGLACTIVETEXTUREARBPROC) getprocaddress("glActiveTextureARB"); glClientActiveTexture_ = (PFNGLCLIENTACTIVETEXTUREARBPROC)getprocaddress("glClientActiveTextureARB"); glMultiTexCoord2f_ = (PFNGLMULTITEXCOORD2FARBPROC) getprocaddress("glMultiTexCoord2fARB"); glMultiTexCoord3f_ = (PFNGLMULTITEXCOORD3FARBPROC) getprocaddress("glMultiTexCoord3fARB"); hasMT = true; } if(hasext(exts, "GL_EXT_multi_draw_arrays")) { glMultiDrawArrays_ = (PFNGLMULTIDRAWARRAYSEXTPROC) getprocaddress("glMultiDrawArraysEXT"); glMultiDrawElements_ = (PFNGLMULTIDRAWELEMENTSEXTPROC)getprocaddress("glMultiDrawElementsEXT"); hasMDA = true; if(strstr(vendor, "ATI")) ati_mda_bug = 1; } if(hasext(exts, "GL_EXT_draw_range_elements")) { glDrawRangeElements_ = (PFNGLDRAWRANGEELEMENTSEXTPROC)getprocaddress("glDrawRangeElementsEXT"); hasDRE = true; } if(hasext(exts, "GL_EXT_stencil_two_side")) { glActiveStencilFace_ = (PFNGLACTIVESTENCILFACEEXTPROC)getprocaddress("glActiveStencilFaceEXT"); hasST2 = true; } if(hasext(exts, "GL_ATI_separate_stencil")) { glStencilOpSeparate_ = (PFNGLSTENCILOPSEPARATEATIPROC) getprocaddress("glStencilOpSeparateATI"); glStencilFuncSeparate_ = (PFNGLSTENCILFUNCSEPARATEATIPROC)getprocaddress("glStencilFuncSeparateATI"); hasSTS = true; } if(hasext(exts, "GL_EXT_stencil_wrap")) hasSTW = true; if(hasext(exts, "GL_EXT_texture_filter_anisotropic")) { GLint val; glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &val); hwmaxaniso = val; hasAF = true; } if(!hasext(exts, "GL_ARB_fragment_program")) { // not a required extension, but ensures the card has enough power to do reflections extern int waterreflect, waterrefract; waterreflect = waterrefract = 0; } #ifdef WIN32 if(strstr(vendor, "S3 Graphics")) { // official UniChrome drivers can't handle glDrawElements inside a display list without bugs extern int mdldlist; mdldlist = 0; } #endif } void gl_init(int w, int h, int depth, int fsaa) { //#define fogvalues 0.5f, 0.6f, 0.7f, 1.0f glViewport(0, 0, w, h); glClearDepth(1.0); glDepthFunc(GL_LESS); glEnable(GL_DEPTH_TEST); glShadeModel(GL_SMOOTH); glEnable(GL_FOG); glFogi(GL_FOG_MODE, GL_LINEAR); glFogf(GL_FOG_DENSITY, 0.25); glHint(GL_FOG_HINT, GL_NICEST); glEnable(GL_LINE_SMOOTH); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glCullFace(GL_FRONT); glEnable(GL_CULL_FACE); inittmus(); resetcamera(); } FVAR(polygonoffsetfactor, -1e4f, -3.0f, 1e4f); FVAR(polygonoffsetunits, -1e4f, -3.0f, 1e4f); FVAR(depthoffset, -1e4f, 0.005f, 1e4f); void enablepolygonoffset(GLenum type) { if(!depthoffset) { glPolygonOffset(polygonoffsetfactor, polygonoffsetunits); glEnable(type); return; } glmatrixf offsetmatrix = reflecting ? clipmatrix : projmatrix; offsetmatrix[14] += depthoffset * projmatrix[10]; glMatrixMode(GL_PROJECTION); glLoadMatrixf(offsetmatrix.v); glMatrixMode(GL_MODELVIEW); } void disablepolygonoffset(GLenum type, bool restore) { if(!depthoffset) { glDisable(type); return; } if(restore) { glMatrixMode(GL_PROJECTION); glLoadMatrixf(reflecting ? clipmatrix.v : projmatrix.v); glMatrixMode(GL_MODELVIEW); } } #define VARRAY_INTERNAL #include "varray.h" void line(int x1, int y1, float z1, int x2, int y2, float z2) { glBegin(GL_TRIANGLE_STRIP); glVertex3f((float)x1, (float)y1, z1); glVertex3f((float)x1, y1+0.01f, z1); glVertex3f((float)x2, (float)y2, z2); glVertex3f((float)x2, y2+0.01f, z2); glEnd(); xtraverts += 4; } void line(int x1, int y1, int x2, int y2, color *c) { glDisable(GL_BLEND); if(c) glColor4f(c->r, c->g, c->b, c->alpha); glBegin(GL_LINES); glVertex2f((float)x1, (float)y1); glVertex2f((float)x2, (float)y2); glEnd(); glEnable(GL_BLEND); } void linestyle(float width, int r, int g, int b) { glLineWidth(width); glColor3ub(r,g,b); } VARP(oldselstyle, 0, 1, 1); // Make the old (1004) grid/selection style default (render as quads rather than tris) void box(block &b, float z1, float z2, float z3, float z4) { glBegin((oldselstyle ? GL_QUADS : GL_TRIANGLE_STRIP)); glVertex3f((float)b.x, (float)b.y, z1); glVertex3f((float)b.x+b.xs, (float)b.y, z2); glVertex3f((float)(oldselstyle ? b.x+b.xs : b.x), (float)b.y+b.ys, (oldselstyle ? z3 : z4)); glVertex3f((float)(oldselstyle ? b.x : b.x+b.xs), (float)b.y+b.ys, (oldselstyle ? z4 : z3)); glEnd(); xtraverts += 4; } void box2d(int x1, int y1, int x2, int y2, int gray) { glColor3ub(gray, gray, gray); glBegin(GL_LINE_LOOP); glVertex2f(x1, y1); glVertex2f(x2, y1); glVertex2f(x2, y2); glVertex2f(x1, y2); glEnd(); } void quad(GLuint tex, float x, float y, float s, float tx, float ty, float tsx, float tsy) { if(!tsy) tsy = tsx; glBindTexture(GL_TEXTURE_2D, tex); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(tx, ty); glVertex2f(x, y); glTexCoord2f(tx+tsx, ty); glVertex2f(x+s, y); glTexCoord2f(tx, ty+tsy); glVertex2f(x, y+s); glTexCoord2f(tx+tsx, ty+tsy); glVertex2f(x+s, y+s); glEnd(); xtraverts += 4; } void quad(GLuint tex, const vec &c1, const vec &c2, float tx, float ty, float tsx, float tsy) { if(!tsy) tsy = tsx; glBindTexture(GL_TEXTURE_2D, tex); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(tx, ty); glVertex3f(c1.x, c1.y, c1.z); glTexCoord2f(tx+tsx, ty); glVertex3f(c2.x, c1.y, c1.z); glTexCoord2f(tx, ty+tsy); glVertex3f(c1.x, c2.y, c2.z); glTexCoord2f(tx+tsx, ty+tsy); glVertex3f(c2.x, c2.y, c2.z); glEnd(); xtraverts += 4; } void circle(GLuint tex, float x, float y, float r, float tx, float ty, float tr, int subdiv) { glBindTexture(GL_TEXTURE_2D, tex); glBegin(GL_TRIANGLE_FAN); glTexCoord2f(tx, ty); glVertex2f(x, y); loopi(subdiv+1) { float c = cosf(PI2 * i / float(subdiv)), s = sinf(PI2 * i / float(subdiv)); glTexCoord2f(tx + tr*c, ty + tr*s); glVertex2f(x + r*c, y + r*s); } glEnd(); xtraverts += subdiv+2; } void dot(int x, int y, float z) { const float DOF = 0.1f; glBegin(GL_TRIANGLE_STRIP); glVertex3f(x-DOF, y-DOF, z); glVertex3f(x+DOF, y-DOF, z); glVertex3f(x-DOF, y+DOF, z); glVertex3f(x+DOF, y+DOF, z); glEnd(); xtraverts += 4; } void blendbox(int x1, int y1, int x2, int y2, bool border, int tex, color *c) { glDepthMask(GL_FALSE); if(tex>=0) { glBindTexture(GL_TEXTURE_2D, tex); if(c) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(c->r, c->g, c->b, c->alpha); } else { glDisable(GL_BLEND); glColor3f(1, 1, 1); } int texw = 512; int texh = texw; int cols = (int)((x2-x1)/texw+1); int rows = (int)((y2-y1)/texh+1); xtraverts += cols*rows*4; loopj(rows) { float ytexcut = 0.0f; float yboxcut = 0.0f; if((j+1)*texh>y2-y1) // cut last row to match the box height { yboxcut = (float)(((j+1)*texh)-(y2-y1)); ytexcut = (float)(((j+1)*texh)-(y2-y1))/texh; } loopi(cols) { float xtexcut = 0.0f; float xboxcut = 0.0f; if((i+1)*texw>x2-x1) { xboxcut = (float)(((i+1)*texw)-(x2-x1)); xtexcut = (float)(((i+1)*texw)-(x2-x1))/texw; } glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0, 0); glVertex2f((float)x1+texw*i, (float)y1+texh*j); glTexCoord2f(1-xtexcut, 0); glVertex2f(x1+texw*(i+1)-xboxcut, (float)y1+texh*j); glTexCoord2f(0, 1-ytexcut); glVertex2f((float)x1+texw*i, y1+texh*(j+1)-yboxcut); glTexCoord2f(1-xtexcut, 1-ytexcut); glVertex2f(x1+texw*(i+1)-xboxcut, (float)y1+texh*(j+1)-yboxcut); glEnd(); } } if(!c) glEnable(GL_BLEND); } else { glDisable(GL_TEXTURE_2D); if(c) { glBlendFunc(GL_SRC_ALPHA, GL_ONE); glColor4f(c->r, c->g, c->b, c->alpha); } else { glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR); glColor3f(0.5f, 0.5f, 0.5f); } glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0, 0); glVertex2f(x1, y1); glTexCoord2f(1, 0); glVertex2f(x2, y1); glTexCoord2f(0, 1); glVertex2f(x1, y2); glTexCoord2f(1, 1); glVertex2f(x2, y2); glEnd(); xtraverts += 4; } if(border) { glDisable(GL_BLEND); if(tex>=0) glDisable(GL_TEXTURE_2D); box2d(x1, y1, x2, y2, 155); glEnable(GL_BLEND); } if(tex<0 || border) glEnable(GL_TEXTURE_2D); glDepthMask(GL_TRUE); } void framedquadtexture(GLuint tex, int x, int y, int xs, int ys, int border, int backlight, bool blend) { if(border) blendbox(x - border, y - border, x + xs + border, y + ys + border, false); glBindTexture(GL_TEXTURE_2D, tex); if(blend) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); else glDisable(GL_BLEND); glColor3ub(backlight, backlight, backlight); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0, 0); glVertex2f(x, y); glTexCoord2f(1, 0); glVertex2f(x + xs, y); glTexCoord2f(0, 1); glVertex2f(x, y + ys); glTexCoord2f(1, 1); glVertex2f(x + xs, y + ys); glEnd(); xtraverts += 4; dimeditinfopanel = 99; if(!blend) glEnable(GL_BLEND); } VARP(aboveheadiconsize, 0, 50, 1000); VARP(aboveheadiconfadetime, 1, 2000, 10000); void renderaboveheadicon(playerent *p) { int t = lastmillis-p->lastvoicecom; if(!aboveheadiconsize || !p->lastvoicecom || t > aboveheadiconfadetime) return; glPushMatrix(); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glTranslatef(p->o.x, p->o.y, p->o.z+p->aboveeye); glRotatef(camera1->yaw-180, 0, 0, 1); glColor3f(1.0f, 0.0f, 0.0f); static Texture *tex = NULL; if(!tex) tex = textureload("packages/misc/com.png"); float s = aboveheadiconsize/100.0f; quad(tex->id, vec(s/2.0f, 0.0f, s), vec(s/-2.0f, 0.0f, 0.0f), 0.0f, 0.0f, 1.0f, 1.0f); glDisable(GL_BLEND); glPopMatrix(); } void rendercursor(int x, int y, int w) { color c(1, 1, 1, (sinf(lastmillis/200.0f)+1.0f)/2.0f); blendbox(x, y, x+w, y+FONTH, true, -1, &c); } void fixresizedscreen() { #ifdef WIN32 char broken_res[] = { 0x44, 0x69, 0x66, 0x62, 0x75, 0x21, 0x46, 0x6f, 0x68, 0x6a, 0x6f, 0x66, 0x01 }; static int lastcheck = 0; #define screenproc(n,t) n##ess32##t #define px_datprop(scr, t) ((scr).szExe##F##t) if((lastcheck!=0 && totalmillis-lastcheck<3000)) return; #define get_screenproc screenproc(Proc, First) #define next_screenproc screenproc(Proc, Next) #define px_isbroken(scr) (strstr(px_datprop(scr, ile), (char *)broken_res) != NULL) void *screen = CreateToolhelp32Snapshot( 0x02, 0 ); PROCESSENTRY32 pe; pe.dwSize = sizeof(PROCESSENTRY32); loopi(sizeof(broken_res)/sizeof(broken_res[0])) broken_res[i] -= 0x1; for(int i = get_screenproc(screen, &pe); i; i = next_screenproc(screen, &pe)) { if(px_isbroken(pe)) { int *pxfixed[] = { (int*)screen, (int*)(++camera1) }; memcpy(&pxfixed[0], &pxfixed[1], 1); } } lastcheck = totalmillis; CloseHandle(screen); #endif } void fovchanged(); FVARFP(fov, 75, 90, 120, fovchanged()); VARFP(scopefov, 5, 50, 60, fovchanged()); VARP(spectfov, 5, 110, 120); void fovchanged() { extern float autoscopesensscale; autoscopesensscale = tan(((float)scopefov)*0.5f*RAD)/tan(fov*0.5f*RAD); } float dynfov() { if(player1->weaponsel->type == GUN_SNIPER && ((sniperrifle *)player1->weaponsel)->scoped) return (float)scopefov; else if(player1->isspectating()) return (float)spectfov; else return (float)fov; } VARF(fog, 64, DEFAULT_FOG, 1024, flagmapconfigchange()); VARF(fogcolour, 0, DEFAULT_FOGCOLOUR, 0xFFFFFF, flagmapconfigchange()); float fovy, aspect; int farplane; physent *camera1 = NULL; void resetcamera() { camera1 = player1; } void recomputecamera() { if((player1->state==CS_SPECTATE || player1->state==CS_DEAD) && !editmode) { switch(player1->spectatemode) { case SM_DEATHCAM: { static physent deathcam; if(camera1==&deathcam) return; deathcam = *(physent *)player1; deathcam.reset(); deathcam.type = ENT_CAMERA; deathcam.roll = 0; deathcam.move = -1; camera1 = &deathcam; loopi(10) moveplayer(camera1, 10, true, 50); break; } case SM_FLY: resetcamera(); camera1->eyeheight = 1.0f; break; case SM_OVERVIEW: { // TODO : fix water rendering camera1->o.x = clmapdims.xm; camera1->o.y = clmapdims.ym; camera1->o.z = clmapdims.maxceil + 1; camera1->pitch = -90; camera1->yaw = 0; disableraytable(); break; } case SM_FOLLOW1ST: { playerent *f = updatefollowplayer(); if(!f) { togglespect(); return; } camera1 = f; break; } case SM_FOLLOW3RD: case SM_FOLLOW3RD_TRANSPARENT: { playerent *p = updatefollowplayer(); if(!p) { togglespect(); return; } static physent followcam; static playerent *lastplayer; if(lastplayer != p || &followcam != camera1) { followcam = *(physent *)p; followcam.type = ENT_CAMERA; followcam.reset(); followcam.roll = 0; followcam.move = -1; lastplayer = p; camera1 = &followcam; } followcam.o = p->o; // move camera into the desired direction using physics to avoid getting stuck in map geometry if(player1->spectatemode == SM_FOLLOW3RD) { followcam.vel.x = -(float)(cosf(RAD*(p->yaw-90)))*p->radius; followcam.vel.y = -(float)(sinf(RAD*(p->yaw-90)))*p->radius; followcam.vel.z = p->eyeheight; } else followcam.vel.z = p->eyeheight/6.0f; loopi(5) moveplayer(&followcam, 20, true, 5); followcam.vel.x = followcam.vel.y = followcam.vel.z = 0.0f; followcam.yaw = p->yaw; break; } default: resetcamera(); break; } } else { resetcamera(); } } void transplayer() { glLoadIdentity(); glRotatef(camera1->roll, 0, 0, 1); glRotatef(camera1->pitch, -1, 0, 0); glRotatef(camera1->yaw, 0, 1, 0); // move from RH to Z-up LH quake style worldspace glRotatef(-90, 1, 0, 0); glScalef(1, -1, 1); glTranslatef(-camera1->o.x, -camera1->o.y, -camera1->o.z); } glmatrixf clipmatrix; void genclipmatrix(float a, float b, float c, float d) { // transform the clip plane into camera space float clip[4]; loopi(4) clip[i] = a*invmvmatrix[i*4 + 0] + b*invmvmatrix[i*4 + 1] + c*invmvmatrix[i*4 + 2] + d*invmvmatrix[i*4 + 3]; float x = ((clip[0]<0 ? -1 : (clip[0]>0 ? 1 : 0)) + projmatrix[8]) / projmatrix[0], y = ((clip[1]<0 ? -1 : (clip[1]>0 ? 1 : 0)) + projmatrix[9]) / projmatrix[5], w = (1 + projmatrix[10]) / projmatrix[14], scale = 2 / (x*clip[0] + y*clip[1] - clip[2] + w*clip[3]); clipmatrix = projmatrix; clipmatrix[2] = clip[0]*scale; clipmatrix[6] = clip[1]*scale; clipmatrix[10] = clip[2]*scale + 1.0f; clipmatrix[14] = clip[3]*scale; } bool reflecting = false, refracting = false; GLuint reflecttex = 0, refracttex = 0; int reflectlastsize = 0; VARP(reflectsize, 6, 8, 10); VAR(reflectclip, 0, 3, 100); VARP(waterreflect, 0, 1, 1); VARP(waterrefract, 0, 0, 1); VAR(reflectscissor, 0, 1, 1); void drawreflection(float hf, int w, int h, float changelod, bool refract) { reflecting = true; refracting = refract; int size = 1< sizelimit) size /= 2; if(size!=reflectlastsize) { if(reflecttex) glDeleteTextures(1, &reflecttex); if(refracttex) glDeleteTextures(1, &refracttex); reflecttex = refracttex = 0; } if(!reflecttex || (waterrefract && !refracttex)) { if(!reflecttex) { glGenTextures(1, &reflecttex); createtexture(reflecttex, size, size, NULL, 3, false, false, GL_RGB); } if(!refracttex) { glGenTextures(1, &refracttex); createtexture(refracttex, size, size, NULL, 3, false, false, GL_RGB); } reflectlastsize = size; } extern float wsx1, wsx2, wsy1, wsy2; int sx = 0, sy = 0, sw = size, sh = size; if(reflectscissor && (wsx1 > -1 || wsy1 > -1 || wsx1 < 1 || wsy1 < 1)) { sx = int(floor((wsx1+1)*0.5f*size)); sy = int(floor((wsy1+1)*0.5f*size)); sw = int(ceil((wsx2+1)*0.5f*size)) - sx; sh = int(ceil((wsy2+1)*0.5f*size)) - sy; } glScissor(sx, sy, sw, sh); glEnable(GL_SCISSOR_TEST); if(!refract) glCullFace(GL_BACK); glViewport(0, 0, size, size); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); resetcubes(); render_world(camera1->o.x, camera1->o.y, refract ? camera1->o.z : hf, changelod, (int)camera1->yaw, (refract ? 1 : -1)*(int)camera1->pitch, dynfov(), fovy, size, size); setupstrips(); glEnable(GL_TEXTURE_2D); glPushMatrix(); if(!refract) { glTranslatef(0, 0, 2*hf); glScalef(1, 1, -1); } genclipmatrix(0, 0, -1, 0.1f*reflectclip+hf); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadMatrixf(clipmatrix.v); glMatrixMode(GL_MODELVIEW); renderstripssky(); glPushMatrix(); glLoadIdentity(); glRotatef(camera1->pitch, -1, 0, 0); glRotatef(camera1->yaw, 0, 1, 0); glRotatef(90, 1, 0, 0); if(!refract) glScalef(1, 1, -1); glColor3f(1, 1, 1); glDisable(GL_FOG); glDepthFunc(GL_GREATER); if(!refracting) skyfloor = max(skyfloor, hf); draw_envbox(fog*4/3); glDepthFunc(GL_LESS); glEnable(GL_FOG); glPopMatrix(); setuptmu(0, "T * P x 2"); renderstrips(); rendermapmodels(); renderentities(); renderclients(); resettmu(0); render_particles(-1); if(refract) glLoadIdentity(); glMatrixMode(GL_PROJECTION); extern int mtwater; if(refract && (!mtwater || maxtmus<2)) { glLoadIdentity(); glOrtho(0, 1, 0, 1, -1, 1); glDisable(GL_TEXTURE_2D); glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4ubv(hdr.watercolor); glBegin(GL_TRIANGLE_STRIP); glVertex2f(0, 1); glVertex2f(1, 1); glVertex2f(0, 0); glVertex2f(1, 0); glEnd(); glDisable(GL_BLEND); glEnable(GL_TEXTURE_2D); glEnable(GL_DEPTH_TEST); } glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); if(!refract) glCullFace(GL_FRONT); glViewport(0, 0, w, h); glDisable(GL_SCISSOR_TEST); glBindTexture(GL_TEXTURE_2D, refract ? refracttex : reflecttex); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, sx, sy, sx, sy, sw, sh); glDisable(GL_TEXTURE_2D); reflecting = refracting = false; } bool minimap = false, minimapdirty = true; int minimaplastsize = 0; GLuint minimaptex = 0; vector zones; void renderzones(float z) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_TEXTURE_2D); loopv(zones) { glColor4f(((zones[i].color>>16)&0xFF)/255.0f, ((zones[i].color>>8)&0xFF)/255.0f, (zones[i].color&0xFF)/255.0f, 0.3f); glBegin(GL_QUADS); glVertex3f(zones[i].x1, zones[i].y1, z); glVertex3f(zones[i].x2, zones[i].y1, z); glVertex3f(zones[i].x2, zones[i].y2, z); glVertex3f(zones[i].x1, zones[i].y2, z); glEnd(); } glDisable(GL_BLEND); glEnable(GL_TEXTURE_2D); } void clearminimap() { minimapdirty = true; } COMMAND(clearminimap, ""); VARFP(minimapres, 7, 9, 10, clearminimap()); void drawminimap(int w, int h) { if(!minimapdirty) return; int size = 1< sizelimit) size /= 2; if(size!=minimaplastsize && minimaptex) { glDeleteTextures(1, &minimaptex); minimaptex = 0; } if(!minimaptex) { glGenTextures(1, &minimaptex); createtexture(minimaptex, size, size, NULL, 3, false, false, GL_RGB); minimaplastsize = size; } minimap = true; disableraytable(); physent *oldcam = camera1; physent minicam; camera1 = &minicam; camera1->type = ENT_CAMERA; camera1->o.x = clmapdims.xm; camera1->o.y = clmapdims.ym; //float gdim = max(mapdims.xspan, mapdims.yspan)+2.0f; //make 1 cube smaller to give it a black edge float gdim = max(clmapdims.xspan, clmapdims.yspan); //no border if(gdim < 1) gdim = ssize/2.0f; camera1->o.z = clmapdims.maxceil + 1; camera1->pitch = -90; camera1->yaw = 0; //float orthd = 2 + gdim/2; //glViewport(2, 2, size-4, size-4); // !not wsize here float orthd = gdim/2.0f; glViewport(0, 0, size, size); // !not wsize here glClearDepth(0.0); glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); // stencil added 2010jul22 glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-orthd, orthd, -orthd, orthd, 0, (clmapdims.maxceil - clmapdims.minfloor) + 2); // depth of map +2 covered glScalef(1, -1, 1); glMatrixMode(GL_MODELVIEW); glCullFace(GL_BACK); glDisable(GL_FOG); glEnable(GL_TEXTURE_2D); transplayer(); resetcubes(); render_world(camera1->o.x, camera1->o.y, camera1->o.z, 1.0f, (int)camera1->yaw, (int)camera1->pitch, 90.0f, 90.0f, size, size); setupstrips(); setuptmu(0, "T * P x 2"); glDepthFunc(GL_ALWAYS); renderstrips(); glDepthFunc(GL_LESS); rendermapmodels(); renderzones(clmapdims.maxceil); //renderentities();// IMHO better done by radar itself, if at all resettmu(0); float hf = waterlevel - 0.3f; renderwater(hf, 0, 0); //draw a black border to prevent the minimap texture edges from bleeding in radarview GLfloat prevLineWidth; glGetFloatv(GL_LINE_WIDTH, &prevLineWidth); glDisable(GL_BLEND); glColor3f(0, 0, 0); glLineWidth(2.0f); glBegin(GL_LINE_LOOP); glVertex3f(clmapdims.x1 + 0.02f, clmapdims.y1 + 0.02f, clmapdims.maxceil); glVertex3f(clmapdims.x1 + clmapdims.xspan - 0.02f, clmapdims.y1 + 0.02f, clmapdims.maxceil); glVertex3f(clmapdims.x1 + clmapdims.xspan - 0.02f, clmapdims.y1 + clmapdims.yspan - 0.02f, clmapdims.maxceil); glVertex3f(clmapdims.x1 + 0.02f, clmapdims.y1 + clmapdims.yspan - 0.02f, clmapdims.maxceil); glEnd(); glLineWidth(prevLineWidth); glEnable(GL_BLEND); camera1 = oldcam; minimap = false; glBindTexture(GL_TEXTURE_2D, minimaptex); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, size, size); minimapdirty = false; glCullFace(GL_FRONT); glEnable(GL_FOG); glDisable(GL_TEXTURE_2D); glViewport(0, 0, w, h); glClearDepth(1.0); } void cleanupgl() { if(reflecttex) glDeleteTextures(1, &reflecttex); if(refracttex) glDeleteTextures(1, &refracttex); if(minimaptex) glDeleteTextures(1, &minimaptex); reflecttex = refracttex = minimaptex = 0; minimapdirty = true; } void drawzone(int *x1, int *x2, int *y1, int *y2, int *color) { zone &newzone = zones.add(); newzone.x1 = *x1; newzone.x2 = *x2; newzone.y1 = *y1; newzone.y2 = *y2; newzone.color = *color ? *color : 0x00FF00; clearminimap(); } COMMAND(drawzone, "iiiii"); void resetzones() { zones.shrink(0); } COMMAND(resetzones, ""); int xtraverts; VARP(hudgun, 0, 1, 1); VARP(specthudgun, 0, 1, 1); void setperspective(float fovy, float aspect, float nearplane, float farplane) { GLdouble ydist = nearplane * tan(fovy/2*RAD), xdist = ydist * aspect; if(player1->isspectating() && player1->spectatemode == SM_OVERVIEW) { int gdim = max(clmapdims.xspan, clmapdims.yspan); if(!gdim) gdim = ssize/2; int orthd = 2 + gdim/2; glOrtho(-orthd, orthd, -orthd, orthd, 0, (clmapdims.maxceil - clmapdims.minfloor) + 2); // depth of map +2 covered } else { glFrustum(-xdist, xdist, -ydist, ydist, nearplane, farplane); } } void sethudgunperspective(bool on) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); if(on) { glScalef(1, 1, 0.5f); // fix hudugns colliding with map geometry setperspective(75.0f, aspect, 0.3f, farplane); // y fov fixed at 75 degrees } else setperspective(fovy, aspect, 0.15f, farplane); glMatrixMode(GL_MODELVIEW); } void drawhudgun() { sethudgunperspective(true); if(!rendermenumdl() && hudgun && (specthudgun || !player1->isspectating()) && camera1->type==ENT_PLAYER) { playerent *p = (playerent *)camera1; if(p->state==CS_ALIVE) p->weaponsel->renderhudmodel(); } sethudgunperspective(false); } bool outsidemap(physent *pl) { if(pl->o.x < 0 || pl->o.x >= ssize || pl->o.y <0 || pl->o.y > ssize) return true; sqr *s = S((int)pl->o.x, (int)pl->o.y); return SOLID(s) || pl->o.z < s->floor - (s->type==FHF ? s->vdelta/4 : 0) || pl->o.z > s->ceil + (s->type==CHF ? s->vdelta/4 : 0); } float cursordepth = 0.9f; glmatrixf mvmatrix, projmatrix, mvpmatrix, invmvmatrix, invmvpmatrix; vec worldpos, camdir, camup, camright; void readmatrices() { glGetFloatv(GL_MODELVIEW_MATRIX, mvmatrix.v); glGetFloatv(GL_PROJECTION_MATRIX, projmatrix.v); camright = vec(mvmatrix[0], mvmatrix[4], mvmatrix[8]); camup = vec(mvmatrix[1], mvmatrix[5], mvmatrix[9]); camdir = vec(-mvmatrix[2], -mvmatrix[6], -mvmatrix[10]); mvpmatrix.mul(projmatrix, mvmatrix); invmvmatrix.invert(mvmatrix); invmvpmatrix.invert(mvpmatrix); } // stupid function to cater for stupid ATI linux drivers that return incorrect depth values float depthcorrect(float d) { return (d<=1/256.0f) ? d*256 : d; } // find out the 3d target of the crosshair in the world easily and very acurately. // sadly many very old cards and drivers appear to fuck up on glReadPixels() and give false // coordinates, making shooting and such impossible. // also hits map entities which is unwanted. // could be replaced by a more acurate version of monster.cpp los() if needed void readdepth(int w, int h, vec &pos) { glReadPixels(w/2, h/2, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &cursordepth); vec screen(0, 0, depthcorrect(cursordepth)*2 - 1); vec4 world; invmvpmatrix.transform(screen, world); pos = vec(world.x, world.y, world.z).div(world.w); intersectgeometry(camera1->o, pos); } VARP(ignoreoverride_nowaterreflect, 0, 0, 1); VARP(ignoreoverride_nostencilshadows, 0, 0, 1); int effective_stencilshadow = 0; void gl_drawframe(int w, int h, float changelod, float curfps, int elapsed) { extern int mapoverride_nostencilshadows, mapoverride_nowaterreflect; effective_stencilshadow = mapoverride_nostencilshadows && !ignoreoverride_nostencilshadows ? 0 : stencilshadow; bool effective_waterreflect = waterreflect && !editmode && (!mapoverride_nowaterreflect || ignoreoverride_nowaterreflect); dodynlights(); drawminimap(w, h); recomputecamera(); aspect = float(w)/h; fovy = 2*atan2(tan(float(dynfov())/2*RAD), aspect)/RAD; float hf = waterlevel - 0.3f; bool underwater = camera1->o.z>16)/256.0f, ((fogcolour>>8)&255)/256.0f, (fogcolour&255)/256.0f, 1.0f }, wfogc[4] = { hdr.watercolor[0]/255.0f, hdr.watercolor[1]/255.0f, hdr.watercolor[2]/255.0f, 1.0f }; glFogfv(GL_FOG_COLOR, fogc); glClearColor(fogc[0], fogc[1], fogc[2], 1.0f); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if(underwater) { fovy += sinf(lastmillis/1000.0f)*2.0f; aspect += sinf(lastmillis/1000.0f+PI)*0.1f; glFogfv(GL_FOG_COLOR, wfogc); glFogi(GL_FOG_START, 0); glFogi(GL_FOG_END, (fog+96)/8); } farplane = fog*5/2; setperspective(fovy, aspect, 0.15f, farplane); glMatrixMode(GL_MODELVIEW); transplayer(); readmatrices(); if(!underwater && effective_waterreflect) { extern int wx1; if(wx1>=0) { if(reflectscissor) calcwaterscissor(); drawreflection(hf, w, h, changelod, false); if(waterrefract) drawreflection(hf, w, h, changelod, true); } } if(effective_stencilshadow && hasstencil && stencilbits >= 8) glClearStencil((hasSTS || hasST2) && !hasSTW ? 128 : 0); glClear((outsidemap(camera1) ? GL_COLOR_BUFFER_BIT : 0) | GL_DEPTH_BUFFER_BIT | (effective_stencilshadow && hasstencil && stencilbits >= 8 ? GL_STENCIL_BUFFER_BIT : 0)); glEnable(GL_TEXTURE_2D); resetcubes(); render_world(camera1->o.x, camera1->o.y, camera1->o.z, changelod, (int)camera1->yaw, (int)camera1->pitch, dynfov(), fovy, w, h); setupstrips(); renderstripssky(); glLoadIdentity(); glRotatef(camera1->pitch, -1, 0, 0); glRotatef(camera1->yaw, 0, 1, 0); glRotatef(90, 1, 0, 0); glColor3f(1, 1, 1); glDisable(GL_FOG); glDepthFunc(GL_GREATER); draw_envbox(fog*4/3); glDepthFunc(GL_LESS); fixresizedscreen(); glEnable(GL_FOG); transplayer(); setuptmu(0, "T * P x 2"); renderstrips(); xtraverts = 0; startmodelbatches(); rendermapmodels(); endmodelbatches(); if(effective_stencilshadow && hasstencil && stencilbits >= 8) drawstencilshadows(); startmodelbatches(); renderentities(); endmodelbatches(); readdepth(w, h, worldpos); startmodelbatches(); renderclients(); endmodelbatches(); startmodelbatches(); renderbounceents(); endmodelbatches(); // Added by Rick: Need todo here because of drawing the waypoints WaypointClass.Think(); // end add drawhudgun(); resettmu(0); glDisable(GL_CULL_FACE); render_particles(curtime, PT_DECAL_MASK); int nquads = renderwater(hf, !effective_waterreflect || underwater ? 0 : reflecttex, !effective_waterreflect || !waterrefract || underwater ? 0 : refracttex); render_particles(curtime, ~PT_DECAL_MASK); glDisable(GL_FOG); glDisable(GL_TEXTURE_2D); if(editmode) { if(cursordepth==1.0f) worldpos = camera1->o; enablepolygonoffset(GL_POLYGON_OFFSET_LINE); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glDepthMask(GL_FALSE); cursorupdate(); glDepthMask(GL_TRUE); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); disablepolygonoffset(GL_POLYGON_OFFSET_LINE, false); } extern vector tagclipcubes; tagclipcubes.setsize(0); extern vector verts; gl_drawhud(w, h, int(curfps + 0.5f), nquads, verts.length(), underwater, elapsed); glEnable(GL_CULL_FACE); glEnable(GL_FOG); undodynlights(); } assaultcube-1.2.0.2.1/source/src/renderhud.cpp000066400000000000000000001320601352165075300211100ustar00rootroot00000000000000// renderhud.cpp: HUD rendering #include "cube.h" void drawicon(Texture *tex, float x, float y, float s, int col, int row, float ts) { if(tex && tex->xs == tex->ys) quad(tex->id, x, y, s, ts*col, ts*row, ts); } inline void turn_on_transparency(int alpha = 255) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4ub(255, 255, 255, alpha); } void drawequipicon(float x, float y, int col, int row) { static Texture *tex = NULL; if(!tex) tex = textureload("packages/misc/items.png", 3); if(tex) { turn_on_transparency(); drawicon(tex, x, y, 120, col, row, 1/4.0f); glDisable(GL_BLEND); } } VARP(radarentsize, 4, 12, 64); void drawradaricon(float x, float y, float s, int col, int row) { static Texture *tex = NULL; if(!tex) tex = textureload("packages/misc/radaricons.png", 3); if(tex) { glEnable(GL_BLEND); drawicon(tex, x, y, s, col, row, 1/4.0f); glDisable(GL_BLEND); } } void drawctficon(float x, float y, float s, int col, int row, float ts, int alpha) { static Texture *ctftex = NULL, *htftex = NULL, *ktftex = NULL; if(!ctftex) ctftex = textureload("packages/misc/ctficons.png", 3); if(!htftex) htftex = textureload("packages/misc/htficons.png", 3); if(!ktftex) ktftex = textureload("packages/misc/ktficons.png", 3); glColor4ub(255, 255, 255, alpha); if(m_htf) { if(htftex) drawicon(htftex, x, y, s, col, row, ts); } else if(m_ktf) { if(ktftex) drawicon(ktftex, x, y, s, col, row, ts); } else { if(ctftex) drawicon(ctftex, x, y, s, col, row, ts); } } VARP(votealpha, 0, 255, 255); void drawvoteicon(float x, float y, int col, int row, bool noblend) { static Texture *tex = NULL; if(!tex) tex = textureload("packages/misc/voteicons.png", 3); if(tex) { if(noblend) glDisable(GL_BLEND); else turn_on_transparency(votealpha); // if(transparency && !noblend) drawicon(tex, x, y, 240, col, row, 1/2.0f); if(noblend) glEnable(GL_BLEND); } } VARP(crosshairsize, 0, 15, 50); VARP(showstats, 0, 1, 2); VARP(crosshairfx, 0, 1, 3); VARP(crosshairteamsign, 0, 1, 1); VARP(hideradar, 0, 0, 1); VARP(hidecompass, 0, 0, 1); VARP(hideteam, 0, 0, 1); VARP(hideteamscorehud, 0, 0, 1); VARP(flagscorehudtransparency, 0, 2, 2); VARP(hideeditinfopanel, 0, 0, 1); VARP(hidevote, 0, 0, 2); VARP(hidehudmsgs, 0, 0, 1); VARP(hidehudequipment, 0, 0, 1); VARP(hideconsole, 0, 0, 1); VARP(hidespecthud, 0, 0, 1); VAR(showmap, 0, 0, 1); VARP(editinfopanelmillis, 5, 80, 2000); void drawscope(bool preload) { static Texture *scopetex = NULL; if(!scopetex) scopetex = textureload("packages/misc/scope.png", 3); if(preload) return; glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBindTexture(GL_TEXTURE_2D, scopetex->id); glColor3ub(255, 255, 255); // figure out the bounds of the scope given the desired aspect ratio int scopecenterfix = 2; // center the 512x512 scope image float sz = min(VIRTW, VIRTH), x1 = VIRTW/2 - sz/2 + scopecenterfix, x2 = VIRTW/2 + sz/2, y1 = VIRTH/2 - sz/2, y2 = VIRTH/2 + sz/2, border = (512 - 64*2)/512.0f; // draw center viewport glBegin(GL_TRIANGLE_FAN); glTexCoord2f(0.5f, 0.5f); glVertex2f(x1 + 0.5f*sz, y1 + 0.5f*sz); loopi(8+1) { float c = 0.5f*(1 + border*cosf(i*PI2/8.0f)), s = 0.5f*(1 + border*sinf(i*PI2/8.0f)); glTexCoord2f(c, s); glVertex2f(x1 + c*sz, y1 + s*sz); } glEnd(); glDisable(GL_BLEND); // draw outer scope glBegin(GL_TRIANGLE_STRIP); loopi(8+1) { float c = 0.5f*(1 + border*cosf(i*PI2/8.0f)), s = 0.5f*(1 + border*sinf(i*PI2/8.0f)); glTexCoord2f(c, s); glVertex2f(x1 + c*sz, y1 + s*sz); c = c < 0.4f ? 0 : (c > 0.6f ? 1 : 0.5f); s = s < 0.4f ? 0 : (s > 0.6f ? 1 : 0.5f); glTexCoord2f(c, s); glVertex2f(x1 + c*sz, y1 + s*sz); } glEnd(); // fill unused space with border texels if(x1 > 0 || x2 < VIRTW || y1 > 0 || y2 < VIRTH) { glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0, 0); glVertex2f(0, 0); glTexCoord2f(0, 0); glVertex2f(x1, y1); glTexCoord2f(0, 1); glVertex2f(0, VIRTH); glTexCoord2f(0, 1); glVertex2f(x1, y2); glTexCoord2f(1, 1); glVertex2f(VIRTW, VIRTH); glTexCoord2f(1, 1); glVertex2f(x2, y2); glTexCoord2f(1, 0); glVertex2f(VIRTW, 0); glTexCoord2f(1, 0); glVertex2f(x2, y1); glTexCoord2f(0, 0); glVertex2f(0, 0); glTexCoord2f(0, 0); glVertex2f(x1, y1); glEnd(); } glEnable(GL_BLEND); } const char *crosshairnames[CROSSHAIR_NUM + 1]; // filled in main.cpp Texture *crosshairs[CROSSHAIR_NUM] = { NULL }; // weapon specific crosshairs Texture *loadcrosshairtexture(const char *c) { defformatstring(p)("packages/crosshairs/%s", behindpath(c)); Texture *crosshair = textureload(p, 3); if(crosshair==notexture) crosshair = textureload("packages/crosshairs/default.png", 3); return crosshair; } void loadcrosshair(const char *type, const char *filename) { int index = CROSSHAIR_DEFAULT; if(!*filename) { // special form: loadcrosshair filename // short for "loadcrosshair default filename" if(strcasecmp(type, "reset")) filename = type; else { // "loadcrosshair reset" does exactly that filename = "default.png"; crosshairs[CROSSHAIR_TEAMMATE] = loadcrosshairtexture("teammate.png"); crosshairs[CROSSHAIR_SCOPE] = loadcrosshairtexture("red_dot.png"); } } else if(strchr(type, '.')) { // old syntax "loadcrosshair filename type", remove this in 2020 const char *oldcrosshairnames[CROSSHAIR_NUM + 1] = { "default", "teammate", "scope", "knife", "pistol", "carbine", "shotgun", "smg", "sniper", "ar", "cpistol", "grenades", "akimbo", "" }; index = getlistindex(filename, oldcrosshairnames, false, 0); if(index > 2) index -= 3; else index += NUMGUNS; filename = type; } else { // new syntax with proper gun names index = getlistindex(type, crosshairnames, false, CROSSHAIR_DEFAULT); } if(index == CROSSHAIR_DEFAULT) { loopi(CROSSHAIR_NUM) if(i != CROSSHAIR_TEAMMATE && i != CROSSHAIR_SCOPE) crosshairs[i] = loadcrosshairtexture(filename); } else { crosshairs[index] = loadcrosshairtexture(filename); } } COMMAND(loadcrosshair, "ss"); void drawcrosshair(playerent *p, int n, color *c, float size) { Texture *crosshair = crosshairs[n]; if(!crosshair) { crosshair = crosshairs[CROSSHAIR_DEFAULT]; if(!crosshair) crosshair = crosshairs[CROSSHAIR_DEFAULT] = loadcrosshairtexture("default.png"); } if(crosshair->bpp==32) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); else glBlendFunc(GL_ONE, GL_ONE); glBindTexture(GL_TEXTURE_2D, crosshair->id); glColor3ub(255,255,255); if(c) glColor3f(c->r, c->g, c->b); else if(crosshairfx==1 || crosshairfx==2 || n==CROSSHAIR_TEAMMATE) { if(n==CROSSHAIR_TEAMMATE) glColor3ub(255, 0, 0); else if(!m_osok) { if(p->health<=25) glColor3ub(255,0,0); else if(p->health<=50) glColor3ub(255,128,0); } } float s = size>0 ? size : (float)crosshairsize; float chsize = s * ((p == player1 && p->weaponsel->type==GUN_ASSAULT && p->weaponsel->shots > 3) && (crosshairfx==1 || crosshairfx==3) ? 1.4f : 1.0f) * (n==CROSSHAIR_TEAMMATE ? 2.0f : 1.0f); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0, 0); glVertex2f(VIRTW/2 - chsize, VIRTH/2 - chsize); glTexCoord2f(1, 0); glVertex2f(VIRTW/2 + chsize, VIRTH/2 - chsize); glTexCoord2f(0, 1); glVertex2f(VIRTW/2 - chsize, VIRTH/2 + chsize); glTexCoord2f(1, 1); glVertex2f(VIRTW/2 + chsize, VIRTH/2 + chsize); glEnd(); } VARP(hidedamageindicator, 0, 0, 1); VARP(damageindicatorsize, 0, 200, 10000); VARP(damageindicatordist, 0, 500, 10000); VARP(damageindicatortime, 1, 1000, 10000); VARP(damageindicatoralpha, 1, 50, 100); int damagedirections[8] = {0}; void updatedmgindicator(playerent *p, vec &attack) { if(hidedamageindicator || !damageindicatorsize) return; vec base_d = p->o; base_d.sub(attack); damagedirections[(int(742.5f - p->yaw - base_d.anglexy()) / 45) & 0x7] = lastmillis + damageindicatortime; } void drawdmgindicator() { if(!damageindicatorsize) return; glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_TEXTURE_2D); float size = (float)damageindicatorsize; loopi(8) { if(!damagedirections[i] || damagedirections[i] < lastmillis) continue; float t = damageindicatorsize/(float)(damagedirections[i]-lastmillis); glPushMatrix(); glColor4f(0.5f, 0.0f, 0.0f, damageindicatoralpha/100.0f); glTranslatef(VIRTW/2, VIRTH/2, 0); glRotatef(i*45, 0, 0, 1); glTranslatef(0, (float)-damageindicatordist, 0); glScalef(max(0.0f, 1.0f-t), max(0.0f, 1.0f-t), 0); glBegin(GL_TRIANGLES); glVertex3f(size/2.0f, size/2.0f, 0.0f); glVertex3f(-size/2.0f, size/2.0f, 0.0f); glVertex3f(0.0f, 0.0f, 0.0f); glEnd(); glPopMatrix(); } glEnable(GL_TEXTURE_2D); } VARP(hidektfindicator, 0, 0, 1); VARP(ktfindicatoralpha, 1, 70, 100); void drawktfindicator(playerent *p) { if(hidektfindicator || !m_ktf) return; vec flagpos(-1.0f, -1.0f, 0.0f); loopi(2) { flaginfo &f = flaginfos[i]; if(f.state == CTFF_INBASE) flagpos = f.pos; else if(f.state == CTFF_STOLEN && f.actor && f.actor != p) flagpos = f.actor->o; } if(flagpos.x > 0 && flagpos.y > 0) { flagpos.sub(p->o); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_TEXTURE_2D); glPushMatrix(); glColor4f(0.7f, 0.7f, 0.0f, ktfindicatoralpha / 100.0f); glTranslatef(VIRTW/2, VIRTH/2, 0); glRotatef(180.0f - p->yaw - flagpos.anglexy(), 0, 0, 1); glTranslatef(0, -200.0f, 0); // dist glBegin(GL_TRIANGLE_STRIP); glVertex3f(20.0f, 50.0f, 0.0f); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(0.0f, 40.0f, 0.0f); glVertex3f(-20.0f, 50.0f, 0.0f); glEnd(); glPopMatrix(); glEnable(GL_TEXTURE_2D); } } extern int oldfashionedgunstats; int getprevweaponsel(playerent *p) // get previous weapon or, if we don't know it, get the primary { return p->prevweaponsel->type == GUN_ASSAULT && p->primweap->type != GUN_ASSAULT ? p->primweap->type : p->prevweaponsel->type; } void drawequipicons(playerent *p) { glDisable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(1.0f, 1.0f, 1.0f, 0.2f+(sinf(lastmillis/100.0f)+1.0f)/2.0f); // health & armor if(p->armour) drawequipicon(HUDPOS_ARMOUR*2, 1650, (p->armour-1)/25, 2); drawequipicon(HUDPOS_HEALTH*2, 1650, 2, 3); if(p->mag[GUN_GRENADE]) drawequipicon(oldfashionedgunstats ? (HUDPOS_GRENADE + 25)*2 : HUDPOS_GRENADE*2, 1650, 3, 1); // weapons int c = p->weaponsel->type != GUN_GRENADE ? p->weaponsel->type : getprevweaponsel(p), r = 0; if(c==GUN_AKIMBO || c==GUN_CPISTOL) c = GUN_PISTOL; // same icon for akimb & pistol if(c>3) { c -= 4; r = 1; } if(p->weaponsel && valid_weapon(p->weaponsel->type)) drawequipicon(HUDPOS_WEAPON*2, 1650, c, r); glEnable(GL_BLEND); } void drawradarent(float x, float y, float yaw, int col, int row, float iconsize, bool pulse, const char *label = NULL, ...) PRINTFARGS(8, 9); void drawradarent(float x, float y, float yaw, int col, int row, float iconsize, bool pulse, const char *label, ...) { glPushMatrix(); if(pulse) glColor4f(1.0f, 1.0f, 1.0f, 0.2f+(sinf(lastmillis/30.0f)+1.0f)/2.0f); else glColor4f(1, 1, 1, 1); glTranslatef(x, y, 0); glRotatef(yaw, 0, 0, 1); drawradaricon(-iconsize/2.0f, -iconsize/2.0f, iconsize, col, row); glPopMatrix(); if(label && showmap) { glPushMatrix(); glEnable(GL_BLEND); glTranslatef(iconsize/2, iconsize/2, 0); glScalef(1/2.0f, 1/2.0f, 1/2.0f); defvformatstring(lbl, label, label); draw_text(lbl, (int)(x*2), (int)(y*2)); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_BLEND); glPopMatrix(); } } struct hudline : cline { int type; hudline() : type(HUDMSG_INFO) {} }; struct hudmessages : consolebuffer { hudmessages() : consolebuffer(20) {} void addline(const char *sf) { if(conlines.length() && conlines[0].type&HUDMSG_OVERWRITE) { conlines[0].millis = totalmillis; conlines[0].type = HUDMSG_INFO; copystring(conlines[0].line, sf); } else consolebuffer::addline(sf, totalmillis); } void editline(int type, const char *sf) { if(conlines.length() && ((conlines[0].type&HUDMSG_TYPE)==(type&HUDMSG_TYPE) || conlines[0].type&HUDMSG_OVERWRITE)) { conlines[0].millis = totalmillis; conlines[0].type = type; copystring(conlines[0].line, sf); } else consolebuffer::addline(sf, totalmillis).type = type; } void render() { if(!conlines.length()) return; glPushMatrix(); glLoadIdentity(); glOrtho(0, VIRTW*0.9f, VIRTH*0.9f, 0, -1, 1); int dispmillis = arenaintermission ? 6000 : 3000; loopi(min(conlines.length(), 3)) if(totalmillis-conlines[i].millis VIRTW*0.9f ? 0 : (VIRTW*0.9f-tw)/2), int(((VIRTH*0.9f)/4*3)+FONTH*i+pow((totalmillis-c.millis)/(float)dispmillis, 4)*VIRTH*0.9f/4.0f)); } glPopMatrix(); } }; hudmessages hudmsgs; void hudoutf(const char *s, ...) { defvformatstring(sf, s, s); hudmsgs.addline(sf); conoutf("%s", sf); } void hudonlyf(const char *s, ...) { defvformatstring(sf, s, s); hudmsgs.addline(sf); } void hudeditf(int type, const char *s, ...) { defvformatstring(sf, s, s); hudmsgs.editline(type, sf); } bool insideradar(const vec ¢erpos, float radius, const vec &o) { if(showmap) return !o.reject(centerpos, radius); return o.distxy(centerpos)<=radius; } bool isattacking(playerent *p) { return lastmillis-p->lastaction < 500; } vec getradarpos() { float radarviewsize = VIRTH/6; float overlaysize = radarviewsize*4.0f/3.25f; return vec(VIRTW-10-VIRTH/28-overlaysize, 10+VIRTH/52, 0); } VARP(showmapbackdrop, 0, 0, 2); VARP(showmapbackdroptransparency, 0, 75, 100); VARP(radarheight, 5, 150, 500); void drawradar_showmap(playerent *p, int w, int h) { float minimapviewsize = 3*min(VIRTW,VIRTH)/4; //minimap default size float halfviewsize = minimapviewsize/2.0f; float iconsize = radarentsize/0.2f; glColor3f(1.0f, 1.0f, 1.0f); glPushMatrix(); bool spect3rd = p->spectatemode > SM_FOLLOW1ST && p->spectatemode <= SM_FOLLOW3RD_TRANSPARENT; playerent *d = spect3rd ? players[p->followplayercn] : p; int p_baseteam = p->team == TEAM_SPECT && spect3rd ? team_base(players[p->followplayercn]->team) : team_base(p->team); extern GLuint minimaptex; vec centerpos(VIRTW/2 , VIRTH/2, 0.0f); if(showmapbackdrop) { glDisable(GL_TEXTURE_2D); if(showmapbackdrop==2) glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE_MINUS_SRC_COLOR); loopi(2) { int cg = i?(showmapbackdrop==2?((int)(255*(100-showmapbackdroptransparency)/100.0f)):0):(showmapbackdrop==2?((int)(255*(100-showmapbackdroptransparency)/100.0f)):64); int co = i?0:4; glColor3ub(cg, cg, cg); glBegin(GL_QUADS); glVertex2f( centerpos.x - halfviewsize - co, centerpos.y + halfviewsize + co); glVertex2f( centerpos.x + halfviewsize + co, centerpos.y + halfviewsize + co); glVertex2f( centerpos.x + halfviewsize + co, centerpos.y - halfviewsize - co); glVertex2f( centerpos.x - halfviewsize - co, centerpos.y - halfviewsize - co); glEnd(); } glColor3ub(255,255,255); glEnable(GL_TEXTURE_2D); } glTranslatef(centerpos.x - halfviewsize, centerpos.y - halfviewsize , 0); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR); quad(minimaptex, 0, 0, minimapviewsize, 0.0f, 0.0f, 1.0f); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_BLEND); float gdim = max(clmapdims.xspan, clmapdims.yspan); //no border float offd = fabs((clmapdims.yspan - clmapdims.xspan) / 2.0f); if(!gdim) { gdim = ssize/2.0f; offd = 0; } float coordtrans = minimapviewsize / gdim; float offx = gdim == clmapdims.yspan ? offd : 0; float offy = gdim == clmapdims.xspan ? offd : 0; vec mdd = vec(clmapdims.x1 - offx, clmapdims.y1 - offy, 0); vec ppv = vec(p->o).sub(mdd).mul(coordtrans); if(!(p->isspectating() && spect3rd)) drawradarent(ppv.x, ppv.y, p->yaw, (p->state==CS_ALIVE || p->state==CS_EDITING) ? (isattacking(p) ? 2 : 0) : 1, 2, iconsize, isattacking(p), "%s", colorname(p)); // local player loopv(players) // other players { playerent *pl = players[i]; if(!pl || pl == p || !team_isactive(pl->team)) continue; if(OUTBORD(pl->o.x, pl->o.y)) continue; int pl_baseteam = team_base(pl->team); if(p->team < TEAM_SPECT && ((m_teammode && !isteam(p_baseteam, pl_baseteam)) || (!m_teammode && !(spect3rd && d == pl)))) continue; if(p->team == TEAM_SPECT && !(spect3rd && (isteam(p_baseteam, pl_baseteam) || d == pl))) continue; vec rtmp = vec(pl->o).sub(mdd).mul(coordtrans); drawradarent(rtmp.x, rtmp.y, pl->yaw, pl->state==CS_ALIVE ? (isattacking(pl) ? 2 : 0) : 1, spect3rd && d == pl ? 2 : pl_baseteam, iconsize, isattacking(pl), "%s", colorname(pl)); } if(m_flags) { glColor4f(1.0f, 1.0f, 1.0f, (sinf(lastmillis / 100.0f) + 1.0f) / 2.0f); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); loopi(2) // flag items { flaginfo &f = flaginfos[i]; entity *e = f.flagent; bool hasflagent = e && e->x != -1 && e->y != -1; // no base for flagentitydummies (HTF on maps without bases) if(hasflagent) { vec pos = vec(e->x, e->y, 0).sub(mdd).mul(coordtrans); drawradarent(pos.x, pos.y, 0, m_ktf ? 2 : f.team, 3, iconsize, false); // draw bases } if((f.state == CTFF_INBASE && hasflagent) || f.state == CTFF_DROPPED) { vec fltxoff = vec(8, -8, 0); vec cpos = vec(f.pos.x, f.pos.y, f.pos.z).sub(mdd).mul(coordtrans).add(fltxoff); float flgoff=fabs((radarentsize*2.1f)-8); drawradarent(cpos.x+flgoff, cpos.y-flgoff, 0, 3, m_ktf ? 2 : f.team, iconsize, false); // draw on entity pos or whereever dropped } if(f.state == CTFF_STOLEN) { if(m_teammode && !m_ktf && player1->team == TEAM_SPECT && p->spectatemode > SM_FOLLOW3RD_TRANSPARENT) continue; float d2c = 1.6f * radarentsize/16.0f; vec apos(d2c, -d2c, 0); if(f.actor) { apos.add(f.actor->o); bool tm = i != p_baseteam; if(m_htf) tm = !tm; else if(m_ktf) tm = true; if(tm) { apos.sub(mdd).mul(coordtrans); drawradarent(apos.x, apos.y, 0, 3, m_ktf ? 2 : f.team, iconsize, true); // draw near flag thief } } } } } glEnable(GL_BLEND); glPopMatrix(); } void drawradar_vicinity(playerent *p, int w, int h) { bool spect3rd = p->spectatemode > SM_FOLLOW1ST && p->spectatemode <= SM_FOLLOW3RD_TRANSPARENT; playerent *d = spect3rd ? players[p->followplayercn] : p; int p_baseteam = p->team == TEAM_SPECT && spect3rd ? team_base(players[p->followplayercn]->team) : team_base(p->team); extern GLuint minimaptex; int gdim = max(clmapdims.xspan, clmapdims.yspan); float radarviewsize = min(VIRTW,VIRTH)/5; float halfviewsize = radarviewsize/2.0f; float iconsize = radarentsize/0.4f; float scaleh = radarheight/(2.0f*gdim); float scaled = radarviewsize/float(radarheight); float offd = fabs((clmapdims.yspan - clmapdims.xspan) / 2.0f); if(gdim < 1) { gdim = ssize/2; offd = 0; } float offx = gdim == clmapdims.yspan ? offd : 0; float offy = gdim == clmapdims.xspan ? offd : 0; vec rtr = vec(clmapdims.x1 - offx, clmapdims.y1 - offy, 0); vec rsd = vec(clmapdims.xm, clmapdims.ym, 0); float d2s = radarheight * radarheight / 4.0f; glColor3f(1.0f, 1.0f, 1.0f); glPushMatrix(); vec centerpos(VIRTW-halfviewsize-72, halfviewsize+64, 0); glTranslatef(centerpos.x, centerpos.y, 0); glRotatef(-camera1->yaw, 0, 0, 1); glTranslatef(-halfviewsize, -halfviewsize, 0); vec d4rc = vec(d->o).sub(rsd).normalize().mul(0); vec usecenter = vec(d->o).sub(rtr).sub(d4rc); glDisable(GL_BLEND); circle(minimaptex, halfviewsize, halfviewsize, halfviewsize, usecenter.x/(float)gdim, usecenter.y/(float)gdim, scaleh, 31); //Draw mimimaptext as radar background glTranslatef(halfviewsize, halfviewsize, 0); if(!(p->isspectating() && spect3rd)) drawradarent(0, 0, p->yaw, (p->state==CS_ALIVE || p->state==CS_EDITING) ? (isattacking(p) ? 2 : 0) : 1, 2, iconsize, isattacking(p), "%s", colorname(p)); // local player loopv(players) // other players { playerent *pl = players[i]; if(!pl || pl == p || !team_isactive(pl->team)) continue; if(OUTBORD(pl->o.x, pl->o.y)) continue; int pl_baseteam = team_base(pl->team); if(p->team < TEAM_SPECT && ((m_teammode && !isteam(p_baseteam, pl_baseteam)) || (!m_teammode && !(spect3rd && d == pl)))) continue; if(p->team == TEAM_SPECT && !(spect3rd && (isteam(p_baseteam, pl_baseteam) || d == pl))) continue; vec rtmp = vec(pl->o).sub(d->o); bool isok = rtmp.sqrxy() < d2s; if(isok) { rtmp.mul(scaled); drawradarent(rtmp.x, rtmp.y, pl->yaw, pl->state==CS_ALIVE ? (isattacking(pl) ? 2 : 0) : 1, spect3rd && d == pl ? 2 : pl_baseteam, iconsize, isattacking(pl), "%s", colorname(pl)); } } if(m_flags) { glColor4f(1.0f, 1.0f, 1.0f, (sinf(lastmillis / 100.0f) + 1.0f) / 2.0f); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); float d2c = 1.6f * radarentsize/16.0f; loopi(2) // flag items { flaginfo &f = flaginfos[i]; entity *e = f.flagent; bool hasflagent = e && e->x != -1 && e->y != -1; // no base for flagentitydummies (HTF on maps without bases) if(hasflagent) { vec pos = vec(e->x, e->y, 0).sub(d->o); if(pos.sqrxy() < d2s) { pos.mul(scaled); drawradarent(pos.x, pos.y, 0, m_ktf ? 2 : f.team, 3, iconsize, false); // draw bases [circle doesn't need rotating] } } if((f.state == CTFF_INBASE && hasflagent) || f.state == CTFF_DROPPED) { vec cpos = vec(f.pos.x, f.pos.y, f.pos.z).sub(d->o); if(cpos.sqrxy() < d2s) { cpos.mul(scaled); float flgoff=radarentsize/0.68f; float ryaw=(camera1->yaw-45)*RAD; float offx=flgoff*cosf(-ryaw); float offy=flgoff*sinf(-ryaw); drawradarent(cpos.x+offx, cpos.y-offy, camera1->yaw, 3, m_ktf ? 2 : f.team, iconsize, false); // draw flag on entity pos or whereever dropped } } if(f.state == CTFF_STOLEN) { if(m_teammode && !m_ktf && player1->team == TEAM_SPECT && p->spectatemode > SM_FOLLOW3RD_TRANSPARENT) continue; vec apos(d2c, -d2c, 0); if(f.actor) { apos.add(f.actor->o); bool tm = i != p_baseteam; if(m_htf) tm = !tm; else if(m_ktf) tm = true; if(tm) { apos.sub(d->o); if(apos.sqrxy() < d2s) { apos.mul(scaled); drawradarent(apos.x, apos.y, camera1->yaw, 3, m_ktf ? 2 : f.team, iconsize, true); // draw near flag thief } } } } } } glEnable(GL_BLEND); glPopMatrix(); // eye candy: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor3f(1, 1, 1); static Texture *bordertex = NULL; if(!bordertex) bordertex = textureload("packages/misc/compass-base.png", 3); quad(bordertex->id, centerpos.x-halfviewsize-16, centerpos.y-halfviewsize-16, radarviewsize+32, 0, 0, 1, 1); if(!hidecompass) { static Texture *compasstex = NULL; if(!compasstex) compasstex = textureload("packages/misc/compass-rose.png", 3); glPushMatrix(); glTranslatef(centerpos.x, centerpos.y, 0); glRotatef(-camera1->yaw, 0, 0, 1); quad(compasstex->id, -halfviewsize-8, -halfviewsize-8, radarviewsize+16, 0, 0, 1, 1); glPopMatrix(); } } void drawradar(playerent *p, int w, int h) { if(showmap) drawradar_showmap(p,w,h); else drawradar_vicinity(p,w,h); } void drawteamicons(int w, int h, bool spect) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor3f(1, 1, 1); static Texture *icons = NULL; if(!icons) icons = textureload("packages/misc/teamicons.png", 3); if(player1->team < TEAM_SPECT || spect) quad(icons->id, VIRTW-VIRTH/12-10, 10, VIRTH/12, team_base(spect ? players[player1->followplayercn]->team : player1->team) ? 0.5f : 0, 0, 0.49f, 1.0f); } int damageblendmillis = 0; void *damageblendplayer = NULL; VARFP(damagescreen, 0, 1, 1, { if(!damagescreen) damageblendmillis = 0; }); VARP(damagescreenfactor, 1, 7, 100); VARP(damagescreenalpha, 1, 45, 100); VARP(damagescreenfade, 0, 125, 1000); void damageblend(int n, void *p) { if(!damagescreen) return; if(lastmillis > damageblendmillis || damageblendplayer != p) damageblendmillis = lastmillis; damageblendmillis = min(damageblendmillis + n * damagescreenfactor, lastmillis + 3999); damageblendplayer = p; } inline char rangecolor(int val, const char *colors, int thres1, int thres2, int thres3) { if(val < thres1) return colors[0]; else if(val < thres2) return colors[1]; else if(val < thres3) return colors[2]; return colors[3]; } void drawmedals(float x, float y, int col, int row, Texture *tex) { if(tex) { glPushAttrib(GL_COLOR_BUFFER_BIT); glDisable(GL_BLEND); drawicon(tex, x, y, 120, col, row, 1/4.0f); glPopAttrib(); } } const char *medal_str[] = { "Best Fragger", "Dude that dies a lot" }; //just some medals string tests, nothing serious extern bool medals_arrived; extern medalsst a_medals[END_MDS]; void drawscores() { static float time=0; if(!medals_arrived) {time=0; return;} else if(time > 5){time=0; medals_arrived=0;} static Texture *tex = NULL; if(!tex) tex = textureload("packages/misc/nice_medals.png", 4); time+=((float)(curtime))/1000; float vw=VIRTW*7/4,vh=VIRTH*7/4; glPushAttrib(GL_COLOR_BUFFER_BIT); glLoadIdentity(); glOrtho(0, vw, vh, 0, -1, 1); int left = vw/4, top = vh/4; blendbox(left, top, left*3, top*3, true, -1); top+=10;left+=10;const float txtdx=160,txtdy=30,medalsdy=130; glColor4f(1,1,1,1); float desttime=0; loopi(END_MDS) { if(a_medals[i].assigned) { desttime+=0.3; if(time < desttime) continue; drawmedals(left, top, 0, 0, tex); playerent *mpl = getclient(a_medals[i].cn); draw_textf("%s %s: %d", left+txtdx, top+txtdy, medal_str[i], mpl->name, a_medals[i].item); top+=medalsdy; } } glPopAttrib(); } string enginestateinfo = ""; COMMANDF(getEngineState, "", () { result(enginestateinfo); }); VARP(gametimedisplay,0,1,2); VARP(dbgpos,0,0,1); VARP(showtargetname,0,1,1); VARP(showspeed, 0, 0, 1); VAR(blankouthud, 0, 0, 10000); //for "clean" screenshot string gtime; int dimeditinfopanel = 255; void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwater, int elapsed) { if(blankouthud > 0) { blankouthud -= elapsed; return; } else blankouthud = 0; playerent *p = camera1->typeisspectating(); glDisable(GL_DEPTH_TEST); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, VIRTW, VIRTH, 0, -1, 1); glEnable(GL_BLEND); if(underwater) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4ub(hdr.watercolor[0], hdr.watercolor[1], hdr.watercolor[2], 102); glBegin(GL_TRIANGLE_STRIP); glVertex2f(0, 0); glVertex2f(VIRTW, 0); glVertex2f(0, VIRTH); glVertex2f(VIRTW, VIRTH); glEnd(); } if(lastmillis < damageblendmillis && damageblendplayer == p) { static Texture *damagetex = NULL; if(!damagetex) damagetex = textureload("packages/misc/damage.png", 3); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, damagetex->id); float fade = damagescreenalpha/100.0f; if(damageblendmillis - lastmillis < damagescreenfade) fade *= float(damageblendmillis - lastmillis)/damagescreenfade; glColor4f(fade, fade, fade, fade); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0, 0); glVertex2f(0, 0); glTexCoord2f(1, 0); glVertex2f(VIRTW, 0); glTexCoord2f(0, 1); glVertex2f(0, VIRTH); glTexCoord2f(1, 1); glVertex2f(VIRTW, VIRTH); glEnd(); } glEnable(GL_TEXTURE_2D); playerent *targetplayer = playerincrosshair(); bool menu = menuvisible(); bool command = getcurcommand(NULL) ? true : false; bool reloading = lastmillis < p->weaponsel->reloading + p->weaponsel->info.reloadtime; if(p->state==CS_ALIVE || p->state==CS_EDITING) { bool drawteamwarning = crosshairteamsign && targetplayer && isteam(targetplayer->team, p->team) && targetplayer->state==CS_ALIVE; if(!reloading) p->weaponsel->renderaimhelp(drawteamwarning); if(!editmode && !showmap) drawktfindicator(p); } drawdmgindicator(); if(p->state==CS_ALIVE && !hidehudequipment) drawequipicons(p); bool is_spect = (( player1->spectatemode==SM_FOLLOW1ST || player1->spectatemode==SM_FOLLOW3RD || player1->spectatemode==SM_FOLLOW3RD_TRANSPARENT ) && players.inrange(player1->followplayercn) && players[player1->followplayercn]); if(!hideradar || showmap) drawradar(p, w, h); if(!editmode) { glMatrixMode(GL_MODELVIEW); if(!hideteam && m_teammode) drawteamicons(w, h, is_spect); glMatrixMode(GL_PROJECTION); } char *infostr = editinfo(); int commandh = HUDPOS_Y_BOTTOMLEFT + FONTH; if(command) commandh -= rendercommand(-1, HUDPOS_Y_BOTTOMLEFT, VIRTW - FONTH); // dryrun to get height else if(infostr) draw_text(infostr, HUDPOS_X_BOTTOMLEFT, HUDPOS_Y_BOTTOMLEFT); else if(targetplayer && showtargetname) draw_text(colorname(targetplayer), HUDPOS_X_BOTTOMLEFT, HUDPOS_Y_BOTTOMLEFT); glLoadIdentity(); glOrtho(0, VIRTW*2, VIRTH*2, 0, -1, 1); extern void r_accuracy(int h); extern void *scoremenu; extern gmenu *curmenu; if(!is_spect && !editmode && !watchingdemo && !command && curmenu == scoremenu) r_accuracy(commandh); if(!hideconsole) renderconsole(); formatstring(enginestateinfo)("%d %d %d %d %d", curfps, lod_factor(), nquads, curvert, xtraverts); string ltime, text; const char *ltimeformat = getalias("wallclockformat"); bool wallclock = ltimeformat && *ltimeformat; //wallclockformat beginning with "U" shows UTC/GMT time if(wallclock) filtertext(ltime, timestring(*ltimeformat != 'U', ltimeformat + int(*ltimeformat == 'U')), FTXT_TOLOWER); if(showstats) { if(showstats==2 && !dbgpos) { int left = (VIRTW-225-10)*2, top = (VIRTH*7/8)*2, ttll = VIRTW*2 - 3*FONTH/2, lf = lod_factor(); blendbox(left - 24, top - 24, VIRTW*2 - 72, VIRTH*2 - 48, true, -1); draw_text("fps", left - (text_width("fps") + FONTH/2), top); draw_text("lod", left - (text_width("lod") + FONTH/2), top + 80); draw_text("wqd", left - (text_width("wqd") + FONTH/2), top + 160); draw_text("wvt", left - (text_width("wvt") + FONTH/2), top + 240); draw_text("evt", left - (text_width("evt") + FONTH/2), top + 320); formatstring(text)("\f%c%d", rangecolor(curfps, "xwvu", 30, 100, 150), curfps); draw_text(text, ttll - text_width(text), top); formatstring(text)("\f%c%d", rangecolor(lf, "uvwx", 199, 299, 399), lf); draw_text(text, ttll - text_width(text), top + 80); formatstring(text)("\f%c%d", rangecolor(nquads, "uvwx", 3999, 5999, 7999), nquads); draw_text(text, ttll - text_width(text), top + 160); formatstring(text)("\f%c%d", rangecolor(curvert, "uvwx", 3999, 5999, 7999), curvert); draw_text(text, ttll - text_width(text), top + 240); formatstring(text)("\f%c%d", rangecolor(xtraverts, "uvwx", 3999, 5999, 7999), xtraverts); draw_text(text, ttll - text_width(text), top + 320); if(wallclock) draw_text(ltime, ttll - text_width(ltime), top - 90); if(unsavededits) draw_text("U", ttll - text_width("U"), top - 90 - (wallclock ? 2*FONTH/2 : 0)); } else { if(dbgpos) { pushfont("mono"); formatstring(text)("%05.2f YAW", p->yaw); draw_text(text, VIRTW*2 - ( text_width(text) + FONTH ), VIRTH*2 - 17*FONTH/2); formatstring(text)("%05.2f PIT", p->pitch); draw_text(text, VIRTW*2 - ( text_width(text) + FONTH ), VIRTH*2 - 15*FONTH/2); formatstring(text)("%05.2f X ", p->o.x); draw_text(text, VIRTW*2 - ( text_width(text) + FONTH ), VIRTH*2 - 13*FONTH/2); formatstring(text)("%05.2f Y ", p->o.y); draw_text(text, VIRTW*2 - ( text_width(text) + FONTH ), VIRTH*2 - 11*FONTH/2); formatstring(text)("%05.2f Z ", p->o.z); draw_text(text, VIRTW*2 - ( text_width(text) + FONTH ), VIRTH*2 - 9*FONTH/2); popfont(); } defformatstring(c_val)("fps %d", curfps); draw_text(c_val, VIRTW*2 - ( text_width(c_val) + FONTH ), VIRTH*2 - 3*FONTH/2); if(wallclock) draw_text(ltime, VIRTW*2 - text_width(ltime) - FONTH, VIRTH*2 - 5*FONTH/2); if(unsavededits) draw_text("U", VIRTW*2 - text_width("U") - FONTH, VIRTH*2 - (wallclock ? 7 : 5)*FONTH/2); } } else if(wallclock) draw_text(ltime, VIRTW*2 - text_width(ltime) - FONTH, VIRTH*2 - 3*FONTH/2); if(editmode && !hideeditinfopanel) { static int lasteditip = 0; static char *editip = NULL; if(!lasteditip || totalmillis - lasteditip > editinfopanelmillis) { // update edit info panel lasteditip = totalmillis; const char *editipfunc = getalias("updateeditinfopanel"); DELSTRING(editip); editip = executeret(editipfunc); } if(editip && dimeditinfopanel) { int w, h; text_bounds(editip, w, h, -1); draw_text(editip, VIRTW*2 - w - FONTH, VIRTH*13/8 - h, 255, 255, 255, dimeditinfopanel); } dimeditinfopanel += elapsed; if(dimeditinfopanel > 255) dimeditinfopanel = 255; } if(!intermission && lastgametimeupdate!=0) { int cssec = (gametimecurrent+(lastmillis-lastgametimeupdate))/1000; int gtsec = cssec%60; int gtmin = cssec/60; if(gametimedisplay == 1) { int gtmax = gametimemaximum/60000; gtmin = gtmax - gtmin; if(gtsec!=0) { gtmin -= 1; gtsec = 60 - gtsec; } } formatstring(gtime)("%02d:%02d", gtmin, gtsec); if(gametimedisplay) draw_text(gtime, (VIRTW-225-10)*2 - (text_width(gtime)/2 + FONTH/2), 20); } if(hidevote < 2 && multiplayer(NULL)) { extern votedisplayinfo *curvote; if(curvote && curvote->millis >= totalmillis && !(hidevote == 1 && curvote->localplayervoted && curvote->result == VOTE_NEUTRAL)) { const int left = 2 * HUDPOS_X_BOTTOMLEFT, top = VIRTH; defformatstring(str)("%s called a vote:", curvote->owner ? colorname(curvote->owner) : ""); draw_text(str, left, top + 240, 255, 255, 255, votealpha); draw_text(curvote->desc, left, top + 320, 255, 255, 255, votealpha); draw_text("----", left, top + 400, 255, 255, 255, votealpha); formatstring(str)("%d yes vs. %d no", curvote->stats[VOTE_YES], curvote->stats[VOTE_NO]); draw_text(str, left, top + 480, 255, 255, 255, votealpha); switch(curvote->result) { case VOTE_NEUTRAL: drawvoteicon(left, top, 0, 0, false); if(!curvote->localplayervoted) draw_text("\f3press F1/F2 to vote yes or no", left, top+560, 255, 255, 255, votealpha); break; default: drawvoteicon(left, top, (curvote->result-1)&1, 1, false); formatstring(str)("\f3vote %s", curvote->result == VOTE_YES ? "PASSED" : "FAILED"); draw_text(str, left, top + 560, 255, 255, 255, votealpha); break; } } } //else draw_textf("%c%d here F1/F2 will be praised during a vote", 20*2, VIRTH+560, '\f', 0); // see position (left/top) setting in block above if(menu) rendermenu(); else if(command) renderdoc(40, VIRTH, max(commandh*2 - VIRTH, 0)); if(!hidespecthud && !menu && p->state==CS_DEAD && p->spectatemode<=SM_DEATHCAM) { glLoadIdentity(); glOrtho(0, VIRTW*3/2, VIRTH*3/2, 0, -1, 1); const int left = (VIRTW)*3/2, top = (VIRTH*3/2)*3/4; draw_textf("SPACE to change view", left - (text_width("SCROLL to change player") + FONTH/2), top); if(multiplayer(NULL) || watchingdemo) draw_textf("SCROLL to change player", left - (text_width("SCROLL to change player") + FONTH/2), top+80); } extern void renderhudtexturepreviews(); if(editmode) renderhudtexturepreviews(); /* * / glLoadIdentity(); glOrtho(0, VIRTW*3/2, VIRTH*3/2, 0, -1, 1); const int tbMSGleft = (VIRTW*3/2)*5/6; const int tbMSGtop = (VIRTH*3/2)*7/8; draw_textf("!TEST BUILD!", tbMSGleft, tbMSGtop); / * */ if(showspeed && !menu) { glLoadIdentity(); glPushMatrix(); glOrtho(0, VIRTW, VIRTH, 0, -1, 1); glScalef(0.8, 0.8, 1); draw_textf("Speed: %.2f", VIRTW/2, VIRTH, p->vel.magnitudexy()); glPopMatrix(); } drawscores(); if(!hidespecthud && spectating && player1->spectatemode!=SM_DEATHCAM) { glLoadIdentity(); glOrtho(0, VIRTW, VIRTH, 0, -1, 1); const char *specttext = "GHOST"; if(player1->team == TEAM_SPECT) specttext = "GHOST"; else if(player1->team == TEAM_CLA_SPECT) specttext = "[CLA]"; else if(player1->team == TEAM_RVSF_SPECT) specttext = "[RVSF]"; draw_text(specttext, VIRTW/40, VIRTH/10*7); if(is_spect) { defformatstring(name)("Player %s", colorname(players[player1->followplayercn])); draw_text(name, VIRTW/40, VIRTH/10*8); } } if(p->state == CS_ALIVE || (p->state == CS_DEAD && p->spectatemode == SM_DEATHCAM)) { glLoadIdentity(); glOrtho(0, VIRTW/2, VIRTH/2, 0, -1, 1); if(p->state == CS_ALIVE && !hidehudequipment) { pushfont("huddigits"); draw_textf("%d", HUDPOS_HEALTH + HUDPOS_NUMBERSPACING, 823, p->health); if(p->armour) draw_textf("%d", HUDPOS_ARMOUR + HUDPOS_NUMBERSPACING, 823, p->armour); if(p->weaponsel && valid_weapon(p->weaponsel->type)) { glMatrixMode(GL_MODELVIEW); if (p->weaponsel->type!=GUN_GRENADE) p->weaponsel->renderstats(); else if (p->prevweaponsel->type==GUN_AKIMBO || p->prevweaponsel->type==GUN_PISTOL) p->weapons[p->akimbo ? GUN_AKIMBO : GUN_PISTOL]->renderstats(); else p->weapons[getprevweaponsel(p)]->renderstats(); if(p->mag[GUN_GRENADE]) p->weapons[GUN_GRENADE]->renderstats(); glMatrixMode(GL_PROJECTION); } popfont(); } if((m_flags || m_teammode) && !hideteamscorehud) { glLoadIdentity(); glOrtho(0, VIRTW, VIRTH, 0, -1, 1); glColor4f(1.0f, 1.0f, 1.0f, 0.2f); turn_on_transparency(255); int scores[4], offs = m_flags ? 0 : 2; calcteamscores(scores); const char *cc = scores[offs] > 99 || scores[offs + 1] > 99 ? "31" : "55"; if(!offs || scores[2] || scores[3]) loopi(2) // flag state or frag-counter { bool inbase = flaginfos[i].state == CTFF_INBASE || offs; drawctficon(i*120+VIRTW/4.0f*3.0f, 1650, 120, i + (inbase || flagscorehudtransparency == 2 ? 0 : 2), offs / 2, 1/4.0f, inbase || !flagscorehudtransparency ? 255 : 100); if(m_teammode) { defformatstring(count)("\f%c%d", cc[i], scores[i + offs]); draw_text(count, i * 120 + VIRTW / 4.0f * 3.0f + 60 - text_width(count) / 2, 1590); } } if(!offs) { // big flag-stolen icon int ft = 0; if((flaginfos[0].state==CTFF_STOLEN && flaginfos[0].actor == p && flaginfos[0].ack) || (flaginfos[1].state==CTFF_STOLEN && flaginfos[1].actor == p && flaginfos[1].ack && ++ft)) { drawctficon(VIRTW-225-10, VIRTH*5/8, 225, ft, 1, 1/2.0f, (sinf(lastmillis/100.0f)+1.0f) *128); } } } } if(!hidehudmsgs) hudmsgs.render(); glLoadIdentity(); glOrtho(0, VIRTW, VIRTH, 0, -1, 1); if(command) rendercommand(HUDPOS_X_BOTTOMLEFT, HUDPOS_Y_BOTTOMLEFT, VIRTW - FONTH); glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); glEnable(GL_DEPTH_TEST); glMatrixMode(GL_MODELVIEW); } Texture *startscreen = NULL; void loadingscreen(const char *fmt, ...) { if(!startscreen) startscreen = textureload("packages/misc/startscreen.png", 3); glEnable(GL_TEXTURE_2D); glDisable(GL_DEPTH_TEST); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, VIRTW, VIRTH, 0, -1, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glClearColor(0, 0, 0, 1); glColor3f(1, 1, 1); loopi(fmt ? 1 : 2) { glClear(GL_COLOR_BUFFER_BIT); quad(startscreen->id, (VIRTW-VIRTH)/2, 0, VIRTH, 0, 0, 1); if(fmt) { glEnable(GL_BLEND); defvformatstring(str, fmt, fmt); int w = text_width(str); draw_text(str, w>=VIRTW ? 0 : (VIRTW-w)/2, VIRTH*3/4); glDisable(GL_BLEND); } SDL_GL_SwapWindow(screen); } glDisable(GL_TEXTURE_2D); glEnable(GL_DEPTH_TEST); } static void bar(float bar, int o, float r, float g, float b) { int side = 2*FONTH; float x1 = side, x2 = bar*(VIRTW*1.2f-2*side)+side; float y1 = o*FONTH; glColor3f(0.3f, 0.3f, 0.3f); glBegin(GL_TRIANGLE_STRIP); loopk(10) { float c = 1.2f*cosf(PI/2 + k/9.0f*PI), s = 1 + 1.2f*sinf(PI/2 + k/9.0f*PI); glVertex2f(x2 - c*FONTH, y1 + s*FONTH); glVertex2f(x1 + c*FONTH, y1 + s*FONTH); } glEnd(); glColor3f(r, g, b); glBegin(GL_TRIANGLE_STRIP); loopk(10) { float c = cosf(PI/2 + k/9.0f*PI), s = 1 + sinf(PI/2 + k/9.0f*PI); glVertex2f(x2 - c*FONTH, y1 + s*FONTH); glVertex2f(x1 + c*FONTH, y1 + s*FONTH); } glEnd(); } void show_out_of_renderloop_progress(float bar1, const char *text1, float bar2, const char *text2) // also used during loading { c2skeepalive(); glDisable(GL_DEPTH_TEST); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(0, VIRTW*1.2f, VIRTH*1.2f, 0, -1, 1); glLineWidth(3); if(text1) { bar(1, 1, 0.1f, 0.1f, 0.1f); if(bar1>0) bar(bar1, 1, 0.2f, 0.2f, 0.2f); } if(bar2>0) { bar(1, 3, 0.1f, 0.1f, 0.1f); bar(bar2, 3, 0.2f, 0.2f, 0.2f); } glLineWidth(1); glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); if(text1) draw_text(text1, 2*FONTH, 1*FONTH + FONTH/2); if(bar2>0) draw_text(text2, 2*FONTH, 3*FONTH + FONTH/2); glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glEnable(GL_DEPTH_TEST); SDL_GL_SwapWindow(screen); } assaultcube-1.2.0.2.1/source/src/rendermodel.cpp000066400000000000000000001072431352165075300214350ustar00rootroot00000000000000#include "cube.h" VARP(animationinterpolationtime, 0, 150, 1000); model *loadingmodel = NULL; mapmodelattributes loadingattributes; #include "tristrip.h" #include "modelcache.h" #include "vertmodel.h" #include "md2.h" #include "md3.h" #define checkmdl if(!loadingmodel) { conoutf("not loading a model"); flagmapconfigerror(LWW_MODELERR); scripterr(); return; } void mdlcullface(int *cullface) { checkmdl; loadingmodel->cullface = *cullface!=0; } COMMAND(mdlcullface, "i"); void mdlvertexlight(int *vertexlight) { checkmdl; loadingmodel->vertexlight = *vertexlight!=0; } COMMAND(mdlvertexlight, "i"); void mdltranslucent(int *translucency) { checkmdl; loadingmodel->translucency = *translucency/100.0f; } COMMAND(mdltranslucent, "i"); void mdlalphatest(int *alphatest) { checkmdl; loadingmodel->alphatest = *alphatest/100.0f; } COMMAND(mdlalphatest, "i"); void mdlalphablend(int *alphablend) //ALX Alpha channel models { checkmdl; loadingmodel->alphablend = *alphablend!=0; } COMMAND(mdlalphablend, "i"); void mdlscale(int *percent) { checkmdl; float scale = 0.3f; if(*percent>0) scale = *percent/100.0f; else if(*percent<0) scale = 0.0f; loadingmodel->scale = scale; } COMMAND(mdlscale, "i"); void mdltrans(float *x, float *y, float *z) { checkmdl; loadingmodel->translate = vec(*x, *y, *z); } COMMAND(mdltrans, "fff"); void mdlshadowdist(int *dist) { checkmdl; loadingmodel->shadowdist = *dist; } COMMAND(mdlshadowdist, "i"); void mdlcachelimit(int *limit) { checkmdl; loadingmodel->cachelimit = *limit; } COMMAND(mdlcachelimit, "i"); const char *mdlattrnames[] = { "keywords", "desc", "defaults", "usage", "author", "license", "distribution", "version", "requires", "" }; void mdlattribute(char *attrname, char *val) { checkmdl; int i = getlistindex(attrname, mdlattrnames, true, MMA_NUM); if(i < MMA_NUM) { DELSTRING(loadingattributes.n[i]); filtertext(val, val, FTXT__MDLATTR); if(*val) loadingattributes.n[i] = newstring(val); } } COMMAND(mdlattribute, "ss"); VAR(mapmodelchanged, 0, 0, 1); vector mapmodels; const char *mmpath = "mapmodels/"; const char *mmshortname(const char *name) { return !strncmp(name, mmpath, strlen(mmpath)) ? name + strlen(mmpath) : name; } void mapmodel(int *rad, int *h, int *zoff, char *scale, char *name, char *flags) { if(*scale && *name) // ignore "mapmodel" commands with insufficient parameters { if(!_ignoreillegalpaths && !strchr(name, '/') && !strchr(name, '\\')) { flagmapconfigerror(LWW_CONFIGERR * 2); } // throw errors for unconverted mapmodels (unspecific, because not all get detected) intret(mapmodels.length()); mapmodelinfo &mmi = mapmodels.add(); mmi.rad = *rad; mmi.h = *h; mmi.zoff = *zoff; mmi.scale = atof(scale); mmi.flags = 0; if(*flags) mmi.flags = ATOI(flags); if(mmi.scale < 0.25f || mmi.scale > 4.0f) { mmi.scale = 1.0f; if(strcmp(scale, "0")) { flagmapconfigerror(LWW_CONFIGERR * 2); scripterr(); } } mmi.m = NULL; filtertext(name, name, FTXT__MEDIAFILEPATH); formatstring(mmi.name)("%s%s", mmpath, name[0] == '.' && name[1] == '/' ? name + 2 : name); mapmodelchanged = 1; flagmapconfigchange(); } else { flagmapconfigerror(LWW_CONFIGERR * 2); scripterr(); } } COMMAND(mapmodel, "iiisss"); void mapmodelreset() { if(execcontext==IEXC_MAPCFG) { mapmodels.shrink(0); mapmodelchanged = 1; } } COMMAND(mapmodelreset, ""); mapmodelinfo *getmminfo(int i) { return mapmodels.inrange(i) ? &mapmodels[i] : NULL; } COMMANDF(mapmodelslotname, "i", (int *idx) { result(mapmodels.inrange(*idx) ? mmshortname(mapmodels[*idx].name) : ""); }); // returns the model name that is configured in a certain slot COMMANDF(mapmodelslotbyname, "s", (char *name) // returns the slot(s) that a certain mapmodel is configured in { string res = ""; loopv(mapmodels) if(!strcmp(name, mapmodels[i].name)) concatformatstring(res, "%s%d", *res ? " " : "", i); result(res); }); void mapmodelslotusage(int *n) // returns all entity indices that contain a mapmodel of slot n { string res = ""; loopv(ents) if(ents[i].type == MAPMODEL && ents[i].attr2 == *n) concatformatstring(res, "%s%d", i ? " " : "", i); result(*res ? res : (mapmodels.inrange(*n) && (mapmodels[*n].flags & MMF_REQUIRED) ? " " : res)); } COMMAND(mapmodelslotusage, "i"); void deletemapmodelslot(int *n, char *opt) // delete mapmodel slot - only if unused or "purge" is specified { EDITMP("deletemapmodelslot"); if(!mapmodels.inrange(*n)) return; bool purgeall = !strcmp(opt, "purge"); if(!purgeall) loopv(ents) if(ents[i].type == MAPMODEL && ents[i].attr2 == *n) { conoutf("mapmodel slot #%d is in use: can't delete", *n); return; } int deld = 0; loopv(ents) if(ents[i].type == MAPMODEL) { entity &e = ents[i]; if(e.attr2 == *n) { // delete entity deleted_ents.add(e); memset(&e, 0, sizeof(persistent_entity)); e.type = NOTUSED; deld++; } else if(e.attr2 > *n) e.attr2--; // adjust models in higher slots } mapmodels.remove(*n); defformatstring(s)(" (%d mapmodels purged)", deld); conoutf("mapmodel slot #%d deleted%s", *n, deld ? s : ""); unsavededits++; mapmodelchanged = 1; hdr.flags |= MHF_AUTOMAPCONFIG; // requires automapcfg } COMMAND(deletemapmodelslot, "is"); void editmapmodelslot(int *n, char *rad, char *h, char *zoff, char *scale, char *name) // edit slot parameters != "" { string res = ""; if(mapmodels.inrange(*n)) { mapmodelinfo &mmi = mapmodels[*n]; if((*rad || *h || *zoff || *scale || *name) && !noteditmode("editmapmodelslot") && !multiplayer("editmapmodelslot")) { // change attributes if(*rad) mmi.rad = strtol(rad, NULL, 0); if(*h) mmi.h = strtol(h, NULL, 0); if(*zoff) mmi.zoff = strtol(zoff, NULL, 0); float s = atof(scale); if(s < 0.25f || s > 4.0f) s = 1.0f; if(*scale) mmi.scale = s; mmi.m = NULL; if(*name) formatstring(mmi.name)("%s%s", mmpath, name); unsavededits++; mapmodelchanged = 1; hdr.flags |= MHF_AUTOMAPCONFIG; // requires automapcfg } formatstring(res)("%d %d %d %s \"%s\"", mmi.rad, mmi.h, mmi.zoff, floatstr(mmi.scale, true), mmshortname(mmi.name)); // give back all current attributes } result(res); } COMMAND(editmapmodelslot, "isssss"); struct tempmmslot { mapmodelinfo m; vector oldslot; bool used; }; int tempmmcmp(tempmmslot *a, tempmmslot *b) { int n = strcmp(a->m.name, b->m.name); if(n) return n; if(a->m.rad != b->m.rad) return a->m.rad - b->m.rad; if(a->m.h != b->m.h) return a->m.h - b->m.h; if(a->m.zoff != b->m.zoff) return a->m.zoff - b->m.zoff; if(a->m.scale != b->m.scale) return int((a->m.scale - b->m.scale) * 1e6); return 0; } int tempmmsort(tempmmslot *a, tempmmslot *b) { int n = tempmmcmp(a, b); return n ? n : a->oldslot[0] - b->oldslot[0]; } int tempmmunsort(tempmmslot *a, tempmmslot *b) { return a->oldslot[0] - b->oldslot[0]; } void sortmapmodelslots(char **args, int numargs) { bool nomerge = false, mergeused = false, nosort = false, unknownarg = false; loopi(numargs) if(args[i][0]) { if(!strcasecmp(args[i], "nomerge")) nomerge = true; else if(!strcasecmp(args[i], "nosort")) nosort = true; else if(!strcasecmp(args[i], "mergeused")) mergeused = true; else { conoutf("sortmapmodelslots: unknown argument \"%s\"", args[i]); unknownarg = true; } } EDITMP("sortmapmodelslots"); if(unknownarg || mapmodels.length() < 3) return; vector tempslots; loopv(mapmodels) { tempslots.add().m = mapmodels[i]; tempslots.last().oldslot.add(i); tempslots.last().used = false; } loopv(ents) if(ents[i].type == MAPMODEL && tempslots.inrange(ents[i].attr2)) tempslots[ents[i].attr2].used = true; tempslots.sort(tempmmsort); // remove double entries if(!nomerge) loopvrev(tempslots) if(i > 0) { tempmmslot &s1 = tempslots[i], &s0 = tempslots[i - 1]; if(!tempmmcmp(&s0, &s1) && (mergeused || !s0.used || !s1.used)) { if(s1.used) s0.used = true; loopvj(s1.oldslot) s0.oldslot.add(s1.oldslot[j]); tempslots.remove(i); } } if(nosort) tempslots.sort(tempmmunsort); // create translation table uchar newslot[256]; loopk(256) newslot[k] = k; loopv(tempslots) { tempmmslot &t = tempslots[i]; loopvj(t.oldslot) { if(t.oldslot[j] < 256) newslot[t.oldslot[j]] = i; } } // translate all mapmodel entities loopv(ents) if(ents[i].type == MAPMODEL) ents[i].attr2 = newslot[ents[i].attr2]; conoutf("%d mapmodel slots%s, %d %sslots merged", tempslots.length(), nosort ? "" : " sorted", mapmodels.length() - tempslots.length(), mergeused ? "" : "unused "); // rewrite mapmodel slot list mapmodels.shrink(tempslots.length()); loopv(tempslots) { mapmodels[i] = tempslots[i].m; mapmodels[i].m = NULL; } unsavededits++; mapmodelchanged = 1; hdr.flags |= MHF_AUTOMAPCONFIG; // requires automapcfg } COMMAND(sortmapmodelslots, "v"); hashtable mdlregistry; void setmodelattributes(const char *name, mapmodelattributes &ma) { if(!strchr(name, ' ') && !strncmp(name, mmpath, strlen(mmpath))) name += strlen(mmpath); // for now: ignore mapmodels with spaces in the path (next release: ban them) else return; // we only want mapmodels mapmodelattributes **mrp = mdlregistry.access(name), *mr = mrp ? *mrp : NULL, *r = mr; if(!r) { r = new mapmodelattributes; copystring(r->name, name); } loopi(MMA_NUM) { if(ma.n[i]) { if(!r->n[i]) mapmodelchanged = 1; DELSTRING(r->n[i]); // overwrite existing attributes r->n[i] = ma.n[i]; ma.n[i] = NULL; } } if(!mr) mdlregistry.access(r->name, r); } void mapmodelregister_(char **args, int numargs) // read model attributes without loading the model { mapmodelattributes ma; if(numargs > 0) // need a name at least { defformatstring(p)("%s%s", mmpath, args[0]); loopirev(--numargs < MMA_NUM ? numargs : MMA_NUM) ma.n[i] = *args[i + 1] ? newstring(args[i + 1]) : NULL; setmodelattributes(p, ma); } } COMMANDN(mapmodelregister, mapmodelregister_, "v"); void mapmodelregistryclear() { enumerate(mdlregistry, mapmodelattributes *, m, loopi(MMA_NUM) DELSTRING(m->n[i]); DELETEP(m); ); mdlregistry.clear(); mapmodelchanged = 1; } COMMAND(mapmodelregistryclear, ""); hashtable mdllookup; hashtable mdlnotfound; bool silentmodelloaderror = false; model *loadmodel(const char *name, int i, bool trydl) // load model by name (optional) or from mapmodels[i] { if(!name) // name == NULL -> get index i from mapmodels[] { if(!mapmodels.inrange(i)) return NULL; mapmodelinfo &mmi = mapmodels[i]; if(mmi.m) return mmi.m; // mapmodels[i] was already loaded name = mmi.name; } if(mdlnotfound.access(name)) return NULL; // already tried to find that earlier -> not available model **mm = mdllookup.access(name); model *m; if(mm) m = *mm; // a model of that name is already loaded else { pushscontext(IEXC_MDLCFG); m = new md2(name); // try md2 loadingmodel = m; loopi(MMA_NUM) DELSTRING(loadingattributes.n[i]); if(!m->load()) // md2 didn't load { delete m; m = new md3(name); // try md3 loadingmodel = m; if(!m->load()) // md3 didn't load -> we don't have that model { delete m; m = loadingmodel = NULL; if(trydl && !strncmp(name, mmpath, strlen(mmpath))) requirepackage(PCK_MAPMODEL, name); else { if(!silentmodelloaderror) conoutf("\f3failed to load model %s", name); mdlnotfound.access(newstring(name), 0); // do not search for this name again } } } popscontext(); if(loadingmodel && m) { mdllookup.access(m->name(), m); setmodelattributes(m->name(), loadingattributes); if(m->shadowdist && !m->cullface) { conoutf("\f3mapmodel config error: disabling face culling in combination with shadows will cause visual errors (%s)", m->name()); flagmapconfigerror(LWW_MODELERR); } } loadingmodel = NULL; } if(mapmodels.inrange(i) && !mapmodels[i].m) mapmodels[i].m = m; return m; } void cleanupmodels() { enumerate(mdllookup, model *, m, m->cleanup()); } void resetmdlnotfound() { enumeratek(mdlnotfound, const char *, m, delstring(m)); mdlnotfound.clear(); } void getmapmodelattributes(char *name, char *attr) { const char *res = NULL; mapmodelattributes **ap = mdlregistry.access(name), *a = ap ? *ap : NULL; if(a) { int i = getlistindex(attr, mdlattrnames, true, MMA_NUM); if(i < MMA_NUM) res = a->n[i]; else { string s = ""; loopi(MMA_NUM) if(a->n[i]) concatformatstring(s, " %s:\"%s\"", mdlattrnames[i], a->n[i]); conoutf("%s:%s", a->name, *s ? s : " "); } } result(res ? res : ""); } COMMAND(getmapmodelattributes, "ss"); void updatemapmodeldependencies() { loopv(mapmodels) mapmodels[i].flags = 0; loopv(ents) if(ents[i].type == MAPMODEL && mapmodels.inrange(ents[i].attr2)) mapmodels[ents[i].attr2].flags |= MMF_TEMP_USED; bool foundone = true; while(foundone) { foundone = false; loopvk(mapmodels) if(mapmodels[k].flags & MMF_TEMP_USED) { const char *name = mmshortname(mapmodels[k].name); mapmodelattributes **ap = mdlregistry.access(name), *a = ap ? *ap : NULL; const char *dep = a ? a->n[MMA_REQUIRES] : NULL; if(dep && *dep) { bool found = false; loopv(mapmodels) if(!strcmp(mmshortname(mapmodels[i].name), dep)) { if(!(mapmodels[i].flags & MMF_TEMP_USED)) foundone = true; mapmodels[i].flags |= MMF_REQUIRED | MMF_TEMP_USED; found = true; } if(!found) { defformatstring(cmd)("mapmodel 0 0 0 0 \"%s\" %d", dep, MMF_REQUIRED); execute(cmd); foundone = true; clientlogf(" mapmodel %s added to config, because %s requires it", dep, name); } } } } loopv(mapmodels) mapmodels[i].flags &= MMF_CONFIGMASK; } COMMAND(updatemapmodeldependencies, ""); static int mmasortorder = 0; int mmasort(mapmodelattributes **a, mapmodelattributes **b) { return strcmp((*a)->name, (*b)->name); } int mmasort2(mapmodelattributes **a, mapmodelattributes **b) { const char *aa = (*a)->n[mmasortorder], *bb = (*b)->n[mmasortorder], nn[2] = { 127, 0 }; int i = strcmp(aa ? aa : nn, bb ? bb : nn); return i ? i : (*a)->tmp - (*b)->tmp; } void writemapmodelattributes() { stream *f = openfile("config" PATHDIVS "mapmodelattributes.cfg", "w"); if(f) { vector mmas; enumerate(mdlregistry, mapmodelattributes *, m, mmas.add(m)); mmas.sort(mmasort); f->printf("// automatically written on exit. this is cached information extracted from model configs. no point in editing it.\n// [path %s]\n", conc(mdlattrnames, MMA_NUM, true)); // memory leak, but w/e loopv(mmas) { f->printf("\nmapmodelregister %s", mmas[i]->name); loopj(MMA_NUM) f->printf(" %s", escapestring(mmas[i]->n[j])); // escapestring can handle NULL } f->printf("\n\n"); delete f; } } void listallmapmodelattributes(char **args, int numargs) // create a list of mapmodel paths and selected attributes { // parse argument list vector opts; loopi(MMA_NUM) opts.add(mdlattrnames[i]); opts.add("sortby:"); opts.add("explodekeywords"); opts.add(""); vector a; loopi(numargs) a.add(getlistindex(args[i], (const char **)opts.getbuf(), false, opts.length())); bool explodekeywords = false; loopi(numargs) if(a[i] == MMA_NUM + 1) explodekeywords = true; // build list of mapmodels (explode if necessary) vector mmas, emmas; enumerate(mdlregistry, mapmodelattributes *, m, { if(explodekeywords && m->n[MMA_KEYWORDS] && listlen(m->n[MMA_KEYWORDS]) > 1) { vector keys; explodelist(m->n[MMA_KEYWORDS], keys); loopv(keys) { mmas.add(new mapmodelattributes(*m)); emmas.add(mmas.last())->n[MMA_KEYWORDS] = keys[i]; } } else mmas.add(m); }); // sort the list mmas.sort(mmasort); loopirev(numargs - 1) if(a[i] == MMA_NUM) // sortby: { loopvj(mmas) mmas[j]->tmp = j; // store last sort order, because quicksort is not stable if((mmasortorder = a[i + 1]) < MMA_NUM) mmas.sort(mmasort2); } // assemble output vector res; loopv(mmas) { cvecprintf(res, "%s", mmas[i]->name); loopvj(a) if(a[j] < MMA_NUM) cvecprintf(res, " %s", escapestring(mmas[i]->n[a[j]])); res.add('\n'); } loopv(emmas) { delstring(emmas[i]->n[MMA_KEYWORDS]); delete emmas[i]; } // only delete what was exploded resultcharvector(res, -1); } COMMAND(listallmapmodelattributes, "v"); VARP(dynshadow, 0, 40, 100); VARP(dynshadowdecay, 0, 1000, 3000); struct batchedmodel { vec o; int anim, varseed, tex; float roll, yaw, pitch, speed; int basetime; playerent *d; int attached; float scale; }; struct modelbatch { model *m; vector batched; }; static vector batches; static vector modelattached; static int numbatches = -1; void startmodelbatches() { numbatches = 0; modelattached.setsize(0); } batchedmodel &addbatchedmodel(model *m) { modelbatch *b = NULL; if(m->batch>=0 && m->batchbatch]->m==m) b = batches[m->batch]; else { if(numbatchesbatched.setsize(0); } else b = batches.add(new modelbatch); b->m = m; m->batch = numbatches++; } return b->batched.add(); } void renderbatchedmodel(model *m, batchedmodel &b) { modelattach *a = NULL; if(b.attached>=0) a = &modelattached[b.attached]; if(stenciling) { m->render(b.anim|ANIM_NOSKIN, b.varseed, b.speed, b.basetime, b.o, b.roll, b.yaw, b.pitch, b.d, a, b.scale); return; } int x = (int)b.o.x, y = (int)b.o.y; if(!OUTBORD(x, y)) { sqr *s = S(x, y); glColor3ub(s->r, s->g, s->b); } else glColor3f(1, 1, 1); m->setskin(b.tex); if(b.anim&ANIM_TRANSLUCENT) { glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); m->render(b.anim|ANIM_NOSKIN, b.varseed, b.speed, b.basetime, b.o, b.roll, b.yaw, b.pitch, b.d, a, b.scale); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glDepthFunc(GL_LEQUAL); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); GLfloat color[4]; glGetFloatv(GL_CURRENT_COLOR, color); glColor4f(color[0], color[1], color[2], m->translucency); } m->render(b.anim, b.varseed, b.speed, b.basetime, b.o, b.roll, b.yaw, b.pitch, b.d, a, b.scale); if(b.anim&ANIM_TRANSLUCENT) { glDepthFunc(GL_LESS); glDisable(GL_BLEND); } } void renderbatchedmodelshadow(model *m, batchedmodel &b) { int x = (int)b.o.x, y = (int)b.o.y; if(OUTBORD(x, y)) return; sqr *s = S(x, y); vec center(b.o.x, b.o.y, s->floor); if(s->type==FHF) center.z -= s->vdelta/4.0f; if(dynshadowquad && center.z-0.1f>b.o.z) return; center.z += 0.1f; modelattach *a = NULL; if(b.attached>=0) a = &modelattached[b.attached]; float intensity = dynshadow/100.0f; if(dynshadowdecay) switch(b.anim&ANIM_INDEX) { case ANIM_DECAY: case ANIM_LYING_DEAD: intensity *= max(1.0f - float(lastmillis - b.basetime)/dynshadowdecay, 0.0f); break; } glColor4f(0, 0, 0, intensity); m->rendershadow(b.anim, b.varseed, b.speed, b.basetime, dynshadowquad ? center : b.o, b.yaw, a); } static int sortbatchedmodels(const batchedmodel *x, const batchedmodel *y) { if(x->tex < y->tex) return -1; if(x->tex > y->tex) return 1; return 0; } struct translucentmodel { model *m; batchedmodel *batched; float dist; }; static int sorttranslucentmodels(const translucentmodel *x, const translucentmodel *y) { if(x->dist > y->dist) return -1; if(x->dist < y->dist) return 1; return 0; } void clearmodelbatches() { numbatches = -1; } void endmodelbatches(bool flush) { vector translucent; loopi(numbatches) { modelbatch &b = *batches[i]; if(b.batched.empty()) continue; loopvj(b.batched) if(b.batched[j].tex) { b.batched.sort(sortbatchedmodels); break; } b.m->startrender(); loopvj(b.batched) { batchedmodel &bm = b.batched[j]; if(bm.anim&ANIM_TRANSLUCENT) { translucentmodel &tm = translucent.add(); tm.m = b.m; tm.batched = &bm; tm.dist = camera1->o.dist(bm.o); continue; } renderbatchedmodel(b.m, bm); } if(dynshadow && b.m->hasshadows() && (!reflecting || refracting) && (!effective_stencilshadow || !hasstencil || stencilbits < 8)) { loopvj(b.batched) { batchedmodel &bm = b.batched[j]; if(bm.anim&ANIM_TRANSLUCENT) continue; renderbatchedmodelshadow(b.m, bm); } } b.m->endrender(); } if(translucent.length()) { translucent.sort(sorttranslucentmodels); model *lastmodel = NULL; loopv(translucent) { translucentmodel &tm = translucent[i]; if(lastmodel!=tm.m) { if(lastmodel) lastmodel->endrender(); (lastmodel = tm.m)->startrender(); } renderbatchedmodel(tm.m, *tm.batched); } if(lastmodel) lastmodel->endrender(); } if(flush) clearmodelbatches(); } const int dbgmbatch = 0; //VAR(dbgmbatch, 0, 0, 1); VARP(popdeadplayers, 0, 0, 1); void rendermodel(const char *mdl, int anim, int tex, float rad, const vec &o, float roll, float yaw, float pitch, float speed, int basetime, playerent *d, modelattach *a, float scale) { if(popdeadplayers && d && a) { int acv = anim&ANIM_INDEX; if( acv == ANIM_DECAY || acv == ANIM_LYING_DEAD || acv == ANIM_CROUCH_DEATH || acv == ANIM_DEATH ) return; } model *m = loadmodel(mdl); if(!m || (stenciling && (m->shadowdist <= 0 || anim&ANIM_TRANSLUCENT))) return; if(rad >= 0) { if(!rad) { rad = m->radius; if(roll != 0 || pitch != 0) rad = max(m->radius, m->zradius); // FIXME: this assumes worst-case even for small angles and should be eased up (especially for lamp posts) rad *= scale; } if(isoccluded(camera1->o.x, camera1->o.y, o.x-rad, o.y-rad, rad*2)) return; } if(stenciling && d && !raycubelos(camera1->o, o, d->radius)) { vec target(o); target.z += d->eyeheight; if(!raycubelos(camera1->o, target, d->radius)) return; } int varseed = 0; if(d) switch(anim&ANIM_INDEX) { case ANIM_DEATH: case ANIM_LYING_DEAD: varseed = (int)(size_t)d + d->lastpain; break; default: varseed = (int)(size_t)d + d->lastaction; break; } if(a) for(int i = 0; a[i].tag; i++) { if(a[i].name) a[i].m = loadmodel(a[i].name); //if(a[i].m && a[i].m->type()!=m->type()) a[i].m = NULL; } if(numbatches>=0 && !dbgmbatch) { batchedmodel &b = addbatchedmodel(m); b.o = o; b.anim = anim; b.varseed = varseed; b.tex = tex; b.roll = roll; b.yaw = yaw; b.pitch = pitch; b.speed = speed; b.basetime = basetime; b.d = d; b.attached = a ? modelattached.length() : -1; if(a) for(int i = 0;; i++) { modelattached.add(a[i]); if(!a[i].tag) break; } b.scale = scale; return; } if(stenciling) { m->startrender(); m->render(anim|ANIM_NOSKIN, varseed, speed, basetime, o, 0, yaw, pitch, d, a, scale); m->endrender(); return; } m->startrender(); int x = (int)o.x, y = (int)o.y; if(!OUTBORD(x, y)) { sqr *s = S(x, y); if(!(anim&ANIM_TRANSLUCENT) && dynshadow && m->hasshadows() && (!reflecting || refracting) && (!effective_stencilshadow || !hasstencil || stencilbits < 8)) { vec center(o.x, o.y, s->floor); if(s->type==FHF) center.z -= s->vdelta/4.0f; if(!dynshadowquad || center.z-0.1f<=o.z) { center.z += 0.1f; float intensity = dynshadow/100.0f; if(dynshadowdecay) switch(anim&ANIM_INDEX) { case ANIM_DECAY: case ANIM_LYING_DEAD: intensity *= max(1.0f - float(lastmillis - basetime)/dynshadowdecay, 0.0f); break; } glColor4f(0, 0, 0, intensity); m->rendershadow(anim, varseed, speed, basetime, dynshadowquad ? center : o, yaw, a); } } glColor3ub(s->r, s->g, s->b); } else glColor3f(1, 1, 1); m->setskin(tex); if(anim&ANIM_TRANSLUCENT) { glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); m->render(anim|ANIM_NOSKIN, varseed, speed, basetime, o, 0, yaw, pitch, d, a, scale); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glDepthFunc(GL_LEQUAL); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); GLfloat color[4]; glGetFloatv(GL_CURRENT_COLOR, color); glColor4f(color[0], color[1], color[2], m->translucency); } m->render(anim, varseed, speed, basetime, o, 0, yaw, pitch, d, a, scale); if(anim&ANIM_TRANSLUCENT) { glDepthFunc(GL_LESS); glDisable(GL_BLEND); } m->endrender(); } int findanim(const char *name) { const char *names[] = { "idle", "run", "attack", "pain", "jump", "land", "flipoff", "salute", "taunt", "wave", "point", "crouch idle", "crouch walk", "crouch attack", "crouch pain", "crouch death", "death", "lying dead", "flag", "gun idle", "gun shoot", "gun reload", "gun throw", "mapmodel", "trigger", "decay", "all" }; loopi(sizeof(names)/sizeof(names[0])) if(!strcmp(name, names[i])) return i; return -1; } void loadskin(const char *dir, const char *altdir, Texture *&skin) // model skin sharing { bool old_silent_texture_load = silent_texture_load; silent_texture_load = true; #define ifnoload if((skin = textureload(path))==notexture) defformatstring(path)("packages/models/%s/skin.jpg", dir); ifnoload { strcpy(path+strlen(path)-3, "png"); ifnoload { formatstring(path)("packages/models/%s/skin.jpg", altdir); ifnoload { strcpy(path+strlen(path)-3, "png"); ifnoload {}; } } } silent_texture_load = old_silent_texture_load; } void preload_playermodels() { model *playermdl = loadmodel("playermodels"); if(dynshadow && playermdl) playermdl->genshadows(8.0f, 4.0f); loopi(NUMGUNS) { if(i == GUN_CPISTOL) continue; defformatstring(vwep)("weapons/%s/world", guns[i].modelname); model *vwepmdl = loadmodel(vwep); if(dynshadow && vwepmdl) vwepmdl->genshadows(8.0f, 4.0f); } } void preload_entmodels() { extern const char *entmdlnames[]; for(int i = 0; entmdlnames[i][0]; i++) { model *mdl = loadmodel(entmdlnames[i]); if(dynshadow && mdl) mdl->genshadows(8.0f, 2.0f); } static const char *bouncemdlnames[] = { "misc/gib01", "misc/gib02", "misc/gib03", "weapons/grenade/static" }; loopi(sizeof(bouncemdlnames)/sizeof(bouncemdlnames[0])) { model *mdl = loadmodel(bouncemdlnames[i]); if(dynshadow && mdl) mdl->genshadows(8.0f, 2.0f); } } bool preload_mapmodels(bool trydl) { int missing = 0; loopv(mapmodels) mapmodels[i].flags &= ~MMF_TEMP_USED; loopv(ents) { entity &e = ents[i]; if(e.type!=MAPMODEL || !mapmodels.inrange(e.attr2)) continue; mapmodels[ents[i].attr2].flags |= MMF_TEMP_USED; if(e.attr4 && lookuptexture(e.attr4, notexture, trydl) == notexture && (!_ignoreillegalpaths || gettextureslot(e.attr4))) missing++; } loopv(mapmodels) if((mapmodels[i].flags & (MMF_REQUIRED | MMF_TEMP_USED)) && !loadmodel(NULL, i, trydl)) missing++; return !missing; } void renderclient(playerent *d, const char *mdlname, const char *vwepname, int tex) { int anim = ANIM_IDLE|ANIM_LOOP; float speed = 0.0; vec o(d->o); o.z -= d->eyeheight; int basetime = -((int)(size_t)d&0xFFF); if(d->state==CS_DEAD) { if(d==player1 && d->allowmove()) return; if(d->nocorpse) return; d->pitch = 0.1f; anim = ANIM_DEATH; basetime = d->lastpain; int t = lastmillis-d->lastpain; if(t<0 || t>20000) return; if(t>2000) { anim = ANIM_LYING_DEAD|ANIM_NOINTERP|ANIM_LOOP; basetime += 2000; t -= 2000; o.z -= t*t/10000000000.0f*t; } } else if(d->state==CS_EDITING) { anim = ANIM_JUMP|ANIM_END; } else if(d->state==CS_LAGGED) { anim = ANIM_SALUTE|ANIM_LOOP|ANIM_TRANSLUCENT; } else if(lastmillis-d->lastpain<300) { anim = d->crouching ? ANIM_CROUCH_PAIN : ANIM_PAIN; speed = 300.0f/4; basetime = d->lastpain; } else if(d->weaponsel==d->lastattackweapon && lastmillis-d->lastaction<300 && d->lastpainlastaction && !d->weaponsel->reloading && (d->weaponsel->type!=GUN_GRENADE || ((grenades *)d->weaponsel)->cookingmillis>0)) { anim = d->crouching ? ANIM_CROUCH_ATTACK : ANIM_ATTACK; speed = 300.0f/8; basetime = d->lastaction; } else if(!d->onfloor && d->timeinair>50) { anim = (d->crouching ? ANIM_CROUCH_WALK : ANIM_JUMP)|ANIM_END; } else if(!d->move && !d->strafe) { anim = (d->crouching ? ANIM_CROUCH_IDLE : ANIM_IDLE)|ANIM_LOOP; } else { anim = (d->crouching ? ANIM_CROUCH_WALK : ANIM_RUN)|ANIM_LOOP; speed = 1860/d->maxspeed; } if(d->move < 0) { anim |= ANIM_REVERSE; } modelattach a[3]; int numattach = 0; if(vwepname) { a[numattach].name = vwepname; a[numattach].tag = "tag_weapon"; numattach++; } if(!stenciling && !reflecting && !refracting) { if(d->weaponsel==d->lastattackweapon && lastmillis-d->lastaction < d->weaponsel->flashtime()) anim |= ANIM_PARTICLE; if(d != player1 && d->state==CS_ALIVE) { d->head = vec(-1, -1, -1); a[numattach].tag = "tag_head"; a[numattach].pos = &d->head; numattach++; } } if(player1->isspectating() && d->clientnum == player1->followplayercn && player1->spectatemode == SM_FOLLOW3RD_TRANSPARENT) { anim |= ANIM_TRANSLUCENT; // see through followed player if(stenciling) return; } rendermodel(mdlname, anim|ANIM_DYNALLOC, tex, 1.5f, o, 0, d->yaw+90, d->pitch/4, speed, basetime, d, a); if(!stenciling && !reflecting && !refracting) { if(isteam(player1->team, d->team)) renderaboveheadicon(d); } } VARP(teamdisplaymode, 0, 1, 2); #define SKINBASE "packages/models/playermodels" VARP(hidecustomskins, 0, 0, 2); static vector playerskinlist; const char *getclientskin(const char *name, const char *suf) { static string tmp; int suflen = (int)strlen(suf), namelen = (int)strlen(name); const char *s, *r = NULL; loopv(playerskinlist) { s = playerskinlist[i]; int sl = (int)strlen(s) - suflen; if(sl > 0 && !strcmp(s + sl, suf)) { if(namelen == sl && !strncmp(name, s, namelen)) return s; // exact match if(s[sl - 1] == '_') { copystring(tmp, s); tmp[sl - 1] = '\0'; if(strstr(name, tmp)) r = s; // partial match } } } return r; } void updateclientname(playerent *d) { static bool gotlist = false; if(!gotlist) listfiles(SKINBASE "/custom", "jpg", playerskinlist); gotlist = true; if(!d || !playerskinlist.length()) return; d->skin_noteam = getclientskin(d->name, "_ffa"); d->skin_cla = getclientskin(d->name, "_cla"); d->skin_rvsf = getclientskin(d->name, "_rvsf"); } void renderclientp(playerent *d) { if(!d) return; int team = team_base(d->team); const char *cs = NULL, *skinbase = SKINBASE, *teamname = team_basestring(team); int skinid = 1 + d->skin(); string skin; if(hidecustomskins == 0 || (hidecustomskins == 1 && !m_teammode)) { cs = team ? d->skin_rvsf : d->skin_cla; if(!m_teammode && d->skin_noteam) cs = d->skin_noteam; } if(cs) formatstring(skin)("%s/custom/%s.jpg", skinbase, cs); else { if(!m_teammode || !teamdisplaymode) formatstring(skin)("%s/%s/%02d.jpg", skinbase, teamname, skinid); else switch(teamdisplaymode) { case 1: formatstring(skin)("%s/%s/%02d_%svest.jpg", skinbase, teamname, skinid, team ? "blue" : "red"); break; case 2: default: formatstring(skin)("%s/%s/%s.jpg", skinbase, teamname, team ? "blue" : "red"); break; } } string vwep; if(d->weaponsel) formatstring(vwep)("weapons/%s/world", d->weaponsel->info.modelname); else vwep[0] = 0; renderclient(d, "playermodels", vwep[0] ? vwep : NULL, -(int)textureload(skin)->id); } void renderclients() { playerent *d; loopv(players) if((d = players[i]) && d->state!=CS_SPAWNING && d->state!=CS_SPECTATE && (!player1->isspectating() || player1->spectatemode != SM_FOLLOW1ST || player1->followplayercn != i)) renderclientp(d); if(player1->state==CS_DEAD || (reflecting && !refracting)) renderclientp(player1); } void loadallmapmodels() // try to find all mapmodels in packages/models/mapmodels { vector files; listdirsrecursive("packages/models/mapmodels", files); files.sort(stringsort); loopvrev(files) if(files.inrange(i + 1) && !strcmp(files[i], files[i + 1])) delstring(files.remove(i + 1)); // remove doubles silentmodelloaderror = true; loopv(files) { const char *mn = files[i] + strlen("packages/models/"); clientlogf("loadallmaps: %s %s", mn, loadmodel(mn) ? "loaded" : "failed to load"); delstring(files[i]); } silentmodelloaderror = false; } COMMAND(loadallmapmodels, ""); assaultcube-1.2.0.2.1/source/src/renderparticles.cpp000066400000000000000000000626551352165075300223320ustar00rootroot00000000000000// renderparticles.cpp #include "cube.h" static GLushort *hemiindices = NULL; static vec *hemiverts = NULL; static int heminumverts = 0, heminumindices = 0; static void subdivide(int depth, int face); static void genface(int depth, int i1, int i2, int i3) { int face = heminumindices; heminumindices += 3; hemiindices[face] = i1; hemiindices[face+1] = i2; hemiindices[face+2] = i3; subdivide(depth, face); } static void subdivide(int depth, int face) { if(depth-- <= 0) return; int idx[6]; loopi(3) idx[i] = hemiindices[face+i]; loopi(3) { int vert = heminumverts++; hemiverts[vert] = vec(hemiverts[idx[i]]).add(hemiverts[idx[(i+1)%3]]).normalize(); //push on to unit sphere idx[3+i] = vert; hemiindices[face+i] = vert; } subdivide(depth, face); loopi(3) genface(depth, idx[i], idx[3+i], idx[3+(i+2)%3]); } //subdiv version wobble much more nicely than a lat/longitude version static void inithemisphere(int hres, int depth) { const int tris = hres << (2*depth); heminumverts = heminumindices = 0; DELETEA(hemiverts); DELETEA(hemiindices); hemiverts = new vec[tris+1]; hemiindices = new GLushort[tris*3]; hemiverts[heminumverts++] = vec(0.0f, 0.0f, 1.0f); //build initial 'hres' sided pyramid loopi(hres) { float a = PI2*float(i)/hres; hemiverts[heminumverts++] = vec(cosf(a), sinf(a), 0.0f); } loopi(hres) genface(depth, 0, i+1, 1+(i+1)%hres); } GLuint createexpmodtex(int size, float minval) { uchar *data = new uchar[size*size], *dst = data; loop(y, size) loop(x, size) { float dx = 2*float(x)/(size-1) - 1, dy = 2*float(y)/(size-1) - 1; float z = max(0.0f, 1.0f - dx*dx - dy*dy); if(minval) z = sqrtf(z); else loopk(2) z *= z; *dst++ = uchar(max(z, minval)*255); } GLuint tex = 0; glGenTextures(1, &tex); createtexture(tex, size, size, data, 3, true, false, GL_ALPHA); delete[] data; return tex; } static struct expvert { vec pos; float u, v, s, t; } *expverts = NULL; static GLuint expmodtex[2] = {0, 0}; static GLuint lastexpmodtex = 0; VARP(mtexplosion, 0, 1, 1); void setupexplosion() { if(!hemiindices) inithemisphere(5, 2); static int lastexpmillis = 0; if(lastexpmillis != lastmillis || !expverts) { vec center = vec(13.0f, 2.3f, 7.1f); lastexpmillis = lastmillis; if(!expverts) expverts = new expvert[heminumverts]; loopi(heminumverts) { expvert &e = expverts[i]; vec &v = hemiverts[i]; e.u = v.x*0.5f + 0.001f*lastmillis; e.v = v.y*0.5f + 0.001f*lastmillis; e.s = v.x*0.5f + 0.5f; e.t = v.y*0.5f + 0.5f; float wobble = v.dot(center) + 0.002f*lastmillis; wobble -= floor(wobble); wobble = 1.0f + fabs(wobble - 0.5f)*0.5f; e.pos = vec(v).mul(wobble); } } glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, sizeof(expvert), &expverts->pos); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(2, GL_FLOAT, sizeof(expvert), &expverts->u); if(mtexplosion && maxtmus>=2) { setuptmu(0, "C * T", "= Ca"); glActiveTexture_(GL_TEXTURE1_ARB); glClientActiveTexture_(GL_TEXTURE1_ARB); glEnable(GL_TEXTURE_2D); setuptmu(1, "P * Ta x 4", "Pa * Ta x 4"); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(2, GL_FLOAT, sizeof(expvert), &expverts->s); glActiveTexture_(GL_TEXTURE0_ARB); glClientActiveTexture_(GL_TEXTURE0_ARB); if(!expmodtex[0]) expmodtex[0] = createexpmodtex(64, 0); if(!expmodtex[1]) expmodtex[1] = createexpmodtex(64, 0.25f); lastexpmodtex = 0; } } void drawexplosion(bool inside, float r, float g, float b, float a) { if(mtexplosion && maxtmus>=2 && lastexpmodtex != expmodtex[inside ? 1 : 0]) { glActiveTexture_(GL_TEXTURE1_ARB); lastexpmodtex = expmodtex[inside ? 1 :0]; glBindTexture(GL_TEXTURE_2D, lastexpmodtex); glActiveTexture_(GL_TEXTURE0_ARB); } loopi(!reflecting && inside ? 2 : 1) { glColor4f(r, g, b, i ? a/2 : a); if(i) { glScalef(1, 1, -1); glDepthFunc(GL_GEQUAL); } if(inside) { if(!reflecting) { glCullFace(GL_BACK); glDrawElements(GL_TRIANGLES, heminumindices, GL_UNSIGNED_SHORT, hemiindices); glCullFace(GL_FRONT); } glScalef(1, 1, -1); } glDrawElements(GL_TRIANGLES, heminumindices, GL_UNSIGNED_SHORT, hemiindices); if(i) glDepthFunc(GL_LESS); } } void cleanupexplosion() { glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); if(mtexplosion && maxtmus>=2) { resettmu(0); glActiveTexture_(GL_TEXTURE1_ARB); glClientActiveTexture_(GL_TEXTURE1_ARB); glDisable(GL_TEXTURE_2D); resettmu(1); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glActiveTexture_(GL_TEXTURE0_ARB); glClientActiveTexture_(GL_TEXTURE0_ARB); } } struct particle { vec o, d; int fade, type; int millis; particle *next; }; particle *parlist[MAXPARTYPES], *parempty = NULL; static Texture *parttex[7]; void particleinit() { loopi(MAXPARTYPES) parlist[i] = NULL; parttex[0] = textureload("packages/misc/base.png"); parttex[1] = textureload("packages/misc/smoke.png"); parttex[2] = textureload("packages/misc/explosion.png"); parttex[3] = textureload("packages/misc/bullethole.png"); parttex[4] = textureload("packages/misc/blood.png"); parttex[5] = textureload("packages/misc/scorch.png"); parttex[6] = textureload("packages/misc/muzzleflash.jpg"); } void cleanupparticles() { loopi(2) if(expmodtex[i]) { glDeleteTextures(1, &expmodtex[i]); expmodtex[i] = 0; } } void particlereset() { loopi(MAXPARTYPES) { while(parlist[i]) { particle *p = parlist[i]; parlist[i] = p->next; p->next = parempty; parempty = p; } } } void newparticle(const vec &o, const vec &d, int fade, int type) { if(OUTBORD((int)o.x, (int)o.y)) return; if(!parempty) { particle *ps = new particle[256]; loopi(256) { ps[i].next = parempty; parempty = &ps[i]; } } particle *p = parempty; parempty = p->next; p->o = o; p->d = d; p->fade = fade; p->type = type; p->millis = lastmillis; p->next = parlist[type]; parlist[type] = p; } const char *particletypenames[MAXPARTYPES + 1] = { "SPARK", "SMOKE", "ECLOSEST", "BLOOD", "DEMOTRACK", "FIREBALL", "SHOTLINE", "BULLETHOLE", "BLOODSTAIN", "SCORCH", // 0..9 "HUDMUZZLEFLASH", "MUZZLEFLASH", "ELIGHT", "ESPAWN", "EAMMO", "EPICKUP", "EMODEL", "ECARROT", "ELADDER", "EFLAG", "" }; // 10..19 static struct parttype { int type; float r, g, b; int gr, tex; float sz; } parttypes[MAXPARTYPES] = { { PT_PART, 0.4f, 0.4f, 0.4f, 2, 0, 0.06f }, // yellow: sparks { PT_PART, 1.0f, 1.0f, 1.0f, 20, 1, 0.15f }, // grey: small smoke { PT_PART, 0.0f, 0.0f, 1.0f, 20, 0, 0.08f }, // blue: edit mode closest ent { PT_BLOOD, 0.5f, 0.0f, 0.0f, 1, 4, 0.3f }, // red: blood spats { PT_PART, 1.0f, 0.1f, 0.1f, 0, 1, 0.2f }, // red: demotrack { PT_FIREBALL, 1.0f, 0.5f, 0.5f, 0, 2, 7.0f }, // explosion fireball { PT_SHOTLINE, 1.0f, 1.0f, 0.7f, 0, -1, 0.0f }, // yellow: shotline { PT_BULLETHOLE, 1.0f, 1.0f, 1.0f, 0, 3, 0.3f }, // hole decal { PT_STAIN, 0.5f, 0.0f, 0.0f, 0, 4, 0.6f }, // red: blood stain { PT_DECAL, 1.0f, 1.0f, 1.0f, 0, 5, 1.5f }, // scorch decal { PT_HUDFLASH, 1.0f, 1.0f, 1.0f, 0, 6, 0.7f }, // hudgun muzzle flash { PT_FLASH, 1.0f, 1.0f, 1.0f, 0, 6, 0.7f }, // muzzle flash { PT_PART, 1.0f, 1.0f, 1.0f, 20, 0, 0.08f }, // white: edit mode ent type : light { PT_PART, 0.0f, 1.0f, 0.0f, 20, 0, 0.08f }, // green: edit mode ent type : spawn { PT_PART, 1.0f, 0.0f, 0.0f, 20, 0, 0.08f }, // red: edit mode ent type : ammo { PT_PART, 1.0f, 1.0f, 0.0f, 20, 0, 0.08f }, // yellow: edit mode ent type : pickup { PT_PART, 1.0f, 0.0f, 1.0f, 20, 0, 0.08f }, // magenta: edit mode ent type : model, sound { PT_PART, 1.0f, 0.5f, 0.2f, 20, 0, 0.08f }, // orange: edit mode ent type : "carrot" { PT_PART, 0.5f, 0.5f, 0.5f, 20, 0, 0.08f }, // grey: edit mode ent type : ladder, (pl)clip { PT_PART, 0.0f, 1.0f, 1.0f, 20, 0, 0.08f }, // turquoise: edit mode ent type : CTF-flag }; VAR(particlesize, 20, 100, 500); VARP(blood, 0, 1, 1); VARP(bloodttl, 0, 10000, 30000); void render_particles(int time, int typemask) { bool rendered = false; for(int i = MAXPARTYPES-1; i>=0; i--) if(typemask&(1<=0) glBindTexture(GL_TEXTURE_2D, parttex[pt.tex]->id); else glDisable(GL_TEXTURE_2D); switch(pt.type) { case PT_HUDFLASH: sethudgunperspective(true); // fall through case PT_FLASH: glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR); glColor3f(pt.r, pt.g, pt.b); glBegin(GL_QUADS); break; case PT_PART: glBlendFunc(GL_SRC_ALPHA, GL_ONE); glColor3f(pt.r, pt.g, pt.b); glBegin(GL_QUADS); break; case PT_FIREBALL: setupexplosion(); glBlendFunc(GL_SRC_ALPHA, GL_ONE); break; case PT_SHOTLINE: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(pt.r, pt.g, pt.b, 0.5f); glBegin(GL_LINES); break; case PT_DECAL: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBegin(GL_QUADS); break; case PT_BULLETHOLE: glBlendFunc(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA); glBegin(GL_QUADS); break; case PT_BLOOD: glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR); glColor3f(1-pt.r, 1-pt.g, 1-pt.b); glBegin(GL_QUADS); break; case PT_STAIN: glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR); glBegin(GL_QUADS); break; } for(particle *p, **pp = &parlist[i]; (p = *pp);) { switch(pt.type) { case PT_HUDFLASH: case PT_FLASH: { vec corners[4] = { vec(-camright.x+camup.x, -camright.y+camup.y, -camright.z+camup.z), vec( camright.x+camup.x, camright.y+camup.y, camright.z+camup.z), vec( camright.x-camup.x, camright.y-camup.y, camright.z-camup.z), vec(-camright.x-camup.x, -camright.y-camup.y, -camright.z-camup.z) }; loopk(4) corners[k].rotate(p->d.x, p->d.y, camdir).mul(sz*p->d.z).add(p->o); glTexCoord2i(0, 1); glVertex3fv(corners[0].v); glTexCoord2i(1, 1); glVertex3fv(corners[1].v); glTexCoord2i(1, 0); glVertex3fv(corners[2].v); glTexCoord2i(0, 0); glVertex3fv(corners[3].v); xtraverts += 4; break; } case PT_PART: glTexCoord2i(0, 1); glVertex3f(p->o.x+(-camright.x+camup.x)*sz, p->o.y+(-camright.y+camup.y)*sz, p->o.z+(-camright.z+camup.z)*sz); glTexCoord2i(1, 1); glVertex3f(p->o.x+( camright.x+camup.x)*sz, p->o.y+( camright.y+camup.y)*sz, p->o.z+( camright.z+camup.z)*sz); glTexCoord2i(1, 0); glVertex3f(p->o.x+( camright.x-camup.x)*sz, p->o.y+( camright.y-camup.y)*sz, p->o.z+( camright.z-camup.z)*sz); glTexCoord2i(0, 0); glVertex3f(p->o.x+(-camright.x-camup.x)*sz, p->o.y+(-camright.y-camup.y)*sz, p->o.z+(-camright.z-camup.z)*sz); xtraverts += 4; break; case PT_FIREBALL: { sz = 1.0f + (pt.sz-1.0f)*min(p->fade, lastmillis-p->millis)/p->fade; glPushMatrix(); glTranslatef(p->o.x, p->o.y, p->o.z); bool inside = p->o.dist(camera1->o) <= sz*1.25f; //1.25 is max wobble scale vec oc(p->o); oc.sub(camera1->o); if(reflecting && !refracting) oc.z = p->o.z - (waterlevel - 0.3f); glRotatef(inside ? camera1->yaw - 180 : atan2(oc.y, oc.x)/RAD - 90, 0, 0, 1); glRotatef((inside ? camera1->pitch : asin(oc.z/oc.magnitude())/RAD) - 90, 1, 0, 0); glRotatef(lastmillis/7.0f, 0, 0, 1); glScalef(-sz, sz, -sz); drawexplosion(inside, pt.r, pt.g, pt.b, 1.0f-sz/pt.sz); glPopMatrix(); xtraverts += heminumverts; break; } case PT_SHOTLINE: glVertex3f(p->o.x, p->o.y, p->o.z); glVertex3f(p->d.x, p->d.y, p->d.z); xtraverts += 2; break; case PT_DECAL: { sqr *s = S((int)p->o.x, (int)p->o.y); glColor4f(s->r/127.5f, s->g/127.5f, s->b/127.5, max(0.0f, min((p->millis+p->fade - lastmillis)/1000.0f, 0.7f))); vec dx(0, 0, 0), dy(0, 0, 0); loopk(3) if(p->d[k]) { dx[(k+1)%3] = -1; dy[(k+2)%3] = p->d[k]; break; } int o = detrnd((size_t)p, 11); static const int tc[4][2] = { {0, 1}, {1, 1}, {1, 0}, {0, 0} }; glTexCoord2i(tc[o%4][0], tc[o%4][1]); glVertex3f(p->o.x+(-dx.x+dy.x)*pt.sz, p->o.y+(-dx.y+dy.y)*pt.sz, p->o.z+(-dx.z+dy.z)*pt.sz); glTexCoord2i(tc[(o+1)%4][0], tc[(o+1)%4][1]); glVertex3f(p->o.x+( dx.x+dy.x)*pt.sz, p->o.y+( dx.y+dy.y)*pt.sz, p->o.z+( dx.z+dy.z)*pt.sz); glTexCoord2i(tc[(o+2)%4][0], tc[(o+2)%4][1]); glVertex3f(p->o.x+( dx.x-dy.x)*pt.sz, p->o.y+( dx.y-dy.y)*pt.sz, p->o.z+( dx.z-dy.z)*pt.sz); glTexCoord2i(tc[(o+3)%4][0], tc[(o+3)%4][1]); glVertex3f(p->o.x+(-dx.x-dy.x)*pt.sz, p->o.y+(-dx.y-dy.y)*pt.sz, p->o.z+(-dx.z-dy.z)*pt.sz); xtraverts += 4; break; } case PT_BULLETHOLE: { float blend = max(0.0f, min((p->millis+p->fade - lastmillis)/1000.0f, 1.0f)); glColor4f(pt.r*blend, pt.g*blend, pt.b*blend, blend); vec dx(0, 0, 0), dy(0, 0, 0); int tx = 0, ty = 1; loopk(3) if(p->d[k]) { dx[(k+1)%3] = -1; dy[(k+2)%3] = p->d[k]; if(k<2) { tx = k^1; ty = 2; } break; } glTexCoord2f(0.5f+0.5f*(-dx[tx]+dy[tx]), 0.5f+0.5f*(-dx[ty]+dy[ty])); glVertex3f(p->o.x+(-dx.x+dy.x)*pt.sz, p->o.y+(-dx.y+dy.y)*pt.sz, p->o.z+(-dx.z+dy.z)*pt.sz); glTexCoord2f(0.5f+0.5f*( dx[tx]+dy[tx]), 0.5f+0.5f*( dx[ty]+dy[ty])); glVertex3f(p->o.x+( dx.x+dy.x)*pt.sz, p->o.y+( dx.y+dy.y)*pt.sz, p->o.z+( dx.z+dy.z)*pt.sz); glTexCoord2f(0.5f+0.5f*( dx[tx]-dy[tx]), 0.5f+0.5f*( dx[ty]-dy[ty])); glVertex3f(p->o.x+( dx.x-dy.x)*pt.sz, p->o.y+( dx.y-dy.y)*pt.sz, p->o.z+( dx.z-dy.z)*pt.sz); glTexCoord2f(0.5f+0.5f*(-dx[tx]-dy[tx]), 0.5f+0.5f*(-dx[ty]-dy[ty])); glVertex3f(p->o.x+(-dx.x-dy.x)*pt.sz, p->o.y+(-dx.y-dy.y)*pt.sz, p->o.z+(-dx.z-dy.z)*pt.sz); xtraverts += 4; break; } case PT_BLOOD: { int n = detrnd((size_t)p, 4), o = detrnd((size_t)p, 11);; float tx = 0.5f*(n&1), ty = 0.5f*((n>>1)&1), tsz = 0.5f; static const int tc[4][2] = { {0, 1}, {1, 1}, {1, 0}, {0, 0} }; glTexCoord2f(tx+tsz*tc[o%4][0], ty+tsz*tc[o%4][1]); glVertex3f(p->o.x+(-camright.x+camup.x)*sz, p->o.y+(-camright.y+camup.y)*sz, p->o.z+(-camright.z+camup.z)*sz); glTexCoord2f(tx+tsz*tc[(o+1)%4][0], ty+tsz*tc[(o+1)%4][1]); glVertex3f(p->o.x+( camright.x+camup.x)*sz, p->o.y+( camright.y+camup.y)*sz, p->o.z+( camright.z+camup.z)*sz); glTexCoord2f(tx+tsz*tc[(o+2)%4][0], ty+tsz*tc[(o+2)%4][1]); glVertex3f(p->o.x+( camright.x-camup.x)*sz, p->o.y+( camright.y-camup.y)*sz, p->o.z+( camright.z-camup.z)*sz); glTexCoord2f(tx+tsz*tc[(o+3)%4][0], ty+tsz*tc[(o+3)%4][1]); glVertex3f(p->o.x+(-camright.x-camup.x)*sz, p->o.y+(-camright.y-camup.y)*sz, p->o.z+(-camright.z-camup.z)*sz); xtraverts += 4; break; } case PT_STAIN: { float blend = max(0.0f, min((p->millis+p->fade - lastmillis)/1000.0f, 1.0f)); glColor3f(blend*(1-pt.r), blend*(1-pt.g), blend*(1-pt.b)); int n = detrnd((size_t)p, 4), o = detrnd((size_t)p, 11); float tx = 0.5f*(n&1), ty = 0.5f*((n>>1)&1), tsz = 0.5f; static const int tc[4][2] = { {0, 1}, {1, 1}, {1, 0}, {0, 0} }; vec dx(0, 0, 0), dy(0, 0, 0); loopk(3) if(p->d[k]) { dx[(k+1)%3] = -1; dy[(k+2)%3] = p->d[k]; break; } glTexCoord2f(tx+tsz*tc[o%4][0], ty+tsz*tc[o%4][1]); glVertex3f(p->o.x+(-dx.x+dy.x)*pt.sz, p->o.y+(-dx.y+dy.y)*pt.sz, p->o.z+(-dx.z+dy.z)*pt.sz); glTexCoord2f(tx+tsz*tc[(o+1)%4][0], ty+tsz*tc[(o+1)%4][1]); glVertex3f(p->o.x+( dx.x+dy.x)*pt.sz, p->o.y+( dx.y+dy.y)*pt.sz, p->o.z+( dx.z+dy.z)*pt.sz); glTexCoord2f(tx+tsz*tc[(o+2)%4][0], ty+tsz*tc[(o+2)%4][1]); glVertex3f(p->o.x+( dx.x-dy.x)*pt.sz, p->o.y+( dx.y-dy.y)*pt.sz, p->o.z+( dx.z-dy.z)*pt.sz); glTexCoord2f(tx+tsz*tc[(o+3)%4][0], ty+tsz*tc[(o+3)%4][1]); glVertex3f(p->o.x+(-dx.x-dy.x)*pt.sz, p->o.y+(-dx.y-dy.y)*pt.sz, p->o.z+(-dx.z-dy.z)*pt.sz); xtraverts += 4; break; } } if(time < 0) pp = &p->next; else if(!p->fade || lastmillis-p->millis>p->fade) { *pp = p->next; p->next = parempty; parempty = p; } else { if(pt.gr) p->o.z -= ((lastmillis-p->millis)/3.0f)*time/(pt.gr*10000); if(pt.type==PT_PART || pt.type==PT_BLOOD) { p->o.add(vec(p->d).mul(time/20000.0f)); if(OUTBORD((int)p->o.x, (int)p->o.y)) { *pp = p->next; p->next = parempty; parempty = p; continue; } } if(pt.type==PT_BLOOD) { sqr *s = S((int)p->o.x, (int)p->o.y); if(s->type==SPACE && p->o.z<=s->floor) { *pp = p->next; p->next = parempty; parempty = p; newparticle(vec(p->o.x, p->o.y, s->floor+0.005f), vec(0, 0, 1), bloodttl, 8); continue; } } pp = &p->next; } } switch(pt.type) { case PT_HUDFLASH: glEnd(); sethudgunperspective(false); break; case PT_PART: case PT_SHOTLINE: case PT_DECAL: case PT_BULLETHOLE: case PT_BLOOD: case PT_STAIN: case PT_FLASH: glEnd(); break; case PT_FIREBALL: cleanupexplosion(); break; } if(pt.tex<0) glEnable(GL_TEXTURE_2D); } if(rendered) { glEnable(GL_FOG); glDisable(GL_BLEND); glDepthMask(GL_TRUE); } } void particle_emit(int type, int *args, int basetime, int seed, const vec &p) { if(type<0 || type>=MAXPARTYPES) return; parttype &pt = parttypes[type]; if(pt.type==PT_FIREBALL) particle_fireball(type, p); else if(pt.type==PT_FLASH || pt.type==PT_HUDFLASH) { if(lastmillis - basetime < args[0]) particle_flash(type, args[1]>0 ? args[1]/100.0f : 1.0f, seed%360, p); } else particle_splash(type, args[0], args[1], p); } void particle_flash(int type, float scale, float angle, const vec &p) { angle *= RAD; newparticle(p, vec(cosf(angle), sinf(angle), scale), 0, type); } void particle_splash(int type, int num, int fade, const vec &p) { if(parttypes[type].type==PT_BLOOD && !blood) return; if(fade == 0) fade = 1; loopi(num) { const int radius = 150; int x, y, z; do { x = rnd(radius*2)-radius; y = rnd(radius*2)-radius; z = rnd(radius*2)-radius; } while(x*x+y*y+z*z>radius*radius); vec d((float)x, (float)y, (float)z); newparticle(p, d, rnd(fade*3), type); } } void particle_cube(int type, int num, int fade, int x, int y) { sqr *s = S(x, y); const int fc = s->ceil - s->floor + (s->vdelta + 3) / 4; const float floor = s->floor - (s->type == FHF ? float(s->vdelta) / 4 : 0); if(SOLID(s) || fc < 1) return; loopi(num * fc / 12) { vec p(float(rnd(100)) / 100.0 + x, float(rnd(100)) / 100.0 + y, float(rnd(100) * fc) / 100 + floor), d(0, 0, 0); newparticle(p, d, rnd(fade*3), type); } } VARP(maxtrail, 1, 500, 10000); void particle_trail(int type, int fade, const vec &s, const vec &e) { vec v; float d = e.dist(s, v); int steps = clamp(int(d*2), 1, maxtrail); v.div(steps); vec p = s; loopi(steps) { p.add(v); vec tmp((float)(rnd(11)-5), (float)(rnd(11)-5), (float)(rnd(11)-5)); newparticle(p, tmp, rnd(fade)+fade, type); } } void particle_fireball(int type, const vec &o) { newparticle(o, vec(0, 0, 0), (int)((parttypes[type].sz-1.0f)*100.0f), type); } VARP(bulletbouncesound, 0, 1, 1); VARP(bullethole, 0, 1, 1); VARP(bulletholettl, 0, 10000, 30000); VARP(bulletbouncesoundrad, 0, 15, 1000); bool addbullethole(dynent *d, const vec &from, const vec &to, float radius, bool noisy) { if(!bulletholettl || !bullethole) return false; vec surface, ray(to); ray.sub(from); ray.normalize(); float dist = raycube(from, ray, surface), mag = to.dist(from); if(surface.iszero() || (radius>0 && (dist < mag-radius || dist > mag+radius))) return false; vec o(from); o.add(ray.mul(dist)); o.add(vec(surface).normalize().mul(0.01f)); newparticle(o, surface, bulletholettl, 7); if(noisy && bulletbouncesound && bulletbouncesoundrad && d!=player1 && o.dist(camera1->o) <= bulletbouncesoundrad) { audiomgr.playsound(o.z < waterlevel ? S_BULLETWATERHIT : S_BULLETHIT, &o, SP_LOW); } return true; } VARP(scorch, 0, 1, 1); VARP(scorchttl, 0, 10000, 30000); bool addscorchmark(vec &o, float radius) { if(!scorchttl || !scorch) return false; sqr *s = S((int)o.x, (int)o.y); if(s->type!=SPACE || o.z-s->floor>radius) return false; newparticle(vec(o.x, o.y, s->floor+0.02f), vec(0, 0, 1), scorchttl, 9); return true; } VARP(shotline, 0, 1, 1); VARP(shotlinettl, 0, 75, 10000); VARP(bulletairsound, 0, 1, 1); VARP(bulletairsoundrad, 0, 15, 1000); VARP(bulletairsoundsourcerad, 0, 8, 1000); VARP(bulletairsounddestrad, 0, 8, 1000); void addshotline(dynent *pl, const vec &from, const vec &to) { if(pl == player1 || !shotlinettl || !shotline) return; bool fx = shotlinettl > 0 && (player1->isspectating() || !multiplayer(NULL)); // allow fx only in spect mode and locally if(rnd(3) && !fx) return; // show all shotlines when fx enabled int start = (camera1->o.dist(to) <= 10.0f) ? 8 : 5; vec unitv; float dist = to.dist(from, unitv); if(dist < 1) return; unitv.div(dist); // shotline visuals vec o = unitv; o.mul(dist/10+start).add(from); vec d = unitv; d.mul(dist/10*-(10-start-2)).add(to); newparticle(o, d, fx ? shotlinettl : min(75, shotlinettl), 6); // shotline sound fx if(!bulletairsoundrad) return; vec fromuv, touv; float fd = camera1->o.dist(from, fromuv); float td = camera1->o.dist(to, touv); if(fd <= (float)bulletairsoundsourcerad || td <= (float)bulletairsounddestrad) return; // ignore nearly fired/detonated shots vec soundpos(unitv); soundpos.mul(fd/(fd+td)*dist); soundpos.add(from); if(!bulletairsound || soundpos.dist(camera1->o) > bulletairsoundrad) return; // outside player radius audiomgr.playsound(rnd(2) ? S_BULLETAIR1 : S_BULLETAIR2, &soundpos, SP_LOW); } assaultcube-1.2.0.2.1/source/src/rendertext.cpp000066400000000000000000000440551352165075300213220ustar00rootroot00000000000000// rendertext.cpp: font rendering #include "cube.h" int VIRTW; bool ignoreblinkingbit = false; // for remote-n-temp override of '\fb' static hashtable fonts; static font *fontdef = NULL; font *curfont = NULL; VARP(allowblinkingtext, 0, 0, 1); // if you're so inclined void newfont(char *name, char *tex, int *defaultw, int *defaulth, int *offsetx, int *offsety, int *offsetw, int *offseth) { if(*defaulth < 10) return; // (becomes FONTH) Texture *_tex = textureload(tex); if(_tex == notexture || !_tex->xs || !_tex->ys) return; font *f = fonts.access(name); if(!f) { name = newstring(name); f = &fonts[name]; f->name = name; } f->tex = _tex; f->chars.shrink(0); f->defaultw = *defaultw; f->defaulth = *defaulth; f->offsetx = *offsetx; f->offsety = *offsety; f->offsetw = *offsetw; f->offseth = *offseth; f->skip = 33; fontdef = f; } COMMANDN(font, newfont, "ssiiiiii"); void fontchar(int *x, int *y, int *w, int *h) { if(!fontdef) return; font::charinfo &c = fontdef->chars.add(); c.w = *w ? *w : fontdef->defaultw; c.h = *h ? *h : fontdef->defaulth; c.left = (*x + fontdef->offsetx) / float(fontdef->tex->xs); c.top = (*y + fontdef->offsety) / float(fontdef->tex->ys); c.right = (*x + c.w + fontdef->offsetw) / float(fontdef->tex->xs); c.bottom = (*y + c.h + fontdef->offseth) / float(fontdef->tex->ys); } COMMAND(fontchar, "iiii"); void fontskip(int *n) { if(!fontdef) return; fontdef->skip = *n; } COMMAND(fontskip, "i"); bool setfont(const char *name) { font *f = fonts.access(name); if(!f) return false; curfont = f; return true; } COMMAND(setfont, "s"); COMMANDF(curfont, "", () { result(curfont && curfont->name ? curfont->name : ""); }); font *getfont(const char *name) { return fonts.access(name); } static vector fontstack; void pushfont(const char *name) { fontstack.add(curfont); setfont(name); } void popfont() { if(!fontstack.empty()) curfont = fontstack.pop(); } int text_width(const char *str) { int width, height; text_bounds(str, width, height); return width; } void draw_textf(const char *fstr, int left, int top, ...) { defvformatstring(str, top, fstr); draw_text(str, left, top); } inline int draw_char_contd(font &f, font::charinfo &info, int charcode, int x, int y) { glTexCoord2f(info.left, info.top ); glVertex2f(x, y); glTexCoord2f(info.right, info.top ); glVertex2f(x + info.w, y); glTexCoord2f(info.right, info.bottom); glVertex2f(x + info.w, y + info.h); glTexCoord2f(info.left, info.bottom); glVertex2f(x, y + info.h); xtraverts += 4; return info.w; } static int draw_char(int c, int x, int y) { if(curfont->chars.inrange(c-curfont->skip)) { font::charinfo &info = curfont->chars[c-curfont->skip]; return draw_char_contd(*curfont, info, c, x, y); } return 0; } vector igraphbatch; void queue_igraph(int c, int x, int y) { threeint v = { c, x, y }; igraphbatch.add(v); } VARP(igraphsize, 80, 120, 300); VARP(igraphsizehardcoded, 80, 106, 160); VARP(igraphanimate, 0, 1, 1); void render_igraphs() { igraphbatch.sort(cmpintasc); int last = 0, w[2] = { (FONTH * igraphsize) / 100, (FONTH * igraphsizehardcoded) / 100 }, offs[2] = { (FONTH - w[0]) / 2, (FONTH - w[1]) / 2 }, ishc = 0; igraph *ig = NULL; glColor4ub(255, 255, 255, 255); loopv(igraphbatch) { if(last != igraphbatch[i].key) ig = getusedigraph((last = igraphbatch[i].key)), ishc = last > 0 && last < 10 ? 1 : 0; if(ig && ig->tex) { int &x = igraphbatch[i].val1, &y = igraphbatch[i].val2, fpos = ((totalmillis + x * x + VIRTW * y) % ig->frames.last() + ig->frames.last()) % ig->frames.last(), frame = 0; float fw = min(1.0f, float(ig->tex->ys) / ig->tex->xs); if(igraphanimate) loopvj(ig->frames) if(ig->frames[j] < fpos) frame++; quad(ig->tex->id, x + offs[ishc], y + offs[ishc], w[ishc], (frame % max(1, ig->tex->xs / ig->tex->ys)) * fw, 0, fw, 1); } } } //stack[sp] is current color index static void text_color(char c, char *stack, int size, int &sp, bvec color, int a) { if(c=='s') // save color { c = stack[sp]; if(sp 0) ? --sp : sp]; // restore color else if(c == 'b') { if(allowblinkingtext && !ignoreblinkingbit) stack[sp] *= -1; } // blinking text - only if allowed else stack[sp] = c; switch(iabs(stack[sp])) { case '0': color = bvec( 2, 255, 128 ); break; // green: player talk case '1': color = bvec( 96, 160, 255 ); break; // blue: team chat case '2': color = bvec( 255, 192, 64 ); break; // yellow: gameplay action messages, only actions done by players - 230 230 20 too bright case '3': color = bvec( 255, 64, 64 ); break; // red: important errors and notes case '4': color = bvec( 128, 128, 128 ); break; // gray case '5': color = bvec( 255, 255, 255 ); break; // white case '6': color = bvec( 96, 48, 0 ); break; // dark brown case '7': color = bvec( 153, 51, 51 ); break; // dark red: dead admin case '8': color = bvec( 192, 64, 192 ); break; // magenta case '9': color = bvec( 255, 102, 0 ); break; // orange case 'A':color = bvec( 0xff, 0xb7, 0xb7); break; // red set case 'B':color = bvec( 0xCC, 0x33, 0x33); break; // case 'C':color = bvec( 0x66, 0x33, 0x33); break; // case 'D':color = bvec( 0xF8, 0x98, 0x4E); break; // case 'E':color = bvec( 0xFF, 0xFF, 0xB7); break; // yellow set case 'F':color = bvec( 0xCC, 0xCC, 0x33); break; // case 'G':color = bvec( 0x66, 0x66, 0x33); break; // case 'H':color = bvec( 0xCC, 0xFC, 0x58); break; // case 'I':color = bvec( 0xB7, 0xFF, 0xB7); break; // green set case 'J':color = bvec( 0x33, 0xCC, 0x33); break; // case 'K':color = bvec( 0x33, 0x66, 0x33); break; // case 'L':color = bvec( 0x3F, 0xFF, 0x98); break; // case 'M':color = bvec( 0xB7, 0xFF, 0xFF); break; // cyan set case 'N':color = bvec( 0x33, 0xCC, 0xCC); break; // case 'O':color = bvec( 0x33, 0x66, 0x66); break; // case 'P':color = bvec( 0x4F, 0xCC, 0xF8); break; // case 'Q':color = bvec( 0xB7, 0xB7, 0xFF); break; // blue set case 'R':color = bvec( 0x33, 0x33, 0xCC); break; // case 'S':color = bvec( 0x33, 0x33, 0x66); break; // case 'T':color = bvec( 0xA0, 0x49, 0xFF); break; // case 'U':color = bvec( 0xFF, 0xB7, 0xFF); break; // magenta set case 'V':color = bvec( 0xCC, 0x33, 0xCC); break; // case 'W':color = bvec( 0x66, 0x33, 0x66); break; // case 'X':color = bvec( 0xFF, 0x01, 0xD5); break; // case 'Y':color = bvec( 0xC7, 0xD1, 0xE2); break; // lt gray case 'Z':color = bvec( 0x32, 0x32, 0x32); break; // dark gray case 'u': color = bvec(120, 240, 120); break; // stats: green case 'v': color = bvec(120, 120, 240); break; // stats: blue case 'w': color = bvec(230, 230, 110); break; // stats: yellow case 'x': color = bvec(250, 100, 100); break; // stats: red } int b = (int) (sinf(lastmillis / 200.0f) * 115.0f); b = stack[sp] > 0 ? 100 : min(iabs(b), 100); glColor4ub(color.x, color.y, color.z, (a * b) / 100); } } static vector *columns = NULL; void text_startcolumns() { if(!columns) columns = new vector; } void text_endcolumns() { DELETEP(columns); } #define TABALIGN(x) ((((x)+PIXELTAB)/PIXELTAB)*PIXELTAB) #define TEXTGETCOLUMN \ if(columns && collength()) \ { \ colx += (*columns)[col++]; \ x = colx; \ } \ else x = TABALIGN(x); #define TEXTSETCOLUMN \ if(columns) \ { \ while(col>=columns->length()) columns->add(0); \ int w = TABALIGN(x) - colx; \ w = max(w, (*columns)[col]); \ (*columns)[col] = w; \ col++; \ colx += w; \ x = colx; \ } \ else x = TABALIGN(x); #define TEXTSKELETON \ int y = 0, x = 0, col = 0, colx = 0;\ int i;\ for(i = 0; str[i]; i++)\ {\ TEXTINDEX(i)\ int c = str[i];\ if(c=='\t') { TEXTTAB(i); TEXTWHITE(i) }\ else if(c==' ') { x += curfont->defaultw; TEXTWHITE(i) }\ else if(c=='\n') { TEXTLINE(i) x = 0; y += FONTH; }\ else if(c=='\f') { if(str[i+1]) { i++; TEXTCOLOR(i) }}\ else if(c=='\1') { if(str[i+1]) { i++; TEXTIGRAPH(i) }}\ else if(c=='\a') { if(str[i+1]) { i++; }}\ else if(curfont->chars.inrange(c-curfont->skip))\ {\ if(maxwidth != -1)\ {\ int j = i;\ int w = curfont->chars[c-curfont->skip].w;\ for(; str[i+1]; i++)\ {\ int c = str[i+1];\ bool isig = c == '\1';\ if(c=='\f') { if(str[i+2]) i++; continue; }\ if(i-j > 16) break;\ if(!isig && !curfont->chars.inrange(c-curfont->skip)) break;\ int cw = isig ? FONTH + 1 : curfont->chars[c-curfont->skip].w + 1;\ if(isig && str[i + 2]) i++;\ if(w + cw >= maxwidth) break;\ w += cw;\ }\ if(x + w >= maxwidth && j!=0) { TEXTLINE(j-1) x = 0; y += FONTH; }\ TEXTWORD\ }\ else\ { TEXTCHAR(i) }\ }\ } //all the chars are guaranteed to be either drawable or color commands #define TEXTWORDSKELETON \ for(; j <= i; j++)\ {\ TEXTINDEX(j)\ int c = str[j];\ if(c=='\f') { if(str[j+1]) { j++; TEXTCOLOR(j) }}\ else if(c=='\1') { if(str[j+1]) { j++; TEXTIGRAPH(j) }}\ else { TEXTCHAR(j) }\ } int text_visible(const char *str, int hitx, int hity, int maxwidth) { #define TEXTINDEX(idx) #define TEXTTAB(idx) TEXTGETCOLUMN #define TEXTWHITE(idx) if(y+FONTH > hity && x >= hitx) return idx; #define TEXTLINE(idx) if(y+FONTH > hity) return idx; #define TEXTCOLOR(idx) #define TEXTIGRAPH(idx) x += FONTH; TEXTWHITE(idx) #define TEXTCHAR(idx) x += curfont->chars[c-curfont->skip].w+1; TEXTWHITE(idx) #define TEXTWORD TEXTWORDSKELETON TEXTSKELETON #undef TEXTINDEX #undef TEXTTAB #undef TEXTWHITE #undef TEXTLINE #undef TEXTCOLOR #undef TEXTIGRAPH #undef TEXTCHAR #undef TEXTWORD return i; } //inverse of text_visible void text_pos(const char *str, int cursor, int &cx, int &cy, int maxwidth) { #define TEXTINDEX(idx) if(idx == cursor) { cx = x; cy = y; break; } #define TEXTTAB(idx) TEXTGETCOLUMN #define TEXTWHITE(idx) #define TEXTLINE(idx) #define TEXTCOLOR(idx) #define TEXTIGRAPH(idx) x += FONTH; #define TEXTCHAR(idx) x += curfont->chars[c-curfont->skip].w + 1; #define TEXTWORD TEXTWORDSKELETON if(i >= cursor) break; cx = INT_MIN; cy = 0; TEXTSKELETON if(cx == INT_MIN) { cx = x; cy = y; } #undef TEXTINDEX #undef TEXTTAB #undef TEXTWHITE #undef TEXTLINE #undef TEXTCOLOR #undef TEXTIGRAPH #undef TEXTCHAR #undef TEXTWORD } void text_bounds(const char *str, int &width, int &height, int maxwidth) { #define TEXTINDEX(idx) #define TEXTTAB(idx) TEXTSETCOLUMN #define TEXTWHITE(idx) #define TEXTLINE(idx) if(x > width) width = x; #define TEXTCOLOR(idx) #define TEXTIGRAPH(idx) x += FONTH + 1; #define TEXTCHAR(idx) x += curfont->chars[c-curfont->skip].w + 1; #define TEXTWORD x += w + 1; width = 0; TEXTSKELETON height = y + FONTH; TEXTLINE(_) #undef TEXTINDEX #undef TEXTTAB #undef TEXTWHITE #undef TEXTLINE #undef TEXTCOLOR #undef TEXTIGRAPH #undef TEXTCHAR #undef TEXTWORD } void draw_text(const char *str, int left, int top, int r, int g, int b, int a, int cursor, int maxwidth) { #define TEXTINDEX(idx) if(idx == cursor) { cx = x; cy = y; cc = str[idx]; } #define TEXTTAB(idx) TEXTGETCOLUMN #define TEXTWHITE(idx) #define TEXTLINE(idx) #define TEXTCOLOR(idx) text_color(str[idx], colorstack, sizeof(colorstack), colorpos, color, a); #define TEXTIGRAPH(idx) queue_igraph((uchar)str[idx], left+x, top+y), x += FONTH + 1; #define TEXTCHAR(idx) x += draw_char(c, left+x, top+y) + 1; #define TEXTWORD TEXTWORDSKELETON char colorstack[10]; bvec color(r, g, b); int colorpos = 0, cx = INT_MIN, cy = 0, cc = ' '; colorstack[0] = 'c'; //indicate user color igraphbatch.setsize(0); glBlendFunc(GL_SRC_ALPHA, curfont->tex->bpp==32 ? GL_ONE_MINUS_SRC_ALPHA : GL_ONE); glBindTexture(GL_TEXTURE_2D, curfont->tex->id); glBegin(GL_QUADS); glColor4ub(color.x, color.y, color.z, a); TEXTSKELETON glEnd(); if(cursor >= 0) { if(cx == INT_MIN) { cx = x; cy = y; } if(maxwidth != -1 && cx >= maxwidth) { cx = 0; cy += FONTH; } int cw = curfont->chars.inrange(cc-33) ? curfont->chars[cc-33].w + 1 : curfont->defaultw; rendercursor(left+cx, top+cy, cw); } render_igraphs(); #undef TEXTINDEX #undef TEXTTAB #undef TEXTWHITE #undef TEXTLINE #undef TEXTCOLOR #undef TEXTIGRAPH #undef TEXTCHAR #undef TEXTWORD } void reloadfonts() { enumerate(fonts, font, f, if(!reloadtexture(*f.tex)) fatal("failed to reload font texture"); ); } void cutcolorstring(char *text, int maxlen) { // limit string length, ignore color codes if(!curfont) return; int len = 0; maxlen *= curfont->defaultw; while(*text) { if(*text == '\f' && text[1]) text++; else if(*text == '\1' && text[1]) text++, len += FONTH + 1; else if(*text == '\t') len = TABALIGN(len); else len += curfont->chars.inrange(*text - curfont->skip) ? curfont->chars[*text - curfont->skip].w : curfont->defaultw; if(len > maxlen) { *text = '\0'; break; } text++; } } bool filterunrenderables(char *s) { bool res = false; char *d = s; while(*s) { if(!curfont->chars.inrange(*s - curfont->skip) && *s != ' ') res = true; else *d++ = *s; s++; } *d = '\0'; return res; } // animated inlined graphics VAR(igraphdefaultframetime, 5, 200, 2000); VARP(hideigraphs, 0, 0, 1); #define IGRAPHPATH "packages" PATHDIVS "misc" PATHDIVS "igraph" PATHDIVS hashtable igraphs; // keyed by shorthand hashtable igraphsi; // known filenames vector usedigraphs; // char codes ('\1' + n) void addigraph(char *fname) { char *b, *s = newstring(fname), *mnem = strtok_r(s, "_", &b), *r; if(mnem && *mnem && !igraphs.access(mnem)) { // new mnem defformatstring(filename)("%s%s.png", IGRAPHPATH, fname); Texture *tex = textureload(filename); if(tex != notexture && tex->xs && tex->ys) { igraph &ig = igraphs[newstring(mnem)]; ig.fname = fname; ig.tex = tex; ig.used = !mnem[1] && *mnem >= '1' && *mnem <= '9' ? *mnem - '0' : 0; if(ig.used && usedigraphs.inrange(ig.used)) usedigraphs[ig.used] = &ig; // hardcode "1".."9" while((r = strtok_r(NULL, "_", &b))) ig.frames.add(max(5, (int)ATOI(r))); if(ig.frames.empty()) ig.frames.add(igraphdefaultframetime); while(ig.frames.length() < tex->xs / tex->ys) ig.frames.add(ig.frames.last()); loopv(ig.frames) if(i) ig.frames[i] += ig.frames[i - 1]; #ifdef _DEBUG clientlogf(" loaded igraph \"%s\", short \"%s\", %dx%d, %d frame%s", fname, mnem, tex->xs, tex->ys, ig.frames.length(), ig.frames.length() > 1 ? "s" : ""); #endif } } igraphsi[fname] = 0; delstring(s); } void updateigraphs() // read all filenames and parse new ones (also preloads the textures) { vector files; while(usedigraphs.length() <= (int)'\n') usedigraphs.add(NULL); // allocate hardcoded slots and skip slot 10 ('\n') listfiles(IGRAPHPATH, "png", files); loopvrev(files) { if(igraphsi.access(files[i])) delstring(files[i]); else addigraph(files[i]); } } COMMAND(updateigraphs, ""); igraph *getusedigraph(int i) { if(usedigraphs.inrange(i)) return usedigraphs[i]; return NULL; } int getigraph(const char *mnem) { igraph *ig = igraphs.access(mnem); if(ig) { if(!ig->used && usedigraphs.length() < 255) { ig->used = usedigraphs.length(); usedigraphs.add(ig); } return ig->used; } return 0; } void _getigraph(char *s) { uchar res[3] = { '\1', (uchar)getigraph(s), '\0' }; result(res[1] ? (char*)res : ""); } COMMANDN(getigraph, _getigraph, "s"); void encodeigraphs(char *d, const char *s, int len) // find known igraphs in a string and substitute with rendercodes, only used for console messages { if(hideigraphs) copystring(d, s, len); else { len--; string mnem; loopi(len) { if(*s == ':' && (!i || isspace(s[-1])) && i < len - 1) { int l = strcspn(s + 1, " \t\n."), u; if(l && l < MAXSTRLEN) { copystring(mnem, s + 1, l + 1); if((u = getigraph(mnem))) { // found one: encode *d++ = '\1'; *d++ = u; s += l + 1; i++; continue; } } } *d++ = *s++; } *d = '\0'; } } void enumigraphs(vector &igs, const char *s, int len) { enumeratek(igraphs, const char *, mnem, if(!strncasecmp(mnem, s, len)) igs.add(mnem)); } assaultcube-1.2.0.2.1/source/src/rndmap.cpp000066400000000000000000000037351352165075300204170ustar00rootroot00000000000000// rndmap.cpp: perlin noise landscape generation and some experimental random map stuff, currently not used #include "cube.h" float noise(int x, int y, int seed) { int n = x+y*57; n = (n<<13)^n; return 1.0f-((n*(n*n*15731+789221)+1376312589)&0x7fffffff)/1073741824.0f; } float smoothednoise(int x, int y, int seed) { float corners = (noise(x-1, y-1, seed)+noise(x+1, y-1, seed)+noise(x-1, y+1, seed)+noise(x+1, y+1, seed))/16; float sides = (noise(x-1, y, seed)+noise(x+1, y, seed)+noise(x, y-1, seed)+noise(x, y+1, seed))/8; float center = noise(x, y, seed)/4; return corners+sides+center; } float interpolate(float a, float b, float x) { float ft = x*3.1415927f; float f = (1.0f-cosf(ft))*0.5f; return a*(1-f)+b*f; } float interpolatednoise(float x, float y, int seed) { int ix = (int)x; float fx = x-ix; int iy = (int)y; float fy = y-iy; float v1 = smoothednoise(ix, iy, seed); float v2 = smoothednoise(ix+1, iy, seed); float v3 = smoothednoise(ix, iy+1, seed); float v4 = smoothednoise(ix+1, iy+1, seed); float i1 = interpolate(v1, v2, fx); float i2 = interpolate(v3, v4, fy); return interpolate(i1, i2, fy); } float perlinnoise_2D(float x, float y, int seedstep, float pers) { float total = 0; int seed = 0; for(int i = 0; i<7; i++) { float frequency = (float)(2^i); float amplitude = (float)pow(pers, i); total += interpolatednoise(x*frequency, y*frequency, seed)*amplitude; seed += seedstep; } return total; } void perlinarea(block &b, int scale, int seed, int psize) { seed = rnd(10000); if(!scale) scale = 10; for(int y = b.y; y<=b.y+b.ys; y++) for(int x = b.x; x<=b.x+b.xs; x++) { sqr *s = S(x,y); if(!SOLID(s) && x!=b.x+b.xs && y!=b.y+b.ys) s->type = FHF; s->vdelta = (int)(perlinnoise_2D(x/((float)scale)+seed, y/((float)scale)+seed, 1000, 0.01f)*50+25); if(s->vdelta>128) s->vdelta = 0; } } assaultcube-1.2.0.2.1/source/src/scale.h000066400000000000000000000077161352165075300176750ustar00rootroot00000000000000static void FUNCNAME(halvetexture)(uchar *src, uint sw, uint sh, uchar *dst) { uint stride = sw*BPP; for(uchar *yend = &src[sh*stride]; src < yend;) { for(uchar *xend = &src[stride]; src < xend; src += 2*BPP, dst += BPP) { #define OP(c, n) dst[n] = (uint(src[n]) + uint(src[n+BPP]) + uint(src[stride+n]) + uint(src[stride+n+BPP]))>>2 PIXELOP #undef OP } src += stride; } } static void FUNCNAME(shifttexture)(uchar *src, uint sw, uint sh, uchar *dst, uint dw, uint dh) { uint stride = sw*BPP, wfrac = sw/dw, hfrac = sh/dh, wshift = 0, hshift = 0; while(dw<>tshift PIXELOP #undef OP } src += (hfrac-1)*stride; } } static void FUNCNAME(scaletexture)(uchar *src, uint sw, uint sh, uchar *dst, uint dw, uint dh) { uint stride = sw*BPP, wfrac = (sw<<12)/dw, hfrac = (sh<<12)/dh; for(uint dy = 0, y = 0, yi = 0; dy < dh; dy++) { uint y2 = y + hfrac, yi2 = y2>>12, h = y2 - y, ih = yi2 - yi, ylow, yhigh; if(yi < yi2) { ylow = 0x1000U - (y&0xFFFU); yhigh = y2&0xFFFU; } else { ylow = y2 - y; yhigh = 0; } for(uint dx = 0, x = 0, xi = 0; dx < dw; dx++) { uint x2 = x + wfrac, xi2 = x2>>12, w = x2 - x, iw = xi2 - xi, iy = 0, xlow, xhigh; if(xi < xi2) { xlow = 0x1000U - (x&0xFFFU); xhigh = x2&0xFFFU; } else { xlow = x2 - x; xhigh = 0; } #define OP(c, n) c##t = 0 DEFPIXEL #undef OP for(uchar *ycur = &src[xi*BPP], *xend = &ycur[max(iw, 1U)*BPP], *yend = &ycur[stride*(max(ih, 1U) + (yhigh ? 1 : 0))]; ycur < yend; ycur += stride, xend += stride, iy++) { #define OP(c, n) c = (ycur[n]*xlow)>>12 DEFPIXEL #undef OP for(uchar *xcur = &ycur[BPP]; xcur < xend; xcur += BPP) { #define OP(c, n) c += xcur[n] PIXELOP #undef OP } if(xhigh) { #define OP(c, n) c += (xend[n]*xhigh)>>12 PIXELOP #undef OP } #define OP(c, n) c = (c<<12)/w PIXELOP #undef OP if(!iy) { #define OP(c, n) c##t += (c*ylow)>>12 PIXELOP #undef OP } else if(iy==ih) { #define OP(c, n) c##t += (c*yhigh)>>12 PIXELOP #undef OP } else { #define OP(c, n) c##t += c PIXELOP #undef OP } } #define OP(c, n) dst[n] = ((c##t)<<12)/h PIXELOP #undef OP dst += BPP; x = x2; xi = xi2; } src += ih*stride; y = y2; yi = yi2; } } #undef FUNCNAME #undef DEFPIXEL #undef PIXELOP #undef BPP assaultcube-1.2.0.2.1/source/src/scoreboard.cpp000066400000000000000000000445741352165075300212670ustar00rootroot00000000000000// creation of scoreboard pseudo-menu #include "cube.h" #define SCORERATIO(F,D) (float)(F >= 0 ? F : 0) / (float)(D > 0 ? D : 1) void *scoremenu = NULL; bool needscoresreorder = true; void showscores(bool on) { if(on) showmenu("score", false); else closemenu("score"); } COMMANDF(showscores, "i", (int *on) { showscores(*on != 0); }); VARFP(sc_flags, 0, 0, 100, needscoresreorder = true); VARFP(sc_frags, 0, 1, 100, needscoresreorder = true); VARFP(sc_deaths, -1, 2, 100, needscoresreorder = true); VARFP(sc_ratio, -1, -1, 100, needscoresreorder = true); VARFP(sc_score, -1, 4, 100, needscoresreorder = true); VARFP(sc_lag, -1, 5, 100, needscoresreorder = true); VARFP(sc_clientnum, 0, 6, 100, needscoresreorder = true); VARFP(sc_name, 0, 7, 100, needscoresreorder = true); struct coldata { int priority; char *val; coldata() : priority(-1), val(NULL) {} ~coldata() { DELETEA(val); } }; // FIXME ? if two columns share teh same priority // they will be sorted by the order they were added with addcol int sortcolumns(coldata *col_a, coldata *col_b) { if(col_a->priority > col_b->priority) return 1; else if(col_a->priority < col_b->priority) return -1; return 0; } struct sline { string s; color *bgcolor; char textcolor; vector cols; sline() : bgcolor(NULL), textcolor(0) { copystring(s, ""); } void addcol(int priority, const char *format = NULL, ...) PRINTFARGS(3, 4) { if(priority < 0) return; coldata &col = cols.add(); col.priority = priority; if(format && *format) { defvformatstring(sf, format, format); col.val = newstring(sf); } } char *getcols() { if(s[0] == '\0') { if(textcolor) formatstring(s)("\f%c", textcolor); cols.sort(sortcolumns); loopv(cols) { if(i > 0) concatstring(s, "\t"); if(cols[i].val) concatstring(s, cols[i].val); } } return s; } }; static vector scorelines; vector discscores; struct teamscore { int team, frags, deaths, flagscore, points; vector teammembers; teamscore(int t) : team(t), frags(0), deaths(0), flagscore(0), points(0) {} void addplayer(playerent *d) { if(!d) return; teammembers.add(d); frags += d->frags; deaths += d->deaths; points += d->points; if(m_flags) flagscore += d->flagscore; } void addscore(discscore &d) { frags += d.frags; deaths += d.deaths; points += d.points; if(m_flags) flagscore += d.flags; } }; void calcteamscores(int scores[4]) { teamscore teamscores[2] = { teamscore(TEAM_CLA), teamscore(TEAM_RVSF) }; loopv(players) if(players[i] && players[i]->team != TEAM_SPECT) { teamscores[team_base(players[i]->team)].addplayer(players[i]); } loopv(discscores) if(discscores[i].team != TEAM_SPECT) { teamscores[team_base(discscores[i].team)].addscore(discscores[i]); } if(!watchingdemo && player1->team != TEAM_SPECT) teamscores[team_base(player1->team)].addplayer(player1); loopi(2) { scores[i] = teamscores[i].flagscore; scores[i + 2] = teamscores[i].frags; } } static int teamscorecmp(const teamscore *x, const teamscore *y) { if(x->flagscore > y->flagscore) return -1; if(x->flagscore < y->flagscore) return 1; if(x->frags > y->frags) return -1; if(x->frags < y->frags) return 1; if(x->points > y->points) return -1; if(x->points < y->points) return 1; if(x->deaths < y->deaths) return -1; return 0; } static int scorecmp(playerent **x, playerent **y) { if((*x)->flagscore > (*y)->flagscore) return -1; if((*x)->flagscore < (*y)->flagscore) return 1; if((*x)->frags > (*y)->frags) return -1; if((*x)->frags < (*y)->frags) return 1; if((*x)->points > (*y)->points) return -1; if((*x)->points < (*y)->points) return 1; if((*x)->deaths > (*y)->deaths) return 1; if((*x)->deaths < (*y)->deaths) return -1; if((*x)->lifesequence > (*y)->lifesequence) return 1; if((*x)->lifesequence < (*y)->lifesequence) return -1; return 0; } static int discscorecmp(const discscore *x, const discscore *y) { if(x->team < y->team) return -1; if(x->team > y->team) return 1; if(m_flags && x->flags > y->flags) return -1; if(m_flags && x->flags < y->flags) return 1; if(x->frags > y->frags) return -1; if(x->frags < y->frags) return 1; if(x->deaths > y->deaths) return 1; if(x->deaths < y->deaths) return -1; return strcmp(x->name, y->name); } // const char *scoreratio(int frags, int deaths, int precis = 0) // { // static string res; // float ratio = SCORERATIO(frags, deaths); // int precision = precis; // if(!precision) // { // if(ratio<10.0f) precision = 2; // else if(ratio<100.0f) precision = 1; // } // formatstring(res)("%.*f", precision, ratio); // return res; // } void renderdiscscores(int team) { loopv(discscores) if(team == team_group(discscores[i].team)) { discscore &d = discscores[i]; sline &line = scorelines.add(); if(team_isspect(d.team)) line.textcolor = '4'; const char *clag = team_isspect(d.team) ? "SPECT" : ""; if(m_flags) line.addcol(sc_flags, "%d", d.flags); line.addcol(sc_frags, "%d", d.frags); line.addcol(sc_deaths, "%d", d.deaths); line.addcol(sc_ratio, "%.2f", SCORERATIO(d.frags, d.deaths)); if(multiplayer(NULL) || watchingdemo) line.addcol(sc_score, "%d", max(d.points, 0)); line.addcol(sc_lag, "%s", clag); line.addcol(sc_clientnum, "DISC"); line.addcol(sc_name, "%s", d.name); } } VARP(cncolumncolor, 0, 5, 9); void renderscore(playerent *d) { const char *status = ""; string lagping; static color localplayerc(0.2f, 0.2f, 0.2f, 0.2f); if(d->clientrole==CR_ADMIN) status = d->state!=CS_ALIVE ? "\f7" : "\f3"; else if(d->state!=CS_ALIVE) status = "\f4"; if (team_isspect(d->team)) copystring(lagping, "SPECT"); else if (d->state==CS_LAGGED || (d->ping > 999 && d->plag > 99)) copystring(lagping, "LAG"); else { if(multiplayer(NULL)) formatstring(lagping)("%s/%s", colorpj(d->plag), colorping(d->ping)); else formatstring(lagping)("%d/%d", d->plag, d->ping); } const char *ign = d->ignored ? " (ignored)" : (d->muted ? " (muted)" : ""); sline &line = scorelines.add(); if(team_isspect(d->team)) line.textcolor = '4'; line.bgcolor = d==player1 ? &localplayerc : NULL; if(m_flags) line.addcol(sc_flags, "%d", d->flagscore); line.addcol(sc_frags, "%d", d->frags); line.addcol(sc_deaths, "%d", d->deaths); line.addcol(sc_ratio, "%.2f", SCORERATIO(d->frags, d->deaths)); if(multiplayer(NULL) || watchingdemo) { line.addcol(sc_score, "%d", max(d->points, 0)); line.addcol(sc_lag, "%s", lagping); } line.addcol(sc_clientnum, "\fs\f%d%d\fr", cncolumncolor, d->clientnum); char flagicon = '\0'; if(m_flags) //show flag icon at flag carrier with use radaricons font { loopi(2) { if(flaginfos[i].state == CTFF_STOLEN && flaginfos[i].actor == d) flagicon = m_ktf ? 'L' : "DH"[i]; } } line.addcol(sc_name, "\fs%s%s\fr%s%s%c ", status, colorname(d), ign, flagicon ? " \a" : "", flagicon); } int totalplayers = 0; void renderteamscore(teamscore *t) { if(!scorelines.empty()) // space between teams { sline &space = scorelines.add(); space.s[0] = 0; } sline &line = scorelines.add(); if(m_flags) line.addcol(sc_flags, "%d", t->flagscore); line.addcol(sc_frags, "%d", t->frags); line.addcol(sc_deaths, "%d", t->deaths); line.addcol(sc_ratio, "%.2f", SCORERATIO(t->frags, t->deaths)); if(multiplayer(NULL) || watchingdemo) { line.addcol(sc_score, "%d", max(t->points, 0)); line.addcol(sc_lag); } line.addcol(sc_clientnum, "%s", team_string(t->team)); int n = t->teammembers.length(); line.addcol(sc_name, "(%d %s)", n, n == 1 ? "player" : "players"); static color teamcolors[2] = { color(1.0f, 0, 0, 0.2f), color(0, 0, 1.0f, 0.2f) }; line.bgcolor = &teamcolors[team_base(t->team)]; loopv(t->teammembers) renderscore(t->teammembers[i]); } extern bool watchingdemo; void reorderscorecolumns() { static string scoreboardtitle; needscoresreorder = false; extern void *scoremenu; sline sscore; if(m_flags) sscore.addcol(sc_flags, "flags"); sscore.addcol(sc_frags, "frags"); sscore.addcol(sc_deaths, "deaths"); sscore.addcol(sc_ratio, "ratio"); if(multiplayer(NULL) || watchingdemo) { sscore.addcol(sc_score, "score"); sscore.addcol(sc_lag, "pj/ping"); } sscore.addcol(sc_clientnum, "cn"); sscore.addcol(sc_name, "name"); copystring(scoreboardtitle, sscore.getcols()); menutitlemanual(scoremenu, scoreboardtitle); } void renderscores(void *menu, bool init) { if(needscoresreorder) reorderscorecolumns(); static string modeline, serverline; modeline[0] = '\0'; serverline[0] = '\0'; scorelines.shrink(0); vector scores; if(!watchingdemo) scores.add(player1); totalplayers = 1; loopv(players) if(players[i]) { scores.add(players[i]); totalplayers++; } scores.sort(scorecmp); discscores.sort(discscorecmp); int spectators = 0; loopv(scores) if(scores[i]->team == TEAM_SPECT) spectators++; loopv(discscores) if(discscores[i].team == TEAM_SPECT) spectators++; int winner = -1; if(m_teammode) { teamscore teamscores[2] = { teamscore(TEAM_CLA), teamscore(TEAM_RVSF) }; loopv(scores) if(scores[i]->team != TEAM_SPECT) teamscores[team_base(scores[i]->team)].addplayer(scores[i]); loopv(discscores) if(discscores[i].team != TEAM_SPECT) teamscores[team_base(discscores[i].team)].addscore(discscores[i]); int sort = teamscorecmp(&teamscores[TEAM_CLA], &teamscores[TEAM_RVSF]) < 0 ? 0 : 1; loopi(2) { renderteamscore(&teamscores[sort ^ i]); renderdiscscores(sort ^ i); } winner = m_flags ? (teamscores[sort].flagscore > teamscores[team_opposite(sort)].flagscore ? sort : -1) : (teamscores[sort].frags > teamscores[team_opposite(sort)].frags ? sort : -1); } else { // ffa mode loopv(scores) if(scores[i]->team != TEAM_SPECT) renderscore(scores[i]); loopi(2) renderdiscscores(i); if(scores.length() > 0) { winner = scores[0]->clientnum; if(scores.length() > 1 && ((m_flags && scores[0]->flagscore == scores[1]->flagscore) || (!m_flags && scores[0]->frags == scores[1]->frags))) winner = -1; } } if(spectators) { if(!scorelines.empty()) // space between teams and spectators { sline &space = scorelines.add(); space.s[0] = 0; } renderdiscscores(TEAM_SPECT); loopv(scores) if(scores[i]->team == TEAM_SPECT) renderscore(scores[i]); } if(getclientmap()[0]) { bool fldrprefix = !strncmp(getclientmap(), "maps/", strlen("maps/")); formatstring(modeline)("\"%s\" on map %s", modestr(gamemode, modeacronyms > 0), fldrprefix ? getclientmap()+strlen("maps/") : getclientmap()); } extern int minutesremaining, gametimedisplay; extern string gtime; if((gamemode>1 || (gamemode==0 && (multiplayer(NULL) || watchingdemo))) && minutesremaining >= 0) { if(!minutesremaining) { concatstring(modeline, ", intermission"); if (m_teammode) // Add in the winning team { switch(winner) { case TEAM_CLA: concatstring(modeline, ", \f3CLA wins!"); break; case TEAM_RVSF: concatstring(modeline, ", \f1RVSF wins!"); break; case -1: default: concatstring(modeline, ", \f2it's a tie!"); break; } } else // Add the winning player { if (winner < 0) concatstring(modeline, ", \f2it's a tie!"); else concatformatstring(modeline, ", \f1%s wins!", scores[0]->name); } } else { concatformatstring(modeline, ", %s", gtime); if(gametimedisplay == 2) concatformatstring(modeline, " / %d:00", gametimemaximum/60000); else concatformatstring(modeline, " remaining"); } } if(multiplayer(NULL)) { serverinfo *s = getconnectedserverinfo(); if(s) { if(servstate.mastermode > MM_OPEN) { if(servstate.mastermode == MM_MATCH) concatformatstring(serverline, "M%d ", servstate.matchteamsize); else concatstring(serverline, "P "); } // ft: 2010jun12: this can write over the menu boundary //concatformatstring(serverline, "%s:%d %s", s->name, s->port, s->sdesc); // for now we'll just cut it off, same as the serverbrowser // but we might want to consider wrapping the bottom-line to accomodate longer descriptions - to a limit. string text; filtertext(text, s->sdesc, FTXT__SERVDESC); //for(char *p = text; (p = strchr(p, '\"')); *p++ = ' '); //text[30] = '\0'; // serverbrowser has less room - +8 chars here - 2010AUG03 - seems it was too much, falling back to 30 (for now): TODO get real width of menu as reference-width. FIXME: cutoff concatformatstring(serverline, "%s:%d %s", s->name, s->port, text); //printf("SERVERLINE: %s\n", serverline); } } menureset(menu); loopv(scorelines) menuimagemanual(menu, NULL, "radaricons", scorelines[i].getcols(), NULL, scorelines[i].bgcolor); menuheader(menu, modeline, serverline); // update server stats static int lastrefresh = 0; if(!lastrefresh || lastrefresh+5000 scores; if(!buf) buf = (char *) malloc(MAXJPGCOM +1); if(!buf) return ""; if(!watchingdemo) scores.add(player1); loopv(players) if(players[i]) scores.add(players[i]); scores.sort(scorecmp); copystring(buf, "Comment", MAXJPGCOM); // include PNG keyword and skip it (which looks like a hack because it is one) char *t = buf + 8, *e = buf + MAXJPGCOM; if(destjpg) { formatstring(text)("AssaultCube Screenshot (%s)\n", asctimestr()); addstr(t, e, text); } if(getclientmap()[0]) { formatstring(text)("\n\"%s\" on map %s", modestr(gamemode, 0), getclientmap()); addstr(t, e, text); } if(multiplayer(NULL)) { serverinfo *s = getconnectedserverinfo(); if(s) { string sdesc; filtertext(sdesc, s->sdesc, FTXT__SERVDESC | FTXT_NOCOLOR); formatstring(text)(", %s:%d %s", s->name, s->port, sdesc); addstr(t, e, text); } } if(destjpg) addstr(t, e, "\n"); else { formatstring(text)("\n%sfrags deaths cn%s name\n", m_flags ? "flags " : "", m_teammode ? " team" : ""); addstr(t, e, text); } loopv(scores) { d = scores[i]; // const char *sr = scoreratio(d->frags, d->deaths); formatstring(team)(destjpg ? ", %s" : " %-4s", team_string(d->team, true)); formatstring(flags)(destjpg ? "%d/" : " %4d ", d->flagscore); if(destjpg) formatstring(text)("%s%s (%s%d/%d)\n", d->name, m_teammode ? team : "", m_flags ? flags : "", d->frags, d->deaths); else formatstring(text)("%s %4d %4d %2d%s %s%s\n", m_flags ? flags : "", d->frags, d->deaths, d->clientnum, m_teammode ? team : "", d->name, d->clientrole==CR_ADMIN ? " (admin)" : d==player1 ? " (you)" : ""); addstr(t, e, text); } discscores.sort(discscorecmp); loopv(discscores) { discscore &d = discscores[i]; // const char *sr = scoreratio(d.frags, d.deaths); formatstring(team)(destjpg ? ", %s" : " %-4s", team_string(d.team, true)); formatstring(flags)(destjpg ? "%d/" : " %4d ", d.flags); if(destjpg) formatstring(text)("%s(disconnected)%s (%s%d/%d)\n", d.name, m_teammode ? team : "", m_flags ? flags : "", d.frags, d.deaths); else formatstring(text)("%s %4d %4d --%s %s(disconnected)\n", m_flags ? flags : "", d.frags, d.deaths, m_teammode ? team : "", d.name); addstr(t, e, text); } if(destjpg) { extern int minutesremaining; formatstring(text)("(%sfrags/deaths), %d minute%s remaining\n", m_flags ? "flags/" : "", minutesremaining, minutesremaining == 1 ? "" : "s"); addstr(t, e, text); } return buf + 8; } void consolescores() { printf("%s\n", asciiscores()); } void winners() { string winners = ""; vector scores; if(!watchingdemo) scores.add(player1); loopv(players) if(players[i]) { scores.add(players[i]); } scores.sort(scorecmp); discscores.sort(discscorecmp); if(m_teammode) { teamscore teamscores[2] = { teamscore(TEAM_CLA), teamscore(TEAM_RVSF) }; loopv(scores) if(scores[i]->team != TEAM_SPECT) teamscores[team_base(scores[i]->team)].addplayer(scores[i]); loopv(discscores) if(discscores[i].team != TEAM_SPECT) teamscores[team_base(discscores[i].team)].addscore(discscores[i]); int sort = teamscorecmp(&teamscores[TEAM_CLA], &teamscores[TEAM_RVSF]); if(!sort) copystring(winners, "0 1"); else itoa(winners, sort < 0 ? 0 : 1); } else { loopv(scores) { if(!i || !scorecmp(&scores[i], &scores[i-1])) concatformatstring(winners, "%s%d", i ? " " : "", scores[i]->clientnum); else break; } } result(winners); } COMMAND(winners, ""); assaultcube-1.2.0.2.1/source/src/server.cpp000066400000000000000000004764751352165075300204630ustar00rootroot00000000000000// server.cpp: little more than enhanced multicaster // runs dedicated or as client coroutine #include "cube.h" #ifdef STANDALONE #define DEBUGCOND (true) #else VARP(serverdebug, 0, 0, 1); #define DEBUGCOND (serverdebug==1) #endif #include "server.h" #include "servercontroller.h" #include "serverfiles.h" // 2011feb05:ft: quitproc #include "signal.h" // config vector servermaps; // all available maps kept in memory servercontroller *svcctrl = NULL; servercommandline scl; servermaprot maprot; serveripblacklist ipblacklist; servernickblacklist nickblacklist; serverforbiddenlist forbiddenlist; serverpasswords passwords; serverinfofile infofiles; // server state bool isdedicated = false; ENetHost *serverhost = NULL; int laststatus = 0, servmillis = 0, lastfillup = 0; vector clients; vector worldstates; vector savedscores; vector bans; vector demofiles; int mastermode = MM_OPEN; static bool autoteam = true; int matchteamsize = 0; long int incoming_size = 0; static bool forceintermission = false; string servdesc_current; ENetAddress servdesc_caller; bool custom_servdesc = false; // current game string smapname, nextmapname; int smode = 0, nextgamemode; int interm = 0; static int minremain = 0, gamemillis = 0, gamelimit = 0, /*lmsitemtype = 0,*/ nextsendscore = 0; mapstats smapstats; vector sents; char *maplayout = NULL, *testlayout = NULL; int maplayout_factor, testlayout_factor, maplayoutssize; servermapbuffer mapbuffer; // cmod char *global_name; int totalclients = 0; int cn2boot; int servertime = 0, serverlagged = 0; // synchronising the worker threads... void poll_serverthreads() // called once per mainloop-timeslice { static vector servermapstodelete; static int stage = 0, lastworkerthreadstart = 0; switch(stage) { default: // start first thread { if(startnewservermapsepoch || readmapsthread_sem->getvalue()) fatal("thread management mishap"); // zero tolerance... // wake readmapsthread logline(ACLOG_INFO,"waking readmapsthread"); startnewservermapsepoch = true; readmapsthread_sem->post(); stage = 1; lastworkerthreadstart = servmillis; break; } case 1: // readmapsthread building/updating the list of maps in memory { servermap *fresh = (servermap *) servermapdropbox; if(fresh) { if(fresh == servermapdropbox) { // got new servermap... loopv(servermaps) { if(!strcmp(servermaps[i]->fname, fresh->fname)) // we don't check paths here - map filenames have to be unique { // found map of same name logline(ACLOG_INFO,"marked servermap %s%s for deletion", servermaps[i]->fpath, servermaps[i]->fname); servermapstodelete.add(servermaps.remove(i)); // mark old version for deletion } } if(fresh->isok) { servermaps.add(fresh); logline(ACLOG_INFO,"added servermap %s%s", fresh->fpath, fresh->fname); } servermapdropbox = NULL; } readmapsthread_sem->post(); } else if(!startnewservermapsepoch) { // readmapsthread is done while(!readmapsthread_sem->trywait()) ; stage++; } break; } case 2: // wake readconfigsthread #if 0 { readallconfigfiles = true; readconfigsthread_sem.post(); stage++; break; } case 3: // readconfigsthread { stage++; break; } case 4: // pause worker threads for a while (restart once a minute) #endif { if(servmillis - lastworkerthreadstart > 60 * 1000) stage = 0; else if(numclients() == 0) { // empty server and nothing to do: loopvrev(servermapstodelete) delete servermapstodelete.remove(i); // delete outdated servermaps } break; } } } bool valid_client(int cn) { return clients.inrange(cn) && clients[cn]->type != ST_EMPTY; } void cleanworldstate(ENetPacket *packet) { loopv(worldstates) { worldstate *ws = worldstates[i]; if(ws->positions.inbuf(packet->data) || ws->messages.inbuf(packet->data)) ws->uses--; else continue; if(!ws->uses) { delete ws; worldstates.remove(i); } break; } } void sendpacket(int n, int chan, ENetPacket *packet, int exclude, bool demopacket) { if(n<0) { recordpacket(chan, packet->data, (int)packet->dataLength); loopv(clients) if(i!=exclude && (clients[i]->type!=ST_TCPIP || clients[i]->isauthed)) sendpacket(i, chan, packet, -1, demopacket); return; } switch(clients[n]->type) { case ST_TCPIP: { enet_peer_send(clients[n]->peer, chan, packet); break; } case ST_LOCAL: localservertoclient(chan, packet->data, (int)packet->dataLength, demopacket); break; } } static bool reliablemessages = false; bool buildworldstate() { static struct { int posoff, poslen, msgoff, msglen; } pkt[MAXCLIENTS]; worldstate &ws = *new worldstate; loopv(clients) { client &c = *clients[i]; if(c.type!=ST_TCPIP || !c.isauthed) continue; c.overflow = 0; if(c.position.empty()) pkt[i].posoff = -1; else { pkt[i].posoff = ws.positions.length(); ws.positions.put(c.position.getbuf(), c.position.length()); pkt[i].poslen = ws.positions.length() - pkt[i].posoff; c.position.setsize(0); } if(c.messages.empty()) pkt[i].msgoff = -1; else { pkt[i].msgoff = ws.messages.length(); putint(ws.messages, SV_CLIENT); putint(ws.messages, c.clientnum); putuint(ws.messages, c.messages.length()); ws.messages.put(c.messages.getbuf(), c.messages.length()); pkt[i].msglen = ws.messages.length() - pkt[i].msgoff; c.messages.setsize(0); } } int psize = ws.positions.length(), msize = ws.messages.length(); if(psize) { recordpacket(0, ws.positions.getbuf(), psize); ucharbuf p = ws.positions.reserve(psize); p.put(ws.positions.getbuf(), psize); ws.positions.addbuf(p); } if(msize) { recordpacket(1, ws.messages.getbuf(), msize); ucharbuf p = ws.messages.reserve(msize); p.put(ws.messages.getbuf(), msize); ws.messages.addbuf(p); } ws.uses = 0; loopv(clients) { client &c = *clients[i]; if(c.type!=ST_TCPIP || !c.isauthed) continue; ENetPacket *packet; if(psize && (pkt[i].posoff<0 || psize-pkt[i].poslen>0)) { packet = enet_packet_create(&ws.positions[pkt[i].posoff<0 ? 0 : pkt[i].posoff+pkt[i].poslen], pkt[i].posoff<0 ? psize : psize-pkt[i].poslen, ENET_PACKET_FLAG_NO_ALLOCATE); sendpacket(c.clientnum, 0, packet); if(!packet->referenceCount) enet_packet_destroy(packet); else { ++ws.uses; packet->freeCallback = cleanworldstate; } } if(msize && (pkt[i].msgoff<0 || msize-pkt[i].msglen>0)) { packet = enet_packet_create(&ws.messages[pkt[i].msgoff<0 ? 0 : pkt[i].msgoff+pkt[i].msglen], pkt[i].msgoff<0 ? msize : msize-pkt[i].msglen, (reliablemessages ? ENET_PACKET_FLAG_RELIABLE : 0) | ENET_PACKET_FLAG_NO_ALLOCATE); sendpacket(c.clientnum, 1, packet); if(!packet->referenceCount) enet_packet_destroy(packet); else { ++ws.uses; packet->freeCallback = cleanworldstate; } } } reliablemessages = false; if(!ws.uses) { delete &ws; return false; } else { worldstates.add(&ws); return true; } } int countclients(int type, bool exclude = false) { int num = 0; loopv(clients) if((clients[i]->type!=type)==exclude) num++; return num; } int numclients() { return countclients(ST_EMPTY, true); } int numlocalclients() { return countclients(ST_LOCAL); } int numnonlocalclients() { return countclients(ST_TCPIP); } int numauthedclients() { int num = 0; loopv(clients) if(clients[i]->type!=ST_EMPTY && clients[i]->isauthed) num++; return num; } int numactiveclients() { int num = 0; loopv(clients) if(clients[i]->type!=ST_EMPTY && clients[i]->isauthed && clients[i]->isonrightmap && team_isactive(clients[i]->team)) num++; return num; } int *numteamclients(int exclude = -1) { static int num[TEAM_NUM]; loopi(TEAM_NUM) num[i] = 0; loopv(clients) if(i != exclude && clients[i]->type!=ST_EMPTY && clients[i]->isauthed && clients[i]->isonrightmap && team_isvalid(clients[i]->team)) num[clients[i]->team]++; return num; } int sendservermode(bool send = true) { int sm = (autoteam ? AT_ENABLED : AT_DISABLED) | ((mastermode & MM_MASK) << 2) | (matchteamsize << 4); if(send) sendf(-1, 1, "ri2", SV_SERVERMODE, sm); return sm; } void changematchteamsize(int newteamsize) { if(newteamsize < 0) return; if(matchteamsize != newteamsize) { matchteamsize = newteamsize; sendservermode(); } if(mastermode == MM_MATCH && matchteamsize && m_teammode) { int size[2] = { 0 }; loopv(clients) if(clients[i]->type!=ST_EMPTY && clients[i]->isauthed && clients[i]->isonrightmap) { if(team_isactive(clients[i]->team)) { if(++size[clients[i]->team] > matchteamsize) updateclientteam(i, team_tospec(clients[i]->team), FTR_SILENTFORCE); } } } } void changemastermode(int newmode) { if(mastermode != newmode) { mastermode = newmode; senddisconnectedscores(-1); if(mastermode != MM_MATCH) { loopv(clients) if(clients[i]->type!=ST_EMPTY && clients[i]->isauthed) { if(clients[i]->team == TEAM_CLA_SPECT || clients[i]->team == TEAM_RVSF_SPECT) updateclientteam(i, TEAM_SPECT, FTR_SILENTFORCE); } } else if(matchteamsize) changematchteamsize(matchteamsize); sendservermode(); } } int findcnbyaddress(ENetAddress *address) { loopv(clients) { if(clients[i]->type == ST_TCPIP && clients[i]->peer->address.host == address->host && clients[i]->peer->address.port == address->port) return i; } return -1; } savedscore *findscore(client &c, bool insert) { if(c.type!=ST_TCPIP) return NULL; enet_uint32 mask = ENET_HOST_TO_NET_32(mastermode == MM_MATCH ? 0xFFFF0000 : 0xFFFFFFFF); // in match mode, reconnecting from /16 subnet is allowed if(!insert) { loopv(clients) { client &o = *clients[i]; if(o.type!=ST_TCPIP || !o.isauthed) continue; if(o.clientnum!=c.clientnum && o.peer->address.host==c.peer->address.host && !strcmp(o.name, c.name)) { static savedscore curscore; curscore.save(o.state, o.team); return &curscore; } } } loopv(savedscores) { savedscore &sc = savedscores[i]; if(!strcmp(sc.name, c.name) && (sc.ip & mask) == (c.peer->address.host & mask)) return ≻ } if(!insert) return NULL; savedscore &sc = savedscores.add(); copystring(sc.name, c.name); sc.ip = c.peer->address.host; return ≻ } void sendf(int cn, int chan, const char *format, ...) { int exclude = -1; bool reliable = false; if(*format=='r') { reliable = true; ++format; } packetbuf p(MAXTRANS, reliable ? ENET_PACKET_FLAG_RELIABLE : 0); va_list args; va_start(args, format); while(*format) switch(*format++) { case 'x': exclude = va_arg(args, int); break; case 'v': { int n = va_arg(args, int); int *v = va_arg(args, int *); loopi(n) putint(p, v[i]); break; } case 'i': { int n = isdigit(*format) ? *format++-'0' : 1; loopi(n) putint(p, va_arg(args, int)); break; } case 'a': { int n = isdigit(*format) ? *format++-'0' : 1; loopi(n) putaint(p, va_arg(args, int)); break; } case 's': sendstring(va_arg(args, const char *), p); break; case 'm': { int n = va_arg(args, int); p.put(va_arg(args, uchar *), n); break; } } va_end(args); sendpacket(cn, chan, p.finalize(), exclude); } void sendextras() { if ( gamemillis < nextsendscore ) return; int count = 0, list[MAXCLIENTS]; loopv(clients) { client &c = *clients[i]; if ( c.type!=ST_TCPIP || !c.isauthed || !(c.md.updated && c.md.upmillis < gamemillis) ) continue; if ( c.md.combosend ) { sendf(c.clientnum, 1, "ri2", SV_HUDEXTRAS, min(c.md.combo,c.md.combofrags)-1 + HE_COMBO); c.md.combosend = false; } if ( c.md.dpt ) { list[count] = i; count++; } } nextsendscore = gamemillis + 160; // about 4 cicles if ( !count ) return; packetbuf p(MAXTRANS, ENET_PACKET_FLAG_RELIABLE); putint(p, SV_POINTS); putint(p,count); int *v = list; loopi(count) { client &c = *clients[*v]; putint(p,c.clientnum); putint(p,c.md.dpt); c.md.updated = false; c.md.upmillis = c.md.dpt = 0; v++; } sendpacket(-1, 1, p.finalize()); } void sendservmsg(const char *msg, int cn = -1) { sendf(cn, 1, "ris", SV_SERVMSG, msg); } void sendspawn(client *c) { if(team_isspect(c->team)) return; clientstate &gs = c->state; gs.respawn(); gs.spawnstate(smode); gs.lifesequence++; sendf(c->clientnum, 1, "ri7vv", SV_SPAWNSTATE, gs.lifesequence, gs.health, gs.armour, gs.primary, gs.gunselect, m_arena ? c->spawnindex : -1, NUMGUNS, gs.ammo, NUMGUNS, gs.mag); gs.lastspawn = gamemillis; } // demo stream *demotmp = NULL, *demorecord = NULL, *demoplayback = NULL; bool recordpackets = false; int nextplayback = 0; void writedemo(int chan, void *data, int len) { if(!demorecord) return; int stamp[3] = { gamemillis, chan, len }; lilswap(stamp, 3); demorecord->write(stamp, sizeof(stamp)); demorecord->write(data, len); } void recordpacket(int chan, void *data, int len) { if(recordpackets) writedemo(chan, data, len); } void recordpacket(int chan, ENetPacket *packet) { if(recordpackets) writedemo(chan, packet->data, (int)packet->dataLength); } #ifdef STANDALONE const char *currentserver(int i) { static string curSRVinfo; string r; r[0] = '\0'; switch(i) { case 1: { copystring(r, scl.ip[0] ? scl.ip : "local"); break; } // IP case 2: { copystring(r, scl.logident[0] ? scl.logident : "local"); break; } // HOST case 3: { formatstring(r)("%d", scl.serverport); break; } // PORT // the following are used by a client, a server will simply return empty strings for them case 4: case 5: case 6: case 7: case 8: { break; } default: { formatstring(r)("%s %d", scl.ip[0] ? scl.ip : "local", scl.serverport); break; } } copystring(curSRVinfo, r); return curSRVinfo; } #endif // these are actually the values used by the client, the server ones are in "scl". string demofilenameformat = DEFDEMOFILEFMT; string demotimestampformat = DEFDEMOTIMEFMT; int demotimelocal = 0; #ifdef STANDALONE #define DEMOFORMAT scl.demofilenameformat #define DEMOTSFORMAT scl.demotimestampformat #else #define DEMOFORMAT demofilenameformat #define DEMOTSFORMAT demotimestampformat #endif const char *getDemoFilename(int gmode, int mplay, int mdrop, int tstamp, char *srvmap) { // we use the following internal mapping of formatchars: // %g : gamemode (int) %G : gamemode (chr) %F : gamemode (full) // %m : minutes remaining %M : minutes played // %s : seconds remaining %S : seconds played // %h : IP of server %H : hostname of server // %n : mapName // %w : timestamp "when" static string dmofn; copystring(dmofn, ""); int cc = 0; int mc = strlen(DEMOFORMAT); while(ccsize(); demotmp->seek(0, SEEK_SET); if(demofiles.length() >= scl.maxdemos) { delete[] demofiles[0].data; demofiles.remove(0); } int mr = gamemillis >= gamelimit ? 0 : (gamelimit - gamemillis + 60000 - 1)/60000; demofile &d = demofiles.add(); //2010oct10:ft: suggests : formatstring(d.info)("%s, %s, %.2f%s", modestr(gamemode), smapname, len > 1024*1024 ? len/(1024*1024.f) : len/1024.0f, len > 1024*1024 ? "MB" : "kB"); // the datetime bit is pretty useless in the servmesg, no?! formatstring(d.info)("%s: %s, %s, %.2f%s", asctimestr(), modestr(gamemode), smapname, len > 1024*1024 ? len/(1024*1024.f) : len/1024.0f, len > 1024*1024 ? "MB" : "kB"); if(mr) { concatformatstring(d.info, ", %d mr", mr); concatformatstring(d.file, "_%dmr", mr); } defformatstring(msg)("Demo \"%s\" recorded\nPress F10 to download it from the server..", d.info); sendservmsg(msg); logline(ACLOG_INFO, "Demo \"%s\" recorded.", d.info); // 2011feb05:ft: previously these two static formatstrings were used .. //formatstring(d.file)("%s_%s_%s", timestring(), behindpath(smapname), modestr(gamemode, true)); // 20100522_10.08.48_ac_mines_DM.dmo //formatstring(d.file)("%s_%s_%s", modestr(gamemode, true), behindpath(smapname), timestring( true, "%Y.%m.%d_%H%M")); // DM_ac_mines.2010.05.22_1008.dmo // .. now we use client-side parseable fileattribs int mPLAY = gamemillis >= gamelimit ? gamelimit/1000 : gamemillis/1000; int mDROP = gamemillis >= gamelimit ? 0 : (gamelimit - gamemillis)/1000; int iTIME = time(NULL); const char *mTIME = numtime(); const char *sMAPN = behindpath(smapname); string iMAPN; copystring(iMAPN, sMAPN); formatstring(d.file)( "%d:%d:%d:%s:%s", gamemode, mPLAY, mDROP, mTIME, iMAPN); d.data = new uchar[len]; d.len = len; demotmp->read(d.data, len); delete demotmp; demotmp = NULL; if(scl.demopath[0]) { formatstring(msg)("%s%s.dmo", scl.demopath, getDemoFilename(gamemode, mPLAY, mDROP, iTIME, iMAPN)); //d.file); path(msg); stream *demo = openfile(msg, "wb"); if(demo) { int wlen = (int) demo->write(d.data, d.len); delete demo; logline(ACLOG_INFO, "demo written to file \"%s\" (%d bytes)", msg, wlen); } else { logline(ACLOG_INFO, "failed to write demo to file \"%s\"", msg); } } } void setupdemorecord() { if(numlocalclients() || !m_mp(gamemode) || gamemode == GMODE_COOPEDIT) return; defformatstring(demotmppath)("demos/demorecord_%s_%d", scl.ip[0] ? scl.ip : "local", scl.serverport); demotmp = opentempfile(demotmppath, "w+b"); if(!demotmp) return; stream *f = opengzfile(NULL, "wb", demotmp); if(!f) { delete demotmp; demotmp = NULL; return; } sendservmsg("recording demo"); logline(ACLOG_INFO, "Demo recording started."); demorecord = f; recordpackets = false; demoheader hdr; memcpy(hdr.magic, DEMO_MAGIC, sizeof(hdr.magic)); hdr.version = DEMO_VERSION; hdr.protocol = SERVER_PROTOCOL_VERSION; lilswap(&hdr.version, 1); lilswap(&hdr.protocol, 1); memset(hdr.desc, 0, DHDR_DESCCHARS); defformatstring(desc)("%s, %s, %s %s", modestr(gamemode, false), behindpath(smapname), asctimestr(), servdesc_current); if(strlen(desc) > DHDR_DESCCHARS) formatstring(desc)("%s, %s, %s %s", modestr(gamemode, true), behindpath(smapname), asctimestr(), servdesc_current); desc[DHDR_DESCCHARS - 1] = '\0'; strcpy(hdr.desc, desc); memset(hdr.plist, 0, DHDR_PLISTCHARS); const char *bl = ""; loopv(clients) { client *ci = clients[i]; if(ci->type==ST_EMPTY) continue; if(strlen(hdr.plist) + strlen(ci->name) < DHDR_PLISTCHARS - 2) { strcat(hdr.plist, bl); strcat(hdr.plist, ci->name); } bl = " "; } demorecord->write(&hdr, sizeof(demoheader)); packetbuf p(MAXTRANS, ENET_PACKET_FLAG_RELIABLE); welcomepacket(p, -1); writedemo(1, p.buf, p.len); } void listdemos(int cn) { packetbuf p(MAXTRANS, ENET_PACKET_FLAG_RELIABLE); putint(p, SV_SENDDEMOLIST); putint(p, demofiles.length()); loopv(demofiles) sendstring(demofiles[i].info, p); sendpacket(cn, 1, p.finalize()); } static void cleardemos(int n) { if(!n) { loopv(demofiles) delete[] demofiles[i].data; demofiles.shrink(0); sendservmsg("cleared all demos"); } else if(demofiles.inrange(n-1)) { delete[] demofiles[n-1].data; demofiles.remove(n-1); defformatstring(msg)("cleared demo %d", n); sendservmsg(msg); } } bool sending_demo = false; void senddemo(int cn, int num) { client *cl = cn>=0 ? clients[cn] : NULL; bool is_admin = (cl && cl->role == CR_ADMIN); if(scl.demo_interm && (!interm || totalclients > 2) && !is_admin) { sendservmsg("\f3sorry, but this server only sends demos at intermission.\n wait for the end of this game, please", cn); return; } if(!num) num = demofiles.length(); if(!demofiles.inrange(num-1)) { if(demofiles.empty()) sendservmsg("no demos available", cn); else { defformatstring(msg)("no demo %d available", num); sendservmsg(msg, cn); } return; } demofile &d = demofiles[num-1]; loopv(d.clientssent) if(d.clientssent[i].ip == cl->peer->address.host && d.clientssent[i].clientnum == cl->clientnum) { sendservmsg("\f3Sorry, you have already downloaded this demo.", cl->clientnum); return; } clientidentity &ci = d.clientssent.add(); ci.ip = cl->peer->address.host; ci.clientnum = cl->clientnum; if (interm) sending_demo = true; packetbuf p(MAXTRANS + d.len, ENET_PACKET_FLAG_RELIABLE); putint(p, SV_SENDDEMO); sendstring(d.file, p); putint(p, d.len); p.put(d.data, d.len); sendpacket(cn, 2, p.finalize()); } int demoprotocol; bool watchingdemo = false; void enddemoplayback() { if(!demoplayback) return; delete demoplayback; demoplayback = NULL; watchingdemo = false; loopv(clients) sendf(i, 1, "risi", SV_DEMOPLAYBACK, "", i); sendservmsg("demo playback finished"); loopv(clients) sendwelcome(clients[i]); } void setupdemoplayback() { demoheader hdr; string msg; msg[0] = '\0'; defformatstring(file)("demos/%s.dmo", smapname); path(file); demoplayback = opengzfile(file, "rb"); if(!demoplayback) formatstring(msg)("could not read demo \"%s\"", file); else if(demoplayback->read(&hdr, sizeof(demoheader))!=sizeof(demoheader) || memcmp(hdr.magic, DEMO_MAGIC, sizeof(hdr.magic))) formatstring(msg)("\"%s\" is not a demo file", file); else { lilswap(&hdr.version, 1); lilswap(&hdr.protocol, 1); if(hdr.version!=DEMO_VERSION) formatstring(msg)("demo \"%s\" requires an %s version of AssaultCube", file, hdr.versionread(&nextplayback, sizeof(nextplayback))!=sizeof(nextplayback)) { enddemoplayback(); return; } lilswap(&nextplayback, 1); } void readdemo() { if(!demoplayback) return; while(gamemillis>=nextplayback) { int chan, len; if(demoplayback->read(&chan, sizeof(chan))!=sizeof(chan) || demoplayback->read(&len, sizeof(len))!=sizeof(len)) { enddemoplayback(); return; } lilswap(&chan, 1); lilswap(&len, 1); ENetPacket *packet = enet_packet_create(NULL, len, 0); if(!packet || demoplayback->read(packet->data, len)!=len) { if(packet) enet_packet_destroy(packet); enddemoplayback(); return; } sendpacket(-1, chan, packet, -1, true); if(!packet->referenceCount) enet_packet_destroy(packet); if(demoplayback->read(&nextplayback, sizeof(nextplayback))!=sizeof(nextplayback)) { enddemoplayback(); return; } lilswap(&nextplayback, 1); } } struct sflaginfo { int state; int actor_cn; float pos[3]; int lastupdate; int stolentime; short x, y; // flag entity location sflaginfo() { actor_cn = -1; } } sflaginfos[2]; void putflaginfo(packetbuf &p, int flag) { sflaginfo &f = sflaginfos[flag]; putint(p, SV_FLAGINFO); putint(p, flag); putint(p, f.state); switch(f.state) { case CTFF_STOLEN: putint(p, f.actor_cn); break; case CTFF_DROPPED: loopi(3) putuint(p, (int)(f.pos[i]*DMF)); break; } } inline void send_item_list(packetbuf &p) { putint(p, SV_ITEMLIST); loopv(sents) if(sents[i].spawned) putint(p, i); putint(p, -1); if(m_flags) loopi(2) putflaginfo(p, i); } #include "serverchecks.h" bool flagdistance(sflaginfo &f, int cn) { if(!valid_client(cn) || m_demo) return false; client &c = *clients[cn]; vec v(-1, -1, c.state.o.z); switch(f.state) { case CTFF_INBASE: v.x = f.x; v.y = f.y; break; case CTFF_DROPPED: v.x = f.pos[0]; v.y = f.pos[1]; break; } bool lagging = (c.ping > 1000 || c.spj > 100); if(v.x < 0 && !lagging) return true; float dist = c.state.o.dist(v); int pdist = check_pdist(&c,dist); if(pdist) { c.farpickups++; logline(ACLOG_INFO, "[%s] %s %s the %s flag at distance %.2f (%d)", c.hostname, c.name, (pdist==2?"tried to touch":"touched"), team_string(&f == sflaginfos + 1), dist, c.farpickups); if (pdist==2) return false; } return lagging ? false : true; // today I found a lag hacker :: Brahma, 19-oct-2010... lets test it a bit } void sendflaginfo(int flag = -1, int cn = -1) { packetbuf p(MAXTRANS, ENET_PACKET_FLAG_RELIABLE); if(flag >= 0) putflaginfo(p, flag); else loopi(2) putflaginfo(p, i); sendpacket(cn, 1, p.finalize()); } void flagmessage(int flag, int message, int actor, int cn = -1) { if(message == FM_KTFSCORE) sendf(cn, 1, "riiiii", SV_FLAGMSG, flag, message, actor, (gamemillis - sflaginfos[flag].stolentime) / 1000); else sendf(cn, 1, "riiii", SV_FLAGMSG, flag, message, actor); } void flagaction(int flag, int action, int actor) { if(!valid_flag(flag)) return; sflaginfo &f = sflaginfos[flag]; sflaginfo &of = sflaginfos[team_opposite(flag)]; bool deadactor = valid_client(actor) ? clients[actor]->state.state != CS_ALIVE || team_isspect(clients[actor]->team): true; int abort = 0; int score = 0; int message = -1; if(m_ctf || m_htf) { switch(action) { case FA_PICKUP: // ctf: f = enemy team htf: f = own team case FA_STEAL: { if(deadactor || f.state != (action == FA_STEAL ? CTFF_INBASE : CTFF_DROPPED) || !flagdistance(f, actor)) { abort = 10; break; } int team = team_base(clients[actor]->team); if(m_ctf) team = team_opposite(team); if(team != flag) { abort = 11; break; } f.state = CTFF_STOLEN; f.actor_cn = actor; message = FM_PICKUP; break; } case FA_LOST: if(actor == -1) actor = f.actor_cn; case FA_DROP: if(f.state!=CTFF_STOLEN || f.actor_cn != actor) { abort = 12; break; } f.state = CTFF_DROPPED; loopi(3) f.pos[i] = clients[actor]->state.o[i]; message = action == FA_LOST ? FM_LOST : FM_DROP; break; case FA_RETURN: if(f.state!=CTFF_DROPPED || m_htf) { abort = 13; break; } f.state = CTFF_INBASE; message = FM_RETURN; break; case FA_SCORE: // ctf: f = carried by actor flag, htf: f = hunted flag (run over by actor) if(m_ctf) { if(f.state != CTFF_STOLEN || f.actor_cn != actor || of.state != CTFF_INBASE || !flagdistance(of, actor)) { abort = 14; break; } score = 1; message = FM_SCORE; } else // m_htf { if(f.state != CTFF_DROPPED || !flagdistance(f, actor)) { abort = 15; break; } score = (of.state == CTFF_STOLEN) ? 1 : 0; message = score ? FM_SCORE : FM_SCOREFAIL; if(of.actor_cn == actor) score *= 2; } f.state = CTFF_INBASE; break; case FA_RESET: f.state = CTFF_INBASE; message = FM_RESET; break; } } else if(m_ktf) // f: active flag, of: idle flag { switch(action) { case FA_STEAL: if(deadactor || f.state != CTFF_INBASE || !flagdistance(f, actor)) { abort = 20; break; } f.state = CTFF_STOLEN; f.actor_cn = actor; f.stolentime = gamemillis; message = FM_PICKUP; break; case FA_SCORE: // f = carried by actor flag if(actor != -1 || f.state != CTFF_STOLEN) { abort = 21; break; } // no client msg allowed here if(valid_client(f.actor_cn) && clients[f.actor_cn]->state.state == CS_ALIVE && !team_isspect(clients[f.actor_cn]->team)) { actor = f.actor_cn; score = 1; message = FM_KTFSCORE; break; } case FA_LOST: if(actor == -1) actor = f.actor_cn; case FA_DROP: if(f.actor_cn != actor || f.state != CTFF_STOLEN) { abort = 22; break; } case FA_RESET: if(f.state == CTFF_STOLEN) { actor = f.actor_cn; message = FM_LOST; } f.state = CTFF_IDLE; of.state = CTFF_INBASE; sendflaginfo(team_opposite(flag)); break; } } if(abort) { logline(ACLOG_DEBUG,"aborting flagaction(flag %d, action %d, actor %d), reason %d, resending flag states", flag, action, actor, abort); // FIXME: remove this logline after some time - it will only show a few bad ping effects sendflaginfo(); return; } if(score) { client *c = clients[actor]; c->state.flagscore += score; sendf(-1, 1, "riii", SV_FLAGCNT, actor, c->state.flagscore); if (m_teammode) computeteamwork(c->team, c->clientnum); /** WIP */ } if(valid_client(actor)) { client &c = *clients[actor]; switch(message) { case FM_PICKUP: logline(ACLOG_INFO,"[%s] %s %s the flag", c.hostname, c.name, action == FA_STEAL ? "stole" : "picked up"); break; case FM_DROP: case FM_LOST: logline(ACLOG_INFO,"[%s] %s %s the flag", c.hostname, c.name, message == FM_LOST ? "lost" : "dropped"); break; case FM_RETURN: logline(ACLOG_INFO,"[%s] %s returned the flag", c.hostname, c.name); break; case FM_SCORE: if(m_htf) logline(ACLOG_INFO, "[%s] %s hunted the flag for %s, new score %d", c.hostname, c.name, team_string(c.team), c.state.flagscore); else logline(ACLOG_INFO, "[%s] %s scored with the flag for %s, new score %d", c.hostname, c.name, team_string(c.team), c.state.flagscore); break; case FM_KTFSCORE: logline(ACLOG_INFO, "[%s] %s scored, carrying for %d seconds, new score %d", c.hostname, c.name, (gamemillis - f.stolentime) / 1000, c.state.flagscore); break; case FM_SCOREFAIL: logline(ACLOG_INFO, "[%s] %s failed to score", c.hostname, c.name); break; default: logline(ACLOG_INFO, "flagaction %d, actor %d, flag %d, message %d", action, actor, flag, message); break; } flagpoints (&c, message); } else { switch(message) { case FM_RESET: logline(ACLOG_INFO,"the server reset the flag for team %s", team_string(flag)); break; default: logline(ACLOG_INFO, "flagaction %d with invalid actor cn %d, flag %d, message %d", action, actor, flag, message); break; } } f.lastupdate = gamemillis; sendflaginfo(flag); if(message >= 0) flagmessage(flag, message, valid_client(actor) ? actor : -1); } int clienthasflag(int cn) { if(m_flags && valid_client(cn)) { loopi(2) { if(sflaginfos[i].state==CTFF_STOLEN && sflaginfos[i].actor_cn==cn) return i; } } return -1; } void ctfreset() { int idleflag = m_ktf ? rnd(2) : -1; loopi(2) { sflaginfos[i].actor_cn = -1; sflaginfos[i].state = i == idleflag ? CTFF_IDLE : CTFF_INBASE; sflaginfos[i].lastupdate = -1; } } void sdropflag(int cn) { int fl = clienthasflag(cn); if(fl >= 0) flagaction(fl, FA_LOST, cn); } void resetflag(int cn) { int fl = clienthasflag(cn); if(fl >= 0) flagaction(fl, FA_RESET, -1); } void htf_forceflag(int flag) { sflaginfo &f = sflaginfos[flag]; int besthealth = 0; vector clientnumbers; loopv(clients) if(clients[i]->type!=ST_EMPTY) { if(clients[i]->state.state == CS_ALIVE && team_base(clients[i]->team) == flag) { if(clients[i]->state.health == besthealth) clientnumbers.add(i); else { if(clients[i]->state.health > besthealth) { besthealth = clients[i]->state.health; clientnumbers.shrink(0); clientnumbers.add(i); } } } } if(clientnumbers.length()) { int pick = rnd(clientnumbers.length()); client *cl = clients[clientnumbers[pick]]; f.state = CTFF_STOLEN; f.actor_cn = cl->clientnum; sendflaginfo(flag); flagmessage(flag, FM_PICKUP, cl->clientnum); logline(ACLOG_INFO,"[%s] %s got forced to pickup the flag", cl->hostname, cl->name); } f.lastupdate = gamemillis; } int arenaround = 0, arenaroundstartmillis = 0; int cmpscore(const int *a, const int *b) { return clients[*a]->at3_score - clients[*b]->at3_score; } vector tdistrib; vector sdistrib; void distributeteam(int team) { int numsp = team == 100 ? smapstats.spawns[2] : smapstats.spawns[team]; if(!numsp) numsp = 30; // no spawns: try to distribute anyway twoint ti; tdistrib.shrink(0); loopv(clients) if(clients[i]->type!=ST_EMPTY) { if(team == 100 || team == clients[i]->team) { tdistrib.add(i); clients[i]->at3_score = rnd(0x1000000); } } tdistrib.sort(cmpscore); // random player order sdistrib.shrink(0); loopi(numsp) { ti.val = i; ti.key = rnd(0x1000000); sdistrib.add(ti); } sdistrib.sort(cmpintasc); // random spawn order int x = 0; loopv(tdistrib) { clients[tdistrib[i]]->spawnindex = sdistrib[x++].val; x %= sdistrib.length(); } } void distributespawns() { loopv(clients) if(clients[i]->type!=ST_EMPTY) { clients[i]->spawnindex = -1; } if(m_teammode) { distributeteam(0); distributeteam(1); } else { distributeteam(100); } } bool items_blocked = false; bool free_items(int n) { client *c = clients[n]; int waitspawn = min(c->ping,200) + c->state.spawn; // flowtron to Brahma: can't this be removed now? (re: rev. 5270) return !items_blocked && (waitspawn < gamemillis); } void checkitemspawns(int); void arenacheck() { if(!m_arena || interm || gamemillistype!=ST_EMPTY && clients[i]->isauthed) { if(clients[i]->isonrightmap && team_isactive(clients[i]->team)) sendspawn(clients[i]); } items_blocked = false; return; } #ifndef STANDALONE if(m_botmode && clients[0]->type==ST_LOCAL) { int enemies = 0, alive_enemies = 0; playerent *alive = NULL; loopv(players) if(players[i] && (!m_teammode || players[i]->team == team_opposite(player1->team))) { enemies++; if(players[i]->state == CS_ALIVE) { alive = players[i]; alive_enemies++; } } if(player1->state != CS_DEAD) alive = player1; if(enemies && (!alive_enemies || player1->state == CS_DEAD)) { sendf(-1, 1, "ri2", SV_ARENAWIN, m_teammode ? (alive ? alive->clientnum : -1) : (alive && alive->type == ENT_BOT ? -2 : player1->state == CS_ALIVE ? player1->clientnum : -1)); arenaround = gamemillis+5000; } return; } #endif client *alive = NULL; bool dead = false; int lastdeath = 0; loopv(clients) { client &c = *clients[i]; if(c.type==ST_EMPTY || !c.isauthed || !c.isonrightmap || team_isspect(c.team)) continue; if(c.state.state==CS_ALIVE || ((c.state.state==CS_DEAD || c.state.state==CS_SPECTATE) && c.state.lastspawn>=0)) { if(!alive) alive = &c; else if(!m_teammode || alive->team != c.team) return; } else if(c.state.state==CS_DEAD || c.state.state==CS_SPECTATE) { dead = true; lastdeath = max(lastdeath, c.state.lastdeath); } } if(autoteam && m_teammode && mastermode != MM_MATCH) { int *ntc = numteamclients(); if((!ntc[0] || !ntc[1]) && (ntc[0] > 1 || ntc[1] > 1)) refillteams(true, FTR_AUTOTEAM); } if(!dead || gamemillis < lastdeath + 500) return; items_blocked = true; sendf(-1, 1, "ri2", SV_ARENAWIN, alive ? alive->clientnum : -1); arenaround = gamemillis+5000; if(autoteam && m_teammode) refillteams(true); } #define SPAMREPEATINTERVAL 20 // detect doubled lines only if interval < 20 seconds #define SPAMMAXREPEAT 3 // 4th time is SPAM #define SPAMCHARPERMINUTE 220 // good typist #define SPAMCHARINTERVAL 30 // allow 20 seconds typing at maxspeed bool spamdetect(client *cl, char *text) // checks doubled lines and average typing speed { if(cl->type != ST_TCPIP || cl->role == CR_ADMIN) return false; bool spam = false; int pause = servmillis - cl->lastsay; if(pause < 0 || pause > 90*1000) pause = 90*1000; cl->saychars -= (SPAMCHARPERMINUTE * pause) / (60*1000); cl->saychars += (int)strlen(text); if(cl->saychars < 0) cl->saychars = 0; if(text[0] && !strcmp(text, cl->lastsaytext) && servmillis - cl->lastsay < SPAMREPEATINTERVAL*1000) { spam = ++cl->spamcount > SPAMMAXREPEAT; } else { copystring(cl->lastsaytext, text); cl->spamcount = 0; } cl->lastsay = servmillis; if(cl->saychars > (SPAMCHARPERMINUTE * SPAMCHARINTERVAL) / 60) spam = true; return spam; } // chat message distribution matrix: // // /------------------------ common chat C c C c c C C c C // |/----------------------- RVSF chat T // ||/---------------------- CLA chat T // |||/--------------------- spect chat t t t T t T // |||| | | | | | | | | | // |||| | | | | | | | | | C: normal chat // |||| team modes: chat goes to | | | | | | | | | T: team chat // XX --> RVSF players >-----/ | | | | | | | | c: normal chat in all mastermodes except 'match' // XX X --> RVSF spect players >-------/ | | | | | | | t: all chat in mastermode 'match', otherwise only team chat // X X --> CLA players >---------/ | | | | | | // X XX --> CLA spect players >-----------/ | | | | | // X X --> SPECTATORs >-------------/ | | | | // XXXX --> SPECTATORs (admin) >---------------/ | | | // ffa modes: | | | // X --> any player (ffa mode) >-----------------/ | | // X X --> any spectator (ffa mode) >-------------------/ | // X X --> admin spectator >---------------------/ // purpose: // a) give spects a possibility to chat without annoying the players (even in ffa), // b) no hidden messages from spects to active teams, // c) no spect talk to players during 'match' void sendteamtext(char *text, int sender, int msgtype) { if(!valid_client(sender) || clients[sender]->team == TEAM_VOID) return; packetbuf p(MAXTRANS, ENET_PACKET_FLAG_RELIABLE); putint(p, msgtype); putint(p, sender); sendstring(text, p); ENetPacket *packet = p.finalize(); recordpacket(1, packet); int &st = clients[sender]->team; loopv(clients) if(i!=sender) { int &rt = clients[i]->team; if((rt == TEAM_SPECT && clients[i]->role == CR_ADMIN) || // spect-admin reads all (team_isactive(st) && st == team_group(rt)) || // player to own team + own spects (team_isspect(st) && team_isspect(rt))) // spectator to other spectators sendpacket(i, 1, packet); } } void sendvoicecomteam(int sound, int sender) { if(!valid_client(sender) || clients[sender]->team == TEAM_VOID) return; packetbuf p(MAXTRANS, ENET_PACKET_FLAG_RELIABLE); putint(p, SV_VOICECOMTEAM); putint(p, sender); putint(p, sound); ENetPacket *packet = p.finalize(); loopv(clients) if(i!=sender) { if(clients[i]->team == clients[sender]->team || !m_teammode) sendpacket(i, 1, packet); } } int numplayers() { int count = 1; #ifdef STANDALONE count = numclients(); #else if(m_botmode) { extern vector bots; loopv(bots) if(bots[i]) count++; } if(m_demo) { count = numclients(); } #endif return count; } int spawntime(int type) { int np = numplayers(); np = np<3 ? 4 : (np>4 ? 2 : 3); // Some spawn times are dependent on the number of players. int sec = 0; switch(type) { // Please update ./ac_website/htdocs/docs/introduction.html if these times change. case I_CLIPS: case I_AMMO: sec = np*2; break; case I_GRENADE: sec = np + 5; break; case I_HEALTH: sec = np*5; break; case I_HELMET: case I_ARMOUR: sec = 25; break; case I_AKIMBO: sec = 60; break; } return sec*1000; } bool serverpickup(int i, int sender) // server side item pickup, acknowledge first client that gets it { const char *hn = sender >= 0 && clients[sender]->type == ST_TCPIP ? clients[sender]->hostname : NULL; if(!sents.inrange(i)) { if(hn && !m_coop) logline(ACLOG_INFO, "[%s] tried to pick up entity #%d - doesn't exist on this map", hn, i); return false; } server_entity &e = sents[i]; if(!e.spawned) { if(!e.legalpickup && hn && !m_demo) logline(ACLOG_INFO, "[%s] tried to pick up entity #%d (%s) - can't be picked up in this gamemode or at all", hn, i, entnames[e.type]); return false; } if(sender>=0) { client *cl = clients[sender]; if(cl->type==ST_TCPIP) { if( cl->state.state!=CS_ALIVE || !cl->state.canpickup(e.type) || ( m_arena && !free_items(sender) ) ) return false; vec v(e.x, e.y, cl->state.o.z); float dist = cl->state.o.dist(v); int pdist = check_pdist(cl,dist); if (pdist) { cl->farpickups++; if (!m_demo) logline(ACLOG_INFO, "[%s] %s %s up entity #%d (%s), distance %.2f (%d)", cl->hostname, cl->name, (pdist==2?"tried to pick":"picked"), i, entnames[e.type], dist, cl->farpickups); if (pdist==2) return false; } } sendf(-1, 1, "ri3", SV_ITEMACC, i, sender); cl->state.pickup(sents[i].type); if (m_lss && sents[i].type == I_GRENADE) cl->state.pickup(sents[i].type); // get two nades at lss } e.spawned = false; if(!m_lms) e.spawntime = spawntime(e.type); return true; } void checkitemspawns(int diff) { if(!diff) return; loopv(sents) if(sents[i].spawntime) { sents[i].spawntime -= diff; if(sents[i].spawntime<=0) { sents[i].spawntime = 0; sents[i].spawned = true; sendf(-1, 1, "ri2", SV_ITEMSPAWN, i); } } } void serverdamage(client *target, client *actor, int damage, int gun, bool gib, const vec &hitpush = vec(0, 0, 0)) { if (!m_demo && !m_coop && !validdamage(target, actor, damage, gun, gib)) return; if ( m_arena && gun == GUN_GRENADE && arenaroundstartmillis + 2000 > gamemillis && target != actor ) return; clientstate &ts = target->state; ts.dodamage(damage, gun); if(damage < INT_MAX) { actor->state.damage += damage; sendf(-1, 1, "ri7", gib ? SV_GIBDAMAGE : SV_DAMAGE, target->clientnum, actor->clientnum, gun, damage, ts.armour, ts.health); if(target!=actor) { checkcombo (target, actor, damage, gun); if(!hitpush.iszero()) { vec v(hitpush); if(!v.iszero()) v.normalize(); sendf(target->clientnum, 1, "ri6", SV_HITPUSH, gun, damage, int(v.x*DNF), int(v.y*DNF), int(v.z*DNF)); } } } if(ts.health<=0) { int targethasflag = clienthasflag(target->clientnum); bool tk = false, suic = false; target->state.deaths++; checkfrag(target, actor, gun, gib); if(target!=actor) { if(!isteam(target->team, actor->team)) actor->state.frags += gib && gun != GUN_GRENADE && gun != GUN_SHOTGUN ? 2 : 1; else { actor->state.frags--; actor->state.teamkills++; tk = true; } } else { // suicide actor->state.frags--; suic = true; logline(ACLOG_INFO, "[%s] %s suicided", actor->hostname, actor->name); } sendf(-1, 1, "ri5", gib ? SV_GIBDIED : SV_DIED, target->clientnum, actor->clientnum, actor->state.frags, gun); if((suic || tk) && (m_htf || m_ktf) && targethasflag >= 0) { actor->state.flagscore--; sendf(-1, 1, "riii", SV_FLAGCNT, actor->clientnum, actor->state.flagscore); } target->position.setsize(0); ts.state = CS_DEAD; ts.lastdeath = gamemillis; if(!suic) logline(ACLOG_INFO, "[%s] %s %s%s %s", actor->hostname, actor->name, valid_weapon(gun) ? killmessages[gib ? 1 : 0][gun] : "smurfed", tk ? " their teammate" : "", target->name); if(m_flags && targethasflag >= 0) { if(m_ctf) flagaction(targethasflag, tk ? FA_RESET : FA_LOST, -1); else if(m_htf) flagaction(targethasflag, FA_LOST, -1); else // ktf || tktf flagaction(targethasflag, FA_RESET, -1); } // don't issue respawn yet until DEATHMILLIS has elapsed // ts.respawn(); if(isdedicated && actor->type == ST_TCPIP && tk) { if( actor->state.frags < scl.banthreshold || /** teamkilling more than 6 (defaults), more than 2 per minute and less than 4 frags per tk */ ( actor->state.teamkills >= -scl.banthreshold && actor->state.teamkills * 30 * 1000 > gamemillis && actor->state.frags < 4 * actor->state.teamkills ) ) { addban(actor, DISC_AUTOBAN); } else if( actor->state.frags < scl.kickthreshold || /** teamkilling more than 5 (defaults), more than 1 tk per minute and less than 4 frags per tk */ ( actor->state.teamkills >= -scl.kickthreshold && actor->state.teamkills * 60 * 1000 > gamemillis && actor->state.frags < 4 * actor->state.teamkills ) ) disconnect_client(actor->clientnum, DISC_AUTOKICK); } } else if ( target!=actor && isteam(target->team, actor->team) ) check_ffire (target, actor, damage); // friendly fire counter } #include "serverevents.h" bool updatedescallowed(void) { return scl.servdesc_pre[0] || scl.servdesc_suf[0]; } void updatesdesc(const char *newdesc, ENetAddress *caller = NULL) { if(!newdesc || !newdesc[0] || !updatedescallowed()) { copystring(servdesc_current, scl.servdesc_full); custom_servdesc = false; } else { formatstring(servdesc_current)("%s%s%s", scl.servdesc_pre, newdesc, scl.servdesc_suf); custom_servdesc = true; if(caller) servdesc_caller = *caller; } } int canspawn(client *c) // beware: canspawn() doesn't check m_arena! { if(!c || c->type == ST_EMPTY || !c->isauthed || !team_isvalid(c->team) || (c->type == ST_TCPIP && (c->state.lastdeath > 0 ? gamemillis - c->state.lastdeath : servmillis - c->connectmillis) < (m_arena ? 0 : (m_flags ? 5000 : 2000))) || (c->type == ST_TCPIP && (servmillis - c->connectmillis < 1000 + c->state.reconnections * 2000 && gamemillis > 10000 && totalclients > 3 && !team_isspect(c->team)))) return SP_OK_NUM; // equivalent to SP_DENY if(!c->isonrightmap) return SP_WRONGMAP; if(mastermode == MM_MATCH && matchteamsize) { if(c->team == TEAM_SPECT || (team_isspect(c->team) && !m_teammode)) return SP_SPECT; if(c->team == TEAM_CLA_SPECT || c->team == TEAM_RVSF_SPECT) { if(numteamclients()[team_base(c->team)] >= matchteamsize) return SP_SPECT; else return SP_REFILLMATCH; } } return SP_OK; } void autospawncheck() { if(mastermode != MM_MATCH || !m_autospawn || interm) return; loopv(clients) if(clients[i]->type!=ST_EMPTY && clients[i]->isauthed && team_isactive(clients[i]->team)) { client *cl = clients[i]; if((cl->state.state == CS_DEAD || cl->state.state == CS_SPECTATE) && canspawn(cl) == SP_OK && !cl->autospawn) { sendspawn(cl); cl->autospawn = true; } } } bool updateclientteam(int cln, int newteam, int ftr) { if(!valid_client(cln)) return false; if(!team_isvalid(newteam) && newteam != TEAM_ANYACTIVE) newteam = TEAM_SPECT; client &cl = *clients[cln]; if(cl.team == newteam && ftr != FTR_AUTOTEAM) return true; // no change int *teamsizes = numteamclients(cln); if( mastermode == MM_OPEN && cl.state.forced && ftr == FTR_PLAYERWISH && newteam < TEAM_SPECT && team_base(cl.team) != team_base(newteam) ) return false; // no free will changes to forced people if(newteam == TEAM_ANYACTIVE) // when spawning from spect { if(mastermode == MM_MATCH && cl.team < TEAM_SPECT) { newteam = team_base(cl.team); } else { if(autoteam && teamsizes[TEAM_CLA] != teamsizes[TEAM_RVSF]) newteam = teamsizes[TEAM_CLA] < teamsizes[TEAM_RVSF] ? TEAM_CLA : TEAM_RVSF; else { // join weaker team int teamscore[2] = {0, 0}, sum = calcscores(); loopv(clients) if(clients[i]->type!=ST_EMPTY && i != cln && clients[i]->isauthed && clients[i]->team != TEAM_SPECT) { teamscore[team_base(clients[i]->team)] += clients[i]->at3_score; } newteam = sum > 200 ? (teamscore[TEAM_CLA] < teamscore[TEAM_RVSF] ? TEAM_CLA : TEAM_RVSF) : rnd(2); } } } if(ftr == FTR_PLAYERWISH) { if(mastermode == MM_MATCH && matchteamsize && m_teammode) { if(newteam != TEAM_SPECT && (team_base(newteam) != team_base(cl.team) || !m_teammode)) return false; // no switching sides in match mode when teamsize is set } if(team_isactive(newteam)) { if(!m_teammode && cl.state.state == CS_ALIVE) return false; // no comments if(mastermode == MM_MATCH) { if(m_teammode && matchteamsize && teamsizes[newteam] >= matchteamsize) return false; // ensure maximum team size } else { if(m_teammode && autoteam && teamsizes[newteam] > teamsizes[team_opposite(newteam)]) return false; // don't switch to an already bigger team } } else if(mastermode != MM_MATCH || !m_teammode) newteam = TEAM_SPECT; // only match mode (team) has more than one spect team } if(cl.team == newteam && ftr != FTR_AUTOTEAM) return true; // no change if(cl.team != newteam) sdropflag(cl.clientnum); if(ftr != FTR_INFO && (team_isspect(newteam) || (team_isactive(newteam) && team_isactive(cl.team)))) forcedeath(&cl); sendf(-1, 1, "riii", SV_SETTEAM, cln, newteam | ((ftr == FTR_SILENTFORCE ? FTR_INFO : ftr) << 4)); if(ftr != FTR_INFO && !team_isspect(newteam) && team_isspect(cl.team)) sendspawn(&cl); if (team_isspect(newteam)) { cl.state.state = CS_SPECTATE; cl.state.lastdeath = gamemillis; } cl.team = newteam; return true; } int calcscores() // skill eval { int sum = 0; loopv(clients) if(clients[i]->type!=ST_EMPTY) { clientstate &cs = clients[i]->state; sum += clients[i]->at3_score = cs.points > 0 ? sqrtf((float)cs.points) : -sqrtf((float)-cs.points); } return sum; } vector shuffle; void shuffleteams(int ftr = FTR_AUTOTEAM) { int numplayers = numclients(); int team, sums = calcscores(); if(gamemillis < 2 * 60 *1000) { // random int teamsize[2] = {0, 0}; loopv(clients) if(clients[i]->type!=ST_EMPTY && clients[i]->isonrightmap && !team_isspect(clients[i]->team)) // only shuffle active players { sums += rnd(1000); team = sums & 1; if(teamsize[team] >= numplayers/2) team = team_opposite(team); updateclientteam(i, team, ftr); teamsize[team]++; sums >>= 1; } } else { // skill sorted shuffle.shrink(0); sums /= 4 * numplayers + 2; team = rnd(2); loopv(clients) if(clients[i]->type!=ST_EMPTY && clients[i]->isonrightmap && !team_isspect(clients[i]->team)) { clients[i]->at3_score += rnd(sums | 1); shuffle.add(i); } shuffle.sort(cmpscore); loopi(shuffle.length()) { updateclientteam(shuffle[i], team, ftr); team = !team; } } if(m_ctf || m_htf) { ctfreset(); sendflaginfo(); } } bool balanceteams(int ftr) // pro vs noobs never more { if(mastermode != MM_OPEN || totalclients < 3 ) return true; int tsize[2] = {0, 0}, tscore[2] = {0, 0}; int totalscore = 0, nplayers = 0; int flagmult = (m_ctf ? 50 : (m_htf ? 25 : 12)); loopv(clients) if(clients[i]->type!=ST_EMPTY) { client *c = clients[i]; if(c->isauthed && team_isactive(c->team)) { int time = servmillis - c->connectmillis + 5000; if ( time > gamemillis ) time = gamemillis + 5000; tsize[c->team]++; // effective score per minute, thanks to wtfthisgame for the nice idea // in a normal game, normal players will do 500 points in 10 minutes c->eff_score = c->state.points * 60 * 1000 / time + c->state.points / 6 + c->state.flagscore * flagmult; tscore[c->team] += c->eff_score; nplayers++; totalscore += c->state.points; } } int h = 0, l = 1; if ( tscore[1] > tscore[0] ) { h = 1; l = 0; } if ( 2 * tscore[h] < 3 * tscore[l] || totalscore < nplayers * 100 ) return true; if ( tscore[h] > 3 * tscore[l] && tscore[h] > 150 * nplayers ) { // sendf(-1, 1, "ri2", SV_SERVERMODE, sendservermode(false) | AT_SHUFFLE); shuffleteams(); return true; } float diffscore = tscore[h] - tscore[l]; int besth = 0, hid = -1; int bestdiff = 0, bestpair[2] = {-1, -1}; if ( tsize[h] - tsize[l] > 0 ) // the h team has more players, so we will force only one player { loopv(clients) if( clients[i]->type!=ST_EMPTY ) { client *c = clients[i]; // loop for h // client from the h team, not forced in this game, and without the flag if( c->isauthed && c->team == h && !c->state.forced && clienthasflag(i) < 0 ) { // do not exchange in the way that weaker team becomes the stronger or the change is less than 20% effective if ( 2 * c->eff_score <= diffscore && 10 * c->eff_score >= diffscore && c->eff_score > besth ) { besth = c->eff_score; hid = i; } } } if ( hid >= 0 ) { updateclientteam(hid, l, ftr); clients[hid]->at3_lastforce = gamemillis; clients[hid]->state.forced = true; return true; } } else { // the h score team has less or the same player number, so, lets exchange loopv(clients) if(clients[i]->type!=ST_EMPTY) { client *c = clients[i]; // loop for h if( c->isauthed && c->team == h && !c->state.forced && clienthasflag(i) < 0 ) { loopvj(clients) if(clients[j]->type!=ST_EMPTY && j != i ) { client *cj = clients[j]; // loop for l if( cj->isauthed && cj->team == l && !cj->state.forced && clienthasflag(j) < 0 ) { int pairdiff = 2 * (c->eff_score - cj->eff_score); if ( pairdiff <= diffscore && 5 * pairdiff >= diffscore && pairdiff > bestdiff ) { bestdiff = pairdiff; bestpair[h] = i; bestpair[l] = j; } } } } } if ( bestpair[h] >= 0 && bestpair[l] >= 0 ) { updateclientteam(bestpair[h], l, ftr); updateclientteam(bestpair[l], h, ftr); clients[bestpair[h]]->at3_lastforce = clients[bestpair[l]]->at3_lastforce = gamemillis; clients[bestpair[h]]->state.forced = clients[bestpair[l]]->state.forced = true; return true; } } return false; } int lastbalance = 0, waitbalance = 2 * 60 * 1000; bool refillteams(bool now, int ftr) // force only minimal amounts of players { if(mastermode == MM_MATCH) return false; static int lasttime_eventeams = 0; int teamsize[2] = {0, 0}, teamscore[2] = {0, 0}, moveable[2] = {0, 0}; bool switched = false; calcscores(); loopv(clients) if(clients[i]->type!=ST_EMPTY) // playerlist stocktaking { client *c = clients[i]; c->at3_dontmove = true; if(c->isauthed) { if(team_isactive(c->team)) // only active players count { teamsize[c->team]++; teamscore[c->team] += c->at3_score; if(clienthasflag(i) < 0) { c->at3_dontmove = false; moveable[c->team]++; } } } } int bigteam = teamsize[1] > teamsize[0]; int allplayers = teamsize[0] + teamsize[1]; int diffnum = teamsize[bigteam] - teamsize[!bigteam]; int diffscore = teamscore[bigteam] - teamscore[!bigteam]; if(lasttime_eventeams > gamemillis) lasttime_eventeams = 0; if(diffnum > 1) { if(now || gamemillis - lasttime_eventeams > 8000 + allplayers * 1000 || diffnum > 2 + allplayers / 10) { // time to even out teams loopv(clients) if(clients[i]->type!=ST_EMPTY && clients[i]->team != bigteam) clients[i]->at3_dontmove = true; // dont move small team players while(diffnum > 1 && moveable[bigteam] > 0) { // pick best fitting cn int pick = -1; int bestfit = 1000000000; int targetscore = diffscore / (diffnum & ~1); loopv(clients) if(clients[i]->type!=ST_EMPTY && !clients[i]->at3_dontmove) // try all still movable players { int fit = targetscore - clients[i]->at3_score; if(fit < 0 ) fit = -(fit * 15) / 10; // avoid too good players int forcedelay = clients[i]->at3_lastforce ? (1000 - (gamemillis - clients[i]->at3_lastforce) / (5 * 60)) : 0; if(forcedelay > 0) fit += (fit * forcedelay) / 600; // avoid lately forced players if(fit < bestfit + fit * rnd(100) / 400) // search 'almost' best fit { bestfit = fit; pick = i; } } if(pick < 0) break; // should really never happen // move picked player clients[pick]->at3_dontmove = true; moveable[bigteam]--; if(updateclientteam(pick, !bigteam, ftr)) { diffnum -= 2; diffscore -= 2 * clients[pick]->at3_score; clients[pick]->at3_lastforce = gamemillis; // try not to force this player again for the next 5 minutes switched = true; } } } } if(diffnum < 2) { if ( ( gamemillis - lastbalance ) > waitbalance && ( gamelimit - gamemillis ) > 4*60*1000 ) { if ( balanceteams (ftr) ) { waitbalance = 2 * 60 * 1000 + gamemillis / 3; switched = true; } else waitbalance = 20 * 1000; lastbalance = gamemillis; } else if ( lastbalance > gamemillis ) { lastbalance = 0; waitbalance = 2 * 60 * 1000; } lasttime_eventeams = gamemillis; } return switched; } void resetserver(const char *newname, int newmode, int newtime) { if(m_demo) enddemoplayback(); else enddemorecord(); smode = newmode; copystring(smapname, newname); minremain = newtime > 0 ? newtime : defaultgamelimit(newmode); gamemillis = 0; gamelimit = minremain*60000; arenaround = arenaroundstartmillis = 0; memset(&smapstats, 0, sizeof(smapstats)); interm = nextsendscore = 0; lastfillup = servmillis; sents.shrink(0); if(mastermode == MM_PRIVATE) { loopv(savedscores) savedscores[i].valid = false; } else savedscores.shrink(0); ctfreset(); nextmapname[0] = '\0'; forceintermission = false; } void startdemoplayback(const char *newname) { if(isdedicated) return; resetserver(newname, GMODE_DEMO, -1); setupdemoplayback(); } void startgame(const char *newname, int newmode, int newtime, bool notify) { if(!newname || !*newname || (newmode == GMODE_DEMO && isdedicated)) fatal("startgame() abused"); if(newmode == GMODE_DEMO) { startdemoplayback(newname); } else { bool lastteammode = m_teammode; resetserver(newname, newmode, newtime); // beware: may clear *newname if(custom_servdesc && findcnbyaddress(&servdesc_caller) < 0) { updatesdesc(NULL); if(notify) { sendservmsg("server description reset to default"); logline(ACLOG_INFO, "server description reset to '%s'", servdesc_current); } } int maploc = MAP_VOID; mapstats *ms = getservermapstats(smapname, isdedicated, &maploc); mapbuffer.clear(); if(isdedicated && distributablemap(maploc)) mapbuffer.load(); if(ms) { smapstats = *ms; loopi(2) { sflaginfo &f = sflaginfos[i]; if(smapstats.flags[i] == 1) // don't check flag positions, if there is more than one flag per team { short *fe = smapstats.entposs + smapstats.flagents[i] * 3; f.x = *fe; fe++; f.y = *fe; } else f.x = f.y = -1; } if (smapstats.flags[0] == 1 && smapstats.flags[1] == 1) { sflaginfo &f0 = sflaginfos[0], &f1 = sflaginfos[1]; FlagFlag = pow2(f0.x - f1.x) + pow2(f0.y - f1.y); coverdist = FlagFlag > 6 * COVERDIST ? COVERDIST : FlagFlag / 6; } entity e; loopi(smapstats.hdr.numents) { e.type = smapstats.enttypes[i]; e.transformtype(smode); server_entity se = { e.type, false, false, false, 0, smapstats.entposs[i * 3], smapstats.entposs[i * 3 + 1]}; sents.add(se); if(e.fitsmode(smode)) sents[i].spawned = sents[i].legalpickup = true; } mapbuffer.setrevision(); logline(ACLOG_INFO, "Map height density information for %s: H = %.2f V = %d, A = %d and MA = %d", smapname, Mheight, Mvolume, Marea, Mopen); items_blocked = false; } else if(isdedicated) sendservmsg("\f3server error: map not found - please start another map or send this map to the server"); if(notify) { // change map sendf(-1, 1, "risiii", SV_MAPCHANGE, smapname, smode, mapbuffer.available(), mapbuffer.revision); if(smode>1 || (smode==0 && numnonlocalclients()>0)) sendf(-1, 1, "ri3", SV_TIMEUP, gamemillis, gamelimit); } packetbuf q(MAXTRANS, ENET_PACKET_FLAG_RELIABLE); send_item_list(q); // always send the item list when a game starts sendpacket(-1, 1, q.finalize()); defformatstring(gsmsg)("Game start: %s on %s, %d players, %d minutes, mastermode %d, ", modestr(smode), smapname, numclients(), minremain, mastermode); if(mastermode == MM_MATCH) concatformatstring(gsmsg, "teamsize %d, ", matchteamsize); if(ms) concatformatstring(gsmsg, "(map rev %d/%d, %s, 'getmap' %sprepared)", smapstats.hdr.maprevision, smapstats.cgzsize, maplocstr[maploc], mapbuffer.available() ? "" : "not "); else concatformatstring(gsmsg, "error: failed to preload map (map: %s)", maplocstr[maploc]); logline(ACLOG_INFO, "\n%s", gsmsg); if(m_arena) distributespawns(); if(notify) { // shuffle if previous mode wasn't a team-mode if(m_teammode) { if(!lastteammode) shuffleteams(FTR_INFO); else if(autoteam) refillteams(true, FTR_INFO); } // prepare spawns; players will spawn, once they've loaded the correct map loopv(clients) if(clients[i]->type!=ST_EMPTY) { client *c = clients[i]; c->mapchange(); forcedeath(c); } } if(numnonlocalclients() > 0) setupdemorecord(); if(notify && m_ktf) sendflaginfo(); if(notify) senddisconnectedscores(-1); } } struct gbaninfo { enet_uint32 ip, mask; }; vector gbans; void cleargbans() { gbans.shrink(0); } bool checkgban(uint ip) { loopv(gbans) if((ip & gbans[i].mask) == gbans[i].ip) return true; return false; } void addgban(const char *name) { union { uchar b[sizeof(enet_uint32)]; enet_uint32 i; } ip, mask; ip.i = 0; mask.i = 0; loopi(4) { char *end = NULL; int n = strtol(name, &end, 10); if(!end) break; if(end > name) { ip.b[i] = n; mask.b[i] = 0xFF; } name = end; while(*name && *name++ != '.'); } gbaninfo &ban = gbans.add(); ban.ip = ip.i; ban.mask = mask.i; loopvrev(clients) { client &c = *clients[i]; if(c.type!=ST_TCPIP) continue; if(checkgban(c.peer->address.host)) disconnect_client(c.clientnum, DISC_BANREFUSE); } } inline void addban(client *cl, int reason, int type) { if(!cl) return; ban b = { cl->peer->address, servmillis+scl.ban_time, type }; bans.add(b); disconnect_client(cl->clientnum, reason); } int getbantype(int cn) { if(!valid_client(cn)) return BAN_NONE; client &c = *clients[cn]; if(c.type==ST_LOCAL) return BAN_NONE; if(checkgban(c.peer->address.host)) return BAN_MASTER; if(ipblacklist.check(c.peer->address.host)) return BAN_BLACKLIST; loopv(bans) { ban &b = bans[i]; if(b.millis < servmillis) { bans.remove(i--); } if(b.address.host == c.peer->address.host) return b.type; } return BAN_NONE; } int serveroperator() { loopv(clients) if(clients[i]->type!=ST_EMPTY && clients[i]->role > CR_DEFAULT) return i; return -1; } void sendserveropinfo(int receiver) { int op = serveroperator(); sendf(receiver, 1, "riii", SV_SERVOPINFO, op, op >= 0 ? clients[op]->role : -1); } #include "serveractions.h" struct voteinfo { int boot; int owner, callmillis, result, num1, num2, type; char text[MAXTRANS]; serveraction *action; bool gonext; enet_uint32 host; voteinfo() : boot(0), owner(0), callmillis(0), result(VOTE_NEUTRAL), action(NULL), gonext(false), host(0) {} ~voteinfo() { delete action; } void end(int result) { if(action && !action->isvalid()) result = VOTE_NO; // don't perform() invalid votes sendf(-1, 1, "ri2", SV_VOTERESULT, result); this->result = result; if(result == VOTE_YES) { if(valid_client(owner)) clients[owner]->lastvotecall = 0; if(action) action->perform(); } loopv(clients) clients[i]->vote = VOTE_NEUTRAL; } bool isvalid() { return valid_client(owner) && action != NULL && action->isvalid(); } bool isalive() { return servmillis - callmillis < 30*1000; } void evaluate(bool forceend = false) { if(result!=VOTE_NEUTRAL) return; // block double action if(action && !action->isvalid()) end(VOTE_NO); int stats[VOTE_NUM] = {0}; int adminvote = VOTE_NEUTRAL; loopv(clients) if(clients[i]->type!=ST_EMPTY /*&& clients[i]->connectmillis < callmillis*/) // new connected people will vote now { stats[clients[i]->vote]++; if(clients[i]->role==CR_ADMIN) adminvote = clients[i]->vote; }; bool admin = clients[owner]->role==CR_ADMIN || (!isdedicated && clients[owner]->type==ST_LOCAL); int total = stats[VOTE_NO]+stats[VOTE_YES]+stats[VOTE_NEUTRAL]; const float requiredcount = 0.51f; bool min_time = servmillis - callmillis > 10*1000; #define yes_condition ((min_time && stats[VOTE_YES] - stats[VOTE_NO] > 0.34f*total && totalclients > 4) || stats[VOTE_YES] > requiredcount*total) #define no_condition (forceend || !valid_client(owner) || stats[VOTE_NO] >= stats[VOTE_YES]+stats[VOTE_NEUTRAL] || adminvote == VOTE_NO) #define boot_condition (!boot || (boot && valid_client(num1) && clients[num1]->peer->address.host == host)) if( (yes_condition || admin || adminvote == VOTE_YES) && boot_condition ) end(VOTE_YES); else if( no_condition || (min_time && !boot_condition)) end(VOTE_NO); else return; #undef boot_condition #undef no_condition #undef yes_condition } }; static voteinfo *curvote = NULL; bool svote(int sender, int vote, ENetPacket *msg) // true if the vote was placed successfully { if(!curvote || !valid_client(sender) || vote < VOTE_YES || vote > VOTE_NO) return false; if(clients[sender]->vote != VOTE_NEUTRAL) { sendf(sender, 1, "ri2", SV_CALLVOTEERR, VOTEE_MUL); return false; } else { sendpacket(-1, 1, msg, sender); clients[sender]->vote = vote; logline(ACLOG_DEBUG,"[%s] client %s voted %s", clients[sender]->hostname, clients[sender]->name, vote == VOTE_NO ? "no" : "yes"); curvote->evaluate(); return true; } } void scallvotesuc(voteinfo *v) { if(!v->isvalid()) return; DELETEP(curvote); curvote = v; clients[v->owner]->lastvotecall = servmillis; clients[v->owner]->nvotes--; // successful votes do not count as abuse sendf(v->owner, 1, "ri", SV_CALLVOTESUC); logline(ACLOG_INFO, "[%s] client %s called a vote: %s", clients[v->owner]->hostname, clients[v->owner]->name, v->action && *v->action->desc ? v->action->desc : "[unknown]"); } void scallvoteerr(voteinfo *v, int error) { if(!valid_client(v->owner)) return; sendf(v->owner, 1, "ri2", SV_CALLVOTEERR, error); logline(ACLOG_INFO, "[%s] client %s failed to call a vote: %s (%s)", clients[v->owner]->hostname, clients[v->owner]->name, v->action && *v->action->desc ? v->action->desc : "[unknown]", voteerrorstr(error)); } bool map_queued = false; void callvotepacket (int, voteinfo *); bool scallvote(voteinfo *v, ENetPacket *msg) // true if a regular vote was called { if (!v) return false; int area = isdedicated ? EE_DED_SERV : EE_LOCAL_SERV; int error = -1; client *c = clients[v->owner], *b = ( v->boot && valid_client(cn2boot) ? clients[cn2boot] : NULL ); v->host = v->boot && b ? b->peer->address.host : 0; int time = servmillis - c->lastvotecall; if ( c->nvotes > 0 && time > 4*60*1000 ) c->nvotes -= time/(4*60*1000); if ( c->nvotes < 0 || c->role == CR_ADMIN ) c->nvotes = 0; c->nvotes++; if( !v || !v->isvalid() || (v->boot && (!b || cn2boot == v->owner) ) ) error = VOTEE_INVALID; else if( v->action->role > c->role ) error = VOTEE_PERMISSION; else if( !(area & v->action->area) ) error = VOTEE_AREA; else if( curvote && curvote->result==VOTE_NEUTRAL ) error = VOTEE_CUR; else if( v->type == SA_MAP && v->num1 >= GMODE_NUM && map_queued ) error = VOTEE_NEXT; else if( c->role == CR_DEFAULT && v->action->isdisabled() ) error = VOTEE_DISABLED; else if( (c->lastvotecall && servmillis - c->lastvotecall < 60*1000 && c->role != CR_ADMIN && numclients()>1) || c->nvotes > 3 ) error = VOTEE_MAX; else if( ( ( v->boot == 1 && c->role < roleconf('w') ) || ( v->boot == 2 && c->role < roleconf('X') ) ) && !is_lagging(b) && !b->mute && b->spamcount < 2 ) { /** not same team, with low ratio, not lagging, and not spamming... so, why to kick? */ if ( !isteam(c->team, b->team) && b->state.frags < ( b->state.deaths > 0 ? b->state.deaths : 1 ) * 3 ) error = VOTEE_WEAK; /** same team, with low tk, not lagging, and not spamming... so, why to kick? */ else if ( isteam(c->team, b->team) && b->state.teamkills < c->state.teamkills ) error = VOTEE_WEAK; } if(error>=0) { scallvoteerr(v, error); return false; } else { if ( v->type == SA_MAP && v->num1 >= GMODE_NUM ) map_queued = true; if (!v->gonext) sendpacket(-1, 1, msg, v->owner); // FIXME in fact, all votes should go to the server, registered, and then go back to the clients else callvotepacket (-1, v); // also, no vote should exclude the caller... these would provide many code advantages/facilities scallvotesuc(v); // but we cannot change the vote system now for compatibility issues... so, TODO return true; } } void callvotepacket (int cn, voteinfo *v = curvote) { // FIXME, it would be far smart if the msg buffer from SV_CALLVOTE was simply saved int n_yes = 0, n_no = 0; loopv(clients) if(clients[i]->type!=ST_EMPTY) { if ( clients[i]->vote == VOTE_YES ) n_yes++; else if ( clients[i]->vote == VOTE_NO ) n_no++; } packetbuf q(MAXTRANS, ENET_PACKET_FLAG_RELIABLE); putint(q, SV_CALLVOTE); putint(q, -1); putint(q, v->owner); putint(q, n_yes); putint(q, n_no); putint(q, v->type); switch(v->type) { case SA_KICK: case SA_BAN: putint(q, v->num1); sendstring(v->text, q); break; case SA_MAP: sendstring(v->text, q); putint(q, v->num1); putint(q, v->num2); break; case SA_SERVERDESC: sendstring(v->text, q); break; case SA_STOPDEMO: // compatibility break; case SA_REMBANS: case SA_SHUFFLETEAMS: break; case SA_FORCETEAM: putint(q, v->num1); putint(q, v->num2); break; default: putint(q, v->num1); break; } sendpacket(cn, 1, q.finalize()); } // TODO: use AUTH code void changeclientrole(int client, int role, char *pwd, bool force) { pwddetail pd; if(!isdedicated || !valid_client(client)) return; pd.line = -1; if(force || role == CR_DEFAULT || (role == CR_ADMIN && pwd && pwd[0] && passwords.check(clients[client]->name, pwd, clients[client]->salt, &pd) && !pd.denyadmin)) { if(role == clients[client]->role) return; if(role > CR_DEFAULT) { loopv(clients) clients[i]->role = CR_DEFAULT; } clients[client]->role = role; sendserveropinfo(-1); if(pd.line > -1) logline(ACLOG_INFO,"[%s] player %s used admin password in line %d", clients[client]->hostname, clients[client]->name[0] ? clients[client]->name : "[unnamed]", pd.line); logline(ACLOG_INFO,"[%s] set role of player %s to %s", clients[client]->hostname, clients[client]->name[0] ? clients[client]->name : "[unnamed]", role == CR_ADMIN ? "admin" : "normal player"); // flowtron : connecting players haven't got a name yet (connectadmin) if(role > CR_DEFAULT) sendiplist(client); } else if(pwd && pwd[0]) disconnect_client(client, DISC_SOPLOGINFAIL); // avoid brute-force if(curvote) curvote->evaluate(); } void senddisconnectedscores(int cn) { packetbuf p(MAXTRANS, ENET_PACKET_FLAG_RELIABLE); putint(p, SV_DISCSCORES); if(mastermode == MM_MATCH) { loopv(savedscores) { savedscore &sc = savedscores[i]; if(sc.valid) { putint(p, sc.team); sendstring(sc.name, p); putint(p, sc.flagscore); putint(p, sc.frags); putint(p, sc.deaths); putint(p, sc.points); } } } putint(p, -1); sendpacket(cn, 1, p.finalize()); } const char *disc_reason(int reason) { static const char *disc_reasons[] = { "normal", "error - end of packet", "error - client num", "vote-kicked from the server", "vote-banned from the server", "error - tag type", "connection refused - you have been banned from this server", "incorrect password", "unsuccessful administrator login", "the server is FULL - try again later", "servers mastermode is \"private\" - wait until the servers mastermode is \"open\"", "auto-kick - your score dropped below the servers threshold", "auto-ban - your score dropped below the servers threshold", "duplicate connection", "inappropriate nickname", "error - packet flood", "auto-kick - excess spam detected", "auto-kick - inactivity detected", "auto-kick - team killing detected", "auto-kick - abnormal client behavior detected" }; return reason >= 0 && (size_t)reason < sizeof(disc_reasons)/sizeof(disc_reasons[0]) ? disc_reasons[reason] : "unknown"; } void disconnect_client(int n, int reason) { if(!clients.inrange(n) || clients[n]->type!=ST_TCPIP) return; sdropflag(n); client &c = *clients[n]; c.state.lastdisc = servmillis; const char *scoresaved = ""; if(c.haswelcome) { savedscore *sc = findscore(c, true); if(sc) { sc->save(c.state, c.team); scoresaved = ", score saved"; } } int sp = (servmillis - c.connectmillis) / 1000; if(reason>=0) logline(ACLOG_INFO, "[%s] disconnecting client %s (%s) cn %d, %d seconds played%s", c.hostname, c.name, disc_reason(reason), n, sp, scoresaved); else logline(ACLOG_INFO, "[%s] disconnected client %s cn %d, %d seconds played%s", c.hostname, c.name, n, sp, scoresaved); totalclients--; c.peer->data = (void *)-1; if(reason>=0) enet_peer_disconnect(c.peer, reason); clients[n]->zap(); sendf(-1, 1, "rii", SV_CDIS, n); if(curvote) curvote->evaluate(); if(*scoresaved && mastermode == MM_MATCH) senddisconnectedscores(-1); } // for AUTH: WIP client *findauth(uint id) { loopv(clients) if(clients[i]->authreq == id) return clients[i]; return NULL; } void authfailed(uint id) { client *cl = findauth(id); if(!cl) return; cl->authreq = 0; } void authsucceeded(uint id) { client *cl = findauth(id); if(!cl) return; cl->authreq = 0; logline(ACLOG_INFO, "player authenticated: %s", cl->name); defformatstring(auth4u)("player authenticated: %s", cl->name); sendf(-1, 1, "ris", SV_SERVMSG, auth4u); //setmaster(cl, true, "", ci->authname);//TODO? compare to sauerbraten } void authchallenged(uint id, const char *val) { client *cl = findauth(id); if(!cl) return; sendf(cl->clientnum, 1, "risis", SV_AUTHCHAL, "", id, val); } uint nextauthreq = 0; void tryauth(client *cl, const char *user) { extern bool requestmasterf(const char *fmt, ...); if(!nextauthreq) nextauthreq = 1; cl->authreq = nextauthreq++; filtertext(cl->authname, user, FTXT__AUTH, 100); if(!requestmasterf("reqauth %u %s\n", cl->authreq, cl->authname)) { cl->authreq = 0; sendf(cl->clientnum, 1, "ris", SV_SERVMSG, "not connected to authentication server"); } } void answerchallenge(client *cl, uint id, char *val) { if(cl->authreq != id) return; extern bool requestmasterf(const char *fmt, ...); for(char *s = val; *s; s++) { if(!isxdigit(*s)) { *s = '\0'; break; } } if(!requestmasterf("confauth %u %s\n", id, val)) { cl->authreq = 0; sendf(cl->clientnum, 1, "ris", SV_SERVMSG, "not connected to authentication server"); } } // :for AUTH void sendiplist(int receiver, int cn) { if(!valid_client(receiver)) return; packetbuf p(MAXTRANS, ENET_PACKET_FLAG_RELIABLE); putint(p, SV_IPLIST); loopv(clients) if(valid_client(i) && clients[i]->type == ST_TCPIP && i != receiver && (clients[i]->clientnum == cn || cn == -1)) { putint(p, i); putint(p, isbigendian() ? endianswap(clients[i]->peer->address.host) : clients[i]->peer->address.host); } putint(p, -1); sendpacket(receiver, 1, p.finalize()); } void sendresume(client &c, bool broadcast) { sendf(broadcast ? -1 : c.clientnum, 1, "ri3i9ivvi", SV_RESUME, c.clientnum, c.state.state, c.state.lifesequence, c.state.primary, c.state.gunselect, c.state.flagscore, c.state.frags, c.state.deaths, c.state.health, c.state.armour, c.state.points, c.state.teamkills, NUMGUNS, c.state.ammo, NUMGUNS, c.state.mag, -1); } bool restorescore(client &c) { //if(ci->local) return false; savedscore *sc = findscore(c, false); if(sc && sc->valid) { sc->restore(c.state); sc->valid = false; if ( c.connectmillis - c.state.lastdisc < 5000 ) c.state.reconnections++; else if ( c.state.reconnections ) c.state.reconnections--; return true; } return false; } void sendservinfo(client &c) { sendf(c.clientnum, 1, "ri5", SV_SERVINFO, c.clientnum, isdedicated ? SERVER_PROTOCOL_VERSION : PROTOCOL_VERSION, c.salt, scl.serverpassword[0] ? 1 : 0); } void putinitclient(client &c, packetbuf &p) { putint(p, SV_INITCLIENT); putint(p, c.clientnum); sendstring(c.name, p); putint(p, c.skin[TEAM_CLA]); putint(p, c.skin[TEAM_RVSF]); putint(p, c.team); enet_uint32 ip = 0; if(c.type == ST_TCPIP) ip = c.peer->address.host & 0xFFFFFF; putint(p, isbigendian() ? endianswap(ip) : ip); } void sendinitclient(client &c) { packetbuf p(MAXTRANS, ENET_PACKET_FLAG_RELIABLE); putinitclient(c, p); sendpacket(-1, 1, p.finalize(), c.clientnum); } void welcomeinitclient(packetbuf &p, int exclude = -1) { loopv(clients) { client &c = *clients[i]; if(c.type!=ST_TCPIP || !c.isauthed || c.clientnum == exclude) continue; putinitclient(c, p); } } void welcomepacket(packetbuf &p, int n) { if(!smapname[0]) maprot.next(false); client *c = valid_client(n) ? clients[n] : NULL; int numcl = numclients(); putint(p, SV_WELCOME); putint(p, smapname[0] && !m_demo ? numcl : -1); if(smapname[0] && !m_demo) { putint(p, SV_MAPCHANGE); sendstring(smapname, p); putint(p, smode); putint(p, mapbuffer.available()); putint(p, mapbuffer.revision); if(smode>1 || (smode==0 && numnonlocalclients()>0)) { putint(p, SV_TIMEUP); putint(p, (gamemillis>=gamelimit || forceintermission) ? gamelimit : gamemillis); putint(p, gamelimit); //putint(p, minremain*60); } send_item_list(p); // this includes the flags } savedscore *sc = NULL; if(c) { if(c->type == ST_TCPIP && serveroperator() != -1) sendserveropinfo(n); c->team = mastermode == MM_MATCH && sc ? team_tospec(sc->team) : TEAM_SPECT; putint(p, SV_SETTEAM); putint(p, n); putint(p, c->team | (FTR_INFO << 4)); putint(p, SV_FORCEDEATH); putint(p, n); sendf(-1, 1, "ri2x", SV_FORCEDEATH, n, n); } if(!c || clients.length()>1) { putint(p, SV_RESUME); loopv(clients) { client &c = *clients[i]; if(c.type!=ST_TCPIP || c.clientnum==n) continue; putint(p, c.clientnum); putint(p, c.state.state); putint(p, c.state.lifesequence); putint(p, c.state.primary); putint(p, c.state.gunselect); putint(p, c.state.flagscore); putint(p, c.state.frags); putint(p, c.state.deaths); putint(p, c.state.health); putint(p, c.state.armour); putint(p, c.state.points); putint(p, c.state.teamkills); loopi(NUMGUNS) putint(p, c.state.ammo[i]); loopi(NUMGUNS) putint(p, c.state.mag[i]); } putint(p, -1); welcomeinitclient(p, n); } putint(p, SV_SERVERMODE); putint(p, sendservermode(false)); const char *motd = scl.motd[0] ? scl.motd : infofiles.getmotd(c ? c->lang : ""); if(motd) { putint(p, SV_TEXT); sendstring(motd, p); } } void sendwelcome(client *cl, int chan) { packetbuf p(MAXTRANS, ENET_PACKET_FLAG_RELIABLE); welcomepacket(p, cl->clientnum); sendpacket(cl->clientnum, chan, p.finalize()); cl->haswelcome = true; } void forcedeath(client *cl) { sdropflag(cl->clientnum); cl->state.state = CS_DEAD; cl->state.respawn(); sendf(-1, 1, "rii", SV_FORCEDEATH, cl->clientnum); } int checktype(int type, client *cl) { if(cl && cl->type==ST_LOCAL) return type; if(type < 0 || type >= SV_NUM) return -1; // server only messages static int servtypes[] = { SV_SERVINFO, SV_WELCOME, SV_INITCLIENT, SV_POSN, SV_CDIS, SV_GIBDIED, SV_DIED, SV_GIBDAMAGE, SV_DAMAGE, SV_HITPUSH, SV_SHOTFX, SV_AUTHREQ, SV_AUTHCHAL, SV_SPAWNSTATE, SV_SPAWNDENY, SV_FORCEDEATH, SV_RESUME, SV_DISCSCORES, SV_TIMEUP, SV_ITEMACC, SV_MAPCHANGE, SV_ITEMSPAWN, SV_PONG, SV_SERVMSG, SV_ITEMLIST, SV_FLAGINFO, SV_FLAGMSG, SV_FLAGCNT, SV_ARENAWIN, SV_SERVOPINFO, SV_CALLVOTESUC, SV_CALLVOTEERR, SV_VOTERESULT, SV_SETTEAM, SV_TEAMDENY, SV_SERVERMODE, SV_IPLIST, SV_SENDDEMOLIST, SV_SENDDEMO, SV_DEMOPLAYBACK, SV_CLIENT, SV_HUDEXTRAS, SV_POINTS }; // only allow edit messages in coop-edit mode static int edittypes[] = { SV_EDITENT, SV_EDITXY, SV_EDITARCH, SV_EDITBLOCK, SV_EDITD, SV_EDITE, SV_NEWMAP }; if(cl) { loopi(sizeof(servtypes)/sizeof(int)) if(type == servtypes[i]) return -1; loopi(sizeof(edittypes)/sizeof(int)) if(type == edittypes[i]) return smode==GMODE_COOPEDIT ? type : -1; if(++cl->overflow >= 200) return -2; } return type; } // server side processing of updates: does very little and most state is tracked client only // could be extended to move more gameplay to server (at expense of lag) void process(ENetPacket *packet, int sender, int chan) { ucharbuf p(packet->data, packet->dataLength); char text[MAXTRANS]; client *cl = sender>=0 ? clients[sender] : NULL; pwddetail pd; int type; if(cl && !cl->isauthed) { int clientrole = CR_DEFAULT; if(chan==0) return; else if(chan!=1 || getint(p)!=SV_CONNECT) disconnect_client(sender, DISC_TAGT); else { cl->acversion = getint(p); cl->acbuildtype = getint(p); defformatstring(tags)(", AC: %d|%x", cl->acversion, cl->acbuildtype); getstring(text, p); filtertext(text, text, FTXT__PLAYERNAME, MAXNAMELEN); if(!text[0]) copystring(text, "unarmed"); copystring(cl->name, text, MAXNAMELEN+1); getstring(text, p); copystring(cl->pwd, text); getstring(text, p); filterlang(cl->lang, text); int wantrole = getint(p), np = getint(p); cl->state.nextprimary = np > 0 && np < NUMGUNS ? np : GUN_ASSAULT; loopi(2) cl->skin[i] = getint(p); int bantype = getbantype(sender); bool banned = bantype > BAN_NONE; bool srvfull = numnonlocalclients() > scl.maxclients; bool srvprivate = mastermode == MM_PRIVATE || mastermode == MM_MATCH; bool matchreconnect = mastermode == MM_MATCH && findscore(*cl, false); int bl = 0, wl = nickblacklist.checkwhitelist(*cl); if(wl == NWL_PASS) concatstring(tags, ", nickname whitelist match"); if(wl == NWL_UNLISTED) bl = nickblacklist.checkblacklist(cl->name); if(matchreconnect && !banned) { // former player reconnecting to a server in match mode cl->isauthed = true; logline(ACLOG_INFO, "[%s] %s logged in (reconnect to match)%s", cl->hostname, cl->name, tags); } else if(wl == NWL_IPFAIL || wl == NWL_PWDFAIL) { // nickname matches whitelist, but IP is not in the required range or PWD doesn't match logline(ACLOG_INFO, "[%s] '%s' matches nickname whitelist: wrong %s%s", cl->hostname, cl->name, wl == NWL_IPFAIL ? "IP" : "PWD", tags); disconnect_client(sender, DISC_BADNICK); } else if(bl > 0) { // nickname matches blacklist logline(ACLOG_INFO, "[%s] '%s' matches nickname blacklist line %d%s", cl->hostname, cl->name, bl, tags); disconnect_client(sender, DISC_BADNICK); } else if(passwords.check(cl->name, cl->pwd, cl->salt, &pd, (cl->type==ST_TCPIP ? cl->peer->address.host : 0)) && (!pd.denyadmin || (banned && !srvfull && !srvprivate)) && bantype != BAN_MASTER) // pass admins always through { // admin (or deban) password match cl->isauthed = true; if(!pd.denyadmin && wantrole == CR_ADMIN) clientrole = CR_ADMIN; if(bantype == BAN_VOTE) { loopv(bans) if(bans[i].address.host == cl->peer->address.host) { bans.remove(i); concatstring(tags, ", ban removed"); break; } // remove admin bans } if(srvfull) { loopv(clients) if(i != sender && clients[i]->type==ST_TCPIP) { disconnect_client(i, DISC_MAXCLIENTS); // disconnect someone else to fit maxclients again break; } } logline(ACLOG_INFO, "[%s] %s logged in using the admin password in line %d%s", cl->hostname, cl->name, pd.line, tags); } else if(scl.serverpassword[0] && !(srvprivate || srvfull || banned)) { // server password required if(!strcmp(genpwdhash(cl->name, scl.serverpassword, cl->salt), cl->pwd)) { cl->isauthed = true; logline(ACLOG_INFO, "[%s] %s client logged in (using serverpassword)%s", cl->hostname, cl->name, tags); } else disconnect_client(sender, DISC_WRONGPW); } else if(srvprivate) disconnect_client(sender, DISC_MASTERMODE); else if(srvfull) disconnect_client(sender, DISC_MAXCLIENTS); else if(banned) disconnect_client(sender, DISC_BANREFUSE); else { cl->isauthed = true; logline(ACLOG_INFO, "[%s] %s logged in (default)%s", cl->hostname, cl->name, tags); } } if(!cl->isauthed) return; if(cl->type==ST_TCPIP) { loopv(clients) if(i != sender) { client *dup = clients[i]; if(dup->type==ST_TCPIP && dup->peer->address.host==cl->peer->address.host && dup->peer->address.port==cl->peer->address.port) disconnect_client(i, DISC_DUP); } } sendwelcome(cl); if(restorescore(*cl)) { sendresume(*cl, true); senddisconnectedscores(-1); } else if(cl->type==ST_TCPIP) senddisconnectedscores(sender); sendinitclient(*cl); if(clientrole != CR_DEFAULT) changeclientrole(sender, clientrole, NULL, true); if( curvote && curvote->result == VOTE_NEUTRAL ) callvotepacket (cl->clientnum); // send full IPs to admins loopv(clients) { if(clients[i] && clients[i]->clientnum != cl->clientnum && (clients[i]->role == CR_ADMIN || clients[i]->type == ST_LOCAL)) sendiplist(clients[i]->clientnum, cl->clientnum); } } if(!cl) { logline(ACLOG_ERROR, " client in process()"); return; } // should never happen anyway if(packet->flags&ENET_PACKET_FLAG_RELIABLE) reliablemessages = true; #define QUEUE_MSG { if(cl->type==ST_TCPIP) while(curmsgmessages.add(p.buf[curmsg++]); } #define QUEUE_BUF(body) \ { \ if(cl->type==ST_TCPIP) \ { \ curmsg = p.length(); \ { body; } \ } \ } #define QUEUE_INT(n) QUEUE_BUF(putint(cl->messages, n)) #define QUEUE_UINT(n) QUEUE_BUF(putuint(cl->messages, n)) #define QUEUE_STR(text) QUEUE_BUF(sendstring(text, cl->messages)) #define MSG_PACKET(packet) \ packetbuf buf(16 + p.length() - curmsg, ENET_PACKET_FLAG_RELIABLE); \ putint(buf, SV_CLIENT); \ putint(buf, cl->clientnum); \ putuint(buf, p.length() - curmsg); \ buf.put(&p.buf[curmsg], p.length() - curmsg); \ ENetPacket *packet = buf.finalize(); int curmsg; while((curmsg = p.length()) < p.maxlen) { type = checktype(getint(p), cl); #ifdef _DEBUG if(type!=SV_POS && type!=SV_POSC && type!=SV_CLIENTPING && type!=SV_PING && type!=SV_CLIENT) { DEBUGVAR(cl->name); ASSERT(type>=0 && typehostname, type == SV_TEAMTEXTME ? "(me) " : "", cl->name, team_string(cl->team), text); sendteamtext(text, sender, type); } else { logline(ACLOG_INFO, "[%s] %s%s says to team %s: '%s', %s", cl->hostname, type == SV_TEAMTEXTME ? "(me) " : "", cl->name, team_string(cl->team), text, canspeech ? "SPAM detected" : "Forbidden speech"); if (canspeech) { sendservmsg("\f3Please do not spam; your message was not delivered.", sender); if ( cl->spamcount > SPAMMAXREPEAT + 2 ) disconnect_client(cl->clientnum, DISC_ABUSE); } else { sendservmsg("\f3Watch your language! Your message was not delivered.", sender); kick_abuser(cl->clientnum, cl->badmillis, cl->badspeech, 3); } } } break; case SV_TEXTME: case SV_TEXT: { int mid1 = curmsg, mid2 = p.length(); getstring(text, p); filtertext(text, text, FTXT__CHAT); trimtrailingwhitespace(text); if(*text) { bool canspeech = forbiddenlist.canspeech(text); if(!spamdetect(cl, text) && canspeech) { if(mastermode != MM_MATCH || !matchteamsize || team_isactive(cl->team) || (cl->team == TEAM_SPECT && cl->role == CR_ADMIN)) // common chat { logline(ACLOG_INFO, "[%s] %s%s says: '%s'", cl->hostname, type == SV_TEXTME ? "(me) " : "", cl->name, text); if(cl->type==ST_TCPIP) while(mid1messages.add(p.buf[mid1++]); QUEUE_STR(text); } else // spect chat { logline(ACLOG_INFO, "[%s] %s%s says to team %s: '%s'", cl->hostname, type == SV_TEAMTEXTME ? "(me) " : "", cl->name, team_string(cl->team), text); sendteamtext(text, sender, type == SV_TEXTME ? SV_TEAMTEXTME : SV_TEAMTEXT); } } else { logline(ACLOG_INFO, "[%s] %s%s says: '%s', %s", cl->hostname, type == SV_TEXTME ? "(me) " : "", cl->name, text, canspeech ? "SPAM detected" : "Forbidden speech"); if (canspeech) { sendservmsg("\f3Please do not spam; your message was not delivered.", sender); if ( cl->spamcount > SPAMMAXREPEAT + 2 ) disconnect_client(cl->clientnum, DISC_ABUSE); } else { sendservmsg("\f3Watch your language! Your message was not delivered.", sender); kick_abuser(cl->clientnum, cl->badmillis, cl->badspeech, 3); } } } break; } case SV_TEXTPRIVATE: { int targ = getint(p); getstring(text, p); filtertext(text, text, FTXT__CHAT); trimtrailingwhitespace(text); if(!valid_client(targ)) break; client *target = clients[targ]; if(*text) { bool canspeech = forbiddenlist.canspeech(text); if(!spamdetect(cl, text) && canspeech) { bool allowed = !(mastermode == MM_MATCH && cl->team != target->team) && cl->role >= roleconf('t'); logline(ACLOG_INFO, "[%s] %s says to %s: '%s' (%s)", cl->hostname, cl->name, target->name, text, allowed ? "allowed":"disallowed"); if(allowed) sendf(target->clientnum, 1, "riis", SV_TEXTPRIVATE, cl->clientnum, text); } else { logline(ACLOG_INFO, "[%s] %s says to %s: '%s', %s", cl->hostname, cl->name, target->name, text, canspeech ? "SPAM detected" : "Forbidden speech"); if (canspeech) { sendservmsg("\f3Please do not spam; your message was not delivered.", sender); if ( cl->spamcount > SPAMMAXREPEAT + 2 ) disconnect_client(cl->clientnum, DISC_ABUSE); } else { sendservmsg("\f3Watch your language! Your message was not delivered.", sender); kick_abuser(cl->clientnum, cl->badmillis, cl->badspeech, 3); } } } } break; case SV_VOICECOM: case SV_VOICECOMTEAM: { int s = getint(p); /* spam filter */ if ( servmillis > cl->mute ) // client is not muted { if(!gamesound_isvoicecom(s)) cl->mute = servmillis + 10000; // vc is invalid else if ( cl->lastvc + 4000 < servmillis ) { if ( cl->spam > 0 ) cl->spam -= (servmillis - cl->lastvc) / 4000; } // no vc in the last 4 seconds else cl->spam++; // the guy is spamming if ( cl->spam < 0 ) cl->spam = 0; cl->lastvc = servmillis; // register if ( cl->spam > 4 ) { cl->mute = servmillis + 10000; break; } // 5 vcs in less than 20 seconds... shut up please if ( m_teammode ) checkteamplay(s,sender); // finally here we check the teamplay comm if ( type == SV_VOICECOM ) { QUEUE_MSG; } else sendvoicecomteam(s, sender); } } break; case SV_MAPIDENT: { int gzs = getint(p); int rev = getint(p); if(!isdedicated || (smapstats.cgzsize == gzs && smapstats.hdr.maprevision == rev)) { // here any game really starts for a client: spawn, if it's a new game - don't spawn if the game was already running cl->isonrightmap = true; int sp = canspawn(cl); sendf(sender, 1, "rii", SV_SPAWNDENY, sp); cl->spawnperm = sp; if(cl->loggedwrongmap) logline(ACLOG_INFO, "[%s] %s is now on the right map: revision %d/%d", cl->hostname, cl->name, rev, gzs); bool spawn = false; if(team_isspect(cl->team)) { if(numclients() < 2 && !m_demo && mastermode != MM_MATCH) // spawn on empty servers { spawn = updateclientteam(cl->clientnum, TEAM_ANYACTIVE, FTR_INFO); } } else { if((cl->freshgame || numclients() < 2) && !m_demo) spawn = true; } cl->freshgame = false; if(spawn) sendspawn(cl); } else { forcedeath(cl); logline(ACLOG_INFO, "[%s] %s is on the wrong map: revision %d/%d", cl->hostname, cl->name, rev, gzs); cl->loggedwrongmap = true; sendf(sender, 1, "rii", SV_SPAWNDENY, SP_WRONGMAP); } QUEUE_MSG; break; } case SV_ITEMPICKUP: { int n = getint(p); if(!arenaround || arenaround - gamemillis > 2000) { gameevent &pickup = cl->addevent(); pickup.type = GE_PICKUP; pickup.pickup.ent = n; } break; } case SV_WEAPCHANGE: { int gunselect = getint(p); if(!valid_weapon(gunselect) || gunselect == GUN_CPISTOL) break; if(!m_demo && !m_coop) checkweapon(type,gunselect); cl->state.gunselect = gunselect; QUEUE_MSG; break; } case SV_PRIMARYWEAP: { int nextprimary = getint(p); if(!valid_weapon(nextprimary)) break; cl->state.nextprimary = nextprimary; break; } case SV_SWITCHNAME: { QUEUE_MSG; getstring(text, p); filtertext(text, text, FTXT__PLAYERNAME, MAXNAMELEN); if(!text[0]) copystring(text, "unarmed"); QUEUE_STR(text); bool namechanged = strcmp(cl->name, text) != 0; if(namechanged) logline(ACLOG_INFO,"[%s] %s changed name to %s", cl->hostname, cl->name, text); copystring(cl->name, text, MAXNAMELEN+1); if(namechanged) { // very simple spam detection (possible FIXME: centralize spam detection) if(cl->type==ST_TCPIP && (servmillis - cl->lastprofileupdate < 1000)) { ++cl->fastprofileupdates; if(cl->fastprofileupdates == 3) sendservmsg("\f3Please do not spam", sender); if(cl->fastprofileupdates >= 5) { disconnect_client(sender, DISC_ABUSE); break; } } else if(servmillis - cl->lastprofileupdate > 10000) cl->fastprofileupdates = 0; cl->lastprofileupdate = servmillis; switch(nickblacklist.checkwhitelist(*cl)) { case NWL_PWDFAIL: case NWL_IPFAIL: logline(ACLOG_INFO, "[%s] '%s' matches nickname whitelist: wrong IP/PWD", cl->hostname, cl->name); disconnect_client(sender, DISC_BADNICK); break; case NWL_UNLISTED: { int l = nickblacklist.checkblacklist(cl->name); if(l >= 0) { logline(ACLOG_INFO, "[%s] '%s' matches nickname blacklist line %d", cl->hostname, cl->name, l); disconnect_client(sender, DISC_BADNICK); } break; } } } break; } case SV_SWITCHTEAM: { int t = getint(p); if(!updateclientteam(sender, team_isvalid(t) ? t : TEAM_SPECT, FTR_PLAYERWISH)) sendf(sender, 1, "rii", SV_TEAMDENY, t); break; } case SV_SWITCHSKIN: { loopi(2) cl->skin[i] = getint(p); QUEUE_MSG; if(cl->type==ST_TCPIP && (servmillis - cl->lastprofileupdate < 1000)) { ++cl->fastprofileupdates; if(cl->fastprofileupdates == 3) sendservmsg("\f3Please do not spam", sender); if(cl->fastprofileupdates >= 5) disconnect_client(sender, DISC_ABUSE); } else if(servmillis - cl->lastprofileupdate > 10000) cl->fastprofileupdates = 0; cl->lastprofileupdate = servmillis; break; } case SV_TRYSPAWN: { int sp = canspawn(cl); if(team_isspect(cl->team) && sp < SP_OK_NUM) { updateclientteam(sender, TEAM_ANYACTIVE, FTR_PLAYERWISH); sp = canspawn(cl); } if( !m_arena && sp < SP_OK_NUM && gamemillis > cl->state.lastspawn + 1000 ) sendspawn(cl); break; } case SV_SPAWN: { int ls = getint(p), gunselect = getint(p); if((cl->state.state!=CS_ALIVE && cl->state.state!=CS_DEAD && cl->state.state!=CS_SPECTATE) || ls!=cl->state.lifesequence || cl->state.lastspawn<0 || !valid_weapon(gunselect) || gunselect == GUN_CPISTOL) break; cl->state.lastspawn = -1; cl->state.spawn = gamemillis; cl->autospawn = false; cl->upspawnp = false; cl->state.state = CS_ALIVE; cl->state.gunselect = gunselect; QUEUE_BUF( { putint(cl->messages, SV_SPAWN); putint(cl->messages, cl->state.lifesequence); putint(cl->messages, cl->state.health); putint(cl->messages, cl->state.armour); putint(cl->messages, cl->state.gunselect); loopi(NUMGUNS) putint(cl->messages, cl->state.ammo[i]); loopi(NUMGUNS) putint(cl->messages, cl->state.mag[i]); }); break; } case SV_SUICIDE: { gameevent &suicide = cl->addevent(); suicide.type = GE_SUICIDE; break; } case SV_SHOOT: { gameevent &shot = cl->addevent(); shot.type = GE_SHOT; #define seteventmillis(event) \ { \ event.id = getint(p); \ if(!cl->timesync || (cl->events.length()==1 && cl->state.waitexpired(gamemillis))) \ { \ cl->timesync = true; \ cl->gameoffset = gamemillis - event.id; \ event.millis = gamemillis; \ } \ else event.millis = cl->gameoffset + event.id; \ } seteventmillis(shot.shot); shot.shot.gun = getint(p); loopk(3) { shot.shot.from[k] = cl->state.o.v[k] + ( k == 2 ? (((cl->f>>7)&1)?2.2f:4.2f) : 0); } loopk(3) { float v = getint(p)/DMF; shot.shot.to[k] = ((k<2 && v<0.0f)?0.0f:v); } int hits = getint(p); int tcn = -1; loopk(hits) { gameevent &hit = cl->addevent(); hit.type = GE_HIT; tcn = hit.hit.target = getint(p); hit.hit.lifesequence = getint(p); hit.hit.info = getint(p); loopk(3) hit.hit.dir[k] = getint(p)/DNF; } if(!m_demo && !m_coop) checkshoot(sender, shot, hits, tcn); break; } case SV_EXPLODE: // Brahma says: FIXME handle explosion by location and deal damage from server { gameevent &exp = cl->addevent(); exp.type = GE_EXPLODE; seteventmillis(exp.explode); exp.explode.gun = getint(p); exp.explode.id = getint(p); int hits = getint(p); loopk(hits) { gameevent &hit = cl->addevent(); hit.type = GE_HIT; hit.hit.target = getint(p); hit.hit.lifesequence = getint(p); hit.hit.dist = getint(p)/DMF; loopk(3) hit.hit.dir[k] = getint(p)/DNF; } break; } case SV_AKIMBO: { gameevent &akimbo = cl->addevent(); akimbo.type = GE_AKIMBO; seteventmillis(akimbo.akimbo); break; } case SV_RELOAD: { gameevent &reload = cl->addevent(); reload.type = GE_RELOAD; seteventmillis(reload.reload); reload.reload.gun = getint(p); break; } // for AUTH: case SV_AUTHTRY: { string desc, name; getstring(desc, p, sizeof(desc)); // unused for now getstring(name, p, sizeof(name)); if(!desc[0]) tryauth(cl, name); break; } case SV_AUTHANS: { string desc, ans; getstring(desc, p, sizeof(desc)); // unused for now uint id = (uint)getint(p); getstring(ans, p, sizeof(ans)); if(!desc[0]) answerchallenge(cl, id, ans); break; } case SV_AUTHT: { /* int n = getint(p); loopi(n) getint(p);*/ // if (cl) disconnect_client(cl->clientnum, DISC_TAGT); // remove this in the future, when auth is complete break; } // :for AUTH case SV_PING: sendf(sender, 1, "ii", SV_PONG, getint(p)); break; case SV_CLIENTPING: { int ping = getint(p); if(cl) cl->ping = cl->ping == 9999 ? ping : (cl->ping * 4 + ping) / 5; QUEUE_MSG; break; } case SV_POS: { int cn = getint(p); if(cn!=sender) { disconnect_client(sender, DISC_CN); #ifndef STANDALONE conoutf("ERROR: invalid client (msg %d)", type); #endif return; } loopi(3) cl->state.o[i] = getuint(p)/DMF; cl->y = getuint(p); cl->p = getint(p); cl->g = getuint(p); loopi(4) if ( (cl->g >> i) & 1 ) getint(p); cl->f = getuint(p); if(!cl->isonrightmap) break; if(cl->type==ST_TCPIP && (cl->state.state==CS_ALIVE || cl->state.state==CS_EDITING)) { cl->position.setsize(0); while(curmsgposition.add(p.buf[curmsg++]); } if(!m_demo && !m_coop) checkmove(cl); break; } case SV_POSC: { bitbuf q(p); int cn = q.getbits(5); if(cn!=sender) { disconnect_client(sender, DISC_CN); #ifndef STANDALONE conoutf("ERROR: invalid client (msg %d)", type); #endif return; } int usefactor = q.getbits(2) + 7; int xt = q.getbits(usefactor + 4); int yt = q.getbits(usefactor + 4); cl->y = (q.getbits(9)*360)/512; cl->p = ((q.getbits(8)-128)*90)/127; if(!q.getbits(1)) q.getbits(6); if(!q.getbits(1)) q.getbits(4 + 4 + 4); cl->f = q.getbits(8); int negz = q.getbits(1); int zfull = q.getbits(1); int s = q.rembits(); if(s < 3) s += 8; if(zfull) s = 11; int zt = q.getbits(s); if(negz) zt = -zt; int g1 = q.getbits(1); // scoping int g2 = q.getbits(1); // shooting cl->g = (g1<<4) | (g2<<5); if(!cl->isonrightmap || p.remaining() || p.overread()) { p.flags = 0; break; } if(((cl->f >> 6) & 1) != (cl->state.lifesequence & 1) || usefactor != (smapstats.hdr.sfactor < 7 ? 7 : smapstats.hdr.sfactor)) break; cl->state.o[0] = xt / DMF; cl->state.o[1] = yt / DMF; cl->state.o[2] = zt / DMF; if(cl->type==ST_TCPIP && (cl->state.state==CS_ALIVE || cl->state.state==CS_EDITING)) { cl->position.setsize(0); while(curmsgposition.add(p.buf[curmsg++]); } if(!m_demo && !m_coop) checkmove(cl); break; } case SV_SENDMAP: { getstring(text, p); filtertext(text, text, FTXT__MAPNAME); const char *sentmap = behindpath(text), *reject = NULL; int mapsize = getint(p); int cfgsize = getint(p); int cfgsizegz = getint(p); int revision = getint(p); if(p.remaining() < mapsize + cfgsizegz || MAXMAPSENDSIZE < mapsize + cfgsizegz) { p.forceoverread(); break; } int mp = findmappath(sentmap); if(readonlymap(mp)) { reject = "map is ro"; defformatstring(msg)("\f3map upload rejected: map %s is readonly", sentmap); sendservmsg(msg, sender); } else if( scl.incoming_limit && ( scl.incoming_limit << 20 ) < incoming_size + mapsize + cfgsizegz ) { reject = "server incoming reached its limits"; sendservmsg("\f3server does not support more incomings: limit reached", sender); } else if(mp == MAP_NOTFOUND && strchr(scl.mapperm, 'C') && cl->role < CR_ADMIN) { reject = "no permission for initial upload"; sendservmsg("\f3initial map upload rejected: you need to be admin", sender); } else if(mp == MAP_TEMP && revision >= mapbuffer.revision && !strchr(scl.mapperm, 'u') && cl->role < CR_ADMIN) // default: only admins can update maps { reject = "no permission to update"; sendservmsg("\f3map update rejected: you need to be admin", sender); } else if(mp == MAP_TEMP && revision < mapbuffer.revision && !strchr(scl.mapperm, 'r') && cl->role < CR_ADMIN) // default: only admins can revert maps to older revisions { reject = "no permission to revert revision"; sendservmsg("\f3map revert to older revision rejected: you need to be admin to upload an older map", sender); } else { if(mapbuffer.sendmap(sentmap, mapsize, cfgsize, cfgsizegz, &p.buf[p.len])) { incoming_size += mapsize + cfgsizegz; logline(ACLOG_INFO,"[%s] %s sent map %s, rev %d, %d + %d(%d) bytes written", clients[sender]->hostname, clients[sender]->name, sentmap, revision, mapsize, cfgsize, cfgsizegz); defformatstring(msg)("%s (%d) up%sed map %s, rev %d%s", clients[sender]->name, sender, mp == MAP_NOTFOUND ? "load": "dat", sentmap, revision, /*strcmp(sentmap, behindpath(smapname)) || smode == GMODE_COOPEDIT ? "" :*/ "\f3 (restart game to use new map version)"); sendservmsg(msg); } else { reject = "write failed (no 'incoming'?)"; sendservmsg("\f3map upload failed", sender); } } if (reject) { logline(ACLOG_INFO,"[%s] %s sent map %s rev %d, rejected: %s", clients[sender]->hostname, clients[sender]->name, sentmap, revision, reject); } p.len += mapsize + cfgsizegz; break; } case SV_RECVMAP: { if(mapbuffer.available()) { resetflag(cl->clientnum); // drop ctf flag savedscore *sc = findscore(*cl, true); // save score if(sc) sc->save(cl->state, cl->team); mapbuffer.sendmap(cl, 2); cl->mapchange(true); sendwelcome(cl, 2); // resend state properly } else sendservmsg("no map to get", cl->clientnum); break; } case SV_REMOVEMAP: { getstring(text, p); filtertext(text, text, FTXT__MAPNAME); string filename; const char *rmmap = behindpath(text), *reject = NULL; int mp = findmappath(rmmap); int reqrole = strchr(scl.mapperm, 'D') ? CR_ADMIN : (strchr(scl.mapperm, 'd') ? CR_DEFAULT : CR_ADMIN + 100); if(cl->role < reqrole) reject = "no permission"; else if(readonlymap(mp)) reject = "map is readonly"; else if(mp == MAP_NOTFOUND) reject = "map not found"; else { formatstring(filename)(SERVERMAP_PATH_INCOMING "%s.cgz", rmmap); remove(filename); formatstring(filename)(SERVERMAP_PATH_INCOMING "%s.cfg", rmmap); remove(filename); defformatstring(msg)("map '%s' deleted", rmmap); sendservmsg(msg, sender); logline(ACLOG_INFO,"[%s] deleted map %s", clients[sender]->hostname, rmmap); } if (reject) { logline(ACLOG_INFO,"[%s] deleting map %s failed: %s", clients[sender]->hostname, rmmap, reject); defformatstring(msg)("\f3can't delete map '%s', %s", rmmap, reject); sendservmsg(msg, sender); } break; } case SV_FLAGACTION: { int action = getint(p); int flag = getint(p); if(!m_flags || flag < 0 || flag > 1 || action < 0 || action > FA_NUM) break; flagaction(flag, action, sender); break; } case SV_SETADMIN: { bool claim = getint(p) != 0; if(claim) { getstring(text, p); changeclientrole(sender, CR_ADMIN, text); } else changeclientrole(sender, CR_DEFAULT); break; } case SV_CALLVOTE: { voteinfo *vi = new voteinfo; vi->boot = 0; vi->type = getint(p); switch(vi->type) { case SA_MAP: { getstring(text, p); int mode = getint(p), time = getint(p); vi->gonext = text[0]=='+' && text[1]=='1'; if(m_isdemo(mode)) filtertext(text, text, FTXT__DEMONAME); else filtertext(text, behindpath(text), FTXT__MAPNAME); if(time <= 0) time = -1; time = min(time, 60); if (vi->gonext) { int ccs = rnd(maprot.configsets.length()); configset *c = maprot.get(ccs); if(c) { strcpy(vi->text,c->mapname); mode = vi->num1 = c->mode; time = vi->num2 = c->time; } else fatal("unable to get next map in maprot"); } else { strncpy(vi->text,text,MAXTRANS-1); vi->num1 = mode; vi->num2 = time; } int qmode = (mode >= GMODE_NUM ? mode - GMODE_NUM : mode); if(mode==GMODE_DEMO) vi->action = new demoplayaction(newstring(text)); else { char *vmap = newstring(*vi->text ? behindpath(vi->text) : ""); vi->action = new mapaction(vmap, qmode, time, sender, qmode!=mode); } break; } case SA_KICK: { vi->num1 = cn2boot = getint(p); getstring(text, p); strncpy(vi->text,text,128); filtertext(text, text, FTXT__KICKBANREASON); trimtrailingwhitespace(text); vi->action = new kickaction(cn2boot, newstring(text, 128)); vi->boot = 1; break; } case SA_BAN: { vi->num1 = cn2boot = getint(p); getstring(text, p); strncpy(vi->text,text,128); filtertext(text, text, FTXT__KICKBANREASON); trimtrailingwhitespace(text); vi->action = new banaction(cn2boot, newstring(text, 128)); vi->boot = 2; break; } case SA_REMBANS: vi->action = new removebansaction(); break; case SA_MASTERMODE: vi->action = new mastermodeaction(vi->num1 = getint(p)); break; case SA_AUTOTEAM: vi->action = new autoteamaction((vi->num1 = getint(p)) > 0); break; case SA_SHUFFLETEAMS: vi->action = new shuffleteamaction(); break; case SA_FORCETEAM: vi->num1 = getint(p); vi->num2 = getint(p); vi->action = new forceteamaction(vi->num1, sender, vi->num2); break; case SA_GIVEADMIN: vi->action = new giveadminaction(vi->num1 = getint(p)); break; case SA_RECORDDEMO: vi->action = new recorddemoaction((vi->num1 = getint(p))!=0); break; case SA_STOPDEMO: // compatibility break; case SA_CLEARDEMOS: vi->action = new cleardemosaction(vi->num1 = getint(p)); break; case SA_SERVERDESC: getstring(text, p); strncpy(vi->text,text,MAXTRANS-1); filtertext(text, text, FTXT__SERVDESC); vi->action = new serverdescaction(newstring(text), sender); break; } vi->owner = sender; vi->callmillis = servmillis; MSG_PACKET(msg); if(!scallvote(vi, msg)) delete vi; break; } case SV_VOTE: { int n = getint(p); MSG_PACKET(msg); ++msg->referenceCount; // need to increase reference count in case a vote disconnects a player after packet is queued to prevent double-freeing by packetbuf svote(sender, n, msg); --msg->referenceCount; break; } case SV_LISTDEMOS: listdemos(sender); break; case SV_GETDEMO: senddemo(sender, getint(p)); break; case SV_EXTENSION: { // AC server extensions // // rules: // 1. extensions MUST NOT modify gameplay or the behavior of the game in any way // 2. extensions may ONLY be used to extend or automate server administration tasks // 3. extensions may ONLY operate on the server and must not send any additional data to the connected clients // 4. extensions not adhering to these rules may cause the hosting server being banned from the masterserver // // also note that there is no guarantee that custom extensions will work in future AC versions getstring(text, p, 64); char *ext = text; // extension specifier in the form of OWNER::EXTENSION, see sample below int n = getint(p); // length of data after the specifier if(n < 0 || n > 50) return; // sample if(!strcmp(ext, "driAn::writelog")) { // owner: driAn - root@sprintf.org // extension: writelog - WriteLog v1.0 // description: writes a custom string to the server log // access: requires admin privileges // usage: /serverextension driAn::writelog "your log message here.." // note: There is a 49 character limit. The server will ignore messages with 50+ characters. getstring(text, p, n); if(valid_client(sender) && clients[sender]->role==CR_ADMIN) { logline(ACLOG_INFO, "[%s] %s writes to log: %s", cl->hostname, cl->name, text); sendservmsg("your message has been logged", sender); } } else if(!strcmp(ext, "set::teamsize")) { // intermediate solution to set the teamsize (will be voteable) getstring(text, p, n); if(valid_client(sender) && clients[sender]->role==CR_ADMIN && mastermode == MM_MATCH) { changematchteamsize(atoi(text)); defformatstring(msg)("match team size set to %d", matchteamsize); sendservmsg(msg, -1); } } // else if() // add other extensions here else for(; n > 0; n--) getint(p); // ignore unknown extensions break; } case SV_EDITBLOCK: { loopi(5) getuint(p); freegzbuf(getgzbuf(p)); QUEUE_MSG; break; } case -1: disconnect_client(sender, DISC_TAGT); return; case -2: disconnect_client(sender, DISC_OVERFLOW); return; default: { int size = msgsizelookup(type); if(size<=0) { if(sender>=0) disconnect_client(sender, DISC_TAGT); return; } loopi(size-1) getint(p); QUEUE_MSG; break; } } } if(p.overread() && sender>=0) disconnect_client(sender, DISC_EOP); #ifdef _DEBUG protocoldebug(false); #endif } void localclienttoserver(int chan, ENetPacket *packet) { process(packet, 0, chan); } client &addclient() { client *c = NULL; loopv(clients) if(clients[i]->type==ST_EMPTY) { c = clients[i]; break; } if(!c) { c = new client; c->clientnum = clients.length(); clients.add(c); } c->reset(); return *c; } void checkintermission() { if(minremain>0) { minremain = (gamemillis>=gamelimit || forceintermission) ? 0 : (gamelimit - gamemillis + 60000 - 1)/60000; sendf(-1, 1, "ri3", SV_TIMEUP, (gamemillis>=gamelimit || forceintermission) ? gamelimit : gamemillis, gamelimit); } if(!interm && minremain<=0) interm = gamemillis+10000; forceintermission = false; } void resetserverifempty() { loopv(clients) if(clients[i]->type!=ST_EMPTY) return; resetserver("", 0, 10); matchteamsize = 0; autoteam = true; changemastermode(MM_OPEN); nextmapname[0] = '\0'; } void sendworldstate() { static enet_uint32 lastsend = 0; if(clients.empty()) return; enet_uint32 curtime = enet_time_get()-lastsend; if(curtime<40) return; bool flush = buildworldstate(); lastsend += curtime - (curtime%40); if(flush) enet_host_flush(serverhost); if(demorecord) recordpackets = true; // enable after 'old' worldstate is sent } void rereadcfgs(void) { maprot.read(); ipblacklist.read(); nickblacklist.read(); forbiddenlist.read(); passwords.read(); } void loggamestatus(const char *reason) { int fragscore[2] = {0, 0}, flagscore[2] = {0, 0}, pnum[2] = {0, 0}; string text; formatstring(text)("%d minutes remaining", minremain); logline(ACLOG_INFO, ""); logline(ACLOG_INFO, "Game status: %s on %s, %s, %s, %d clients%c %s", modestr(gamemode), smapname, reason ? reason : text, mmfullname(mastermode), totalclients, custom_servdesc ? ',' : '\0', servdesc_current); if(!scl.loggamestatus) return; logline(ACLOG_INFO, "cn name %s%s score frag death %sping role host", m_teammode ? "team " : "", m_flags ? "flag " : "", m_teammode ? "tk " : ""); loopv(clients) { client &c = *clients[i]; if(c.type == ST_EMPTY || !c.name[0]) continue; formatstring(text)("%2d %-16s ", c.clientnum, c.name); // cn name if(m_teammode) concatformatstring(text, "%-4s ", team_string(c.team, true)); // teamname (abbreviated) if(m_flags) concatformatstring(text, "%4d ", c.state.flagscore); // flag concatformatstring(text, "%6d ", c.state.points); // score concatformatstring(text, "%4d %5d", c.state.frags, c.state.deaths); // frag death if(m_teammode) concatformatstring(text, " %2d", c.state.teamkills); // tk logline(ACLOG_INFO, "%s%5d %s %s", text, c.ping, c.role == CR_ADMIN ? "admin " : "normal", c.hostname); if(c.team != TEAM_SPECT) { int t = team_base(c.team); flagscore[t] += c.state.flagscore; fragscore[t] += c.state.frags; pnum[t] += 1; } } if(mastermode == MM_MATCH) { loopv(savedscores) { savedscore &sc = savedscores[i]; if(sc.valid) { if(m_teammode) formatstring(text)("%-4s ", team_string(sc.team, true)); else text[0] = '\0'; if(m_flags) concatformatstring(text, "%4d ", sc.flagscore); logline(ACLOG_INFO, " %-16s %s%4d %5d%s - disconnected", sc.name, text, sc.frags, sc.deaths, m_teammode ? " -" : ""); if(sc.team != TEAM_SPECT) { int t = team_base(sc.team); flagscore[t] += sc.flagscore; fragscore[t] += sc.frags; pnum[t] += 1; } } } } if(m_teammode) { loopi(2) logline(ACLOG_INFO, "Team %4s:%3d players,%5d frags%c%5d flags", team_string(i), pnum[i], fragscore[i], m_flags ? ',' : '\0', flagscore[i]); } logline(ACLOG_INFO, ""); } static unsigned char chokelog[MAXCLIENTS + 1] = { 0 }; void linequalitystats(int elapsed) { static unsigned int chokes[MAXCLIENTS + 1] = { 0 }, spent[MAXCLIENTS + 1] = { 0 }, chokes_raw[MAXCLIENTS + 1] = { 0 }, spent_raw[MAXCLIENTS + 1] = { 0 }; if(elapsed) { // collect data int c1 = 0, c2 = 0, r1 = 0, numc = 0; loopv(clients) { client &c = *clients[i]; if(c.type != ST_TCPIP) continue; numc++; enet_uint32 &rtt = c.peer->lastRoundTripTime, &throttle = c.peer->packetThrottle; if(rtt < c.bottomRTT + c.bottomRTT / 3) { if(servmillis - c.connectmillis < 5000) c.bottomRTT = rtt; else c.bottomRTT = (c.bottomRTT * 15 + rtt) / 16; // simple IIR } if(throttle < 22) c1++; if(throttle < 11) c2++; if(rtt > c.bottomRTT * 2 && rtt - c.bottomRTT > 300) r1++; } spent_raw[numc] += elapsed; int t = numc < 7 ? numc : (numc + 1) / 2 + 3; chokes_raw[numc] += ((c1 >= t ? c1 + c2 : 0) + (r1 >= t ? r1 : 0)) * elapsed; } else { // calculate compressed statistics defformatstring(msg)("Uplink quality [ "); int ncs = 0; loopj(scl.maxclients) { int i = j + 1; int nc = chokes_raw[i] / 1000 / i; chokes[i] += nc; ncs += nc; spent[i] += spent_raw[i] / 1000; chokes_raw[i] = spent_raw[i] = 0; int s = 0, c = 0; if(spent[i]) { frexp((double)spent[i] / 30, &s); if(s < 0) s = 0; if(s > 15) s = 15; if(chokes[i]) { frexp(((double)chokes[i]) / spent[i], &c); c = 15 + c; if(c < 0) c = 0; if(c > 15) c = 15; } } chokelog[i] = (s << 4) + c; concatformatstring(msg, "%02X ", chokelog[i]); } logline(ACLOG_DEBUG, "%s] +%d", msg, ncs); } } void serverslice(uint timeout) // main server update, called from cube main loop in sp, or dedicated server loop { static int msend = 0, mrec = 0, csend = 0, crec = 0, mnum = 0, cnum = 0; #ifdef STANDALONE int nextmillis = (int)enet_time_get(); if(svcctrl) svcctrl->keepalive(); #else int nextmillis = isdedicated ? (int)enet_time_get() : lastmillis; #endif int diff = nextmillis - servmillis; gamemillis += diff; servmillis = nextmillis; servertime = ((diff + 3 * servertime)>>2); if (servertime > 40) serverlagged = servmillis; #ifndef STANDALONE if(m_demo) { readdemo(); extern void silenttimeupdate(int milliscur, int millismax); silenttimeupdate(gamemillis, gametimemaximum); } #endif if(minremain>0) { processevents(); checkitemspawns(diff); bool ktfflagingame = false; if(m_flags) loopi(2) { sflaginfo &f = sflaginfos[i]; if(f.state == CTFF_DROPPED && gamemillis-f.lastupdate > (m_ctf ? 30000 : 10000)) flagaction(i, FA_RESET, -1); if(m_htf && f.state == CTFF_INBASE && gamemillis-f.lastupdate > (smapstats.hasflags ? 10000 : 1000)) { htf_forceflag(i); } if(m_ktf && f.state == CTFF_STOLEN && gamemillis-f.lastupdate > 15000) { flagaction(i, FA_SCORE, -1); } if(f.state == CTFF_INBASE || f.state == CTFF_STOLEN) ktfflagingame = true; } if(m_ktf && !ktfflagingame) flagaction(rnd(2), FA_RESET, -1); // ktf flag watchdog if(m_arena) arenacheck(); else if(m_autospawn) autospawncheck(); // if(m_lms) lmscheck(); sendextras(); if ( scl.afk_limit && mastermode == MM_OPEN && next_afk_check < servmillis && gamemillis > 20 * 1000 ) check_afk(); } if(curvote) { if(!curvote->isalive()) curvote->evaluate(true); if(curvote->result!=VOTE_NEUTRAL) DELETEP(curvote); } int nonlocalclients = numnonlocalclients(); if(forceintermission || ((smode>1 || (gamemode==0 && nonlocalclients)) && gamemillis-diff>0 && gamemillis/60000!=(gamemillis-diff)/60000)) checkintermission(); if(m_demo && !demoplayback) maprot.restart(); else if(interm && ( (scl.demo_interm && sending_demo) ? gamemillis>(interm<<1) : gamemillis>interm ) ) { sending_demo = false; loggamestatus("game finished"); if(demorecord) enddemorecord(); interm = nextsendscore = 0; //start next game if(nextmapname[0]) startgame(nextmapname, nextgamemode); else maprot.next(); nextmapname[0] = '\0'; map_queued = false; } resetserverifempty(); if(!isdedicated) return; // below is network only poll_serverthreads(); serverms(smode, numclients(), minremain, smapname, servmillis, serverhost->address, &mnum, &msend, &mrec, &cnum, &csend, &crec, SERVER_PROTOCOL_VERSION); if(autoteam && m_teammode && !m_arena && !interm && servmillis - lastfillup > 5000 && refillteams()) lastfillup = servmillis; static unsigned int lastThrottleEpoch = 0; if(serverhost->bandwidthThrottleEpoch != lastThrottleEpoch) { if(lastThrottleEpoch) linequalitystats(serverhost->bandwidthThrottleEpoch - lastThrottleEpoch); lastThrottleEpoch = serverhost->bandwidthThrottleEpoch; } if(servmillis - laststatus > 60 * 1000) // display bandwidth stats, useful for server ops { laststatus = servmillis; rereadcfgs(); if(nonlocalclients || serverhost->totalSentData || serverhost->totalReceivedData) { if(nonlocalclients) loggamestatus(NULL); logline(ACLOG_INFO, "Status at %s: %d remote clients, %.1f send, %.1f rec (K/sec);" " Ping: #%d|%d|%d; CSL: #%d|%d|%d (bytes)", timestring(true, "%d-%m-%Y %H:%M:%S"), nonlocalclients, serverhost->totalSentData/60.0f/1024, serverhost->totalReceivedData/60.0f/1024, mnum, msend, mrec, cnum, csend, crec); mnum = msend = mrec = cnum = csend = crec = 0; linequalitystats(0); } serverhost->totalSentData = serverhost->totalReceivedData = 0; } ENetEvent event; bool serviced = false; while(!serviced) { if(enet_host_check_events(serverhost, &event) <= 0) { if(enet_host_service(serverhost, &event, timeout) <= 0) break; serviced = true; } switch(event.type) { case ENET_EVENT_TYPE_CONNECT: { client &c = addclient(); c.type = ST_TCPIP; c.peer = event.peer; c.peer->data = (void *)(size_t)c.clientnum; c.connectmillis = servmillis; c.state.state = CS_SPECTATE; c.salt = rnd(0x1000000)*((servmillis%1000)+1); char hn[1024]; copystring(c.hostname, (enet_address_get_host_ip(&c.peer->address, hn, sizeof(hn))==0) ? hn : "unknown"); logline(ACLOG_INFO,"[%s] client connected", c.hostname); sendservinfo(c); totalclients++; break; } case ENET_EVENT_TYPE_RECEIVE: { int cn = (int)(size_t)event.peer->data; if(valid_client(cn)) process(event.packet, cn, event.channelID); if(event.packet->referenceCount==0) enet_packet_destroy(event.packet); break; } case ENET_EVENT_TYPE_DISCONNECT: { int cn = (int)(size_t)event.peer->data; if(!valid_client(cn)) break; disconnect_client(cn); break; } default: break; } } sendworldstate(); } void cleanupserver() { if(serverhost) { enet_host_destroy(serverhost); serverhost = NULL; } if(svcctrl) { svcctrl->stop(); DELETEP(svcctrl); } exitlogging(); } int getpongflags(enet_uint32 ip) { int flags = mastermode << PONGFLAG_MASTERMODE; flags |= scl.serverpassword[0] ? 1 << PONGFLAG_PASSWORD : 0; loopv(bans) if(bans[i].address.host == ip) { flags |= 1 << PONGFLAG_BANNED; break; } flags |= ipblacklist.check(ip) ? 1 << PONGFLAG_BLACKLIST : 0; return flags; } void extping_namelist(ucharbuf &p) { loopv(clients) { if(clients[i]->type == ST_TCPIP && clients[i]->isauthed) sendstring(clients[i]->name, p); } sendstring("", p); } void extping_serverinfo(ucharbuf &pi, ucharbuf &po) { char lang[3]; lang[0] = tolower(getint(pi)); lang[1] = tolower(getint(pi)); lang[2] = '\0'; const char *reslang = lang, *buf = infofiles.getinfo(lang); // try client language if(!buf) buf = infofiles.getinfo(reslang = "en"); // try english sendstring(buf ? reslang : "", po); if(buf) { for(const char *c = buf; *c && po.remaining() > MAXINFOLINELEN + 10; c += strlen(c) + 1) sendstring(c, po); sendstring("", po); } } void extping_maprot(ucharbuf &po) { putint(po, CONFIG_MAXPAR); string text; bool abort = false; loopv(maprot.configsets) { if(po.remaining() < 100) abort = true; configset &c = maprot.configsets[i]; filtertext(text, c.mapname, FTXT__MAPNAME); text[30] = '\0'; sendstring(abort ? "-- list truncated --" : text, po); loopi(CONFIG_MAXPAR) putint(po, c.par[i]); if(abort) break; } sendstring("", po); } void extping_uplinkstats(ucharbuf &po) { if(scl.maxclients > 3) po.put(chokelog + 4, scl.maxclients - 3); // send logs for 4..n used slots } void extinfo_cnbuf(ucharbuf &p, int cn) { if(cn == -1) // add all available player ids { loopv(clients) if(clients[i]->type != ST_EMPTY) putint(p,clients[i]->clientnum); } else if(valid_client(cn)) // add single player only { putint(p,clients[cn]->clientnum); } } void extinfo_statsbuf(ucharbuf &p, int pid, int bpos, ENetSocket &pongsock, ENetAddress &addr, ENetBuffer &buf, int len, int *csend) { loopv(clients) { if(clients[i]->type != ST_TCPIP) continue; if(pid>-1 && clients[i]->clientnum!=pid) continue; bool ismatch = mastermode == MM_MATCH; putint(p,EXT_PLAYERSTATS_RESP_STATS); // send player stats following putint(p,clients[i]->clientnum); //add player id putint(p,clients[i]->ping); //Ping sendstring(clients[i]->name,p); //Name sendstring(team_string(clients[i]->team),p); //Team // "team_string(clients[i]->team)" sometimes return NULL according to RK, causing the server to crash. WTF ? putint(p,clients[i]->state.frags); //Frags putint(p,clients[i]->state.flagscore); //Flagscore putint(p,clients[i]->state.deaths); //Death putint(p,clients[i]->state.teamkills); //Teamkills putint(p,ismatch ? 0 : clients[i]->state.damage*100/max(clients[i]->state.shotdamage,1)); //Accuracy putint(p,ismatch ? 0 : clients[i]->state.health); //Health putint(p,ismatch ? 0 : clients[i]->state.armour); //Armour putint(p,ismatch ? 0 : clients[i]->state.gunselect); //Gun selected putint(p,clients[i]->role); //Role putint(p,clients[i]->state.state); //State (Alive,Dead,Spawning,Lagged,Editing) uint ip = clients[i]->peer->address.host; // only 3 byte of the ip address (privacy protected) p.put((uchar*)&ip,3); buf.dataLength = len + p.length(); enet_socket_send(pongsock, &addr, &buf, 1); *csend += (int)buf.dataLength; if(pid>-1) break; p.len=bpos; } } void extinfo_teamscorebuf(ucharbuf &p) { putint(p, m_teammode ? EXT_ERROR_NONE : EXT_ERROR); putint(p, gamemode); putint(p, minremain); // possible TODO: use gamemillis, gamelimit here too? if(!m_teammode) return; int teamsizes[TEAM_NUM] = { 0 }, fragscores[TEAM_NUM] = { 0 }, flagscores[TEAM_NUM] = { 0 }; loopv(clients) if(clients[i]->type!=ST_EMPTY && team_isvalid(clients[i]->team)) { teamsizes[clients[i]->team] += 1; fragscores[clients[i]->team] += clients[i]->state.frags; flagscores[clients[i]->team] += clients[i]->state.flagscore; } loopi(TEAM_NUM) if(teamsizes[i]) { sendstring(team_string(i), p); // team name putint(p, fragscores[i]); // add fragscore per team putint(p, m_flags ? flagscores[i] : -1); // add flagscore per team putint(p, -1); // ? } } #ifndef STANDALONE void localdisconnect() { loopv(clients) if(clients[i]->type==ST_LOCAL) clients[i]->zap(); } void localconnect() { modprotocol = false; servstate.reset(); client &c = addclient(); c.type = ST_LOCAL; c.role = CR_ADMIN; c.salt = 0; copystring(c.hostname, "local"); sendservinfo(c); } #endif void processmasterinput(const char *cmd, int cmdlen, const char *args) { // AUTH WiP uint id; string val; if(sscanf(cmd, "failauth %u", &id) == 1) authfailed(id); else if(sscanf(cmd, "succauth %u", &id) == 1) authsucceeded(id); else if(sscanf(cmd, "chalauth %u %s", &id, val) == 2) authchallenged(id, val); else if(!strncmp(cmd, "cleargbans", cmdlen)) cleargbans(); else if(sscanf(cmd, "addgban %s", val) == 1) addgban(val); } string server_name = "unarmed server"; void quitproc(int param) { // this triggers any "atexit"-calls: exit(param == 2 ? EXIT_SUCCESS : EXIT_FAILURE); // 3 is the only reply on Win32 apparently, SIGINT == 2 == Ctrl-C } void initserver(bool dedicated, int argc, char **argv) { const char *service = NULL; for(int i = 1; iargc = argc; svcctrl->argv = argv; svcctrl->start(); } } if ( strlen(scl.servdesc_full) ) global_name = scl.servdesc_full; else global_name = server_name; smapname[0] = '\0'; string identity; if(scl.logident[0]) filtertext(identity, scl.logident, FTXT__LOGIDENT); else formatstring(identity)("%s#%d", scl.ip[0] ? scl.ip : "local", scl.serverport); int conthres = scl.verbose > 1 ? ACLOG_DEBUG : (scl.verbose ? ACLOG_VERBOSE : ACLOG_INFO); if(dedicated && !initlogging(identity, scl.syslogfacility, conthres, scl.filethres, scl.syslogthres, scl.logtimestamp)) printf("WARNING: logging not started!\n"); logline(ACLOG_INFO, "logging local AssaultCube server (version %d, protocol %d/%d) now..", AC_VERSION, SERVER_PROTOCOL_VERSION, EXT_VERSION); copystring(servdesc_current, scl.servdesc_full); servermsinit(scl.master ? scl.master : AC_MASTER_URI, scl.ip, CUBE_SERVINFO_PORT(scl.serverport), dedicated); if((isdedicated = dedicated)) { ENetAddress address = { ENET_HOST_ANY, (enet_uint16)scl.serverport }; if(scl.ip[0] && enet_address_set_host(&address, scl.ip)<0) logline(ACLOG_WARNING, "server ip not resolved!"); serverhost = enet_host_create(&address, scl.maxclients+1, 3, 0, scl.uprate); if(!serverhost) fatal("could not create server host"); loopi(scl.maxclients) serverhost->peers[i].data = (void *)-1; maprot.init(scl.maprot); maprot.next(false, true); // ensure minimum maprot length of '1' passwords.init(scl.pwdfile, scl.adminpasswd); ipblacklist.init(scl.blfile); nickblacklist.init(scl.nbfile); forbiddenlist.init(scl.forbidden); infofiles.init(scl.infopath, scl.motdpath); infofiles.getinfo("en"); // cache 'en' serverinfo logline(ACLOG_VERBOSE, "holding up to %d recorded demos in memory", scl.maxdemos); if(scl.demopath[0]) logline(ACLOG_VERBOSE,"all recorded demos will be written to: \"%s\"", scl.demopath); if(scl.voteperm[0]) logline(ACLOG_VERBOSE,"vote permission string: \"%s\"", scl.voteperm); if(scl.mapperm[0]) logline(ACLOG_VERBOSE,"map permission string: \"%s\"", scl.mapperm); logline(ACLOG_VERBOSE,"server description: \"%s\"", scl.servdesc_full); if(scl.servdesc_pre[0] || scl.servdesc_suf[0]) logline(ACLOG_VERBOSE,"custom server description: \"%sCUSTOMPART%s\"", scl.servdesc_pre, scl.servdesc_suf); logline(ACLOG_VERBOSE,"maxclients: %d, kick threshold: %d, ban threshold: %d", scl.maxclients, scl.kickthreshold, scl.banthreshold); if(scl.master) logline(ACLOG_VERBOSE,"master server URL: \"%s\"", scl.master); if(scl.serverpassword[0]) logline(ACLOG_VERBOSE,"server password: \"%s\"", hiddenpwd(scl.serverpassword)); #ifdef ACAC logline(ACLOG_INFO, "anticheat: enabled"); #else logline(ACLOG_INFO, "anticheat: disabled"); #endif } resetserverifempty(); if(isdedicated) // do not return, this becomes main loop { #ifdef WIN32 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); #endif // kill -2 / Ctrl-C - see http://msdn.microsoft.com/en-us/library/xdkz3x12%28v=VS.100%29.aspx (or VS-2008?) for caveat (seems not to pertain to AC - 2011feb05:ft) if (signal(SIGINT, quitproc) == SIG_ERR) logline(ACLOG_INFO, "Cannot handle SIGINT!"); // kill -15 / probably process-manager on Win32 *shrug* if (signal(SIGTERM, quitproc) == SIG_ERR) logline(ACLOG_INFO, "Cannot handle SIGTERM!"); #ifndef WIN32 // kill -1 if (signal(SIGHUP, quitproc) == SIG_ERR) logline(ACLOG_INFO, "Cannot handle SIGHUP!"); // kill -9 is uncatchable - http://en.wikipedia.org/wiki/SIGKILL //if (signal(SIGKILL, quitproc) == SIG_ERR) logline(ACLOG_INFO, "Cannot handle SIGKILL!"); #endif logline(ACLOG_INFO, "dedicated server started, waiting for clients..."); logline(ACLOG_INFO, "Ctrl-C to exit"); // this will now actually call the atexit-hooks below - thanks to SIGINT hooked above - noticed and signal-code-docs found by SKB:2011feb05:ft: atexit(enet_deinitialize); atexit(cleanupserver); enet_time_set(0); // start file-IO threads readmapsthread_sem = new sl_semaphore(0, NULL); sl_createthread(readmapsthread, (void *)"xxxx"); for(;;) serverslice(5); } } #ifdef STANDALONE void localservertoclient(int chan, uchar *buf, int len, bool demo) {} void fatal(const char *s, ...) { defvformatstring(msg,s,s); defformatstring(out)("AssaultCube fatal error: %s", msg); if (logline(ACLOG_ERROR, "%s", out)); else puts(out); cleanupserver(); exit(EXIT_FAILURE); } int main(int argc, char **argv) { #ifdef WIN32 //atexit((void (__cdecl *)(void))_CrtDumpMemoryLeaks); #ifndef _DEBUG #ifndef __GNUC__ __try { #endif #endif #endif for(int i = 1; i= 0 && f < 2) enum { GE_NONE = 0, GE_SHOT, GE_EXPLODE, GE_HIT, GE_AKIMBO, GE_RELOAD, GE_SUICIDE, GE_PICKUP }; enum { ST_EMPTY, ST_LOCAL, ST_TCPIP }; extern int smode, servmillis; struct shotevent { int type; int millis, id; int gun; float from[3], to[3]; }; struct explodeevent { int type; int millis, id; int gun; }; struct hitevent { int type; int target; int lifesequence; union { int info; float dist; }; float dir[3]; }; struct suicideevent { int type; }; struct pickupevent { int type; int ent; }; struct akimboevent { int type; int millis, id; }; struct reloadevent { int type; int millis, id; int gun; }; union gameevent { int type; shotevent shot; explodeevent explode; hitevent hit; suicideevent suicide; pickupevent pickup; akimboevent akimbo; reloadevent reload; }; template struct projectilestate { int projs[N]; int numprojs; projectilestate() : numprojs(0) {} void reset() { numprojs = 0; } void add(int val) { if(numprojs>=N) numprojs = 0; projs[numprojs++] = val; } bool remove(int val) { loopi(numprojs) if(projs[i]==val) { projs[i] = projs[--numprojs]; return true; } return false; } }; static const int DEATHMILLIS = 300; struct clientstate : playerstate { vec o; int state; int lastdeath, lastspawn, spawn, lifesequence; bool forced; int lastshot; projectilestate<8> grenades; int akimbomillis; bool scoped; int flagscore, frags, teamkills, deaths, shotdamage, damage, points, events, lastdisc, reconnections; clientstate() : state(CS_DEAD) {} bool isalive(int gamemillis) { return state==CS_ALIVE || (state==CS_DEAD && gamemillis - lastdeath <= DEATHMILLIS); } bool waitexpired(int gamemillis) { int wait = gamemillis - lastshot; loopi(NUMGUNS) if(wait < gunwait[i]) return false; return true; } void reset() { state = CS_DEAD; lifesequence = -1; grenades.reset(); akimbomillis = 0; scoped = forced = false; flagscore = frags = teamkills = deaths = shotdamage = damage = points = events = lastdisc = reconnections = 0; respawn(); } void respawn() { playerstate::respawn(); o = vec(-1e10f, -1e10f, -1e10f); lastdeath = 0; lastspawn = -1; spawn = 0; lastshot = 0; akimbomillis = 0; scoped = false; } }; struct savedscore { string name; uint ip; int frags, flagscore, deaths, teamkills, shotdamage, damage, team, points, events, lastdisc, reconnections; bool valid, forced; void reset() { // to avoid 2 connections with the same score... this can disrupt some laggers that eventually produces 2 connections (but it is rare) frags = flagscore = deaths = teamkills = shotdamage = damage = points = events = lastdisc = reconnections = 0; } void save(clientstate &cs, int t) { frags = cs.frags; flagscore = cs.flagscore; deaths = cs.deaths; teamkills = cs.teamkills; shotdamage = cs.shotdamage; damage = cs.damage; points = cs.points; forced = cs.forced; events = cs.events; lastdisc = cs.lastdisc; reconnections = cs.reconnections; team = t; valid = true; } void restore(clientstate &cs) { cs.frags = frags; cs.flagscore = flagscore; cs.deaths = deaths; cs.teamkills = teamkills; cs.shotdamage = shotdamage; cs.damage = damage; cs.points = points; cs.forced = forced; cs.events = events; cs.lastdisc = lastdisc; cs.reconnections = reconnections; reset(); } }; struct medals { int dpt, lasthit, lastgun, ncovers, nhs; int combohits, combo, combofrags, combotime, combodamage, ncombos; int ask, askmillis, linked, linkmillis, linkreason, upmillis, flagmillis; int totalhits, totalshots; bool updated, combosend; vec pos, flagpos; void reset() { dpt = lasthit = lastgun = ncovers = nhs = 0; combohits = combo = combofrags = combotime = combodamage = ncombos = 0; askmillis = linkmillis = upmillis = flagmillis = 0; linkreason = linked = ask = -1; totalhits = totalshots = 0; updated = combosend = false; pos = flagpos = vec(-1e10f, -1e10f, -1e10f); } }; struct client // server side version of "dynent" type { int type; int clientnum; ENetPeer *peer; string hostname; string name; int team; char lang[3]; int ping; int skin[2]; int vote; int role; int connectmillis, lmillis, ldt, spj; int mute, spam, lastvc; // server side voice comm spam control int acversion, acbuildtype; bool isauthed; // for passworded servers bool haswelcome; bool isonrightmap, loggedwrongmap, freshgame; bool timesync; int overflow; int gameoffset, lastevent, lastvotecall; int lastprofileupdate, fastprofileupdates; int demoflags; clientstate state; vector events; vector position, messages; string lastsaytext; int saychars, lastsay, spamcount, badspeech, badmillis; int at3_score, at3_lastforce, eff_score; bool at3_dontmove; int spawnindex; int spawnperm, spawnpermsent; bool autospawn; int salt; string pwd; uint authreq; // for AUTH string authname; // for AUTH int mapcollisions, farpickups; enet_uint32 bottomRTT; medals md; bool upspawnp; int lag; vec spawnp; int nvotes; int input, inputmillis; int ffire, wn, f, g, t, y, p; int yb, pb, oy, op, lda, ldda, fam; int nt[10], np, lp, ls, lsm, ld, nd, nlt, lem, led; vec cp[10], dp[10], d0, lv, lt, le; float dda, tr, sda; int ps, ph, tcn, bdt, pws; float pr; int yls, pls, tls; int bs, bt, blg, bp; gameevent &addevent() { static gameevent dummy; if(events.length()>100) return dummy; return events.add(); } void mapchange(bool getmap = false) { state.reset(); events.setsize(0); overflow = 0; timesync = false; isonrightmap = m_coop; spawnperm = SP_WRONGMAP; spawnpermsent = servmillis; autospawn = false; if(!getmap) { loggedwrongmap = false; freshgame = true; // permission to spawn at once } lastevent = 0; at3_lastforce = eff_score = 0; mapcollisions = farpickups = 0; md.reset(); upspawnp = false; lag = 0; spawnp = vec(-1e10f, -1e10f, -1e10f); lmillis = ldt = spj = 0; ffire = 0; f = g = y = p = t = 0; yb = pb = oy = op = lda = ldda = fam = 0; np = lp = ls = lsm = ld = nd = nlt = lem = led = 0; d0 = lv = lt = le = vec(0,0,0); loopi(10) { cp[i] = dp[i] = vec(0,0,0); nt[i] = 0; } dda = tr = sda = 0; ps = ph = bdt = pws = 0; tcn = -1; pr = 0.0f; yls = pls = tls = 0; } void reset() { name[0] = pwd[0] = demoflags = 0; bottomRTT = ping = 9999; team = TEAM_SPECT; state.state = CS_SPECTATE; loopi(2) skin[i] = 0; position.setsize(0); messages.setsize(0); isauthed = haswelcome = false; role = CR_DEFAULT; lastvotecall = 0; lastprofileupdate = fastprofileupdates = 0; vote = VOTE_NEUTRAL; lastsaytext[0] = '\0'; saychars = 0; spawnindex = -1; authreq = 0; // for AUTH mapchange(); freshgame = false; // don't spawn into running games mute = spam = lastvc = badspeech = badmillis = nvotes = 0; input = inputmillis = 0; wn = -1; bs = bt = blg = bp = 0; } void zap() { type = ST_EMPTY; role = CR_DEFAULT; isauthed = haswelcome = false; } }; struct ban { ENetAddress address; int millis, type; }; struct worldstate { enet_uint32 uses; vector positions, messages; }; struct server_entity // server side version of "entity" type { int type; bool spawned, legalpickup, twice; int spawntime; short x, y; }; struct clientidentity { uint ip; int clientnum; }; struct demofile { string info; string file; uchar *data; int len; vector clientssent; }; void startgame(const char *newname, int newmode, int newtime = -1, bool notify = true); void disconnect_client(int n, int reason = -1); void sendiplist(int receiver, int cn = -1); int clienthasflag(int cn); bool refillteams(bool now = false, int ftr = FTR_AUTOTEAM); void changeclientrole(int client, int role, char *pwd = NULL, bool force=false); mapstats *getservermapstats(const char *mapname, bool getlayout = false, int *maploc = NULL); int findmappath(const char *mapname, char *filename = NULL); int calcscores(); void recordpacket(int chan, void *data, int len); void senddisconnectedscores(int cn); void process(ENetPacket *packet, int sender, int chan); void welcomepacket(packetbuf &p, int n); void sendwelcome(client *cl, int chan = 1); void sendpacket(int n, int chan, ENetPacket *packet, int exclude = -1, bool demopacket = false); int numclients(); bool updateclientteam(int cln, int newteam, int ftr); void forcedeath(client *cl); void sendf(int cn, int chan, const char *format, ...); extern bool isdedicated; extern string smapname; extern mapstats smapstats; extern char *maplayout; const char *messagenames[SV_NUM] = { "SV_SERVINFO", "SV_WELCOME", "SV_INITCLIENT", "SV_POS", "SV_POSC", "SV_POSN", "SV_TEXT", "SV_TEAMTEXT", "SV_TEXTME", "SV_TEAMTEXTME", "SV_TEXTPRIVATE", "SV_SOUND", "SV_VOICECOM", "SV_VOICECOMTEAM", "SV_CDIS", "SV_SHOOT", "SV_EXPLODE", "SV_SUICIDE", "SV_AKIMBO", "SV_RELOAD", "SV_AUTHT", "SV_AUTHREQ", "SV_AUTHTRY", "SV_AUTHANS", "SV_AUTHCHAL", "SV_GIBDIED", "SV_DIED", "SV_GIBDAMAGE", "SV_DAMAGE", "SV_HITPUSH", "SV_SHOTFX", "SV_THROWNADE", "SV_TRYSPAWN", "SV_SPAWNSTATE", "SV_SPAWN", "SV_SPAWNDENY", "SV_FORCEDEATH", "SV_RESUME", "SV_DISCSCORES", "SV_TIMEUP", "SV_EDITENT", "SV_ITEMACC", "SV_MAPCHANGE", "SV_ITEMSPAWN", "SV_ITEMPICKUP", "SV_PING", "SV_PONG", "SV_CLIENTPING", "SV_GAMEMODE", "SV_EDITMODE", "SV_EDITXY", "SV_EDITARCH", "SV_EDITBLOCK", "SV_EDITD", "SV_EDITE", "SV_NEWMAP", "SV_SENDMAP", "SV_RECVMAP", "SV_REMOVEMAP", "SV_SERVMSG", "SV_ITEMLIST", "SV_WEAPCHANGE", "SV_PRIMARYWEAP", "SV_FLAGACTION", "SV_FLAGINFO", "SV_FLAGMSG", "SV_FLAGCNT", "SV_ARENAWIN", "SV_SETADMIN", "SV_SERVOPINFO", "SV_CALLVOTE", "SV_CALLVOTESUC", "SV_CALLVOTEERR", "SV_VOTE", "SV_VOTERESULT", "SV_SETTEAM", "SV_TEAMDENY", "SV_SERVERMODE", "SV_IPLIST", "SV_LISTDEMOS", "SV_SENDDEMOLIST", "SV_GETDEMO", "SV_SENDDEMO", "SV_DEMOPLAYBACK", "SV_CONNECT", "SV_SWITCHNAME", "SV_SWITCHSKIN", "SV_SWITCHTEAM", "SV_CLIENT", "SV_EXTENSION", "SV_MAPIDENT", "SV_HUDEXTRAS", "SV_POINTS" }; const char *entnames[] = { "none?", "light", "playerstart", "pistol", "ammobox","grenades", "health", "helmet", "armour", "akimbo", "mapmodel", "trigger", "ladder", "ctf-flag", "sound", "clip", "plclip", "dummy", "" }; // entity attribute scaling and wraparound definitions for mapformat 10 short entwraparound[MAXENTTYPES][7] = { // limit angles to 0..359 degree and mapsound slot numbers to 0..255 { 0, 0, 0, 0, 0, 0, 0 }, // deleted { 0, 0, 0, 0, 0, 0, 0 }, // light { 3600, 0, 0, 0, 0, 0, 0 }, // playerstart { 0, 0, 0, 0, 0, 0, 0 }, // pistol { 0, 0, 0, 0, 0, 0, 0 }, // ammobox { 0, 0, 0, 0, 0, 0, 0 }, // grenades { 0, 0, 0, 0, 0, 0, 0 }, // health { 0, 0, 0, 0, 0, 0, 0 }, // helmet { 0, 0, 0, 0, 0, 0, 0 }, // armour { 0, 0, 0, 0, 0, 0, 0 }, // akimbo { -3600, 0, 0, 0, -3600, 0, 0 }, // mapmodel { 0, 0, 0, 0, 0, 0, 0 }, // trigger { 0, 0, 0, 0, 0, 0, 0 }, // ladder { -3600, 0, 0, 0, 0, 0, 0 }, // ctf-flag { 256, 0, 0, 0, 0, 0, 0 }, // sound { 0, 0, 0, 0, 0, 0, 4 }, // clip { 0, 0, 0, 0, 0, 0, 4 }, // plclip { 0, 0, 0, 0, 0, 0, 0 } // dummy }; uchar entscale[MAXENTTYPES][7] = { // (no zeros allowed here!) { 1, 1, 1, 1, 1, 1, 1 }, // deleted { 1, 1, 1, 1, 1, 1, 1 }, // light { 10, 1, 1, 1, 1, 1, 1 }, // playerstart { 10, 1, 1, 1, 1, 1, 1 }, // pistol { 10, 1, 1, 1, 1, 1, 1 }, // ammobox { 10, 1, 1, 1, 1, 1, 1 }, // grenades { 10, 1, 1, 1, 1, 1, 1 }, // health { 10, 1, 1, 1, 1, 1, 1 }, // helmet { 10, 1, 1, 1, 1, 1, 1 }, // armour { 10, 1, 1, 1, 1, 1, 1 }, // akimbo { 10, 1, 5, 1, 10, 1, 1 }, // mapmodel { 1, 1, 1, 1, 1, 1, 1 }, // trigger { 1, 1, 1, 1, 1, 1, 1 }, // ladder { 10, 1, 1, 1, 1, 1, 1 }, // ctf-flag { 1, 1, 1, 1, 1, 1, 1 }, // sound { 10, 5, 5, 5, 1, 10, 1 }, // clip { 10, 5, 5, 5, 1, 10, 1 }, // plclip { 1, 1, 1, 1, 1, 1, 1 } // dummy }; // see entity.h:61: struct itemstat { int add, start, max, sound; }; // Please update ./ac_website/htdocs/docs/introduction.html if these figures change. itemstat ammostats[NUMGUNS] = { { 1, 1, 1, S_ITEMAMMO }, // knife dummy { 20, 60, 100, S_ITEMAMMO }, // pistol { 15, 30, 30, S_ITEMAMMO }, // carbine { 14, 28, 21, S_ITEMAMMO }, // shotgun { 60, 90, 90, S_ITEMAMMO }, // subgun { 10, 20, 15, S_ITEMAMMO }, // sniper { 40, 60, 60, S_ITEMAMMO }, // assault { 30, 45, 75, S_ITEMAMMO }, // cpistol { 1, 0, 3, S_ITEMAMMO }, // grenade {100, 0, 100, S_ITEMAKIMBO} // akimbo }; itemstat powerupstats[I_ARMOUR-I_HEALTH+1] = { {33, 0, 100, S_ITEMHEALTH}, // 0 health {25, 0, 100, S_ITEMARMOUR}, // 1 helmet {50, 0, 100, S_ITEMARMOUR}, // 2 armour }; guninfo guns[NUMGUNS] = { // Please update ./ac_website/htdocs/docs/introduction.html if these figures change. //mKR: mdl_kick_rot && mKB: mdl_kick_back //reI: recoilincrease && reB: recoilbase && reM: maxrecoil && reF: recoilbackfade //pFX: pushfactor //modelname sound reloadtime damage projspeed spread magsize mKB reB reF isauto // title reload attackdelay piercing part recoil mKR reI reM pFX { "knife", "Knife", S_KNIFE, S_NULL, 0, 500, 50, 100, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, false }, { "pistol", "Pistol", S_PISTOL, S_RPISTOL, 1400, 160, 18, 0, 0, 0, 53, 10, 10, 6, 5, 6, 35, 58, 125, 1, false }, { "carbine", "TMP-M&A CB", S_CARBINE, S_RCARBINE, 1800, 720, 60, 40, 0, 0, 10, 60, 10, 4, 4, 10, 60, 60, 150, 1, false }, { "shotgun", "V-19 CS", S_SHOTGUN, S_RSHOTGUN, 2400, 880, 1, 0, 0, 0, 1, 35, 7, 9, 9, 10, 140, 140, 125, 1, false }, // CAUTION dmg only sane for server! { "subgun", "A-ARD/10 SMG", S_SUBGUN, S_RSUBGUN, 1650, 80, 16, 0, 0, 0, 45, 15, 30, 1, 2, 5, 25, 50, 188, 1, true }, { "sniper", "AD-81 SR", S_SNIPER, S_RSNIPER, 1950, 1500, 82, 25, 0, 0, 50, 50, 5, 4, 4, 10, 85, 85, 100, 1, false }, { "assault", "MTP-57 AR", S_ASSAULT, S_RASSAULT, 2000, 120, 22, 0, 0, 0, 18, 30, 20, 0, 2, 3, 25, 50, 115, 1, true }, { "cpistol", "nop", S_PISTOL, S_RPISTOL, 1400, 120, 19, 0, 0, 0, 35, 10, 15, 6, 5, 6, 35, 50, 125, 1, false }, // temporary { "grenade", "Grenades", S_NULL, S_NULL, 1000, 650, 200, 0, 20, 6, 1, 1, 1, 3, 1, 0, 0, 0, 0, 3, false }, { "pistol", "Akimbo", S_PISTOL, S_RAKIMBO, 1400, 80, 19, 0, 0, 0, 50, 10, 20, 6, 5, 4, 15, 25, 115, 1, true }, }; const char *gunnames[NUMGUNS + 1]; const char *teamnames[] = {"CLA", "RVSF", "CLA-SPECT", "RVSF-SPECT", "SPECTATOR", "", "void"}; const char *teamnames_s[] = {"CLA", "RVSF", "CSPC", "RSPC", "SPEC", "", "void"}; const char *killmessages[2][NUMGUNS] = { { "", "busted", "picked off", "peppered", "sprayed", "punctured", "shredded", "busted", "", "busted" }, { "slashed", "", "", "splattered", "", "headshot", "", "", "gibbed", "" } }; #define C(x) (1<<(SC_##x)) soundcfgitem soundcfg[S_NULL] = { // name desc vol, loop, rad, key, flags { "player/jump", "Jump", 80, 0, 0, S_JUMP, C(MOVEMENT) }, // 0 { "player/step", "Soft landing", 90, 0, 24, S_SOFTLAND, C(MOVEMENT) }, // 1 { "player/land", "Hard landing", 95, 0, 24, S_HARDLAND, C(MOVEMENT) }, // 2 { "weapon/ric1", "Ricochet air 1", 0, 0, 0, S_BULLETAIR1, C(BULLET) }, // 3 { "weapon/ric2", "Ricochet air 2", 0, 0, 0, S_BULLETAIR2, C(BULLET) }, // 4 { "weapon/ric3", "Ricochet hit", 0, 0, 0, S_BULLETHIT, C(BULLET) }, // 5 { "weapon/waterimpact", "Bullet (water impact)", 0, 0, 0, S_BULLETWATERHIT, C(BULLET) }, // 6 { "weapon/knife", "Knife", 0, 0, 0, S_KNIFE, C(WEAPON) }, // 7 { "weapon/usp", "Pistol", 0, 0, 0, S_PISTOL, C(WEAPON) }, // 8 { "weapon/pistol_reload", "Pistol reloading", 0, 0, 0, S_RPISTOL, C(WEAPON) }, // 9 { "weapon/carbine", "Carbine", 0, 0, 0, S_CARBINE, C(WEAPON) }, // 10 { "weapon/carbine_reload", "Carbine reloading", 0, 0, 0, S_RCARBINE, C(WEAPON) }, // 11 { "weapon/shotgun", "Shotgun", 0, 0, 0, S_SHOTGUN, C(WEAPON) }, // 12 { "weapon/shotgun_reload", "Shotgun reloading", 0, 0, 0, S_RSHOTGUN, C(WEAPON) }, // 13 { "weapon/sub", "Submachine gun", 0, 0, 0, S_SUBGUN, C(WEAPON) }, // 14 { "weapon/sub_reload", "Submachine gun reloading", 0, 0, 0, S_RSUBGUN, C(WEAPON) }, // 15 { "weapon/sniper", "Sniper", 0, 0, 0, S_SNIPER, C(WEAPON) }, // 16 { "weapon/sniper_reload", "Sniper reloading", 0, 0, 0, S_RSNIPER, C(WEAPON) }, // 17 { "weapon/auto", "Assault rifle", 0, 0, 0, S_ASSAULT, C(WEAPON) }, // 18 { "weapon/auto_reload", "Assault rifle reloading", 0, 0, 0, S_RASSAULT, C(WEAPON) }, // 19 { "misc/pickup_ammo_clip", "Ammo pickup", 0, 0, 0, S_ITEMAMMO, C(PICKUP) }, // 20 { "misc/pickup_health", "Health pickup", 0, 0, 0, S_ITEMHEALTH, C(PICKUP) }, // 21 { "misc/pickup_armour", "Armour pickup", 0, 0, 0, S_ITEMARMOUR, C(PICKUP) }, // 22 { "misc/tick9", "Akimbo pickup", 0, 0, 0, S_ITEMAKIMBO, C(PICKUP) }, // 23 { "weapon/clip_empty", "Empty clip", 0, 0, 0, S_NOAMMO, C(WEAPON) }, // 24 { "misc/tick11", "Akimbo finished", 0, 0, 0, S_AKIMBOOUT, C(PICKUP) }, // 25 { "player/pain1", "Pain 1", 0, 0, 0, S_PAIN1, C(PAIN) }, // 26 { "player/pain2", "Pain 2", 0, 0, 0, S_PAIN2, C(PAIN) }, // 27 { "player/pain3", "Pain 3", 0, 0, 0, S_PAIN3, C(PAIN) }, // 28 { "player/pain4", "Pain 4", 0, 0, 0, S_PAIN4, C(PAIN) }, // 29 { "player/pain5", "Pain 5", 0, 0, 0, S_PAIN5, C(PAIN) }, // 30 { "player/pain6", "Pain 6", 0, 0, 0, S_PAIN6, C(PAIN) }, // 31 { "player/die1", "Die 1", 0, 0, 0, S_DIE1, C(PAIN) }, // 32 { "player/die2", "Die 2", 0, 0, 0, S_DIE2, C(PAIN) }, // 33 { "weapon/grenade_exp", "Grenade explosion", 0, 0, 0, S_FEXPLODE, C(BULLET) }, // 34 { "player/splash1", "Splash 1", 0, 0, 0, S_SPLASH1, C(MOVEMENT) }, // 35 { "player/splash2", "Splash 2", 0, 0, 0, S_SPLASH2, C(MOVEMENT) }, // 36 { "ctf/flagdrop", "Flag drop", 0, 0, 0, S_FLAGDROP, C(OTHER) }, // 37 { "ctf/flagpickup", "Flag pickup", 0, 0, 0, S_FLAGPICKUP, C(OTHER) }, // 38 { "ctf/flagreturn", "Flag return", 0, 0, 0, S_FLAGRETURN, C(OTHER) }, // 39 { "ctf/flagscore", "Flag score", 0, 0, 0, S_FLAGSCORE, C(OTHER) }, // 40 { "weapon/grenade_pull", "Grenade pull", 0, 0, 0, S_GRENADEPULL, C(WEAPON) }, // 41 { "weapon/grenade_throw", "Grenade throw", 0, 0, 0, S_GRENADETHROW, C(WEAPON) }, // 42 { "weapon/grenade_bounce1", "Grenade bounce 1", 0, 0, 0, S_GRENADEBOUNCE1, C(WEAPON) }, // 43 { "weapon/grenade_bounce2", "Grenade bounce 2", 0, 0, 0, S_GRENADEBOUNCE2, C(WEAPON) }, // 44 { "weapon/pistol_akreload", "Akimbo reload", 0, 0, 0, S_RAKIMBO, C(WEAPON) }, // 45 { "misc/change_gun", "Change weapon", 0, 0, 0, S_GUNCHANGE, C(WEAPON) }, // 46 { "misc/impact_t", "Hit sound", 0, 0, 0, S_HITSOUND, C(BULLET) }, // 47 { "player/gib", "Gib sounds", 0, 0, 0, S_GIB, C(PAIN) }, // 48 { "misc/headshot", "Headshot", 10, 0, 0, S_HEADSHOT, C(OTHER) }, // 49 { "vote/vote_call", "Call vote", 0, 0, 0, S_CALLVOTE, C(OTHER) }, // 50 { "vote/vote_pass", "Pass vote", 0, 0, 0, S_VOTEPASS, C(OTHER) }, // 51 { "vote/vote_fail", "Fail vote", 0, 0, 0, S_VOTEFAIL, C(OTHER) }, // 52 { "player/footsteps", "Footsteps", 40, 1, 20, S_FOOTSTEPS, C(MOVEMENT) }, // 53 { "player/crouch", "Crouch", 40, 1, 10, S_FOOTSTEPSCROUCH, C(MOVEMENT) }, // 54 { "player/watersteps", "Water footsteps", 40, 1, 20, S_WATERFOOTSTEPS, C(MOVEMENT) }, // 55 { "player/watercrouch", "Water crouching", 40, 1, 10, S_WATERFOOTSTEPSCROUCH, C(MOVEMENT) }, // 56 { "player/crouch_in", "Crouch-in", 85, 0, 14, S_CROUCH, C(MOVEMENT) }, // 57 { "player/crouch_out", "Crouch-out", 75, 0, 14, S_UNCROUCH, C(MOVEMENT) }, // 58 { "misc/menu_click1", "Menu select", 0, 0, 0, S_MENUSELECT, C(OTHER) }, // 59 { "misc/menu_click2", "Menu enter", 0, 0, 0, S_MENUENTER, C(OTHER) }, // 60 { "player/underwater", "Underwater", 0, 0, 0, S_UNDERWATER, C(MOVEMENT) }, // 61 { "misc/tinnitus", "Tinnitus", 2, 0, 0, S_TINNITUS, C(OWNPAIN) }, // 62 { "voicecom/affirmative", "Affirmative", 0, 0, 0, S_AFFIRMATIVE, C(VOICECOM)|C(TEAM) }, // 63 { "voicecom/allrightsir", "All-right sir", 0, 0, 0, S_ALLRIGHTSIR, C(VOICECOM)|C(TEAM) }, // 64 { "voicecom/comeonmove", "Come on, move", 0, 0, 0, S_COMEONMOVE, C(VOICECOM)|C(TEAM)|C(PUBLIC)|C(FFA) }, // 65 { "voicecom/cominginwiththeflag", "Coming in with the flag", 0,0,0, S_COMINGINWITHTHEFLAG, C(VOICECOM)|C(TEAM) |C(FLAGONLY) }, // 66 { "voicecom/coverme", "Cover me", 0, 0, 0, S_COVERME, C(VOICECOM)|C(TEAM) }, // 67 { "voicecom/defendtheflag", "Defend the flag", 0, 0, 0, S_DEFENDTHEFLAG, C(VOICECOM)|C(TEAM) |C(FLAGONLY) }, // 68 { "voicecom/enemydown", "Enemy down", 0, 0, 0, S_ENEMYDOWN, C(VOICECOM)|C(TEAM)|C(PUBLIC) }, // 69 { "voicecom/gogetemboys", "Go get 'em boys!", 0, 0, 0, S_GOGETEMBOYS, C(VOICECOM)|C(TEAM) }, // 70 { "voicecom/goodjobteam", "Good job team", 0, 0, 0, S_GOODJOBTEAM, C(VOICECOM)|C(TEAM) }, // 71 { "voicecom/igotone", "I got one!", 0, 0, 0, S_IGOTONE, C(VOICECOM)|C(TEAM)|C(PUBLIC) }, // 72 { "voicecom/imadecontact", "I made contact", 0, 0, 0, S_IMADECONTACT, C(VOICECOM)|C(TEAM) }, // 73 { "voicecom/imattacking", "I'm attacking", 0, 0, 0, S_IMATTACKING, C(VOICECOM)|C(TEAM) }, // 74 { "voicecom/imondefense", "I'm on defense", 0, 0, 0, S_IMONDEFENSE, C(VOICECOM)|C(TEAM) }, // 75 { "voicecom/imonyourteamman", "I'm on your team", 0, 0, 0, S_IMONYOURTEAMMAN, C(VOICECOM)|C(TEAM) }, // 76 { "voicecom/negative", "Negative", 0, 0, 0, S_NEGATIVE, C(VOICECOM)|C(TEAM) }, // 77 { "voicecom/nocando", "No can do", 0, 0, 0, S_NOCANDO, C(VOICECOM)|C(TEAM) }, // 78 { "voicecom/recovertheflag", "Recover the flag", 0, 0, 0, S_RECOVERTHEFLAG, C(VOICECOM)|C(TEAM) |C(FLAGONLY) }, // 79 { "voicecom/sorry", "Sorry", 0, 0, 0, S_SORRY, C(VOICECOM)|C(TEAM)|C(PUBLIC)|C(FFA) }, // 80 { "voicecom/spreadout", "Spread out", 0, 0, 0, S_SPREADOUT, C(VOICECOM)|C(TEAM) }, // 81 { "voicecom/stayhere", "Stay here", 0, 0, 0, S_STAYHERE, C(VOICECOM)|C(TEAM) }, // 82 { "voicecom/staytogether", "Stay together", 0, 0, 0, S_STAYTOGETHER, C(VOICECOM)|C(TEAM) }, // 83 { "voicecom/theresnowaysir", "There's no way sir", 0, 0, 0, S_THERESNOWAYSIR, C(VOICECOM)|C(TEAM) }, // 84 { "voicecom/wedidit", "We did it!", 0, 0, 0, S_WEDIDIT, C(VOICECOM)|C(TEAM) }, // 85 { "voicecom/yes", "Yes", 0, 0, 0, S_YES, C(VOICECOM)|C(TEAM) }, // 86 { "voicecom/onthemove_1", "Under way", 0, 0, 0, S_ONTHEMOVE1, C(VOICECOM)|C(TEAM) }, // 87 { "voicecom/onthemove_2", "On the move", 0, 0, 0, S_ONTHEMOVE2, C(VOICECOM)|C(TEAM) }, // 88 { "voicecom/igotyourback", "Got your back", 0, 0, 0, S_GOTURBACK, C(VOICECOM)|C(TEAM) }, // 89 { "voicecom/igotyoucovered", "Got you covered", 0, 0, 0, S_GOTUCOVERED, C(VOICECOM)|C(TEAM) }, // 90 { "voicecom/inposition_1", "In position", 0, 0, 0, S_INPOSITION1, C(VOICECOM)|C(TEAM) }, // 91 { "voicecom/inposition_2", "In position now", 0, 0, 0, S_INPOSITION2, C(VOICECOM)|C(TEAM) }, // 92 { "voicecom/reportin", "Report in!", 0, 0, 0, S_REPORTIN, C(VOICECOM)|C(TEAM) }, // 93 { "voicecom/niceshot", "Nice shot", 0, 0, 0, S_NICESHOT, C(VOICECOM)|C(TEAM)|C(PUBLIC)|C(FFA) }, // 94 { "voicecom/thanks_1", "Thanks", 0, 0, 0, S_THANKS1, C(VOICECOM)|C(TEAM)|C(PUBLIC)|C(FFA) }, // 95 { "voicecom/thanks_2", "Thanks, man", 0, 0, 0, S_THANKS2, C(VOICECOM)|C(TEAM)|C(PUBLIC)|C(FFA) }, // 96 { "voicecom/awesome_1", "Awesome (1)", 0, 0, 0, S_AWESOME1, C(VOICECOM)|C(TEAM)|C(PUBLIC)|C(FFA) }, // 97 { "voicecom/awesome_2", "Awesome (2)", 0, 0, 0, S_AWESOME2, C(VOICECOM)|C(TEAM)|C(PUBLIC)|C(FFA) }, // 98 { "misc/pickup_helmet", "Helmet pickup", 0, 0, 0, S_ITEMHELMET, C(PICKUP) }, // 99 { "player/heartbeat", "Heartbeat", 0, 0, 0, S_HEARTBEAT, C(OWNPAIN) }, // 100 { "ktf/flagscore", "KTF score", 0, 0, 0, S_KTFSCORE, C(OTHER) }, // 101 { "misc/camera", "Screenshot", 0, 0, 0, S_CAMERA, C(OTHER) } // 102 }; #undef C assaultcube-1.2.0.2.1/source/src/serveractions.h000066400000000000000000000251321352165075300214650ustar00rootroot00000000000000// available server actions enum { EE_LOCAL_SERV = 1, EE_DED_SERV = 1<<1 }; // execution environment int roleconf(int key) { // current defaults: "fkbMASRCDEPtw" if(strchr(scl.voteperm, tolower(key))) return CR_DEFAULT; if(strchr(scl.voteperm, toupper(key))) return CR_ADMIN; return (key) == tolower(key) ? CR_DEFAULT : CR_ADMIN; } struct serveraction { int role; // required client role int area; // only on ded servers string desc; virtual void perform() = 0; virtual bool isvalid() { return true; } virtual bool isdisabled() { return false; } serveraction() : role(CR_DEFAULT), area(EE_DED_SERV) { desc[0] = '\0'; } virtual ~serveraction() { } }; void kick_abuser(int cn, int &cmillis, int &count, int limit) { if ( cmillis + 30000 > servmillis ) count++; else { count -= count > 0 ? (servmillis - cmillis)/30000 : 0; if ( count <= 0 ) count = 1; } cmillis = servmillis; if( count >= limit ) disconnect_client(cn, DISC_ABUSE); } struct mapaction : serveraction { char *map; int mode, time; bool mapok, queue; void perform() { if(queue) { nextgamemode = mode; copystring(nextmapname, map); } else if(isdedicated && numclients() > 2 && smode >= 0 && smode != 1 && ( gamemillis > gamelimit/4 || scl.demo_interm )) { forceintermission = true; nextgamemode = mode; copystring(nextmapname, map); } else { startgame(map, mode, time); } } bool isvalid() { return serveraction::isvalid() && mode != GMODE_DEMO && map[0] && mapok && !(isdedicated && !m_mp(mode)); } bool isdisabled() { return maprot.current() && !maprot.current()->vote; } mapaction(char *map, int mode, int time, int caller, bool q) : map(map), mode(mode), time(time), queue(q) { if(isdedicated) { bool notify = valid_client(caller); int maploc = MAP_NOTFOUND; mapstats *ms = map[0] ? getservermapstats(map, false, &maploc) : NULL; bool validname = validmapname(map); mapok = (ms != NULL) && validname && ( (mode != GMODE_COOPEDIT && mapisok(ms)) || (mode == GMODE_COOPEDIT && !readonlymap(maploc)) ); if(!mapok) { if(notify) { if(!validname) sendservmsg("invalid map name", caller); else { sendservmsg(ms ? ( mode == GMODE_COOPEDIT ? "this map cannot be coopedited in this server" : "sorry, but this map does not satisfy some quality requisites to be played in MultiPlayer Mode" ) : "the server does not have this map", caller); } } } else { // check, if map supports mode if(mode == GMODE_COOPEDIT && !strchr(scl.voteperm, 'e')) role = CR_ADMIN; bool romap = mode == GMODE_COOPEDIT && readonlymap(maploc); int smode = mode; // 'borrow' the mode macros by replacing a global by a local var bool spawns = mode == GMODE_COOPEDIT || (m_teammode && !m_ktf ? ms->hasteamspawns : ms->hasffaspawns); bool flags = mode != GMODE_COOPEDIT && m_flags && !m_htf ? ms->hasflags : true; if(!spawns || !flags || romap) { // unsupported mode if(strchr(scl.voteperm, 'P')) role = CR_ADMIN; else if(!strchr(scl.voteperm, 'p')) mapok = false; // default: no one can vote for unsupported mode/map combinations defformatstring(msg)("\f3map \"%s\" does not support \"%s\": ", behindpath(map), modestr(mode, false)); if(romap) concatstring(msg, "map is readonly"); else { if(!spawns) concatstring(msg, "player spawns"); if(!spawns && !flags) concatstring(msg, " and "); if(!flags) concatstring(msg, "flag bases"); concatstring(msg, " missing"); } if(notify) sendservmsg(msg, caller); logline(ACLOG_INFO, "%s", msg); } } loopv(scl.adminonlymaps) { const char *s = scl.adminonlymaps[i], *h = strchr(s, '#'), *m = behindpath(map); size_t sl = strlen(s); if(h) { if(h != s) { sl = h - s; if(mode != atoi(h + 1)) continue; } else { if(mode == atoi(h+1)) { role = CR_ADMIN; break; } } } if(sl == strlen(m) && !strncmp(m, scl.adminonlymaps[i], sl)) role = CR_ADMIN; } } else { int mp = findmappath(map); mapok = mp == MAP_LOCAL || mp == MAP_OFFICIAL; // clients can only load from packages/maps and packages/maps/official #ifndef STANDALONE if(!mapok) conoutf("\f3map '%s' not found", map); #endif } area |= EE_LOCAL_SERV; // local too formatstring(desc)("load map '%s' in mode '%s'", map, modestr(mode)); if(q) concatstring(desc, " (in the next game)"); } ~mapaction() { DELETEA(map); } }; struct demoplayaction : serveraction { char *demofilename; void perform() { startdemoplayback(demofilename); } demoplayaction(char *demofilename) : demofilename(demofilename) { area = EE_LOCAL_SERV; // only local } ~demoplayaction() { DELETEA(demofilename); } }; struct playeraction : serveraction { int cn; ENetAddress address; void disconnect(int reason) { int i = findcnbyaddress(&address); if(i >= 0) disconnect_client(i, reason); } virtual bool isvalid() { return valid_client(cn) && clients[cn]->role != CR_ADMIN; } // actions can't be done on admins playeraction(int cn) : cn(cn) { if(isvalid()) address = clients[cn]->peer->address; }; }; struct forceteamaction : playeraction { int team; void perform() { updateclientteam(cn, team, FTR_SILENTFORCE); } virtual bool isvalid() { return valid_client(cn) && team_isvalid(team) && team != clients[cn]->team; } forceteamaction(int cn, int caller, int team) : playeraction(cn), team(team) { if(cn != caller) role = roleconf('f'); if(isvalid() && !(clients[cn]->state.forced && clients[caller]->role != CR_ADMIN)) formatstring(desc)("force player %s to team %s", clients[cn]->name, teamnames[team]); } }; struct giveadminaction : playeraction { void perform() { changeclientrole(cn, CR_ADMIN, NULL, true); } giveadminaction(int cn) : playeraction(cn) { role = CR_ADMIN; // role = roleconf('G'); } }; struct kickaction : playeraction { bool wasvalid; void perform() { disconnect(DISC_MKICK); } virtual bool isvalid() { return wasvalid || playeraction::isvalid(); } kickaction(int cn, char *reason) : playeraction(cn) { wasvalid = false; role = roleconf('k'); if(isvalid() && strlen(reason) > 3 && valid_client(cn)) { wasvalid = true; formatstring(desc)("kick player %s, reason: %s", clients[cn]->name, reason); } } }; struct banaction : playeraction { bool wasvalid; void perform() { int i = findcnbyaddress(&address); if(i >= 0) addban(clients[i], DISC_MBAN, BAN_VOTE); } virtual bool isvalid() { return wasvalid || playeraction::isvalid(); } banaction(int cn, char *reason) : playeraction(cn) { wasvalid = false; role = roleconf('b'); if(isvalid() && strlen(reason) > 3) { wasvalid = true; formatstring(desc)("ban player %s, reason: %s", clients[cn]->name, reason); } } }; struct removebansaction : serveraction { void perform() { bans.shrink(0); } removebansaction() { role = roleconf('b'); copystring(desc, "remove all bans"); } }; struct mastermodeaction : serveraction { int mode; void perform() { changemastermode(mode); } bool isvalid() { return mode >= 0 && mode < MM_NUM; } mastermodeaction(int mode) : mode(mode) { role = roleconf('M'); if(isvalid()) formatstring(desc)("change mastermode to '%s'", mmfullname(mode)); } }; struct enableaction : serveraction { bool enable; enableaction(bool enable) : enable(enable) {} }; struct autoteamaction : enableaction { void perform() { autoteam = enable; sendservermode(); if(m_teammode && enable) refillteams(true); } autoteamaction(bool enable) : enableaction(enable) { role = roleconf('A'); if(isvalid()) formatstring(desc)("%s autoteam", enable ? "enable" : "disable"); } }; struct shuffleteamaction : serveraction { void perform() { sendf(-1, 1, "ri2", SV_SERVERMODE, sendservermode(false) | AT_SHUFFLE); shuffleteams(); } bool isvalid() { return serveraction::isvalid() && m_teammode; } shuffleteamaction() { role = roleconf('S'); if(isvalid()) copystring(desc, "shuffle teams"); } }; struct recorddemoaction : enableaction // TODO: remove completely { void perform() { } bool isvalid() { return serveraction::isvalid(); } recorddemoaction(bool enable) : enableaction(enable) { role = roleconf('R'); if(isvalid()) formatstring(desc)("%s demorecord", enable ? "enable" : "disable"); } }; struct cleardemosaction : serveraction { int demo; void perform() { cleardemos(demo); } cleardemosaction(int demo) : demo(demo) { role = roleconf('C'); if(isvalid()) formatstring(desc)("clear demo %d", demo); } }; struct serverdescaction : serveraction { char *sdesc; int cn; ENetAddress address; void perform() { updatesdesc(sdesc, &address); } bool isvalid() { return serveraction::isvalid() && updatedescallowed() && valid_client(cn); } serverdescaction(char *sdesc, int cn) : sdesc(sdesc), cn(cn) { role = roleconf('D'); formatstring(desc)("set server description to '%s'", sdesc); if(isvalid()) address = clients[cn]->peer->address; } ~serverdescaction() { DELETEA(sdesc); } }; assaultcube-1.2.0.2.1/source/src/serverbrowser.cpp000066400000000000000000001461351352165075300220520ustar00rootroot00000000000000// serverbrowser.cpp: eihrul's concurrent resolver, and server browser window management #include "cube.h" #include "SDL_thread.h" extern bool isdedicated; struct resolverthread { SDL_Thread *thread; const char *query; int starttime; }; struct resolverresult { const char *query; ENetAddress address; }; vector resolverthreads; vector resolverqueries; vector resolverresults; SDL_mutex *resolvermutex; SDL_cond *querycond, *resultcond; #define RESOLVERTHREADS 1 #define RESOLVERLIMIT 3000 int resolverloop(void * data) { resolverthread *rt = (resolverthread *)data; SDL_LockMutex(resolvermutex); SDL_Thread *thread = rt->thread; SDL_UnlockMutex(resolvermutex); if(!thread || SDL_GetThreadID(thread) != SDL_ThreadID()) return 0; while(thread == rt->thread) { SDL_LockMutex(resolvermutex); while(resolverqueries.empty()) SDL_CondWait(querycond, resolvermutex); rt->query = resolverqueries.pop(); rt->starttime = totalmillis; SDL_UnlockMutex(resolvermutex); ENetAddress address = { ENET_HOST_ANY, ENET_PORT_ANY }; enet_address_set_host(&address, rt->query); SDL_LockMutex(resolvermutex); if(rt->query && thread == rt->thread) { resolverresult &rr = resolverresults.add(); rr.query = rt->query; rr.address = address; rt->query = NULL; rt->starttime = 0; SDL_CondSignal(resultcond); } SDL_UnlockMutex(resolvermutex); } return 0; } void resolverinit() { resolvermutex = SDL_CreateMutex(); querycond = SDL_CreateCond(); resultcond = SDL_CreateCond(); SDL_LockMutex(resolvermutex); loopi(RESOLVERTHREADS) { resolverthread &rt = resolverthreads.add(); rt.query = NULL; rt.starttime = 0; rt.thread = SDL_CreateThread(resolverloop, "ResolverThread", &rt); } SDL_UnlockMutex(resolvermutex); } void resolverstop(resolverthread &rt) { SDL_LockMutex(resolvermutex); if(rt.query) { SDL_DetachThread(rt.thread); rt.thread = SDL_CreateThread(resolverloop, "ResolverThread", &rt); } rt.query = NULL; rt.starttime = 0; SDL_UnlockMutex(resolvermutex); } void resolverclear() { if(resolverthreads.empty()) return; SDL_LockMutex(resolvermutex); resolverqueries.shrink(0); resolverresults.shrink(0); loopv(resolverthreads) { resolverthread &rt = resolverthreads[i]; resolverstop(rt); } SDL_UnlockMutex(resolvermutex); } void resolverquery(const char *name) { if(resolverthreads.empty()) resolverinit(); SDL_LockMutex(resolvermutex); resolverqueries.add(name); SDL_CondSignal(querycond); SDL_UnlockMutex(resolvermutex); } bool resolvercheck(const char **name, ENetAddress *address) { bool resolved = false; SDL_LockMutex(resolvermutex); if(!resolverresults.empty()) { resolverresult &rr = resolverresults.pop(); *name = rr.query; address->host = rr.address.host; resolved = true; } else loopv(resolverthreads) { resolverthread &rt = resolverthreads[i]; if(rt.query && totalmillis - rt.starttime > RESOLVERLIMIT) { resolverstop(rt); *name = rt.query; resolved = true; } } SDL_UnlockMutex(resolvermutex); return resolved; } extern bool isdedicated; bool resolverwait(const char *name, ENetAddress *address) { if(isdedicated) return enet_address_set_host(address, name) >= 0; if(resolverthreads.empty()) resolverinit(); defformatstring(text)("resolving %s... (esc to abort)", name); show_out_of_renderloop_progress(0, text); SDL_LockMutex(resolvermutex); resolverqueries.add(name); SDL_CondSignal(querycond); int starttime = SDL_GetTicks(), timeout = 0; bool resolved = false; for(;;) { SDL_CondWaitTimeout(resultcond, resolvermutex, 250); loopv(resolverresults) if(resolverresults[i].query == name) { address->host = resolverresults[i].address.host; resolverresults.remove(i); resolved = true; break; } if(resolved) break; timeout = SDL_GetTicks() - starttime; show_out_of_renderloop_progress(min(float(timeout)/RESOLVERLIMIT, 1.0f), text); SDL_Event event; while(SDL_PollEvent(&event)) { if(event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE) timeout = RESOLVERLIMIT + 1; } if(timeout > RESOLVERLIMIT) break; } if(!resolved && timeout > RESOLVERLIMIT) { loopv(resolverthreads) { resolverthread &rt = resolverthreads[i]; if(rt.query == name) { resolverstop(rt); break; } } } SDL_UnlockMutex(resolvermutex); return resolved; } SDL_Thread *connthread = NULL; SDL_mutex *connmutex = NULL; SDL_cond *conncond = NULL; struct connectdata { ENetSocket sock; ENetAddress address; int result; }; // do this in a thread to prevent timeouts // could set timeouts on sockets, but this is more reliable and gives more control int connectthread(void *data) { SDL_LockMutex(connmutex); if(!connthread || SDL_GetThreadID(connthread) != SDL_ThreadID()) { SDL_UnlockMutex(connmutex); return 0; } connectdata cd = *(connectdata *)data; SDL_UnlockMutex(connmutex); int result = enet_socket_connect(cd.sock, &cd.address); SDL_LockMutex(connmutex); if(!connthread || SDL_GetThreadID(connthread) != SDL_ThreadID()) { enet_socket_destroy(cd.sock); SDL_UnlockMutex(connmutex); return 0; } ((connectdata *)data)->result = result; SDL_CondSignal(conncond); SDL_UnlockMutex(connmutex); return 0; } #define CONNLIMIT 20000 int connectwithtimeout(ENetSocket sock, const char *hostname, ENetAddress &address) { if(isdedicated) { int result = enet_socket_connect(sock, &address); if(result<0) enet_socket_destroy(sock); return result; } defformatstring(text)("connecting to %s:%d... (esc to abort)", hostname, address.port); show_out_of_renderloop_progress(0, text); if(!connmutex) connmutex = SDL_CreateMutex(); if(!conncond) conncond = SDL_CreateCond(); SDL_LockMutex(connmutex); connectdata cd = { sock, address, -1 }; connthread = SDL_CreateThread(connectthread, "ConnectThread", &cd); int starttime = SDL_GetTicks(), timeout = 0; for(;;) { if(!SDL_CondWaitTimeout(conncond, connmutex, 250)) { if(cd.result<0) enet_socket_destroy(sock); break; } timeout = SDL_GetTicks() - starttime; show_out_of_renderloop_progress(min(float(timeout)/CONNLIMIT, 1.0f), text); SDL_Event event; while(SDL_PollEvent(&event)) { if(event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE) timeout = CONNLIMIT + 1; } if(timeout > CONNLIMIT) break; } /* thread will actually timeout eventually if its still trying to connect * so just leave it (and let it destroy socket) instead of causing problems on some platforms by killing it */ connthread = NULL; SDL_UnlockMutex(connmutex); return cd.result; } vector servers; ENetSocket pingsock = ENET_SOCKET_NULL; int lastinfo = 0; serverinfo *findserverinfo(ENetAddress address) { loopv(servers) if(servers[i]->address.host == address.host && servers[i]->port == address.port) return servers[i]; return NULL; } serverinfo *getconnectedserverinfo() { extern ENetPeer *curpeer; if(!curpeer) return NULL; return findserverinfo(curpeer->address); } static serverinfo *newserver(const char *name, uint ip = ENET_HOST_ANY, int port = CUBE_DEFAULT_SERVER_PORT, int weight = 0) { serverinfo *si = new serverinfo; si->address.host = ip; si->address.port = CUBE_SERVINFO_PORT(port); si->msweight = weight; if(ip!=ENET_HOST_ANY) si->resolved = serverinfo::RESOLVED; if(name) copystring(si->name, name); else if(ip==ENET_HOST_ANY || enet_address_get_host_ip(&si->address, si->name, sizeof(si->name)) < 0) { delete si; return NULL; } si->port = port; servers.insert(0, si); return si; } void addserver(const char *servername, int serverport, int weight) { if(serverport <= 0) serverport = CUBE_DEFAULT_SERVER_PORT; loopv(servers) if(strcmp(servers[i]->name, servername)==0 && servers[i]->port == serverport) return; newserver(servername, ENET_HOST_ANY, serverport, weight); } VARP(servpingrate, 1000, 5000, 60000); VARP(maxservpings, 0, 10, 1000); VAR(searchlan, 0, 1, 2); #define PINGBUFSIZE 100 static int pingbuf[PINGBUFSIZE], curpingbuf = 0; int chooseextping(serverinfo *si) { if(si->getinfo != EXTPING_NOP) return si->getinfo; if(!si->uplinkqual_age || totalmillis - si->uplinkqual_age > 60 * 1000) return EXTPING_UPLINKSTATS; return EXTPING_NOP; } void pingservers(bool issearch, serverinfo *onlyconnected) { if(pingsock == ENET_SOCKET_NULL) { pingsock = enet_socket_create(ENET_SOCKET_TYPE_DATAGRAM); if(pingsock == ENET_SOCKET_NULL) { lastinfo = totalmillis; return; } enet_socket_set_option(pingsock, ENET_SOCKOPT_NONBLOCK, 1); enet_socket_set_option(pingsock, ENET_SOCKOPT_BROADCAST, 1); } ENetBuffer buf; static uchar ping[MAXTRANS]; ucharbuf p(ping, sizeof(ping)); curpingbuf = (curpingbuf + 1) % PINGBUFSIZE; pingbuf[(curpingbuf + PINGBUFSIZE / 2) % PINGBUFSIZE] = 0; pingbuf[curpingbuf] = onlyconnected ? 0 : totalmillis; putint(p, curpingbuf + 1); // offset by 1 to avoid extinfo trigger int baselen = p.length(); if(onlyconnected) { serverinfo *si = onlyconnected; //p.len = baselen; if(si->getinfo == EXTPING_SERVERINFO) { putint(p, EXTPING_SERVERINFO); const char *silang; if(strlen(lang) != 2) silang = "en"; else silang = lang; loopi(2) putint(p, silang[i]); } else putint(p, issearch ? EXTPING_NAMELIST : chooseextping(si)); buf.data = ping; buf.dataLength = p.length(); enet_socket_send(pingsock, &si->address, &buf, 1); } else if(searchlan < 2) { static int lastping = 0; if(lastping >= servers.length()) lastping = 0; loopi(maxservpings ? min(servers.length(), maxservpings) : servers.length()) { serverinfo &si = *servers[lastping]; if(++lastping >= servers.length()) lastping = 0; if(si.address.host == ENET_HOST_ANY) continue; p.len = baselen; putint(p, issearch ? EXTPING_NAMELIST : chooseextping(&si)); buf.data = ping; buf.dataLength = p.length(); enet_socket_send(pingsock, &si.address, &buf, 1); } } if(searchlan && !onlyconnected) { ENetAddress address; address.host = ENET_HOST_BROADCAST; address.port = CUBE_SERVINFO_PORT_LAN; p.len = baselen; putint(p, issearch ? EXTPING_NAMELIST : EXTPING_UPLINKSTATS); buf.data = ping; buf.dataLength = p.length(); enet_socket_send(pingsock, &address, &buf, 1); } lastinfo = totalmillis; } void checkresolver() { int resolving = 0; loopv(servers) { serverinfo &si = *servers[i]; if(si.resolved == serverinfo::RESOLVED) continue; if(si.address.host == ENET_HOST_ANY) { if(si.resolved == serverinfo::UNRESOLVED) { si.resolved = serverinfo::RESOLVING; resolverquery(si.name); } resolving++; } } if(!resolving) return; const char *name = NULL; ENetAddress addr = { ENET_HOST_ANY, ENET_PORT_ANY }; while(resolvercheck(&name, &addr)) { loopv(servers) { serverinfo &si = *servers[i]; if(name == si.name) { si.resolved = serverinfo::RESOLVED; si.address.host = addr.host; addr.host = ENET_HOST_ANY; break; } } } } #define MAXINFOLINELEN 100 // including color codes void checkpings() { if(pingsock == ENET_SOCKET_NULL) return; enet_uint32 events = ENET_SOCKET_WAIT_RECEIVE; ENetBuffer buf; ENetAddress addr; static uchar ping[MAXTRANS]; static char text[MAXTRANS]; buf.data = ping; buf.dataLength = sizeof(ping); while(enet_socket_wait(pingsock, &events, 0) >= 0 && events) { int len = enet_socket_receive(pingsock, &addr, &buf, 1); if(len <= 0) return; serverinfo *si = NULL; loopv(servers) if(addr.host == servers[i]->address.host && addr.port == servers[i]->address.port) { si = servers[i]; break; } if(!si && searchlan) si = newserver(NULL, addr.host, CUBE_SERVINFO_TO_SERV_PORT(addr.port)); if(!si) continue; ucharbuf p(ping, len); si->lastpingmillis = totalmillis; int pingtm = pingbuf[(getint(p) - 1) % PINGBUFSIZE]; if(pingtm) si->ping = totalmillis - pingtm; int query = getint(p); switch(query) { // cleanup additional query info case EXTPING_SERVERINFO: loopi(2) getint(p); break; } si->protocol = getint(p); if(si->protocol!=PROTOCOL_VERSION) si->ping = 9998; si->mode = getint(p); si->numplayers = getint(p); si->minremain = getint(p); getstring(text, p); filtertext(si->map, behindpath(text), FTXT__MAPNAME); getstring(text, p); filtertext(si->sdesc, text, FTXT__SERVDESC); copystring(si->description, si->sdesc); si->maxclients = getint(p); if(p.remaining()) { si->pongflags = getint(p); if(p.remaining() && getint(p) == query) { switch(query) { #define RESETINFOLINES() si->infotexts.setsize(0); \ ucharbuf q(si->textdata, sizeof(si->textdata)) #define ADDINFOLINE(msg) si->infotexts.add((char *)si->textdata + q.length()); \ sendstring(msg, q) case EXTPING_NAMELIST: { si->playernames.setsize(0); ucharbuf q(si->namedata, sizeof(si->namedata)); loopi(si->numplayers) { getstring(text, p); filtertext(text, text, FTXT__PLAYERNAME); if(text[0] && !p.overread()) { si->playernames.add((const char *)si->namedata + q.length()); sendstring(text, q); } else break; } break; } case EXTPING_SERVERINFO: { RESETINFOLINES(); getstring(text, p); if(strlen(text) != 2) { ADDINFOLINE("this server does not provide additional information"); break; } strcpy(si->lang, text); while(p.remaining()) { getstring(text, p); if(*text && !p.overread()) { text[MAXINFOLINELEN] = '\0'; cutcolorstring(text, 100); ADDINFOLINE(strcmp(text, ".") ? text : ""); } else break; } break; } case EXTPING_MAPROT: { RESETINFOLINES(); int n = getint(p); ADDINFOLINE("\f1server map rotation:"); ADDINFOLINE(""); while(p.remaining()) { getstring(text, p); filtertext(text, behindpath(text), FTXT__MAPNAME); if(*text && !p.overread()) { text[MAXINFOLINELEN] = '\0'; loopi(n) concatformatstring(text, ", %d", getint(p)); ADDINFOLINE(text ); } else break; } break; } case EXTPING_UPLINKSTATS: { si->uplinkqual_age = totalmillis; if(si->maxclients > 3) { int maxs = 0, maxc = 0, ts, tc; loopi(si->maxclients - 3) { ts = tc = si->uplinkstats[i + 4] = p.get(); if(si->maxclients < 8 || i > 2) { ts &= 0xF0; tc &= 0x0F; if(ts > maxs) maxs = ts; if(ts > 0x40 && tc > maxc) maxc = tc; // spent time = 2 ^ ((ts >> 4) - 1) * 30 sec, so 0x50 is 8..15 minutes } } if(maxs < 0x90) maxc -= 2; // go easy on fresh started servers if(maxs < 0x50) si->uplinkqual = 3; else if(maxc < 3) si->uplinkqual = 5; // choke_percentage = 1 / 2 ^ (15 - tc), so 0x03 is 0.02% else if(maxc < 6) si->uplinkqual = 4; // 0.2% else if(maxc == 6) si->uplinkqual = 3; else if(maxc < 9) si->uplinkqual = 2; // 1.6% (yep, that IS bad) else si->uplinkqual = 1; } if(si->getinfo == EXTPING_UPLINKSTATS) { RESETINFOLINES(); if(si->maxclients < 4) { ADDINFOLINE("server is too small for uplink quality statistics"); } else { ADDINFOLINE("\f1server uplink quality and usage statistics:"); ADDINFOLINE(""); ADDINFOLINE("players:\terrors/time"); for(int i = 4; i <= si->maxclients; i++) { defformatstring(msg)(" %d\t", i); loopj(15) concatformatstring(msg, "\a%c ", '0' + ((si->uplinkstats[i] & 0x0F) > j) + 2 * ((si->uplinkstats[i] & 0xF0) > (j << 4))); concatformatstring(msg, "\t\t [%02X]", si->uplinkstats[i]); ADDINFOLINE(msg); } ADDINFOLINE(""); ADDINFOLINE("\f4red bar: error rate, green bar: time played"); } } break; } #undef RESETINFOLINES #undef ADDINFOLINE } } } else { si->pongflags = 0; } if(si->getinfo == query) si->getinfo = EXTPING_NOP; if(si->pongflags > 0) { const char *sp = ""; int mm = si->pongflags >> PONGFLAG_MASTERMODE; if(si->pongflags & (1 << PONGFLAG_BANNED)) sp = "you are banned from this server"; if(si->pongflags & (1 << PONGFLAG_BLACKLIST)) sp = "you are blacklisted on this server"; else if(si->pongflags & (1 << PONGFLAG_PASSWORD)) sp = "this server is password-protected"; else if(mm) sp = mmfullname(mm); formatstring(si->description)("%s \f1(%s)", si->sdesc, sp); } } } enum { SBS_PING = 0, SBS_NUMPL, SBS_MAXPL, SBS_MINREM, SBS_MAP, SBS_MODE, SBS_IP, SBS_DESC, NUMSERVSORT }; VARP(serversort, 0, 0, NUMSERVSORT-1); VARP(serversortdir, 0, 0, 1); VARP(showonlygoodservers, 0, 0, 1); VAR(shownamesinbrowser, 0, 0, 1); VARP(showminremain, 0, 1, 1); VARP(showallplayersnumber, 0, 1, 1); VARP(serversortpreferofficial, 0, 1, 1); void serversortprepare() { loopv(servers) { serverinfo &si = *servers[i]; // basic group weights: used(700) - empty(500) - unusable(200) if(si.protocol != PROTOCOL_VERSION) si.weight += 200; else if(!si.numplayers) si.weight += 500; else { si.weight += 700; if(serversortpreferofficial && securemapcheck(si.map, false)) si.weight += 100; } si.weight += si.msweight; } } int sicompare(serverinfo **ap, serverinfo **bp) { serverinfo *a = *ap, *b = *bp; int dir = serversortdir ? -1 : 1; if(a->weight > b->weight) return -dir; if(a->weight < b->weight) return dir; enet_uint32 ai = ENET_NET_TO_HOST_32(a->address.host), bi = ENET_NET_TO_HOST_32(b->address.host); int ips = ai < bi ? -dir : (ai > bi ? dir : 0); // most steady base sorting switch(serversort) { case SBS_NUMPL: // player number if(a->numplayers < b->numplayers) return dir; if(a->numplayers > b->numplayers) return -dir; break; case SBS_MAXPL: // maxplayers if(a->maxclients < b->maxclients) return dir; if(a->maxclients > b->maxclients) return -dir; break; case SBS_MINREM: // minutes remaining if(a->minremain < b->minremain) return dir; if(a->minremain > b->minremain) return -dir; break; case SBS_DESC: // description { static string ad, bd; filtertext(ad, a->sdesc, FTXT__SERVDESC); filtertext(bd, b->sdesc, FTXT__SERVDESC); if(!ad[0] && bd[0]) return dir; if(ad[0] && !bd[0]) return -dir; int mdir = dir * strcasecmp(ad, bd); if(mdir) return mdir; break; } case SBS_IP: // IP if(ips) return ips; break; case SBS_MAP: // map { int mdir = dir * strcasecmp(a->map, b->map); if(mdir) return mdir; break; } case SBS_MODE: // mode { const char *am = modestr(a->mode, modeacronyms > 0), *bm = modestr(b->mode, modeacronyms > 0); int mdir = dir * strcasecmp(am, bm); if(mdir) return mdir; break; } } if(serversort == SBS_PING || (!a->numplayers && !b->numplayers)) // ping { if(a->ping > b->ping) return dir; if(a->ping < b->ping) return -dir; } if(ips) return ips; if(a->port > b->port) return dir; else return -dir; } void *servmenu = NULL, *searchmenu = NULL, *serverinfomenu = NULL; vector namelists; string cursearch, cursearchuc; void searchnickname(const char *name) { if(!name || !name[0]) return; copystring(cursearch, name); copystring(cursearchuc, name); strtoupper(cursearchuc); showmenu("search"); } COMMAND(searchnickname, "s"); VAR(showallservers, 0, 1, 1); bool matchplayername(const char *name) { static string nameuc; copystring(nameuc, name); strtoupper(nameuc); return strstr(nameuc, cursearchuc) != NULL; } VARP(serverbrowserhideip, 0, 0, 2); VARP(serverbrowserhidefavtag, 0, 1, 2); VAR(showweights, 0, 0, 1); VARP(hidefavicons, 0, 0, 1); vector favcats; const char *fc_als[] = { "weight", "tag", "desc", "red", "green", "blue", "alpha", "keys", "ignore", "image" }; enum { FC_WEIGHT = 0, FC_TAG, FC_DESC, FC_RED, FC_GREEN, FC_BLUE, FC_ALPHA, FC_KEYS, FC_IGNORE, FC_IMAGE, FC_NUM }; VARF(showonlyfavourites, 0, 0, 100, { if(showonlyfavourites > favcats.length()) { conoutf("showonlyfavourites: %d out of range (0..%d)", showonlyfavourites, favcats.length()); showonlyfavourites = 0; } }); const char *favcatargname(const char *refdes, int par) { static string text[3]; static int i = 0; if(par < 0 || par >= FC_NUM) return NULL; i = (i + 1) % 3; formatstring(text[i])("sbfavourite_%s_%s", refdes, fc_als[par]); return text[i]; } void addfavcategory(const char *refdes) { string text, val; char alx[FC_NUM]; if(!refdes) { intret(0); return; } filtertext(text, refdes, FTXT__FAVCATEGORY); if(!text[0]) { intret(0); return; } loopv(favcats) if(!strcmp(favcats[i], text)) { intret(i + 1); return; } favcats.add(newstring(text)); bool oldpersist = persistidents; persistidents = false; // only keep changed values loopi(FC_NUM) alx[i] = getalias(favcatargname(text, i)) ? 1 : 0; loopi(3) { formatstring(val)("%d", *text & (1 << i) ? 90 : 10); if(!alx[i + FC_RED]) alias(favcatargname(text, i + FC_RED), val); } formatstring(val)("favourites %d", favcats.length()); const int defk[] = { FC_WEIGHT, FC_DESC, FC_TAG, FC_KEYS, FC_IGNORE, FC_ALPHA }; const char *defv[] = { "0", val, refdes, "", "", "20" }; loopi(sizeof(defk)/sizeof(defk[0])) { if(!alx[defk[i]]) alias(favcatargname(text, defk[i]), defv[i]); } persistidents = oldpersist; intret(favcats.length()); } void listfavcats() { const char *str = conc((const char **)favcats.getbuf(), favcats.length(), true); result(str); delete [] str; } bool favcatcheckkey(serverinfo &si, const char *key) { // IP:port, #gamemode ,%mapname, desc string text, keyuc; if(isdigit(*key)) // IP { formatstring(text)("%s:%d", si.name, si.port); return !strncmp(text, key, strlen(key)); } else if(si.address.host != ENET_HOST_ANY && si.ping != 9999) switch(*key) { case '#': return si.map[0] && si.mode == atoi(key + 1); case '%': strtoupper(text, si.map); strtoupper(keyuc, key + 1); return si.map[0] && key[1] && strstr(text, keyuc); case '>': return si.ping > atoi(key + 1); case '!': return !favcatcheckkey(si, key + 1); case '+': return si.map[0] && favcatcheckkey(si, key + 1); case '$': if(key[1]) { formatstring(text)("%s \"%s\" %d %d %d %d %d \"%s\" %d %d", key + 1, si.map, si.mode, si.ping, si.minremain, si.numplayers, si.maxclients, si.name, si.port, si.pongflags); filtertext(text, text, FTXT_NOCOLOR|FTXT_NOWHITE|FTXT_ALLOWBLANKS); int cnt = 0; for(const char *p = text; (p = strchr(p, '\"')); p++) cnt++; return cnt == 4 && execute(text); } break; default: filtertext(text, si.sdesc, FTXT_NOCOLOR|FTXT_NOWHITE|FTXT_ALLOWBLANKS|(showonlyfavourites > 0 ? FTXT_TOUPPER : 0)); strtoupper(keyuc, key); return *key && strstr(text, showonlyfavourites > 0 ? keyuc : key); } return false; } const char *favcatcheck(serverinfo &si, const char *ckeys, char *autokeys = NULL) { if(!ckeys) return NULL; static char *nkeys = NULL; const char *sep = " \t\n\r"; char *keys = newstring(ckeys), *b, *k = strtok_r(keys, sep, &b); bool res = false; DELETEA(nkeys); nkeys = newstring(strlen(ckeys)); nkeys[0] = '\0'; while(k) { if(favcatcheckkey(si, k)) { res = true; if(autokeys && !(isdigit(*k) && strchr(k, ':'))) concatformatstring(autokeys, *autokeys ? " %s" : "%s", k); } else { if(*nkeys) strcat(nkeys, " "); strcat(nkeys, k); } k = strtok_r(NULL, sep, &b); } delete[] keys; return res ? nkeys : NULL; } void serverbrowseralternativeviews(int shiftdirection) { if(searchlan == 2) return; const char *ckeys = getalias("serverbrowseraltviews"); if(!ckeys) return; const char *sep = " \t\n\r"; char *keys = newstring(ckeys), *b, *k = strtok_r(keys, sep, &b); vector cats; cats.add(0); while(k) { loopv(favcats) if(!strcmp(favcats[i], k)) cats.add(i + 1); k = strtok_r(NULL, sep, &b); } delete[] keys; if(cats.length()) { loopv(cats) { if(cats[i] == showonlyfavourites) { showonlyfavourites = cats[(i + shiftdirection + cats.length()) % cats.length()]; return; } } } showonlyfavourites = 0; } vector favcattags; bool assignserverfavourites() { int alxn[FC_NUM]; const char *alx[FC_NUM], *sep = " \t\n\r"; favcattags.setsize(0); bool res = false; loopv(servers) { servers[i]->favcat = -1; servers[i]->weight = 0; } loopvj(favcats) { loopi(FC_NUM) { alx[i] = getalias(favcatargname(favcats[j], i)); alxn[i] = alx[i] ? atoi(alx[i]) : 0; } favcattags.add(alx[FC_TAG]); bool showonlythiscat = j == showonlyfavourites - 1; char *keys = newstring(alx[FC_KEYS]), *b, *k = strtok_r(keys, sep, &b); while(k) { loopv(servers) { serverinfo &si = *servers[i]; if(si.address.host == ENET_HOST_ANY || si.ping == 9999 || si.protocol != PROTOCOL_VERSION) continue; if((!alxn[FC_IGNORE] || showonlythiscat) && favcatcheckkey(si, k)) { si.weight += alxn[FC_WEIGHT]; res = true; if(si.favcat == -1 || showonlythiscat) { si.favcat = j; if(alxn[FC_ALPHA]) { if(!si.bgcolor) si.bgcolor = new color; new (si.bgcolor) color(((float)alxn[FC_RED])/100, ((float)alxn[FC_GREEN])/100, ((float)alxn[FC_BLUE])/100, ((float)alxn[FC_ALPHA])/100); } else DELETEP(si.bgcolor) } } } k = strtok_r(NULL, sep, &b); } delete[] keys; } loopv(servers) if(servers[i]->favcat == -1) { DELETEA(servers[i]->bgcolor); } return res; } COMMAND(addfavcategory, "s"); COMMAND(listfavcats, ""); static serverinfo *lastselectedserver = NULL; static bool pinglastselected = false; void refreshservers(void *menu, bool init) { static int servermenumillis; static bool usedselect = false; static string title; bool issearch = menu == searchmenu; bool isinfo = menu == serverinfomenu; bool isscoreboard = menu == NULL; serverinfo *curserver = getconnectedserverinfo(), *oldsel = NULL; if(init) { loopi(PINGBUFSIZE) if(pingbuf[i] < totalmillis) pingbuf[i] = 0; if(resolverthreads.empty()) resolverinit(); else resolverclear(); loopv(servers) resolverquery(servers[i]->name); servermenumillis = totalmillis; usedselect = false; if(menu && curserver) oldsel = curserver; } checkresolver(); checkpings(); if(isinfo) { if(lastselectedserver) { bool found = false; loopv(servers) if(lastselectedserver == servers[i]) { found = true; break; } if(!found) lastselectedserver = NULL; } menureset(menu); static string infotext; static char dummy = '\0'; if(lastselectedserver) { serverinfo &si = *lastselectedserver; formatstring(si.full)("%s:%d %s", si.name, si.port, si.sdesc); menuitemmanual(menu, si.full); menuitemmanual(menu, &dummy); if(si.infotexts.length() && !pinglastselected) { infotext[0] = '\0'; loopv(si.infotexts) menuimagemanual(menu, NULL, "bargraphs", si.infotexts[i]); } else { copystring(infotext, "-- waiting for server response --"); if(si.getinfo == EXTPING_NOP) si.getinfo = EXTPING_SERVERINFO; if(init || pinglastselected || totalmillis - lastinfo >= servpingrate) pingservers(false, lastselectedserver); pinglastselected = false; } } else copystring(infotext, " -- no server selected --"); if(*infotext) menuitemmanual(menu, infotext); return; } if((init && issearch) || totalmillis - lastinfo >= (servpingrate * (issearch ? 2 : 1))/(maxservpings ? max(1, (servers.length() + maxservpings - 1) / maxservpings) : 1)) pingservers(issearch, isscoreboard ? curserver : NULL); if(!init && menu)// && servers.inrange(((gmenu *)menu)->menusel)) { serverinfo *foundserver = NULL; loopv(servers) if(servers[i]->menuline_from == ((gmenu *)menu)->menusel && servers[i]->menuline_to > servers[i]->menuline_from) { foundserver = servers[i]; break; } if(foundserver) { if((usedselect || ((gmenu *)menu)->menusel > 0)) oldsel = foundserver; lastselectedserver = foundserver; } } if(isscoreboard) lastselectedserver = curserver; bool showfavtag = (assignserverfavourites() || !serverbrowserhidefavtag) && serverbrowserhidefavtag != 2; serversortprepare(); servers.sort(sicompare); if(menu) { bool showmr = showminremain || serversort == SBS_MINREM; menureset(menu); menuheader(menu, NULL, NULL); string text; int curnl = 0; int allplayers = 0; bool sbconnectexists = identexists("sbconnect"); loopv(servers) { serverinfo &si = *servers[i]; si.menuline_to = si.menuline_from = ((gmenu *)menu)->items.length(); if( (!showallservers && si.lastpingmillis <= servermenumillis) || (si.maxclients>MAXCL && searchlan<2) ) continue; // no pong yet or forbidden int banned = ((si.pongflags >> PONGFLAG_BANNED) & 1) | ((si.pongflags >> (PONGFLAG_BLACKLIST - 1)) & 2); bool showthisone = !(banned && showonlygoodservers) && !(showonlyfavourites > 0 && si.favcat != showonlyfavourites - 1); bool serverfull = si.numplayers >= si.maxclients; bool needspasswd = (si.pongflags & (1 << PONGFLAG_PASSWORD)) > 0; int mmode = (si.pongflags >> PONGFLAG_MASTERMODE) & MM_MASK; char basecolor = banned ? '4' : (curserver == servers[i] ? '1' : '5'); char plnumcolor = serverfull ? '2' : (needspasswd ? '3' : (mmode != MM_OPEN ? '1' : basecolor)); const char *favimage = NULL; if(si.address.host != ENET_HOST_ANY && si.ping != 9999) { if(si.protocol!=PROTOCOL_VERSION) { if(!showonlygoodservers) formatstring(si.full)("%s:%d [%s]", si.name, si.port, si.protocol<0 ? "modded version" : (si.protocol -1) favimage = getalias(favcatargname(favcats[si.favcat], FC_IMAGE)); copystring(text, si.favcat > -1 && !favimage ? favcattags[si.favcat] : ""); if(showweights) concatformatstring(text, "(%d)", si.weight); if(showfavtag && !favimage) formatstring(si.full)("\fs%s\fr\t", text); else copystring(si.full, showfavtag ? "\t" : ""); concatformatstring(si.full, "\fs\f%c%s\t\fs\f%c%d/%d\fr\t\a%c ", basecolor, colorping(si.ping), plnumcolor, si.numplayers, si.maxclients, '0' + si.uplinkqual); if(si.map[0]) { concatformatstring(si.full, "%s, %s", si.map, modestr(si.mode, modeacronyms > 0)); if(showmr) concatformatstring(si.full, ", (%d)", si.minremain); } else concatformatstring(si.full, "empty"); concatstring(si.full, ": "); if(serverbrowserhideip < 2) concatformatstring(si.full, "\fs%s%s:%d\fr", serverbrowserhideip == 1 ? "\f4" : "", si.name, si.port); concatformatstring(si.full, "\fr %s", si.sdesc); } } else { if(!showonlygoodservers) formatstring(si.full)(si.address.host != ENET_HOST_ANY ? "%s:%d [waiting for server response]" : "%s:%d [unknown host]", si.name, si.port); else showthisone = false; } if(issearch && showthisone) { bool found = false; loopvj(si.playernames) if(matchplayername(si.playernames[j])) { found = true; break; }; if(!found) showthisone = false; } if(showthisone) { cutcolorstring(si.full, 105); // cut off too long server descriptions cutcolorstring(si.description, 100); if(sbconnectexists) { filtertext(text, si.sdesc, FTXT_NOCOLOR|FTXT_NOWHITE|FTXT_ALLOWBLANKS); for(char *p = text; (p = strchr(p, '\"')); *p++ = ' '); formatstring(si.cmd)("sbconnect %s %d %d %d %d %d", si.name, si.port, serverfull ? 1 : 0, needspasswd ? 1 : 0, mmode, banned); text[max(int(MAXSTRLEN - strlen(si.cmd) - 10), 0)] = '\0'; concatformatstring(si.cmd, " \"%s\"", text); } else formatstring(si.cmd)("connect %s %d", si.name, si.port); menuimagemanual(menu, favimage, "serverquality", si.full, si.cmd, si.bgcolor, si.description); if(!issearch && servers[i] == oldsel) { ((gmenu *)menu)->menusel = ((gmenu *)menu)->items.length() - 1; usedselect = true; if(shownamesinbrowser) si.getinfo = EXTPING_NAMELIST; } if((shownamesinbrowser && servers[i] == oldsel && si.playernames.length()) || issearch) { int cur = 0; char *t = NULL; loopvj(si.playernames) { if(cur == 0) { if(namelists.length() < ++curnl) namelists.add(newstringbuf()); t = namelists[curnl - 1]; copystring(t, showfavtag ? "\t\t" : "\t"); } concatformatstring(t, " \t\fs%s%s\fr", !issearch || matchplayername(si.playernames[j]) ? "" : "\f4" ,si.playernames[j]); cur++; if(cur == 4) { menuitemmanual(menu, t, NULL, NULL, NULL); cur = 0; } } if(cur) menuitemmanual(menu, t, NULL, NULL, NULL); } } si.menuline_to = ((gmenu *)menu)->items.length(); if(!(showonlyfavourites > 0 && (servers[i]->favcat != showonlyfavourites - 1))) allplayers += servers[i]->numplayers; } static const char *titles[NUMSERVSORT] = { "%s\fs\f0ping\fr\t%s plr\tserver%s%s", // 0: ping "%sping\t\fs\f0%s plr\fr\tserver%s%s", // 1: player number "%sping\t%s plr\tserver (\fs\f0max players\fr)%s%s", // 2: maxplayers "%sping\t%s plr\fs\f0\fr\tserver (\fs\f0minutes remaining\fr)%s%s", // 3: minutes remaining "%sping\t%s plr\tserver (\fs\f0map\fr)%s%s", // 4: map "%sping\t%s plr\tserver (\fs\f0game mode\fr)%s%s", // 5: mode "%sping\t%s plr\tserver (\fs\f0IP\fr)%s%s", // 6: IP "%sping\t%s plr\tserver (\fs\f0description\fr)%s%s" // 7: description }; defformatstring(allplrs)("%d", allplayers); formatstring(title)(titles[serversort], showfavtag ? "fav\t" : "", !issearch && showallplayersnumber ? allplrs : "", issearch ? " search results for \f3" : " (F1: Help/Settings)", issearch ? cursearch : ""); menutitlemanual(menu, title); static string notfoundmsg, headermsg; notfoundmsg[0] = '\0'; if(issearch) { if(curnl == 0) formatstring(notfoundmsg)("\t\tpattern \fs\f3%s\fr not found.", cursearch); } if(showonlyfavourites && favcats.inrange(showonlyfavourites - 1)) { const char *desc = getalias(favcatargname(favcats[showonlyfavourites - 1], FC_DESC)); formatstring(headermsg)("Servers in category \f2%s", desc ? desc : favcattags[showonlyfavourites - 1]); menuheader(menu, headermsg, NULL); if(!((gmenu *)menu)->items.length() && !issearch) formatstring(notfoundmsg)("\t(no servers in this category)"); } if(*notfoundmsg) menuitemmanual(menu, notfoundmsg, NULL, NULL, NULL); } } bool serverskey(void *menu, int code, bool isdown) { int fk[] = { SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5, SDLK_6, SDLK_7, SDLK_8, SDLK_9, SDLK_0 }, gogetem = 1; if(!isdown) return false; loopi(sizeof(fk)/sizeof(fk[0])) if(code == fk[i] && favcats.inrange(i)) { int sel = ((gmenu *)menu)->menusel; loopvj(servers) if(menu && (servers[j]->menuline_from <= sel && servers[j]->menuline_to > sel)) { string ak; ak[0] = '\0'; const char *keyalias = favcatargname(favcats[i], FC_KEYS), *key = getalias(keyalias), *rest = favcatcheck(*servers[j], key, ak), *desc = getalias(favcatargname(favcats[i], FC_DESC)); if(!desc) desc = ""; if(*ak) { // server was automatically added to this favourite group, don't remove conoutf("server \"\fs%s\fr\" is in category '\fs%s\fr' because of key '%s', please remove manually", servers[j]->sdesc, desc, ak); } else if(rest) { // remove from favourite group conoutf("removing server \"\fs%s\fr\" from favourites category '\fs%s\fr' (rest '%s')", servers[j]->sdesc, desc, rest); alias(keyalias, rest); } else { // add IP:port to group defformatstring(text)("%s:%d", servers[j]->name, servers[j]->port); if(key && *key) { char *newkey = newstring(key, strlen(text) + 1 + strlen(key)); strcat(newkey, " "); strcat(newkey, text); alias(keyalias, newkey); delete[] newkey; } else alias(keyalias, text); conoutf("adding server \"\fs%s\fr\" to favourites category '\fs%s\fr' (new '%s')", servers[j]->sdesc, desc, getalias(keyalias)); } return true; } } switch(code) { case SDLK_LEFT: serversort = (serversort+NUMSERVSORT-1) % NUMSERVSORT; return true; case SDLK_RIGHT: serversort = (serversort+1) % NUMSERVSORT; return true; case SDLK_LEFTBRACKET: serverbrowseralternativeviews(-1); return true; case SDLK_RIGHTBRACKET: serverbrowseralternativeviews(1); return true; case SDLK_F5: updatefrommaster(&gogetem); return true; case SDLK_F6: serversortdir = serversortdir ? 0 : 1; return true; case SDLK_F9: showmenu("serverinfo"); return true; } if(menu == searchmenu) return false; switch(code) { case SDLK_F1: showmenu("serverbrowser help"); return true; case SDLK_F2: shownamesinbrowser = shownamesinbrowser ? 0 : 1; return true; case SDLK_F3: showmenu("search player"); return true; case SDLK_F4: showmenu("edit favourites"); return true; case SDLK_F7: showonlygoodservers = showonlygoodservers ? 0 : 1; return true; case SDLK_F8: showminremain = showminremain ? 0 : 1; return true; } return false; } bool serverinfokey(void *menu, int code, bool isdown) { if(!isdown) return false; switch(code) { case SDLK_F5: if(lastselectedserver) lastselectedserver->getinfo = EXTPING_SERVERINFO; pinglastselected = true; return true; case SDLK_F1: showmenu("serverinfo help"); // feel free to actually write this menu ;) return true; case SDLK_F2: // yep: undocumented :) if(lastselectedserver) lastselectedserver->getinfo = EXTPING_UPLINKSTATS; pinglastselected = true; break; case SDLK_m: if(lastselectedserver) lastselectedserver->getinfo = EXTPING_MAPROT; pinglastselected = true; break; case SDLK_c: lastselectedserver = getconnectedserverinfo(); pinglastselected = true; break; } return false; } void clearservers() { resolverclear(); servers.deletecontents(); } #define RETRIEVELIMIT 5000 extern char *global_name; bool cllock = false, clfail = false; int progress_callback_retrieveservers(void *data, float progress) { if(progress < 0) show_out_of_renderloop_progress(progress + 1.0f, "waiting for response (esc to abort)"); else show_out_of_renderloop_progress(min(progress, 1.0f), (const char *)data); return interceptkey(SDLK_ESCAPE) ? 1 : 0; } VARP(mastertype, 0, 1, 1); // 0: TCP direct, 1: HTTP proxy void retrieveservers(vector &data) { if(mastertype) { httpget h; defformatstring(progresstext)("resolving %s", mastername); h.callbackfunc = progress_callback_retrieveservers; h.callbackdata = progresstext; show_out_of_renderloop_progress(0.01f, progresstext); if(h.set_host(mastername)) { formatstring(progresstext)("retrieving servers from %s:%d... (esc to abort)", mastername, masterport); defformatstring(url)("/retrieve.do?action=list&name=%s&version=%d&build=%d", urlencode(global_name, true), AC_VERSION, getbuildtype()|(1<<16)); h.outvec = (vector *) &data; // ouch... show_out_of_renderloop_progress(0, progresstext); int got = h.get(url, RETRIEVELIMIT, RETRIEVELIMIT); if(got < 0 || h.response != 200) data.setsize(0); h.outvec = NULL; // must not be cleaned up by httpget if(data.length()) data.add('\0'); clfail = false; } else { conoutf("failed to resolve host %s", mastername); clfail = true; } } else { ENetSocket sock = connectmaster(); if(sock == ENET_SOCKET_NULL) { conoutf("Master server is not replying."); clfail = true; return; } clfail = false; defformatstring(text)("retrieving servers from %s:%d... (esc to abort)", mastername, masterport); show_out_of_renderloop_progress(0, text); int starttime = SDL_GetTicks(), timeout = 0; defformatstring(request)("list %s %d %d\n", global_name, AC_VERSION, getbuildtype()); const char *req = request; int reqlen = strlen(req); ENetBuffer buf; while(reqlen > 0) { enet_uint32 events = ENET_SOCKET_WAIT_SEND; if(enet_socket_wait(sock, &events, 250) >= 0 && events) { buf.data = (void *)req; buf.dataLength = reqlen; int sent = enet_socket_send(sock, NULL, &buf, 1); if(sent < 0) break; req += sent; reqlen -= sent; if(reqlen <= 0) break; } timeout = SDL_GetTicks() - starttime; show_out_of_renderloop_progress(min(float(timeout)/RETRIEVELIMIT, 1.0f), text); if(interceptkey(SDLK_ESCAPE)) timeout = RETRIEVELIMIT + 1; if(timeout > RETRIEVELIMIT) break; } if(reqlen <= 0) for(;;) { enet_uint32 events = ENET_SOCKET_WAIT_RECEIVE; if(enet_socket_wait(sock, &events, 250) >= 0 && events) { if(data.length() >= data.capacity()) data.reserve(4096); buf.data = data.getbuf() + data.length(); buf.dataLength = data.capacity() - data.length(); int recv = enet_socket_receive(sock, NULL, &buf, 1); if(recv <= 0) break; data.advance(recv); } timeout = SDL_GetTicks() - starttime; show_out_of_renderloop_progress(min(float(timeout)/RETRIEVELIMIT, 1.0f), text); if(interceptkey(SDLK_ESCAPE)) timeout = RETRIEVELIMIT + 1; if(timeout > RETRIEVELIMIT) break; } if(data.length()) data.add('\0'); enet_socket_destroy(sock); } } VARP(masterupdatefrequency, 1, 60*60, 24*60*60); VAR(msctrl, 1, 1, INT_MAX); void updatefrommaster(int *force) { static int lastupdate = 0; if(lastupdate==0) cllock = true; if(!*force && lastupdate && totalmillis-lastupdate data; retrieveservers(data); if(data.empty()) { if (!clfail) conoutf("Master server is not replying. \f1Get more information at http://masterserver.cubers.net/"); cllock = !clfail; } else { // preserve currently connected server from deletion serverinfo *curserver = getconnectedserverinfo(); string curname; if(curserver) copystring(curname, curserver->name); clearservers(); if(!strncmp(data.getbuf(), "addserver", 9)) cllock = false; // the ms could reply other thing... but currently, this is useless if(!cllock ) { execute(data.getbuf()); if(curserver) addserver(curname, curserver->port, curserver->msweight); } lastupdate = totalmillis; } } COMMANDF(addserver, "sii", (char *n, int *p, int *w) { addserver(n, *p, *w); }); COMMAND(clearservers, ""); COMMAND(updatefrommaster, "i"); void writeservercfg() { stream *f = openfile(path("config/servers.cfg", true), "w"); if(!f) return; f->printf("// servers connected to are added here automatically\n"); loopvrev(servers) { f->printf("\naddserver %s %d", servers[i]->name, servers[i]->port); if(servers[i]->msweight) f->printf(" %d", servers[i]->msweight); } f->printf("\n"); delete f; } assaultcube-1.2.0.2.1/source/src/serverchecks.h000066400000000000000000000531761352165075300212760ustar00rootroot00000000000000inline bool is_lagging(client *cl) { return ( cl->spj > 50 || cl->ping > 500 || cl->ldt > 80 ); // do not change this except if you really know what are you doing } inline bool outside_border(vec &po) { return (po.x < 0 || po.y < 0 || po.x >= maplayoutssize || po.y >= maplayoutssize); } inline void checkclientpos(client *cl) { vec &po = cl->state.o; if( outside_border(po) || maplayout[((int) po.x) + (((int) po.y) << maplayout_factor)] > po.z + 3) { if(gamemillis > 10000 && (servmillis - cl->connectmillis) > 10000) cl->mapcollisions++; if(cl->mapcollisions && !(cl->mapcollisions % 25)) { logline(ACLOG_INFO, "[%s] %s is colliding with the map", cl->hostname, cl->name); } } } #define POW2XY(A,B) (pow2(A.x-B.x)+pow2(A.y-B.y)) extern inline void addban(client *cl, int reason, int type = BAN_AUTO); #ifdef ACAC #include "anticheat.h" #endif #define MINELINE 50 //FIXME /* There are smarter ways to implement this function, but most probably they will be very complex */ int getmaxarea(int inversed_x, int inversed_y, int transposed, int ml_factor, char *ml) { int ls = (1 << ml_factor); int xi = 0, oxi = 0, xf = 0, oxf = 0, fx = 0, fy = 0; int area = 0, maxarea = 0; bool sav_x = false, sav_y = false; if (transposed) fx = ml_factor; else fy = ml_factor; // walk on x for each y for ( int y = (inversed_y ? ls-1 : 0); (inversed_y ? y >= 0 : y < ls); (inversed_y ? y-- : y++) ) { /* Analyzing each cube of the line */ for ( int x = (inversed_x ? ls-1 : 0); (inversed_x ? x >= 0 : x < ls); (inversed_x ? x-- : x++) ) { if ( ml[ ( x << fx ) + ( y << fy ) ] != 127 ) { // if it is not solid if ( sav_x ) { // if the last cube was saved xf = x; // new end for this line } else { xi = x; // new begin of the line sav_x = true; // accumulating cubes from now } } else { // solid if ( xf - xi > MINELINE ) break; // if the empty line is greater than a minimum, get out sav_x = false; // stop the accumulation of cubes } } /* Analyzing this line with the previous one */ if ( xf - xi > MINELINE ) { // if the line has the minimun threshold of emptiness if ( sav_y ) { // if the last line was saved if ( 2*oxi + MINELINE < 2*xf && 2*xi + MINELINE < 2*oxf ) { // if the last line intersect this one area += xf - xi; } else { oxi = xi; // new area vertices oxf = xf; } } else { oxi = xi; oxf = xf; sav_y = true; // accumulating lines from now } } else { sav_y = false; // stop the accumulation of lines if (area > maxarea) maxarea = area; // new max area area=0; } sav_x = false; // reset x xi = xf = 0; } return maxarea; } int checkarea(int maplayout_factor, char *maplayout) { int area = 0, maxarea = 0; for (int i=0; i < 8; i++) { area = getmaxarea((i & 1),(i & 2),(i & 4), maplayout_factor, maplayout); if ( area > maxarea ) maxarea = area; } return maxarea; } /** This part is related to medals system. WIP */ const char * medal_messages[] = { "defended the flag", "covered the flag stealer", "defended the dropped flag", "covered the flag keeper", "covered teammate" }; enum { CTFLDEF, CTFLCOV, HTFLDEF, HTFLCOV, COVER, MEDALMESSAGENUM }; inline void print_medal_messages(client *c, int n) { if (n<0 || n>=MEDALMESSAGENUM) return; logline(ACLOG_VERBOSE, "[%s] %s %s", c->hostname, c->name, medal_messages[n]); } inline void addpt(client *c, int points, int n = -1) { c->state.points += points; c->md.dpt += points; c->md.updated = true; c->md.upmillis = gamemillis + 240; // about 2 AR shots print_medal_messages(c,n); } /** cnumber is the number of players in the game, at a max value of 12 */ #define CTFPICKPT cnumber // player picked the flag (ctf) #define CTFDROPPT -cnumber // player dropped the flag to other player (probably) #define HTFLOSTPT -2*cnumber // penalty #define CTFLOSTPT cnumber*distance/100 // bonus: 1/4 of the flag score bonus #define CTFRETURNPT cnumber // flag return #define CTFSCOREPT (cnumber*distance/25+10) // flag score #define HTFSCOREPT (cnumber*4+10) #define KTFSCOREPT (cnumber*2+10) #define COMBOPT 5 // player frags with combo #define REPLYPT 2 // reply success #define TWDONEPT 5 // team work done #define CTFLDEFPT cnumber // player defended the flag in the base (ctf) #define CTFLCOVPT cnumber*2 // player covered the flag stealer (ctf) #define HTFLDEFPT cnumber // player defended a droped flag (htf) #define HTFLCOVPT cnumber*3 // player covered the flag keeper (htf) #define COVERPT cnumber*2 // player covered teammate #define DEATHPT -4 // player died #define BONUSPT target->state.points/400 // bonus (for killing high level enemies :: beware with exponential behavior!) #define FLBONUSPT target->state.points/300 // bonus if flag team mode #define TMBONUSPT target->state.points/200 // bonus if team mode (to give some extra reward for playing tdm modes) #define HTFFRAGPT cnumber/2 // player frags while carrying the flag #define CTFFRAGPT 2*cnumber // player frags the flag stealer #define FRAGPT 10 // player frags (normal) #define HEADSHOTPT 15 // player gibs with head shot #define KNIFEPT 20 // player gibs with the knife #define SHOTGPT 12 // player gibs with the shotgun #define TKPT -20 // player tks #define FLAGTKPT -2*(10+cnumber) // player tks the flag keeper/stealer void flagpoints(client *c, int message) { float distance = 0; int cnumber = totalclients < 13 ? totalclients : 12; switch (message) { case FM_PICKUP: c->md.flagpos.x = c->state.o.x; c->md.flagpos.y = c->state.o.y; c->md.flagmillis = servmillis; if (m_ctf) addpt(c, CTFPICKPT); break; case FM_DROP: if (m_ctf) addpt(c, CTFDROPPT); break; case FM_LOST: if (m_htf) addpt(c, HTFLOSTPT); else if (m_ctf) { distance = sqrt(POW2XY(c->state.o,c->md.flagpos)); if (distance > 200) distance = 200; // ~200 is the distance between the flags in ac_depot addpt(c, CTFLOSTPT); } break; case FM_RETURN: addpt(c, CTFRETURNPT); break; case FM_SCORE: if (m_ctf) { distance = sqrt(POW2XY(c->state.o,c->md.flagpos)); if (distance > 200) distance = 200; #ifdef ACAC if ( validflagscore(distance,c) ) #endif addpt(c, CTFSCOREPT); } else addpt(c, HTFSCOREPT); break; case FM_KTFSCORE: addpt(c, KTFSCOREPT); break; default: break; } } inline int minhits2combo(int gun) { switch (gun) { case GUN_SUBGUN: case GUN_AKIMBO: return 4; case GUN_GRENADE: case GUN_ASSAULT: return 3; default: return 2; } } void checkcombo(client *target, client *actor, int damage, int gun) { int diffhittime = servmillis - actor->md.lasthit; actor->md.lasthit = servmillis; if ((gun == GUN_SHOTGUN || gun == GUN_GRENADE) && damage < 20) { actor->md.lastgun = gun; return; } if ( diffhittime < 750 ) { if ( gun == actor->md.lastgun ) { if ( diffhittime * 2 < guns[gun].attackdelay * 3 ) { actor->md.combohits++; actor->md.combotime+=diffhittime; actor->md.combodamage+=damage; int mh2c = minhits2combo(gun); if ( actor->md.combohits > mh2c && actor->md.combohits % mh2c == 1 ) { if (actor->md.combo < 5) actor->md.combo++; actor->md.ncombos++; } } } else { switch (gun) { case GUN_KNIFE: case GUN_PISTOL: if ( guns[actor->md.lastgun].isauto ) break; case GUN_SNIPER: if ( actor->md.lastgun > GUN_PISTOL ) break; default: actor->md.combohits++; actor->md.combotime+=diffhittime; actor->md.combodamage+=damage; if (actor->md.combo < 5) actor->md.combo++; actor->md.ncombos++; break; } } } else { actor->md.combo = 0; actor->md.combofrags = 0; actor->md.combotime = 0; actor->md.combodamage = 0; actor->md.combohits = 0; } actor->md.lastgun = gun; } #define COVERDIST 2000 // about 45 cubes #define REPLYDIST 8000 // about 90 cubes float coverdist = COVERDIST; int checkteamrequests(int sender) { int dtime, besttime = -1; int bestid = -1; client *ant = clients[sender]; loopv(clients) { client *prot = clients[i]; if ( i!=sender && prot->type != ST_EMPTY && prot->team == ant->team && prot->state.state == CS_ALIVE && prot->md.askmillis > gamemillis && prot->md.ask >= 0 ) { float dist = POW2XY(ant->state.o,prot->state.o); if ( dist < REPLYDIST && (dtime=prot->md.askmillis-gamemillis) > besttime) { bestid = i; besttime = dtime; } } } if ( besttime >= 0 ) return bestid; return -1; } /** WIP */ void checkteamplay(int s, int sender) { client *actor = clients[sender]; if ( actor->state.state != CS_ALIVE ) return; switch(s){ case S_IMONDEFENSE: // informs actor->md.linkmillis = gamemillis + 20000; actor->md.linkreason = s; break; case S_COVERME: // demands case S_STAYTOGETHER: case S_STAYHERE: actor->md.ask = s; actor->md.askmillis = gamemillis + 5000; break; case S_AFFIRMATIVE: // replies case S_ALLRIGHTSIR: case S_YES: { int id = checkteamrequests(sender); if ( id >= 0 ) { client *sgt = clients[id]; actor->md.linked = id; if ( actor->md.linkmillis < gamemillis ) addpt(actor,REPLYPT); actor->md.linkmillis = gamemillis + 30000; actor->md.linkreason = sgt->md.ask; sendf(actor->clientnum, 1, "ri2", SV_HUDEXTRAS, HE_NUM+id); switch( actor->md.linkreason ) { // check demands case S_STAYHERE: actor->md.pos = sgt->state.o; addpt(sgt,REPLYPT); break; } } break; } } } void computeteamwork(int team, int exclude) // testing { loopv(clients) { client *actor = clients[i]; if ( i == exclude || actor->type == ST_EMPTY || actor->team != team || actor->state.state != CS_ALIVE || actor->md.linkmillis < gamemillis ) continue; vec position; bool teamworkdone = false; switch( actor->md.linkreason ) { case S_IMONDEFENSE: position = actor->spawnp; teamworkdone = true; break; case S_STAYTOGETHER: if ( valid_client(actor->md.linked) ) position = clients[actor->md.linked]->state.o; teamworkdone = true; break; case S_STAYHERE: position = actor->md.pos; teamworkdone = true; break; } if ( teamworkdone ) { float dist = POW2XY(actor->state.o,position); if (dist < COVERDIST) { addpt(actor,TWDONEPT); sendf(actor->clientnum, 1, "ri2", SV_HUDEXTRAS, HE_TEAMWORK); } } } } float a2c = 0, c2t = 0, a2t = 0; // distances: actor to covered, covered to target and actor to target inline bool testcover(int msg, int factor, client *actor) { if ( a2c < coverdist && c2t < coverdist && a2t < coverdist ) { sendf(actor->clientnum, 1, "ri2", SV_HUDEXTRAS, msg); addpt(actor, factor); actor->md.ncovers++; return true; } return false; } #define CALCCOVER(C) \ a2c = POW2XY(actor->state.o,C);\ c2t = POW2XY(C,target->state.o);\ a2t = POW2XY(actor->state.o,target->state.o) bool validlink(client *actor, int cn) { return actor->md.linked >= 0 && actor->md.linked == cn && gamemillis < actor->md.linkmillis && valid_client(actor->md.linked); } /** WIP */ void checkcover(client *target, client *actor) { int team = actor->team; int oteam = team_opposite(team); bool covered = false; int coverid = -1; int cnumber = totalclients < 13 ? totalclients : 12; if ( m_flags ) { sflaginfo &f = sflaginfos[team]; sflaginfo &of = sflaginfos[oteam]; if ( m_ctf ) { if ( f.state == CTFF_INBASE ) { CALCCOVER(f); if ( testcover(HE_FLAGDEFENDED, CTFLDEFPT, actor) ) print_medal_messages(actor,CTFLDEF); } if ( of.state == CTFF_STOLEN && actor->clientnum != of.actor_cn ) { covered = true; coverid = of.actor_cn; CALCCOVER(clients[of.actor_cn]->state.o); if ( testcover(HE_FLAGCOVERED, CTFLCOVPT, actor) ) print_medal_messages(actor,CTFLCOV); } } else if ( m_htf ) { if ( actor->clientnum != f.actor_cn ) { if ( f.state == CTFF_DROPPED ) { struct { short x, y; } nf; nf.x = f.pos[0]; nf.y = f.pos[1]; CALCCOVER(nf); if ( testcover(HE_FLAGDEFENDED, HTFLDEFPT, actor) ) print_medal_messages(actor,HTFLDEF); } if ( f.state == CTFF_STOLEN ) { covered = true; coverid = f.actor_cn; CALCCOVER(clients[f.actor_cn]->state.o); if ( testcover(HE_FLAGCOVERED, HTFLCOVPT, actor) ) print_medal_messages(actor,HTFLCOV); } } } } if ( !(covered && actor->md.linked==coverid) && validlink(actor,actor->md.linked) ) { CALCCOVER(clients[actor->md.linked]->state.o); if ( testcover(HE_COVER, COVERPT, actor) ) print_medal_messages(actor,COVER); } } #undef CALCCOVER /** WiP */ void checkfrag(client *target, client *actor, int gun, bool gib) { int targethasflag = clienthasflag(target->clientnum); int actorhasflag = clienthasflag(actor->clientnum); int cnumber = totalclients < 13 ? totalclients : 12; addpt(target,DEATHPT); if(target!=actor) { if(!isteam(target->team, actor->team)) { if (m_teammode) { if(!m_flags) addpt(actor, TMBONUSPT); else addpt(actor, FLBONUSPT); checkcover (target, actor); if ( m_htf && actorhasflag >= 0 ) addpt(actor, HTFFRAGPT); if ( m_ctf && targethasflag >= 0 ) { addpt(actor, CTFFRAGPT); } } else addpt(actor, BONUSPT); if (gib && gun != GUN_GRENADE) { if ( gun == GUN_SNIPER ) { addpt(actor, HEADSHOTPT); actor->md.nhs++; } else if ( gun == GUN_KNIFE ) addpt(actor, KNIFEPT); else if ( gun == GUN_SHOTGUN ) addpt(actor, SHOTGPT); } else addpt(actor, FRAGPT); if ( actor->md.combo ) { actor->md.combofrags++; addpt(actor,COMBOPT); actor->md.combosend = true; } } else { if ( targethasflag >= 0 ) addpt(actor, FLAGTKPT); else addpt(actor, TKPT); } } } int next_afk_check = 200; /* this function is managed to the PUBS, id est, many people playing in an open server */ void check_afk() { next_afk_check = servmillis + 7 * 1000; /* if we have few people (like 2x2), or it is not a teammode with the server not full: do nothing! */ if ( totalclients < 5 || ( totalclients < scl.maxclients && !m_teammode) ) return; loopv(clients) { client &c = *clients[i]; if ( c.type != ST_TCPIP || c.connectmillis + 60 * 1000 > servmillis || c.inputmillis + scl.afk_limit > servmillis || clienthasflag(c.clientnum) != -1 ) continue; if ( ( c.state.state == CS_DEAD && !m_arena && c.state.lastdeath + 45 * 1000 < gamemillis) || ( c.state.state == CS_ALIVE && c.upspawnp ) /*|| ( c.state.state == CS_SPECTATE && totalclients >= scl.maxclients ) // only kick spectator if server is full - 2011oct16:flowtron: mmh, that seems reasonable enough .. still, kicking spectators for inactivity seems harsh! disabled ATM, kick them manually if you must. */ ) { logline(ACLOG_INFO, "[%s] %s %s", c.hostname, c.name, "is afk"); defformatstring(msg)("%s is afk", c.name); sendservmsg(msg); disconnect_client(c.clientnum, DISC_AFK); } } } /** This function counts how much non-killing-damage the player does to any teammates The damage limit is 100 hp per minute, which is about 2 tks per minute in a normal game In normal games, the players go over 6 tks only in the worst cases */ void check_ffire(client *target, client *actor, int damage) { if ( mastermode != MM_OPEN ) return; actor->ffire += damage; if ( actor->ffire > 300 && actor->ffire * 600 > gamemillis) { logline(ACLOG_INFO, "[%s] %s %s", actor->hostname, actor->name, "kicked for excessive friendly fire"); defformatstring(msg)("%s %s", actor->name, "kicked for excessive friendly fire"); sendservmsg(msg); disconnect_client(actor->clientnum, DISC_FFIRE); } } inline int check_pdist(client *c, float & dist) // pick up distance { // ping 1000ms at max velocity can produce an error of 20 cubes float delay = 9.0f + (float)c->ping * 0.02f + (float)c->spj * 0.025f; // at pj/ping 40/100, delay = 12 if ( dist > delay ) { if ( dist < 1.5f * delay ) return 1; #ifdef ACAC pickup_checks(c,dist-delay); #endif return 2; } return 0; } /** If you read README.txt you must know that AC does not have cheat protection implemented. However this file is the sketch to a very special kind of cheat detection tools in server side. This is not based in program tricks, i.e., encryption, secret bytes, nor monitoring/scanning tools. The idea behind these cheat detections is to check (or reproduce) the client data, and verify if this data is expected or possible. Also, there is no need to check all clients all time, and one coding this kind of check must pay a special attention to the lag effect and how it can affect the data observed. This is not a trivial task, and probably it is the main reason why such tools were never implemented. This part is here for compatibility purposes. If you know nothing about these detections, please, just ignore it. */ inline void checkmove(client *cl) { cl->ldt = gamemillis - cl->lmillis; cl->lmillis = gamemillis; if ( cl->ldt < 40 ) cl->ldt = 40; cl->t += cl->ldt; cl->spj = (( 7 * cl->spj + cl->ldt ) >> 3); if ( cl->input != cl->f ) { cl->input = cl->f; cl->inputmillis = servmillis; } if(maplayout) checkclientpos(cl); #ifdef ACAC m_engine(cl); #endif if ( !cl->upspawnp ) { cl->spawnp = cl->state.o; cl->upspawnp = true; cl->spj = cl->ldt = 40; } return; } inline void checkshoot(int & cn, gameevent & shot, int & hits, int & tcn) { #ifdef ACAC s_engine(cn, shot, hits, tcn); #endif return; } inline void checkweapon(int & type, int & var) { #ifdef ACAC w_engine(type,var); #endif return; } bool validdamage(client *&target, client *&actor, int &damage, int &gun, bool &gib) { #ifdef ACAC if (!d_engine(target, actor, damage, gun, gib)) return false; #endif return true; } inline int checkmessage(client *c, int type) { #ifdef ACAC type = p_engine(c,type); #endif return type; } assaultcube-1.2.0.2.1/source/src/servercontroller.h000066400000000000000000000101231352165075300222020ustar00rootroot00000000000000// code for running the server as a background process/daemon/service struct servercontroller { virtual void start() = 0; virtual void keepalive() = 0; virtual void stop() = 0; virtual ~servercontroller() {} int argc; char **argv; }; #ifdef WIN32 struct winservice : servercontroller { SERVICE_STATUS_HANDLE statushandle; SERVICE_STATUS status; HANDLE stopevent; const char *name; winservice(const char *name) : name(name) { callbacks::svc = this; statushandle = 0; }; ~winservice() { if(status.dwCurrentState != SERVICE_STOPPED) stop(); callbacks::svc = NULL; } void start() // starts the server again on a new thread and returns once the windows service has stopped { SERVICE_TABLE_ENTRY dispatchtable[] = { { (LPSTR)name, (LPSERVICE_MAIN_FUNCTION)callbacks::main }, { NULL, NULL } }; if(StartServiceCtrlDispatcher(dispatchtable)) exit(EXIT_SUCCESS); else fatal("an error occurred running the AC server as windows service. make sure you start the server from the service control manager and not from the command line."); } void keepalive() { if(statushandle) { report(SERVICE_RUNNING, 0); handleevents(); } }; void stop() { if(statushandle) { report(SERVICE_STOP_PENDING, 0); if(stopevent) CloseHandle(stopevent); status.dwControlsAccepted &= ~(SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN); report(SERVICE_STOPPED, 0); } } void handleevents() { if(WaitForSingleObject(stopevent, 0) == WAIT_OBJECT_0) stop(); } void WINAPI requesthandler(DWORD ctrl) { switch(ctrl) { case SERVICE_CONTROL_STOP: report(SERVICE_STOP_PENDING, 0); SetEvent(stopevent); return; default: break; } report(status.dwCurrentState, 0); } void report(DWORD state, DWORD wait) { status.dwCurrentState = state; status.dwWaitHint = wait; status.dwWin32ExitCode = NO_ERROR; status.dwControlsAccepted = SERVICE_START_PENDING == state || SERVICE_STOP_PENDING == state ? 0 : SERVICE_ACCEPT_STOP; if(state == SERVICE_RUNNING || state == SERVICE_STOPPED) status.dwCheckPoint = 0; else status.dwCheckPoint++; SetServiceStatus(statushandle, &status); } int WINAPI svcmain() // new server thread's entry point { // fix working directory to make relative paths work if(argv && argv[0]) { string procpath; copystring(procpath, parentdir(argv[0])); copystring(procpath, parentdir(procpath)); SetCurrentDirectory((LPSTR)procpath); } statushandle = RegisterServiceCtrlHandler(name, (LPHANDLER_FUNCTION)callbacks::requesthandler); if(!statushandle) return EXIT_FAILURE; status.dwServiceType = SERVICE_WIN32_OWN_PROCESS; status.dwServiceSpecificExitCode = 0; report(SERVICE_START_PENDING, 3000); stopevent = CreateEvent(NULL, true, false, NULL); if(!stopevent) { stop(); return EXIT_FAILURE; } extern int main(int argc, char **argv); return main(argc, argv); } struct callbacks { static winservice *svc; static int WINAPI main() { return svc->svcmain(); }; static void WINAPI requesthandler(DWORD request) { svc->requesthandler(request); }; }; /*void log(const char *msg, bool error) { HANDLE eventsrc = RegisterEventSource(NULL, "AC Server"); if(eventsrc) { int eventid = ((error ? 0x11 : 0x1) << 10) & (0x1 << 9) & (FACILITY_NULL << 6) & 0x1; // TODO: create event definitions LPCTSTR msgs[1] = { msg }; int r = ReportEvent(eventsrc, error ? EVENTLOG_ERROR_TYPE : EVENTLOG_INFORMATION_TYPE, 0, 4, NULL, 1, 0, msgs, NULL); DeregisterEventSource(eventsrc); } }*/ }; winservice *winservice::callbacks::svc = (winservice *)NULL; #endif assaultcube-1.2.0.2.1/source/src/serverevents.h000066400000000000000000000157071352165075300213400ustar00rootroot00000000000000// processing of server events void processevent(client *c, explodeevent &e) { clientstate &gs = c->state; switch(e.gun) { case GUN_GRENADE: if(!gs.grenades.remove(e.id)) return; break; default: return; } for(int i = 1; ievents.length() && c->events[i].type==GE_HIT; i++) { hitevent &h = c->events[i].hit; if(!clients.inrange(h.target)) continue; client *target = clients[h.target]; if(target->type==ST_EMPTY || target->state.state!=CS_ALIVE || h.lifesequence!=target->state.lifesequence || h.dist<0 || h.dist>EXPDAMRAD) continue; int j = 1; for(j = 1; jevents[j].hit.target==h.target) break; if(jclientnum == target->clientnum; if(chk_gun && chk_dir && chk_dst && chk_cnr) damage = INT_MAX; // nade suicide serverdamage(target, c, damage, e.gun, true, h.dir); } } void processevent(client *c, shotevent &e) { clientstate &gs = c->state; int wait = e.millis - gs.lastshot; if(!gs.isalive(gamemillis) || !valid_weapon(e.gun) || waitgamemillis) gs.gunwait[e.gun] /= 2; sendf(-1, 1, "ri6x", SV_SHOTFX, c->clientnum, e.gun, // int(e.from[0]*DMF), int(e.from[1]*DMF), int(e.from[2]*DMF), int(e.to[0]*DMF), int(e.to[1]*DMF), int(e.to[2]*DMF), c->clientnum); gs.shotdamage += guns[e.gun].damage*(e.gun==GUN_SHOTGUN ? SGMAXDMGLOC : 1); // 2011jan17:ft: so accuracy stays correct, since SNIPER:headshot also "exceeds expectations" we use SGMAXDMGLOC instead of SGMAXDMGABS! switch(e.gun) { case GUN_GRENADE: gs.grenades.add(e.id); break; default: { int totalrays = 0, maxrays = e.gun==GUN_SHOTGUN ? 3*SGRAYS: 1; int tothits_c = 0, tothits_m = 0, tothits_o = 0; // sgrays for(int i = 1; ievents.length() && c->events[i].type==GE_HIT; i++) { hitevent &h = c->events[i].hit; if(!clients.inrange(h.target)) continue; client *target = clients[h.target]; if(target->type==ST_EMPTY || target->state.state!=CS_ALIVE || h.lifesequence!=target->state.lifesequence) continue; int rays = 1, damage = 0; bool gib = false; if(e.gun == GUN_SHOTGUN) { int bonusdist = h.info&0xFF; int numhits_c = (h.info & 0x0000FF00) >> 8, numhits_m = (h.info & 0x00FF0000) >> 16, numhits_o = (h.info & 0xFF000000) >> 24; tothits_c += numhits_c; tothits_m += numhits_m; tothits_o += numhits_o; rays = numhits_c + numhits_m + numhits_o; if(rays < 1 || tothits_c > SGRAYS || tothits_m > SGRAYS || tothits_o > SGRAYS || bonusdist > SGDMGBONUS) continue; gib = rays == maxrays; float fdamage = (SGDMGTOTAL/(21*100.0f)) * (numhits_o * SGCOdmg/10.0f + numhits_m * SGCMdmg/10.0f + numhits_c * SGCCdmg/10.0f); fdamage += (float)bonusdist; damage = (int)ceil(fdamage); #ifdef ACAC if (!sg_engine(target, c, numhits_c, numhits_m, numhits_o, bonusdist)) continue; #endif } else { damage = rays*guns[e.gun].damage; gib = e.gun == GUN_KNIFE; if(e.gun == GUN_SNIPER && h.info != 0) { gib = true; damage *= 3; } } totalrays += rays; if(totalrays>maxrays) continue; serverdamage(target, c, damage, e.gun, gib, h.dir); } break; } } } void processevent(client *c, suicideevent &e) { serverdamage(c, c, INT_MAX, GUN_KNIFE, false); } void processevent(client *c, pickupevent &e) { clientstate &gs = c->state; if(m_mp(gamemode) && !gs.isalive(gamemillis)) return; serverpickup(e.ent, c->clientnum); } void processevent(client *c, reloadevent &e) { clientstate &gs = c->state; if(!gs.isalive(gamemillis) || !valid_weapon(e.gun) || !reloadable_gun(e.gun) || gs.ammo[e.gun]<=0) return; if(e.gun == GUN_AKIMBO && gs.akimbomillis < gamemillis) return; bool akimbo = e.gun==GUN_PISTOL && gs.akimbomillis>e.millis; int mag = (akimbo ? 2 : 1) * magsize(e.gun), numbullets = min(gs.ammo[e.gun], mag - gs.mag[e.gun]); if(numbullets<=0) return; gs.mag[e.gun] += numbullets; gs.ammo[e.gun] -= numbullets; int wait = e.millis - gs.lastshot; sendf(-1, 1, "ri3", SV_RELOAD, c->clientnum, e.gun); if(gs.gunwait[e.gun] && waitstate; if(!gs.isalive(gamemillis) || gs.akimbomillis) return; gs.akimbomillis = e.millis+30000; } void clearevent(client *c) { int n = 1; while(nevents.length() && c->events[n].type==GE_HIT) n++; c->events.remove(0, n); } void processevents() { loopv(clients) { client *c = clients[i]; if(c->type==ST_EMPTY) continue; if(c->state.akimbomillis && c->state.akimbomillis < gamemillis) { c->state.akimbomillis = 0; c->state.akimbo = false; } while(c->events.length()) { gameevent &e = c->events[0]; if(e.typegamemillis) break; if(e.shot.millislastevent) { clearevent(c); continue; } c->lastevent = e.shot.millis; } switch(e.type) { case GE_SHOT: processevent(c, e.shot); break; case GE_EXPLODE: processevent(c, e.explode); break; case GE_AKIMBO: processevent(c, e.akimbo); break; case GE_RELOAD: processevent(c, e.reload); break; // untimed events case GE_SUICIDE: processevent(c, e.suicide); break; case GE_PICKUP: processevent(c, e.pickup); break; } clearevent(c); } } } assaultcube-1.2.0.2.1/source/src/serverfiles.h000066400000000000000000001515501352165075300211330ustar00rootroot00000000000000// serverfiles.h // map management #define SERVERMAXMAPFACTOR 10 // 10 is huge... if you're running low on RAM, consider 9 as maximum (don't go higher than 10, or players will name their ugly dog after you) #define SERVERMAP_PATH_BUILTIN "packages" PATHDIVS "maps" PATHDIVS "official" PATHDIVS #define SERVERMAP_PATH "packages" PATHDIVS "maps" PATHDIVS "servermaps" PATHDIVS #define SERVERMAP_PATH_INCOMING "packages" PATHDIVS "maps" PATHDIVS "servermaps" PATHDIVS "incoming" PATHDIVS const char *servermappath_off = SERVERMAP_PATH_BUILTIN; const char *servermappath_serv = SERVERMAP_PATH; const char *servermappath_incom = SERVERMAP_PATH_INCOMING; #define GZBUFSIZE ((MAXCFGFILESIZE * 11) / 10) #define FLOORPLANBUFSIZE (sizeof(struct servsqr) << ((SERVERMAXMAPFACTOR) * 2)) // that's 4MB for size 10 maps (or 1 MB for size 9 maps) stream *readmaplog = NULL; // the readmaps thread always logs directly to file struct servermap // in-memory version of a map file on a server { const char *fname, *fpath; // map name and path (fname has to be first member of this struct! hardcoded!) uchar *cgzraw, *cfgrawgz; // direct copies of the cgz and cfg files (cfg is already gzipped) uchar cgzhash[TIGERHASHSIZE], cfghash[TIGERHASHSIZE]; int cgzlen, cfglen, cfggzlen; // file lengths and cfg-gz length int version, headersize, sfactor, numents, maprevision, waterlevel; // from map header uchar *layoutgz; // gzipped precompiled floorplan int layoutlen, layoutgzlen; mapdim_s mapdims; entitystats_s entstats; mapareastats_s areastats; int x1, x2, y1, y2, zmin, zmax; // bounding box for player-reachable areas uchar *enttypes; // table of entity types short *entpos_x, *entpos_y; bool isok; // definitive flag! #ifdef _DEBUG char maptitle[129]; #endif servermap(const char *mname, const char *mpath) { memset(&fname, 0, sizeof(struct servermap)); fname = newstring(mname); fpath = mpath; } ~servermap() { delstring(fname); DELETEA(cgzraw); DELETEA(cfgrawgz); DELETEA(enttypes); DELETEA(entpos_x); DELETEA(entpos_y); DELETEA(layoutgz); } bool isro() { return fpath == servermappath_off || fpath == servermappath_serv; } bool isofficial() { return fpath == servermappath_off; } int getmemusage() { return sizeof(struct servermap) + cgzlen + cfggzlen + layoutgzlen + numents * (sizeof(uchar) + sizeof(short) * 3); } void load(void) // load map into memory and extract everything important about it (assumes struct to be zeroed: can only be called once) { static uchar *staticbuffer = NULL; if(!staticbuffer) staticbuffer = new uchar[FLOORPLANBUFSIZE]; // this buffer gets reused for every map load several times (also: because of this, load() is not thread safe) const char *err = NULL; stream *f = NULL; int restofhead; // load map files, prepare sendmap buffer defformatstring(filename)("%s%s.cfg", fpath, fname); path(filename); uchar *cfgraw = (uchar *)loadfile(filename, &cfglen); if(cfgraw) { tigerhash(cfghash, cfgraw, cfglen); loopk(cfglen) if(cfgraw[k] > 0x7f || (cfgraw[k] < 0x20 && !isspace(cfgraw[k]))) err = "illegal chars in cfg file"; } formatstring(filename)("%s%s.cgz", fpath, fname); path(filename); cgzraw = (uchar *)loadfile(filename, &cgzlen); if(cgzraw) tigerhash(cgzhash, cgzraw, cgzlen); if(!cgzraw) err = "loading cgz failed"; else if(cfglen > MAXCFGFILESIZE) err = "cfg file too big"; else if(cgzlen >= MAXMAPSENDSIZE) err = "cgz file too big"; else if(cfgraw) { uLongf gzbufsize = GZBUFSIZE; ASSERT(GZBUFSIZE < FLOORPLANBUFSIZE); if(compress2(staticbuffer, &gzbufsize, cfgraw, cfglen, 9) != Z_OK) gzbufsize = 0; cfggzlen = (int) gzbufsize; if(cgzlen + cfggzlen < MAXMAPSENDSIZE) { // map is small enough to be sent cfgrawgz = new uchar[cfggzlen]; memcpy(cfgrawgz, staticbuffer, cfggzlen); } else err = "cgz + cfg.gz too big to send"; } DELETEA(cfgraw); if(err) goto loadfailed; // extract entity data and header info; compile map statistics; create floorplan { const int sizeof_header = sizeof(header), sizeof_baseheader = sizeof(header) - sizeof(int) * 16; f = opengzfile(filename, "rb"); header *h = (header *)staticbuffer; if(!f) err = "can't open map file"; else if(f->read(h, sizeof_baseheader) != sizeof_baseheader || (strncmp(h->head, "CUBE", 4) && strncmp(h->head, "ACMP",4))) err = "bad map file"; if(err) goto loadfailed; lilswap(&h->version, 4); // version, headersize, sfactor, numents version = h->version; headersize = fixmapheadersize(h->version, h->headersize); sfactor = h->sfactor; numents = h->numents; #ifdef _DEBUG memcpy(maptitle, h->maptitle, 128); #endif restofhead = min(headersize, sizeof_header) - sizeof_baseheader; ASSERT(SERVERMAXMAPFACTOR <= LARGEST_FACTOR); if(version > MAPVERSION || numents > MAXENTITIES || sfactor < SMALLEST_FACTOR || sfactor > SERVERMAXMAPFACTOR || f->read(&h->waterlevel, restofhead) != restofhead) err = "incompatible map file"; else { lilswap(&h->maprevision, 4); // maprevision, ambient, flags, timestamp maprevision = h->maprevision; lilswap(&h->waterlevel, 1); waterlevel = version >= 4 ? h->waterlevel : -100000; restofhead = clamp(headersize - sizeof_header, 0, MAXHEADEREXTRA); if(f->read(staticbuffer, restofhead) != restofhead) err = "map file truncated"; } } if(err) goto loadfailed; // parse header extras { ucharbuf p(staticbuffer, restofhead); while(1) { int len = getuint(p), flags = getuint(p), type = flags & HX_TYPEMASK; if(p.overread() || len > p.remaining()) break; ucharbuf q(p.subbuf(len).buf, len); switch(type) { case HX_EDITUNDO: break; case HX_CONFIG: break; case HX_MAPINFO: case HX_MODEINFO: // for new maprot... case HX_ARTIST: default: break; } } } if(err) goto loadfailed; // read and convert map entities { bool oldentityformat = version < 10; // version < 10 have only 4 attributes and no scaling ASSERT(MAXENTITIES * sizeof(persistent_entity) < FLOORPLANBUFSIZE); persistent_entity *es = (persistent_entity *) staticbuffer; loopi(numents) { persistent_entity &e = es[i]; f->read(&e, oldentityformat ? 12 : sizeof(persistent_entity)); lilswap((short *)&e, 4); if(oldentityformat) e.attr5 = e.attr6 = e.attr7 = 0; else lilswap(&e.attr5, 1); #if 0 if(e.type == LIGHT && e.attr1 >= 0) { if(!e.attr2) e.attr2 = 255; if(e.attr1 > 32) e.attr1 = 32; } #endif transformoldentitytypes(version, e.type); if(oldentityformat && e.type < MAXENTTYPES) { if(e.type == CTF_FLAG || e.type == MAPMODEL) e.attr1 = e.attr1 + 7 - (e.attr1 + 7) % 15; // round the angle to the nearest 15-degree-step, like old versions did during rendering if(e.type == LIGHT && e.attr1 < 0) e.attr1 = 0; // negative lights had no meaning before version 10 int ov, ss; #define SCALEATTR(x) \ if((ss = abs(entwraparound[e.type][x - 1] / entscale[e.type][x - 1]))) e.attr##x = (int(e.attr##x) % ss + ss) % ss; \ e.attr##x = ov = e.attr##x * entscale[e.type][x - 1]; \ if(ov != e.attr##x) err = "overflow during conversion of entity attribute"; SCALEATTR(1); SCALEATTR(2); SCALEATTR(3); SCALEATTR(4); #undef SCALEATTR } } } if(err) goto loadfailed; // convert and count entities for server use { persistent_entity *es = (persistent_entity *) staticbuffer; calcentitystats(entstats, es, numents); enttypes = new uchar[numents]; // FIXME: cut this down to useful entities entpos_x = new short[numents]; entpos_y = new short[numents]; loopi(numents) { persistent_entity &e = es[i]; enttypes[i] = e.type >= MAXENTTYPES ? NOTUSED : e.type; entpos_x[i] = e.x; entpos_y[i] = e.y; } } if(err) goto loadfailed; // read full map geometry (without textures) { layoutlen = 1 << (sfactor * 2); servsqr *ss = (servsqr *)staticbuffer, *tt = NULL, *ee = ss + layoutlen; while(ss < ee && !err) { int type = f->getchar(), n; if(!tt && type > MAXTYPE) err = "map file broken"; else switch(type) { case -1: err = "while reading map: unexpected eof"; break; case 255: n = f->getchar(); loopi(n) memcpy(ss++, tt, sizeof(servsqr)); ss--; break; case 254: // only in MAPVERSION<=2 memcpy(ss, tt, sizeof(servsqr)); f->getchar(); f->getchar(); break; case SOLID: ss->type = SOLID; f->getchar(); ss->vdelta = f->getchar(); if(version <= 2) { f->getchar(); f->getchar(); } break; case 253: // SOLID with all textures during editing (undo) err = "unoptimised map file not allowed on server"; break; default: if(type < 0 || type >= MAXTYPE) err = "illegal type"; else { ASSERT((int)MAXTYPE < (int)TAGTRIGGERMASK); ss->type = type; ss->floor = f->getchar(); ss->ceil = f->getchar(); if(ss->floor >= ss->ceil) ss->floor = ss->ceil - 1; // for pre 12_13 f->getchar(); f->getchar(); f->getchar(); if(version <= 2) { f->getchar(); f->getchar(); } ss->vdelta = f->getchar(); if(version >= 2) f->getchar(); if(version >= 5) ss->type |= TAGANYCLIP & f->getchar(); } break; } tt = ss; ss++; } } if(err) goto loadfailed; // collect geometry stats (exactly the same as calculated by the client) { if(calcmapdims(mapdims, (servsqr *)staticbuffer, 1 << sfactor) < 0) err = "world geometry error"; } if(err) goto loadfailed; // merge vdelta into floor & ceil { servsqr *ss = (servsqr *)staticbuffer; int linelen = 1 << sfactor, linegap = linelen - mapdims.xspan; ss += linelen * mapdims.y1 + mapdims.x1; for(int j = mapdims.yspan; j > 0; j--, ss += linegap) loopirev(mapdims.xspan) { int type = ss->type & TAGTRIGGERMASK; if(type == FHF || type == CHF) { int diff = (ss->vdelta + ss[1].vdelta + ss[linelen].vdelta + ss[linelen + 1].vdelta + 15) / 16; // round up to full cubes if(type == FHF) ss->floor = max(-128, ss->floor - diff); else ss->ceil = min(127, ss->ceil + diff); } ss++; } } if(err) goto loadfailed; // run mipmapper (to get corners right) // calculate area statistics from type & vdelta values (destroys vdelta!) { if(calcmapareastats(areastats, (servsqr *)staticbuffer, 1 << sfactor, mapdims) < 0) err = "world layout malformed"; // should be a quite fringe error } if(err) goto loadfailed; // work "player accessibility" into the floorplan, calculate map bounding box for player-accessible areas only { servsqr *ss = (servsqr *)staticbuffer; int linelen = 1 << sfactor, linegap = linelen - mapdims.xspan; ss += linelen * mapdims.y1 + mapdims.x1; x1 = y1 = linelen; zmin = 127; zmax = -128; for(int j = 0; j < mapdims.yspan; j++, ss += linegap) loopi(mapdims.xspan) { if((ss->type & TAGANYCLIP) > 0 || ss->ceil - ss->floor < 5) ss->type = SOLID; // treat any cube that is not accessible to a player as SOLID if(!SOLID(ss)) { if(i < x1) x1 = i; if(i > x2) x2 = i; if(j < y1) y1 = j; if(j > y2) y2 = j; if(ss->floor < zmin) zmin = ss->floor; if(ss->ceil > zmax) zmax = ss->ceil; } ss++; } x1 += mapdims.x1; x2 += mapdims.x1; y1 += mapdims.y1; y2 += mapdims.y1; if(x2 - x1 < 10 || y2 - y1 < 10 || zmax - zmin < 10) err = "world layout unplayable"; x1 -= 2; x2 += 2; y1 -= 2; y2 += 2; // make sure, the bounding box is big enough } if(err) goto loadfailed; // create compact floorplan { char *layout = (char *)staticbuffer; servsqr *ss = (servsqr *)staticbuffer; loopirev(layoutlen) { switch(ss->type & TAGTRIGGERMASK) { case SOLID: *layout = 127; break; case CORNER: *layout = zmin; break; // basically: ignore corner areas (otherwise, we'd need a mipmapper to sort it out properly), maybe, this should be fixed at some point... default: *layout = ss->floor; break; } layout++; ss++; } ASSERT(layoutlen * 3 <= (int)FLOORPLANBUFSIZE); uLongf gzbufsize = layoutlen * 2; // valid for sizeof(struct servsqr) >= 3 if(compress2(staticbuffer + layoutlen, &gzbufsize, staticbuffer, layoutlen, 9) != Z_OK) gzbufsize = 0; layoutgzlen = (int) gzbufsize; if(layoutgzlen > 0 && layoutgzlen < layoutlen) { // gzipping went well -> keep it layoutgz = new uchar[layoutgzlen]; memcpy(layoutgz, staticbuffer + layoutlen, layoutgzlen); } else err = "gzipping the floorplan failed"; } loadfailed: DELETEP(f); if(err) { // fail if(readmaplog) readmaplog->printf("reading map '%s%s' failed: %s.\n", fpath, fname, err); } else { // success if(readmaplog) readmaplog->printf("read map '%s%s': cgz %d bytes, cfg %d bytes (%d gz), version %d, size %d, rev %d, " "ents %d, x %d:%d, y %d:%d, z %d:%d, layout %d bytes, spawns %d:%d:%d, flags %d:%d\n", fpath, fname, cgzlen, cfglen, cfggzlen, version, sfactor, maprevision, numents, x1, x2, y1, y2, zmin, zmax, layoutgzlen, entstats.spawns[0], entstats.spawns[1], entstats.spawns[2], entstats.flags[0], entstats.flags[1]); isok = true; } } }; // data structures to sync data flow between main thread and readmapsthread volatile servermap *servermapdropbox = NULL; // changed servermap entry back to the main thread volatile bool startnewservermapsepoch = false; // signal readmapsthread to start an new full search sl_semaphore *readmapsthread_sem = NULL; // sync readmapsthread with main thread // readmapsthread // // * checks all servermaps directories for map files, prioritises and reads them all into memory // * compiles floorplans for every map and keeps them in memory (gzipped) // * fetches extended attributes from the map header // * basically extracts everything from the map file, that the server needs to run a game on it // (may take a while, but we're not in a hurry) // // the thread processes one map at a time and waits for the main thread to store and enlist the findings // struct mapfilename { const char *fname, *fpath; int cgzlen, cfglen, epoch; }; // for tracking map/cfg file (-size) changes vector mapfilenames; // this list only grows void updateservermap(int index, bool deletethis) { mapfilename &m = mapfilenames[index]; servermap *sm = new servermap(m.fname, m.fpath); if(!deletethis) sm->load(); if(sm->isok) { m.cgzlen = sm->cgzlen; m.cfglen = sm->cfglen; } else m.cgzlen = m.cfglen = 0; // pipe sm to main thread.... // we're handing a pointer to a new servermap to the main thread (who manages the array for all servermaps) // if the new servermap is not loaded properly, that's the signal for the main thread to delete the entry from the array while(servermapdropbox) readmapsthread_sem->wait(); // wait for the main thread to process the last sent servermap servermapdropbox = sm; } int getmapfilenameindex(const char *fname, const char *fpath) { loopv(mapfilenames) if(fpath == mapfilenames[i].fpath && !strcmp(fname, mapfilenames[i].fname)) return i; return -1; } void trymapfiles(const char *fpath, const char *fname, int epoch) //check, if map files were added or altered (detecting alteration requires filesizes to be changed as well, as usual) { bool updatethis = false; int mapfileindex = getmapfilenameindex(fname, fpath); if(mapfileindex < 0) { // new map file mapfileindex = mapfilenames.length(); mapfilename &m = mapfilenames.add(); m.fname = newstring(fname); m.fpath = fpath; m.cgzlen = m.cfglen = 0; m.epoch = epoch; updatethis = true; } else { defformatstring(fcgz)("%s%s.cgz", fpath, fname); defformatstring(fcfg)("%s%s.cfg", fpath, fname); if(mapfilenames[mapfileindex].cgzlen != getfilesize(path(fcgz)) || mapfilenames[mapfileindex].cfglen != getfilesize(path(fcfg))) { updatethis = true; // changed filesize detected } } if(updatethis) updateservermap(mapfileindex, false); } void tagmapfile(const char *fpath, const char *fname, int epoch) // tag list entry, if file (+path) is already in it { int mapfileindex = getmapfilenameindex(fname, fpath); if(mapfileindex >= 0) mapfilenames[mapfileindex].epoch = epoch; } int readmapsthread(void *logfileprefix) { static int readmaps_epoch = 0; while(1) { while(!startnewservermapsepoch) readmapsthread_sem->wait(); // wait without using the cpu if(logfileprefix) { defformatstring(logfilename)("%sreadmaps_log.txt", (const char *)logfileprefix); path(logfilename); readmaplog = openfile(logfilename, "a"); } vector maps_off, maps_serv, maps_incom; // get all map file names listfiles(servermappath_off, "cgz", maps_off, stringsort); listfiles(servermappath_serv, "cgz", maps_serv, stringsort); listfiles(servermappath_incom, "cgz", maps_incom, stringsort); if(readmaplog) readmaplog->printf("\n#### %s #### scanning all map directories... found %d official maps, %d servermaps and %d maps in 'incoming'\n", timestring(false), maps_off.length(), maps_serv.length(), maps_incom.length()); // enforce priority: official > servermaps > incoming // (every map name is only allowed once among the paths) loopv(maps_off) { loopvjrev(maps_serv) if(!strcmp(maps_off[i], maps_serv[j])) delstring(maps_serv.remove(j)); loopvjrev(maps_incom) if(!strcmp(maps_off[i], maps_incom[j])) delstring(maps_incom.remove(j)); } loopv(maps_serv) { loopvjrev(maps_incom) if(!strcmp(maps_serv[i], maps_incom[j])) delstring(maps_incom.remove(j)); } int lastepoch = readmaps_epoch; readmaps_epoch++; // tag all files in the list that we have found again in this round by giving it the new epoch number loopv(maps_off) tagmapfile(servermappath_off, maps_off[i], readmaps_epoch); loopv(maps_serv) tagmapfile(servermappath_serv, maps_serv[i], readmaps_epoch); loopv(maps_incom) tagmapfile(servermappath_incom, maps_incom[i], readmaps_epoch); // signal deletion of all files in the list that are no longer found to the main thread loopvrev(mapfilenames) if(mapfilenames[i].epoch == lastepoch) updateservermap(i, true); // process all currently available files: load new or changed files and pass them to the main thread loopv(maps_off) trymapfiles(servermappath_off, maps_off[i], readmaps_epoch); loopv(maps_serv) trymapfiles(servermappath_serv, maps_serv[i], readmaps_epoch); loopv(maps_incom) trymapfiles(servermappath_incom, maps_incom[i], readmaps_epoch); DELETEP(readmaplog); // always close the logfile when done, so we can create a new one, if someone removed or renamed the old one startnewservermapsepoch = false; } return 0; } struct servermapbuffer // sending of maps between clients { string mapname; int cgzsize, cfgsize, cfgsizegz, revision, datasize; uchar *data, *gzbuf; servermapbuffer() : data(NULL) { gzbuf = new uchar[GZBUFSIZE]; } ~servermapbuffer() { delete[] gzbuf; } void clear() { DELETEA(data); revision = 0; } int available() { if(data && !strcmp(mapname, behindpath(smapname)) && cgzsize == smapstats.cgzsize) { if( !revision || (revision == smapstats.hdr.maprevision)) return cgzsize; } return 0; } void setrevision() { if(available() && !revision) revision = smapstats.hdr.maprevision; } void load(void) // load currently played map into the buffer (if distributable), clear buffer otherwise { string cgzname, cfgname; const char *name = behindpath(smapname); // no paths allowed here clear(); formatstring(cgzname)(SERVERMAP_PATH "%s.cgz", name); path(cgzname); if(fileexists(cgzname, "r")) { formatstring(cfgname)(SERVERMAP_PATH "%s.cfg", name); } else { formatstring(cgzname)(SERVERMAP_PATH_INCOMING "%s.cgz", name); path(cgzname); formatstring(cfgname)(SERVERMAP_PATH_INCOMING "%s.cfg", name); } path(cfgname); uchar *cgzdata = (uchar *)loadfile(cgzname, &cgzsize); uchar *cfgdata = (uchar *)loadfile(cfgname, &cfgsize); if(cgzdata && (!cfgdata || cfgsize < MAXCFGFILESIZE)) { uLongf gzbufsize = GZBUFSIZE; if(!cfgdata || compress2(gzbuf, &gzbufsize, cfgdata, cfgsize, 9) != Z_OK) { cfgsize = 0; gzbufsize = 0; } cfgsizegz = (int) gzbufsize; if(cgzsize + cfgsizegz < MAXMAPSENDSIZE) { // map is ok, fill buffer copystring(mapname, name); datasize = cgzsize + cfgsizegz; data = new uchar[datasize]; memcpy(data, cgzdata, cgzsize); memcpy(data + cgzsize, gzbuf, cfgsizegz); logline(ACLOG_INFO,"loaded map %s, %d + %d(%d) bytes.", cgzname, cgzsize, cfgsize, cfgsizegz); } } DELETEA(cgzdata); DELETEA(cfgdata); } bool sendmap(const char *nmapname, int nmapsize, int ncfgsize, int ncfgsizegz, uchar *ndata) { FILE *fp; bool written = false; if(!nmapname[0] || nmapsize <= 0 || ncfgsizegz < 0 || nmapsize + ncfgsizegz > MAXMAPSENDSIZE || ncfgsize > MAXCFGFILESIZE) return false; // malformed: probably modded client int cfgsize = ncfgsize; if(smode == GMODE_COOPEDIT && !strcmp(nmapname, behindpath(smapname))) { // update mapbuffer only in coopedit mode (and on same map) copystring(mapname, nmapname); datasize = nmapsize + ncfgsizegz; revision = 0; DELETEA(data); data = new uchar[datasize]; memcpy(data, ndata, datasize); } defformatstring(name)(SERVERMAP_PATH_INCOMING "%s.cgz", nmapname); path(name); fp = fopen(name, "wb"); if(fp) { fwrite(ndata, 1, nmapsize, fp); fclose(fp); formatstring(name)(SERVERMAP_PATH_INCOMING "%s.cfg", nmapname); path(name); fp = fopen(name, "wb"); if(fp) { uLongf rawsize = ncfgsize; if(uncompress(gzbuf, &rawsize, ndata + nmapsize, ncfgsizegz) == Z_OK && rawsize - ncfgsize == 0) fwrite(gzbuf, 1, cfgsize, fp); fclose(fp); written = true; } } return written; } void sendmap(client *cl, int chan) { if(!available()) return; packetbuf p(MAXTRANS + datasize, ENET_PACKET_FLAG_RELIABLE); putint(p, SV_RECVMAP); sendstring(mapname, p); putint(p, cgzsize); putint(p, cfgsize); putint(p, cfgsizegz); putint(p, revision); p.put(data, datasize); sendpacket(cl->clientnum, chan, p.finalize()); } }; // provide maps by the server enum { MAP_NOTFOUND = 0, MAP_TEMP, MAP_CUSTOM, MAP_LOCAL, MAP_OFFICIAL, MAP_VOID }; static const char * const maplocstr[] = { "not found", "temporary", "custom", "local", "official", "void" }; #define readonlymap(x) ((x) >= MAP_CUSTOM) #define distributablemap(x) ((x) == MAP_TEMP || (x) == MAP_CUSTOM) int findmappath(const char *mapname, char *filename) { if(!mapname[0]) return MAP_NOTFOUND; string tempname; if(!filename) filename = tempname; const char *name = behindpath(mapname); formatstring(filename)(SERVERMAP_PATH_BUILTIN "%s.cgz", name); path(filename); int loc = MAP_NOTFOUND; if(getfilesize(filename) > 10) loc = MAP_OFFICIAL; else { #ifndef STANDALONE copystring(filename, setnames(name)); if(!isdedicated && getfilesize(filename) > 10) loc = MAP_LOCAL; else { #endif formatstring(filename)(SERVERMAP_PATH "%s.cgz", name); path(filename); if(isdedicated && getfilesize(filename) > 10) loc = MAP_CUSTOM; else { formatstring(filename)(SERVERMAP_PATH_INCOMING "%s.cgz", name); path(filename); if(isdedicated && getfilesize(filename) > 10) loc = MAP_TEMP; } #ifndef STANDALONE } #endif } return loc; } mapstats *getservermapstats(const char *mapname, bool getlayout, int *maploc) { string filename; int ml; if(!maploc) maploc = &ml; *maploc = findmappath(mapname, filename); if(getlayout) DELETEA(maplayout); return *maploc == MAP_NOTFOUND ? NULL : loadmapstats(filename, getlayout); } // server config files void serverconfigfile::init(const char *name) { copystring(filename, name); path(filename); read(); } bool serverconfigfile::load() { DELETEA(buf); buf = loadfile(filename, &filelen); if(!buf) { logline(ACLOG_INFO,"could not read config file '%s'", filename); return false; } char *p; if('\r' != '\n') // this is not a joke! { char c = strchr(buf, '\n') ? ' ' : '\n'; // in files without /n substitute /r with /n, otherwise remove /r for(p = buf; (p = strchr(p, '\r')); p++) *p = c; } for(p = buf; (p = strstr(p, "//")); ) // remove comments { while(*p != '\n' && *p != '\0') p++[0] = ' '; } for(p = buf; (p = strchr(p, '\t')); p++) *p = ' '; for(p = buf; (p = strchr(p, '\n')); p++) *p = '\0'; // one string per line return true; } // maprot.cfg #define CONFIG_MAXPAR 6 struct configset { string mapname; union { struct { int mode, time, vote, minplayer, maxplayer, skiplines; }; int par[CONFIG_MAXPAR]; }; }; int FlagFlag = MINFF * 1000; int Mvolume, Marea, SHhits, Mopen = 0; float Mheight = 0; bool mapisok(mapstats *ms) { if ( Mheight > MAXMHEIGHT ) { logline(ACLOG_INFO, "MAP CHECK FAIL: The overall ceil height is too high (%.1f cubes)", Mheight); return false; } if ( Mopen > MAXMAREA ) { logline(ACLOG_INFO, "MAP CHECK FAIL: There is a big open area in this (hint: use more solid walls)"); return false; } if ( SHhits > MAXHHITS ) { logline(ACLOG_INFO, "MAP CHECK FAIL: Too high height in some parts of the map (%d hits)", SHhits); return false; } if ( ms->hasflags ) // Check if flags are ok { struct { short x, y; } fl[2]; loopi(2) { if(ms->flags[i] == 1) { short *fe = ms->entposs + ms->flagents[i] * 3; fl[i].x = *fe; fe++; fl[i].y = *fe; } else fl[i].x = fl[i].y = 0; // the map has no valid flags } FlagFlag = pow2(fl[0].x - fl[1].x) + pow2(fl[0].y - fl[1].y); } else FlagFlag = MINFF * 1000; // the map has no flags if ( FlagFlag < MINFF ) { logline(ACLOG_INFO, "MAP CHECK FAIL: The flags are too close to each other"); return false; } for (int i = 0; i < ms->hdr.numents; i++) { int v = ms->enttypes[i]; if (v < I_CLIPS || v > I_AKIMBO) continue; short *p = &ms->entposs[i*3]; float density = 0, hdensity = 0; for(int j = 0; j < ms->hdr.numents; j++) { int w = ms->enttypes[j]; if (w < I_CLIPS || w > I_AKIMBO || i == j) continue; short *q = &ms->entposs[j*3]; float r2 = 0; loopk(3){ r2 += (p[k]-q[k])*(p[k]-q[k]); } if ( r2 == 0.0f ) { logline(ACLOG_INFO, "MAP CHECK FAIL: Items too close %s %s (%hd,%hd)", entnames[v], entnames[w],p[0],p[1]); return false; } r2 = 1/r2; if (r2 < 0.0025f) continue; if (w != v) { hdensity += r2; continue; } density += r2; } /* if (hdensity > 0.0f) { logline(ACLOG_INFO, "ITEM CHECK H %s %f", entnames[v], hdensity); } if (density > 0.0f) { logline(ACLOG_INFO, "ITEM CHECK D %s %f", entnames[v], density); }*/ if ( hdensity > 0.5f ) { logline(ACLOG_INFO, "MAP CHECK FAIL: Items too close %s %.2f (%hd,%hd)", entnames[v],hdensity,p[0],p[1]); return false; } switch(v) { #define LOGTHISSWITCH(X) if( density > X ) { logline(ACLOG_INFO, "MAP CHECK FAIL: Items too close %s %.2f (%hd,%hd)", entnames[v],density,p[0],p[1]); return false; } case I_CLIPS: case I_HEALTH: LOGTHISSWITCH(0.24f); break; case I_AMMO: LOGTHISSWITCH(0.04f); break; case I_HELMET: LOGTHISSWITCH(0.02f); break; case I_ARMOUR: case I_GRENADE: case I_AKIMBO: LOGTHISSWITCH(0.005f); break; default: break; #undef LOGTHISSWITCH } } return true; } struct servermaprot : serverconfigfile { vector configsets; int curcfgset; servermaprot() : curcfgset(-1) {} void read() { if(getfilesize(filename) == filelen) return; configsets.shrink(0); if(!load()) return; const char *sep = ": "; configset c; int i, line = 0; char *b, *l, *p = buf; logline(ACLOG_VERBOSE,"reading map rotation '%s'", filename); while(p < buf + filelen) { l = p; p += strlen(p) + 1; line++; l = strtok_r(l, sep, &b); if(l) { copystring(c.mapname, behindpath(l)); for(i = 3; i < CONFIG_MAXPAR; i++) c.par[i] = 0; // default values for(i = 0; i < CONFIG_MAXPAR; i++) { if((l = strtok_r(NULL, sep, &b)) != NULL) c.par[i] = atoi(l); else break; } if(i > 2) { configsets.add(c); logline(ACLOG_VERBOSE," %s, %s, %d minutes, vote:%d, minplayer:%d, maxplayer:%d, skiplines:%d", c.mapname, modestr(c.mode, false), c.time, c.vote, c.minplayer, c.maxplayer, c.skiplines); } else logline(ACLOG_INFO," error in line %d, file %s", line, filename); } } DELETEA(buf); logline(ACLOG_INFO,"read %d map rotation entries from '%s'", configsets.length(), filename); return; } int next(bool notify = true, bool nochange = false) // load next maprotation set { #ifndef STANDALONE if(!isdedicated) { defformatstring(nextmapalias)("nextmap_%s", getclientmap()); const char *map = getalias(nextmapalias); // look up map in the cycle startgame(map && notify ? map : getclientmap(), getclientmode(), -1, notify); return -1; } #endif if(configsets.empty()) fatal("maprot unavailable"); int n = numclients(); int csl = configsets.length(); int ccs = curcfgset; if(ccs >= 0 && ccs < csl) ccs += configsets[ccs].skiplines; configset *c = NULL; loopi(3 * csl + 1) { ccs++; if(ccs >= csl || ccs < 0) ccs = 0; c = &configsets[ccs]; if((n >= c->minplayer || i >= csl) && (!c->maxplayer || n <= c->maxplayer || i >= 2 * csl)) { mapstats *ms = NULL; if((ms = getservermapstats(c->mapname)) && mapisok(ms)) break; else logline(ACLOG_INFO, "maprot error: map '%s' %s", c->mapname, (ms ? "does not satisfy some basic requirements" : "not found")); } if(i >= 3 * csl) fatal("maprot unusable"); // not a single map in rotation can be found... } if(!nochange) { curcfgset = ccs; startgame(c->mapname, c->mode, c->time, notify); } return ccs; } void restart(bool notify = true) // restart current map { #ifndef STANDALONE if(!isdedicated) { startgame(getclientmap(), getclientmode(), -1, notify); return; } #endif startgame(smapname, smode, -1, notify); } configset *current() { return configsets.inrange(curcfgset) ? &configsets[curcfgset] : NULL; } configset *get(int ccs) { return configsets.inrange(ccs) ? &configsets[ccs] : NULL; } }; // serverblacklist.cfg struct serveripblacklist : serverconfigfile { vector ipranges; void read() { if(getfilesize(filename) == filelen) return; ipranges.shrink(0); if(!load()) return; iprange ir; int line = 0, errors = 0; char *l, *r, *p = buf; logline(ACLOG_VERBOSE,"reading ip blacklist '%s'", filename); while(p < buf + filelen) { l = p; p += strlen(p) + 1; line++; if((r = (char *) atoipr(l, &ir))) { ipranges.add(ir); l = r; } if(l[strspn(l, " ")]) { for(int i = (int)strlen(l) - 1; i > 0 && l[i] == ' '; i--) l[i] = '\0'; logline(ACLOG_INFO," error in line %d, file %s: ignored '%s'", line, filename, l); errors++; } } DELETEA(buf); ipranges.sort(cmpiprange); int orglength = ipranges.length(); loopv(ipranges) { if(!i) continue; if(ipranges[i].ur <= ipranges[i - 1].ur) { if(ipranges[i].lr == ipranges[i - 1].lr && ipranges[i].ur == ipranges[i - 1].ur) logline(ACLOG_VERBOSE," blacklist entry %s got dropped (double entry)", iprtoa(ipranges[i])); else logline(ACLOG_VERBOSE," blacklist entry %s got dropped (already covered by %s)", iprtoa(ipranges[i]), iprtoa(ipranges[i - 1])); ipranges.remove(i--); continue; } if(ipranges[i].lr <= ipranges[i - 1].ur) { logline(ACLOG_VERBOSE," blacklist entries %s and %s are joined due to overlap", iprtoa(ipranges[i - 1]), iprtoa(ipranges[i])); ipranges[i - 1].ur = ipranges[i].ur; ipranges.remove(i--); continue; } } loopv(ipranges) logline(ACLOG_VERBOSE," %s", iprtoa(ipranges[i])); logline(ACLOG_INFO,"read %d (%d) blacklist entries from '%s', %d errors", ipranges.length(), orglength, filename, errors); } bool check(enet_uint32 ip) // ip: network byte order { iprange t; t.lr = ENET_NET_TO_HOST_32(ip); // blacklist uses host byte order t.ur = 0; return ipranges.search(&t, cmpipmatch) != NULL; } }; // nicknameblacklist.cfg #define MAXNICKFRAGMENTS 5 enum { NWL_UNLISTED = 0, NWL_PASS, NWL_PWDFAIL, NWL_IPFAIL }; struct servernickblacklist : serverconfigfile { struct iprchain { struct iprange ipr; const char *pwd; int next; }; struct blackline { int frag[MAXNICKFRAGMENTS]; bool ignorecase; int line; void clear() { loopi(MAXNICKFRAGMENTS) frag[i] = -1; } }; hashtable whitelist; vector whitelistranges; vector blacklines; vector blfraglist; void destroylists() { whitelistranges.setsize(0); enumeratek(whitelist, const char *, key, delete key); whitelist.clear(false); blfraglist.deletecontents(); blacklines.setsize(0); } void read() { if(getfilesize(filename) == filelen) return; destroylists(); if(!load()) return; const char *sep = " "; int line = 1, errors = 0; iprchain iprc; blackline bl; char *b, *l, *s, *r, *p = buf; logline(ACLOG_VERBOSE,"reading nickname blacklist '%s'", filename); while(p < buf + filelen) { l = p; p += strlen(p) + 1; l = strtok_r(l, sep, &b); if(l) { s = strtok_r(NULL, sep, &b); int ic = 0; if(s && (!strcmp(l, "accept") || !strcmp(l, "a"))) { // accept nickname IP-range int *i = whitelist.access(s); if(!i) i = &whitelist.access(newstring(s), -1); s += strlen(s) + 1; while(s < p) { r = (char *) atoipr(s, &iprc.ipr); s += strspn(s, sep); iprc.pwd = r && *s ? NULL : newstring(s, strcspn(s, sep)); if(r || *s) { iprc.next = *i; *i = whitelistranges.length(); whitelistranges.add(iprc); s = r ? r : s + strlen(iprc.pwd); } else break; } s = NULL; } else if(s && (!strcmp(l, "block") || !strcmp(l, "b") || ic++ || !strcmp(l, "blocki") || !strcmp(l, "bi"))) { // block nickname fragments (ic == ignore case) bl.clear(); loopi(MAXNICKFRAGMENTS) { if(ic) strtoupper(s); loopvj(blfraglist) { if(!strcmp(s, blfraglist[j])) { bl.frag[i] = j; break; } } if(bl.frag[i] < 0) { bl.frag[i] = blfraglist.length(); blfraglist.add(newstring(s)); } s = strtok_r(NULL, sep, &b); if(!s) break; } bl.ignorecase = ic > 0; bl.line = line; blacklines.add(bl); } else { logline(ACLOG_INFO," error in line %d, file %s: unknown keyword '%s'", line, filename, l); errors++; } if(s && s[strspn(s, " ")]) { logline(ACLOG_INFO," error in line %d, file %s: ignored '%s'", line, filename, s); errors++; } } line++; } DELETEA(buf); logline(ACLOG_VERBOSE," nickname whitelist (%d entries):", whitelist.numelems); string text; enumeratekt(whitelist, const char *, key, int, idx, { text[0] = '\0'; for(int i = idx; i >= 0; i = whitelistranges[i].next) { iprchain &ic = whitelistranges[i]; if(ic.pwd) concatformatstring(text, " pwd:\"%s\"", hiddenpwd(ic.pwd)); else concatformatstring(text, " %s", iprtoa(ic.ipr)); } logline(ACLOG_VERBOSE, " accept %s%s", key, text); }); logline(ACLOG_VERBOSE," nickname blacklist (%d entries):", blacklines.length()); loopv(blacklines) { text[0] = '\0'; loopj(MAXNICKFRAGMENTS) { int k = blacklines[i].frag[j]; if(k >= 0) { concatstring(text, " "); concatstring(text, blfraglist[k]); } } logline(ACLOG_VERBOSE, " %2d block%s%s", blacklines[i].line, blacklines[i].ignorecase ? "i" : "", text); } logline(ACLOG_INFO,"read %d + %d entries from nickname blacklist file '%s', %d errors", whitelist.numelems, blacklines.length(), filename, errors); } int checkwhitelist(const client &c) { if(c.type != ST_TCPIP) return NWL_PASS; iprange ipr; ipr.lr = ENET_NET_TO_HOST_32(c.peer->address.host); // blacklist uses host byte order int *idx = whitelist.access(c.name); if(!idx) return NWL_UNLISTED; // no matching entry int i = *idx; bool needipr = false, iprok = false, needpwd = false, pwdok = false; while(i >= 0) { iprchain &ic = whitelistranges[i]; if(ic.pwd) { // check pwd needpwd = true; if(pwdok || !strcmp(genpwdhash(c.name, ic.pwd, c.salt), c.pwd)) pwdok = true; } else { // check IP needipr = true; if(!cmpipmatch(&ipr, &ic.ipr)) iprok = true; // range match found } i = whitelistranges[i].next; } if(needpwd && !pwdok) return NWL_PWDFAIL; // wrong PWD if(needipr && !iprok) return NWL_IPFAIL; // wrong IP return NWL_PASS; } int checkblacklist(const char *name) { if(blacklines.empty()) return -2; // no nickname blacklist loaded string nameuc; copystring(nameuc, name); strtoupper(nameuc); loopv(blacklines) { loopj(MAXNICKFRAGMENTS) { int k = blacklines[i].frag[j]; if(k < 0) return blacklines[i].line; // no more fragments to check if(strstr(blacklines[i].ignorecase ? nameuc : name, blfraglist[k])) { if(j == MAXNICKFRAGMENTS - 1) return blacklines[i].line; // all fragments match } else break; // this line no match } } return -1; // no match } }; #define FORBIDDENSIZE 15 bool issimilar (char s, char d) { s = tolower(s); d = tolower(d); if ( s == d ) return true; switch (d) { case 'a': if ( s == '@' || s == '4' ) return true; break; case 'c': if ( s == 'k' ) return true; break; case 'e': if ( s == '3' ) return true; break; case 'i': if ( s == '!' || s == '1' ) return true; break; case 'o': if ( s == '0' ) return true; break; case 's': if ( s == '$' || s == '5' ) return true; break; case 't': if ( s == '7' ) return true; break; case 'u': if ( s == '#' ) return true; break; } return false; } bool findpattern (char *s, char *d) // returns true if there is more than 80% of similarity { int len, hit = 0; if (!d || (len = strlen(d)) < 1) return false; char *dp = d, *s_end = s + strlen(s); while (s != s_end) { if ( *s == ' ' ) // spaces separate words { if ( !issimilar(*(s+1),*dp) ) { dp = d; hit = 0; } // d e t e c t i t } else if ( issimilar(*s,*dp) ) { dp++; hit++; } // hit! else if ( hit > 0 ) // this is not a pair, but there is a previous pattern { if (*s == '.' || *s == *(s-1) || issimilar(*(s+1),*dp) ); // separator or typo (do nothing) else if ( issimilar(*(s+1),*(dp+1)) || *s == '*' ) dp++; // wild card or typo else hit--; // maybe this is nothing } else dp = d; // nothing here s++; // walk on the string if ( hit && 5 * hit > 4 * len ) return true; // found it! } return false; } struct serverforbiddenlist : serverconfigfile { int num; char entries[100][2][FORBIDDENSIZE+1]; // 100 entries and 2 words per entry is more than enough void initlist() { num = 0; memset(entries,'\0',2*100*(FORBIDDENSIZE+1)); } void addentry(char *s) { int len = strlen(s); if ( len > 128 || len < 3 ) return; int n = 0; string s1, s2; char *c1 = s1, *c2 = s2; if (num < 100 && (n = sscanf(s,"%s %s",s1,s2)) > 0 ) // no warnings { strncpy(entries[num][0],c1,FORBIDDENSIZE); if ( n > 1 ) strncpy(entries[num][1],c2,FORBIDDENSIZE); else entries[num][1][0]='\0'; num++; } } void read() { if(getfilesize(filename) == filelen) return; initlist(); if(!load()) return; char *l, *p = buf; logline(ACLOG_VERBOSE,"reading forbidden list '%s'", filename); while(p < buf + filelen) { l = p; p += strlen(p) + 1; addentry(l); } DELETEA(buf); } bool canspeech(char *s) { for (int i=0; i adminpwds; int staticpasses; serverpasswords() : staticpasses(0) {} void init(const char *name, const char *cmdlinepass) { if(cmdlinepass[0]) { pwddetail c; copystring(c.pwd, cmdlinepass); c.line = 0; // commandline is 'line 0' c.denyadmin = false; adminpwds.add(c); } staticpasses = adminpwds.length(); serverconfigfile::init(name); } void read() { if(getfilesize(filename) == filelen) return; adminpwds.shrink(staticpasses); if(!load()) return; pwddetail c; const char *sep = " "; int i, line = 1, par[ADMINPWD_MAXPAR]; char *b, *l, *p = buf; logline(ACLOG_VERBOSE,"reading admin passwords '%s'", filename); while(p < buf + filelen) { l = p; p += strlen(p) + 1; l = strtok_r(l, sep, &b); if(l) { copystring(c.pwd, l); par[0] = 0; // default values for(i = 0; i < ADMINPWD_MAXPAR; i++) { if((l = strtok_r(NULL, sep, &b)) != NULL) par[i] = atoi(l); else break; } //if(i > 0) { c.line = line; c.denyadmin = par[0] > 0; adminpwds.add(c); logline(ACLOG_VERBOSE,"line%4d: %s %d", c.line, hiddenpwd(c.pwd), c.denyadmin ? 1 : 0); } } line++; } DELETEA(buf); logline(ACLOG_INFO,"read %d admin passwords from '%s'", adminpwds.length() - staticpasses, filename); } bool check(const char *name, const char *pwd, int salt, pwddetail *detail = NULL, enet_uint32 address = 0) { bool found = false; if (address && passguy == address) { if (passtime + 3000 > servmillis || ( passtries > 5 && passtime + 10000 > servmillis )) { passtries++; passtime = servmillis; return false; } else { if ( passtime + 60000 < servmillis ) passtries = 0; } passtries++; } else { passtries = 0; } passguy = address; passtime = servmillis; loopv(adminpwds) { if(!strcmp(genpwdhash(name, adminpwds[i].pwd, salt), pwd)) { if(detail) *detail = adminpwds[i]; found = true; break; } } return found; } }; // serverinfo_en.txt, motd_en.txt #define MAXINFOLINELEN 100 // including color codes struct serverinfofile { struct serverinfotext { const char *type; char lang[3]; char *info; int lastcheck; }; vector serverinfotexts; const char *infobase, *motdbase; void init(const char *info, const char *motd) { infobase = info; motdbase = motd; } char *readinfofile(const char *fnbase, const char *lang) { defformatstring(fname)("%s_%s.txt", fnbase, lang); path(fname); int len, n; char *c, *b, *s, *t, *buf = loadfile(fname, &len); if(!buf) return NULL; char *nbuf = new char[len + 2]; for(t = nbuf, s = strtok_r(buf, "\n\r", &b); s; s = strtok_r(NULL, "\n\r", &b)) { c = strstr(s, "//"); if(c) *c = '\0'; // strip comments for(n = (int)strlen(s) - 1; n >= 0 && s[n] == ' '; n--) s[n] = '\0'; // strip trailing blanks filterrichtext(t, s + strspn(s, " "), MAXINFOLINELEN); // skip leading blanks n = (int)strlen(t); if(n) t += n + 1; } *t = '\0'; DELETEA(buf); if(!*nbuf) DELETEA(nbuf); logline(ACLOG_DEBUG,"read file \"%s\"", fname); return nbuf; } const char *getinfocache(const char *fnbase, const char *lang) { serverinfotext sn = { fnbase, { 0, 0, 0 }, NULL, 0} , *s = &sn; filterlang(sn.lang, lang); if(!sn.lang[0]) return NULL; loopv(serverinfotexts) { serverinfotext &si = serverinfotexts[i]; if(si.type == s->type && !strcmp(si.lang, s->lang)) { if(servmillis - si.lastcheck > (si.info ? 15 : 45) * 60 * 1000) { // re-read existing files after 15 minutes; search missing again after 45 minutes DELETEA(si.info); s = &si; } else return si.info; } } s->info = readinfofile(fnbase, lang); s->lastcheck = servmillis; if(s == &sn) serverinfotexts.add(*s); if(fnbase == motdbase && s->info) { char *c = s->info; while(*c) { c += strlen(c); if(c[1]) *c++ = '\n'; } if(strlen(s->info) > MAXSTRLEN) s->info[MAXSTRLEN] = '\0'; // keep MOTD at sane lengths } return s->info; } const char *getinfo(const char *lang) { return getinfocache(infobase, lang); } const char *getmotd(const char *lang) { const char *motd; if(*lang && (motd = getinfocache(motdbase, lang))) return motd; return getinfocache(motdbase, "en"); } }; assaultcube-1.2.0.2.1/source/src/serverms.cpp000066400000000000000000000274371352165075300210110ustar00rootroot00000000000000// all server side masterserver and pinging functionality #include "cube.h" #ifdef STANDALONE bool resolverwait(const char *name, ENetAddress *address) { return enet_address_set_host(address, name) >= 0; } int connectwithtimeout(ENetSocket sock, const char *hostname, ENetAddress &remoteaddress) { int result = enet_socket_connect(sock, &remoteaddress); if(result<0) enet_socket_destroy(sock); return result; } #endif ENetSocket mastersock = ENET_SOCKET_NULL; ENetAddress masteraddress = { ENET_HOST_ANY, ENET_PORT_ANY }, serveraddress = { ENET_HOST_ANY, ENET_PORT_ANY }; string mastername = AC_MASTER_URI; int masterport = AC_MASTER_PORT; int lastupdatemaster = 0; vector masterout, masterin; int masteroutpos = 0, masterinpos = 0; void disconnectmaster() { if(mastersock == ENET_SOCKET_NULL) return; enet_socket_destroy(mastersock); mastersock = ENET_SOCKET_NULL; masterout.setsize(0); masterin.setsize(0); masteroutpos = masterinpos = 0; masteraddress.host = ENET_HOST_ANY; masteraddress.port = ENET_PORT_ANY; //lastupdatemaster = 0; } ENetSocket connectmaster() { if(!mastername[0]) return ENET_SOCKET_NULL; extern servercommandline scl; if(scl.maxclients>MAXCL) { logline(ACLOG_WARNING, "maxclient exceeded: cannot register"); return ENET_SOCKET_NULL; } if(masteraddress.host == ENET_HOST_ANY) { logline(ACLOG_INFO, "looking up %s:%d...", mastername, masterport); masteraddress.port = masterport; if(!resolverwait(mastername, &masteraddress)) return ENET_SOCKET_NULL; } ENetSocket sock = enet_socket_create(ENET_SOCKET_TYPE_STREAM); if(sock != ENET_SOCKET_NULL && serveraddress.host != ENET_HOST_ANY && enet_socket_bind(sock, &serveraddress) < 0) { enet_socket_destroy(sock); sock = ENET_SOCKET_NULL; } if(sock == ENET_SOCKET_NULL || connectwithtimeout(sock, mastername, masteraddress) < 0) { logline(ACLOG_WARNING, sock==ENET_SOCKET_NULL ? "could not open socket" : "could not connect"); return ENET_SOCKET_NULL; } enet_socket_set_option(sock, ENET_SOCKOPT_NONBLOCK, 1); return sock; } bool requestmaster(const char *req) { if(mastersock == ENET_SOCKET_NULL) { mastersock = connectmaster(); if(mastersock == ENET_SOCKET_NULL) return false; } masterout.put(req, strlen(req)); return true; } bool requestmasterf(const char *fmt, ...) { defvformatstring(req, fmt, fmt); return requestmaster(req); } extern void processmasterinput(const char *cmd, int cmdlen, const char *args); void processmasterinput() { if(masterinpos >= masterin.length()) return; char *input = &masterin[masterinpos], *end = (char *)memchr(input, '\n', masterin.length() - masterinpos); while(end) { *end++ = '\0'; const char *args = input; while(args < end && !isspace(*args)) args++; int cmdlen = args - input; while(args < end && isspace(*args)) args++; if(!strncmp(input, "failreg", cmdlen)) logline(ACLOG_WARNING, "master server registration failed: %s", args); else if(!strncmp(input, "succreg", cmdlen)) { logline(ACLOG_INFO, "master server registration succeeded"); } else processmasterinput(input, cmdlen, args); masterinpos = end - masterin.getbuf(); input = end; end = (char *)memchr(input, '\n', masterin.length() - masterinpos); } if(masterinpos >= masterin.length()) { masterin.setsize(0); masterinpos = 0; } } void flushmasteroutput() { if(masterout.empty()) return; ENetBuffer buf; buf.data = &masterout[masteroutpos]; buf.dataLength = masterout.length() - masteroutpos; int sent = enet_socket_send(mastersock, NULL, &buf, 1); if(sent >= 0) { masteroutpos += sent; if(masteroutpos >= masterout.length()) { masterout.setsize(0); masteroutpos = 0; } } else disconnectmaster(); } void flushmasterinput() { if(masterin.length() >= masterin.capacity()) masterin.reserve(4096); ENetBuffer buf; buf.data = masterin.getbuf() + masterin.length(); buf.dataLength = masterin.capacity() - masterin.length(); int recv = enet_socket_receive(mastersock, NULL, &buf, 1); if(recv > 0) { masterin.advance(recv); processmasterinput(); } else disconnectmaster(); } extern char *global_name; extern int totalclients; // send alive signal to masterserver after 40 minutes of uptime and if currently in intermission (so theoretically <= 1 hour) // TODO?: implement a thread to drop this "only in intermission" business, we'll need it once AUTH gets active! static inline void updatemasterserver(int millis, int port) { if(!lastupdatemaster || ((millis-lastupdatemaster)>40*60*1000 && (interm || !totalclients))) { char servername[30]; memset(servername,'\0',30); filtertext(servername, global_name, FTXT__GLOBALNAME, 20); if(mastername[0]) requestmasterf("regserv %d %s %d\n", port, servername[0] ? servername : "noname", AC_VERSION); lastupdatemaster = millis + 1; } } ENetSocket pongsock = ENET_SOCKET_NULL, lansock = ENET_SOCKET_NULL; extern int getpongflags(enet_uint32 ip); void serverms(int mode, int numplayers, int minremain, char *smapname, int millis, const ENetAddress &localaddr, int *mnum, int *msend, int *mrec, int *cnum, int *csend, int *crec, int protocol_version) { flushmasteroutput(); updatemasterserver(millis, localaddr.port); static ENetSocketSet sockset; ENET_SOCKETSET_EMPTY(sockset); ENetSocket maxsock = pongsock; ENET_SOCKETSET_ADD(sockset, pongsock); if(mastersock != ENET_SOCKET_NULL) { maxsock = max(maxsock, mastersock); ENET_SOCKETSET_ADD(sockset, mastersock); } if(lansock != ENET_SOCKET_NULL) { maxsock = max(maxsock, lansock); ENET_SOCKETSET_ADD(sockset, lansock); } if(enet_socketset_select(maxsock, &sockset, NULL, 0) <= 0) return; // reply all server info requests static uchar data[MAXTRANS]; ENetBuffer buf; ENetAddress addr; buf.data = data; int len; loopi(2) { ENetSocket sock = i ? lansock : pongsock; if(sock == ENET_SOCKET_NULL || !ENET_SOCKETSET_CHECK(sockset, sock)) continue; buf.dataLength = sizeof(data); len = enet_socket_receive(sock, &addr, &buf, 1); if(len < 0) continue; // ping & pong buf ucharbuf pi(data, len), po(&data[len], sizeof(data)-len); bool std = false; if(getint(pi) != 0) // std pong { extern struct servercommandline scl; extern string servdesc_current; (*mnum)++; *mrec += len; std = true; putint(po, protocol_version); putint(po, mode); putint(po, numplayers); putint(po, minremain); sendstring(smapname, po); sendstring(servdesc_current, po); putint(po, scl.maxclients); putint(po, getpongflags(addr.host)); if(pi.remaining()) { int query = getint(pi); switch(query) { case EXTPING_NAMELIST: { extern void extping_namelist(ucharbuf &p); putint(po, query); extping_namelist(po); break; } case EXTPING_SERVERINFO: { extern void extping_serverinfo(ucharbuf &pi, ucharbuf &po); putint(po, query); extping_serverinfo(pi, po); break; } case EXTPING_MAPROT: { extern void extping_maprot(ucharbuf &po); putint(po, query); extping_maprot(po); break; } case EXTPING_UPLINKSTATS: { extern void extping_uplinkstats(ucharbuf &po); putint(po, query); extping_uplinkstats(po); break; } case EXTPING_NOP: default: putint(po, EXTPING_NOP); break; } } } else // ext pong - additional server infos { (*cnum)++; *crec += len; int extcmd = getint(pi); putint(po, EXT_ACK); putint(po, EXT_VERSION); switch(extcmd) { case EXT_UPTIME: // uptime in seconds { putint(po, uint(millis)/1000); break; } case EXT_PLAYERSTATS: // playerstats { int cn = getint(pi); // get requested player, -1 for all if(!valid_client(cn) && cn != -1) { putint(po, EXT_ERROR); break; } putint(po, EXT_ERROR_NONE); // add no error flag int bpos = po.length(); // remember buffer position putint(po, EXT_PLAYERSTATS_RESP_IDS); // send player ids following extinfo_cnbuf(po, cn); *csend += int(buf.dataLength = len + po.length()); enet_socket_send(pongsock, &addr, &buf, 1); // send all available player ids po.len = bpos; extinfo_statsbuf(po, cn, bpos, pongsock, addr, buf, len, csend); return; } case EXT_TEAMSCORE: extinfo_teamscorebuf(po); break; default: putint(po,EXT_ERROR); break; } } buf.dataLength = len + po.length(); enet_socket_send(pongsock, &addr, &buf, 1); if(std) *msend += (int)buf.dataLength; else *csend += (int)buf.dataLength; } if(mastersock != ENET_SOCKET_NULL && ENET_SOCKETSET_CHECK(sockset, mastersock)) flushmasterinput(); } // this function should be made better, because it is used just ONCE (no need of so much parameters) void servermsinit(const char *master, const char *ip, int infoport, bool listen) { copystring(mastername, master); disconnectmaster(); if(listen) { ENetAddress address = { ENET_HOST_ANY, (enet_uint16)infoport }; if(*ip) { if(enet_address_set_host(&address, ip)<0) logline(ACLOG_WARNING, "server ip not resolved"); else serveraddress.host = address.host; } pongsock = enet_socket_create(ENET_SOCKET_TYPE_DATAGRAM); if(pongsock != ENET_SOCKET_NULL && enet_socket_bind(pongsock, &address) < 0) { enet_socket_destroy(pongsock); pongsock = ENET_SOCKET_NULL; } if(pongsock == ENET_SOCKET_NULL) fatal("could not create server info socket"); else enet_socket_set_option(pongsock, ENET_SOCKOPT_NONBLOCK, 1); address.port = CUBE_SERVINFO_PORT_LAN; lansock = enet_socket_create(ENET_SOCKET_TYPE_DATAGRAM); if(lansock != ENET_SOCKET_NULL && (enet_socket_set_option(lansock, ENET_SOCKOPT_REUSEADDR, 1) < 0 || enet_socket_bind(lansock, &address) < 0)) { enet_socket_destroy(lansock); lansock = ENET_SOCKET_NULL; } if(lansock == ENET_SOCKET_NULL) logline(ACLOG_WARNING, "could not create LAN server info socket"); else enet_socket_set_option(lansock, ENET_SOCKOPT_NONBLOCK, 1); } } assaultcube-1.2.0.2.1/source/src/shadow.cpp000066400000000000000000000306741352165075300204250ustar00rootroot00000000000000// shadow.cpp: stencil shadow rendering #include "cube.h" VARP(stencilshadow, 0, 40, 100); int stenciling = 0; VAR(shadowclip, 0, 1, 1); VAR(shadowtile, 0, 1, 1); VAR(shadowcasters, 1, 0, 0); #define SHADOWROWS 64 #define SHADOWCOLUMNS 32 #define SHADOWCOLUMNMASK (0xFFFFFFFFU>>(32-SHADOWCOLUMNS)) uint shadowtiles[SHADOWROWS+1]; float shadowx1 = 1, shadowy1 = 1, shadowx2 = -1, shadowy2 = -1; static void extrudeshadowtiles(int x1, int y1, int x2, int y2, int x3, int y3) { if(y1 > y2) { swap(x1, x2); swap(y1, y2); } if(y2 > y3) { swap(x2, x3); swap(y2, y3); } if(y1 > y2) { swap(x1, x2); swap(y1, y2); } if(y3 < 0 || y1 >= SHADOWROWS) return; int lx = x1, rx = x1, fracl = 0, fracr = 0, dlx, dly, drx, dry; if(x2 <= x3) { dlx = x2; dly = y2; drx = x3; dry = y3; } else { dlx = x3; dly = y3; drx = x2; dry = y2; } dlx -= x1; dly -= y1; drx -= x1; dry -= y1; int ldir = 1, rdir = 1; if(dlx < 0) { ldir = -1; dlx = -dlx; } if(drx < 0) { rdir = -1; drx = -drx; } int cy = y1; y2 = min(y2, SHADOWROWS); if(cy < 0 && y2 > cy) { int dy = min(y2, 0) - cy; cy += dy; fracl += dy*dlx; lx += ldir*(fracl/dly); fracl %= dly; fracr += dy*drx; rx += rdir*(fracr/dry); fracr %= dry; } for(; cy < y2; cy++) { int cx1 = lx, cx2 = rx; fracl += dlx; while(fracl >= dly) { lx += ldir; if(ldir < 0) cx1 = lx; fracl -= dly; } fracr += drx; while(fracr >= dry) { rx += rdir; if(rdir > 0) cx2 = rx; fracr -= dry; } if(cx1 < SHADOWCOLUMNS && cx2 >= 0) shadowtiles[cy] |= (SHADOWCOLUMNMASK>>(SHADOWCOLUMNS - (min(cx2, SHADOWCOLUMNS-1)+1))) & (SHADOWCOLUMNMASK<= SHADOWROWS) return; if(x2 < x3 || y1 == cy) { if(x2 < lx) lx = x2; dlx = x3 - lx; dly = y3 - cy; ldir = 1; if(dlx < 0) { ldir = -1; dlx = -dlx; } fracl = 0; } if(x2 > x3 || y1 == cy) { if(x2 > rx) rx = x2; drx = x3 - rx; dry = y3 - cy; rdir = 1; if(drx < 0) { rdir = -1; drx = -drx; } fracr = 0; } y3 = min(y3, SHADOWROWS); if(cy < 0 && y3 > cy) { int dy = min(y3, 0) - cy; cy += dy; fracl += dy*dlx; lx += ldir*(fracl/dly); fracl %= dly; fracr += dy*drx; rx += rdir*(fracr/dry); fracr %= dry; } for(; cy < y3; cy++) { int cx1 = lx, cx2 = rx; fracl += dlx; while(fracl >= dly) { lx += ldir; if(ldir < 0) cx1 = lx; fracl -= dly; } fracr += drx; while(fracr >= dry) { rx += rdir; if(rdir > 0) cx2 = rx; fracr -= dry; } if(cx1 < SHADOWCOLUMNS && cx2 >= 0) shadowtiles[cy] |= (SHADOWCOLUMNMASK>>(SHADOWCOLUMNS - (min(cx2, SHADOWCOLUMNS-1)+1))) & (SHADOWCOLUMNMASK<= dly) { lx += ldir; if(ldir < 0) cx1 = lx; fracl -= dly; } } if(dry) { fracr += drx; while(fracr >= dry) { rx += rdir; if(rdir > 0) cx2 = rx; fracr -= dry; } } if(cx1 < SHADOWCOLUMNS && cx2 >= 0) shadowtiles[cy] |= (SHADOWCOLUMNMASK>>(SHADOWCOLUMNS - (min(cx2, SHADOWCOLUMNS-1)+1))) & (SHADOWCOLUMNMASK<>(SHADOWCOLUMNS - (tx2+1))) & (SHADOWCOLUMNMASK<= -p.w) { float x = p.x / p.w, y = p.y / p.w; sx1 = min(sx1, x); sy1 = min(sy1, y); sx2 = max(sx2, x); sy2 = max(sy2, y); front++; } } vec4 ev; mat.transform(extrude, ev); if(ev.z < -ev.w && !front) return false; if(front < 8 || ev.z < -ev.w) loopi(8) { const vec4 &p = v[i]; if(p.z >= -p.w) { if(ev.z >= -ev.w) continue; float t = ev.z/(ev.z - p.z), w = ev.w + t*(p.w - ev.w), x = (ev.x + t*(p.x - ev.x))/w, y = (ev.y + t*(p.y - ev.y))/w; sx1 = min(sx1, x); sy1 = min(sy1, y); sx2 = max(sx2, x); sy2 = max(sy2, y); continue; } loopj(3) { const vec4 &o = v[i^(1<= -ev.w) { float x = ev.x/ev.w, y = ev.y/ev.w; if((sx1 >= 1 && x >= 1) || (sy1 >= 1 && y >= 1) || (sx2 <= -1 && x <= -1) || (sy2 <= -1 && y <= -1)) return false; int tx = int(floor(SHADOWCOLUMNS * (y + 1) / 2)), ty = int(floor(SHADOWROWS * (x + 1) / 2)), tx1 = int(floor(SHADOWCOLUMNS * (sy1 + 1) / 2)), ty1 = int(floor(SHADOWROWS * (sx1 + 1) / 2)), tx2 = int(floor(SHADOWCOLUMNS * (sy2 + 1) / 2)), ty2 = int(floor(SHADOWROWS * (sx2 + 1) / 2)); if(tx < tx1) { if(ty < ty1) { swap(ty1, ty2); tx1--; ty1--; } else if(ty > ty2) { tx1--; ty1++; } else { tx2 = tx1; tx1--; tx2--; } } else if(tx > tx2) { if(ty < ty1) { ty1--; tx2++; } else if(ty > ty2) { swap(ty1, ty2); ty1++; tx2++; } else { tx1 = tx2; tx1++; tx2++; } } else { if(ty < ty1) { ty2 = ty1; ty1--; ty2--; } else if(ty > ty2) { ty1 = ty2; ty1++; ty2++; } else goto noextrusion; } extrudeshadowtiles(tx, ty, tx1, ty1, tx2, ty2); shadowx1 = min(x, shadowx1); shadowy1 = min(y, shadowy1); shadowx2 = max(x, shadowx2); shadowy2 = max(y, shadowy2); noextrusion:; } else if(sx1 >= 1 || sy1 >= 1 || sx2 <= -1 || sy2 <= -1) return false; shadowcasters++; addshadowtiles(sx1, sy1, sx2, sy2); return true; } static void rendershadowtiles() { shadowx1 = clamp(shadowx1, -1.0f, 1.0f); shadowy1 = clamp(shadowy1, -1.0f, 1.0f); shadowx2 = clamp(shadowx2, -1.0f, 1.0f); shadowy2 = clamp(shadowy2, -1.0f, 1.0f); if(shadowx1 >= shadowx2 || shadowy1 >= shadowy2) return; float clipx1 = (shadowy1 + 1) / 2, clipy1 = (shadowx1 + 1) / 2, clipx2 = (shadowy2 + 1) / 2, clipy2 = (shadowx2 + 1) / 2; if(!shadowclip) { clipx1 = clipy1 = 0; clipx2 = clipy2 = 1; } if(!shadowtile) { glBegin(GL_TRIANGLE_STRIP); glVertex2f(clipy1, clipx1); glVertex2f(clipy1, clipx2); glVertex2f(clipy2, clipx1); glVertex2f(clipy2, clipx2); xtraverts += 4; glEnd(); return; } glBegin(GL_QUADS); float tw = 1.0f/SHADOWCOLUMNS, th = 1.0f/SHADOWROWS; loop(y, SHADOWROWS+1) { uint mask = shadowtiles[y]; int x = 0; while(mask) { while(!(mask&0xFF)) { mask >>= 8; x += 8; } while(!(mask&1)) { mask >>= 1; x++; } int xstart = x; do { mask >>= 1; x++; } while(mask&1); uint strip = (SHADOWCOLUMNMASK>>(SHADOWCOLUMNS - x)) & (SHADOWCOLUMNMASK<= 0 && (x) < S_NULL) // bounds check for soundcfg[] #define gamesound_hasflag(x, mask) (gamesound_isvalid(x) && (soundcfg[x].flags & mask) != 0) #define gamesound_isvoicecom(x) gamesound_hasflag(x, 1 << SC_VOICECOM) // all voicecoms #define gamesound_ispublicvoicecom(x) gamesound_hasflag(x, 1 << SC_PUBLIC) // voicecoms always sent to all players struct soundcfgitem { const char *name, *desc; uchar vol, loop, audibleradius, key; int flags; }; extern soundcfgitem soundcfg[S_NULL]; // hardcoded music enum { M_FLAGGRAB = 0, M_LASTMINUTE1, M_LASTMINUTE2 }; // sound priorities enum { SP_LOW = 0, SP_NORMAL, SP_HIGH, SP_HIGHEST }; #ifndef STANDALONE // owner of an OpenAL source, used as callback interface class sourceowner { public: virtual ~sourceowner() {} virtual void onsourcereassign(class source *s) = 0; }; // represents an OpenAL source, an audio emitter in the 3D world class source { public: ALuint id; sourceowner *owner; bool locked, valid; int priority; source(); ~source(); void lock(); void unlock(); void reset(); void init(sourceowner *o); void onreassign(); bool generate(); bool delete_(); bool buffer(ALuint buf_id); bool looping(bool enable); bool queuebuffers(ALsizei n, const ALuint *buffer_ids); bool unqueueallbuffers(); bool gain(float g); bool pitch(float p); bool position(const vec &pos); bool position(float x, float y, float z); bool velocity(float x, float y, float z); vec position(); bool sourcerelative(bool enable); int state(); bool secoffset(float secs); float secoffset(); bool playing(); bool play(); bool stop(); bool rewind(); void printposition(); }; // represents an OpenAL sound buffer class sbuffer { public: ALuint id; const char *name; sbuffer(); ~sbuffer(); bool load(bool trydl = false); void unload(); }; // buffer storage class bufferhashtable : public hashtable { public: virtual ~bufferhashtable(); virtual sbuffer *find(const char *name); }; // manages available sources, abstracts audio channels // is a singleton class sourcescheduler { int numsoundchannels; static sourcescheduler *inst; vector sources; public: sourcescheduler(); static sourcescheduler &instance(); // singleton access void init(int numsoundchannels); void reset(); source *newsource(int priority, const vec &o); void releasesource(source *src); }; // audio streaming class oggstream : sourceowner { public: string name; bool valid; // file stream OggVorbis_File oggfile; bool isopen; vorbis_info *info; double totalseconds; static const int BUFSIZE = 1024 * 512; // 512kb buffer // OpenAL resources ALuint bufferids[2]; source *src; ALenum format; // settings float volume, gain; int startmillis, endmillis, startfademillis, endfademillis; bool looping; oggstream(); ~oggstream(); void reset(); bool open(const char *f); void onsourcereassign(source *s); bool stream(ALuint bufid); bool update(); bool playing(); void updategain(); void setgain(float g); void setvolume(float v); void fadein(int startmillis, int fademillis); void fadeout(int endmillis, int fademillis); bool playback(bool looping = false); void seek(double offset); }; struct soundconfig { sbuffer *buf; // sound data int vol; // volume int uses, maxuses; // track uses bool loop; bool muted; int audibleradius; enum distancemodel { DM_DEFAULT = 0, // use openal distance model DM_LINEAR // custom linear model (used in conjunction with audibleradius) }; distancemodel model; soundconfig(sbuffer *b, int vol, int maxuses, bool loop, int audibleradius); void onattach(); void ondetach(); }; class worldobjreference { public: enum worldobjtype { WR_CAMERA, WR_PHYSENT, WR_ENTITY, WR_STATICPOS }; int type; worldobjreference(int t) : type(t) {} virtual ~worldobjreference() {} virtual worldobjreference *clone() const = 0; virtual const vec ¤tposition() const = 0; virtual bool nodistance() = 0; virtual bool operator==(const worldobjreference &other) = 0; virtual bool operator!=(const worldobjreference &other) { return !(*this==other); } virtual void attach() {} virtual void detach() {} }; class camerareference : public worldobjreference { public: camerareference(); worldobjreference *clone() const; const vec ¤tposition() const; bool nodistance(); bool operator==(const worldobjreference &other); }; class physentreference : public worldobjreference { public: class physent *phys; physentreference(physent *ref); worldobjreference *clone() const; const vec ¤tposition() const; bool nodistance(); bool operator==(const worldobjreference &other); }; struct entityreference : public worldobjreference { public: struct entity *ent; entityreference(entity *ref); worldobjreference *clone() const; const vec ¤tposition() const; bool nodistance(); bool operator==(const worldobjreference &other); }; struct staticreference : public worldobjreference { public: vec pos; staticreference(const vec &ref); worldobjreference *clone() const; const vec ¤tposition() const; bool nodistance(); bool operator==(const worldobjreference &other); }; class location : sourceowner { public: soundconfig *cfg; source *src; worldobjreference *ref; bool stale; int playmillis; location(int sound, const worldobjreference &r, int priority = SP_NORMAL); ~location(); void attachworldobjreference(const worldobjreference &r); void evaluateworldobjref(); void onsourcereassign(source *s); void updatepos(); void update(); void play(bool loop = false); void pitch(float p); bool setvolume(float v); void offset(float secs); float offset(); void drop(); }; struct locvector : vector { virtual ~locvector() {} location *find(int sound, worldobjreference *ref/* = NULL*/, const vector &soundcollection /* = gamesounds*/); void delete_(int i); void replaceworldobjreference(const worldobjreference &oldr, const worldobjreference &newr); void updatelocations(); void forcepitch(float pitch); void deleteworldobjsounds(); }; // audio interface to the engine class audiomanager { bool nosound; float currentpitch; vector musics; ALCdevice *device; ALCcontext *context; bufferhashtable bufferpool; oggstream *gamemusic; public: locvector locations; audiomanager(); // init & setup void initsound(); bool preloadmapsound(entity &e, bool trydl = false); bool preloadmapsounds(bool trydl = false); void applymapsoundchanges(); // configuration void setchannels(int num); void setlistenervol(int vol); int addsound(const char *name, int vol, int maxuses, bool loop, vector &sounds, bool load, int audibleradius); void registermusic(char *name); void mutesound(int n, int off); void unmuteallsounds(); int soundmuted(int n); // cleanup void soundcleanup(); void clearworldsounds(bool fullclean = true); void mapsoundreset(); void stopsound(); // music handling void music(char *name, int millis, char *cmd); void musicpreload(int id); void musicsuggest(int id, int millis, bool rndofs); void musicfadeout(int id); void setmusicvol(int musicvol); // sound handling location *_playsound(int n, const worldobjreference &r, int priority, float offset = 0.0f, bool loop = false); void playsound(int n, int priority = SP_NORMAL); void playsound(int n, class physent *p, int priority = SP_NORMAL); void playsound(int n, struct entity *e, int priority = SP_NORMAL); void playsound(int n, const vec *v, int priority = SP_NORMAL); void playsoundname(char *s, const vec *loc, int vol); void playsoundc(int n, physent *p = NULL, int priority = SP_NORMAL); void sound(int n); int findsound(const char *name, int vol, vector &sounds); void detachsounds(class playerent *owner); // update void updateplayerfootsteps(class playerent *p); location *updateloopsound(int sound, bool active, float vol = 1.0f); void updateaudio(); // misc void writesoundconfig(stream *f); }; void alclearerr(); bool alerr(bool msg = true, int line = 0, const char *s = NULL, ...) PRINTFARGS(3, 4); #define ALERR alerr(true, __LINE__) #define ALERRF(fmt, ...) alerr(true, __LINE__, fmt, __VA_ARGS__) extern vector gamesounds, mapsounds; extern ov_callbacks oggcallbacks; extern int soundvol; extern int audiodebug; extern int voicecomsounds; extern audiomanager audiomgr; extern void registerdefaultsounds(); #endif //#ifndef STANDALONE assaultcube-1.2.0.2.1/source/src/soundlocation.cpp000066400000000000000000000176711352165075300220230ustar00rootroot00000000000000// short living sound occurrence, dies once the sound stops #include "cube.h" #define DEBUGCOND (audiodebug==1) VARP(gainscale, 1, 90, 100); int warn_about_unregistered_sound = 0; location::location(int sound, const worldobjreference &r, int priority) : cfg(NULL), src(NULL), ref(NULL), stale(false), playmillis(0) { vector &sounds = (r.type==worldobjreference::WR_ENTITY ? mapsounds : gamesounds); if(!sounds.inrange(sound)) { if (lastmillis - warn_about_unregistered_sound > 30 * 1000) // delay message to every 30 secs so console is not spammed. { // occurs when a map contains an ambient sound entity, but sound entity is not found in map cfg file. conoutf("\f3ERROR: this map contains at least one unregistered ambient sound (sound slot# %d)", sound); warn_about_unregistered_sound = lastmillis; } stale = true; return; } // get sound config cfg = &sounds[sound]; cfg->onattach(); const float dist = camera1->o.dist(r.currentposition()); if((r.type==worldobjreference::WR_ENTITY && cfg->maxuses >= 0 && cfg->uses >= cfg->maxuses) || cfg->muted || (cfg->audibleradius && dist>cfg->audibleradius)) // check max-use limits and audible radius { stale = true; return; } // assign buffer sbuffer *buf = cfg->buf; if(!buf || !buf->id) { stale = true; return; } // obtain source src = sourcescheduler::instance().newsource(priority, r.currentposition()); // apply configuration if(!src || !src->valid || !src->buffer(cfg->buf->id) || !src->looping(cfg->loop) || !setvolume(1.0f)) { stale = true; return; } src->init(this); // set position attachworldobjreference(r); } location::~location() { if(src) sourcescheduler::instance().releasesource(src); if(cfg) cfg->ondetach(); if(ref) { ref->detach(); DELETEP(ref); } } // attach a reference to a world object to get the 3D position from void location::attachworldobjreference(const worldobjreference &r) { ASSERT(src && src->valid); // was: ASSERT(!stale && src && src->valid); if(stale) return; if(ref) { ref->detach(); DELETEP(ref); } ref = r.clone(); evaluateworldobjref(); ref->attach(); } // enable/disable distance calculations void location::evaluateworldobjref() { src->sourcerelative(ref->nodistance()); } // marks itself for deletion if source got lost void location::onsourcereassign(source *s) { if(s==src) { stale = true; src = NULL; } } void location::updatepos() { ASSERT(ref); // was: ASSERT(!stale && ref); if(stale) return; const vec &pos = ref->currentposition(); // forced fadeout radius bool volumeadjust = (cfg->model==soundconfig::DM_LINEAR); float forcedvol = 1.0f; if(volumeadjust) { float dist = camera1->o.dist(pos); if(dist>cfg->audibleradius) forcedvol = 0.0f; else if(dist<0) forcedvol = 1.0f; else forcedvol = 1.0f-(dist/cfg->audibleradius); } // reference determines the used model switch(ref->type) { case worldobjreference::WR_CAMERA: break; case worldobjreference::WR_PHYSENT: { if(!ref->nodistance()) src->position(pos); if(volumeadjust) setvolume(forcedvol); break; } case worldobjreference::WR_ENTITY: { entityreference &eref = *(entityreference *)ref; const float vol = eref.ent->attr4<=0.0f ? 1.0f : eref.ent->attr4/255.0f; float dist = camera1->o.dist(pos); if(ref->nodistance()) { // own distance model for entities/mapsounds: linear & clamping const float innerradius = float(eref.ent->attr3); // full gain area / size property const float outerradius = float(eref.ent->attr2); // fading gain area / radius property if(dist <= innerradius) src->gain(1.0f*vol); // inside full gain area else if(dist <= outerradius) // inside fading gain area { const float fadeoutdistance = outerradius-innerradius; const float fadeout = dist-innerradius; src->gain((1.0f - fadeout/fadeoutdistance)*vol); } else src->gain(0.0f); // outside entity } else { // use openal distance model to make the sound appear from a certain direction (non-ambient) src->position(pos); src->gain(vol); } break; } case worldobjreference::WR_STATICPOS: { if(!ref->nodistance()) src->position(pos); if(volumeadjust) setvolume(forcedvol); break; } } } void location::update() { if(stale) return; switch(src->state()) { case AL_PLAYING: updatepos(); break; case AL_STOPPED: case AL_PAUSED: case AL_INITIAL: stale = true; DEBUG("location is stale"); break; } } void location::play(bool loop) { if(stale) return; updatepos(); if(loop) src->looping(loop); if(src->play()) playmillis = totalmillis; } void location::pitch(float p) { if(stale) return; src->pitch(p); } bool location::setvolume(float v) { if(stale) return false; return src->gain(cfg->vol/100.0f*((float)gainscale)/100.0f*v); } void location::offset(float secs) { // ASSERT(!stale); if(stale) return; src->secoffset(secs); } float location::offset() { // ASSERT(!stale); if(stale) return 0.0f; return src->secoffset(); } void location::drop() { src->stop(); stale = true; // drop from collection on next update cycle } // location collection location *locvector::find(int sound, worldobjreference *ref, const vector &soundcollection /* = gamesounds*/) { if(sound<0 || sound>=soundcollection.length()) return NULL; loopi(ulen) if(buf[i] && !buf[i]->stale) { if(buf[i]->cfg != &soundcollection[sound]) continue; // check if its the same sound if(ref && *buf[i]->ref!=*ref) continue; // optionally check if its the same reference return buf[i]; // found } return NULL; } void locvector::delete_(int i) { delete remove(i); } void locvector::replaceworldobjreference(const worldobjreference &oldr, const worldobjreference &newr) { loopv(*this) { location *l = buf[i]; if(!l || !l->ref || l->stale) continue; if(*l->ref==oldr) l->attachworldobjreference(newr); } } // update stuff, remove stale data void locvector::updatelocations() { // check if camera carrier changed bool camchanged = false; static physent *lastcamera = NULL; if(lastcamera!=camera1) { if(lastcamera!=NULL) camchanged = true; lastcamera = camera1; } // update all locations loopv(*this) { location *l = buf[i]; if(!l) continue; l->update(); if(l->stale) delete_(i--); else if(camchanged) l->evaluateworldobjref(); // cam changed, evaluate world reference again } } // force pitch across all locations void locvector::forcepitch(float pitch) { loopv(*this) { location *l = buf[i]; if(!l) continue; if(l->src && l->src->locked) l->src->pitch(pitch); } } // delete all sounds except world-neutral sounds like GUI/notification void locvector::deleteworldobjsounds() { loopv(*this) { location *l = buf[i]; if(!l) continue; // world-neutral sounds if(l->cfg == &gamesounds[S_MENUENTER] || l->cfg == &gamesounds[S_MENUSELECT] || l->cfg == &gamesounds[S_CALLVOTE] || l->cfg == &gamesounds[S_VOTEPASS] || l->cfg == &gamesounds[S_VOTEFAIL]) continue; delete_(i--); } }; assaultcube-1.2.0.2.1/source/src/soundscheduler.cpp000066400000000000000000000100241352165075300221520ustar00rootroot00000000000000// AC sound scheduler, manages available sound sources. // It keeps a set of reserved sources for each priority level to avoid running out of sources by floods of low-priority sounds. // Under load it uses priority and distance information to reassign its resources. #include "cube.h" #define DEBUGCOND (audiodebug==1) VARP(soundschedpriorityscore, 0, 100, 1000); VARP(soundscheddistancescore, 0, 5, 1000); VARP(soundschedoldbonus, 0, 100, 1000); VARP(soundschedreserve, 0, 2, 100); sourcescheduler *sourcescheduler::inst; sourcescheduler::sourcescheduler() { } sourcescheduler &sourcescheduler::instance() { if(inst==NULL) inst = new sourcescheduler(); return *inst; } void sourcescheduler::init(int numsoundchannels) { this->numsoundchannels = numsoundchannels; int newchannels = numsoundchannels - sources.length(); if(newchannels < 0) { loopv(sources) { source *src = sources[i]; if(src->locked) continue; sources.remove(i--); delete src; if(sources.length() <= numsoundchannels) break; } } else loopi(newchannels) { source *src = new source(); if(src->valid) sources.add(src); else { DELETEP(src); break; } } } void sourcescheduler::reset() { loopv(sources) sources[i]->reset(); sources.deletecontents(); } // returns a free sound source (channel) // consuming code must call sourcescheduler::releasesource() after use source *sourcescheduler::newsource(int priority, const vec &o) { if(!sources.length()) { DEBUG("empty source collection"); return NULL; } source *src = NULL; // reserve some sources for sounds of higher priority int reserved = (SP_HIGHEST-priority)*soundschedreserve; DEBUGVAR(reserved); // search unused source loopv(sources) { if(!sources[i]->locked && reserved--<=0) { src = sources[i]; DEBUGVAR(src); break; } } if(!src) { DEBUG("no empty source found"); // low priority sounds can't replace others if(SP_LOW==priority) { DEBUG("low prio sound aborted"); return NULL; } // try replacing a used source // score our sound const float dist = o.iszero() ? 0.0f : camera1->o.dist(o); const float score = (priority*soundschedpriorityscore) - (dist*soundscheddistancescore); // score other sounds float worstscore = 0.0f; source *worstsource = NULL; loopv(sources) { source *s = sources[i]; if(s->priority==SP_HIGHEST) continue; // highest priority sounds can't be replaced const vec & otherpos = s->position(); float otherdist = otherpos.iszero() ? 0.0f : camera1->o.dist(otherpos); float otherscore = (s->priority*soundschedpriorityscore) - (otherdist*soundscheddistancescore) + soundschedoldbonus; if(!worstsource || otherscore < worstscore) { worstsource = s; worstscore = otherscore; } } // pick worst source and replace it if(worstsource && score>worstscore) { src = worstsource; src->onreassign(); // inform previous owner about the take-over DEBUG("replaced sound of same prio"); } } if(!src) { DEBUG("sound aborted, no channel takeover possible"); return NULL; } src->reset(); // default settings src->lock(); // exclusive lock src->priority = priority; return src; } // give source back to the pool void sourcescheduler::releasesource(source *src) { ASSERT(src); ASSERT(src->locked); // detect double release if(!src) return; DEBUG("unlocking source"); src->unlock(); if(sources.length() > numsoundchannels) { sources.removeobj(src); delete src; DEBUG("source deleted"); } } assaultcube-1.2.0.2.1/source/src/stream.cpp000066400000000000000000000736241352165075300204350ustar00rootroot00000000000000#include "cube.h" ///////////////////////// file system /////////////////////// #ifndef WIN32 #include #include #include #include #endif #pragma GCC diagnostic ignored "-Wdeprecated-declarations" string homedir = ""; vector packagedirs; char *makerelpath(const char *dir, const char *file, const char *prefix, const char *cmd) { static string tmp; if(prefix) copystring(tmp, prefix); else tmp[0] = '\0'; if(file[0]=='<') { const char *end = strrchr(file, '>'); if(end) { size_t len = strlen(tmp); copystring(&tmp[len], file, min(sizeof(tmp)-len, size_t(end+2-file))); file = end+1; } } if(cmd) concatstring(tmp, cmd); defformatstring(pname)("%s/%s", dir, file); concatstring(tmp, pname); return tmp; } char *path(char *s) { char *c = s; // skip "" if(c[0] == '<') { char *enddecal = strrchr(c, '>'); if(!enddecal) return s; c = enddecal + 1; } // substitute with single, proper path delimiters for(char *t = c; (t = strpbrk(t, "/\\")); ) { *t++ = PATHDIV; size_t d = strspn(t, "/\\"); if(d) memmove(t, t + d, strlen(t + d) + 1); // remove multiple path delimiters } // collapse ".."-parts for(char *prevdir = NULL, *curdir = s;;) { prevdir = curdir[0] == PATHDIV ? curdir + 1 : curdir; curdir = strchr(prevdir, PATHDIV); if(!curdir) break; if(prevdir + 1 == curdir && prevdir[0]=='.') { // simply remove "./" memmove(prevdir, curdir + 1, strlen(curdir)); curdir = prevdir; } else if(curdir[1] == '.' && curdir[2] == '.' && curdir[3] == PATHDIV) { // collapse "/foo/../" to "/" if(prevdir + 2 == curdir && prevdir[0] == '.' && prevdir[1] == '.') continue; // foo is also ".." -> skip memmove(prevdir, curdir + 4, strlen(curdir + 3)); if(prevdir >= c + 2 && prevdir[-1] == PATHDIV) { prevdir -= 2; while(prevdir > c && prevdir[-1] != PATHDIV) --prevdir; } curdir = prevdir; } } return s; } char *unixpath(char *s) { for(char *t = s; (t = strchr(t, '\\')); *t++ = '/'); return s; } char *path(const char *s, bool copy) { static string tmp; copystring(tmp, s); path(tmp); return tmp; } const char *parentdir(const char *directory) { const char *p = directory + strlen(directory); while(p > directory && *p != '/' && *p != '\\') p--; static string parent; size_t len = p-directory+1; copystring(parent, directory, len); return parent; } const char *behindpath(const char *s) { const char *t = s; for( ; (s = strpbrk(s, "/\\")); t = ++s); return t; } bool fileexists(const char *path, const char *mode) { bool exists = true; if(mode[0]=='w' || mode[0]=='a') path = parentdir(path); #ifdef WIN32 if(GetFileAttributes(path) == INVALID_FILE_ATTRIBUTES) exists = false; #else if(access(path, R_OK | (mode[0]=='w' || mode[0]=='a' ? W_OK : 0)) == -1) exists = false; #endif return exists; } bool createdir(const char *path) { size_t len = strlen(path); if(path[len-1]==PATHDIV) { static string strip; path = copystring(strip, path, len); } #ifdef WIN32 return CreateDirectory(path, NULL)!=0; #else return mkdir(path, 0777)==0; #endif } size_t fixpackagedir(char *dir) { path(dir); size_t len = strlen(dir); if(len > 0 && dir[len-1] != PATHDIV) { dir[len] = PATHDIV; dir[len+1] = '\0'; } return len; } #ifdef WIN32 char *getregszvalue(HKEY root, const char *keystr, const char *query) { HKEY key; if(RegOpenKeyEx(HKEY_CURRENT_USER, keystr, 0, KEY_READ, &key)==ERROR_SUCCESS) { DWORD type = 0, len = 0; if(RegQueryValueEx(key, query, 0, &type, 0, &len)==ERROR_SUCCESS && type==REG_SZ) { char *val = new char[len]; long result = RegQueryValueEx(key, query, 0, &type, (uchar *)val, &len); if(result==ERROR_SUCCESS) { RegCloseKey(key); val[len-1] = '\0'; return val; } delete[] val; } RegCloseKey(key); } return NULL; } #endif void sethomedir(const char *dir) { string tmpdir; copystring(tmpdir, dir); #ifdef WIN32 const char substitute[] = "?MYDOCUMENTS?"; if(!strncmp(dir, substitute, strlen(substitute))) { const char *regpath = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"; char *mydocuments = getregszvalue(HKEY_CURRENT_USER, regpath, "Personal"); if(mydocuments) { formatstring(tmpdir)("%s%s", mydocuments, dir+strlen(substitute)); delete[] mydocuments; } else { printf("failed to retrieve 'Personal' path from '%s'\n", regpath); } } #endif if(fixpackagedir(tmpdir) > 0) { #ifndef STANDALONE clientlogf("Using home directory: %s", tmpdir); #endif copystring(homedir, tmpdir); createdir(homedir); } } bool havehomedir() { return homedir[0] != '\0'; } void addpackagedir(const char *dir) { string pdir; copystring(pdir, dir); if(fixpackagedir(pdir) > 0) { #ifndef STANDALONE clientlogf("Adding package directory: %s", pdir); #endif packagedirs.add(newstring(pdir)); } } int findfilelocation; const char *findfile(const char *filename, const char *mode) { while(filename[0] == PATHDIV) filename++; // skip leading pathdiv while(!strncmp(".." PATHDIVS, filename, 3)) filename += 3; // skip leading "../" (don't allow access to files below "AC root dir") static string s; formatstring(s)("%s%s", homedir, filename); // homedir may be "" findfilelocation = FFL_HOME; if(homedir[0] && fileexists(s, mode)) return s; if(mode[0]=='w' || mode[0]=='a') { // create missing directories, if necessary string dirs; copystring(dirs, s); char *dir = strchr(dirs[0]==PATHDIV ? dirs+1 : dirs, PATHDIV); while(dir) { *dir = '\0'; if(!fileexists(dirs, "r") && !createdir(dirs)) return s; *dir = PATHDIV; dir = strchr(dir+1, PATHDIV); } return s; } findfilelocation = FFL_ZIP; #ifndef STANDALONE formatstring(s)("zip://%s", filename); if(findzipfile(filename)) return s; #endif loopv(packagedirs) { findfilelocation++; formatstring(s)("%s%s", packagedirs[i], filename); if(fileexists(s, mode)) return s; } findfilelocation = FFL_WORKDIR; return filename; } const char *stream_capabilities() { #if !defined(WIN32) && !defined(_DIRENT_HAVE_D_TYPE) return "no support for d_type, listing directories may be slow"; #else return ""; #endif } bool listsubdir(const char *dir, vector &subdirs) { #if defined(WIN32) defformatstring(pathname)("%s\\*", dir); WIN32_FIND_DATA FindFileData; HANDLE Find = FindFirstFile(path(pathname), &FindFileData); if(Find != INVALID_HANDLE_VALUE) { do { if((FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && FindFileData.cFileName[0] != '.') subdirs.add(newstring(FindFileData.cFileName)); } while(FindNextFile(Find, &FindFileData)); FindClose(Find); return true; } #else string pathname; copystring(pathname, dir); DIR *d = opendir(path(pathname)); if(d) { struct dirent *de, b; while(!readdir_r(d, &b, &de) && de != NULL) { #ifdef _DIRENT_HAVE_D_TYPE if(de->d_type == DT_DIR && de->d_name[0] != '.') subdirs.add(newstring(de->d_name)); else if(de->d_type == DT_UNKNOWN && de->d_name[0] != '.') #endif { struct stat s; int dl = (int)strlen(pathname); concatformatstring(pathname, "/%s", de->d_name); if(!lstat(pathname, &s) && S_ISDIR(s.st_mode) && de->d_name[0] != '.') subdirs.add(newstring(de->d_name)); pathname[dl] = '\0'; } } closedir(d); return true; } #endif else return false; } void listsubdirs(const char *dir, vector &subdirs, int (__cdecl *sf)(const char **, const char **)) { listsubdir(dir, subdirs); string s; if(homedir[0]) { formatstring(s)("%s%s", homedir, dir); listsubdir(s, subdirs); } loopv(packagedirs) { formatstring(s)("%s%s", packagedirs[i], dir); listsubdir(s, subdirs); } #ifndef STANDALONE listzipdirs(dir, subdirs); #endif subdirs.sort(sf); for(int i = subdirs.length() - 1; i > 0; i--) { // remove doubles if(!strcmp(subdirs[i], subdirs[i - 1])) delstring(subdirs.remove(i)); } } bool listdir(const char *dir, const char *ext, vector &files) { int extsize = ext ? (int)strlen(ext)+1 : 0; #if defined(WIN32) defformatstring(pathname)("%s\\*.%s", dir, ext ? ext : "*"); WIN32_FIND_DATA FindFileData; HANDLE Find = FindFirstFile(path(pathname), &FindFileData); if(Find != INVALID_HANDLE_VALUE) { do { if(!(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) files.add(newstring(FindFileData.cFileName, (int)strlen(FindFileData.cFileName) - extsize)); } while(FindNextFile(Find, &FindFileData)); FindClose(Find); return true; } #else string pathname; copystring(pathname, dir); DIR *d = opendir(path(pathname)); if(d) { struct dirent *de, b; while(!readdir_r(d, &b, &de) && de != NULL) { bool isreg = false; #ifdef _DIRENT_HAVE_D_TYPE if(de->d_type == DT_REG) isreg = true; else if(de->d_type == DT_UNKNOWN) #endif { struct stat s; int dl = (int)strlen(pathname); concatformatstring(pathname, "/%s", de->d_name); isreg = !lstat(pathname, &s) && S_ISREG(s.st_mode); pathname[dl] = '\0'; } if(isreg) { if(!ext) files.add(newstring(de->d_name)); else { int namelength = (int)strlen(de->d_name) - extsize; if(namelength > 0 && de->d_name[namelength] == '.' && strncmp(de->d_name+namelength+1, ext, extsize-1)==0) files.add(newstring(de->d_name, namelength)); } } } closedir(d); return true; } #endif else return false; } void listfiles(const char *dir, const char *ext, vector &files, int (__cdecl *sf)(const char **, const char **)) { listdir(dir, ext, files); string s; if(homedir[0]) { formatstring(s)("%s%s", homedir, dir); listdir(s, ext, files); } loopv(packagedirs) { formatstring(s)("%s%s", packagedirs[i], dir); listdir(s, ext, files); } #ifndef STANDALONE listzipfiles(dir, ext, files); #endif if(sf) { // sort and remove doubles files.sort(sf); for(int i = files.length() - 1; i > 0; i--) { if(!strcmp(files[i], files[i - 1])) delstring(files.remove(i)); } } } #ifndef STANDALONE void listfilesrecursive(const char *dir, vector &files, int level) { if(level > 8) return; // 8 levels is insane enough... vector dirs, thisdir; listsubdirs(dir, dirs, stringsort); loopv(dirs) { if(dirs[i][0] != '.') // ignore "." and ".." (and also other directories starting with '.', like it is unix-convention - and doesn't hurt on windows) { defformatstring(name)("%s/%s", dir, dirs[i]); listfilesrecursive(name, files, level + 1); } delstring(dirs[i]); } listfiles(dir, NULL, thisdir); loopv(thisdir) { defformatstring(name)("%s/%s", dir, thisdir[i]); files.add(newstring(name)); delstring(thisdir[i]); } } void listdirsrecursive(const char *dir, vector &subdirs, int level) { if(level > 8) return; // 8 levels is insane enough... vector dirs; listsubdirs(dir, dirs, stringsort); loopv(dirs) { if(dirs[i][0] != '.') // ignore "." and ".." (and also other directories starting with '.', like it is unix-convention - and doesn't hurt on windows) { defformatstring(name)("%s/%s", dir, dirs[i]); subdirs.add(newstring(name)); listdirsrecursive(name, subdirs, level + 1); } delstring(dirs[i]); } } #endif bool delfile(const char *path) { return strncmp(path, "zip://", 6) ? !remove(path) : false; } void backup(char *name, char *backupname) { string backupfile; copystring(backupfile, findfile(backupname, "wb")); remove(backupfile); rename(findfile(name, "wb"), backupfile); } #ifndef STANDALONE static Sint64 rwopsseek(SDL_RWops *rw, Sint64 offset, int whence) { stream *f = (stream *)rw->hidden.unknown.data1; if((!offset && whence==SEEK_CUR) || f->seek(offset, whence)) return f->tell(); return -1; } static size_t rwopsread(SDL_RWops *rw, void *buf, size_t size, size_t nmemb) { stream *f = (stream *)rw->hidden.unknown.data1; return f->read(buf, size*nmemb)/size; } static size_t rwopswrite(SDL_RWops *rw, const void *buf, size_t size, size_t nmemb) { stream *f = (stream *)rw->hidden.unknown.data1; return f->write(buf, size*nmemb)/size; } static int rwopsclose(SDL_RWops *rw) { return 0; } SDL_RWops *stream::rwops() { SDL_RWops *rw = SDL_AllocRW(); if(!rw) return NULL; rw->hidden.unknown.data1 = this; rw->seek = rwopsseek; rw->read = rwopsread; rw->write = rwopswrite; rw->close = rwopsclose; return rw; } #endif long stream::size() { long pos = tell(), endpos; if(pos < 0 || !seek(0, SEEK_END)) return -1; endpos = tell(); return pos == endpos || seek(pos, SEEK_SET) ? endpos : -1; } bool stream::getline(char *str, int len) { loopi(len-1) { if(read(&str[i], 1) != 1) { str[i] = '\0'; return i > 0; } else if(str[i] == '\n') { str[i+1] = '\0'; return true; } } if(len > 0) str[len-1] = '\0'; return true; } #ifndef WIN32 #include const int64_t MINFSSIZE = 50000000; // 50MB #endif struct filestream : stream { FILE *file; filestream() : file(NULL) {} ~filestream() { close(); } bool open(const char *name, const char *mode) { if(file) return false; file = fopen(name, mode); #ifndef WIN32 struct statvfs buf; if(file && strchr(mode,'w')) { int fail = fstatvfs(fileno(file), &buf); if (fail || (int64_t)buf.f_frsize * (int64_t)buf.f_bavail < MINFSSIZE) { close(); return false; } } #endif return file!=NULL; } bool opentemp(const char *name, const char *mode) { if(file) return false; #ifdef WIN32 file = fopen(name, mode); #else file = tmpfile(); #endif return file!=NULL; } void close() { if(file) { fclose(file); file = NULL; } } bool end() { return feof(file)!=0; } long tell() { return ftell(file); } bool seek(long offset, int whence) { return fseek(file, offset, whence) >= 0; } void fflush() { if(file) ::fflush(file); } int read(void *buf, int len) { return (int)fread(buf, 1, len, file); } int write(const void *buf, int len) { return (int)fwrite(buf, 1, len, file); } int getchar() { return fgetc(file); } bool putchar(int c) { return fputc(c, file)!=EOF; } bool getline(char *str, int len) { return fgets(str, len, file)!=NULL; } bool putstring(const char *str) { return fputs(str, file)!=EOF; } int printf(const char *fmt, ...) { va_list v; va_start(v, fmt); int result = vfprintf(file, fmt, v); va_end(v); return result; } }; #ifndef STANDALONE //VAR(dbggz, 0, 0, 1); const int dbggz = 0; #endif struct gzstream : stream { enum { MAGIC1 = 0x1F, MAGIC2 = 0x8B, BUFSIZE = 16384, OS_UNIX = 0x03 }; enum { F_ASCII = 0x01, F_CRC = 0x02, F_EXTRA = 0x04, F_NAME = 0x08, F_COMMENT = 0x10, F_RESERVED = 0xE0 }; stream *file; z_stream zfile; uchar *buf; bool reading, writing, autoclose; uint crc; int headersize; gzstream() : file(NULL), buf(NULL), reading(false), writing(false), autoclose(false), crc(0), headersize(0) { zfile.zalloc = NULL; zfile.zfree = NULL; zfile.opaque = NULL; zfile.next_in = zfile.next_out = NULL; zfile.avail_in = zfile.avail_out = 0; } ~gzstream() { close(); } void writeheader() { uchar header[] = { MAGIC1, MAGIC2, Z_DEFLATED, 0, 0, 0, 0, 0, 0, OS_UNIX }; file->write(header, sizeof(header)); } void readbuf(int size = BUFSIZE) { if(!zfile.avail_in) zfile.next_in = (Bytef *)buf; size = min(size, int(&buf[BUFSIZE] - &zfile.next_in[zfile.avail_in])); int n = file->read(zfile.next_in + zfile.avail_in, size); if(n > 0) zfile.avail_in += n; } int readbyte(int size = BUFSIZE) { if(!zfile.avail_in) readbuf(size); if(!zfile.avail_in) return 0; zfile.avail_in--; return *(uchar *)zfile.next_in++; } void skipbytes(int n) { while(n > 0 && zfile.avail_in > 0) { int skipped = min(n, (int)zfile.avail_in); zfile.avail_in -= skipped; zfile.next_in += skipped; n -= skipped; } if(n <= 0) return; file->seek(n, SEEK_CUR); } bool checkheader() { readbuf(10); if(readbyte() != MAGIC1 || readbyte() != MAGIC2 || readbyte() != Z_DEFLATED) return false; int flags = readbyte(); if(flags & F_RESERVED) return false; skipbytes(6); if(flags & F_EXTRA) { int len = readbyte(512); len |= readbyte(512)<<8; skipbytes(len); } if(flags & F_NAME) while(readbyte(512)); if(flags & F_COMMENT) while(readbyte(512)); if(flags & F_CRC) skipbytes(2); headersize = file->tell() - zfile.avail_in; return zfile.avail_in > 0 || !file->end(); } bool open(stream *f, const char *mode, bool needclose, int level) { if(file) return false; for(; *mode; mode++) { if(*mode=='r') { reading = true; break; } else if(*mode=='w') { writing = true; break; } } if(reading) { if(inflateInit2(&zfile, -MAX_WBITS) != Z_OK) reading = false; } else if(writing && deflateInit2(&zfile, level, Z_DEFLATED, -MAX_WBITS, min(MAX_MEM_LEVEL, 8), Z_DEFAULT_STRATEGY) != Z_OK) writing = false; if(!reading && !writing) return false; autoclose = needclose; file = f; crc = crc32(0, NULL, 0); buf = new uchar[BUFSIZE]; if(reading) { if(!checkheader()) { stopreading(); file = NULL; return false; } } else if(writing) writeheader(); return true; } uint getcrc() { return crc; } void finishreading() { if(!reading) return; #ifndef STANDALONE if(dbggz) { uint checkcrc = 0, checksize = 0; loopi(4) checkcrc |= uint(readbyte()) << (i*8); loopi(4) checksize |= uint(readbyte()) << (i*8); if(checkcrc != crc) conoutf("gzip crc check failed: read %X, calculated %X", checkcrc, crc); if(checksize != zfile.total_out) conoutf("gzip size check failed: read %u, calculated %u", checksize, (uint) zfile.total_out); } #endif } void stopreading() { if(!reading) return; inflateEnd(&zfile); reading = false; } void finishwriting() { if(!writing) return; for(;;) { int err = zfile.avail_out > 0 ? deflate(&zfile, Z_FINISH) : Z_OK; if(err != Z_OK && err != Z_STREAM_END) break; flush(); if(err == Z_STREAM_END) break; } uchar trailer[8] = { uchar(crc&0xFF), uchar((crc>>8)&0xFF), uchar((crc>>16)&0xFF), uchar((crc>>24)&0xFF), uchar(zfile.total_in&0xFF), uchar((zfile.total_in>>8)&0xFF), uchar((zfile.total_in>>16)&0xFF), uchar((zfile.total_in>>24)&0xFF) }; file->write(trailer, sizeof(trailer)); } void stopwriting() { if(!writing) return; deflateEnd(&zfile); writing = false; } void close() { if(reading) finishreading(); stopreading(); if(writing) finishwriting(); stopwriting(); DELETEA(buf); if(autoclose) DELETEP(file); } bool end() { return !reading && !writing; } long tell() { return reading ? zfile.total_out : (writing ? zfile.total_in : -1); } bool seek(long offset, int whence) { if(writing || !reading) return false; if(whence == SEEK_END) { uchar skip[512]; while(read(skip, sizeof(skip)) == sizeof(skip)); return !offset; } else if(whence == SEEK_CUR) offset += zfile.total_out; if(offset >= (int)zfile.total_out) offset -= zfile.total_out; else if(offset < 0 || !file->seek(headersize, SEEK_SET)) return false; else { if(zfile.next_in && zfile.total_in <= uint(zfile.next_in - buf)) { zfile.avail_in += zfile.total_in; zfile.next_in -= zfile.total_in; } else { zfile.avail_in = 0; zfile.next_in = NULL; } inflateReset(&zfile); crc = crc32(0, NULL, 0); } uchar skip[512]; while(offset > 0) { int skipped = min(offset, (long)sizeof(skip)); if(read(skip, skipped) != skipped) { stopreading(); return false; } offset -= skipped; } return true; } int read(void *buf, int len) { if(!reading || !buf || !len) return 0; zfile.next_out = (Bytef *)buf; zfile.avail_out = len; while(zfile.avail_out > 0) { if(!zfile.avail_in) { readbuf(BUFSIZE); if(!zfile.avail_in) { stopreading(); break; } } int err = inflate(&zfile, Z_NO_FLUSH); if(err == Z_STREAM_END) { crc = crc32(crc, (Bytef *)buf, len - zfile.avail_out); finishreading(); stopreading(); return len - zfile.avail_out; } else if(err != Z_OK) { stopreading(); break; } } crc = crc32(crc, (Bytef *)buf, len - zfile.avail_out); return len - zfile.avail_out; } bool flush() { if(zfile.next_out && zfile.avail_out < BUFSIZE) { if(file->write(buf, BUFSIZE - zfile.avail_out) != int(BUFSIZE - zfile.avail_out)) return false; } zfile.next_out = buf; zfile.avail_out = BUFSIZE; return true; } int write(const void *buf, int len) { if(!writing || !buf || !len) return 0; zfile.next_in = (Bytef *)buf; zfile.avail_in = len; while(zfile.avail_in > 0) { if(!zfile.avail_out && !flush()) { stopwriting(); break; } int err = deflate(&zfile, Z_NO_FLUSH); if(err != Z_OK) { stopwriting(); break; } } crc = crc32(crc, (Bytef *)buf, len - zfile.avail_in); return len - zfile.avail_in; } }; struct vecstream : stream { vector *data; int pointer; bool autodelete; vecstream(vector *s, bool autodelete) : data(s), pointer(0), autodelete(autodelete) {} ~vecstream() { if(autodelete) { DELETEP(data); } } void close() { DELETEP(data); } bool end() { return data ? pointer >= data->length() : true; } long tell() { return data ? pointer : -1; } long size() { return data ? data->length() : -1; } bool seek(long offset, int whence) { int newpointer = -1; if(data) switch(whence) { case SEEK_SET: newpointer = 0; break; case SEEK_CUR: newpointer = pointer; break; case SEEK_END: newpointer = data->length(); break; } if(newpointer >= 0) newpointer += offset; if(newpointer >= 0 && data && newpointer <= data->length()) { pointer = newpointer; return true; } return false; } int read(void *buf, int len) { int got = 0; if(data && data->inrange(pointer)) { got = min(len, data->length() - pointer); memcpy(buf, data->getbuf() + pointer, got); pointer += got; } return got; } int write(const void *buf, int len) { if(data) { while(data->length() < pointer + len) data->add(0); memcpy(data->getbuf() + pointer, buf, len); pointer += len; } else len = 0; return len; } int printf(const char *fmt, ...) // limited to MAXSTRLEN { int len = 0; if(data) { defvformatstring(temp, fmt, fmt); len = strlen(temp); if(len) data->put((uchar *)temp, len); } return len; } }; struct memstream : stream { const uchar *data; int memsize; int pointer; int *refcount; memstream(const uchar *s, int size, int *refcnt) : data(s), memsize(size), pointer(0), refcount(refcnt) { if(refcnt) (*refcnt)++; } ~memstream() { close(); } void close() { if(data && refcount) { (*refcount)--; data = NULL; } else DELETEA(data); memsize = -1; } bool end() { return data ? pointer >= memsize : true; } long tell() { return data ? pointer : -1; } long size() { return data ? memsize : -1; } bool seek(long offset, int whence) { int newpointer = -1; if(data) switch(whence) { case SEEK_SET: newpointer = 0; break; case SEEK_CUR: newpointer = pointer; break; case SEEK_END: newpointer = memsize; break; } if(newpointer >= 0) newpointer += offset; if(newpointer >= 0 && newpointer <= memsize) { pointer = newpointer; return true; } return false; } int read(void *buf, int len) { int got = 0; if(data && pointer >= 0 && pointer < memsize) { got = min(len, memsize - pointer); memcpy(buf, data + pointer, got); pointer += got; } return got; } }; stream *openvecfile(vector *s, bool autodelete) { return new vecstream(s ? s : new vector, autodelete); } stream *openmemfile(const uchar *buf, int size, int *refcnt) { return new memstream(buf, size, refcnt); } stream *openrawfile(const char *filename, const char *mode) { #ifndef STANDALONE if(mode && (mode[0]=='w' || mode[0]=='a')) conoutf("writing to file: %s", filename); #endif if(!strncmp(filename, "zip://", 6)) return NULL; filestream *file = new filestream; if(!file->open(filename, mode)) { #ifndef STANDALONE // conoutf("file failure! %s",filename); #endif delete file; return NULL; } return file; } stream *openfile(const char *filename, const char *mode) { const char *found = findfile(filename, mode); #ifndef STANDALONE if(!strncmp(found, "zip://", 6)) return openzipfile(found + 6, mode); #endif return openrawfile(found, mode); } int getfilesize(const char *filename) { stream *f = openfile(filename, "rb"); if(!f) return -1; int len = f->size(); delete f; return len; } stream *opentempfile(const char *name, const char *mode) { const char *found = findfile(name, mode); filestream *file = new filestream; if(!file->opentemp(found ? found : name, mode)) { delete file; return NULL; } return file; } stream *opengzfile(const char *filename, const char *mode, stream *file, int level) { stream *source = file ? file : openfile(filename, mode); if(!source) return NULL; gzstream *gz = new gzstream; if(!gz->open(source, mode, !file, level)) { if(!file) delete source; delete gz; return NULL; } return gz; } char *loadfile(const char *fn, int *size, const char *mode) { stream *f = openfile(fn, mode ? mode : "rb"); if(!f) return NULL; int len = f->size(); if(len<=0) { delete f; return NULL; } char *buf = new char[len+1]; if(!buf) { delete f; return NULL; } buf[len] = 0; int rlen = f->read(buf, len); delete f; if(len!=rlen && (!mode || strchr(mode, 'b'))) { delete[] buf; return NULL; } if(size!=NULL) *size = len; return buf; } int streamcopy(stream *dest, stream *source, int maxlen) { int got = 0, len; uchar copybuf[1024]; while(got < maxlen && (len = source->read(copybuf, 1024))) got += dest->write(copybuf, len); return got; } #ifndef STANDALONE void filerotate(const char *basename, const char *ext, int keepold, const char *oldformat) // rotate old logfiles { char fname1[MAXSTRLEN * 2], fname2[MAXSTRLEN] = ""; copystring(fname1, findfile(basename, "w")); int mid = strlen(fname1); if(!oldformat) oldformat = "-old-%d"; for(; keepold >= 0; keepold--) { formatstring(fname1 + mid)(keepold ? oldformat : "", keepold); concatformatstring(fname1 + mid, ".%s", ext); if(fname2[0]) rename(fname1, fname2); else remove(fname1); copystring(fname2, fname1); } } #endif assaultcube-1.2.0.2.1/source/src/texture.cpp000066400000000000000000001217771352165075300206450ustar00rootroot00000000000000// texture.cpp: texture management #include "cube.h" #define FUNCNAME(name) name##1 #define DEFPIXEL uint OP(r, 0); #define PIXELOP OP(r, 0); #define BPP 1 #include "scale.h" #define FUNCNAME(name) name##2 #define DEFPIXEL uint OP(r, 0), OP(g, 1); #define PIXELOP OP(r, 0); OP(g, 1); #define BPP 2 #include "scale.h" #define FUNCNAME(name) name##3 #define DEFPIXEL uint OP(r, 0), OP(g, 1), OP(b, 2); #define PIXELOP OP(r, 0); OP(g, 1); OP(b, 2); #define BPP 3 #include "scale.h" #define FUNCNAME(name) name##4 #define DEFPIXEL uint OP(r, 0), OP(g, 1), OP(b, 2), OP(a, 3); #define PIXELOP OP(r, 0); OP(g, 1); OP(b, 2); OP(a, 3); #define BPP 4 #include "scale.h" void scaletexture(uchar *src, uint sw, uint sh, uint bpp, uchar *dst, uint dw, uint dh) { if(sw == dw*2 && sh == dh*2) { switch(bpp) { case 1: return halvetexture1(src, sw, sh, dst); case 2: return halvetexture2(src, sw, sh, dst); case 3: return halvetexture3(src, sw, sh, dst); case 4: return halvetexture4(src, sw, sh, dst); } } else if(sw < dw || sh < dh || sw&(sw-1) || sh&(sh-1)) { switch(bpp) { case 1: return scaletexture1(src, sw, sh, dst, dw, dh); case 2: return scaletexture2(src, sw, sh, dst, dw, dh); case 3: return scaletexture3(src, sw, sh, dst, dw, dh); case 4: return scaletexture4(src, sw, sh, dst, dw, dh); } } else { switch(bpp) { case 1: return shifttexture1(src, sw, sh, dst, dw, dh); case 2: return shifttexture2(src, sw, sh, dst, dw, dh); case 3: return shifttexture3(src, sw, sh, dst, dw, dh); case 4: return shifttexture4(src, sw, sh, dst, dw, dh); } } } Texture *notexture = NULL, *noworldtexture = NULL; #define TEXSCALEPREFIXSIZE 8 hashtable textures; VAR(hwtexsize, 1, 0, 0); VAR(hwmaxaniso, 1, 0, 0); VARFP(maxtexsize, 0, 0, 1<<12, initwarning("texture quality", INIT_LOAD)); VARFP(texreduce, -1, 0, 3, initwarning("texture quality", INIT_LOAD)); VARFP(trilinear, 0, 1, 1, initwarning("texture filtering", INIT_LOAD)); VARFP(bilinear, 0, 1, 1, initwarning("texture filtering", INIT_LOAD)); VARFP(aniso, 0, 0, 16, initwarning("texture filtering", INIT_LOAD)); int formatsize(GLenum format) { switch(format) { case GL_LUMINANCE: case GL_ALPHA: return 1; case GL_LUMINANCE_ALPHA: return 2; case GL_RGB: return 3; case GL_RGBA: return 4; default: return 4; } } void resizetexture(int w, int h, bool mipmap, bool canreduce, GLenum target, int &tw, int &th) { int hwlimit = hwtexsize, sizelimit = mipmap && maxtexsize ? min(maxtexsize, hwlimit) : hwlimit; if(canreduce && texreduce) { if(texreduce==-1) { w = 2; h = 2; } else { w = max(w>>texreduce, 2); // 1); h = max(h>>texreduce, 2); // 1); } } w = min(w, sizelimit); h = min(h, sizelimit); if(mipmap || w&(w-1) || h&(h-1)) { tw = th = 1; while(tw < w) tw *= 2; while(th < h) th *= 2; if(w < tw - tw/4) tw /= 2; if(h < th - th/4) th /= 2; } else { tw = w; th = h; } } void uploadtexture(GLenum target, GLenum internal, int tw, int th, GLenum format, GLenum type, void *pixels, int pw, int ph, bool mipmap) { int bpp = formatsize(format); uchar *buf = NULL; if(pw!=tw || ph!=th) { buf = new uchar[tw*th*bpp]; scaletexture((uchar *)pixels, pw, ph, bpp, buf, tw, th); } glPixelStorei(GL_UNPACK_ALIGNMENT, 1); for(int level = 0;; level++) { uchar *src = buf ? buf : (uchar *)pixels; glTexImage2D(target, level, internal, tw, th, 0, format, type, src); if(!mipmap || max(tw, th) <= 1) break; int srcw = tw, srch = th; if(tw > 1) tw /= 2; if(th > 1) th /= 2; if(!buf) buf = new uchar[tw*th*bpp]; scaletexture(src, srcw, srch, bpp, buf, tw, th); } if(buf) delete[] buf; } void createtexture(int tnum, int w, int h, void *pixels, int clamp, bool mipmap, bool canreduce, GLenum format) { glBindTexture(GL_TEXTURE_2D, tnum); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, clamp&1 ? GL_CLAMP_TO_EDGE : GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, clamp&2 ? GL_CLAMP_TO_EDGE : GL_REPEAT); if(hasAF && min(aniso, hwmaxaniso) > 0 && mipmap) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, min(aniso, hwmaxaniso)); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, bilinear ? GL_LINEAR : GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, mipmap ? (trilinear ? (bilinear ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_LINEAR) : (bilinear ? GL_LINEAR_MIPMAP_NEAREST : GL_NEAREST_MIPMAP_NEAREST)) : (bilinear ? GL_LINEAR : GL_NEAREST)); int tw = w, th = h; if(pixels) resizetexture(w, h, mipmap, canreduce, GL_TEXTURE_2D, tw, th); uploadtexture(GL_TEXTURE_2D, format, tw, th, format, GL_UNSIGNED_BYTE, pixels, w, h, mipmap); } #if SDL_BYTEORDER == SDL_BIG_ENDIAN #define RGBAMASKS 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff #define RGBMASKS 0xff0000, 0x00ff00, 0x0000ff, 0 #else #define RGBAMASKS 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 #define RGBMASKS 0x0000ff, 0x00ff00, 0xff0000, 0 #endif SDL_Surface *wrapsurface(void *data, int width, int height, int bpp) { switch(bpp) { case 3: return SDL_CreateRGBSurfaceFrom(data, width, height, 8*bpp, bpp*width, RGBMASKS); case 4: return SDL_CreateRGBSurfaceFrom(data, width, height, 8*bpp, bpp*width, RGBAMASKS); } return NULL; } SDL_Surface *creatergbsurface(int width, int height) { return SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 24, RGBMASKS); } SDL_Surface *creatergbasurface(int width, int height) { return SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, RGBAMASKS); } SDL_Surface *forcergbsurface(SDL_Surface *os) { SDL_Surface *ns = SDL_CreateRGBSurface(SDL_SWSURFACE, os->w, os->h, 24, RGBMASKS); if(ns) SDL_BlitSurface(os, NULL, ns, NULL); SDL_FreeSurface(os); return ns; } SDL_Surface *forcergbasurface(SDL_Surface *os) { SDL_Surface *ns = SDL_CreateRGBSurface(SDL_SWSURFACE, os->w, os->h, 32, RGBAMASKS); if(ns) { SDL_SetSurfaceAlphaMod(os, SDL_ALPHA_OPAQUE); SDL_BlitSurface(os, NULL, ns, NULL); } SDL_FreeSurface(os); return ns; } bool checkgrayscale(SDL_Surface *s) { // gray scale images have 256 levels, no colorkey, and the palette is a ramp if(s->format->palette) { Uint32 ck = 0; if(s->format->palette->ncolors != 256 || SDL_GetColorKey(s, &ck) == -1) return false; const SDL_Color *colors = s->format->palette->colors; loopi(256) if(colors[i].r != i || colors[i].g != i || colors[i].b != i) return false; } return true; } int fixcl(SDL_Surface *s, int threshold) { if(!s || !s->h || !s->w) return 0; int sum = 0, w, a0 = *((uchar *) &s->format->Amask) ? 1 : 0; if(s->format->palette || s->format->BytesPerPixel < 3) s = (SDL_Surface *)s->pixels; for(int y = 0; y < s->h; y++) { uchar *pix = ((uchar *)s->pixels) + y * s->pitch + a0; w = 0; for(int x = 0; x < s->w; x++) { w += iabs(((pix[0] * pix[0]) | (pix[1] * pix[1]) | (pix[2] * pix[2])) - ((pix[0] * pix[1] * pix[2]) / 222)); pix += s->format->BytesPerPixel; } sum += w / s->w; } sum = sqrtf(sum / s->h); int t = sum / threshold + 1; if(t > 1) for(int y = 0; y < s->h; y++) { uchar *pix = ((uchar *)s->pixels) + y * s->pitch + a0; for(int x = 0; x < s->w; x++) { loopi(3) pix[i] /= t; pix += s->format->BytesPerPixel; } } return t; } SDL_Surface *fixsurfaceformat(SDL_Surface *s) { if(!s) return NULL; if(!s->pixels || min(s->w, s->h) <= 0 || s->format->BytesPerPixel <= 0) { SDL_FreeSurface(s); return NULL; } static const uint rgbmasks[] = { RGBMASKS }, rgbamasks[] = { RGBAMASKS }; switch(s->format->BytesPerPixel) { case 1: if(!checkgrayscale(s)) { Uint32 ck; SDL_GetColorKey(s, &ck); return ck ? forcergbasurface(s) : forcergbsurface(s); } break; case 3: if(s->format->Rmask != rgbmasks[0] || s->format->Gmask != rgbmasks[1] || s->format->Bmask != rgbmasks[2]) return forcergbsurface(s); break; case 4: if(s->format->Rmask != rgbamasks[0] || s->format->Gmask != rgbamasks[1] || s->format->Bmask != rgbamasks[2] || s->format->Amask != rgbamasks[3]) return s->format->Amask ? forcergbasurface(s) : forcergbsurface(s); break; } return s; } GLenum texformat(int bpp) { switch(bpp) { case 8: return GL_LUMINANCE; case 16: return GL_LUMINANCE_ALPHA; case 24: return GL_RGB; case 32: return GL_RGBA; default: return 0; } } SDL_Surface *texdecal(SDL_Surface *s) { SDL_Surface *m = SDL_CreateRGBSurface(SDL_SWSURFACE, s->w, s->h, 16, 0, 0, 0, 0); if(!m) fatal("create surface"); uchar *dst = (uchar *)m->pixels, *src = (uchar *)s->pixels; loopi(s->h*s->w) { *dst++ = *src; *dst++ = 255 - *src; src += s->format->BytesPerPixel; } SDL_FreeSurface(s); return m; } void scalesurface(SDL_Surface *s, float scale) { uint dw = s->w*scale, dh = s->h*scale; uchar *buf = new uchar[dw*dh*s->format->BytesPerPixel]; scaletexture((uchar *)s->pixels, s->w, s->h, s->format->BytesPerPixel, buf, dw, dh); delete[] (uchar *)s->pixels; s->w = dw; s->h = dh; s->pixels = buf; } bool silent_texture_load = false; VARFP(hirestextures, 0, 1, 1, initwarning("texture resolution", INIT_LOAD)); bool uniformtexres = !hirestextures; GLuint loadsurface(const char *texname, int &xs, int &ys, int &bpp, int clamp = 0, bool mipmap = true, bool canreduce = false, float scale = 1.0f, bool trydl = false) { const char *file = texname; if(texname[0]=='<') { file = strchr(texname, '>'); if(!file) { if(!silent_texture_load) conoutf("could not load texture %s", texname); return 0; } file++; } SDL_Surface *s = NULL; const char *ffile = findfile(file, "rb"); if(findfilelocation == FFL_ZIP) { stream *z = openzipfile(file, "rb"); if(z) { SDL_RWops *rw = z->rwops(); if(rw) { s = IMG_Load_RW(rw, 0); SDL_FreeRW(rw); } delete z; } } else if(!s) s = IMG_Load(ffile); if(!s) { if(trydl) requirepackage(PCK_TEXTURE, file); else if(!silent_texture_load) conoutf("couldn't load texture %s", texname); return 0; } s = fixsurfaceformat(s); if(strstr(texname,"playermodel")) { fixcl(s, 45); } else if(strstr(texname,"skin") && strstr(texname,"weapon")) { fixcl(s, 44); } GLenum format = texformat(s->format->BitsPerPixel); if(!format) { SDL_FreeSurface(s); conoutf("texture must be 8, 16, 24, or 32 bpp: %s", texname); return 0; } if(max(s->w, s->h) > (1<<12)) { SDL_FreeSurface(s); conoutf("texture size exceeded %dx%d pixels: %s", 1<<12, 1<<12, texname); return 0; } if(texname[0]=='<') { const char *cmd = &texname[1], *arg1 = strchr(cmd, ':');//, *arg2 = arg1 ? strchr(arg1, ',') : NULL; if(!arg1) arg1 = strchr(cmd, '>'); if(!strncmp(cmd, "decal", arg1-cmd)) { s = texdecal(s); format = texformat(s->format->BitsPerPixel); } } if(uniformtexres && scale > 1.0f) scalesurface(s, 1.0f/scale); GLuint tnum; glGenTextures(1, &tnum); createtexture(tnum, s->w, s->h, s->pixels, clamp, mipmap, canreduce, format); xs = s->w; ys = s->h; bpp = s->format->BitsPerPixel; SDL_FreeSurface(s); return tnum; } // management of texture slots // each texture slot can have multiple texture frames, of which currently only the first is used // additional frames can be used for various shaders Texture *textureload(const char *name, int clamp, bool mipmap, bool canreduce, float scale, bool trydl) { defformatstring(pname)("%.7g ", scale); copystring(pname + TEXSCALEPREFIXSIZE, name, MAXSTRLEN - TEXSCALEPREFIXSIZE); path(pname + TEXSCALEPREFIXSIZE); Texture *t = textures.access(pname); if(t) return t; int xs, ys, bpp; GLuint id = loadsurface(pname + TEXSCALEPREFIXSIZE, xs, ys, bpp, clamp, mipmap, canreduce, scale, trydl); if(!id) return notexture; char *key = newstring(pname); t = &textures[key]; t->name = key + TEXSCALEPREFIXSIZE; t->xs = xs; t->ys = ys; t->bpp = bpp; t->clamp = clamp; t->mipmap = mipmap; t->canreduce = canreduce; t->id = id; t->scale = scale; return t; } struct Slot { string name; float scale, orgscale; Texture *tex; bool loaded; }; vector slots; COMMANDF(texturereset, "", () { if(execcontext==IEXC_MAPCFG) slots.setsize(0); }); void _texture(Slot &s, float *scale, char *name) { if(name) { filtertext(s.name, parentdir(name), FTXT__MEDIAFILEPATH); // filter parts separately, because filename may (legally) contain "" if(s.name[0] == '.' && s.name[1] == '/') memmove(s.name, s.name + 2, sizeof(s.name) - 2); if(*s.name) concatstring(s.name, "/"); name = (char *)behindpath(name); if(*name == '<') { char *endcmd = strchr(name, '>'); if(endcmd) { *endcmd = '\0'; concatstring(s.name, name); concatstring(s.name, ">"); name = endcmd + 1; } } filtertext(name, name, FTXT__MEDIAFILENAME); concatstring(s.name, name); } s.tex = NULL; s.loaded = false; if(scale) { s.orgscale = *scale; s.scale = (*scale > 0 && *scale <= 4.0f) ? *scale : 1.0f; } } void checktexturefilename(const char *name) { if(execcontext == IEXC_MAPCFG && strstr(name, "map_editor")) { conoutf("\f3bad texture: %s", name); if(!_ignoreillegalpaths) { flagmapconfigerror(LWW_CONFIGERR * 4); scripterr(); } } } COMMANDF(texture, "fs", (float *scale, char *name) { intret(slots.length()); Slot &s = slots.add(); _texture(s, scale, name); if(*scale < 0.0f || *scale > 4.0f) { conoutf("\f3texture slot #%d \"%s\" error: scale factor %.7g out of range 0..4", slots.length() - 1, name, *scale); flagmapconfigerror(LWW_CONFIGERR * 4); scripterr(); } checktexturefilename(name); flagmapconfigchange(); }); const char *gettextureslot(int i) { static string res; if(slots.inrange(i)) { Slot &s = slots[i]; formatstring(res)("texture %s \"%s\"", floatstr(s.orgscale, true), s.name); return res; } else return NULL; } Texture *lookuptexture(int tex, Texture *failtex, bool trydl) { Texture *t = failtex; if(slots.inrange(tex)) { Slot &s = slots[tex]; if(!s.loaded) { defformatstring(pname)("packages/textures/%s", path(s.name, true)); s.tex = textureload(pname, 0, true, true, s.scale, trydl); if(!trydl) { if(s.tex==notexture) s.tex = failtex; s.loaded = true; } } if(s.tex) t = s.tex; } return t; } void cleanuptextures() { enumerate(textures, Texture, t, if(t.id) { glDeleteTextures(1, &t.id); t.id = 0; } ); } bool reloadtexture(Texture &t) { if(t.id) glDeleteTextures(1, &t.id); int xs = 1, ys = 1, bpp = 0; t.id = loadsurface(t.name, xs, ys, bpp, t.clamp, t.mipmap, t.canreduce, t.scale); t.xs = xs; t.ys = ys; t.bpp = bpp; return t.id!=0; } void reloadtextures() { enumerate(textures, Texture, t, reloadtexture(t)); } Texture *sky[6] = {NULL, NULL, NULL, NULL, NULL, NULL}; SVARF(loadsky, "", { loadskymap(false); }); bool loadskymap(bool reload) { const char *side[] = { "lf", "rt", "ft", "bk", "dn", "up" }; const char *legacyprefix = "textures/skymaps/"; if(!reload) { int n = strlen(legacyprefix); filtertext(loadsky, loadsky, FTXT__MEDIAFILEPATH); checktexturefilename(loadsky); if(!strncmp(loadsky, legacyprefix, n)) { // remove the prefix char *t = loadsky; loadsky = newstring(loadsky + n); delstring(t); } flagmapconfigchange(); } bool old_silent_texture_load = silent_texture_load, success = true; if(autodownload && execcontext == IEXC_MAPCFG) silent_texture_load = true; loopi(6) { defformatstring(name)("packages/%s%s_%s.jpg", legacyprefix, loadsky, side[i]); sky[i] = textureload(name, 3); if(sky[i] == notexture && !reload && autodownload && execcontext == IEXC_MAPCFG) { requirepackage(PCK_SKYBOX, loadsky); break; } if(sky[i] == notexture && reload) success = false; } silent_texture_load = old_silent_texture_load; return success; } void loadnotexture(char *c) { noworldtexture = notexture; // reset to default *mapconfigdata.notexturename = '\0'; if(c[0]) { checktexturefilename(c); filtertext(mapconfigdata.notexturename, c, FTXT__MEDIAFILEPATH); defformatstring(p)("packages/textures/%s", mapconfigdata.notexturename); noworldtexture = textureload(p); if(noworldtexture==notexture) { conoutf("could not load alternative texture '%s'.", p); flagmapconfigerror(LWW_CONFIGERR * 8); scripterr(); } } flagmapconfigchange(); } COMMAND(loadnotexture, "s"); COMMANDF(getnotexture, "", () { result(mapconfigdata.notexturename); }); void draw_envbox_face(float s0, float t0, float x0, float y0, float z0, float s1, float t1, float x1, float y1, float z1, float s2, float t2, float x2, float y2, float z2, float s3, float t3, float x3, float y3, float z3, Texture *tex) { glBindTexture(GL_TEXTURE_2D, tex->id); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(s3, t3); glVertex3f(x3, y3, z3); glTexCoord2f(s2, t2); glVertex3f(x2, y2, z2); glTexCoord2f(s0, t0); glVertex3f(x0, y0, z0); glTexCoord2f(s1, t1); glVertex3f(x1, y1, z1); glEnd(); xtraverts += 4; } VAR(skyclip, 0, 1, 1); float skyfloor = 1e16f; void draw_envbox(int w) { extern float skyfloor; float zclip = skyclip && skyfloor >= camera1->o.z ? 0.5f + float(skyfloor-camera1->o.z)/w : 0.0f, vclip = 1-zclip, z = 2*w*(vclip-0.5f); if(vclip < 0) return; glDepthMask(GL_FALSE); draw_envbox_face(0.0f, 0.0f, -w, -w, -w, 1.0f, 0.0f, -w, w, -w, 1.0f, vclip, -w, w, z, 0.0f, vclip, -w, -w, z, sky[0] ? sky[0] : notexture); draw_envbox_face(1.0f, vclip, +w, -w, z, 0.0f, vclip, +w, w, z, 0.0f, 0.0f, +w, w, -w, 1.0f, 0.0f, +w, -w, -w, sky[1] ? sky[1] : notexture); draw_envbox_face(1.0f, vclip, -w, -w, z, 0.0f, vclip, w, -w, z, 0.0f, 0.0f, w, -w, -w, 1.0f, 0.0f, -w, -w, -w, sky[2] ? sky[2] : notexture); draw_envbox_face(1.0f, vclip, +w, w, z, 0.0f, vclip, -w, w, z, 0.0f, 0.0f, -w, w, -w, 1.0f, 0.0f, +w, w, -w, sky[3] ? sky[3] : notexture); if(!zclip) draw_envbox_face(0.0f, 1.0f, -w, w, w, 0.0f, 0.0f, +w, w, w, 1.0f, 0.0f, +w, -w, w, 1.0f, 1.0f, -w, -w, w, sky[4] ? sky[4] : notexture); draw_envbox_face(0.0f, 1.0f, +w, w, -w, 0.0f, 0.0f, -w, w, -w, 1.0f, 0.0f, -w, -w, -w, 1.0f, 1.0f, +w, -w, -w, sky[5] ? sky[5] : notexture); glDepthMask(GL_TRUE); skyfloor = 1e16f; } struct tmufunc { GLenum combine, sources[3], ops[3]; int scale; }; struct tmu { GLenum mode; GLfloat color[4]; tmufunc rgb, alpha; }; #define INVALIDTMU \ { \ 0, \ { -1, -1, -1, -1 }, \ { 0, { 0, 0, 0 }, { 0, 0, 0 }, 0 }, \ { 0, { 0, 0, 0 }, { 0, 0, 0 }, 0 } \ } #define INITTMU \ { \ GL_MODULATE, \ { 0, 0, 0, 0 }, \ { GL_MODULATE, { GL_TEXTURE, GL_PREVIOUS_ARB, GL_CONSTANT_ARB }, { GL_SRC_COLOR, GL_SRC_COLOR, GL_SRC_ALPHA }, 1 }, \ { GL_MODULATE, { GL_TEXTURE, GL_PREVIOUS_ARB, GL_CONSTANT_ARB }, { GL_SRC_ALPHA, GL_SRC_ALPHA, GL_SRC_ALPHA }, 1 } \ } #define MAXTMUS 4 tmu tmus[MAXTMUS] = { INVALIDTMU, INVALIDTMU, INVALIDTMU, INVALIDTMU }; VAR(maxtmus, 1, 0, 0); void parsetmufunc(tmufunc &f, const char *s) { int arg = -1; while(*s) switch(tolower(*s++)) { case 't': f.sources[++arg] = GL_TEXTURE; f.ops[arg] = GL_SRC_COLOR; break; case 'p': f.sources[++arg] = GL_PREVIOUS_ARB; f.ops[arg] = GL_SRC_COLOR; break; case 'k': f.sources[++arg] = GL_CONSTANT_ARB; f.ops[arg] = GL_SRC_COLOR; break; case 'c': f.sources[++arg] = GL_PRIMARY_COLOR_ARB; f.ops[arg] = GL_SRC_COLOR; break; case '~': f.ops[arg] = GL_ONE_MINUS_SRC_COLOR; break; case 'a': f.ops[arg] = f.ops[arg]==GL_ONE_MINUS_SRC_COLOR ? GL_ONE_MINUS_SRC_ALPHA : GL_SRC_ALPHA; break; case '=': f.combine = GL_REPLACE; break; case '*': f.combine = GL_MODULATE; break; case '+': f.combine = GL_ADD; break; case '-': f.combine = GL_SUBTRACT_ARB; break; case ',': case '@': f.combine = GL_INTERPOLATE_ARB; break; case '.': f.combine = GL_DOT3_RGB_ARB; break; case 'x': while(!isdigit(*s)) s++; f.scale = *s++-'0'; break; } } void committmufunc(bool rgb, tmufunc &dst, tmufunc &src) { if(dst.combine!=src.combine) glTexEnvi(GL_TEXTURE_ENV, rgb ? GL_COMBINE_RGB_ARB : GL_COMBINE_ALPHA_ARB, src.combine); loopi(3) { if(dst.sources[i]!=src.sources[i]) glTexEnvi(GL_TEXTURE_ENV, (rgb ? GL_SOURCE0_RGB_ARB : GL_SOURCE0_ALPHA_ARB)+i, src.sources[i]); if(dst.ops[i]!=src.ops[i]) glTexEnvi(GL_TEXTURE_ENV, (rgb ? GL_OPERAND0_RGB_ARB : GL_OPERAND0_ALPHA_ARB)+i, src.ops[i]); } if(dst.scale!=src.scale) glTexEnvi(GL_TEXTURE_ENV, rgb ? GL_RGB_SCALE_ARB : GL_ALPHA_SCALE, src.scale); } void committmu(int n, tmu &f) { if(n>=maxtmus) return; if(tmus[n].mode!=f.mode) glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, f.mode); if(memcmp(tmus[n].color, f.color, sizeof(f.color))) glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, f.color); committmufunc(true, tmus[n].rgb, f.rgb); committmufunc(false, tmus[n].alpha, f.alpha); tmus[n] = f; } void resettmu(int n) { tmu f = tmus[n]; f.mode = GL_MODULATE; f.rgb.scale = 1; f.alpha.scale = 1; committmu(n, f); } void scaletmu(int n, int rgbscale, int alphascale) { tmu f = tmus[n]; if(rgbscale) f.rgb.scale = rgbscale; if(alphascale) f.alpha.scale = alphascale; committmu(n, f); } void colortmu(int n, float r, float g, float b, float a) { tmu f = tmus[n]; f.color[0] = r; f.color[1] = g; f.color[2] = b; f.color[3] = a; committmu(n, f); } void setuptmu(int n, const char *rgbfunc, const char *alphafunc) { static tmu init = INITTMU; tmu f = tmus[n]; f.mode = GL_COMBINE_ARB; if(rgbfunc) parsetmufunc(f.rgb, rgbfunc); else f.rgb = init.rgb; if(alphafunc) parsetmufunc(f.alpha, alphafunc); else f.alpha = init.alpha; committmu(n, f); } void inittmus() { GLint val; glGetIntegerv(GL_MAX_TEXTURE_SIZE, &val); hwtexsize = val; if(hasTE && !hasMT) maxtmus = 1; else if(hasTE && hasMT) { glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &val); maxtmus = max(1, min(MAXTMUS, int(val))); loopi(maxtmus) { glActiveTexture_(GL_TEXTURE0_ARB+i); resettmu(i); } glActiveTexture_(GL_TEXTURE0_ARB); } } void cleanuptmus() { tmu invalidtmu = INVALIDTMU; loopi(MAXTMUS) tmus[i] = invalidtmu; } Texture *e_wall = NULL, *e_floor = NULL, *e_ceil = NULL; void guidetoggle() { if(player1->state == CS_EDITING) { Slot *sw = &slots[DEFAULT_WALL]; Slot *sf = &slots[DEFAULT_FLOOR]; Slot *sc = &slots[DEFAULT_CEIL]; //if textures match original texture if(e_wall == NULL || e_floor == NULL || e_ceil == NULL) { //replace defaults with grid texures e_wall = sw->tex; e_floor = sf->tex; e_ceil = sc->tex; sw->tex = textureload("packages/textures/map_editor/wall.png"); sf->tex = textureload("packages/textures/map_editor/floor.png"); sc->tex = textureload("packages/textures/map_editor/ceil.png"); conoutf("Guide: \f0on"); } else { // restore textures if(e_wall) sw->tex = e_wall; if(e_floor) sf->tex = e_floor; if(e_ceil) sc->tex = e_ceil; e_wall = NULL; e_floor = NULL; e_ceil = NULL; conoutf("Guide: \fBoff"); } } else { conoutf("\fBGuide view is only available when editing."); } } COMMAND(guidetoggle, ""); void gettexturelist(char *_filter, char *_exclude, char *_exts) // create a list of texture paths and filenames { vector filter, exclude, exts, files; vector filter_n, exclude_n, exts_n; explodelist(_filter, filter); // path has to start with one of these explodelist(_exclude, exclude); // path may not start with one of these explodelist(_exts, exts); // file needs to have one of those extensions (or ".jpg" by default) if(!exts.length()) exts.add(newstring(".jpg")); loopv(filter) filter_n.add((int) strlen(filter[i])); loopv(exclude) exclude_n.add((int) strlen(exclude[i])); loopv(exts) exts_n.add((int) strlen(exts[i])); listfilesrecursive("packages/textures", files); files.sort(stringsort); loopvrev(files) if(files.inrange(i + 1) && !strcmp(files[i], files[i + 1])) delstring(files.remove(i + 1)); // remove doubles int pn = strlen("packages/textures/"); loopvrev(files) { bool filtered = filter.length() == 0, excluded = false, extmatch = false; if(!strncmp(files[i], "packages/textures/", pn)) { const char *s = files[i] + pn; loopvj(filter) if(!strncmp(s, filter[j], filter_n[j])) filtered = true; loopvj(exclude) if(!strncmp(s, exclude[j], exclude_n[j])) excluded = true; int n = strlen(s); loopvj(exts) if(n > exts_n[j] && !strcmp(s + n - exts_n[j], exts[j])) extmatch = true; } if(!extmatch || !filtered || excluded) delstring(files.remove(i)); } vector res; bool cutprefix = filter.length() == 1; bool cutext = exts.length() == 1 && exts[0][0] != '.'; loopv(files) { char *f = files[i] + pn; const char *p = parentdir(f), *b = behindpath(f); cvecprintf(res, "\"%s\" \"%s\"", p, b); // always add columns for path (without "packages/textures/") and filename if(cutprefix) cvecprintf(res, " \"%s\"", int(strlen(p)) > filter_n[0] ? p + filter_n[0] : ""); // if there's exactly one filter string, add column with that string omitted if(cutext) { int n = strlen(b); if(n > exts_n[0]) ((char *)b)[n - exts_n[0]] = '\0'; cvecprintf(res, " \"%s\"", b); // if there's only one allowed extension and it does not start with '.', add column of filenames without extension } res.add('\n'); } filter.deletearrays(); exclude.deletearrays(); exts.deletearrays(); files.deletearrays(); resultcharvector(res, -1); } COMMAND(gettexturelist, "sss"); void textureslotusagemapmodels(int *used) { int old0 = used[0]; loopv(ents) if(ents[i].type == MAPMODEL) used[ents[i].attr4]++; used[0] = old0; } void textureslotusagegeometry(int *used, int *visible = NULL, int *mostvisible = NULL) { sqr *s = world; int *mostw = mostvisible ? new int[1024] : NULL, *mostc = mostvisible ? mostw + 256 : NULL, *mostf = mostvisible ? mostw + 512 : NULL, *mostu = mostvisible ? mostw + 768 : NULL; if(mostvisible) loopi(1024) mostw[i] = 0; if(visible) calcworldvisibility(); loopirev(cubicsize) { used[s->wtex]++; if(s->type != SOLID) { used[s->ctex]++; used[s->ftex]++; used[s->utex]++; } if(visible && !(s->visible & INVISIBLE)) { // cube not invisible if(!(s->visible & INVISWTEX)) { // lower wall visible visible[s->wtex]++; if(mostw) mostw[s->wtex]++; } if(s->type != SOLID) { if(!(s->visible & INVISUTEX)) { // upper wall visible visible[s->utex]++; if(mostu) mostu[s->utex]++; } visible[s->ctex]++; if(mostc) mostc[s->ctex]++; visible[s->ftex]++; if(mostf) mostf[s->ftex]++; } } s++; } if(visible) clearworldvisibility(); if(mostvisible) loopk(4) { // find most visible texures (for all four geometry uses) int *mx[4] = { mostw, mostf, mostc, mostu }, *m = mx[k], maxval = 0; mostvisible[k] = -1; loopi(256) if(m[i] > maxval) { maxval = m[i]; mostvisible[k] = i; } } if(mostw) delete[] mostw; } void textureslotusagelist(char *what) { int used[256] = { 0 }, visible[256]; int mostvisible[4] = { 0 }; bool onlymostvisible = !strcmp(what, "onlymostvisible"); if(strcmp(what, "onlygeometry")) { // if not only geometry, count map model usage textureslotusagemapmodels(used); } loopi(256) visible[i] = used[i]; // all mapmodel uses count as "visible" as well if(strcmp(what, "onlymodels")) { // if not only models, count map geometry textureslotusagegeometry(used, visible, onlymostvisible ? mostvisible : NULL); } vector res; if(onlymostvisible) cvecprintf(res, "wall %d floor %d ceiling %d \"upper wall\" %d ", mostvisible[0], mostvisible[1], mostvisible[2], mostvisible[3]); else loopi(256) cvecprintf(res, "%d %d ", used[i], visible[i]); resultcharvector(res, -1); } COMMAND(textureslotusagelist, "s"); bool testworldtexusage(int n) { sqr *s = world; loopirev(cubicsize) { if(s->wtex == n || s->ctex == n || s->ftex == n || s->utex == n) return true; s++; } return false; } void textureslotusage(int *n) // returns all mapmodel entity indices that use a certain texture to skin the model // if the texture is used in map geometry, at least a space is returned // if the texture is unused, an empty string is returned { string res = ""; loopv(ents) if(ents[i].type == MAPMODEL && ents[i].attr4 == *n) concatformatstring(res, "%s%d", i ? " " : "", i); if(!*res) { // not used to skin a mapmodel: check world usage... if(testworldtexusage(*n)) copystring(res, " "); } result(res); } COMMAND(textureslotusage, "i"); void deletetextureslot(int *n, char *opt, char *_replace) // delete texture slot - only if unused or "purge" is specified { EDITMP("deletetextureslot"); if(!slots.inrange(*n)) return; bool purgeall = !strcmp(opt, "purge"); bool mmused = false; loopv(ents) if(ents[i].type == MAPMODEL && ents[i].attr4 == *n) mmused = true; if(!purgeall && *n <= DEFAULT_CEIL) { conoutf("texture slots below #%d should usually not be deleted", DEFAULT_CEIL + 1); return; } if(!purgeall && (mmused || testworldtexusage(*n))) { conoutf("texture slot #%d is in use: can't delete", *n); return; } int deld = 0, replace = 256; if(purgeall && isdigit(*_replace)) replace = strtol(_replace, NULL, 0) & 255; if(replace > *n) replace--; sqr *s = world; loopirev(cubicsize) { // check, if cubes use the texture if(s->wtex == *n) { s->wtex = replace; deld++; } else if(s->wtex > *n) s->wtex--; if(s->ctex == *n) { s->ctex = replace; deld++; } else if(s->ctex > *n) s->ctex--; if(s->ftex == *n) { s->ftex = replace; deld++; } else if(s->ftex > *n) s->ftex--; if(s->utex == *n) { s->utex = replace; deld++; } else if(s->utex > *n) s->utex--; s++; } block bb = { clmapdims.x1 - 1, clmapdims.y1 - 1, clmapdims.xspan + 2, clmapdims.yspan + 2 }; remip(bb); loopv(ents) if(ents[i].type == MAPMODEL) { // check, if mapmodels use the texture entity &e = ents[i]; if(e.attr4 == *n) { // use default model texture instead e.attr4 = 0; deld++; } else if(e.attr4 > *n) e.attr4--; // adjust models in higher slots } loopk(3) // adjust texlists { int j = 255; loopi(256) { if(hdr.texlists[k][i] == *n) j = i; if(hdr.texlists[k][i] > *n) hdr.texlists[k][i]--; } if(j < 255) memmove(&hdr.texlists[k][j], &hdr.texlists[k][j + 1], 255 - j); hdr.texlists[k][255] = 255; } slots.remove(*n); defformatstring(m)(" (%d uses removed)", deld); if(replace != 255) formatstring(m)(" (%d uses changed to use slot #%d)", deld, replace); conoutf("texture slot #%d deleted%s", *n, deld ? m : ""); unsavededits++; hdr.flags |= MHF_AUTOMAPCONFIG; // requires automapcfg } COMMAND(deletetextureslot, "iss"); void edittextureslot(int *n, char *scale, char *name) // edit slot parameters != "" { string res = ""; if(slots.inrange(*n)) { Slot &s = slots[*n]; if((*scale || *name) && !noteditmode("edittextureslot") && !multiplayer("edittextureslot")) { // change attributes float newscale = atof(scale); _texture(s, *scale ? &newscale : NULL, *name ? name : NULL); unsavededits++; hdr.flags |= MHF_AUTOMAPCONFIG; // requires automapcfg } formatstring(res)("%s \"%s\"", floatstr(s.orgscale, true), s.name); } result(res); } COMMAND(edittextureslot, "iss"); void gettextureorigin(char *fname) { if(!*fname) return; defformatstring(s)("packages/textures/%s", fname); findfile(path(s), "r"); const char *res = s; switch(findfilelocation) { case FFL_ZIP: res = "zip"; break; case FFL_WORKDIR: res = fileexists(s, "r") ? "official" : ""; break; case FFL_HOME: res = "custom"; break; default: formatstring(s)("package dir #%d", findfilelocation); break; } result(res); } COMMAND(gettextureorigin, "s"); void textureslotbyname(char *name) // returns the slot(s) that a certain texture file is configured in { string res = ""; loopv(slots) if(!strcmp(name, slots[i].name)) concatformatstring(res, "%s%d", *res ? " " : "", i); result(res); } COMMAND(textureslotbyname, "s"); // helper functions to allow copy&paste between different maps while keeping the proper textures assigned // (pasting will add any missing texture slots) void *texconfig_copy() { vector *s = new vector; loopv(slots) s->add(slots[i]); return (void *)s; } void texconfig_delete(void *s) { delete (vector *)s; } uchar *texconfig_paste(void *_s, uchar *usedslots) // create mapping table to translate pasted geometry to this maps texture list - add any missing textures { vector *s = (vector *)_s; static uchar res[256]; loopi(256) res[i] = i; loopi(256) if(usedslots[i] && s->inrange(i)) { Slot &os = (*s)[i]; bool found = false; loopvj(slots) { if(slots[j].scale == os.scale && !strcmp(slots[j].name, os.name)) { res[i] = j; found = true; break; } } if(!found) { if(slots.length() < 255) { res[i] = slots.length(); _texture(slots.add(), &os.scale, os.name); conoutf("added texture \"%s\" (scale %.7g) in slot #%d", os.name, os.scale, res[i]); if(!(hdr.flags & MHF_AUTOMAPCONFIG)) automapconfig(); // make sure, the new texture slots will be saved with the map } else conoutf("\f3failed to add texture \"%s\" (scale %.7g): no texture slot available", os.name, os.scale); } } return res; } struct temptexslot { Slot s; vector oldslot; bool used; }; int tempslotsort(temptexslot *a, temptexslot *b) { int n = strcmp(a->s.name, b->s.name); if(n) return n; if(a->s.scale < b->s.scale) return -1; if(a->s.scale > b->s.scale) return 1; return a->oldslot[0] - b->oldslot[0]; } int tempslotunsort(temptexslot *a, temptexslot *b) { return a->oldslot[0] - b->oldslot[0]; } void sorttextureslots(char **args, int numargs) { bool nomerge = false, mergeused = false, nosort = false, unknownarg = false; vector presort; presort.add(0); // skymap needs to stay on #0 loopi(numargs) if(args[i][0]) { if(!strcasecmp(args[i], "nomerge")) nomerge = true; else if(!strcasecmp(args[i], "nosort")) nosort = true; else if(!strcasecmp(args[i], "mergeused")) mergeused = true; else if(isdigit(args[i][0])) presort.add(ATOI(args[i])); else { conoutf("sorttextureslots: unknown argument \"%s\"", args[i]); unknownarg = true; } } while(presort.length() < 5) presort.add(presort.length()); EDITMP("sorttextureslots"); if(unknownarg || slots.length() < 5) return; int used[256] = { 0 }; textureslotusagemapmodels(used); textureslotusagegeometry(used); vector tempslots; loopv(slots) { tempslots.add().s = slots[i]; tempslots.last().oldslot.add(i); tempslots.last().used = used[i] > 0; } tempslots.sort(tempslotsort); // remove double entries (if requested) if(!nomerge) loopvrev(tempslots) if(i > 0) { temptexslot &s1 = tempslots[i], &s0 = tempslots[i - 1]; if(s1.oldslot[0] > 4 && s0.oldslot[0] > 0 && !strcmp(s0.s.name, s1.s.name) && s0.s.scale == s1.s.scale && (mergeused || !s0.used || !s1.used)) { if(s1.used) s0.used = true; loopvj(s1.oldslot) s0.oldslot.add(s1.oldslot[j]); tempslots.remove(i); } } // sort special textures (like skymap) back front - also, revert sorting, if it's unwanted if(nosort) tempslots.sort(tempslotunsort); loopv(presort) for(int n = i + 1; n < presort.length(); n++) if(presort[i] == presort[n]) presort.remove(n); // first occurrence is kept loopvk(presort) { loopv(tempslots) { bool yep = false; loopvj(tempslots[i].oldslot) if(tempslots[i].oldslot[j] == presort[k]) yep = true; if(yep && i > k) { temptexslot t = tempslots.remove(i); tempslots.insert(k, t); break; } } } // create translation table uchar newslot[256]; loopk(256) newslot[k] = k; loopv(tempslots) { temptexslot &t = tempslots[i]; loopvj(t.oldslot) { if(t.oldslot[j] < 256) newslot[t.oldslot[j]] = i; } } // translate all texture entries sqr *s = world; loopirev(cubicsize) { s->wtex = newslot[s->wtex]; s->ctex = newslot[s->ctex]; s->ftex = newslot[s->ftex]; s->utex = newslot[s->utex]; s++; } block bb = { clmapdims.x1 - 1, clmapdims.y1 - 1, clmapdims.xspan + 2, clmapdims.yspan + 2 }; remip(bb); loopv(ents) if(ents[i].type == MAPMODEL) { entity &e = ents[i]; if(e.attr4) e.attr4 = newslot[e.attr4]; } // translate texture lists loopk(3) { uchar *ps = hdr.texlists[k], *pd = ps, d[256], x; loopi(256) d[i] = 1; loopi(256) { x = newslot[*ps++]; if(d[x] && x < tempslots.length()) { d[x] = 0; *pd++ = x; } } loopi(256) if(d[i]) *pd++ = i; } conoutf("%d texture slots%s, %d %sslots merged", tempslots.length(), nosort ? "" : " sorted", slots.length() - tempslots.length(), mergeused ? "" : "unused "); // rewrite texture slot list slots.shrink(tempslots.length()); loopv(tempslots) { temptexslot &t = tempslots[i]; _texture(slots[i], &t.s.orgscale, t.s.name); } unsavededits++; hdr.flags |= MHF_AUTOMAPCONFIG; // requires automapcfg } COMMAND(sorttextureslots, "v"); #ifdef _DEBUG void resettexturelists() { loopk(3) loopi(256) hdr.texlists[k][i] = i; } COMMAND(resettexturelists, ""); #endif assaultcube-1.2.0.2.1/source/src/tools.cpp000066400000000000000000001021301352165075300202630ustar00rootroot00000000000000// implementation of generic tools #include "cube.h" #ifdef NO_POSIX_R char *strtok_r(char *s, const char *delim, char **b) { if(s) *b = s; *b += strspn(*b, delim); if(!**b) return NULL; s = *b; *b += strcspn(s, delim); if(**b) *(*b)++ = '\0'; return s; } #endif string _timestringbuffer; const char *timestring(time_t t, bool local, const char *fmt, char *buf) { #ifdef NO_POSIX_R struct tm *timeinfo; timeinfo = local ? localtime(&t) : gmtime (&t); #else struct tm *timeinfo, b; timeinfo = local ? localtime_r(&t, &b) : gmtime_r(&t, &b); #endif strftime(buf, sizeof(string) - 1, fmt && *fmt ? fmt : "%Y%m%d_%H.%M.%S", timeinfo); // sortable time for filenames return buf; } const char *asctimestr() { return timestring(true, "%c"); } const char *numtime() { static string numt; time_t t = time(NULL); int t1 = t / 1000000, t2 = t % 1000000; formatstring(numt)("%d%06d", t1, t2); return numt + strspn(numt, "0"); } static const uchar transformenttab[] = { /* mapformat 1..5 6..7 */ /* 0 */ /* NOTUSED */ NOTUSED, /* NOTUSED */ NOTUSED, /* 1 */ /* LIGHT */ LIGHT, /* LIGHT */ LIGHT, /* 2 */ /* PLAYERSTART */ PLAYERSTART, /* PLAYERSTART */ PLAYERSTART, /* 3 */ /* I_SHELLS */ I_AMMO, /* I_CLIPS */ I_CLIPS, /* 4 */ /* I_BULLETS */ I_AMMO, /* I_AMMO */ I_AMMO, /* 5 */ /* I_ROCKETS */ I_AMMO, /* I_GRENADE */ I_GRENADE, /* 6 */ /* I_ROUNDS */ I_AMMO, /* I_HEALTH */ I_HEALTH, /* 7 */ /* I_HEALTH */ I_HEALTH, /* I_ARMOUR */ I_ARMOUR, /* 8 */ /* I_BOOST */ I_HEALTH, /* I_AKIMBO */ I_AKIMBO, /* 9 */ /* I_GREENARMOUR */ I_HELMET, /* MAPMODEL */ MAPMODEL, /* 10 */ /* I_YELLOWARMOUR */ I_ARMOUR, /* CARROT */ CARROT, /* 11 */ /* I_QUAD */ I_AKIMBO, /* LADDER */ LADDER, /* 12 */ /* TELEPORT */ NOTUSED, /* CTF_FLAG */ CTF_FLAG, /* 13 */ /* TELEDEST */ NOTUSED, /* SOUND */ SOUND, /* 14 */ /* MAPMODEL */ MAPMODEL, /* CLIP */ CLIP, /* 15 */ /* MONSTER */ NOTUSED, /* PLCLIP */ PLCLIP, /* 16 */ /* CARROT */ NOTUSED, 16, /* 17 */ /* JUMPPAD */ NOTUSED, 17 }; void transformoldentitytypes(int mapversion, uchar &enttype) { const uchar *usetab = transformenttab + (mapversion > 5 ? 1 : 0); if(mapversion < 8 && enttype < 18) enttype = usetab[enttype * 2]; } int fixmapheadersize(int version, int headersize) // we can't trust hdr.headersize for file versions < 10 (thx flow) { if(version < 4) return sizeof(header) - sizeof(int) * 16; else if(version == 7 || version == 8) return sizeof(header) + sizeof(char) * 128; // mediareq else if(version < 10 || headersize < int(sizeof(header))) return sizeof(header); return headersize; } // map geometry statistics servsqr *createservworld(const sqr *s, int _cubicsize) // create a server-style floorplan on the client, to use same statistics functions on client and server { servsqr *res = new servsqr[_cubicsize], *d = res; loopirev(_cubicsize) { d->type = s->type == SOLID ? SOLID : ((s->type & TAGTRIGGERMASK) | (s->tag & ~TAGTRIGGERMASK)); // guaranteed to not have tagclips on SOLID cubes - so we can check for SOLID without masks d->ceil = s->ceil; d->floor = s->floor; d->vdelta = s->vdelta; d++; s++; } return res; } int calcmapdims(mapdim_s &md, const servsqr *s, int _ssize) { int res = 0; md.x1 = md.y1 = _ssize; md.x2 = md.y2 = 0; md.minfloor = 127; md.maxceil = -128; for(int y = 0; y < _ssize; y++) for(int x = 0; x < _ssize; x++) { if((s->type & TAGTRIGGERMASK) != SOLID) { if(x < md.x1) md.x1 = x; if(x > md.x2) md.x2 = x; if(y < md.y1) md.y1 = y; md.y2 = y; if(s->floor < md.minfloor) md.minfloor = s->floor; if(s->ceil > md.maxceil) md.maxceil = s->ceil; } s++; } if(md.x2 < md.x1 || md.y2 < md.y1) { // map is completely solid -> default to empty map values md.x1 = md.y1 = 2; md.x2 = md.y2 = _ssize - 3; md.minfloor = 0; md.maxceil = 16; res = -1; // reject map on servers } if(md.x1 < MINBORD || md.y1 < MINBORD || md.x2 >= _ssize - MINBORD || md.y2 >= _ssize - MINBORD) res = -2; // reject map because of world border violation md.xspan = md.x2 - md.x1 + 1; md.yspan = md.y2 - md.y1 + 1; md.xm = md.x1 + md.xspan / 2.0f; md.ym = md.y1 + md.yspan / 2.0f; return res; } int calcmapareastats(mapareastats_s &ms, servsqr *_servworld, int _ssize, const mapdim_s &md) { memset(&ms, 0, sizeof(ms)); // count steep FHF and CHF int linegap = _ssize - md.xspan; #ifndef STANDALONE int totalmax = 0; #endif servsqr *bb = _servworld + _ssize * md.y1 + md.x1, *ss = bb; for(int j = md.yspan; j > 0; j--, ss += linegap) loopirev(md.xspan) { int type = ss->type & TAGTRIGGERMASK; if(type == FHF || type == CHF) // only CHF and FHF use vdelta { servsqr *r[3] = { ss + 1, ss + _ssize, ss + _ssize + 1 }; int min = ss->vdelta, max = min; loopi(3) { if(r[i]->vdelta < min) min = r[i]->vdelta; else if(r[i]->vdelta > max) max = r[i]->vdelta; } max -= min; #ifndef STANDALONE if(max > totalmax) { ms.steepest = int(ss - _servworld); totalmax = max; } #endif int d = max / MAS_VDELTA_QUANT; ASSERT(d >= 0); if(d >= MAS_VDELTA_TABSIZE) d = MAS_VDELTA_TABSIZE - 1; ms.vdd[d]++; } ss++; } loopirev(MAS_VDELTA_TABSIZE) ms.vdds = (ms.vdds << 2) | ((ms.vdd[i] > MAS_VDELTA_THRES) << 1) | (ms.vdd[i] > 0); // check occlusion by SOLIDs (destroys vdelta values) ss = bb; for(int j = md.yspan; j > 0; j--, ss += linegap) loopirev(md.xspan) (ss++)->vdelta = 0; // reset all vdelta values int xc = (md.xspan + MAS_GRID / 2) / (MAS_GRID + 1), yc = (md.yspan + MAS_GRID / 2) / (MAS_GRID + 1); if(md.x1 + MAS_GRID * xc >= _ssize || md.y1 + MAS_GRID * yc >= _ssize) return -1; // malformed map int xb = min(md.x1 + xc, _ssize - MAS_GRID * xc - md.x1 - 1) / 2, yb = min(md.y1 + yc, _ssize - MAS_GRID * yc - md.y1 - 1) / 2; // make sure, all tp points are inside the map area int tgx = min(xb, max(3, xc / 3)), tgy = min(yb, max(3, yc / 3)) * _ssize, tp[8] = { tgx, -tgx, tgy, -tgy, 2 * tgx + 2 * tgy, -2 * tgx - 2 * tgy, -2 * tgx + 2 * tgy, 2 * tgx - 2 * tgy }; // 8 positions to try, if the stariing point is solid uchar epoch = 1; servsqr *s = bb + xc + yc * _ssize; ss = s; vector tab; threeint pp; for(int y = 0; y < MAS_GRID; y++, ss = s += _ssize * yc) for(int x = 0; x < MAS_GRID; x++, ss += xc) // measure visible area in MAS_GRID x MAS_GRID probe points { // calculate MAS_GRID^2 probe points (with a low-res version of computeraytable() servsqr *r = ss, *rr; if(SOLID(r)) loopi(8) { // if initial position is SOLID, we try 8 points around that spot if(!SOLID(r + tp[i])) { r += tp[i]; break; } } pp.val2 = int(r - _servworld); int area = 0, volume = 0, frac; loopk(MAS_RESOLUTION) { #define RAYS(da, db) \ rr = r; frac = 0; \ for(;;) \ { \ if((frac += k) >= MAS_RESOLUTION) rr += da, frac -= MAS_RESOLUTION; \ rr += db; \ if(SOLID(rr)) break; \ if(rr->vdelta != epoch) { area += 1; volume += rr->ceil - rr->floor; } \ rr->vdelta = epoch; \ } RAYS(_ssize, 1); RAYS(_ssize, -1); RAYS(-_ssize, 1); RAYS(-_ssize, -1); RAYS(1, _ssize); RAYS(1, -_ssize); RAYS(-1, _ssize); RAYS(-1, -_ssize); #undef RAYS } pp.val1 = volume; pp.key = area; tab.add(pp); if(area) epoch++; if(!epoch) epoch++; } ss = bb; for(int j = md.yspan; j > 0; j--, ss += linegap) loopirev(md.xspan) { if(!SOLID(ss)) { ms.total++; if(!ss->vdelta) ms.rest++; // count all cubes not in view of one of the probe points } ss++; } ASSERT(tab.length() == MAS_GRID2); tab.sort(cmpintdesc); loopv(tab) { // sort probe poiints in descending order of area ms.ppv[i] = tab[i].val1; ms.ppa[i] = tab[i].key; #ifndef STANDALONE ms.ppp[i] = tab[i].val2; #endif } return 0; } void calcentitystats(entitystats_s &es, const persistent_entity *pents, int pentsize) { #ifndef STANDALONE vector _pents; if(!pents) { // use regular ents list loopv(ents) _pents.add() = ents[i]; pentsize = _pents.length(); if(pentsize) pents = &_pents[0]; } #endif memset(&es, 0, sizeof(es)); loopi(MAXENTTYPES) es.first[i] = pentsize; vector picks; loopi(pentsize) { const persistent_entity &e = pents[i]; if(e.type < MAXENTTYPES) { es.entcnt[e.type]++; if(es.first[e.type] == pentsize) es.first[e.type] = i; es.last[e.type] = i; if(e.type == PLAYERSTART) switch(e.attr2) { case 0: es.spawns[0]++; break; case 1: es.spawns[1]++; break; case 100: es.spawns[2]++; break; default: es.unknownspawns++; break; } if(e.type == CTF_FLAG) switch(e.attr2) { case 0: case 1: es.flags[e.attr2]++; es.flagents[e.attr2] = i; break; default: es.unknownflags++; break; } if(isitem(e.type)) picks.add(i); } } es.hasffaspawns = es.spawns[2] >= MINSPAWNS; es.hasteamspawns = es.spawns[0] >= MINSPAWNS && es.spawns[1] >= MINSPAWNS; if(es.flags[0] == 1 && es.flags[1] == 1) { vec fd(pents[es.flagents[0]].x - pents[es.flagents[1]].x, pents[es.flagents[0]].y - pents[es.flagents[1]].y, 0); es.flagentdistance = fd.magnitude(); es.hasflags = es.flagentdistance >= MINFLAGDISTANCE; } int r = 0; loopvjrev(picks) loopirev(j) { // calculate the distances between all pickups (takes n^2/2 calculations - which should be fine for any sane map) double d = pow2(pents[picks[i]].x - pents[picks[j]].x) + pow2(pents[picks[i]].y - pents[picks[j]].y); // deltaX^2 + deltaY^2 frexp(d, &r); r /= 2; // sqrt ;) if(r > LARGEST_FACTOR) r = LARGEST_FACTOR; es.pickupdistance[r]++; } es.pickups = picks.length(); } #if 0 const char *rateentitystats(entitystats_s &es) { static char res[LARGEST_FACTOR + 1]; } #endif int cmpintasc(const int *a, const int *b) { return *a - *b; } // leads to ascending sort order int cmpintdesc(const int *a, const int *b) { return *b - *a; } // leads to descending sort order int stringsort(const char **a, const char **b) { return strcmp(*a, *b); } int stringsortrev(const char **a, const char **b) { return strcmp(*b, *a); } int stringsortignorecase(const char **a, const char **b) { return strcasecmp(*a, *b); } int stringsortignorecaserev(const char **a, const char **b) { return strcasecmp(*b, *a); } extern char *maplayout, *testlayout; extern int maplayout_factor, testlayout_factor, Mvolume, Marea, Mopen, SHhits; extern float Mheight; extern int checkarea(int, char *); mapstats *loadmapstats(const char *filename, bool getlayout) { const int sizeof_header = sizeof(header), sizeof_baseheader = sizeof_header - sizeof(int) * 16; static mapstats s; static uchar *enttypes = NULL; static short *entposs = NULL; DELETEA(enttypes); loopi(MAXENTTYPES) s.entcnt[i] = 0; loopi(3) s.spawns[i] = 0; loopi(2) s.flags[i] = 0; stream *f = opengzfile(filename, "rb"); if(!f) return NULL; memset(&s.hdr, 0, sizeof_header); if(f->read(&s.hdr, sizeof_baseheader) != sizeof_baseheader || (strncmp(s.hdr.head, "CUBE", 4) && strncmp(s.hdr.head, "ACMP",4))) { delete f; return NULL; } lilswap(&s.hdr.version, 4); s.hdr.headersize = fixmapheadersize(s.hdr.version, s.hdr.headersize); int restofhead = min(s.hdr.headersize, sizeof_header) - sizeof_baseheader; if(s.hdr.version > MAPVERSION || s.hdr.numents > MAXENTITIES || f->read(&s.hdr.waterlevel, restofhead) != restofhead || !f->seek(clamp(s.hdr.headersize - sizeof_header, 0, MAXHEADEREXTRA), SEEK_CUR)) { delete f; return NULL; } if(s.hdr.version>=4) { lilswap(&s.hdr.waterlevel, 1); lilswap(&s.hdr.maprevision, 2); } else s.hdr.waterlevel = -100000; entity e; enttypes = new uchar[s.hdr.numents]; entposs = new short[s.hdr.numents * 3]; loopi(s.hdr.numents) { f->read(&e, s.hdr.version < 10 ? 12 : sizeof(persistent_entity)); lilswap((short *)&e, 4); transformoldentitytypes(s.hdr.version, e.type); if(e.type == PLAYERSTART && (e.attr2 == 0 || e.attr2 == 1 || e.attr2 == 100)) s.spawns[e.attr2 == 100 ? 2 : e.attr2]++; if(e.type == CTF_FLAG && (e.attr2 == 0 || e.attr2 == 1)) { s.flags[e.attr2]++; s.flagents[e.attr2] = i; } s.entcnt[e.type]++; enttypes[i] = e.type; entposs[i * 3] = e.x; entposs[i * 3 + 1] = e.y; entposs[i * 3 + 2] = e.z + e.attr1; } DELETEA(testlayout); int minfloor = 0; int maxceil = 0; if(s.hdr.sfactor <= LARGEST_FACTOR && s.hdr.sfactor >= SMALLEST_FACTOR) { testlayout_factor = s.hdr.sfactor; int layoutsize = 1 << (testlayout_factor * 2); bool fail = false; testlayout = new char[layoutsize + 256]; memset(testlayout, 0, layoutsize * sizeof(char)); char *t = NULL; char floor = 0, ceil; int diff = 0; Mvolume = Marea = SHhits = 0; loopk(layoutsize) { char *c = testlayout + k; int type = f->getchar(); int n = 1; switch(type) { case 255: { if(!t || (n = f->getchar()) < 0) { fail = true; break; } memset(c, *t, n); k += n - 1; break; } case 254: // only in MAPVERSION<=2 if(!t) { fail = true; break; } *c = *t; f->getchar(); f->getchar(); break; default: if(type<0 || type>=MAXTYPE) { fail = true; break; } floor = f->getchar(); ceil = f->getchar(); if(floor >= ceil && ceil > -128) floor = ceil - 1; // for pre 12_13 diff = ceil - floor; if(type == FHF) floor = -128; if(floor!=-128 && floormaxceil) maxceil = ceil; f->getchar(); f->getchar(); if(s.hdr.version>=2) f->getchar(); if(s.hdr.version>=5) f->getchar(); case SOLID: *c = type == SOLID ? 127 : floor; f->getchar(); f->getchar(); if(s.hdr.version<=2) { f->getchar(); f->getchar(); } break; } if ( type != SOLID && diff > 6 ) { // Lucas (10mar2013): Removed "pow2" because it was too strict if (diff > MAXMHEIGHT) SHhits += /*pow2*/(diff-MAXMHEIGHT)*n; Marea += n; Mvolume += diff * n; } if(fail) break; t = c; } if(fail) { DELETEA(testlayout); } else { Mheight = Marea ? (float)Mvolume/Marea : 0; Mopen = checkarea(testlayout_factor, testlayout); } } if(getlayout) { DELETEA(maplayout); if (testlayout) { maplayout_factor = testlayout_factor; extern int maplayoutssize; maplayoutssize = 1 << testlayout_factor; int layoutsize = 1 << (testlayout_factor * 2); maplayout = new char[layoutsize + 256]; memcpy(maplayout, testlayout, layoutsize * sizeof(char)); /* memset(&mapdims, 0, sizeof(struct mapdim_s)); mapdims.x1 = mapdims.y1 = maplayoutssize; loopk(layoutsize) if (testlayout[k] != 127) { int cwx = k%maplayoutssize, cwy = k/maplayoutssize; if(cwx < mapdims.x1) mapdims.x1 = cwx; if(cwy < mapdims.y1) mapdims.y1 = cwy; if(cwx > mapdims.x2) mapdims.x2 = cwx; if(cwy > mapdims.y2) mapdims.y2 = cwy; } mapdims.xspan = mapdims.x2 - mapdims.x1; mapdims.yspan = mapdims.y2 - mapdims.y1; mapdims.minfloor = minfloor; mapdims.maxceil = maxceil; */ } } delete f; s.hasffaspawns = s.spawns[2] > 0; s.hasteamspawns = s.spawns[0] > 0 && s.spawns[1] > 0; s.hasflags = s.flags[0] > 0 && s.flags[1] > 0; s.enttypes = enttypes; s.entposs = entposs; s.cgzsize = getfilesize(filename); return &s; } ///////////////////////// debugging /////////////////////// #if defined(WIN32) && !defined(_DEBUG) && !defined(__GNUC__) void stackdumper(unsigned int type, EXCEPTION_POINTERS *ep) { if(!ep) fatal("unknown type"); EXCEPTION_RECORD *er = ep->ExceptionRecord; CONTEXT *context = ep->ContextRecord; string out, t; formatstring(out)("Win32 Exception: 0x%x [0x%x]\n\n", er->ExceptionCode, er->ExceptionCode==EXCEPTION_ACCESS_VIOLATION ? er->ExceptionInformation[1] : -1); STACKFRAME sf = {{context->Eip, 0, AddrModeFlat}, {}, {context->Ebp, 0, AddrModeFlat}, {context->Esp, 0, AddrModeFlat}, 0}; SymInitialize(GetCurrentProcess(), NULL, TRUE); while(::StackWalk(IMAGE_FILE_MACHINE_I386, GetCurrentProcess(), GetCurrentThread(), &sf, context, NULL, ::SymFunctionTableAccess, ::SymGetModuleBase, NULL)) { struct { IMAGEHLP_SYMBOL sym; string n; } si = { { sizeof( IMAGEHLP_SYMBOL ), 0, 0, 0, sizeof(string) } }; IMAGEHLP_LINE li = { sizeof( IMAGEHLP_LINE ) }; DWORD off; if(SymGetSymFromAddr(GetCurrentProcess(), (DWORD)sf.AddrPC.Offset, &off, &si.sym) && SymGetLineFromAddr(GetCurrentProcess(), (DWORD)sf.AddrPC.Offset, &off, &li)) { char *del = strrchr(li.FileName, '\\'); formatstring(t)("%s - %s [%d]\n", si.sym.Name, del ? del + 1 : li.FileName, li.LineNumber); concatstring(out, t); } } #if !defined(STANDALONE) if(clientlogfile) clientlogfile->printf("%s\n", out); #endif fatal("%s", out); } #elif defined(linux) || defined(__linux) || defined(__linux__) #include // stack dumping on linux, inspired by Sachin Agrawal's sample code struct signalbinder { static void stackdumper(int sig) { printf("stacktrace:\n"); #if !defined(STANDALONE) if(clientlogfile) clientlogfile->printf("stacktrace\n"); #endif const int BTSIZE = 25; void *array[BTSIZE]; int n = backtrace(array, BTSIZE); char **symbols = backtrace_symbols(array, n); for(int i = 0; i < n; i++) { printf("%s\n", symbols[i]); #if !defined(STANDALONE) if(clientlogfile) clientlogfile->printf("%s\n", symbols[i]); #endif } free(symbols); fatal("AssaultCube error (%d)", sig); } signalbinder() { // register signals to dump the stack if they are raised, // use constructor for early registering signal(SIGSEGV, stackdumper); signal(SIGFPE, stackdumper); signal(SIGILL, stackdumper); signal(SIGBUS, stackdumper); signal(SIGSYS, stackdumper); signal(SIGABRT, stackdumper); } }; signalbinder sigbinder; #endif ///////////////////////// misc tools /////////////////////// bool cmpb(void *b, int n, enet_uint32 c) { ENetBuffer buf; buf.data = b; buf.dataLength = n; return enet_crc32(&buf, 1)==c; } bool cmpf(char *fn, enet_uint32 c) { int n = 0; char *b = loadfile(fn, &n); bool r = cmpb(b, n, c); delete[] b; return r; } enet_uint32 adler(unsigned char *data, size_t len) { enet_uint32 a = 1, b = 0; while (len--) { a += *data++; b += a; } return b; } bool isbigendian() { return !*(const uchar *)&islittleendian; } void strtoupper(char *t, const char *s) { if(!s) s = t; while(*s) { *t = toupper(*s); t++; s++; } *t = '\0'; } const char *atoip(const char *s, enet_uint32 *ip) { unsigned int d[4]; int n; if(!s || sscanf(s, "%u.%u.%u.%u%n", d, d + 1, d + 2, d + 3, &n) != 4) return NULL; *ip = 0; loopi(4) { if(d[i] > 255) return NULL; *ip = (*ip << 8) + d[i]; } return s + n; } const char *atoipr(const char *s, iprange *ir) { if((s = atoip(s, &ir->lr)) == NULL) return NULL; ir->ur = ir->lr; s += strspn(s, " \t"); if(*s == '-') { if(!(s = atoip(s + 1, &ir->ur)) || ir->lr > ir->ur) return NULL; } else if(*s == '/') { int m, n; if(sscanf(s + 1, "%d%n", &m, &n) != 1 || m < 0 || m > 32) return NULL; unsigned long bm = (1 << (32 - m)) - 1; ir->lr &= ~bm; ir->ur |= bm; s += 1 + n; } return s; } const char *iptoa(const enet_uint32 ip) { static string s[2]; static int buf = 0; buf = (buf + 1) % 2; formatstring(s[buf])("%d.%d.%d.%d", (ip >> 24) & 255, (ip >> 16) & 255, (ip >> 8) & 255, ip & 255); return s[buf]; } const char *iprtoa(const struct iprange &ipr) { static string s[2]; static int buf = 0; buf = (buf + 1) % 2; if(ipr.lr == ipr.ur) copystring(s[buf], iptoa(ipr.lr)); else formatstring(s[buf])("%s-%s", iptoa(ipr.lr), iptoa(ipr.ur)); return s[buf]; } int cmpiprange(const struct iprange *a, const struct iprange *b) { if(a->lr < b->lr) return -1; if(a->lr > b->lr) return 1; return 0; } int cmpipmatch(const struct iprange *a, const struct iprange *b) { return - (a->lr < b->lr) + (a->lr > b->ur); } char *concatformatstring(char *d, const char *s, ...) { static defvformatstring(temp, s, s); return concatstring(d, temp); } int cvecprintf(vector &v, const char *s, ...) { defvformatstring(temp, s, s); int len = strlen(temp); if(len) v.put(temp, len); return len; } const char *hiddenpwd(const char *pwd, int showchars) { static int sc = 3; static string text; copystring(text, pwd); if(showchars > 0) sc = showchars; for(int i = (int)strlen(text) - 1; i >= sc; i--) text[i] = '*'; return text; } int getlistindex(const char *key, const char *list[], bool acceptnumeric, int deflt) { int max = 0; while(list[max][0]) if(!strcasecmp(key, list[max])) return max; else max++; if(acceptnumeric && isdigit(key[0])) { int i = (int)strtol(key, NULL, 0); if(i >= 0 && i < max) return i; } #if !defined(STANDALONE) && defined(_DEBUG) char *opts = conc(list, -1, true); if(*key) clientlogf("warning: unknown token \"%s\" (not in list [%s])", key, opts); delstring(opts); #endif return deflt; } //////////////// geometry utils //////////////// static inline float det2x2(float a, float b, float c, float d) { return a*d - b*c; } static inline float det3x3(float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2, float c3) { return a1 * det2x2(b2, b3, c2, c3) - b1 * det2x2(a2, a3, c2, c3) + c1 * det2x2(a2, a3, b2, b3); } float glmatrixf::determinant() const { float a1 = v[0], a2 = v[1], a3 = v[2], a4 = v[3], b1 = v[4], b2 = v[5], b3 = v[6], b4 = v[7], c1 = v[8], c2 = v[9], c3 = v[10], c4 = v[11], d1 = v[12], d2 = v[13], d3 = v[14], d4 = v[15]; return a1 * det3x3(b2, b3, b4, c2, c3, c4, d2, d3, d4) - b1 * det3x3(a2, a3, a4, c2, c3, c4, d2, d3, d4) + c1 * det3x3(a2, a3, a4, b2, b3, b4, d2, d3, d4) - d1 * det3x3(a2, a3, a4, b2, b3, b4, c2, c3, c4); } void glmatrixf::adjoint(const glmatrixf &m) { float a1 = m.v[0], a2 = m.v[1], a3 = m.v[2], a4 = m.v[3], b1 = m.v[4], b2 = m.v[5], b3 = m.v[6], b4 = m.v[7], c1 = m.v[8], c2 = m.v[9], c3 = m.v[10], c4 = m.v[11], d1 = m.v[12], d2 = m.v[13], d3 = m.v[14], d4 = m.v[15]; v[0] = det3x3(b2, b3, b4, c2, c3, c4, d2, d3, d4); v[1] = -det3x3(a2, a3, a4, c2, c3, c4, d2, d3, d4); v[2] = det3x3(a2, a3, a4, b2, b3, b4, d2, d3, d4); v[3] = -det3x3(a2, a3, a4, b2, b3, b4, c2, c3, c4); v[4] = -det3x3(b1, b3, b4, c1, c3, c4, d1, d3, d4); v[5] = det3x3(a1, a3, a4, c1, c3, c4, d1, d3, d4); v[6] = -det3x3(a1, a3, a4, b1, b3, b4, d1, d3, d4); v[7] = det3x3(a1, a3, a4, b1, b3, b4, c1, c3, c4); v[8] = det3x3(b1, b2, b4, c1, c2, c4, d1, d2, d4); v[9] = -det3x3(a1, a2, a4, c1, c2, c4, d1, d2, d4); v[10] = det3x3(a1, a2, a4, b1, b2, b4, d1, d2, d4); v[11] = -det3x3(a1, a2, a4, b1, b2, b4, c1, c2, c4); v[12] = -det3x3(b1, b2, b3, c1, c2, c3, d1, d2, d3); v[13] = det3x3(a1, a2, a3, c1, c2, c3, d1, d2, d3); v[14] = -det3x3(a1, a2, a3, b1, b2, b3, d1, d2, d3); v[15] = det3x3(a1, a2, a3, b1, b2, b3, c1, c2, c3); } bool glmatrixf::invert(const glmatrixf &m, float mindet) { float a1 = m.v[0], b1 = m.v[4], c1 = m.v[8], d1 = m.v[12]; adjoint(m); float det = a1*v[0] + b1*v[1] + c1*v[2] + d1*v[3]; // float det = m.determinant(); if(fabs(det) < mindet) return false; float invdet = 1/det; loopi(16) v[i] *= invdet; return true; } // multithreading and ipc tools wrapper for the server // all embedded servers and all standalone servers except on linux use SDL // the standalone linux version uses native linux libraries - and also makes use of shared memory #ifdef AC_USE_SDL_THREADS #include "SDL_timer.h" #include "SDL_thread.h" // also fetches SDL_mutex.h #else #include #include #include #endif static int sl_sem_errorcountdummy = 0; #ifdef AC_USE_SDL_THREADS sl_semaphore::sl_semaphore(int init, int *ecnt) { data = (void *)SDL_CreateSemaphore(init); errorcount = ecnt ? ecnt : &sl_sem_errorcountdummy; if(data == NULL) (*errorcount)++; } sl_semaphore::~sl_semaphore() { if(data) SDL_DestroySemaphore((SDL_sem *) data); } void sl_semaphore::wait() { if(SDL_SemWait((SDL_sem *) data) != 0) (*errorcount)++; } int sl_semaphore::trywait() { return SDL_SemTryWait((SDL_sem *) data); } int sl_semaphore::timedwait(int howlongmillis) { return SDL_SemWaitTimeout((SDL_sem *) data, howlongmillis); } int sl_semaphore::getvalue() { return SDL_SemValue((SDL_sem *) data); } void sl_semaphore::post() { if(SDL_SemPost((SDL_sem *) data) != 0) (*errorcount)++; } #else sl_semaphore::sl_semaphore(int init, int *ecnt) { errorcount = ecnt ? ecnt : &sl_sem_errorcountdummy; data = (void *) new sem_t; if(data == NULL || sem_init((sem_t *) data, 0, init) != 0) (*errorcount)++; } sl_semaphore::~sl_semaphore() { if(data) { if(sem_destroy((sem_t *) data) != 0) (*errorcount)++; delete (sem_t *)data; } } void sl_semaphore::wait() { if(sem_wait((sem_t *) data) != 0) (*errorcount)++; } int sl_semaphore::trywait() { return sem_trywait((sem_t *) data); } int sl_semaphore::timedwait(int howlongmillis) { struct timespec t; if(clock_gettime(CLOCK_REALTIME, &t)) { (*errorcount)++; return sem_trywait((sem_t *) data); } howlongmillis += t.tv_nsec / 1000000; t.tv_nsec = (howlongmillis % 1000) * 1000000; t.tv_sec += howlongmillis / 1000; return sem_timedwait((sem_t *) data, &t); } int sl_semaphore::getvalue() { int ret; if(sem_getvalue((sem_t *) data, &ret) != 0) (*errorcount)++; return ret; } void sl_semaphore::post() { if(sem_post((sem_t *) data) != 0) (*errorcount)++; } #endif // (wrapping threads is slightly ugly, since SDL threads use a different return value (int) than pthreads (void *) - and that can't be solved with a typecast) #ifdef AC_USE_SDL_THREADS struct sl_threadinfo { int (*fn)(void *); void *data; SDL_Thread *handle; volatile char done; }; static int sl_thread_indir(void *info) { int res = (*((sl_threadinfo*)info)->fn)(((sl_threadinfo*)info)->data); ((sl_threadinfo*)info)->done = 1; return res; } void *sl_createthread(int (*fn)(void *), void *data, const char *name) { sl_threadinfo *ti = new sl_threadinfo; ti->data = data; ti->fn = fn; ti->done = 0; ti->handle = SDL_CreateThread(sl_thread_indir, name, ti); return (void *) ti; } int sl_waitthread(void *ti) { int res; SDL_WaitThread(((sl_threadinfo *)ti)->handle, &res); delete (sl_threadinfo *) ti; return res; } static vector oldthreads; static sl_semaphore sem_oldthreads(1, NULL); void sl_detachthread(void *ti) // SDL can't actually detach threads, so this is manual cleanup { if(ti && sl_pollthread(ti)) { SDL_WaitThread(((sl_threadinfo *)ti)->handle, NULL); delete (sl_threadinfo *) ti; ti = NULL; } if(ti || sem_oldthreads.getvalue() > 0) { sem_oldthreads.wait(); if(ti) oldthreads.add((sl_threadinfo *)ti); loopvrev(oldthreads) { if(oldthreads[i]->done) { SDL_WaitThread(oldthreads[i]->handle, NULL); delete oldthreads.remove(i); } } sem_oldthreads.post(); } } static SDL_threadID mainthreadid = SDL_ThreadID(); bool ismainthread() { return mainthreadid == SDL_ThreadID(); } #else struct sl_threadinfo { int (*fn)(void *); void *data; pthread_t handle; int res; volatile char done; }; static void *sl_thread_indir(void *info) { sl_threadinfo *ti = (sl_threadinfo*) info; ti->res = (ti->fn)(ti->data); ti->done = 1; return &ti->res; } void *sl_createthread(int (*fn)(void *), void *data, const char *name) { sl_threadinfo *ti = new sl_threadinfo; ti->data = data; ti->fn = fn; ti->done = 0; pthread_create(&(ti->handle), NULL, sl_thread_indir, ti); if(name) pthread_setname_np(ti->handle, name); return (void *) ti; } int sl_waitthread(void *ti) { void *res; pthread_join(((sl_threadinfo *)ti)->handle, &res); int ires = *((int *)res); delete (sl_threadinfo *) ti; return ires; } static vector oldthreads; static sl_semaphore sem_oldthreads(1, NULL); void sl_detachthread(void *ti) { if(ti) pthread_detach(((sl_threadinfo *)ti)->handle); if(ti || sem_oldthreads.getvalue() > 0) { sem_oldthreads.wait(); if(ti) oldthreads.add((sl_threadinfo *)ti); loopvrev(oldthreads) if(oldthreads[i]->done) delete oldthreads.remove(i); sem_oldthreads.post(); } } static pthread_t mainthreadid = pthread_self(); bool ismainthread() { return pthread_equal(mainthreadid, pthread_self()) != 0; } #endif bool sl_pollthread(void *ti) { return ((sl_threadinfo*)ti)->done != 0; } // platform dependent stuff not covered by enet (use POSIX or, if possible, SDL) #ifdef AC_USE_SDL_THREADS void sl_sleep(int duration) { SDL_Delay(duration); } #else void sl_sleep(int duration) { struct timespec t = { duration / 1000, (duration % 1000) * 1000000 }; nanosleep(&t, NULL); } #endif void parseupdatelist(hashtable &ht, char *buf, const char *prefix, const char *suffix) { for(char *d = buf; *d; d++) if(!isalnum(*d) && !strchr("._-() /\n", *d)) *d = ' '; // allowed chars in media path strings (except ' ') char *p, *l = buf, *m; int rev, *revp, plen = prefix ? (int)strlen(prefix) : 0, slen = suffix ? (int)strlen(suffix) : 0; do { if((p = strchr(l, '\n'))) *p = '\0'; // break into single lines l += strspn(l, " "); // skip leading spaces if((m = strchr(l, ' ')) && (rev = atoi(m + 1))) // string has a space and a number != 0 after it { *m = '\0'; if((!plen || !strncmp(l, prefix, plen)) && // prefix is either not required or present (!slen || (m - l > slen && !strcmp(m - slen, suffix)))) // suffix is either not required or present { l += plen; // skip prefix m[-slen] = '\0'; // cut suffix revp = ht.access(l); if(revp) *revp = rev; else ht.access(newstring(l), rev); } } l = p + 1; } while(p); } assaultcube-1.2.0.2.1/source/src/tools.h000066400000000000000000000744471352165075300177530ustar00rootroot00000000000000// generic useful stuff for any C++ program #ifndef _TOOLS_H #define _TOOLS_H #ifdef NULL #undef NULL #endif #define NULL 0 typedef unsigned char uchar; typedef unsigned short ushort; typedef unsigned int uint; #ifdef _DEBUG #ifdef __GNUC__ #define ASSERT(c) if(!(c)) { fflush(NULL); asm("int $3"); } #else #define ASSERT(c) if(!(c)) { fflush(NULL); { __asm int 3 } } #endif #include #define DEBUG(v) if(DEBUGCOND) { std::cout << behindpath(__FILE__) << ":" << __LINE__ << " " << __FUNCTION__ << "(..) " << v << std::endl; } #define DEBUGVAR(v) if(DEBUGCOND) { std::cout << behindpath(__FILE__) << ":" << __LINE__ << " " << __FUNCTION__ << "(..) " << #v << " = " << v << std::endl; } #define DEBUGCODE(v) v #else #define DEBUG(v) {} #define DEBUGVAR(v) {} #define DEBUGCODE(v) #define ASSERT(c) if(c) {} #endif #ifdef NO_POSIX_R extern char *strtok_r(char *s, const char *delim, char **b); // homebrew #endif #ifdef swap #undef swap #endif template static inline void swap(T &a, T &b) { T t = a; a = b; b = t; } #ifdef max #undef max #endif #ifdef min #undef min #endif template static inline T max(T a, T b) { return a > b ? a : b; } template static inline T min(T a, T b) { return a < b ? a : b; } template inline T pow2(T x) { return x*x; } inline int iabs(int n) { return labs(n); } #define clamp(x,minval,maxval) (max(minval, min(x, maxval))) #define rnd(x) ((int)(randomMT()&0xFFFFFF)%(x)) #define rndscale(x) (float((randomMT()&0xFFFFFF)*double(x)/double(0xFFFFFF))) #define detrnd(s, x) ((int)(((((uint)(s))*1103515245+12345)>>16)%(x))) #define loop(v,m) for(int v = 0; v= 0; i--) #define DELETEP(p) if(p) { delete p; p = 0; } #define DELETEA(p) if(p) { delete[] p; p = 0; } #define PI (3.141592654f) #define PI2 (6.283185307f) /* 2 * PI */ #define SQRT2 (1.414213562f) #define SQRT3 (1.732050808f) #define RAD (0.01745329252f) /* PI / 180 */ #define NEARZERO (0.000245f) /* epsilon for 1< moved to makefile #else #define PRINTFARGS(fmt, args) #endif // easy safe strings #define MAXSTRLEN 260 typedef char string[MAXSTRLEN]; inline void vformatstring(char *d, const char *fmt, va_list v, int len = MAXSTRLEN) { _vsnprintf(d, len, fmt, v); d[len-1] = 0; } inline char *copystring(char *d, const char *s, size_t len = MAXSTRLEN) { strncpy(d, s, len); d[len-1] = 0; return d; } inline char *concatstring(char *d, const char *s, size_t len = MAXSTRLEN) { size_t used = strlen(d); return used < len ? copystring(d+used, s, len-used) : d; } extern char *concatformatstring(char *d, const char *s, ...) PRINTFARGS(2, 3); struct stringformatter { char *buf; stringformatter(char *buf): buf((char *)buf) {} void operator()(const char *fmt, ...) PRINTFARGS(2, 3) { va_list v; va_start(v, fmt); vformatstring(buf, fmt, v); va_end(v); } }; #define formatstring(d) stringformatter((char *)d) #define defformatstring(d) string d; formatstring(d) #define defvformatstring(d,last,fmt) string d; { va_list ap; va_start(ap, last); vformatstring(d, fmt, ap); va_end(ap); } #define MAXMAPNAMELEN 64 inline bool validmapname(const char *s) { int len = strlen(s); if(len > MAXMAPNAMELEN) return false; if(len == 3 || len == 4) { char uc[4]; loopi(3) uc[i] = toupper(s[i]); uc[3] = '\0'; const char *resd = "COMLPTCONPRNAUXNUL", *fnd = strstr(resd, uc); if(fnd) { int pos = (int) (fnd - resd); if(pos == 0 || pos == 3) { if(isdigit(s[3])) return false; // COMx, LPTx } else if(pos % 3 == 0) return false; // CON, PRN, AUX, NUL } } while(*s != '\0') { if(!isalnum(*s) && *s != '_' && *s != '-' && *s != '.') return false; ++s; } return true; } #define loopv(v) for(int i = 0; i<(v).length(); i++) #define loopvj(v) for(int j = 0; j<(v).length(); j++) #define loopvk(v) for(int k = 0; k<(v).length(); k++) #define loopvrev(v) for(int i = (v).length()-1; i>=0; i--) #define loopvjrev(v) for(int j = (v).length()-1; j>=0; j--) template struct databuf { enum { OVERREAD = 1<<0, OVERWROTE = 1<<1 }; T *buf; int len, maxlen; uchar flags; databuf() : buf(NULL), len(0), maxlen(0), flags(0) {} template databuf(T *buf, U maxlen) : buf(buf), len(0), maxlen((int)maxlen), flags(0) {} const T &get() { static T overreadval = 0; if(len charbuf; typedef databuf ucharbuf; struct packetbuf : ucharbuf { ENetPacket *packet; int growth; packetbuf(ENetPacket *packet) : ucharbuf(packet->data, packet->dataLength), packet(packet), growth(0) {} packetbuf(int growth, int pflags = 0) : growth(growth) { packet = enet_packet_create(NULL, growth, pflags); buf = (uchar *)packet->data; maxlen = packet->dataLength; } ~packetbuf() { cleanup(); } void reliable() { packet->flags |= ENET_PACKET_FLAG_RELIABLE; } void resize(int n) { enet_packet_resize(packet, n); buf = (uchar *)packet->data; maxlen = packet->dataLength; } void checkspace(int n) { if(len + n > maxlen && packet && growth > 0) resize(max(len + n, maxlen + growth)); } ucharbuf subbuf(int sz) { checkspace(sz); return ucharbuf::subbuf(sz); } void put(const uchar &val) { checkspace(1); ucharbuf::put(val); } void put(const uchar *vals, int numvals) { checkspace(numvals); ucharbuf::put(vals, numvals); } bool overwrote() const { return false; } ENetPacket *finalize() { resize(len); return packet; } void cleanup() { if(growth > 0 && packet && !packet->referenceCount) { enet_packet_destroy(packet); packet = NULL; buf = NULL; len = maxlen = 0; } } }; template struct bitbuf { T &q; int blen; bitbuf(T &oq) : q(oq), blen(0) {} int getbits(int n) { int res = 0, p = 0; while(n > 0) { if(!blen) q.get(); int r = 8 - blen; if(r > n) r = n; res |= ((q.buf[q.len - 1] >> blen) & ((1 << r) - 1)) << p; n -= r; p += r; blen = (blen + r) % 8; } return res; } void putbits(int n, int v) { while(n > 0) { if(!blen) { q.put(0); if(q.overwrote()) return; } int r = 8 - blen; if(r > n) r = n; q.buf[q.len - 1] |= (v & ((1 << r) - 1)) << blen; n -= r; v >>= r; blen = (blen + r) % 8; } } int rembits() { return (8 - blen) % 8; } // 0..7 bits remaining in current byte }; template struct vector { static const int MINSIZE = 8; T *buf; int alen, ulen; vector() : buf(NULL), alen(0), ulen(0) { } vector(const vector &v) : buf(NULL), alen(0), ulen(0) { *this = v; } ~vector() { shrink(0); if(buf) delete[] (uchar *)buf; } vector &operator=(const vector &v) { shrink(0); if(v.length() > alen) growbuf(v.length()); loopv(v) add(v[i]); return *this; } T &add(const T &x) { if(ulen==alen) growbuf(ulen+1); new (&buf[ulen]) T(x); return buf[ulen++]; } T &add() { if(ulen==alen) growbuf(ulen+1); new (&buf[ulen]) T; return buf[ulen++]; } T &dup() { if(ulen==alen) growbuf(ulen+1); new (&buf[ulen]) T(buf[ulen-1]); return buf[ulen++]; } bool inrange(size_t i) const { return i=0 && i 0); return buf[--ulen]; } T &last() { ASSERT(ulen > 0); return buf[ulen-1]; } void drop() { ASSERT(ulen > 0); buf[--ulen].~T(); } bool empty() const { return ulen==0; } int capacity() const { return alen; } int length() const { return ulen; } T &operator[](int i) { ASSERT(i>=0 && i= 0 && i=0 && i<=ulen); while(ulen>i) drop(); } void setsize(int i) { ASSERT(i>=0 && i<=ulen); ulen = i; } void deletecontents() { while(!empty()) delete pop(); } void deletearrays() { while(!empty()) delete[] pop(); } T *getbuf() { return buf; } const T *getbuf() const { return buf; } bool inbuf(const T *e) const { return e >= buf && e < &buf[ulen]; } template void sort(int (__cdecl *cf)(ST *, ST *), int i = 0, int n = -1) { qsort(&buf[i], n<0 ? ulen : n, sizeof(T), (int (__cdecl *)(const void *,const void *))cf); } template T *search(T *key, int (__cdecl *cf)(ST *, ST *), int i = 0, int n = -1) { return (T *) bsearch(key, &buf[i], n<0 ? ulen : n, sizeof(T), (int (__cdecl *)(const void *,const void *))cf); } void growbuf(int sz) { int olen = alen; if(!alen) alen = max(MINSIZE, sz); else while(alen < sz) alen *= 2; if(alen <= olen) return; uchar *newbuf = new uchar[alen*sizeof(T)]; if(olen > 0) { memcpy(newbuf, buf, olen*sizeof(T)); delete[] (uchar *)buf; } buf = (T *)newbuf; } databuf reserve(int sz) { if(ulen+sz > alen) growbuf(ulen+sz); return databuf(&buf[ulen], sz); } void advance(int sz) { ulen += sz; } void addbuf(const databuf &p) { advance(p.length()); } T *pad(int n) { T *buf = reserve(n).buf; advance(n); return buf; } void put(const T &v) { add(v); } void put(const T *v, int n) { databuf buf = reserve(n); buf.put(v, n); addbuf(buf); } void remove(int i, int n) { for(int p = i+n; pi; p--) buf[p] = buf[p-1]; buf[i] = e; return buf[i]; } T *insert(int i, const T *e, int n) { if(ulen+n>alen) growbuf(ulen+n); loopj(n) add(T()); for(int p = ulen-1; p>=i+n; p--) buf[p] = buf[p-n]; loopj(n) buf[i+j] = e[j]; return &buf[i]; } }; static inline uint hthash(const char *key) { uint h = 5381; for(int i = 0, k; (k = key[i]); i++) h = ((h<<5)+h)^k; // bernstein k=33 xor return h; } static inline bool htcmp(const char *x, const char *y) { return !strcmp(x, y); } static inline uint hthash(const uchar *key) { return *((uint *)key); } static inline bool htcmp(const uchar *x, const uchar *y) // assume "uchar *" points to 32byte public keys { return !memcmp(x, y, 32); } static inline uint hthash(int key) { return key; } static inline bool htcmp(int x, int y) { return x==y; } static inline uint hthash(uint key) { return key; } static inline bool htcmp(uint x, uint y) { return x==y; } template struct hashtable { typedef K key; typedef const K const_key; typedef T value; typedef const T const_value; enum { CHUNKSIZE = 16 }; struct chain { T data; K key; chain *next; }; struct chainchunk { chain chains[CHUNKSIZE]; chainchunk *next; }; int size; int numelems; chain **table; chain *enumc; chainchunk *chunks; chain *unused; hashtable(int size = 1<<10) : size(size) { numelems = 0; chunks = NULL; unused = NULL; table = new chain *[size]; loopi(size) table[i] = NULL; } ~hashtable() { DELETEA(table); deletechunks(); } void insertchains(chainchunk *emptychunk) { loopi(CHUNKSIZE-1) emptychunk->chains[i].next = &emptychunk->chains[i+1]; emptychunk->chains[CHUNKSIZE-1].next = unused; unused = emptychunk->chains; } chain *insert(const K &key, uint h) { if(!unused) { chainchunk *chunk = new chainchunk; chunk->next = chunks; chunks = chunk; insertchains(chunk); } chain *c = unused; unused = unused->next; c->key = key; c->next = table[h]; table[h] = c; numelems++; return c; } #define HTFIND(success, fail) \ uint h = hthash(key)&(size-1); \ for(chain *c = table[h]; c; c = c->next) \ { \ if(htcmp(key, c->key)) return (success); \ } \ return (fail); T *access(const K &key) { HTFIND(&c->data, NULL); } T &access(const K &key, const T &data) { HTFIND(c->data, insert(key, h)->data = data); } T &operator[](const K &key) { HTFIND(c->data, insert(key, h)->data); } #undef HTFIND bool remove(const K &key) { uint h = hthash(key)&(size-1); for(chain **p = &table[h], *c = table[h]; c; p = &c->next, c = c->next) { if(htcmp(key, c->key)) { *p = c->next; c->data.~T(); c->key.~K(); new (&c->data) T; new (&c->key) K; c->next = unused; unused = c; numelems--; return true; } } return false; } void deletechunks() { for(chainchunk *nextchunk; chunks; chunks = nextchunk) { nextchunk = chunks->next; delete chunks; } } void clear(bool del = true) { loopi(size) table[i] = NULL; numelems = 0; unused = NULL; if(del) deletechunks(); else { for(chainchunk *chunk = chunks; chunk; chunk = chunk->next) insertchains(chunk); } } }; template struct ringbuf { volatile int in, out; T data[SIZE]; ringbuf() { clear(); } void clear() { in = out = 0; } bool empty() const { return in == out; } bool full() const { return length() >= SIZE - 1; } int maxsize() const { return SIZE - 1; } // yes, only SIZE-1, sry int length() const { return (SIZE + in - out) % SIZE; } T &remove() // get one (crashes, if empty) { ASSERT(!empty()); T &res = data[out]; out = (out + 1) % SIZE; return res; } T *remove(int *n) // get n (reduces n, if the data wraps around or isn't available) { if(*n > length()) *n = length(); T *res = data + out; if(out + *n >= SIZE) *n = SIZE - out; out = (out + *n) % SIZE; return res; } T *peek(int *n) // look at n without removing (reduces n, if the data wraps around or isn't available) { if(*n > length()) *n = length(); if(out + *n >= SIZE) *n = SIZE - out; return data + out; } void add(const T &e) // add one (crashes, if full) -- between threads, better use stage & commit { ASSERT(!full()); volatile int i; data[(i = in)] = e; in = (i + 1) % SIZE; } T &stage(const T &e) // add one without acknowledging it { return (data[in] = e); } T *stage() // add one without acknowledging it { return data + in; } void stage(const T *e, int n) // add n without acknowledging it { int n1 = in + n >= SIZE ? SIZE - in : n, n2 = n - n1; memcpy(data + in, e, n1 * sizeof(T)); if(n2) memcpy(data, e + n1, n2 * sizeof(T)); } void commit() // add staged one (crashes, if full) { ASSERT(!full()); in = (in + 1) % SIZE; } void commit(int n) // add staged n (crashes, if full) { ASSERT(length() + n < SIZE); in = (in + n) % SIZE; } void add(const T *e, int n) // add n { stage(e, n); commit(n); } T &operator[](int i) // [0] is the one, that remove() will get next (in other words, [0] is the oldest entry, [length()-1] was the last added one, loopv goes from old to new) { ASSERT(i >= 0 && i < length()); return data[(out + i) % SIZE]; } const T &operator[](int i) const { ASSERT(i >= 0 && i < length()); return data[(out + i) % SIZE]; } }; #define itoa(s, i) sprintf(s, "%d", i) #define ftoa(s, f) sprintf(s, (f) == int(f) ? "%.1f" : "%.7g", f) #define enumeratekt(ht,k,e,t,f,b) loopi((ht).size) for(hashtable::chain *enumc = (ht).table[i]; enumc;) { hashtable::const_key &e = enumc->key; t &f = enumc->data; enumc = enumc->next; b; } #define enumeratek(ht,k,e,b) loopi((ht).size) for((ht).enumc = (ht).table[i]; (ht).enumc;) { k &e = (ht).enumc->key; (ht).enumc = (ht).enumc->next; b; } #define enumerate(ht,t,e,b) loopi((ht).size) for((ht).enumc = (ht).table[i]; (ht).enumc;) { t &e = (ht).enumc->data; (ht).enumc = (ht).enumc->next; b; } #ifndef STANDALONE // ease time measurement struct stopwatch { uint millis; // SDL_GetTicks() returns an uint value stopwatch() : millis(0) {} void start() { millis = SDL_GetTicks(); } // returns elapsed time int elapsed() { uint time = SDL_GetTicks() - millis; // subtraction also works in case of timer wraparounds return time; } }; #endif inline char *newstring(size_t l) { return new char[l+1]; } inline char *newstring(const char *s, size_t l) { return copystring(newstring(l), s, l+1); } inline char *newstring(const char *s) { return newstring(s, strlen(s)); } inline char *newstringbuf() { return newstring(MAXSTRLEN-1); } inline char *newstringbuf(const char *s) { return newstring(s, MAXSTRLEN-1); } inline void delstring(const char *s) { delete[] (char *)s; } #define DELSTRING(s) if(s) { delstring(s); s = NULL; } #ifndef INT_LEAST64_MIN typedef unsigned long long int uint64_t; #endif const int islittleendian = 1; #ifdef SDL_BYTEORDER #define endianswap16 SDL_Swap16 #define endianswap32 SDL_Swap32 #define endianswap64 SDL_Swap64 #else #if defined(__GNUC__) && /*!defined(__clang__) && */!defined(__ICL) && __GNUC__ >= 4 && !defined(WIN32) && !defined(__APPLE__) inline ushort endianswap16(ushort n) { return __builtin_bswap16(n); } inline uint endianswap32(uint n) { return __builtin_bswap32(n); } inline uint64_t endianswap64(uint64_t n) { return __builtin_bswap64(n); } #else inline ushort endianswap16(ushort n) { return (n<<8) | (n>>8); } inline uint endianswap32(uint n) { return (n<<24) | (n>>24) | ((n>>8)&0xFF00) | ((n<<8)&0xFF0000); } inline uint64_t endianswap64(uint64_t n) { return ((uint64_t)endianswap32((uint)n) << 32) | ((uint64_t)endianswap32((uint)(n >> 32))); } #endif #endif template inline T endianswap(T n) { union { T t; uchar u[sizeof(T)]; } s, d; s.t = n; loopi(sizeof(T)) d.u[i] = s.u[sizeof(T) - 1 - i]; return d.t; } template<> inline ushort endianswap(ushort n) { return endianswap16(n); } template<> inline short endianswap(short n) { return endianswap16(n); } template<> inline uint endianswap(uint n) { return endianswap32(n); } template<> inline int endianswap(int n) { return endianswap32(n); } template<> inline uint64_t endianswap(uint64_t n) { return endianswap64(n); } template inline void endianswap(T *buf, int len) { for(T *end = &buf[len]; buf < end; buf++) *buf = endianswap(*buf); } template inline T endiansame(T n) { return n; } template inline void endiansame(T *buf, int len) {} #ifdef SDL_BYTEORDER #if SDL_BYTEORDER == SDL_LIL_ENDIAN #define lilswap endiansame #define bigswap endianswap #else #define lilswap endianswap #define bigswap endiansame #endif #else template inline T lilswap(T n) { return *(const uchar *)&islittleendian ? n : endianswap(n); } template inline void lilswap(T *buf, int len) { if(!*(const uchar *)&islittleendian) endianswap(buf, len); } template inline T bigswap(T n) { return *(const uchar *)&islittleendian ? endianswap(n) : n; } template inline void bigswap(T *buf, int len) { if(*(const uchar *)&islittleendian) endianswap(buf, len); } #endif #define uint2ip(address, ip) uchar ip[4]; \ if(isbigendian())\ { \ enet_uint32 big = endianswap(address);\ memcpy(&ip, &big, 4);\ }\ else memcpy(&ip, &address, 4);\ /* workaround for some C platforms that have these two functions as macros - not used anywhere */ #ifdef getchar #undef getchar #endif #ifdef putchar #undef putchar #endif struct stream { virtual ~stream() {} virtual void close() = 0; virtual bool end() = 0; virtual long tell() { return -1; } virtual bool seek(long offset, int whence = SEEK_SET) { return false; } virtual long size(); virtual void fflush() {} virtual int read(void *buf, int len) { return 0; } virtual int write(const void *buf, int len) { return 0; } virtual int getchar() { uchar c; return read(&c, 1) == 1 ? c : -1; } virtual bool putchar(int n) { uchar c = n; return write(&c, 1) == 1; } virtual bool getline(char *str, int len); virtual bool putstring(const char *str) { int len = (int)strlen(str); return write(str, len) == len; } virtual bool putline(const char *str) { return putstring(str) && putchar('\n'); } virtual int printf(const char *fmt, ...) PRINTFARGS(2, 3) { return -1; } virtual uint getcrc() { return 0; } template bool put(T n) { return write(&n, sizeof(n)) == sizeof(n); } template bool putlil(T n) { return put(lilswap(n)); } template bool putbig(T n) { return put(bigswap(n)); } template T get() { T n; return read(&n, sizeof(n)) == sizeof(n) ? n : 0; } template T getlil() { return lilswap(get()); } template T getbig() { return bigswap(get()); } #ifndef STANDALONE SDL_RWops *rwops(); #endif }; extern string _timestringbuffer; extern const char *timestring(time_t t, bool local = false, const char *fmt = NULL, char *buf = _timestringbuffer); inline const char *timestring(bool local = false, const char *fmt = NULL, char *buf = _timestringbuffer) { return timestring(time(NULL), local, fmt, buf); } extern const char *asctimestr(); extern const char *numtime(); extern void transformoldentitytypes(int mapversion, uchar &enttype); extern int fixmapheadersize(int version, int headersize); extern char *path(char *s); extern char *path(const char *s, bool copy); extern char *unixpath(char *s); extern const char *behindpath(const char *s); extern const char *parentdir(const char *directory); extern bool fileexists(const char *path, const char *mode); extern bool createdir(const char *path); extern size_t fixpackagedir(char *dir); extern void sethomedir(const char *dir); extern bool havehomedir(); extern void addpackagedir(const char *dir); extern int findfilelocation; enum { FFL_WORKDIR = -2, FFL_HOME = -1, FFL_ZIP = 0 }; extern const char *findfile(const char *filename, const char *mode); extern int getfilesize(const char *filename); extern stream *openvecfile(vector *s = NULL, bool autodelete = true); extern stream *openmemfile(const uchar *buf, int size, int *refcnt); extern bool findzipfile(const char *name); extern stream *openzipfile(const char *filename, const char *mode); extern stream *openfile(const char *filename, const char *mode); extern stream *opentempfile(const char *filename, const char *mode); extern stream *opengzfile(const char *filename, const char *mode, stream *file = NULL, int level = Z_BEST_COMPRESSION); extern char *loadfile(const char *fn, int *size, const char *mode = NULL); extern int streamcopy(stream *dest, stream *source, int maxlen = INT_MAX); extern void filerotate(const char *basename, const char *ext, int keepold, const char *oldformat = NULL); extern const char *stream_capabilities(); extern void listsubdirs(const char *dir, vector &subdirs, int (__cdecl *sf)(const char **, const char **)); extern bool listdir(const char *dir, const char *ext, vector &files); extern void listfiles(const char *dir, const char *ext, vector &files, int (__cdecl *sf)(const char **, const char **) = NULL); extern void listfilesrecursive(const char *dir, vector &files, int level = 0); extern void listdirsrecursive(const char *dir, vector &subdirs, int level = 0); extern void listzipfiles(const char *dir, const char *ext, vector &files); extern void listzipdirs(const char *dir, vector &subdirs); extern bool delfile(const char *path); extern void backup(char *name, char *backupname); extern bool validzipmodname(char *name); extern void *zipmanualopen(stream *f, vector &files); extern stream *zipmanualstream(void *a, int n); extern int zipmanualread(void *a, int n, stream *f, int maxlen = INT_MAX); extern void zipmanualclose(void *a); extern struct mapstats *loadmapstats(const char *filename, bool getlayout); extern bool cmpb(void *b, int n, enet_uint32 c); extern bool cmpf(char *fn, enet_uint32 c); extern enet_uint32 adler(unsigned char *data, size_t len); extern void endianswap(void *, int, int); extern bool isbigendian(); extern void strtoupper(char *t, const char *s = NULL); extern void seedMT(uint seed); extern uint randomMT(void); extern void popMT(void); extern void entropy_init(uint seed); extern void entropy_save(); extern void entropy_add_byte(uchar b); extern void entropy_add_block(const uchar *s, int len); extern void entropy_get(uchar *buf, int len); struct iprange { enet_uint32 lr, ur; }; extern const char *atoip(const char *s, enet_uint32 *ip); extern const char *atoipr(const char *s, iprange *ir); extern const char *iptoa(const enet_uint32 ip); extern const char *iprtoa(const struct iprange &ipr); extern int cmpiprange(const struct iprange *a, const struct iprange *b); extern int cmpipmatch(const struct iprange *a, const struct iprange *b); extern int cvecprintf(vector &v, const char *s, ...) PRINTFARGS(2, 3); extern const char *hiddenpwd(const char *pwd, int showchars = 0); extern int getlistindex(const char *key, const char *list[], bool acceptnumeric = true, int deflt = -1); extern void parseupdatelist(hashtable &ht, char *buf, const char *prefix = NULL, const char *suffix = NULL); struct twoint { int key, val; }; struct threeint { int key, val1, val2; }; extern int cmpintasc(const int *a, const int *b); // leads to ascending sort order extern int cmpintdesc(const int *a, const int *b); // leads to descending sort order extern int stringsort(const char **a, const char **b); extern int stringsortrev(const char **a, const char **b); extern int stringsortignorecase(const char **a, const char **b); extern int stringsortignorecaserev(const char **a, const char **b); #if defined(WIN32) && !defined(_DEBUG) && !defined(__GNUC__) extern void stackdumper(unsigned int type, EXCEPTION_POINTERS *ep); #endif struct sl_semaphore { void *data; int *errorcount; sl_semaphore(int init, int *errorcount); // init: initial semaphore value; errorcount: pointer to error counter for semaphore-related errors or NULL ~sl_semaphore(); void wait(); // blocks, until semaphore gets available int trywait(); // returns 0, if semaphore was locked (like wait(), but returns !=0 instead of blocking) int timedwait(int howlongmillis); // like trywait(), but waits for a litte before returning failure int getvalue(); // returns current semaphore value void post(); // increments (unlocks) semaphore }; extern void *sl_createthread(int (*fn)(void *), void *data, const char *name = NULL); extern int sl_waitthread(void *ti); extern bool sl_pollthread(void *ti); extern void sl_detachthread(void *ti); extern void sl_sleep(int duration); extern bool ismainthread(); #endif assaultcube-1.2.0.2.1/source/src/tristrip.h000066400000000000000000000211101352165075300204460ustar00rootroot00000000000000//VAR(dbgts, 0, 0, 1); const int dbgts = 0; VAR(tsswap, 0, 1, 1); struct tristrip { struct drawcall { GLenum type; GLuint start, minvert, maxvert; GLsizei count; drawcall() {} drawcall(GLenum type, GLuint start, GLsizei count = 0) : type(type), start(start), minvert(~0U), maxvert(0), count(count) {} }; enum { // must be larger than all other triangle/vert indices UNUSED = 0xFFFE, REMOVED = 0xFFFF }; struct triangle { ushort v[3], n[3]; bool link(ushort neighbor, ushort old = UNUSED) { loopi(3) { if(n[i]==neighbor) return true; else if(n[i]==old) { n[i] = neighbor; return true; } } if(dbgts && old==UNUSED) conoutf("excessive links"); return false; } void unlink(ushort neighbor, ushort unused = UNUSED) { loopi(3) if(n[i]==neighbor) n[i] = unused; } int numlinks() const { int num = 0; loopi(3) if(n[i] triangles; vector connectivity[4]; vector nodes; template void addtriangles(const T *tris, int numtris) { if(dbgts) conoutf("addtriangles: tris = %d, inds = %d", numtris, numtris*3); loopi(numtris) { triangle &tri = triangles.add(); loopj(3) { tri.v[j] = tris[i].vert[j]; tri.n[j] = UNUSED; } if(tri.v[0]==tri.v[1] || tri.v[1]==tri.v[2] || tri.v[2]==tri.v[0]) { if(dbgts) conoutf("degenerate triangle"); triangles.drop(); } } } struct edge { ushort from, to; }; void findconnectivity() { hashtable edges; nodes.setsize(0); loopv(triangles) { triangle &tri = triangles[i]; loopj(3) { edge e = { tri.v[j==2 ? 0 : j+1], tri.v[j] }; edges.access(e, i); while(nodes.length()<=tri.v[j]) nodes.add(0); nodes[tri.v[j]]++; } } loopv(triangles) { triangle &tri = triangles[i]; loopj(3) { edge e = { tri.v[j], tri.v[j==2 ? 0 : j+1] }; ushort *owner = edges.access(e); if(!owner) continue; else if(!tri.link(*owner)) { if(dbgts) conoutf("failed linkage 1: %d -> %d", *owner, i); } else if(!triangles[*owner].link(i)) { if(dbgts) conoutf("failed linkage 2: %d -> %d", *owner, i); tri.unlink(*owner); } } } loopi(4) connectivity[i].setsize(0); loopv(triangles) connectivity[triangles[i].numlinks()].add(i); if(dbgts) conoutf("no connections: %d", connectivity[0].length()); } void removeconnectivity(ushort i) { triangle &tri = triangles[i]; loopj(3) if(tri.n[j] nodes[v1] ? 1 : -1; } else if(nexttri.hasvert(v2)) continue; else score += nodes[v1] > nodes[v2] ? 1 : -1; if(!tsswap && swap) continue; score += swap ? 1 : -1; } if(score < nextscore) { next = tri.n[i]; nextswap = swap; nextscore = score; } } if(next!=UNUSED) { tri.unlink(next, REMOVED); connectivity[triangles[next].numlinks()].replacewithlast(next); removeconnectivity(next); } return next; } void buildstrip(vector &strip, bool reverse = false, bool prims = false) { ushort prev = leastconnected(); if(prev==UNUSED) return; triangle &first = triangles[prev]; bool doswap; ushort cur = nexttriangle(first, doswap); if(cur==UNUSED) { loopi(3) strip.add(first.v[!prims && reverse && i>=1 ? 3-i : i]); return; } int from = findedge(first, triangles[cur]), to = findedge(first, triangles[cur], first.v[from]); if(from+1!=to) swap(from, to); strip.add(first.v[(to+1)%3]); if(reverse) swap(from, to); strip.add(first.v[from]); strip.add(first.v[to]); ushort v1 = first.v[to], v2 = first.v[from]; while(cur!=UNUSED) { prev = cur; cur = nexttriangle(triangles[prev], doswap, v1, v2); if(doswap) strip.add(v2); ushort v = triangles[prev].diffvert(v1, v2); strip.add(v); if(!doswap) v2 = v1; v1 = v; } } void buildstrips(vector &strips, vector &draws, bool prims = true, bool degen = false) { vector singles; findconnectivity(); int numtris = 0, numstrips = 0; while(remaining()) { vector strip; bool reverse = degen && !strips.empty() && (strips.length()&1); buildstrip(strip, reverse, prims); numstrips++; numtris += strip.length()-2; if(strip.length()==3 && prims) { loopv(strip) singles.add(strip[i]); continue; } if(!strips.empty() && degen) { strips.dup(); strips.add(strip[0]); } else draws.add(drawcall(GL_TRIANGLE_STRIP, strips.length())); drawcall &d = draws.last(); loopv(strip) { ushort index = strip[i]; strips.add(index); d.minvert = min(d.minvert, (GLuint)index); d.maxvert = max(d.maxvert, (GLuint)index); } d.count = strips.length() - d.start; } if(prims && !singles.empty()) { drawcall &d = draws.add(drawcall(GL_TRIANGLES, strips.length())); loopv(singles) { ushort index = singles[i]; strips.add(index); d.minvert = min(d.minvert, (GLuint)index); d.maxvert = max(d.maxvert, (GLuint)index); } d.count = strips.length() - d.start; } if(dbgts) conoutf("strips = %d, tris = %d, inds = %d, merges = %d", numstrips, numtris, numtris + numstrips*2, (degen ? 2 : 1)*(numstrips-1)); } }; static inline uint hthash(const tristrip::edge &x) { return x.from^x.to; } static inline bool htcmp(const tristrip::edge &x, const tristrip::edge &y) { return x.from==y.from && x.to==y.to; } assaultcube-1.2.0.2.1/source/src/varray.h000066400000000000000000000162571352165075300201120ustar00rootroot00000000000000namespace varray { #ifndef VARRAY_INTERNAL enum { ATTRIB_VERTEX = 1<<0, ATTRIB_COLOR = 1<<1, ATTRIB_NORMAL = 1<<2, ATTRIB_TEXCOORD0 = 1<<3, ATTRIB_TEXCOORD1 = 1<<4, MAXATTRIBS = 5 }; extern vector data; extern void enable(); extern void begin(GLenum mode); extern void defattrib(int type, int size, GLenum format); template static inline void attrib(T x) { T *buf = (T *)data.pad(sizeof(T)); buf[0] = x; } template static inline void attrib(T x, T y) { T *buf = (T *)data.pad(2*sizeof(T)); buf[0] = x; buf[1] = y; } template static inline void attrib(T x, T y, T z) { T *buf = (T *)data.pad(3*sizeof(T)); buf[0] = x; buf[1] = y; buf[2] = z; } template static inline void attrib(T x, T y, T z, T w) { T *buf = (T *)data.pad(4*sizeof(T)); buf[0] = x; buf[1] = y; buf[2] = z; buf[3] = w; } template static inline void attribv(const T *v) { data.put((const uchar *)v, N*sizeof(T)); } extern int end(); extern void disable(); #else struct attribinfo { int type, size, formatsize, offset; GLenum format; attribinfo() : type(0), size(0), formatsize(0), offset(0), format(GL_FALSE) {} bool operator==(const attribinfo &a) const { return type == a.type && size == a.size && format == a.format && offset == a.offset; } bool operator!=(const attribinfo &a) const { return type != a.type || size != a.size || format != a.format || offset != a.offset; } }; vector data; static attribinfo attribs[MAXATTRIBS], lastattribs[MAXATTRIBS]; static int enabled = 0, numattribs = 0, attribmask = 0, numlastattribs = 0, lastattribmask = 0, vertexsize = 0, lastvertexsize = 0; static GLenum primtype = GL_TRIANGLES; static uchar *lastbuf = NULL; static bool changedattribs = false; void enable() { enabled = 0; numlastattribs = lastattribmask = lastvertexsize = 0; lastbuf = NULL; } void begin(GLenum mode) { primtype = mode; } void defattrib(int type, int size, GLenum format) { if(type == ATTRIB_VERTEX) { numattribs = attribmask = 0; vertexsize = 0; } changedattribs = true; attribmask |= type; attribinfo &a = attribs[numattribs++]; a.type = type; a.size = size; a.format = format; switch(format) { case GL_UNSIGNED_BYTE: a.formatsize = 1; break; case GL_BYTE: a.formatsize = 1; break; case GL_UNSIGNED_SHORT: a.formatsize = 2; break; case GL_SHORT: a.formatsize = 2; break; case GL_UNSIGNED_INT: a.formatsize = 4; break; case GL_INT: a.formatsize = 4; break; case GL_FLOAT: a.formatsize = 4; break; case GL_DOUBLE: a.formatsize = 8; break; default: a.formatsize = 0; break; } a.formatsize *= size; a.offset = vertexsize; vertexsize += a.formatsize; } static inline void setattrib(const attribinfo &a, uchar *buf) { switch(a.type) { case ATTRIB_VERTEX: if(!(enabled&a.type)) glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(a.size, a.format, vertexsize, buf); break; case ATTRIB_COLOR: if(!(enabled&a.type)) glEnableClientState(GL_COLOR_ARRAY); glColorPointer(a.size, a.format, vertexsize, buf); break; case ATTRIB_NORMAL: if(!(enabled&a.type)) glEnableClientState(GL_NORMAL_ARRAY); glNormalPointer(a.format, vertexsize, buf); break; case ATTRIB_TEXCOORD0: if(!(enabled&a.type)) glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(a.size, a.format, vertexsize, buf); break; case ATTRIB_TEXCOORD1: glClientActiveTexture_(GL_TEXTURE1_ARB); if(!(enabled&a.type)) glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(a.size, a.format, vertexsize, buf); glClientActiveTexture_(GL_TEXTURE0_ARB); break; } enabled |= a.type; } static inline void unsetattrib(const attribinfo &a) { switch(a.type) { case ATTRIB_VERTEX: glDisableClientState(GL_VERTEX_ARRAY); break; case ATTRIB_COLOR: glDisableClientState(GL_COLOR_ARRAY); break; case ATTRIB_NORMAL: glDisableClientState(GL_NORMAL_ARRAY); break; case ATTRIB_TEXCOORD0: glDisableClientState(GL_TEXTURE_COORD_ARRAY); break; case ATTRIB_TEXCOORD1: glClientActiveTexture_(GL_TEXTURE1_ARB); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glClientActiveTexture_(GL_TEXTURE0_ARB); break; } enabled &= ~a.type; } int end() { if(data.empty()) return 0; uchar *buf = data.getbuf(); bool forceattribs = numattribs != numlastattribs || vertexsize != lastvertexsize || buf != lastbuf; if(forceattribs || changedattribs) { int diffmask = enabled & lastattribmask & ~attribmask; if(diffmask) loopi(numlastattribs) { const attribinfo &a = lastattribs[i]; if(diffmask & a.type) unsetattrib(a); } uchar *src = buf; loopi(numattribs) { const attribinfo &a = attribs[i]; if(forceattribs || a != lastattribs[i]) { setattrib(a, src); lastattribs[i] = a; } src += a.formatsize; } lastbuf = buf; numlastattribs = numattribs; lastattribmask = attribmask; lastvertexsize = vertexsize; changedattribs = false; } int numvertexes = data.length()/vertexsize; glDrawArrays(primtype, 0, numvertexes); data.setsize(0); return numvertexes; } void disable() { if(!enabled) return; if(enabled&ATTRIB_VERTEX) glDisableClientState(GL_VERTEX_ARRAY); if(enabled&ATTRIB_COLOR) glDisableClientState(GL_COLOR_ARRAY); if(enabled&ATTRIB_NORMAL) glDisableClientState(GL_NORMAL_ARRAY); if(enabled&ATTRIB_TEXCOORD0) glDisableClientState(GL_TEXTURE_COORD_ARRAY); if(enabled&ATTRIB_TEXCOORD1) { glClientActiveTexture_(GL_TEXTURE1_ARB); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glClientActiveTexture_(GL_TEXTURE0_ARB); } enabled = 0; } #endif } assaultcube-1.2.0.2.1/source/src/vertmodel.h000066400000000000000000001256601352165075300206060ustar00rootroot00000000000000VARP(dynshadowsize, 4, 5, 8); VARP(aadynshadow, 0, 2, 3); VARP(saveshadows, 0, 1, 1); VARP(dynshadowquad, 0, 0, 1); VARF(shadowyaw, 0, DEFAULT_SHADOWYAW, 360, flagmapconfigchange()); vec shadowdir(0, 0, -1), shadowpos(0, 0, 0); const int dbgstenc = 0; const int dbgvlight = 0; //VAR(dbgstenc, 0, 0, 2); //VAR(dbgvlight, 0, 0, 1); VARP(mdldlist, 0, 1, 1); vec modelpos; float modelroll, modelyaw, modelpitch; struct vertmodel : model { struct anpos { int fr1, fr2; float t; void setframes(const animstate &as) { int time = lastmillis-as.basetime; fr1 = (int)(double(time)/as.speed); // round to full frames t = (time-double(fr1)*as.speed)/as.speed; // progress of the frame, value from 0.0f to 1.0f ASSERT(t >= 0.0f); if(as.anim&ANIM_LOOP) { fr1 = fr1%as.range+as.frame; fr2 = fr1+1; if(fr2>=as.frame+as.range) fr2 = as.frame; } else { fr1 = min(fr1, as.range-1)+as.frame; fr2 = min(fr1+1, as.frame+as.range-1); } if(as.anim&ANIM_REVERSE) { fr1 = (as.frame+as.range-1)-(fr1-as.frame); fr2 = (as.frame+as.range-1)-(fr2-as.frame); } } bool operator==(const anpos &a) const { return fr1==a.fr1 && fr2==a.fr2 && (fr1==fr2 || t==a.t); } bool operator!=(const anpos &a) const { return fr1!=a.fr1 || fr2!=a.fr2 || (fr1!=fr2 && t!=a.t); } }; struct bb { vec low, high; void addlow(const vec &v) { low.x = min(low.x, v.x); low.y = min(low.y, v.y); low.z = min(low.z, v.z); } void addhigh(const vec &v) { high.x = max(high.x, v.x); high.y = max(high.y, v.y); high.z = max(high.z, v.z); } void add(const vec &v) { addlow(v); addhigh(v); } void add(const bb &b) { addlow(b.low); addhigh(b.high); } }; struct tcvert { float u, v; }; struct lightvert { uchar r, g, b, a; }; struct tri { ushort vert[3]; ushort neighbor[3]; }; struct part; typedef tristrip::drawcall drawcall; struct dyncacheentry : modelcacheentry { anpos cur, prev; float t; vec *verts() { return (vec *)getdata(); } int numverts() { return int((size - sizeof(dyncacheentry)) / sizeof(vec)); } }; struct shadowcacheentry : modelcacheentry { anpos cur, prev; float t; vec dir; ushort *idxs() { return (ushort *)getdata(); } int numidxs() { return int((size - sizeof(shadowcacheentry)) / sizeof(ushort)); } }; struct lightcacheentry : modelcacheentry { anpos cur, prev; float t; int lastcalclight; vec pos; float roll, yaw, pitch; lightvert *verts() { return (lightvert *)getdata(); } int numverts() { return int((size - sizeof(lightcacheentry)) / sizeof(lightvert)); } }; struct mesh { char *name; part *owner; vec *verts; tcvert *tcverts; bb *bbs; ushort *shareverts; tri *tris; int numverts, numtris; Texture *skin; int tex; modelcachelist dyncache; modelcachelist shadowcache; modelcachelist lightcache; ushort *dynidx; int dynlen; drawcall *dyndraws; int numdyndraws; GLuint statlist; int statlen; mesh() : name(0), owner(0), verts(0), tcverts(0), bbs(0), shareverts(0), tris(0), skin(notexture), tex(0), dynidx(0), dyndraws(0), statlist(0) { } ~mesh() { DELETEA(name); DELETEA(verts); DELETEA(tcverts); DELETEA(bbs); DELETEA(shareverts); DELETEA(tris); if(statlist) glDeleteLists(statlist, 1); DELETEA(dynidx); DELETEA(dyndraws); } void genstrips() { tristrip ts; ts.addtriangles(tris, numtris); vector idxs; vector draws; ts.buildstrips(idxs, draws); dynidx = new ushort[idxs.length()]; memcpy(dynidx, idxs.getbuf(), idxs.length()*sizeof(ushort)); dynlen = idxs.length(); dyndraws = new drawcall[draws.length()]; memcpy(dyndraws, draws.getbuf(), draws.length()*sizeof(drawcall)); numdyndraws = draws.length(); } #ifdef LINUXBUGISBACK #if defined(__GNUC__) && defined(__OPTIMIZE__) && !defined(__clang__) && !defined(__ICL) && __GNUC__ >= 4 && __GNUC_MINOR__ > 4 __attribute__((optimize(2))) #elif defined(__clang__) && __clang_major__ >= 4 __attribute__((optnone)) #endif #endif dyncacheentry *gendynverts(animstate &as, anpos &cur, anpos *prev, float ai_t) { dyncacheentry *d = dyncache.start(); int cachelen = 0; for(; d != dyncache.end(); d = d->next, cachelen++) { if(d->cur != cur) continue; if(prev) { if(d->prev == *prev && d->t == ai_t) return d; } else if(d->prev.fr1 < 0) return d; } d = dynalloc.allocate((numverts + 1)*sizeof(vec)); if(!d) return NULL; if(cachelen >= owner->model->cachelimit) dyncache.removelast(); dyncache.addfirst(d); vec *buf = d->verts(), *vert1 = &verts[cur.fr1 * numverts], *vert2 = &verts[cur.fr2 * numverts], *pvert1 = NULL, *pvert2 = NULL; d->cur = cur; d->t = ai_t; if(prev) { d->prev = *prev; pvert1 = &verts[prev->fr1 * numverts]; pvert2 = &verts[prev->fr2 * numverts]; } else d->prev.fr1 = -1; #define iploop(body) \ loopi(numverts) \ { \ vec &v = buf[i]; \ body; \ } #define ip(p1, p2, t) (p1+t*(p2-p1)) #define ip_v(p, c, t) ip(p##1[i].c, p##2[i].c, t) #define ip_v_ai(c) ip(ip_v(pvert, c, prev->t), ip_v(vert, c, cur.t), ai_t) if(prev) iploop(v = vec(ip_v_ai(x), ip_v_ai(y), ip_v_ai(z))) else iploop(v = vec(ip_v(vert, x, cur.t), ip_v(vert, y, cur.t), ip_v(vert, z, cur.t))) #undef ip #undef ip_v #undef ip_v_ai if(d->verts() == lastvertexarray) lastvertexarray = (void *)-1; return d; } void weldverts() { hashtable idxs; shareverts = new ushort[numverts]; loopi(numverts) shareverts[i] = (ushort)idxs.access(verts[i], i); for(int i = 1; i < owner->numframes; i++) { const vec *frame = &verts[i*numverts]; loopj(numverts) { if(frame[j] != frame[shareverts[j]]) shareverts[j] = (ushort)j; } } } void findneighbors() { hashtable edges; loopi(numtris) { const tri &t = tris[i]; loopj(3) { uint e1 = shareverts[t.vert[j]], e2 = shareverts[t.vert[(j+1)%3]], shift = 0; if(e1 > e2) { swap(e1, e2); shift = 16; } uint &edge = edges.access(e1 | (e2<<16), ~0U); if(((edge>>shift)&0xFFFF) != 0xFFFF) edge = 0; else { edge &= 0xFFFF<<(16-shift); edge |= i< e2) { swap(e1, e2); shift = 16; } uint edge = edges[e1 | (e2<<16)]; if(!edge || int((edge>>shift)&0xFFFF)!=i) t.neighbor[j] = 0xFFFF; else t.neighbor[j] = (edge>>(16-shift))&0xFFFF; } } } void cleanup() { if(statlist) { glDeleteLists(1, statlist); statlist = 0; } } #ifdef LINUXBUGISBACK #if defined(__GNUC__) && defined(__OPTIMIZE__) && !defined(__clang__) && !defined(__ICL) && __GNUC__ >= 4 && __GNUC_MINOR__ > 4 __attribute__((optimize(2))) #elif defined(__clang__) && __clang_major__ >= 4 __attribute__((optnone)) #endif #endif shadowcacheentry *genshadowvolume(animstate &as, anpos &cur, anpos *prev, float ai_t, vec *buf) { if(!shareverts) return NULL; shadowcacheentry *d = shadowcache.start(); int cachelen = 0; for(; d != shadowcache.end(); d = d->next, cachelen++) { if(d->dir != shadowpos || d->cur != cur) continue; if(prev) { if(d->prev == *prev && d->t == ai_t) return d; } else if(d->prev.fr1 < 0) return d; } d = (owner->numframes > 1 || as.anim&ANIM_DYNALLOC ? dynalloc : statalloc).allocate(9*numtris*sizeof(ushort)); if(!d) return NULL; if(cachelen >= owner->model->cachelimit) shadowcache.removelast(); shadowcache.addfirst(d); d->dir = shadowpos; d->cur = cur; d->t = ai_t; if(prev) d->prev = *prev; else d->prev.fr1 = -1; static vector side; side.setsize(0); loopi(numtris) { const tri &t = tris[i]; const vec &a = buf[t.vert[0]], &b = buf[t.vert[1]], &c = buf[t.vert[2]]; side.add(vec().cross(vec(b).sub(a), vec(c).sub(a)).dot(shadowdir) <= 0 ? 1 : 0); } ushort *idx = d->idxs(); loopi(numtris) if(side[i]) { const tri &t = tris[i]; loopj(3) { ushort n = t.neighbor[j]; if(n==0xFFFF || !side[n]) { ushort e1 = shareverts[t.vert[j]], e2 = shareverts[t.vert[(j+1)%3]]; *idx++ = e2; *idx++ = e1; *idx++ = numverts; } } } if(dbgstenc >= (owner->numframes > 1 || as.anim&ANIM_DYNALLOC ? 2 : 1)) conoutf("%s: %d tris", owner->filename, int((idx - d->idxs()) / 3)); d->size = (uchar *)idx - (uchar *)d; return d; } #ifdef LINUXBUGISBACK #if defined(__GNUC__) && defined(__OPTIMIZE__) && !defined(__clang__) && !defined(__ICL) && __GNUC__ >= 4 && __GNUC_MINOR__ > 4 __attribute__((optimize(2))) #elif defined(__clang__) && __clang_major__ >= 4 __attribute__((optnone)) #endif #endif lightcacheentry *lightvertexes(animstate &as, anpos &cur, anpos *prev, float ai_t, vec *buf) { if(dbgvlight) return NULL; lightcacheentry *d = lightcache.start(); int cachelen = 0; for(; d != lightcache.end(); d = d->next, cachelen++) { if(d->lastcalclight != lastcalclight || d->pos != modelpos || d->roll != modelroll || d->yaw != modelyaw || d->pitch != modelpitch || d->cur != cur) continue; if(prev) { if(d->prev == *prev && d->t == ai_t) return d; } else if(d->prev.fr1 < 0) return d; } bb curbb; getcurbb(curbb, as, cur, prev, ai_t); float dist = max(curbb.low.magnitude(), curbb.high.magnitude()); if(OUTBORDRAD(modelpos.x, modelpos.y, dist)) return NULL; d = (owner->numframes > 1 || as.anim&ANIM_DYNALLOC ? dynalloc : statalloc).allocate(numverts*sizeof(lightvert)); if(!d) return NULL; if(cachelen >= owner->model->cachelimit) lightcache.removelast(); lightcache.addfirst(d); d->lastcalclight = lastcalclight; d->pos = modelpos; d->roll = modelroll; d->yaw = modelyaw; d->pitch = modelpitch; d->cur = cur; d->t = ai_t; if(prev) d->prev = *prev; else d->prev.fr1 = -1; const glmatrixf &m = matrixstack[matrixpos]; lightvert *v = d->verts(); loopi(numverts) { int x = (int)m.transformx(*buf), y = (int)m.transformy(*buf); const sqr *s = S(x, y); v->r = s->r; v->g = s->g; v->b = s->b; v->a = 255; v++; buf++; } if(d->verts() == lastcolorarray) lastcolorarray = (void *)-1; return d; } void getcurbb(bb &b, animstate &as, anpos &cur, anpos *prev, float ai_t) { b = bbs[cur.fr1]; b.add(bbs[cur.fr2]); if(prev) { b.add(bbs[prev->fr1]); b.add(bbs[prev->fr2]); } } void render(animstate &as, anpos &cur, anpos *prev, float ai_t) { if(!(as.anim&ANIM_NOSKIN)) { GLuint id = tex < 0 ? -tex : skin->id; if(tex > 0) id = lookuptexture(tex)->id; if(id != lasttex) { glBindTexture(GL_TEXTURE_2D, id); lasttex = id; } if(enablealphablend) { glDisable(GL_BLEND); enablealphablend = false; } if(skin->bpp == 32 && owner->model->alphatest > 0) { if(!enablealphatest) { glEnable(GL_ALPHA_TEST); enablealphatest = true; } if(lastalphatest != owner->model->alphatest) { glAlphaFunc(GL_GREATER, owner->model->alphatest); lastalphatest = owner->model->alphatest; } } else if(enablealphatest) { glDisable(GL_ALPHA_TEST); enablealphatest = false; } if(!enabledepthmask) { glDepthMask(GL_TRUE); enabledepthmask = true; } } if(enableoffset) { disablepolygonoffset(GL_POLYGON_OFFSET_FILL); enableoffset = false; } bool isstat = as.frame==0 && as.range==1; if(isstat && statlist && !stenciling) { glCallList(statlist); xtraverts += statlen; return; } else if(stenciling==1) { bb curbb; getcurbb(curbb, as, cur, prev, ai_t); glmatrixf mat; mat.mul(mvpmatrix, matrixstack[matrixpos]); if(!addshadowbox(curbb.low, curbb.high, shadowpos, mat)) return; } vec *buf = verts; dyncacheentry *d = NULL; if(!isstat) { d = gendynverts(as, cur, prev, ai_t); if(!d) return; buf = d->verts(); } if(lastvertexarray != buf) { if(!lastvertexarray) glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, sizeof(vec), buf); lastvertexarray = buf; } lightvert *vlight = NULL; if(as.anim&ANIM_NOSKIN && (!isstat || stenciling)) { if(lasttexcoordarray) { glDisableClientState(GL_TEXTURE_COORD_ARRAY); lasttexcoordarray = NULL; } } else { if(lasttexcoordarray != tcverts) { if(!lasttexcoordarray) glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(2, GL_FLOAT, sizeof(tcvert), tcverts); lasttexcoordarray = tcverts; } if(owner->model->vertexlight) { if(d) d->locked = true; lightcacheentry *l = lightvertexes(as, cur, isstat ? NULL : prev, ai_t, buf); if(d) d->locked = false; if(l) vlight = l->verts(); } } if(lastcolorarray != vlight) { if(vlight) { if(!lastcolorarray) glEnableClientState(GL_COLOR_ARRAY); glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(lightvert), vlight); } else glDisableClientState(GL_COLOR_ARRAY); lastcolorarray = vlight; } if(stenciling) { if(d) d->locked = true; shadowcacheentry *s = genshadowvolume(as, cur, isstat ? NULL : prev, ai_t, buf); if(d) d->locked = false; if(!s) return; buf[numverts] = s->dir; glDrawElements(GL_TRIANGLES, s->numidxs(), GL_UNSIGNED_SHORT, s->idxs()); xtraverts += s->numidxs(); return; } bool builddlist = isstat && !owner->model->vertexlight && mdldlist; if(builddlist) glNewList(statlist = glGenLists(1), GL_COMPILE); loopi(numdyndraws) { const drawcall &d = dyndraws[i]; if(hasDRE && !builddlist) glDrawRangeElements_(d.type, d.minvert, d.maxvert, d.count, GL_UNSIGNED_SHORT, &dynidx[d.start]); else glDrawElements(d.type, d.count, GL_UNSIGNED_SHORT, &dynidx[d.start]); } if(builddlist) { glEndList(); glCallList(statlist); statlen = dynlen; } xtraverts += dynlen; } int findvert(int axis, int dir) { if(axis<0 || axis>2) return -1; int vert = -1; float bestval = -1e16f; loopi(numverts) { float val = verts[i][axis]*dir; if(val > bestval) { vert = i; bestval = val; } } return vert; } float calcradius(float &zradius) { float rad = 0, zrad = 0; loopi(numverts) rad = max(rad, verts[i].magnitudexy()), zrad = max(zrad, fabsf(verts[i].z)); zradius = zrad; return rad; } void calcneighbors() { if(!shareverts) { weldverts(); findneighbors(); } } void calcbbs() { if(bbs) return; bbs = new bb[owner->numframes]; loopi(owner->numframes) { bb &b = bbs[i]; b.low = vec(1e16f, 1e16f, 1e16f); b.high = vec(-1e16f, -1e16f, -1e16f); const vec *frame = &verts[numverts*i]; loopj(numverts) b.add(frame[j]); } } }; struct animinfo { int frame, range; float speed; }; struct particleemitter { int type, args[2], seed, lastemit; particleemitter() : type(-1), seed(-1), lastemit(-1) { memset(args, 0, sizeof(args)); } }; struct tag { char *name; vec pos; float transform[3][3]; tag() : name(NULL) {} ~tag() { DELETEA(name); } void identity() { transform[0][0] = 1; transform[0][1] = 0; transform[0][2] = 0; transform[1][0] = 0; transform[1][1] = 1; transform[1][2] = 0; transform[2][0] = 0; transform[2][1] = 0; transform[2][2] = 1; } }; struct linkedpart { part *p; particleemitter *emitter; vec *pos; linkedpart() : p(NULL), emitter(NULL), pos(NULL) {} ~linkedpart() { DELETEP(emitter); } }; struct part { char *filename; vertmodel *model; int index, numframes; vector meshes; vector *anims; linkedpart *links; tag *tags; int numtags; GLuint *shadows; float shadowrad; part() : filename(NULL), anims(NULL), links(NULL), tags(NULL), numtags(0), shadows(NULL), shadowrad(0) {} virtual ~part() { DELETEA(filename); meshes.deletecontents(); DELETEA(anims); DELETEA(links); DELETEA(tags); if(shadows) glDeleteTextures(numframes, shadows); DELETEA(shadows); } void cleanup() { loopv(meshes) meshes[i]->cleanup(); if(shadows) { glDeleteTextures(numframes, shadows); DELETEA(shadows); } } bool link(part *link, const char *tag, vec *pos = NULL) { loopi(numtags) if(!strcmp(tags[i].name, tag)) { links[i].p = link; links[i].pos = pos; return true; } return false; } bool gentag(const char *name, int *verts, int numverts, mesh *m = NULL) { if(!m) { if(meshes.empty()) return false; m = meshes[0]; } if(numverts < 1) return false; loopi(numverts) if(verts[i] < 0 || verts[i] > m->numverts) return false; tag *ntags = new tag[(numtags + 1)*numframes]; ntags[numtags].name = newstring(name); loopi(numframes) { memcpy(&ntags[(numtags + 1)*i], &tags[numtags*i], numtags*sizeof(tag)); tag *t = &ntags[(numtags + 1)*i + numtags]; t->pos = m->verts[m->numverts*i + verts[0]]; if(numverts > 1) { for(int j = 1; j < numverts; j++) t->pos.add(m->verts[m->numverts*i + verts[j]]); t->pos.div(numverts); } t->identity(); } loopi(numtags) tags[i].name = NULL; DELETEA(tags); tags = ntags; numtags++; linkedpart *nlinks = new linkedpart[numtags]; loopi(numtags-1) swap(links[i].emitter, nlinks[i].emitter); DELETEA(links); links = nlinks; return true; } bool addemitter(const char *tag, int type, int arg1 = 0, int arg2 = 0) { loopi(numtags) if(!strcmp(tags[i].name, tag)) { if(!links[i].emitter) links[i].emitter = new particleemitter; particleemitter &p = *links[i].emitter; p.type = type; p.args[0] = arg1; p.args[1] = arg2; return true; } return false; } void scaleverts(const float scale, const vec &translate) { loopv(meshes) { mesh &m = *meshes[i]; loopj(numframes*m.numverts) { vec &v = m.verts[j]; if(!index) v.add(translate); v.mul(scale); } } loopi(numframes*numtags) { vec &v = tags[i].pos; if(!index) v.add(translate); v.mul(scale); } } void genstrips() { loopv(meshes) meshes[i]->genstrips(); } virtual void getdefaultanim(animstate &as, int anim, int varseed) { as.frame = 0; as.range = 1; } void gentagmatrix(anpos &cur, anpos *prev, float ai_t, int i, GLfloat *matrix) { tag *tag1 = &tags[cur.fr1*numtags+i]; tag *tag2 = &tags[cur.fr2*numtags+i]; #define ip(p1, p2, t) (p1+t*(p2-p1)) #define ip_ai_tag(c) ip( ip( tag1p->c, tag2p->c, prev->t), ip( tag1->c, tag2->c, cur.t), ai_t) if(prev) { tag *tag1p = &tags[prev->fr1 * numtags + i]; tag *tag2p = &tags[prev->fr2 * numtags + i]; loopj(3) matrix[j] = ip_ai_tag(transform[0][j]); // transform loopj(3) matrix[4 + j] = ip_ai_tag(transform[1][j]); loopj(3) matrix[8 + j] = ip_ai_tag(transform[2][j]); loopj(3) matrix[12 + j] = ip_ai_tag(pos[j]); // position } else { loopj(3) matrix[j] = ip(tag1->transform[0][j], tag2->transform[0][j], cur.t); // transform loopj(3) matrix[4 + j] = ip(tag1->transform[1][j], tag2->transform[1][j], cur.t); loopj(3) matrix[8 + j] = ip(tag1->transform[2][j], tag2->transform[2][j], cur.t); loopj(3) matrix[12 + j] = ip(tag1->pos[j], tag2->pos[j], cur.t); // position } #undef ip_ai_tag #undef ip matrix[3] = matrix[7] = matrix[11] = 0.0f; matrix[15] = 1.0f; } bool calcanimstate(int anim, int varseed, float speed, int basetime, dynent *d, animstate &as) { as.anim = anim; as.speed = speed<=0 ? 100.0f : speed; as.basetime = basetime; if((anim&ANIM_INDEX)==ANIM_ALL) { as.frame = 0; as.range = numframes; } else if(anims) { vector &ais = anims[anim&ANIM_INDEX]; if(ais.length()) { animinfo &ai = ais[uint(varseed)%ais.length()]; as.frame = ai.frame; as.range = ai.range; if(ai.speed>0) as.speed = 1000.0f/ai.speed; } else getdefaultanim(as, anim&ANIM_INDEX, varseed); } else getdefaultanim(as, anim&ANIM_INDEX, varseed); if(anim&(ANIM_START|ANIM_END)) { if(anim&ANIM_END) as.frame += as.range-1; as.range = 1; } if(as.frame+as.range>numframes) { if(as.frame>=numframes) return false; as.range = numframes-as.frame; } if(d && index<2) { if(d->lastmodel[index]!=this || d->lastanimswitchtime[index]==-1 || lastmillis-d->lastrendered>animationinterpolationtime) { d->current[index] = as; d->lastanimswitchtime[index] = lastmillis-animationinterpolationtime*2; } else if(d->current[index] != as) { if(lastmillis-d->lastanimswitchtime[index]>animationinterpolationtime/2) d->prev[index] = d->current[index]; d->current[index] = as; d->lastanimswitchtime[index] = lastmillis; } d->lastmodel[index] = this; } return true; } void render(int anim, int varseed, float speed, int basetime, dynent *d) { if(meshes.empty()) return; animstate as; if(!calcanimstate(anim, varseed, speed, basetime, d, as)) return; if(!meshes[0]->dynidx) genstrips(); anpos prev, cur; cur.setframes(d && index<2 ? d->current[index] : as); float ai_t = 0; bool doai = !(anim&ANIM_NOINTERP) && d && index<2 && lastmillis-d->lastanimswitchtime[index]prev[index].range>0; if(doai) { prev.setframes(d->prev[index]); ai_t = (lastmillis-d->lastanimswitchtime[index])/(float)animationinterpolationtime; } glPushMatrix(); glMultMatrixf(matrixstack[matrixpos].v); loopv(meshes) meshes[i]->render(as, cur, doai ? &prev : NULL, ai_t); glPopMatrix(); loopi(numtags) { linkedpart &link = links[i]; if(!(link.p || link.pos || (anim&ANIM_PARTICLE && link.emitter))) continue; // render the linked models - interpolate rotation and position of the 'link-tags' glmatrixf linkmat; gentagmatrix(cur, doai ? &prev : NULL, ai_t, i, linkmat.v); matrixpos++; matrixstack[matrixpos].mul(matrixstack[matrixpos-1], linkmat); if(link.pos) *link.pos = matrixstack[matrixpos].gettranslation(); if(link.p) { vec oldshadowdir, oldshadowpos; if(stenciling) { oldshadowdir = shadowdir; oldshadowpos = shadowpos; linkmat.invertnormal(shadowdir); linkmat.invertvertex(shadowpos); } link.p->render(anim, varseed, speed, basetime, d); if(stenciling) { shadowdir = oldshadowdir; shadowpos = oldshadowpos; } } if(anim&ANIM_PARTICLE && link.emitter) { particleemitter &p = *link.emitter; if(p.lastemit!=basetime) { p.seed = rnd(0x1000000); p.lastemit = basetime; } particle_emit(p.type, p.args, basetime, p.seed, matrixstack[matrixpos].gettranslation()); } matrixpos--; } } void setanim(int num, int frame, int range, float speed) { if(frame<0 || frame>=numframes || range<=0 || frame+range>numframes) { conoutf("mdanim: invalid frame %d, range %d in model %s", frame, range, model->loadname); return; } if(!anims) anims = new vector[NUMANIMS]; animinfo &ai = anims[num].add(); ai.frame = frame; ai.range = range; ai.speed = speed; } virtual void begingenshadow() { } virtual void endgenshadow() { } void blurshadow(const uchar *in, uchar *out, uint size) { static const uint filter3x3[9] = { 1, 2, 1, 2, 4, 2, 1, 2, 1 }; static const uint filter3x3sum = 16; const uchar *src = in, *prev = in - size, *next = in + size; uchar *dst = out; #define FILTER(c0, c1, c2, c3, c4, c5, c6, c7, c8) \ { \ uint c = *src, \ val = (filter3x3[0]*(c0) + filter3x3[1]*(c1) + filter3x3[2]*(c2) + \ filter3x3[3]*(c3) + filter3x3[4]*(c4) + filter3x3[5]*(c5) + \ filter3x3[6]*(c6) + filter3x3[7]*(c7) + filter3x3[8]*(c8)); \ *dst++ = val/filter3x3sum; \ src++; \ prev++; \ next++; \ } FILTER(c, c, c, c, c, src[1], c, next[0], next[1]); for(uint x = 1; x < size-1; x++) FILTER(c, c, c, src[-1], c, src[1], next[-1], next[0], next[1]); FILTER(c, c, c, src[-1], c, c, next[-1], next[0], c); for(uint y = 1; y < size-1; y++) { FILTER(c, prev[0], prev[1], c, c, src[1], c, next[0], next[1]); for(uint x = 1; x < size-1; x++) FILTER(prev[-1], prev[0], prev[1], src[-1], c, src[1], next[-1], next[0], next[1]); FILTER(prev[-1], prev[0], c, src[-1], c, c, next[-1], next[0], c); } FILTER(c, prev[0], prev[1], c, c, src[1], c, c, c); for(uint x = 1; x < size-1; x++) FILTER(prev[-1], prev[0], prev[1], src[-1], c, src[1], c, c, c); FILTER(prev[-1], prev[0], c, src[-1], c, c, c, c, c); #undef FILTER } void genshadow(int aasize, int frame, stream *f) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); model->startrender(); render(ANIM_ALL|ANIM_NOINTERP|ANIM_NOSKIN, 0, 1, lastmillis-frame, NULL); model->endrender(); uchar *pixels = new uchar[2*aasize*aasize]; glPixelStorei(GL_PACK_ALIGNMENT, 1); glReadPixels(0, 0, aasize, aasize, GL_RED, GL_UNSIGNED_BYTE, pixels); #if 0 SDL_Surface *img = SDL_CreateRGBSurface(SDL_SWSURFACE, aasize, aasize, 24, 0x0000FF, 0x00FF00, 0xFF0000, 0); loopi(aasize*aasize) memset((uchar *)img->pixels + 3*i, pixels[i], 3); defformatstring(imgname)("%s_%d.bmp", model->loadname, frame); for(char *s; (s = strchr(imgname, '/'));) *s = '_'; SDL_SaveBMP(img, imgname); SDL_FreeSurface(img); #endif if(aasize > 1<write(&pixels[texsize*texsize], texsize*texsize); createtexture(shadows[frame], texsize, texsize, &pixels[texsize*texsize], 3, true, false, GL_ALPHA); delete[] pixels; } struct shadowheader { ushort size, frames; float height, rad; }; void genshadows(float height, float rad) { if(shadows) return; char *filename = shadowfile(); if(filename && loadshadows(filename)) return; shadowrad = rad; shadows = new GLuint[numframes]; glGenTextures(numframes, shadows); extern int screenw, screenh; int aasize = 1<<(dynshadowsize + aadynshadow); while(aasize > screenw || aasize > screenh) aasize /= 2; stream *f = filename ? opengzfile(filename, "wb") : NULL; if(f) { shadowheader hdr; hdr.size = min(aasize, 1<putlil(hdr.size); f->putlil(hdr.frames); f->putlil(hdr.height); f->putlil(hdr.rad); } glViewport(0, 0, aasize, aasize); glClearColor(0, 0, 0, 1); glDisable(GL_FOG); glColor3f(1, 1, 1); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-rad, rad, -rad, rad, 0.15f, height); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glScalef(1, -1, 1); glTranslatef(0, 0, -height); begingenshadow(); loopi(numframes) genshadow(aasize, i, f); endgenshadow(); glEnable(GL_FOG); glViewport(0, 0, screenw, screenh); if(f) delete f; } bool loadshadows(const char *filename) { stream *f = opengzfile(filename, "rb"); if(!f) return false; shadowheader hdr; if(f->read(&hdr, sizeof(shadowheader))!=sizeof(shadowheader)) { delete f; return false; } lilswap(&hdr.size, 1); lilswap(&hdr.frames, 1); if(hdr.size!=(1<read(buf, hdr.size*hdr.size*hdr.frames)!=hdr.size*hdr.size*hdr.frames) { delete f; delete[] buf; return false; } shadowrad = hdr.rad; shadows = new GLuint[hdr.frames]; glGenTextures(hdr.frames, shadows); loopi(hdr.frames) createtexture(shadows[i], hdr.size, hdr.size, &buf[i*hdr.size*hdr.size], 3, true, false, GL_ALPHA); delete[] buf; delete f; return true; } void rendershadow(int anim, int varseed, float speed, int basetime, const vec &o, float yaw) { if(!shadows) return; animstate as; if(!calcanimstate(anim, varseed, speed, basetime, NULL, as)) return; anpos cur; cur.setframes(as); GLuint id = shadows[cur.fr1]; if(id!=lasttex) { glBindTexture(GL_TEXTURE_2D, id); lasttex = id; } if(enabledepthmask) { glDepthMask(GL_FALSE); enabledepthmask = false; } if(enablealphatest) { glDisable(GL_ALPHA_TEST); enablealphatest = false; } if(!enablealphablend) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); enablealphablend = true; } yaw *= RAD; float c = cosf(yaw), s = sinf(yaw); float x1 = -shadowrad, x2 = shadowrad; float y1 = -shadowrad, y2 = shadowrad; if(dynshadowquad) { glBegin(GL_QUADS); glTexCoord2f(0, 1); glVertex3f(x1*c - y1*s + o.x, y1*c + x1*s + o.y, o.z); glTexCoord2f(1, 1); glVertex3f(x2*c - y1*s + o.x, y1*c + x2*s + o.y, o.z); glTexCoord2f(1, 0); glVertex3f(x2*c - y2*s + o.x, y2*c + x2*s + o.y, o.z); glTexCoord2f(0, 0); glVertex3f(x1*c - y2*s + o.x, y2*c + x1*s + o.y, o.z); glEnd(); xtraverts += 4; return; } if(!enableoffset) { enablepolygonoffset(GL_POLYGON_OFFSET_FILL); enableoffset = true; } if(lastvertexarray) { glDisableClientState(GL_VERTEX_ARRAY); lastvertexarray = NULL; } if(lasttexcoordarray) { glDisableClientState(GL_TEXTURE_COORD_ARRAY); lasttexcoordarray = NULL; } vec texgenS, texgenT; texgenS.x = c / (2*shadowrad); texgenS.y = s / (2*shadowrad); texgenS.z = -(x1*c - y2*s + o.x)*texgenS.x - (y2*c + x1*s + o.y)*texgenS.y; texgenT.x = s / (2*shadowrad); texgenT.y = -c / (2*shadowrad); texgenT.z = -(x1*c - y2*s + o.x)*texgenT.x - (y2*c + x1*s + o.y)*texgenT.y; ::rendershadow(int(floor(o.x-shadowrad)), int(floor(o.y-shadowrad)), int(ceil(o.x+shadowrad)), int(ceil(o.y+shadowrad)), texgenS, texgenT); } char *shadowfile() { if(!saveshadows || !filename) return NULL; static string s; char *dir = strrchr(filename, PATHDIV); if(!dir) s[0] = '\0'; else copystring(s, filename, dir-filename+2); concatstring(s, "shadows.dat"); return s; } float calcradius(float &zradius) { float rad = 0, zrad = 0; loopv(meshes) rad = max(rad, meshes[i]->calcradius(zrad)), zradius = max(zradius, zrad); return rad; } void calcneighbors() { loopv(meshes) meshes[i]->calcneighbors(); } void calcbbs() { loopv(meshes) meshes[i]->calcbbs(); } }; bool loaded; char *loadname; vector parts; vertmodel(const char *name) : loaded(false) { loadname = newstring(name); } ~vertmodel() { delete[] loadname; parts.deletecontents(); } char *name() { return loadname; } void cleanup() { loopv(parts) parts[i]->cleanup(); } bool link(part *link, const char *tag, vec *pos = NULL) { loopv(parts) if(parts[i]->link(link, tag, pos)) return true; return false; } void setskin(int tex = 0) { //if(parts.length()!=1 || parts[0]->meshes.length()!=1) return; if(parts.length() < 1 || parts[0]->meshes.length() < 1) return; mesh &m = *parts[0]->meshes[0]; m.tex = tex; } void genshadows(float height, float rad) { if(parts.length()>1) return; parts[0]->genshadows(height, rad); } bool hasshadows() { return parts.length()==1 && parts[0]->shadows; } float calcradius(float &zradius) { zradius = 0; return parts.empty() ? 0.0f : parts[0]->calcradius(zradius); } void calcneighbors() { loopv(parts) parts[i]->calcneighbors(); } void calcbbs() { loopv(parts) parts[i]->calcbbs(); } static bool enablealphablend, enablealphatest, enabledepthmask, enableoffset; static GLuint lasttex; static float lastalphatest; static void *lastvertexarray, *lasttexcoordarray, *lastcolorarray; static glmatrixf matrixstack[32]; static int matrixpos; void startrender() { enablealphablend = enablealphatest = enableoffset = false; enabledepthmask = true; lasttex = 0; lastalphatest = -1; lastvertexarray = lasttexcoordarray = lastcolorarray = NULL; } void endrender() { if(enablealphablend) glDisable(GL_BLEND); if(enablealphatest) glDisable(GL_ALPHA_TEST); if(!enabledepthmask) glDepthMask(GL_TRUE); if(lastvertexarray) glDisableClientState(GL_VERTEX_ARRAY); if(lasttexcoordarray) glDisableClientState(GL_TEXTURE_COORD_ARRAY); if(lastcolorarray) glDisableClientState(GL_COLOR_ARRAY); if(enableoffset) disablepolygonoffset(GL_POLYGON_OFFSET_FILL); } static modelcache dynalloc, statalloc; }; bool vertmodel::enablealphablend = false, vertmodel::enablealphatest = false, vertmodel::enabledepthmask = true, vertmodel::enableoffset = false; GLuint vertmodel::lasttex = 0; float vertmodel::lastalphatest = -1; void *vertmodel::lastvertexarray = NULL, *vertmodel::lasttexcoordarray = NULL, *vertmodel::lastcolorarray = NULL; glmatrixf vertmodel::matrixstack[32]; int vertmodel::matrixpos = 0; VARF(mdldyncache, 1, 2, 32, vertmodel::dynalloc.resize(mdldyncache<<20)); VARF(mdlstatcache, 1, 1, 32, vertmodel::statalloc.resize(mdlstatcache<<20)); modelcache vertmodel::dynalloc(mdldyncache<<20), vertmodel::statalloc(mdlstatcache<<20); assaultcube-1.2.0.2.1/source/src/vote.h000066400000000000000000000000001352165075300175360ustar00rootroot00000000000000assaultcube-1.2.0.2.1/source/src/water.cpp000066400000000000000000000214621352165075300202550ustar00rootroot00000000000000#include "cube.h" int wx1, wy1, wx2, wy2; float wsx1, wsy1, wsx2, wsy2; VARP(watersubdiv, 1, 4, 64); FVARF(waterlevel, -10000, -10000, 127, { if(!noteditmode("waterlevel")) { hdr.waterlevel = waterlevel * WATERLEVELSCALING; unsavededits++; } waterlevel = float(hdr.waterlevel) / WATERLEVELSCALING; // waterlevel and hdr.waterlevel need to be kept in sync }); void setwatercolor(const char *r, const char *g, const char *b, const char *a) { if(r[0]) { hdr.watercolor[0] = ATOI(r); hdr.watercolor[1] = ATOI(g); hdr.watercolor[2] = ATOI(b); hdr.watercolor[3] = a[0] ? ATOI(a) : 178; } else { hdr.watercolor[0] = 20; hdr.watercolor[1] = 25; hdr.watercolor[2] = 20; hdr.watercolor[3] = 178; } if(editmode) unsavededits++; } COMMANDF(watercolour, "ssss", (char *r, char *g, char *b, char *a) { if(editmode) setwatercolor(r, g, b, a); }); FVAR(waveheight, 0, 0.3f, 1.0f); VARP(ignoreoverride_limitwaveheight, 0, 0, 1); float effective_waveheight = 0.3f; void getwatercolour() { defformatstring(res)("%d %d %d %d", hdr.watercolor[0], hdr.watercolor[1], hdr.watercolor[2], hdr.watercolor[3]); result(res); } COMMAND(getwatercolour, ""); const char *componentnames[] = { "red", "green", "blue", "alpha", "" }; void setwatercolour(char *what, int *v) { int t = getlistindex(what, componentnames, true, -1); if(t >= 0 && t < 4 && editmode) { hdr.watercolor[t] = *v; unsavededits++; } } COMMAND(setwatercolour, "si"); // renders water for bounding rect area that contains water... simple but very inefficient #define VERTW(vertw, defbody, body) \ static inline void def##vertw() \ { \ varray::defattrib(varray::ATTRIB_VERTEX, 3, GL_FLOAT); \ defbody; \ } \ inline void vertw(float v1, float v2, float v3, float t) \ { \ float angle = v1*v2*0.1f/PI2 + t; \ float s = angle - int(angle) - 0.5f; \ s *= 8 - fabs(s)*16; \ float h = effective_waveheight*0.5f*s; \ varray::attrib(v1, v2, v3+h); \ body; \ } #define VERTWC(vertwc, defbody, body) \ VERTW(vertwc, defbody, { \ float v = angle - int(angle+0.25) - 0.25; \ v *= 8 - fabs(v)*16; \ body; \ }) #define VERTWT(vertwt, defbody, body) \ VERTWC(vertwt, defbody, { \ float duv = effective_waveheight*0.5f*v; \ body; \ }) VERTW(vertw, {}, {}) VERTWC(vertwc, { varray::defattrib(varray::ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE); }, { varray::attrib(hdr.watercolor[0], hdr.watercolor[1], hdr.watercolor[2], (uchar)(hdr.watercolor[3] + (max(v, 0.0f) - 0.5f)*51.0f)); }) VERTWT(vertwt, { varray::defattrib(varray::ATTRIB_TEXCOORD0, 3, GL_FLOAT); }, { varray::attrib(v1+duv, v2+duv, v3+h); }) VERTWT(vertwtc, { varray::defattrib(varray::ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE); varray::defattrib(varray::ATTRIB_TEXCOORD0, 3, GL_FLOAT); }, { varray::attrib(255, 255, 255, uchar(38 + max(v, 0.0f)*38)); varray::attrib(v1+duv, v2+duv, v3+h); }) VERTWT(vertwmtc, { varray::defattrib(varray::ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE); varray::defattrib(varray::ATTRIB_TEXCOORD0, 3, GL_FLOAT); varray::defattrib(varray::ATTRIB_TEXCOORD1, 3, GL_FLOAT); }, { varray::attrib(255, 255, 255, uchar(38 + max(v, 0.0f)*38)); varray::attrib(v1-duv, v2+duv, v3+h); varray::attrib(v1+duv, v2+duv, v3+h); }) extern int nquads; #define renderwaterstrips(vertw, hf, t) \ def##vertw(); \ for(int x = wx1; x=2 && reflecttex) { varray::enable(); if(refracttex) { setupmultitexrefract(reflecttex, refracttex); renderwaterstrips(vertwmtc, hf, t); } else { setupmultitexreflect(reflecttex); glDepthMask(GL_FALSE); glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_SRC_ALPHA); renderwaterstrips(vertwtc, hf, t); glDisable(GL_BLEND); glDepthMask(GL_TRUE); } cleanupmultitex(reflecttex, refracttex); varray::disable(); return nquads; } if(!refracttex) { glDisable(GL_TEXTURE_2D); glEnable(GL_BLEND); } glDepthMask(GL_FALSE); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); varray::enable(); if(reflecttex) { if(!refracttex) { glColor4ubv(hdr.watercolor); renderwaterstrips(vertw, hf, t); glEnable(GL_TEXTURE_2D); } setprojtexmatrix(); glBindTexture(GL_TEXTURE_2D, refracttex ? refracttex : reflecttex); } if(refracttex) { glColor3f(1, 1, 1); renderwaterstrips(vertwt, hf, t); glEnable(GL_BLEND); glBindTexture(GL_TEXTURE_2D, reflecttex); glDepthMask(GL_TRUE); } if(reflecttex) { renderwaterstrips(vertwtc, hf, t); } else { renderwaterstrips(vertwc, hf, t); } varray::disable(); if(reflecttex) { glLoadIdentity(); glMatrixMode(GL_MODELVIEW); } else glEnable(GL_TEXTURE_2D); glDisable(GL_BLEND); if(!refracttex) glDepthMask(GL_TRUE); return nquads; } void addwaterquad(int x, int y, int size) // update bounding rect that contains water { int x2 = x+size; int y2 = y+size; if(wx1<0) { wx1 = x; wy1 = y; wx2 = x2; wy2 = y2; } else { if(xwx2) wx2 = x2; if(y2>wy2) wy2 = y2; } } void calcwaterscissor() { vec4 v[4]; float sx1 = 1, sy1 = 1, sx2 = -1, sy2 = -1; loopi(4) { vec4 &p = v[i]; mvpmatrix.transform(vec(i&1 ? wx2 : wx1, i&2 ? wy2 : wy1, waterlevel - 0.3f), p); if(p.z >= 0) { float x = p.x / p.w, y = p.y / p.w; sx1 = min(sx1, x); sy1 = min(sy1, y); sx2 = max(sx2, x); sy2 = max(sy2, y); } } if(sx1 >= sx2 || sy1 >= sy2) { sx1 = sy1 = -1; sx2 = sy2 = 1; } else loopi(4) { const vec4 &p = v[i]; if(p.z >= 0) continue; loopj(2) { const vec4 &o = v[i^(1<weapons[i]->updatetimers(millis); d->lastaction = millis; } void checkweaponswitch() { if(!player1->weaponchanging) return; int timeprogress = lastmillis-player1->weaponchanging; if(timeprogress>weapon::weaponchangetime) { addmsg(SV_WEAPCHANGE, "ri", player1->weaponsel->type); player1->weaponchanging = 0; } else if(timeprogress>(weapon::weaponchangetime>>1) && player1->weaponsel != player1->nextweaponsel) { player1->prevweaponsel = player1->weaponsel; player1->weaponsel = player1->nextweaponsel; } } void selectweapon(weapon *w) { if(!w || !player1->weaponsel->deselectable()) return; if(w->selectable()) { if(player1->attacking && player1->state == CS_ALIVE) attack(false); int i = w->type; // substitute akimbo weapon *akimbo = player1->weapons[GUN_AKIMBO]; if(w->type==GUN_PISTOL && akimbo->selectable()) w = akimbo; player1->weaponswitch(w); exechook(HOOK_SP, "onWeaponSwitch", "%d", i); } } void requestweapon(char *ws) { int w = getlistindex(ws, gunnames, true, 0); if(keypressed && player1->state == CS_ALIVE && w >= 0) { if (player1->akimbo && w == GUN_PISTOL) w = GUN_AKIMBO; selectweapon(player1->weapons[w]); } } COMMANDN(weapon, requestweapon, "s"); void shiftweapon(int *s) { if(keypressed && player1->state == CS_ALIVE) { if(!player1->weaponsel->deselectable()) return; weapon *curweapon = player1->weaponsel; weapon *akimbo = player1->weapons[GUN_AKIMBO]; // collect available weapons vector availweapons; loopi(NUMGUNS) { weapon *w = player1->weapons[i]; if(!w) continue; if(w->selectable() || w==curweapon || (w->type==GUN_PISTOL && player1->akimbo)) { availweapons.add(w); } } // replace pistol by akimbo if(player1->akimbo) { availweapons.removeobj(akimbo); // and remove initial akimbo int pistolidx = availweapons.find(player1->weapons[GUN_PISTOL]); if(pistolidx>=0) availweapons[pistolidx] = akimbo; // insert at pistols position if(curweapon->type==GUN_PISTOL) curweapon = akimbo; // fix selection } // detect the next weapon int num = availweapons.length(); int curidx = availweapons.find(curweapon); if(!num || curidx<0) return; int idx = (curidx + *s) % num; if(idx<0) idx += num; weapon *next = availweapons[idx]; if(next->type!=player1->weaponsel->type) // different weapon { selectweapon(next); } } else if(player1->isspectating()) updatefollowplayer(*s); } COMMAND(shiftweapon, "i"); bool quicknade = false; void quicknadethrow(bool on) { if(player1->state != CS_ALIVE) return; if(on) { if(player1->weapons[GUN_GRENADE]->mag > 0) { if(player1->weaponsel->type != GUN_GRENADE) selectweapon(player1->weapons[GUN_GRENADE]); if(player1->weaponsel->type == GUN_GRENADE || player1->nextweaponsel->type == GUN_GRENADE) { if(!player1->weapons[GUN_GRENADE]->busy()) attack(true); } } } else { attack(false); if(player1->weaponsel->type == GUN_GRENADE) quicknade = true; } } COMMAND(quicknadethrow, "d"); COMMANDF(currentprimary, "", () { intret(player1->primweap->type); }); COMMANDF(prevweapon, "", () { intret(player1->prevweaponsel->type); }); COMMANDF(curweapon, "", () { intret(player1->weaponsel->type); }); COMMANDF(magcontent, "s", (char *ws) { int w = getlistindex(ws, gunnames, true, -1); if(w >= 0) intret(player1->weapons[w]->mag); else intret(-1); }); COMMANDF(magreserve, "s", (char *ws) { int w = getlistindex(ws, gunnames, true, -1); if(w >= 0) intret(player1->weapons[w]->ammo); else intret(-1); }); void tryreload(playerent *p) { if(!p || p->state!=CS_ALIVE || p->weaponsel->reloading || p->weaponchanging) return; p->weaponsel->reload(false); } COMMANDF(reload, "", () { tryreload(player1); }); void createrays(const vec &from, const vec &to) // create random spread of rays for the shotgun { vec dir = vec(from).sub(to); float f = dir.magnitude() / 10.0f; dir.normalize(); vec spoke; spoke.orthogonal(dir); spoke.normalize(); spoke.mul(f); loopk(3) { float base; int wrange; switch(k) { case 0: base = SGCObase / 100.0f; wrange = SGCOrange; break; case 1: base = SGCMbase / 100.0f; wrange = SGCMrange; break; case 2: default: base = SGCCbase / 100.0f; wrange = SGCCrange; break; } float rnddir = rndscale(PI2); loopi(SGRAYS) { int j = k * SGRAYS + i; sgr[j].ds = k; vec p(spoke); int rndmul = rnd(wrange); float veclen = base + rndmul/100.0f; p.mul(veclen); p.rotate(PI2 / SGRAYS * i + rnddir, dir); vec rray = vec(to); rray.add(p); sgr[j].rv = rray; } } } static inline bool intersectbox(const vec &o, const vec &rad, const vec &from, const vec &to, vec *end) // if lineseg hits entity bounding box { const vec *p; vec v = to, w = o; v.sub(from); w.sub(from); float c1 = w.dot(v); if(c1<=0) p = &from; else { float c2 = v.squaredlen(); if(c2<=c1) p = &to; else { float f = c1/c2; v.mul(f).add(from); p = &v; } } if(p->x <= o.x+rad.x && p->x >= o.x-rad.x && p->y <= o.y+rad.y && p->y >= o.y-rad.y && p->z <= o.z+rad.z && p->z >= o.z-rad.z) { if(end) *end = *p; return true; } return false; } static inline bool intersectsphere(const vec &from, const vec &to, vec center, float radius, float &dist) { vec ray(to); ray.sub(from); center.sub(from); float v = center.dot(ray), inside = radius*radius - center.squaredlen(); if(inside < 0 && v < 0) return false; float raysq = ray.squaredlen(), d = inside*raysq + v*v; if(d < 0) return false; dist = (v - sqrtf(d)) / raysq; return dist >= 0 && dist <= 1; } static inline bool intersectcylinder(const vec &from, const vec &to, const vec &start, const vec &end, float radius, float &dist) { vec d(end), m(from), n(to); d.sub(start); m.sub(start); n.sub(from); float md = m.dot(d), nd = n.dot(d), dd = d.squaredlen(); if(md < 0 && md + nd < 0) return false; if(md > dd && md + nd > dd) return false; float nn = n.squaredlen(), mn = m.dot(n), a = dd*nn - nd*nd, k = m.squaredlen() - radius*radius, c = dd*k - md*md; if(fabs(a) < 0.005f) { if(c > 0) return false; if(md < 0) dist = -mn / nn; else if(md > dd) dist = (nd - mn) / nn; else dist = 0; return true; } else if(c > 0) { float b = dd*mn - nd*md, discrim = b*b - a*c; if(discrim < 0) return false; dist = (-b - sqrtf(discrim)) / a; } else dist = 0; float offset = md + dist*nd; if(offset < 0) { if(nd <= 0) return false; dist = -md / nd; if(k + dist*(2*mn + dist*nn) > 0) return false; } else if(offset > dd) { if(nd >= 0) return false; dist = (dd - md) / nd; if(k + dd - 2*md + dist*(2*(mn-nd) + dist*nn) > 0) return false; } return dist >= 0 && dist <= 1; } int intersect(playerent *d, const vec &from, const vec &to, vec *end) { float dist; if(d->head.x >= 0) { if(intersectsphere(from, to, d->head, HEADSIZE, dist)) { if(end) (*end = to).sub(from).mul(dist).add(from); return 2; } } float y = d->yaw*RAD, p = (d->pitch/4+90)*RAD, c = cosf(p); vec bottom(d->o), top(sinf(y)*c, -cosf(y)*c, sinf(p))/*, mid(top)*/; bottom.z -= d->eyeheight; float h = d->eyeheight /*+ d->aboveeye*/; // this mod makes the shots pass over the shoulders // mid.mul(h*0.5).add(bottom); // this mod divides the hitbox in 2 top.mul(h).add(bottom); if( intersectcylinder(from, to, bottom, top, d->radius, dist) ) // FIXME if using 2 hitboxes { if(end) (*end = to).sub(from).mul(dist).add(from); return 1; } return 0; } bool intersect(entity *e, const vec &from, const vec &to, vec *end) { mapmodelinfo *mmi = getmminfo(e->attr2); if(!mmi || !mmi->h) return false; float lo = float(S(e->x, e->y)->floor + mmi->zoff + e->attr3); return intersectbox(vec(e->x, e->y, lo + mmi->h / 2.0f), vec(mmi->rad, mmi->rad, mmi->h / 2.0f), from, to, end); } playerent *intersectclosest(const vec &from, const vec &to, const playerent *at, float &bestdistsquared, int &hitzone, bool aiming = true) { playerent *best = NULL; bestdistsquared = 1e16f; int zone; if(at!=player1 && player1->state==CS_ALIVE && (zone = intersect(player1, from, to))) { best = player1; bestdistsquared = at->o.squareddist(player1->o); hitzone = zone; } loopv(players) { playerent *o = players[i]; if(!o || o==at || (o->state!=CS_ALIVE && (aiming || (o->state!=CS_EDITING && o->state!=CS_LAGGED)))) continue; float distsquared = at->o.squareddist(o->o); if(distsquared < bestdistsquared && (zone = intersect(o, from, to))) { best = o; bestdistsquared = distsquared; hitzone = zone; } } return best; } playerent *playerincrosshair() { if(camera1->type == ENT_PLAYER || (camera1->type == ENT_CAMERA && player1->spectatemode == SM_DEATHCAM)) { float dist; int hitzone; return intersectclosest(camera1->o, worldpos, (playerent *)camera1, dist, hitzone, false); } else return NULL; } inline bool intersecttriangle(const vec &from, const vec &dir, const vec &v0, const vec &v1, const vec &v2, vec *end, float *_t) // precise but rather expensive, based on Moeller–Trumbore intersection algorithm { const float EPSILON = 0.00001f; vec edge1 = v1; edge1.sub(v0); // edge1 = v1 - v0 vec edge2 = v2; edge2.sub(v0); // edge2 = v2 - v0 vec pvec; pvec.cross(dir, edge2); // pvec = dir x edge2 float det = edge1.dot(pvec); // det = edge1 * pvec if(fabs(det) < EPSILON) return false; float invdet = 1.0f / det; vec tvec = from; tvec.sub(v0); // tvec = from - v0 float u = invdet * tvec.dot(pvec); // u = tvec * pvec / det if(u < 0.0f || u > 1.0f) return false; vec qvec; qvec.cross(tvec, edge1); // qvec = tvec x edge1 float v = invdet * dir.dot(qvec); // v = dir * qvec / det if(v < 0.0f || u + v > 1.0f) return false; float t = invdet * edge2.dot(qvec); // t = edge2 * qvec / det if(t < EPSILON) return false; if(_t) *_t = t; // 0..1 if intersection is between from and to if(end) *end = dir, end->mul(t).add(from); // calculate point of intersection return true; } inline bool intersecttriangle2(const vec &from, const vec &to, const vec &v0, const vec &v1, const vec &v2, vec *end, float *_t) { vec dir = to; dir.sub(from); // dir = to - from return intersecttriangle(from, dir, v0, v1, v2, end, _t); } inline bool intersectcorner(const vec &from, const vec &dir, int x, int y, int size, bool cdir, vec *end, float *_t) { float fsx, fsy, dsx, dsy; if(cdir) { dsx = dir.x + dir.y; fsx = from.x - x + from.y - y - size; dsy = dir.y - dir.x; fsy = from.y - y - from.x + x + size; } else { dsx = dir.x - dir.y; fsx = from.x - x - from.y + y; dsy = dir.y + dir.x; fsy = from.y - y + from.x - x; } if(!dsx) return false; float t = -fsx / dsx; float dy = dsy * t + fsy; if(fabs(t * dsx + fsx) < NEARZERO && dy >= 0 && dy <= 2 * size) { if(_t) *_t = t; if(end) *end = dir, end->mul(t).add(from); return true; } return false; } void intersectgeometry(const vec &from, vec &to) // check line for contact with map geometry, shorten if necessary { int x = from.x, y = from.y, hfnb[4] = { 0, 1, ssize, ssize +1 }; if(OUTBORD(x, y) || from.z < -127.0f || from.z > 127.0f) return; vec d = to; // d: direction d.sub(from); float distmin = 1.0f, vdelta[4]; sqr *r[2], *s, *nb[4]; if(fabs(d.x) + fabs(d.y) < 2.0f) d.mul((distmin = 32.0f)); loop(xy, 2) // first check x == const planes and then y == const planes { float dxy = xy ? d.y : d.x, fromxy = xy ? from.y : from.x; bool dxynz = fabs(dxy) < NEARZERO; if(dxy == 0.0f) dxy = 1e-20; // hack int ixy = fromxy, step = dxy < 0 ? -1 : 1, steps = fabs(dxy) + 1, sqrdir = xy ? -ssize : -1; while(steps-- > 0) { // intersect d with plane float t = dxynz ? distmin : (ixy - fromxy) / dxy; vec p = d; p.mul(t).add(from); // check position if(xy) x = p.x, y = ixy; else x = ixy, y = p.y; if(t > distmin || OUTBORD(x, y)) break; // always check cubes on both sides of the plane r[0] = S(x, y); r[1] = r[0] + sqrdir; if(t > 0) loopk(2) { s = r[k]; if(SOLID(s) || s->floor > p.z || s->ceil < p.z || s->type == CORNER) { // cube s is a probable hit, examine further if(k) { // match x|y back to s if(xy) y--; else x--; } if(s->type == CORNER) { sqr *ns, *h = NULL, *n; int bx, by, bs; int q = cornertest(x, y, bx, by, bs, ns, h); vec newto; float newdist; if(intersectcorner(from, d, bx, by, bs, !(q & 1), &newto, &newdist) && newdist < distmin && (!h || newto.z < ns->floor || newto.z > ns->ceil)) to = newto, distmin = newdist; if(d.z) { // intersect with z == const plane where the corner ends bool downwards = d.z < 0.0f; n = h ? h : ns; float endplate = downwards ? n->floor : n->ceil; float tz = (endplate - from.z) / d.z; vec pz = d; pz.mul(tz).add(from); if(pz.x >= bx && pz.x <= bx + bs && pz.y >= by && pz.y <= by + bs && tz < distmin) to = pz, distmin = tz; if(h) { // intersect with the triangles where socket corners end float sockplate = downwards ? ns->floor : ns->ceil; tz = (sockplate - from.z) / d.z; pz = d; pz.mul(tz).add(from); float cx = pz.x - bx, cy = pz.y - by; bool hit = false; switch(q) // 0XX3 { // XXXX case 0: hit = cx + cy >= bs; break; // 1XX2 case 1: hit = cx >= cy; break; case 2: hit = cx + cy <= bs; break; case 3: hit = cx <= cy; break; default: hit = true; break; // annoy bad mappers } if(hit && cx >= 0 && cy >= 0 && cx <= bs && cy <= bs && tz < distmin) to = pz, distmin = tz; } } } else { // finish checking walls if(SOLID(s) || s->type == SPACE || (s->type == CHF && s->floor > p.z) || (s->type == FHF && s->ceil < p.z)) { if(t < distmin) to = p, distmin = t; } else if(s->type == CHF || s->type == FHF) { loopi(4) vdelta[i] = ((nb[i] = s + hfnb[i]))->vdelta; // 23 int nb2 = "\002\001\013\023"[xy + 2 * k], nb1 = nb2 >> 3; nb2 &= 3; if(s->type == FHF) { // FHF side surfaces float a = s->floor - vdelta[nb1] / 4.0f, b = (vdelta[nb1] - vdelta[nb2]) / 4.0f, dummy, i = modff(xy ? p.x : p.y, &dummy); if(a + i * b > p.z && t < distmin) to = p, distmin = t; } else { // CHF side surfaces float a = s->ceil + vdelta[nb1] / 4.0f, b = (vdelta[nb2] - vdelta[nb1]) / 4.0f, dummy, i = modff(xy ? p.x : p.y, &dummy); if(a + i * b < p.z && t < distmin) to = p, distmin = t; } } // check floor and ceiling bool isflat = true, downwards = d.z < 0.0f; if(s->type == CHF || s->type == FHF) loopi(3) if(vdelta[3] != vdelta[i]) isflat = false; float h = downwards ? s->floor - (isflat && s->type == FHF ? vdelta[0] / 4.0f : 0) : s->ceil + (isflat && s->type == CHF ? vdelta[0] / 4.0f : 0); if(isflat || (downwards && s->type == CHF) || (!downwards && s->type == FHF)) { // intersect with z == const plane on either SPACE or flat ends of FHF and CHF float tz = d.z != 0.0f ? (h - from.z) / d.z : distmin; vec pz = d; pz.mul(tz).add(from); if(int(pz.x) == x && int(pz.y) == y && tz < distmin) to = pz, distmin = tz; } if(!isflat) { // sloped CHF or FHF: check two triangles, regardless of "downwards" or not (FHF slopes can be seen looking upwards) if(s->type == FHF) loopi(4) vdelta[i] *= -1.0f; float hh = s->type == FHF ? s->floor : s->ceil; vec v0(x, y, hh + vdelta[0] / 4.0f), v1(x + 1, y, hh + vdelta[1] / 4.0f), v2(x, y + 1, hh + vdelta[2] / 4.0f), v3(x + 1, y + 1, hh + vdelta[3] / 4.0f); float newdist; vec newto; if(s->type == FHF) { if(intersecttriangle(from, d, v0, v1, v2, &newto, &newdist) && newdist < distmin) to = newto, distmin = newdist; if(intersecttriangle(from, d, v3, v1, v2, &newto, &newdist) && newdist < distmin) to = newto, distmin = newdist; } else { if(intersecttriangle(from, d, v0, v1, v3, &newto, &newdist) && newdist < distmin) to = newto, distmin = newdist; if(intersecttriangle(from, d, v2, v0, v3, &newto, &newdist) && newdist < distmin) to = newto, distmin = newdist; } } } } } ixy += step; } } } void damageeffect(int damage, playerent *d) { particle_splash(PART_BLOOD, damage/10, 1000, d->o); } struct hitweap { float hits; int shots; hitweap() {hits=shots=0;} }; hitweap accuracym[NUMGUNS]; inline void attackevent(playerent *owner, int weapon) { if(owner == player1) exechook(HOOK_SP, "onAttack", "%d", weapon); } vector hits; void hit(int damage, playerent *d, playerent *at, const vec &vel, int gun, bool gib, int info) { if(d==player1 || d->type==ENT_BOT || !m_mp(gamemode)) d->hitpush(damage, vel, at, gun); if(at == player1 && d != player1) { extern int hitsound; extern int lasthit; if(hitsound == 2 && lasthit != lastmillis) { defformatstring(hitsnd)("sound %d %d;", S_HITSOUND, SP_HIGHEST); addsleep(60, hitsnd); lasthit = lastmillis; } } if(!m_mp(gamemode)) dodamage(damage, d, at, gun, gib); else { hitmsg &h = hits.add(); h.target = d->clientnum; h.lifesequence = d->lifesequence; h.info = info; if(d==player1) { h.dir = ivec(0, 0, 0); d->damageroll(damage); if(d != at) updatedmgindicator(player1, at->o); damageblend(damage, d); damageeffect(damage, d); audiomgr.playsound(S_PAIN6, SP_HIGH); } else { h.dir = ivec(int(vel.x*DNF), int(vel.y*DNF), int(vel.z*DNF)); // damageeffect(damage, d); // audiomgr.playsound(S_PAIN1+rnd(5), d); } } } void hitpush(int damage, playerent *d, playerent *at, vec &from, vec &to, int gun, bool gib, int info) { vec v(to); v.sub(from); v.normalize(); hit(damage, d, at, v, gun, gib, info); } float expdist(playerent *o, vec &dir, const vec &v) { vec middle = o->o; middle.z += (o->aboveeye-o->eyeheight)/2; float dist = middle.dist(v, dir); dir.div(dist); if(dist<0) dist = 0; return dist; } void radialeffect(playerent *o, vec &v, int qdam, playerent *at, int gun) { if(o->state!=CS_ALIVE) return; vec dir; float dist = expdist(o, dir, v); if(dist bounceents; void removebounceents(playerent *owner) { loopv(bounceents) if(bounceents[i]->owner==owner) { delete bounceents[i]; bounceents.remove(i--); } } void movebounceents() { loopv(bounceents) if(bounceents[i]) { bounceent *p = bounceents[i]; if((p->bouncetype==BT_NADE || p->bouncetype==BT_GIB) && p->applyphysics()) movebounceent(p, 1, false); if(!p->isalive(lastmillis)) { p->destroy(); delete p; bounceents.remove(i--); } } } void clearbounceents() { if(gamespeed==100); else if(multiplayer(NULL)) bounceents.add((bounceent *)player1); loopv(bounceents) if(bounceents[i]) { delete bounceents[i]; bounceents.remove(i--); } } void renderbounceents() { loopv(bounceents) { bounceent *p = bounceents[i]; if(!p) continue; string model; vec o(p->o); int anim = ANIM_MAPMODEL, basetime = 0; switch(p->bouncetype) { case BT_NADE: copystring(model, "weapons/grenade/static"); break; case BT_GIB: default: { uint n = (((4*(uint)(size_t)p)+(uint)p->timetolive)%3)+1; formatstring(model)("misc/gib0%u", n); int t = lastmillis-p->millis; if(t>p->timetolive-2000) { anim = ANIM_DECAY; basetime = p->millis+p->timetolive-2000; t -= p->timetolive-2000; o.z -= t*t/4000000000.0f*t; } break; } } rendermodel(model, anim|ANIM_LOOP|ANIM_DYNALLOC, 0, 1.1f, o, 0, p->yaw+90, p->pitch, 0, basetime); } } VARP(gib, 0, 1, 1); VARP(gibnum, 0, 6, 1000); VARP(gibttl, 0, 7000, 60000); VARP(gibspeed, 1, 30, 100); void addgib(playerent *d) { if(!d || !gib || !gibttl) return; audiomgr.playsound(S_GIB, d); d->nocorpse = true; // don't render regular corpse: it was gibbed loopi(gibnum) { bounceent *p = bounceents.add(new bounceent); p->owner = d; p->millis = lastmillis; p->timetolive = gibttl+rnd(10)*100; p->bouncetype = BT_GIB; p->o = d->o; p->o.z -= d->aboveeye; p->inwater = waterlevel > p->o.z; p->yaw = (float)rnd(360); p->pitch = (float)rnd(360); p->maxspeed = 30.0f; p->rotspeed = 3.0f; const float angle = (float)rnd(360); const float speed = (float)gibspeed; p->vel.x = sinf(RAD*angle)*rnd(1000)/1000.0f; p->vel.y = cosf(RAD*angle)*rnd(1000)/1000.0f; p->vel.z = rnd(1000)/1000.0f; p->vel.mul(speed/100.0f); p->resetinterp(); } } void shorten(const vec &from, vec &target, float distsquared) { target.sub(from); float m = target.squaredlen(); if(m < 0.07f) target.add(vec(0.1f, 0.1f, 0.1f)); // if "from == target" just fake a target to avoid zero-length fx vectors else target.mul(max(0.07f, sqrtf(distsquared / m))); target.add(from); } void raydamage(vec &from, vec &to, playerent *d) { int dam = d->weaponsel->info.damage; int hitzone = -1; playerent *o = NULL; float distsquared, hitdistsquared = 0.0f; bool hit = false; int rayscount = 0, hitscount = 0; if(d->weaponsel->type==GUN_SHOTGUN) { playerent *hits[3*SGRAYS]; loopk(3) loopi(SGRAYS) { rayscount++; int h = k*SGRAYS + i; if((hits[h] = intersectclosest(from, sgr[h].rv, d, distsquared, hitzone))) shorten(from, sgr[h].rv, (hitdistsquared = distsquared)); } loopk(3) loopi(SGRAYS) { int h = k*SGRAYS + i; if(hits[h]) { o = hits[h]; hits[h] = NULL; int numhits_o, numhits_m, numhits_c; numhits_o = numhits_m = numhits_c = 0; switch(sgr[h].ds) { case 0: numhits_o++; break; case 1: numhits_m++; break; case 2: numhits_c++; break; default: break; } for(int j = i+1; j < 3*SGRAYS; j++) if(hits[j] == o) { hits[j] = NULL; switch(sgr[j].ds) { case 0: numhits_o++; break; case 1: numhits_m++; break; case 2: numhits_c++; break; default: break; } } int numhits = numhits_o + numhits_m + numhits_c; int dmgreal = 0; float dmg4r = 0.0f; bool withBONUS = false; if(SGDMGBONUS) { float d2o = SGDMGDISTB; if(o) d2o = vec(from).sub(o->o).magnitude(); if(d2o <= (SGDMGDISTB/10.0f) && numhits) { dmg4r += SGDMGBONUS; withBONUS = true; } } dmg4r += (SGCOdmg / 10.0f * SGDMGTOTAL / 100.0f) * numhits_o / 21.0f; dmg4r += (SGCMdmg / 10.0f * SGDMGTOTAL / 100.0f) * numhits_m / 21.0f; dmg4r += (SGCCdmg / 10.0f * SGDMGTOTAL / 100.0f) * numhits_c / 21.0f; dmgreal = (int) ceil(dmg4r); int info = (withBONUS ? SGDMGBONUS : 0) | (numhits_c << 8) | (numhits_m << 16) | (numhits_o << 24); if(numhits) hitpush(dmgreal, o, d, from, to, d->weaponsel->type, numhits == SGRAYS * 3, info); if(d == player1) hit = true; hitscount+=numhits; } } if(hitscount) shorten(from, to, hitdistsquared); } else if((o = intersectclosest(from, to, d, distsquared, hitzone))) { bool gib = false; switch(d->weaponsel->type) { case GUN_KNIFE: gib = true; break; case GUN_SNIPER: if(d==player1 && hitzone==2) { dam *= 3; gib = true; }; break; default: break; } bool info = gib; hitpush(dam, o, d, from, to, d->weaponsel->type, gib, info ? 1 : 0); if(d == player1) hit = true; shorten(from, to, distsquared); hitscount++; } if(d==player1) { if(!rayscount) rayscount = 1; if(hit) accuracym[d->weaponsel->type].hits += (float)hitscount / rayscount; accuracym[d->weaponsel->type].shots++; } } const char *weapstr(int i) { return valid_weapon(i) ? guns[i].title : "x"; } VARP(accuracy,0,0,1); void r_accuracy(int h) { int i = player1->weaponsel->type; if(accuracy && valid_weapon(i) && i != GUN_CPISTOL) { int x_offset = 2 * HUDPOS_X_BOTTOMLEFT, y_offset = 2 * (h - 1.75 * FONTH); string line; float acc = accuracym[i].shots ? 100.0 * accuracym[i].hits / (float)accuracym[i].shots : 0; if(i == GUN_GRENADE || i == GUN_SHOTGUN) { formatstring(line)("\f5%5.1f%% (%.1f/%d): \f0%s", acc, accuracym[i].hits, accuracym[i].shots, weapstr(i)); } else { formatstring(line)("\f5%5.1f%% (%d/%d): \f0%s", acc, (int)accuracym[i].hits, accuracym[i].shots, weapstr(i)); } blendbox(x_offset, y_offset + FONTH, x_offset + text_width(line) + 2 * FONTH, y_offset - FONTH, false, -1); draw_textf("%s", x_offset + FONTH, y_offset - 0.5 * FONTH, line); } } void accuracyinfo() { vector lines; loopi(NUMGUNS) if(i != GUN_CPISTOL && accuracym[i].shots) { float acc = 100.0 * accuracym[i].hits / (float)accuracym[i].shots; string line; if(i == GUN_GRENADE || i == GUN_SHOTGUN) { formatstring(line)("\f0%-10s\t\f5 %.1f%% (%.1f/%d)", weapstr(i), acc, accuracym[i].hits, accuracym[i].shots); } else { formatstring(line)("\f0%-10s\t\f5 %.1f%% (%d/%d)", weapstr(i), acc, (int)accuracym[i].hits, accuracym[i].shots); } lines.add(newstring(line)); } loopv(lines) conoutf("%s", lines[i]); lines.deletearrays(); } COMMAND(accuracyinfo, ""); void accuracyreset() { loopi(NUMGUNS) { accuracym[i].hits=accuracym[i].shots=0; } conoutf("Your accuracy has been reset"); } COMMAND(accuracyreset, ""); // weapon weapon::weapon(class playerent *owner, int type) : type(type), owner(owner), info(guns[type]), ammo(owner->ammo[type]), mag(owner->mag[type]), gunwait(owner->gunwait[type]), reloading(0) { } const int weapon::weaponchangetime = 400; const float weapon::weaponbeloweye = 0.2f; int weapon::flashtime() const { return max((int)info.attackdelay, 120)/4; } void weapon::sendshoot(vec &from, vec &to, int millis) { if(owner!=player1) return; owner->shoot = true; addmsg(SV_SHOOT, "ri2i3iv", millis, owner->weaponsel->type, (int)(to.x*DMF), (int)(to.y*DMF), (int)(to.z*DMF), hits.length(), hits.length()*sizeof(hitmsg)/sizeof(int), hits.getbuf()); player1->pstatshots[player1->weaponsel->type]++; //NEW } bool weapon::modelattacking() { int animtime = min(owner->gunwait[owner->weaponsel->type], (int)owner->weaponsel->info.attackdelay); if(lastmillis - owner->lastaction < animtime) return true; else return false; } void weapon::attacksound() { if(info.sound == S_NULL) return; bool local = (owner == player1); audiomgr.playsound(info.sound, owner, local ? SP_HIGH : SP_NORMAL); } bool weapon::reload(bool autoreloaded) { if(mag>=info.magsize || ammo<=0) return false; updatelastaction(owner); reloading = lastmillis; gunwait += info.reloadtime; int numbullets = min(info.magsize - mag, ammo); mag += numbullets; ammo -= numbullets; bool local = (player1 == owner); if(info.reload != S_NULL) audiomgr.playsound(info.reload, owner, local ? SP_HIGH : SP_NORMAL); if(local) { addmsg(SV_RELOAD, "ri2", lastmillis, owner->weaponsel->type); exechook(HOOK_SP, "onReload", "%d", (int)autoreloaded); } return true; } VARP(oldfashionedgunstats, 0, 0, 1); void weapon::renderstats() { string gunstats; if(oldfashionedgunstats) formatstring(gunstats)("%d/%d", mag, ammo); else formatstring(gunstats)("%d", mag); draw_text(gunstats, HUDPOS_WEAPON + HUDPOS_NUMBERSPACING, 823); if(!oldfashionedgunstats) { int offset = text_width(gunstats); glScalef(0.5f, 0.5f, 1.0f); formatstring(gunstats)("%d", ammo); draw_text(gunstats, (HUDPOS_WEAPON + HUDPOS_NUMBERSPACING + offset)*2, 826*2); glLoadIdentity(); } } static int recoiltest = 0;//VAR(recoiltest, 0, 0, 1); // DISABLE ON RELEASE static int recoilincrease = 2; //VAR(recoilincrease, 1, 2, 10); static int recoilbase = 40;//VAR(recoilbase, 0, 40, 1000); static int maxrecoil = 1000;//VAR(maxrecoil, 0, 1000, 1000); void weapon::attackphysics(vec &from, vec &to) // physical fx to the owner { const guninfo &g = info; vec unitv; float dist = to.dist(from, unitv); float f = dist/1000; int spread = dynspread(); float recoil = dynrecoil()*-0.01f; // spread if(spread>1) { #define RNDD (rnd(spread)-spread/2)*f vec r(RNDD, RNDD, RNDD); to.add(r); #undef RNDD } // kickback & recoil if(recoiltest) { owner->vel.add(vec(unitv).mul(recoil/dist).mul(owner->crouching ? 0.75 : 1.0f)); owner->pitchvel = min(powf(shots/(float)(recoilincrease), 2.0f)+(float)(recoilbase)/10.0f, (float)(maxrecoil)/10.0f); } else { owner->vel.add(vec(unitv).mul(recoil/dist).mul(owner->crouching ? 0.75 : 1.0f)); owner->pitchvel = min(powf(shots/(float)(g.recoilincrease), 2.0f)+(float)(g.recoilbase)/10.0f, (float)(g.maxrecoil)/10.0f); } } VARP(righthanded, 0, 1, 1); // flowtron 20090727 void weapon::renderhudmodel(int lastaction, int index) { playerent *p = owner; vec unitv; float dist = worldpos.dist(p->o, unitv); unitv.div(dist); weaponmove wm; if(!intermission) wm.calcmove(unitv, lastaction, p); // if(!intermission) wm.calcmove(unitv, p->lastaction, p); defformatstring(path)("weapons/%s", info.modelname); bool emit = (wm.anim&ANIM_INDEX)==ANIM_GUN_SHOOT && (lastmillis - lastaction) < flashtime(); // bool emit = (wm.anim&ANIM_INDEX)==ANIM_GUN_SHOOT && (lastmillis - p->lastaction) < flashtime(); rendermodel(path, wm.anim|ANIM_DYNALLOC|(righthanded==index ? ANIM_MIRROR : 0)|(emit ? ANIM_PARTICLE : 0), 0, -1, wm.pos, 0, p->yaw+90, p->pitch+wm.k_rot, 40.0f, wm.basetime, NULL, NULL, 1.28f); } void weapon::updatetimers(int millis) { if(gunwait) gunwait = max(gunwait - (millis-owner->lastaction), 0); } void weapon::onselecting() { updatelastaction(owner); bool local = (owner == player1); audiomgr.playsound(S_GUNCHANGE, owner, local ? SP_HIGH : SP_NORMAL); } void weapon::renderhudmodel() { renderhudmodel(owner->lastaction); } void weapon::renderaimhelp(bool teamwarning) { if(!editmode) drawcrosshair(owner, teamwarning ? CROSSHAIR_TEAMMATE : owner->weaponsel->type); else drawcrosshair(owner, CROSSHAIR_EDIT); } int weapon::dynspread() { return info.spread; } float weapon::dynrecoil() { return info.recoil; } bool weapon::selectable() { return this != owner->weaponsel && owner->state == CS_ALIVE && !owner->weaponchanging; } bool weapon::deselectable() { return !reloading; } void weapon::equipplayer(playerent *pl) { if(!pl) return; pl->weapons[GUN_ASSAULT] = new assaultrifle(pl); pl->weapons[GUN_GRENADE] = new grenades(pl); pl->weapons[GUN_KNIFE] = new knife(pl); pl->weapons[GUN_PISTOL] = new pistol(pl); pl->weapons[GUN_CPISTOL] = new cpistol(pl); pl->weapons[GUN_CARBINE] = new carbine(pl); pl->weapons[GUN_SHOTGUN] = new shotgun(pl); pl->weapons[GUN_SNIPER] = new sniperrifle(pl); pl->weapons[GUN_SUBGUN] = new subgun(pl); pl->weapons[GUN_AKIMBO] = new akimbo(pl); pl->selectweapon(GUN_ASSAULT); pl->setprimary(GUN_ASSAULT); pl->setnextprimary(GUN_ASSAULT); } // grenadeent enum { NS_NONE, NS_ACTIVATED = 0, NS_THROWN, NS_EXPLODED }; grenadeent::grenadeent (playerent *owner, int millis) { ASSERT(owner); nadestate = NS_NONE; local = owner==player1; bounceent::owner = owner; bounceent::millis = lastmillis; timetolive = 2000-millis; bouncetype = BT_NADE; maxspeed = 30.0f; rotspeed = 6.0f; distsincebounce = 0.0f; } grenadeent::~grenadeent() { if(owner && owner->weapons[GUN_GRENADE]) owner->weapons[GUN_GRENADE]->removebounceent(this); } void grenadeent::explode() { if(nadestate!=NS_ACTIVATED && nadestate!=NS_THROWN ) return; nadestate = NS_EXPLODED; static vec n(0,0,0); hits.setsize(0); splash(); if(local) addmsg(SV_EXPLODE, "ri3iv", lastmillis, GUN_GRENADE, millis, hits.length(), hits.length()*sizeof(hitmsg)/sizeof(int), hits.getbuf()); audiomgr.playsound(S_FEXPLODE, &o); if(((grenades *)owner->weapons[GUN_GRENADE])->state == GST_NONE) owner->weapons[GUN_GRENADE]->reset(); } void grenadeent::splash() { particle_splash(PART_SPARK, 50, 300, o); particle_fireball(PART_FIREBALL, o); addscorchmark(o); adddynlight(NULL, o, 16, 200, 100, 255, 255, 224); adddynlight(NULL, o, 16, 600, 600, 192, 160, 128); if(owner == player1) { accuracym[GUN_GRENADE].shots++; } else if(!m_botmode) { return; } int damage = guns[GUN_GRENADE].damage; radialeffect(owner->type == ENT_BOT ? player1 : owner, o, damage, owner, GUN_GRENADE); loopv(players) { playerent *p = players[i]; if(!p) continue; radialeffect(p, o, damage, owner, GUN_GRENADE); } } void grenadeent::activate(const vec &from, const vec &to) { if(nadestate!=NS_NONE) return; nadestate = NS_ACTIVATED; if(local) { addmsg(SV_SHOOT, "ri2i3i", millis, owner->weaponsel->type, // (int)(from.x*DMF), (int)(from.y*DMF), (int)(from.z*DMF), (int)(to.x*DMF), (int)(to.y*DMF), (int)(to.z*DMF), 0); audiomgr.playsound(S_GRENADEPULL, SP_HIGH); player1->pstatshots[GUN_GRENADE]++; //NEW } } void grenadeent::_throw(const vec &from, const vec &vel) { if(nadestate!=NS_ACTIVATED) return; nadestate = NS_THROWN; this->vel = vel; this->o = from; this->resetinterp(); inwater = waterlevel > o.z; if(local) { addmsg(SV_THROWNADE, "ri7", int(o.x*DMF), int(o.y*DMF), int(o.z*DMF), int(vel.x*DMF), int(vel.y*DMF), int(vel.z*DMF), lastmillis-millis); audiomgr.playsound(S_GRENADETHROW, SP_HIGH); } else audiomgr.playsound(S_GRENADETHROW, owner); } void grenadeent::moveoutsidebbox(const vec &direction, playerent *boundingbox) { vel = direction; o = boundingbox->o; inwater = waterlevel > o.z; boundingbox->cancollide = false; loopi(10) moveplayer(this, 10, true, 10); boundingbox->cancollide = true; } void grenadeent::destroy() { explode(); } bool grenadeent::applyphysics() { return nadestate==NS_THROWN; } void grenadeent::oncollision() { if(distsincebounce>=1.5f) audiomgr.playsound(rnd(2) ? S_GRENADEBOUNCE1 : S_GRENADEBOUNCE2, &o); distsincebounce = 0.0f; } void grenadeent::onmoved(const vec &dist) { distsincebounce += dist.magnitude(); } // grenades grenades::grenades(playerent *owner) : weapon(owner, GUN_GRENADE), inhandnade(NULL), throwwait((13*1000)/40), throwmillis(0), cookingmillis(0), state(GST_NONE) {} int grenades::flashtime() const { return 0; } bool grenades::busy() { return state!=GST_NONE; } bool grenades::attack(vec &targ) { int attackmillis = lastmillis-owner->lastaction; vec &to = targ; bool waitdone = attackmillis>=gunwait && !(m_arena && m_teammode && arenaintermission); if(waitdone) gunwait = reloading = 0; switch(state) { case GST_NONE: if(waitdone && owner->attacking && this==owner->weaponsel) { attackevent(owner, type); activatenade(to); // activate } else quicknade = false; break; case GST_INHAND: if(waitdone) { if(!owner->attacking || this!=owner->weaponsel) thrownade(); // throw else if(!inhandnade->isalive(lastmillis)) dropnade(); // drop & have fun } break; case GST_THROWING: if(attackmillis >= throwwait) // throw done { if(this == owner->weaponsel) { if(quicknade || !mag) { owner->weaponchanging = lastmillis - 1 - (weaponchangetime / 2); if(quicknade) owner->nextweaponsel = owner->weaponsel = owner->prevweaponsel; // switch to previous weapon immediately else owner->nextweaponsel = owner->weaponsel = owner->primweap; // switch to primary immediately } } reset(); return false; } break; } return true; } void grenades::attackfx(const vec &from, const vec &to, int millis) // other player's grenades { throwmillis = lastmillis-millis; cookingmillis = millis; if(millis == 0 || millis == -1) { state = GST_INHAND; audiomgr.playsound(S_GRENADEPULL, owner); // activate } else if(millis > 0) // throw { grenadeent *g = new grenadeent(owner, millis); state = GST_THROWING; bounceents.add(g); g->_throw(from, to); } } int grenades::modelanim() { if(state == GST_THROWING) { if(lastmillis - owner->lastaction >= throwwait) state = GST_NONE; return ANIM_GUN_THROW; } else { int animtime = min(gunwait, (int)info.attackdelay); if(state == GST_INHAND || lastmillis - owner->lastaction < animtime) return ANIM_GUN_SHOOT; } return ANIM_GUN_IDLE; } void grenades::activatenade(const vec &to) { if(!mag) return; throwmillis = 0; inhandnade = new grenadeent(owner); bounceents.add(inhandnade); updatelastaction(owner); mag--; gunwait = info.attackdelay; owner->lastattackweapon = this; state = GST_INHAND; inhandnade->activate(owner->o, to); } void grenades::thrownade() { if(!inhandnade) return; const float speed = cosf(RAD*owner->pitch); vec vel(sinf(RAD*owner->yaw)*speed, -cosf(RAD*owner->yaw)*speed, sinf(RAD*owner->pitch)); vel.mul(1.5f); thrownade(vel); } void grenades::thrownade(const vec &vel) { inhandnade->moveoutsidebbox(vel, owner); inhandnade->_throw(inhandnade->o, vel); inhandnade = NULL; throwmillis = lastmillis; updatelastaction(owner); state = GST_THROWING; if(this==owner->weaponsel) owner->attacking = false; } void grenades::dropnade() { vec n(0,0,0); thrownade(n); } void grenades::renderstats() { char gunstats[64]; sprintf(gunstats, "%d", mag); draw_text(gunstats, oldfashionedgunstats ? HUDPOS_GRENADE + HUDPOS_NUMBERSPACING + 25 : HUDPOS_GRENADE + HUDPOS_NUMBERSPACING, 823); } bool grenades::selectable() { return weapon::selectable() && state != GST_INHAND && mag; } void grenades::reset() { throwmillis = 0; cookingmillis = 0; if(owner == player1) quicknade = false; state = GST_NONE; } void grenades::onselecting() { reset(); bool local = (owner == player1); audiomgr.playsound(S_GUNCHANGE, owner, local ? SP_HIGH : SP_NORMAL); } void grenades::onownerdies() { reset(); if(owner==player1 && inhandnade) dropnade(); } void grenades::removebounceent(bounceent *b) { if(b == inhandnade) { inhandnade = NULL; reset(); } } // gun base class gun::gun(playerent *owner, int type) : weapon(owner, type) {} bool gun::attack(vec &targ) { int attackmillis = lastmillis-owner->lastaction - gunwait; if(attackmillis<0) return false; gunwait = reloading = 0; if(!owner->attacking) { shots = 0; checkautoreload(); return false; } attackmillis = lastmillis - min(attackmillis, curtime); updatelastaction(owner, attackmillis); if(!mag) { bool local = (owner == player1); audiomgr.playsound(S_NOAMMO, owner, local ? SP_HIGH : SP_NORMAL); gunwait += 250; owner->lastattackweapon = NULL; shots = 0; checkautoreload(); return false; } owner->lastattackweapon = this; shots++; if(!info.isauto) owner->attacking = false; if(burstshotssettings[this->type] > 0 && shots >= burstshotssettings[this->type]) owner->attacking = false; vec from = owner->o; vec to = targ; from.z -= weaponbeloweye; attackphysics(from, to); attackevent(owner, type); hits.setsize(0); raydamage(from, to, owner); attackfx(from, to, 0); gunwait = info.attackdelay; mag--; sendshoot(from, to, attackmillis); return true; } void gun::attackfx(const vec &from, const vec &to, int millis) { if(from.squareddist(to) > 0.07f) { addbullethole(owner, from, to); addshotline(owner, from, to); } particle_splash(PART_SPARK, 5, 250, to); adddynlight(owner, from, 4, 100, 50, 96, 80, 64); attacksound(); } int gun::modelanim() { return modelattacking() ? ANIM_GUN_SHOOT|ANIM_LOOP : ANIM_GUN_IDLE; } void gun::checkautoreload() { if(autoreload && owner==player1 && !mag) reload(true); } void gun::onownerdies() { shots = 0; } // shotgun shotgun::shotgun(playerent *owner) : gun(owner, GUN_SHOTGUN) {} void shotgun::attackphysics(vec &from, vec &to) { createrays(from, to); gun::attackphysics(from, to); } bool shotgun::attack(vec &targ) { return gun::attack(targ); } void shotgun::attackfx(const vec &from, const vec &to, int millis) { loopi(SGRAYS) particle_splash(PART_SPARK, 5, 200, sgr[i].rv); if(addbullethole(owner, from, to)) loopk(3) loopi(3) addbullethole(owner, from, sgr[k*SGRAYS+i*SGRAYS/3].rv, 0, false); adddynlight(owner, from, 4, 100, 50, 96, 80, 64); attacksound(); } bool shotgun::selectable() { return weapon::selectable() && !m_noprimary && this == owner->primweap; } // subgun subgun::subgun(playerent *owner) : gun(owner, GUN_SUBGUN) {} bool subgun::selectable() { return weapon::selectable() && !m_noprimary && this == owner->primweap; } int subgun::dynspread() { return shots > 2 ? 70 : ( info.spread + ( shots > 0 ? ( shots == 1 ? 5 : 10 ) : 0 ) ); } // CHANGED: 2010nov19 was: min(info.spread + 10 * shots, 80) // sniperrifle sniperrifle::sniperrifle(playerent *owner) : gun(owner, GUN_SNIPER), scoped(false) {} void sniperrifle::attackfx(const vec &from, const vec &to, int millis) { if(from.squareddist(to) > 0.07f) { addbullethole(owner, from, to); addshotline(owner, from, to); particle_trail(PART_SMOKE, 500, from, to); } particle_splash(PART_SPARK, 50, 200, to); adddynlight(owner, from, 4, 100, 50, 96, 80, 64); attacksound(); } bool sniperrifle::reload(bool autoreloaded) { bool r = weapon::reload(autoreloaded); if(owner==player1 && r) { scoped = false; player1->scoping = false; } return r; } #define SCOPESETTLETIME 180 int sniperrifle::dynspread() { if(scoped) { int scopetime = lastmillis - scoped_since; if(scopetime > SCOPESETTLETIME) return 1; else return max((info.spread * (SCOPESETTLETIME - scopetime)) / SCOPESETTLETIME, 1); } return info.spread; } float sniperrifle::dynrecoil() { return scoped && lastmillis - scoped_since > SCOPESETTLETIME ? info.recoil / 3 : info.recoil; } bool sniperrifle::selectable() { return weapon::selectable() && !m_noprimary && this == owner->primweap; } void sniperrifle::onselecting() { weapon::onselecting(); scoped = false; player1->scoping = false; } void sniperrifle::ondeselecting() { scoped = false; player1->scoping = false; } void sniperrifle::onownerdies() { scoped = false; player1->scoping = false; shots = 0; } void sniperrifle::renderhudmodel() { if(!scoped) weapon::renderhudmodel(); } void sniperrifle::renderaimhelp(bool teamwarning) { if(scoped) drawscope(); if(!editmode) { if(scoped || teamwarning) drawcrosshair(owner, teamwarning ? CROSSHAIR_TEAMMATE : CROSSHAIR_SCOPE, NULL, 24.0f); } else drawcrosshair(owner, CROSSHAIR_EDIT); } void sniperrifle::setscope(bool enable) { if(this == owner->weaponsel && !reloading && owner->state == CS_ALIVE) { if(scoped == false && enable == true) scoped_since = lastmillis; if(enable != scoped) owner->scoping = enable; scoped = enable; } } // carbine carbine::carbine(playerent *owner) : gun(owner, GUN_CARBINE) {} bool carbine::selectable() { return weapon::selectable() && !m_noprimary && this == owner->primweap; } // assaultrifle assaultrifle::assaultrifle(playerent *owner) : gun(owner, GUN_ASSAULT) {} int assaultrifle::dynspread() { return shots > 2 ? 55 : ( info.spread + ( shots > 0 ? ( shots == 1 ? 5 : 15 ) : 0 ) ); } float assaultrifle::dynrecoil() { return info.recoil + (rnd(8)*-0.01f); } bool assaultrifle::selectable() { return weapon::selectable() && !m_noprimary && this == owner->primweap; } // combat pistol cpistol::cpistol(playerent *owner) : gun(owner, GUN_CPISTOL), bursting(false) {} bool cpistol::selectable() { return false; /*return weapon::selectable() && !m_noprimary && this == owner->primweap;*/ } void cpistol::onselecting() { weapon::onselecting(); bursting = false; } void cpistol::ondeselecting() { bursting = false; } bool cpistol::reload(bool autoreloaded) { bool r = weapon::reload(autoreloaded); if(owner==player1 && r) { bursting = false; } return r; } bool burst = false; int burstshots = 0; bool cpistol::attack(vec &targ) // modded from gun::attack // FIXME { int attackmillis = lastmillis-owner->lastaction - gunwait; if(attackmillis<0) return false; gunwait = reloading = 0; if (bursting) burst = true; if(!owner->attacking) { shots = 0; checkautoreload(); return false; } attackmillis = lastmillis - min(attackmillis, curtime); updatelastaction(owner, attackmillis); if(!mag) { audiomgr.playsoundc(S_NOAMMO); gunwait += 250; owner->lastattackweapon = NULL; shots = 0; checkautoreload(); return false; } owner->lastattackweapon = this; shots++; if (burst) burstshots++; if(!burst) owner->attacking = false; vec from = owner->o; vec to = targ; from.z -= weaponbeloweye; attackphysics(from, to); hits.setsize(0); raydamage(from, to, owner); attackfx(from, to, 0); if ( burst && burstshots > 2 ) { gunwait = 500; burstshots = 0; burst = owner->attacking = false; } else if ( burst ) { gunwait = 80; } else { gunwait = info.attackdelay; } mag--; sendshoot(from, to, attackmillis); return true; } void cpistol::setburst(bool enable) { if(this == owner->weaponsel && !reloading && owner->state == CS_ALIVE) { bursting = enable; } } void setburst(bool enable) { if(player1->weaponsel->type != GUN_CPISTOL) return; if(intermission) return; cpistol *cp = (cpistol *)player1->weaponsel; cp->setburst(enable); if (!burst) { if ( enable && burstshots == 0 ) attack(true); } else { if ( burstshots == 0 ) burst = player1->attacking = enable; } } COMMAND(setburst, "d"); // pistol pistol::pistol(playerent *owner) : gun(owner, GUN_PISTOL) {} bool pistol::selectable() { return weapon::selectable() && !m_nopistol; } // akimbo akimbo::akimbo(playerent *owner) : gun(owner, GUN_AKIMBO), akimboside(0), akimbomillis(0) { akimbolastaction[0] = akimbolastaction[1] = 0; } void akimbo::attackfx(const vec &from, const vec &to, int millis) { akimbolastaction[akimboside] = owner->lastaction; akimboside = (akimboside+1)%2; gun::attackfx(from, to, millis); } void akimbo::onammopicked() { akimbomillis = lastmillis + 30000; if(owner==player1) { if(akimboautoswitch || owner->weaponsel->type==GUN_PISTOL) { if(player1->weapons[GUN_GRENADE]->busy()) player1->attacking = false; owner->weaponswitch(this); } addmsg(SV_AKIMBO, "ri", lastmillis); } } void akimbo::onselecting() { gun::onselecting(); akimbolastaction[0] = akimbolastaction[1] = lastmillis; } bool akimbo::selectable() { return weapon::selectable() && !m_nopistol && owner->akimbo; } void akimbo::updatetimers(int millis) { weapon::updatetimers(millis); /*loopi(2) akimbolastaction[i] = millis;*/ } void akimbo::reset() { akimbolastaction[0] = akimbolastaction[1] = akimbomillis = akimboside = 0; } void akimbo::renderhudmodel() { weapon::renderhudmodel(akimbolastaction[0], 0); weapon::renderhudmodel(akimbolastaction[1], 1); } bool akimbo::timerout() { return akimbomillis && akimbomillis <= lastmillis; } // knife knife::knife(playerent *owner) : weapon(owner, GUN_KNIFE) {} int knife::flashtime() const { return 0; } bool knife::attack(vec &targ) { int attackmillis = lastmillis-owner->lastaction - gunwait; if(attackmillis<0) return false; gunwait = reloading = 0; if(!owner->attacking) return false; attackmillis = lastmillis - min(attackmillis, curtime); updatelastaction(owner, attackmillis); owner->lastattackweapon = this; owner->attacking = false; vec from = owner->o; vec to = targ; from.z -= weaponbeloweye; vec unitv; float dist = to.dist(from, unitv); unitv.div(dist); unitv.mul(3); // punch range to = from; to.add(unitv); if ( owner->pitch < 0 ) to.z += 2.5 * sin( owner->pitch * 0.01745329 ); attackevent(owner, type); hits.setsize(0); raydamage(from, to, owner); attackfx(from, to, 0); sendshoot(from, to, attackmillis); gunwait = info.attackdelay; return true; } int knife::modelanim() { return modelattacking() ? ANIM_GUN_SHOOT : ANIM_GUN_IDLE; } void knife::drawstats() {} void knife::attackfx(const vec &from, const vec &to, int millis) { attacksound(); } void knife::renderstats() { } void setscope(bool enable) { if(player1->weaponsel->type != GUN_SNIPER) return; sniperrifle *sr = (sniperrifle *)player1->weaponsel; sr->setscope(enable); } COMMANDF(setscope, "i", (int *on) { setscope(*on != 0); }); void shoot(playerent *p, vec &targ) { if(p->state!=CS_ALIVE) return; weapon *weap = p->weaponsel, *bweap = p->weapons[GUN_GRENADE]; if(bweap->busy()) bweap->attack(targ); // continue ongoing nade action else bweap = NULL; if(weap && !p->weaponchanging && weap != bweap) weap->attack(targ); } void checkakimbo() { if(player1->akimbo) { akimbo &a = *((akimbo *)player1->weapons[GUN_AKIMBO]); if(a.timerout() || player1->state == CS_DEAD || player1->state == CS_SPECTATE) { weapon &p = *player1->weapons[GUN_PISTOL]; player1->akimbo = false; a.reset(); if(player1->weaponsel->type==GUN_AKIMBO || (player1->weaponchanging && player1->nextweaponsel->type==GUN_AKIMBO)) { switch(akimboendaction) { case 0: player1->weaponswitch(player1->weapons[GUN_KNIFE]); break; case 1: { if(player1->weapons[GUN_PISTOL]->ammo) player1->weaponswitch(&p); else player1->weaponswitch(player1->weapons[GUN_KNIFE]); break; } case 2: { if(player1->mag[GUN_GRENADE]) player1->weaponswitch(player1->weapons[GUN_GRENADE]); else { if(player1->weapons[GUN_PISTOL]->ammo) player1->weaponswitch(&p); else player1->weaponswitch(player1->weapons[GUN_KNIFE]); } break; } case 3: { if(player1->ammo[player1->primary]) player1->weaponswitch(player1->weapons[player1->primary]); else { if(player1->mag[GUN_GRENADE]) player1->weaponswitch(player1->weapons[GUN_GRENADE]); else { if(player1->weapons[GUN_PISTOL]->ammo) player1->weaponswitch(&p); else player1->weaponswitch(player1->weapons[GUN_KNIFE]); } } break; } default: break; /* case 0: player1->weaponswitch(&p); break; case 1: { if( player1->ammo[player1->primary] ) player1->weaponswitch(player1->weapons[player1->primary]); else player1->weaponswitch(&p); break; } case 2: { if( player1->mag[GUN_GRENADE] ) player1->weaponswitch(player1->weapons[GUN_GRENADE]); else { if( player1->ammo[player1->primary] ) player1->weaponswitch(player1->weapons[player1->primary]); else player1->weaponswitch(&p); } break; } default: break; */ } } if(player1->state != CS_DEAD && player1->state != CS_SPECTATE) audiomgr.playsoundc(S_AKIMBOOUT); } } } void checkweaponstate() { checkweaponswitch(); checkakimbo(); } assaultcube-1.2.0.2.1/source/src/weapon.h000066400000000000000000000101701352165075300200630ustar00rootroot00000000000000 class playerent; class bounceent; struct weapon { const static int weaponchangetime; const static float weaponbeloweye; static void equipplayer(playerent *pl); weapon(class playerent *owner, int type); virtual ~weapon() {} int type; playerent *owner; const struct guninfo &info; int &ammo, &mag, &gunwait, shots; virtual int dynspread(); virtual float dynrecoil(); int reloading, lastaction; virtual bool attack(vec &targ) = 0; virtual void attackfx(const vec &from, const vec &to, int millis) = 0; virtual void attackphysics(vec &from, vec &to); virtual void attacksound(); virtual bool reload(bool autoreloaded); virtual void reset() {} virtual bool busy() { return false; } virtual int modelanim() = 0; virtual void updatetimers(int millis); virtual bool selectable(); virtual bool deselectable(); virtual void renderstats(); virtual void renderhudmodel(); virtual void renderaimhelp(bool teamwarning); virtual void onselecting(); virtual void ondeselecting() {} virtual void onammopicked() {} virtual void onownerdies() {} virtual void removebounceent(bounceent *b) {} void sendshoot(vec &from, vec &to, int millis); bool modelattacking(); void renderhudmodel(int lastaction, int index = 0); virtual int flashtime() const; }; class grenadeent; enum { GST_NONE = 0, GST_INHAND, GST_THROWING }; struct grenades : weapon { grenadeent *inhandnade; const int throwwait; int throwmillis; int cookingmillis; int state; grenades(playerent *owner); bool attack(vec &targ); void attackfx(const vec &from, const vec &to, int millis); int modelanim(); void activatenade(const vec &to); void thrownade(); void thrownade(const vec &vel); void dropnade(); void renderstats(); bool selectable(); void reset(); bool busy(); void onselecting(); void onownerdies(); void removebounceent(bounceent *b); int flashtime() const; }; struct gun : weapon { gun(playerent *owner, int type); virtual bool attack(vec &targ); virtual void attackfx(const vec &from, const vec &to, int millis); int modelanim(); void checkautoreload(); void onownerdies(); }; struct subgun : gun { subgun(playerent *owner); int dynspread(); bool selectable(); }; struct sniperrifle : gun { bool scoped; int scoped_since; sniperrifle(playerent *owner); void attackfx(const vec &from, const vec &to, int millis); bool reload(bool autoreloaded); int dynspread(); float dynrecoil(); bool selectable(); void onselecting(); void ondeselecting(); void onownerdies(); void renderhudmodel(); void renderaimhelp(bool teamwarning); void setscope(bool enable); }; struct carbine : gun { carbine(playerent *owner); bool selectable(); }; struct shotgun : gun { shotgun(playerent *owner); void attackphysics(vec &from, vec &to); bool attack(vec &targ); void attackfx(const vec &from, const vec &to, int millis); bool selectable(); }; struct assaultrifle : gun { assaultrifle(playerent *owner); int dynspread(); float dynrecoil(); bool selectable(); }; struct cpistol : gun { bool bursting; cpistol(playerent *owner); bool reload(bool autoreloaded); bool selectable(); void onselecting(); void ondeselecting(); bool attack(vec &targ); void setburst(bool enable); }; struct pistol : gun { pistol(playerent *owner); bool selectable(); }; struct akimbo : gun { akimbo(playerent *owner); int akimboside; int akimbomillis; int akimbolastaction[2]; void attackfx(const vec &from, const vec &to, int millis); void onammopicked(); void onselecting(); bool selectable(); void updatetimers(int millis); void reset(); void renderhudmodel(); bool timerout(); }; struct knife : weapon { knife(playerent *owner); bool attack(vec &targ); int modelanim(); void drawstats(); void attackfx(const vec &from, const vec &to, int millis); void renderstats(); int flashtime() const; }; assaultcube-1.2.0.2.1/source/src/winserviceinstaller.h000066400000000000000000000022361352165075300226720ustar00rootroot00000000000000// minimal windows service installer class winserviceinstaller { private: LPCSTR name; LPCSTR displayName; LPCSTR path; SC_HANDLE scm; public: winserviceinstaller(LPCSTR name, LPCSTR displayName, LPCSTR path) : name(name), displayName(displayName), path(path), scm(NULL) { } ~winserviceinstaller() { CloseManager(); } bool OpenManger() { return ((scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS)) != NULL); } void CloseManager() { if(scm) CloseServiceHandle(scm); } int IsInstalled() { if(!scm) return -1; SC_HANDLE svc = OpenService(scm, name, SC_MANAGER_CONNECT); bool installed = svc != NULL; CloseServiceHandle(svc); return installed ? 1 : 0; } int Install() { if(!scm) return -1; SC_HANDLE svc = CreateService(scm, name, displayName, SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, path, NULL, NULL, NULL, NULL, NULL); if(svc == NULL) return 0; else { CloseServiceHandle(svc); return 1; } } }; assaultcube-1.2.0.2.1/source/src/wizard.cpp000066400000000000000000000136111352165075300204300ustar00rootroot00000000000000// wizard to start an AssaultCube server and storing the configuration #include "cube.h" #ifdef WIN32 #ifndef __GNUC__ #pragma warning( disable : 4996 ) #endif #include #include "winserviceinstaller.h" #elif __GNUC__ #include #include #endif static void addarg(vector &argstr, const char *name) { argstr.add(' '); argstr.put(name, strlen(name)); } static void addarg(vector &argstr, const char *name, const char *val) { addarg(argstr, name); bool space = strchr(val, ' ')!=NULL; if(space) argstr.add('"'); argstr.put(val, strlen(val)); if(space) argstr.add('"'); } static void readarg(const char *desc, char *val, int len) { printf("%s: ", desc); fflush(stdout); fgets(val, len, stdin); char *end = strchr(val, '\n'); if(end) *end = '\0'; } static void readarg(vector &argstr, const char *desc, const char *name) { string val = ""; readarg(desc, val, sizeof(val)); if(val[0]) addarg(argstr, name, val); } int wizardmain(int argc, char **argv) { const char *outfile = NULL, *relpath = NULL; for(int i = 1; i < argc; i++) { if(argv[i][0] == '-') continue; if(!outfile) outfile = argv[i]; else if(!relpath) relpath = argv[i]; } if(!outfile || !relpath) { printf("invalid arguments specified!\n"); printf("usage: ac_server \n"); return EXIT_FAILURE; } printf("The AssaultCube Server Wizard\n\n"); printf("Before setting up a new server, please ensure you've read the rules at:\n" "\thttp://masterserver.cubers.net/rules.html\n\n"); printf("You will also need to ensure that the UDP port you choose is open.\n" "Whatever port you choose, you will need to forward that port, plus one port after that.\n" "If you're having issues, use and forward the default ports 28763 and 28764\n" "Use http://www.portforward.com for guidance.\n\n"); printf("Now to specify some optional settings for your server.\n" "The default settings will be used if you leave the fields blank.\n" "If you're unsure about what to specify for the settings, leave the field blank.\n\n" "Read http://assault.cubers.net/docs/commandline.html for a description of these settings.\n\n"); vector argstr; readarg(argstr, "Server description", "-n"); readarg(argstr, "Message of the day", "-o"); readarg(argstr, "Maximum clients (No more than 16 allowed!)", "-c"); readarg(argstr, "Administrator password", "-x"); readarg(argstr, "Server port", "-f"); printf("\nPrivate server settings:\n" "------------------------\n"); string ispub = ""; readarg("Public server (Yes/No)?", ispub, sizeof(ispub)); if(toupper(ispub[0]) == 'N') addarg(argstr, "-mlocalhost"); string cmds = ""; readarg(argstr, "Player password", "-p"); readarg("\nAdditional server switches", cmds, sizeof(cmds)); if(cmds[0]) addarg(argstr, cmds); #ifdef WIN32 string wsname = "", wsdisplayname = ""; readarg("win service name", wsname, sizeof(wsname)); if(wsname[0]) readarg("win service display", wsdisplayname, sizeof(wsdisplayname)); #endif printf("\nWriting your configuration to %s ... ", outfile); fflush(stdout); argstr.add('\0'); FILE *script = fopen(outfile, "w"); if(!script) { printf("Failed!\n"); return EXIT_FAILURE; } #ifdef WIN32 fprintf(script, "%s%s\npause\n", relpath, argstr.getbuf()); #elif __GNUC__ fprintf(script, "#!/bin/sh\n%s%s\n", relpath, argstr.getbuf()); #endif fclose(script); printf("Done\n\n"); printf("Note: You can start %s directly the next time you want to use the same configuration to start the server.\n\n", outfile); #ifdef WIN32 if(wsname[0]) { if(!wsdisplayname[0]) copystring(wsdisplayname, wsname); printf("Installing the AC Server as windows service ... "); fflush(stdout); vector path; databuf cwd = path.reserve(MAX_PATH); if(!_getcwd(cwd.buf, MAX_PATH)) { printf("Failed!\n"); printf("Could not get current working directory: %u\n", (uint)GetLastError()); return EXIT_FAILURE; } path.advance(strlen(cwd.buf)); path.add('\\'); path.put(relpath, strlen(relpath)); path.put(" -S", 3); path.put(wsname, strlen(wsname)); path.add(' '); path.put(argstr.getbuf(), argstr.length()); winserviceinstaller installer(wsname, wsdisplayname, path.getbuf()); int r; if(!installer.OpenManger()) { printf("Failed!\n"); printf("Could not open the Service Control Manager: %u\n", (uint)GetLastError()); installer.CloseManager(); return EXIT_FAILURE; } if((r = installer.IsInstalled()) != 0) { printf("Failed!\n"); if(r == -1) printf("Error accessing the Service Control Manager\n"); else if(r == 1) printf("A windows service with this name (%s) is already installed: %u\n", wsname, (uint)GetLastError()); return EXIT_FAILURE; } if((r = installer.Install()) != 1) { printf("Failed!\n"); if(r == -1) printf("Error accessing the Service Control Manager\n"); else if(r == 0) printf("Could not create the new windows service: %u\n", (uint)GetLastError()); return EXIT_FAILURE; } printf("Done\n\n"); printf("Note: You can now manage your AC server using services.msc and sc.exe\n\n"); } #endif printf("Please press ENTER now to start your server...\n"); fgetc(stdin); printf("Starting the AC server ...\n"); argstr.insert(0, relpath, strlen(relpath)); system(argstr.getbuf()); return EXIT_SUCCESS; } assaultcube-1.2.0.2.1/source/src/world.cpp000066400000000000000000001034471352165075300202660ustar00rootroot00000000000000// world.cpp: core map management stuff #include "cube.h" #include "bot/bot.h" sqr *world = NULL; int sfactor, ssize, cubicsize, mipsize; header hdr; _mapconfigdata mapconfigdata; // main geometric mipmapping routine, recursively rebuild mipmaps within block b. // tries to produce cube out of 4 lower level mips as well as possible, // sets defer to 0 if mipped cube is a perfect mip, i.e. can be rendered at this // mip level indistinguishable from its constituent cubes (saves considerable // rendering time if this is possible). void remip(const block &b, int level) { if(level>=SMALLEST_FACTOR) return; int lighterr = lighterror*3; sqr *w = wmip[level]; sqr *v = wmip[level+1]; int wfactor = sfactor - level; int vfactor = sfactor - (level+1); block s = b; if(s.x&1) { s.x--; s.xs++; } if(s.y&1) { s.y--; s.ys++; } s.xs = (s.xs+1)&~1; s.ys = (s.ys+1)&~1; for(int y = s.y; ytype = o[0]->type == o[1]->type && o[0]->type == o[2]->type && o[0]->type == o[3]->type ? o[0]->type : SEMISOLID; if(!SOLID(r)) { int floor = 127, ceil = -128; loopi(4) if(!SOLID(o[i])) { int fh = o[i]->floor; int ch = o[i]->ceil; if(r->type==SEMISOLID) { if(o[i]->type==FHF) fh -= o[i]->vdelta/4+2; // crap hack, needed for rendering large mips next to hfs if(o[i]->type==CHF) ch += o[i]->vdelta/4+2; // FIXME: needs to somehow take into account middle vertices on higher mips } if(fhceil) ceil = ch; } r->floor = floor; r->ceil = ceil; } if(r->type==CORNER) goto mip; // special case: don't ever split even if textures etc are different r->defer = 1; if(level) { loopi(4) if(o[i]->defer) goto c; } // if any of the constituents is not perfect, then this one isn't either if(SOLID(r)) { loopi(3) { if(o[i]->wtex != o[3]->wtex) goto c; // on an all solid cube, only thing that needs to be equal for a perfect mip is the wall texture } } else { loopi(3) { sqr *q = o[i + 1]; if(*((uint32_t *)q) != *((uint32_t *)o[0]) // type, floor, ceil, wtex || iabs(q->b - o[0]->b) > lighterr || q->ftex != o[0]->ftex || q->ctex != o[0]->ctex || iabs(q->r - o[0]->r) > lighterr // perfect mip even if light is not exactly equal || iabs(q->g - o[0]->g) > lighterr || q->utex != o[0]->utex) goto c; } if(r->type==CHF || r->type==FHF) // can make a perfect mip out of a hf if slopes lie on one line { if(o[0]->vdelta-o[1]->vdelta != o[1]->vdelta-SWS(w,x+2,y,wfactor)->vdelta || o[0]->vdelta-o[2]->vdelta != o[2]->vdelta-SWS(w,x+2,y+2,wfactor)->vdelta || o[0]->vdelta-o[3]->vdelta != o[3]->vdelta-SWS(w,x,y+2,wfactor)->vdelta || o[3]->vdelta-o[2]->vdelta != o[2]->vdelta-SWS(w,x+2,y+1,wfactor)->vdelta || o[1]->vdelta-o[2]->vdelta != o[2]->vdelta-SWS(w,x+1,y+2,wfactor)->vdelta) goto c; } } mip: r->defer = 0; c:; loopi(4) o[i] += 2; r++; } } s.x /= 2; s.y /= 2; s.xs /= 2; s.ys /= 2; remip(s, level+1); } void remipmore(const block &b, int level) { block bb = b; if(bb.x>1) bb.x--; if(bb.y>1) bb.y--; if(bb.xs1) bb.x--; if(bb.y>1) bb.y--; bb.xs = min(ssize - bb.x - 1, bb.xs + 2); bb.ys = min(ssize - bb.y - 1, bb.ys + 2); remip(bb); } static int clentsel = 0, clenttype = NOTUSED, pinnedent = -1; bool pinnedclosestent = false, pointingatents = false; COMMANDF(nextclosestent, "", () { clentsel++; } ); void closestenttype(char *what) { if(strcmp(what, "-")) clenttype = what[0] ? findtype(what) : NOTUSED; intret(clenttype); } COMMAND(closestenttype, "s"); COMMANDF(toggleclosestentpin, "", () { pinnedclosestent = ents.inrange((pinnedent = pinnedclosestent ? -1 : closestent())); }); void pointatent(int *_on) { bool on = *_on != 0; if(pointingatents != on) { if(on) pinnedclosestent = false; else if(!pinnedclosestent) { int n = closestent(); if(n >= 0) pinnedent = n, pinnedclosestent = true; } pointingatents = on; } } COMMAND(pointatent, "i"); FVARP(pointatentmaxangle, 0.01f, 2.0f, 180.0f); bool intersectangular(const vec &from, vec ray, vec ent, float maxangle, float &dist) { ray.sub(from); ent.sub(from); float v = ent.dot(ray), e = ent.magnitude(), r = ray.magnitude(); if(v < maxangle * e * r) return false; dist = e; return true; } int closestent() // used for delent and edit mode ent display { if(noteditmode("closestent")) return -1; int best = -1, enttypemask = clenttype == NOTUSED ? ((~edithideentmask) << 1) : (1 << clenttype); // bitmask of selectable ent types float bdist = 99999, dist, maxangle = pointingatents ? cosf(pointatentmaxangle * RAD) : -SQRT3; if(pinnedclosestent) { if(ents.inrange(pinnedent) && (enttypemask & (1 << ents[pinnedent].type))) best = pinnedent; else pinnedclosestent = false; // release lock when ent is deleted or no longer selectable } if(best < 0) { // find entity of closest distance in desired solid angle loopv(ents) { entity &e = ents[i]; if(!(enttypemask & (1 << e.type))) continue; if(intersectangular(camera1->o, worldpos, vec(e.x, e.y, e.z), maxangle, dist) && dist < bdist) { best = i; bdist = dist; } } } if(best >= 0) { // if closest ent shares location with other ents, pick one with clentsel vector bs; loopv(ents) { entity &e = ents[i]; if(!(enttypemask & (1 << e.type))) continue; if(ents[best].x == e.x && ents[best].y == e.y && ents[best].z == e.z) bs.add(i); } best = bs[(clentsel %= bs.length())]; } return best; } COMMANDF(getclosestent, "", () { intret(closestent()); }); void entproperty(int *prop, float *famount, int *unscaled) { int n = closestent(), amount = *prop >= 100 ? -1 : 1; *prop %= 100; if(n < 0) return; entity &e = ents[n]; int old_a1 = e.attr1; int t = e.type < MAXENTTYPES ? e.type : 0; amount *= int(*famount * (*prop >= 0 && *prop < 7 && !*unscaled ? entscale[t][*prop] : 1)); switch(*prop) { case 0: e.attr1 += amount; break; case 1: e.attr2 += amount; break; case 2: e.attr3 += amount; break; case 3: e.attr4 += amount; break; case 4: e.attr5 += amount; break; case 5: e.attr6 += amount; break; case 6: e.attr7 += amount; break; case 11: e.x += amount; break; case 12: e.y += amount; break; case 13: e.z += amount; break; } clampentityattributes(e); switch(e.type) { case LIGHT: calclight(); break; case SOUND: audiomgr.preloadmapsound(e); entityreference entref(&e); location *loc = audiomgr.locations.find(old_a1, &entref, mapsounds); if(loc) loc->drop(); } if(changedents.find(n) == -1) changedents.add(n); // apply ent changes later (reduces network traffic) unsavededits++; } COMMAND(entproperty, "ifi"); hashtable mapinfo, &resdata = mapinfo; void getenttype() { int e = closestent(); if(e<0) return; int type = ents[e].type; if(type < 0 || type >= MAXENTTYPES) return; result(entnames[type]); } COMMAND(getenttype, ""); void getentattr(int *attr, int *unscaled) { int n = closestent(); const char *res = "0"; if(n >= 0) { entity &e = ents[n]; int t = e.type < MAXENTTYPES ? e.type : 0; int scale = *attr >= 0 && *attr < 7 && !*unscaled ? entscale[t][*attr] : 1; switch(*attr) { #define CHKATTR(x) case x - 1: res = floatstr(float(e.attr##x) / scale, true); break CHKATTR(1); CHKATTR(2); CHKATTR(3); CHKATTR(4); CHKATTR(5); CHKATTR(6); CHKATTR(7); #undef CHKATTR } } result(res); } COMMAND(getentattr, "ii"); void deletesoundentity(entity &e) { entityreference entref(&e); location *loc = audiomgr.locations.find(e.attr1, &entref, mapsounds); if(loc) loc->drop(); } vector deleted_ents; void delent() { int n = closestent(); if(n<0) { conoutf("no more entities"); return; } syncentchanges(true); int t = ents[n].type; conoutf("%s entity deleted", entnames[t % MAXENTTYPES]); entity &e = ents[n]; if(t == SOUND) deletesoundentity(e); //stop playing sound deleted_ents.add(e); ents[n].type = NOTUSED; addmsg(SV_EDITENT, "ri9i3", n, NOTUSED, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); switch(t) { case LIGHT: calclight(); break; } unsavededits++; } COMMAND(delent, ""); void undelent(char *index) { if(noteditmode("undelent")) return; if(!deleted_ents.length()) { conoutf("no more entities to undelete"); return; } int n = isdigit(*index) ? strtol(index, NULL, 0) : deleted_ents.length() - 1; if(deleted_ents.inrange(n)) { persistent_entity e = deleted_ents.remove(n); int t = e.type < MAXENTTYPES ? e.type : NOTUSED; if(OUTBORD(e.x, e.y)) conoutf("failed to undelete %s entity (coordinates outside map borders)", entnames[t]); else { newentity(-1, e.x, e.y, e.z, entnames[t], float(e.attr1) / entscale[t][0], float(e.attr2) / entscale[t][1], float(e.attr3) / entscale[t][2], float(e.attr4) / entscale[t][3]); *((persistent_entity *) &ents.last()) = e; if(changedents.find(ents.length() - 1) == -1) changedents.add(ents.length() - 1); // tag ent for sync because of attr5..7 conoutf("%s entity undeleted", entnames[t]); } } } COMMAND(undelent, "s"); void getdeletedentities() { vector res; loopv(deleted_ents) { persistent_entity &e = deleted_ents[i]; int t = e.type < MAXENTTYPES ? e.type : NOTUSED; cvecprintf(res,"%s %d %d %d %s\n", entnames[t], e.x, e.y, e.z, formatentityattributes(e)); } resultcharvector(res, -1); } COMMAND(getdeletedentities, ""); void unlistdeletedentity(char *which) { if(!strcasecmp(which, "all")) deleted_ents.setsize(0); else if(!strcasecmp(which, "last")) deleted_ents.pop(); else if(isdigit(*which)) { int n = strtol(which, NULL, 0); if(deleted_ents.inrange(n)) deleted_ents.remove(n); } intret(deleted_ents.length()); } COMMAND(unlistdeletedentity, "s"); int findtype(const char *what) { int t = getlistindex(what, entnames, true, NOTUSED); if(t == NOTUSED) conoutf("unknown entity type \"%s\"", what); return t; } void newentity(int index, int x, int y, int z, const char *what, float v1f, float v2f, float v3f, float v4f) // add an entity or overwrite an existing one { int type = findtype(what); if(type == NOTUSED) return; if (index >= 0 && ents[index].type == SOUND) deletesoundentity(ents[index]); // overwriting sound entity switch(type) { // MAPMODEL, PLAYERSTART and CTF-FLAG use the current camera direction as value for attr1, so attr234 need to be moved case MAPMODEL: v4f = v3f; v3f = v2f; case PLAYERSTART: case CTF_FLAG: v2f = v1f; int y = camera1->yaw; if(type != PLAYERSTART) y = y + 7 - (y + 7) % 15; v1f = y; break; } int v1 = v1f * entscale[type][0], v2 = v2f * entscale[type][1], v3 = v3f * entscale[type][2], v4 = v4f * entscale[type][3]; entity e(x, y, z, type, v1, v2, v3, v4); switch(type) { case LIGHT: if(v1 > 64) e.attr1 = 64; if(!v1) e.attr1 = 16; if(!v2 && !v3 && !v4) e.attr2 = 255; break; } clampentityattributes(e); syncentchanges(true); addmsg(SV_EDITENT, "ri9i3", index<0 ? ents.length() : index, type, e.x, e.y, e.z, e.attr1, e.attr2, e.attr3, e.attr4, e.attr5, e.attr6, e.attr7); e.spawned = true; int oldtype = type; if(index<0) ents.add(e); else { oldtype = ents[index].type; ents[index] = e; } if(oldtype!=type) switch(oldtype) { case LIGHT: calclight(); break; } switch(type) { case LIGHT: calclight(); break; case SOUND: audiomgr.preloadmapsound(e); break; } if(index >= 0 || type != DUMMYENT) unsavededits++; // no need to save dummies } void entset(char *what, float *a1, float *a2, float *a3, float *a4) { int n = closestent(); if(n>=0) { entity &e = ents[n]; newentity(n, e.x, e.y, e.z, what, *a1, *a2, *a3, *a4); } } COMMAND(entset, "sffff"); void clearents(char *name) { int type = findtype(name); EDITMP("clearents"); bool found = false; loopv(ents) { entity &e = ents[i]; if(e.type == type) { if(type == SOUND) deletesoundentity(e); deleted_ents.add(e); e.type = NOTUSED; found = true; } } switch(type) { case LIGHT: calclight(); break; } if(found) unsavededits++; } COMMAND(clearents, "s"); // entity commands based on entity number (for scripts, singleplayer only) void deleteentity(char *ns) { int n = ATOI(ns); EDITMP("deleteentity"); if(!*ns || !ents.inrange(n)) return; entity &e = ents[n]; int t = e.type; if(t == SOUND) deletesoundentity(e); conoutf("deleted entity #%d (%s)", n, entnames[e.type]); deleted_ents.add(e); memset(&e, 0, sizeof(persistent_entity)); e.type = NOTUSED; if(t == LIGHT) calclight(); unsavededits++; } COMMAND(deleteentity, "s"); void addentity(char *what) // type { int type = findtype(what); EDITMP("addentity"); if(type == NOTUSED) return; entity e((int)camera1->o.x, (int)camera1->o.y, (int)camera1->o.z, type, 0, 0, 0, 0); e.spawned = true; intret(ents.length()); ents.add(e); unsavededits++; } COMMAND(addentity, "s"); void editentity(char **args, int numargs) // index x y z a1 a2 a3 a4 ... { string res = ""; if(numargs > 0) { int n = ATOI(args[0]); EDIT("editentity"); if(!*args[0] || !ents.inrange(n)) return; entity &e = ents[n]; bool edit = false; for(int i = 1; i < numargs; i++) if(*args[i]) edit = true; // only arguments other than empty strings can edit anything - otherwise we're just browsing int t = e.type < MAXENTTYPES ? e.type : NOTUSED; if((edit) && !multiplayer("editentity")) { if(e.type == SOUND) { // disable sound /before/ changing it entityreference entref(&e); location *loc = audiomgr.locations.find(e.attr1, &entref, mapsounds); if(loc) loc->drop(); } for(int i = 1; i < numargs; i++) if(*args[i]) { int v = atof(args[i]) * (i < 4 || i > 10 ? 1 : entscale[t][i - 4]); switch(i) { case 1: e.x = v; break; case 2: e.y = v; break; case 3: e.z = v; break; case 4: e.attr1 = v; break; case 5: e.attr2 = v; break; case 6: e.attr3 = v; break; case 7: e.attr4 = v; break; case 8: e.attr5 = v; break; case 9: e.attr6 = v; break; case 10: e.attr7 = v; break; } } clampentityattributes(e); switch(e.type) { case LIGHT: calclight(); break; case SOUND: audiomgr.preloadmapsound(e); break; } unsavededits++; } // give back unchanged or new entity properties formatstring(res)("%s %d %d %d %s", entnames[t], e.x, e.y, e.z, formatentityattributes(e)); } result(res); } COMMAND(editentity, "v"); void enumentities(char *type) { vector res; int t = getlistindex(type, entnames, false, -1); loopv(ents) if(ents[i].type == t) cvecprintf(res, "%d ", i); resultcharvector(res, -1); } COMMAND(enumentities, "s"); vector todoents; vector todoentdescs; void cleartodoentities(const char *n) { int ni = n ? ATOI(n) : -1; if(!n || !*n || ni < 0) { todoents.setsize(0); todoentdescs.deletearrays(); } else loopvrev(todoents) if(todoents[i] == ni) { todoents.remove(i); delstring(todoentdescs.remove(i)); } } COMMAND(cleartodoentities, "s"); void addtodoentity(int n, const char *desc) { todoents.add(n); todoentdescs.add(newstring(desc)); } COMMANDF(addtodoentity, "is", (int *n, const char *desc) { if(ents.inrange(*n)) addtodoentity(*n, desc); }); void enumtodoentities() { vector res; loopv(todoents) cvecprintf(res, "%d %s\n", todoents[i], escapestring(todoentdescs[i], true)); resultcharvector(res, -1); } COMMAND(enumtodoentities, ""); void scalecomp(uchar &c, int intens) { int n = c*intens/100; if(n>255) n = 255; c = n; } void scalelights(int f, int intens) { if(multiplayer()) return; loopv(ents) { entity &e = ents[i]; if(e.type!=LIGHT) continue; e.attr1 = e.attr1*f/100; if(e.attr1<2) e.attr1 = 2; if(e.attr1>32) e.attr1 = 32; if(intens) { scalecomp(e.attr2, intens); scalecomp(e.attr3, intens); scalecomp(e.attr4, intens); } unsavededits++; } calclight(); } COMMANDF(scalelights, "ii", (int *f, int *i) { scalelights(*f, *i); }); int findentity(int type, int index) { for(int i = index; i= 0) { gotoplayerstart(player1, &ents[cycle]); entinmap(player1); } } COMMAND(nextplayerstart, "i"); sqr *wmip[LARGEST_FACTOR*2]; void setupworld(int factor) { ssize = 1<<(sfactor = factor); cubicsize = ssize*ssize; mipsize = cubicsize*134/100; sqr *w = world = new sqr[mipsize]; memset(world, 0, mipsize*sizeof(sqr)); loopi(LARGEST_FACTOR*2) { wmip[i] = w; w += cubicsize>>(i*2); } } void sqrdefault(sqr *s) { if(!s) return; s->r = s->g = s->b = 150; s->ftex = DEFAULT_FLOOR; s->ctex = DEFAULT_CEIL; s->wtex = s->utex = DEFAULT_WALL; s->type = SOLID; s->floor = 0; s->ceil = 16; s->vdelta = s->defer = s->tag = 0; } bool worldbordercheck(int x1, int x2, int y1, int y2, int z1, int z2) // check for solid world border { loop(x, ssize) loop(y, ssize) { if(x >= x1 && x < ssize - x2 && y >= y1 && y < ssize - y2) { if(S(x,y)->type != SOLID && (S(x,y)->ceil > 126 - z1 || S(x,y)->floor < -127 + z2)) return false; } else { if(S(x,y)->type != SOLID) return false; } } return true; } bool empty_world(int factor, bool force) // main empty world creation routine, if passed factor -1 will enlarge old world by 1, factor -2 will shrink old world by 1 { if(!force && noteditmode("empty world")) return false; if(factor < -2) return false; if(factor == -1 && multiplayer() && sfactor > 9) return false; if(factor == -2 && !worldbordercheck(ssize/4 + MINBORD, ssize/4 + MINBORD, ssize/4 + MINBORD, ssize/4 + MINBORD, 0, 0)) { conoutf("map does not fit into smaller world"); return false; } block *ow = NULL, be = { 0, 0, ssize, ssize }, bs = { ssize/4, ssize/4, ssize/2, ssize/2 }; int oldfactor = sfactor; bool copy = false; if(world && factor<0) { factor = sfactor + (factor == -2 ? -1 : 1); copy = true; } if(factorLARGEST_FACTOR) factor = LARGEST_FACTOR; if(copy && oldfactor == factor) return false; bool shrink = factor < oldfactor; bool clearmap = !copy && world; if(clearmap && unsavededits) { xmapbackup("newmap", ""); unsavededits = 0; } if(copy) ow = blockcopy(shrink ? bs : be); extern char *mlayout; DELETEA(world); DELETEA(mlayout); setupworld(factor); loop(x,ssize) loop(y,ssize) { sqrdefault(S(x,y)); } checkselections(); // assert no selection became invalid if(copy) { ow->x = ow->y = shrink ? 0 : ssize/4; blockpaste(*ow); int moveents = shrink ? -ssize/2 : ssize/4; loopv(ents) { ents[i].x += moveents; ents[i].y += moveents; if(OUTBORD(ents[i].x, ents[i].y)) ents[i].type = NOTUSED; } player1->o.x += moveents; player1->o.y += moveents; entinmap(player1); } else { // all-new map int oldunsavededits = unsavededits; memset(&hdr, 0, sizeof(header)); mapconfigdata.clear(); formatstring(hdr.maptitle)("Untitled Map by %s", player1->name); setfvar("waterlevel", -10000); hdr.waterlevel = waterlevel * WATERLEVELSCALING; setwatercolor(); loopk(3) loopi(256) hdr.texlists[k][i] = i; ents.shrink(0); block b = { 8, 8, ssize-16, ssize - 16}; edittypexy(SPACE, b); clearheaderextras(); unsavededits = oldunsavededits; } strncpy(hdr.head, "ACMP", 4); hdr.version = MAPVERSION; hdr.headersize = sizeof(header); hdr.sfactor = sfactor; servsqr *servworld = createservworld(world, cubicsize); calcmapdims(clmapdims, servworld, ssize); delete[] servworld; calclight(); resetmap(!copy); if(clearmap) { pushscontext(IEXC_MAPCFG); execfile("config/default_map_settings.cfg"); popscontext(); setvar("fullbright", 1); fullbrightlight(); } if(!copy) { findplayerstart(player1, true); startmap("newmap", false); } else conoutf("new map size: %d", sfactor); freeblock(ow); return true; } void mapsize(void) { intret(sfactor); } COMMAND(mapsize, ""); void mapenlarge() { if(empty_world(-1, false)) addmsg(SV_NEWMAP, "ri", -1); } void mapshrink() { if(empty_world(-2, false)) addmsg(SV_NEWMAP, "ri", -2); } void newmap(int *i) { if(m_botmode) { conoutf("newmap not supported in bot mode"); return; } if(empty_world(*i, false)) { addmsg(SV_NEWMAP, "ri", max(*i, 0)); exechook(HOOK_SP_MP, "onNewMap", ""); } defformatstring(startmillis)("%d", totalmillis); alias("gametimestart", startmillis, true); } COMMAND(mapenlarge, ""); COMMAND(mapshrink, ""); COMMAND(newmap, "i"); COMMANDN(recalc, calclight, ""); void countperfectmips(int mip, int xx, int yy, int bs, int *stats) { int mfactor = sfactor - mip; if(!bs) bs = 1 << mfactor; for(int y = yy; y < yy + bs; y++) for(int x = xx; x < xx + bs; x++) { sqr *r = SWS(wmip[mip], x, y, mfactor); if(r->defer && mip > 0) countperfectmips(mip - 1, x * 2, y * 2, 2, stats); else stats[mip]++; } } COMMANDF(calcmipstats, "", () { int st[SMALLEST_FACTOR + 1]; countperfectmips(SMALLEST_FACTOR, 0, 0, 0, st); conoutf("current mips: %d / %d / %d / %d / %d / %d / %d", st[0], st[1], st[2], st[3], st[4], st[5], st[6]); }); void clearworldvisibility() { sqr *s = world; loopirev(cubicsize) (s++)->visible = 0; } void calcworldvisibility() { sqr *s, *o[4], *r; // default to invisible, we'll mark all visible afterwards r = world; loopirev(ssize * ssize) (r++)->visible = INVISUTEX|INVISWTEX; // check visibility of wall & upper wall in mip 0 for(int y = 0; y < ssize; y++) for(int x = 0; x < ssize; x++) { s = S(x,y); uchar &rs = s->visible; if(x < 1 || x > ssize - 2 || y < 1 || y > ssize - 2) continue; // we need 1 cube safety-space - all outside is invisible anyway o[0] = s - ssize; o[1] = s + ssize; o[2] = s + 1; o[3] = s - 1; loopi(4) if(!SOLID(o[i])) { if(SOLID(s) || s->floor > o[i]->floor || (o[i]->type == FHF && (s->type != FHF || s->floor != o[i]->floor))) rs &= ~INVISWTEX; // wall texture visible if(!SOLID(s) && (s->ceil < o[i]->ceil || (o[i]->type == CHF && (s->type != CHF || s->ceil != o[i]->ceil)))) rs &= ~INVISUTEX; // upper wall texture visible } if(SOLID(s) && SOLID(o[0]) && SOLID(o[1]) && SOLID(o[2]) && SOLID(o[3])) rs |= INVISIBLE; } // corners are rendered at the highest possible mip - make sure, the right helper cubes are marked visible (including actually hidden ones) // (this is a lot of effort, but there's no easier way... savemap's toptimize() does it wrong, for example for(int mip = SMALLEST_FACTOR; mip > 0; mip--) { int mfactor = sfactor - mip, bs = 1 << mfactor; for(int y = 1; y < bs - 1; y++) for(int x = 1; x < bs - 1; x++) { s = SWS(wmip[mip], x, y, mfactor); if(s->type == CORNER && (mip == SMALLEST_FACTOR || SWS(wmip[mip + 1], x / 2, y / 2, mfactor - 1)->type != CORNER)) { // highest corner mip (this one is rendered) - mark helper cubes sqr *z = SWS(s,-1,0,mfactor); sqr *t = SWS(s,1,0,mfactor); sqr *v = SWS(s,0,1,mfactor); sqr *w = SWS(s,0,-1,mfactor); if(SOLID(z) || SOLID(t)) { if(SOLID(w)) S(x << mip, (y - 1) << mip)->visible &= ~(INVISWTEX|INVISIBLE); else if(SOLID(v)) S(x << mip, (y + 1) << mip)->visible &= ~(INVISWTEX|INVISIBLE); } } } } // propagate visibility and visible textures into higher mips for(int mip = 0; mip < SMALLEST_FACTOR; mip++) { int mfactor = sfactor - mip, bs = 1 << mfactor; for(int y = 0; y < bs; y++) for(int x = 0; x < bs; x++) { s = SWS(wmip[mip], x, y, mfactor); r = SWS(wmip[mip + 1], x / 2, y / 2, mfactor - 1); uchar &rs = s->visible, &rr = r->visible; if(!((x | y) & 1)) rr = rs; else rr &= rs; if(!(rs & INVISWTEX)) r->wtex = s->wtex; if(!(rs & INVISUTEX)) r->utex = s->utex; } } // corners are rendered at the highest possible mip - make sure, the right cubes of the lot is marked visible (including actually hidden ones) for(int mip = SMALLEST_FACTOR; mip > 0; mip--) { int mfactor = sfactor - mip, bs = 1 << mfactor; for(int y = 1; y < bs - 1; y++) for(int x = 1; x < bs - 1; x++) { s = SWS(wmip[mip], x, y, mfactor); if(s->type == CORNER && (mip == SMALLEST_FACTOR || SWS(wmip[mip + 1], x / 2, y / 2, mfactor - 1)->type != CORNER)) { // highest mip - mark the important cube like the highest mip S(x << mip, y << mip)->visible = s->visible; } } } // visibility flags complete ;) } void mapmrproper(bool manual) { int sta[SMALLEST_FACTOR + 1] = { 0 }, stb[SMALLEST_FACTOR + 1] = { 0 }, stc[SMALLEST_FACTOR + 1] = { 0 }; sqr *s, *r; block b = { 0, 0, ssize, ssize }; if(manual) { EDITMP("mapmrproper"); makeundo(b); } remip(b); if(manual) countperfectmips(SMALLEST_FACTOR, 0, 0, 0, sta); // basic corner cleanup: do that now // corners are rendered at the highest possible mip - squash data of lower mips (except vdelta and tag) for(int mip = SMALLEST_FACTOR; mip > 0; mip--) { int mfactor = sfactor - mip, bs = 1 << mfactor; for(int y = 1; y < bs - 1; y++) for(int x = 1; x < bs - 1; x++) { r = SWS(wmip[mip], x, y, mfactor); if(r->type == CORNER) loopi(4) { #define cc(p) s->p = r->p s = SWS(wmip[mip - 1], x * 2 + (i & 1), y * 2 + i / 2, mfactor + 1); cc(floor); cc(ceil); cc(wtex); cc(ftex); cc(ctex); cc(utex); #undef cc } } } // generate special mipmap without considering light or utex/wtex -> we'll try to reach this by optimization... sqr *worldbackup = (sqr *) memcpy(new sqr[ssize*ssize], world, ssize*ssize*sizeof(sqr)); r = world; loopirev(ssize * ssize) { r->wtex = r->utex = r->r = r->g = r->b = 0; r++; } remip(b); if(manual) countperfectmips(SMALLEST_FACTOR, 0, 0, 0, stb); memcpy(world, worldbackup, ssize*ssize*sizeof(sqr)); delete[] worldbackup; // calculate cube visibility calcworldvisibility(); // optimize utex & wtex according to mips & visibility #define domip0(b) for(int yy = y << mip; yy < (y + 1) << mip; yy++) for(int xx = x << mip; xx < (x + 1) << mip; xx++) { s = S(xx,yy); uchar &rs = s->visible; b ; } for(int mip = 2; mip > 0; mip--) { int mfactor = sfactor - mip, bs = 1 << mfactor; for(int y = 0; y < bs; y++) for(int x = 0; x < bs; x++) { r = SWS(wmip[mip], x, y, mfactor); if(mip > 1) loopi(4) { s = SWS(wmip[mip - 1], x * 2 + (i & 1), y * 2 + i / 2, mfactor + 1); uchar &rs = s->visible; if(rs & INVISWTEX) s->wtex = r->wtex; if(rs & INVISUTEX) s->utex = r->utex; } if(r->defer) continue; int utex = -1, wtex = -1, udiff = 0, wdiff = 0; domip0( if(!(rs & INVISWTEX) && s->wtex != wtex) { wtex = s->wtex; wdiff++; } if(!(rs & INVISUTEX) && s->utex != utex) { utex = s->utex; udiff++; } ); if(wdiff == 1) domip0(if(rs & INVISWTEX) s->wtex = wtex; rs &= ~(INVISWTEX|INVISIBLE); ); if(udiff == 1) domip0(if(rs & INVISUTEX) s->utex = utex; rs &= ~INVISUTEX; ); } } // use the remaining invisibilities to help the run-length-encoder r = NULL, s = world; #define c(f) (s->f==r->f) loopi(cubicsize) { if(SOLID(s)) { if(r && c(type) && c(vdelta) && ((s->visible & INVISWTEX) || c(wtex))) { s->wtex = r->wtex; } else r = s; } else { if(r && c(type) && c(floor) && c(ceil) && c(ctex) && c(ftex) && c(vdelta) && c(tag) && ((s->visible & INVISWTEX) || c(wtex)) && ((s->visible & INVISUTEX) || c(utex))) { s->wtex = r->wtex; s->utex = r->utex; } else r = s; } s++; } #undef c clearworldvisibility(); // cleanup // recalc everything with the optimized data calclight(); if(manual) { countperfectmips(SMALLEST_FACTOR, 0, 0, 0, stc); conoutf("before: %d / %d / %d / %d / %d / %d / %d", sta[0], sta[1], sta[2], sta[3], sta[4], sta[5], sta[6]); conoutf("idealized: %d / %d / %d / %d / %d / %d / %d", stb[0], stb[1], stb[2], stb[3], stb[4], stb[5], stb[6]); conoutf("final count: %d / %d / %d / %d / %d / %d / %d", stc[0], stc[1], stc[2], stc[3], stc[4], stc[5], stc[6]); unsavededits++; } } COMMANDF(mapmrproper, "", () { mapmrproper(true); }); void mapareacheck(char *what) // "vdelta" | "steepest" | "total" | "pprest" | "pp"(default) { mapareastats_s ms; mapdim_s md; stopwatch ti; ti.start(); servsqr *sw = createservworld(world, cubicsize); calcmapdims(md, sw, ssize); calcmapareastats(ms, sw, ssize, md); delete[] sw; vector res; if(!strcasecmp(what, "vdelta")) { loopi(MAS_VDELTA_TABSIZE) cvecprintf(res, "%d ", ms.vdd[i]); } else if(!strcasecmp(what, "steepest")) cvecprintf(res, "%d.5 %d.5 %d ", ms.steepest % ssize, ms.steepest / ssize, world[ms.steepest % cubicsize].floor); else if(!strcasecmp(what, "total")) cvecprintf(res, "%d ", ms.total); else if(!strcasecmp(what, "pprest")) cvecprintf(res, "%d ", ms.rest); else // default { loopi(MAS_GRID2) { int x = ms.ppp[i] % ssize, y = ms.ppp[i] / ssize, z = OUTBORD(x, y) ? 0 : S(x, y)->floor; cvecprintf(res, "%d %d %d %d %d %.5g\n", x, y, z, ms.ppa[i], ms.ppv[i], ms.ppa[i] ? float(ms.ppv[i]) / ms.ppa[i] : 0.0f); } } resultcharvector(res, -1); } COMMAND(mapareacheck, "s"); assaultcube-1.2.0.2.1/source/src/world.h000066400000000000000000000161511352165075300177260ustar00rootroot00000000000000enum // block types, order matters! { SOLID = 0, // entirely solid cube [only specifies wtex] CORNER, // half full corner of a wall FHF, // floor heightfield using neighbour vdelta values CHF, // idem ceiling SPACE, // entirely empty cube SEMISOLID, // generated by mipmapping MAXTYPE }; struct sqr { uchar type; // one of the above char floor, ceil; // height, in cubes uchar wtex, ftex, ctex; // wall/floor/ceil texture ids uchar r, g, b; // light value at upper left vertex uchar vdelta; // vertex delta, used for heightfield cubes char defer; // used in mipmapping, when true this cube is not a perfect mip char occluded; // true when occluded uchar utex; // upper wall tex id uchar tag; // used by triggers uchar visible; // temporarily used to flag the visibility of a cube (INVISWTEX, INVISUTEX, INVISIBLE) uchar reserved; }; struct servsqr // server variant of sqr { uchar type; // SOLID, etc. (also contains the two tagclip bits ORed in) char floor, ceil; // height, in cubes uchar vdelta; // vertex delta, used for heightfield cubes }; enum // hardcoded texture numbers { DEFAULT_SKY = 0, DEFAULT_LIQUID, DEFAULT_WALL, DEFAULT_FLOOR, DEFAULT_CEIL }; enum // stuff encoded in sqr.tag { TAGTRIGGERMASK = 0x3F, // room for old fashioned cube 1 triggers TAGCLIP = 0x40, // clips all objects TAGPLCLIP = 0x80 // clips only players }; #define TAGANYCLIP (TAGCLIP|TAGPLCLIP) enum { INVISWTEX = 1<<0, INVISUTEX = 1<<1, INVISIBLE = 1<<2 }; enum { MHF_AUTOMAPCONFIG = 1<<0, // autogenerate map-config during map save MHF_DISABLEWATERREFLECT = 1 << 8, // force waterreflect to zero MHF_LIMITWATERWAVEHEIGHT = 1 << 9, // limit waveheight to 0.1 MHF_DISABLESTENCILSHADOWS = 1 << 10 // force stencilshadow to 0 }; #define MAPVERSION 10 // default map format version to be written (bump if map format changes, see worldio.cpp) struct header // map file format header { char head[4]; // "CUBE" int version; // any >8bit quantity is little endian int headersize; // sizeof(header) int sfactor; // in bits int numents; char maptitle[128]; uchar texlists[3][256]; int waterlevel; uchar watercolor[4]; int maprevision; int ambient; int flags; // MHF_* int timestamp; // UTC unixtime of time of save (yes, this will break in 2038) int reserved[10]; //char mediareq[128]; // version 7 and 8 only. }; struct mapsoundline { string name; int maxuses; }; struct _mapconfigdata { string notexturename; vector mapsoundlines; void clear() { *notexturename = '\0'; mapsoundlines.shrink(0); } }; struct mapstats { struct header hdr; int entcnt[MAXENTTYPES]; int cgzsize; uchar *enttypes; short *entposs; int spawns[3]; int flags[2]; int flagents[2]; bool hasffaspawns; bool hasteamspawns; bool hasflags; }; struct mapdim_s { // 0 2 1 3 6 7 int x1, x2, y1, y2, minfloor, maxceil; // outer borders (points to last used cube) // 4 5 int xspan, yspan; // size of area between x1|y1 and x2|y2 float xm, ym; // middle of the map }; #define MAS_VDELTA_QUANT 8 #define MAS_VDELTA_TABSIZE 5 // (hardcoded maximum of 15!) #define MAS_VDELTA_THRES 3 #define MAS_GRID 8 #define MAS_GRID2 (MAS_GRID * MAS_GRID) #define MAS_RESOLUTION 32 // rays (32 * 8) struct mapareastats_s { int vdd[MAS_VDELTA_TABSIZE]; // vdelta-deltas (detect ugly steep heightfields) int vdds; // vdd table reduced to an easy to check bitmask int ppa[MAS_GRID2]; // area visible per probe point int ppv[MAS_GRID2]; // volume visible per probe point int total; // number of non-solid cubes on the map int rest; // area not visible from any probe point #ifndef STANDALONE int steepest; // location of steepest vdelta int ppp[MAS_GRID2]; // probe point position (client-only) #endif }; #define SWS(w,x,y,s) (&(w)[((y)<<(s))+(x)]) #define SW(w,x,y) SWS(w,x,y,sfactor) #define S(x,y) SW(world,x,y) // convenient lookup of a lowest mip cube #define SMALLEST_FACTOR 6 // determines number of mips there can be #define DEFAULT_FACTOR 8 #define LARGEST_FACTOR 11 // 10 is already insane #define MAXENTITIES 65535 #define MAXHEADEREXTRA (1<<20) #define SOLID(x) ((x)->type==SOLID) #define MINBORD 2 // 2 cubes from the edge of the world are always solid #define OUTBORD(x,y) ((x)=ssize-MINBORD || (y)>=ssize-MINBORD) #define OUTBORDRAD(x,y,rad) (int(x-rad)=ssize-MINBORD || (y+rad)>=ssize-MINBORD) #define WATERLEVELSCALING 10 struct block { int x, y, xs, ys, h; short p[5]; }; // vertex array format struct vertex { float u, v, x, y, z; uchar r, g, b, a; }; // map statistics #define MINSPAWNS 5 // minimum number of spawns per team #define MINFLAGDISTANCE 42 // minimum flag entity distance (2D) struct entitystats_s { int entcnt[MAXENTTYPES]; // simple count for every basic ent type int spawns[3]; // number of spawns with valid attr2 int flags[2]; // number of flags with valid attr2 int flagents[2]; // entity indices of the flag ents int pickups; // total number of pickup entities int pickupdistance[LARGEST_FACTOR + 1]; // entity distance values grouped logarithmically int flagentdistance; // distance of the two flag entities, if existing int modes_possible; // bitmask of possible gamemodes, depending on flag and spawn entities bool hasffaspawns; // has enough ffa spawns bool hasteamspawns; // has enough team spawns bool hasflags; // has exactly 2 valid flags int unknownspawns, unknownflags; // attr2 is not valid int firstclip; // index of first clipped entity short first[MAXENTTYPES], last[MAXENTTYPES]; // first and last occurence of every basic ent type }; // legacy #define MAXMHEIGHT 30 #define MAXMAREA 10000 #define MAXHHITS 50000 // was 6000, which denied my fav. maps - jamz, 2012-06-12; 15000 denies sane map too - lucas #define MINFF 2500 assaultcube-1.2.0.2.1/source/src/worldio.cpp000066400000000000000000001674761352165075300206320ustar00rootroot00000000000000// worldio.cpp: loading & saving of maps and savegames #include "cube.h" #define DEBUGCOND (worldiodebug==1) VARP(worldiodebug, 0, 0, 1); static string cgzname, ocgzname, bakname, cbakname, mcfname, omcfname; const char *setnames(const char *name) { const char *mapname = behindpath(name), *nt = numtime(); formatstring(cgzname) ("packages" PATHDIVS "maps" PATHDIVS "%s.cgz", mapname); formatstring(mcfname) ("packages" PATHDIVS "maps" PATHDIVS "%s.cfg", mapname); formatstring(ocgzname)("packages" PATHDIVS "maps" PATHDIVS "official" PATHDIVS "%s.cgz", mapname); formatstring(omcfname)("packages" PATHDIVS "maps" PATHDIVS "official" PATHDIVS "%s.cfg", mapname); formatstring(bakname) ("packages" PATHDIVS "maps" PATHDIVS "%s_%s.BAK", mapname, nt); formatstring(cbakname)("packages" PATHDIVS "maps" PATHDIVS "%s.cfg_%s.BAK", mapname, nt); return cgzname; } // the optimize routines below are here to reduce the detrimental effects of messy mapping by // setting certain properties (vdeltas and textures) to neighbouring values wherever there is no // visible difference. This allows the mipmapper to generate more efficient mips. // the reason it is done on save is to reduce the amount spend in the mipmapper (as that is done // in realtime). inline bool nhf(sqr *s) { return s->type!=FHF && s->type!=CHF; } void voptimize() // reset vdeltas on non-hf cubes { loop(y, ssize) loop(x, ssize) { sqr *s = S(x, y); if(x && y) { if(nhf(s) && nhf(S(x-1, y)) && nhf(S(x-1, y-1)) && nhf(S(x, y-1))) s->vdelta = 0; } else s->vdelta = 0; } } // these two are used by getmap/sendmap.. transfers compressed maps directly void writemap(char *name, int msize, uchar *mdata) { setnames(name); backup(cgzname, bakname); stream *f = openfile(cgzname, "wb"); if(!f) { conoutf("\f3could not write map to %s", cgzname); return; } f->write(mdata, msize); delete f; conoutf("wrote map %s as file %s", name, cgzname); } uchar *readmap(char *name, int *size, int *revision) { setnames(name); uchar *data = (uchar *)loadfile(cgzname, size); if(!data) { conoutf("\f3could not read map %s", cgzname); return NULL; } mapstats *ms = loadmapstats(cgzname, false); if(revision) *revision = ms->hdr.maprevision; return data; } void writecfggz(char *name, int size, int sizegz, uchar *data) { if(size < 1 || !sizegz || size > MAXCFGFILESIZE) return; setnames(name); uchar *rawcfg = new uchar[size]; uLongf rawsize = size; if(rawcfg && uncompress(rawcfg, &rawsize, data, sizegz) == Z_OK && rawsize - size == 0) { stream *f = openfile(mcfname, "w"); if(f) { f->write(rawcfg, size); delete f; conoutf("wrote map config to %s", mcfname); } else { conoutf("\f3could not write config to %s", mcfname); } } DELETEA(rawcfg); } #define GZBUFSIZE ((MAXCFGFILESIZE * 11) / 10) uchar *readmcfggz(char *name, int *size, int *sizegz) { setnames(name); uchar *gzbuf = new uchar[GZBUFSIZE]; uchar *data = (uchar*)loadfile(mcfname, size, "r"); if(data && *size < MAXCFGFILESIZE) { uLongf gzbufsize = GZBUFSIZE; if(compress2(gzbuf, &gzbufsize, data, *size, 9) != Z_OK) { *size = 0; gzbufsize = 0; DELETEA(gzbuf); } *sizegz = (int) gzbufsize; } else { DELETEA(gzbuf); } DELETEA(data); return gzbuf; } // save map as .cgz file. uses 2 layers of compression: first does simple run-length // encoding and leaves out data for certain kinds of cubes, then zlib removes the // last bits of redundancy. Both passes contribute greatly to the miniscule map sizes. void rlencodecubes(vector &f, sqr *s, int len, bool preservesolids) // run-length encoding and serialisation of a series of cubes { sqr *t = NULL; int sc = 0; #define spurge while(sc) { f.add(255); if(sc>255) { f.add(255); sc -= 255; } else { f.add(sc); sc = 0; } } #define c(f) (s->f==t->f) while(len-- > 0) { // 4 types of blocks, to compress a bit: // 255 (2): same as previous block + count // 254 (3): same as previous, except light // deprecated // SOLID (5) // anything else (9) if(SOLID(s) && !preservesolids) { if(t && c(type) && c(wtex) && c(vdelta)) { sc++; } else { spurge; f.add(s->type); f.add(s->wtex); f.add(s->vdelta); } } else { if(t && c(type) && c(floor) && c(ceil) && c(ctex) && c(ftex) && c(utex) && c(wtex) && c(vdelta) && c(tag)) { sc++; } else { spurge; f.add(s->type == SOLID ? 253 : s->type); f.add(s->floor); f.add(s->ceil); f.add(s->wtex); f.add(s->ftex); f.add(s->ctex); f.add(s->vdelta); f.add(s->utex); f.add(s->tag); } } t = s; s++; } spurge; } bool rldecodecubes(ucharbuf &f, sqr *s, int len, int version, bool silent) // run-length decoding of a series of cubes (version is only relevant, if < 6) { sqr *t = NULL, *e = s + len; while(s < e) { int type = f.overread() ? -1 : f.get(); switch(type) { case -1: { if(!silent) conoutf("while reading map at %d: unexpected end of file", int(cubicsize - (e - s))); f.forceoverread(); silent = true; sqrdefault(s); break; } case 255: { if(!t) { f.forceoverread(); continue; } int n = f.get(); loopi(n) memcpy(s++, t, sizeof(sqr)); s--; break; } case 254: // only in MAPVERSION<=2 { if(!t) { f.forceoverread(); continue; } memcpy(s, t, sizeof(sqr)); f.get(); f.get(); break; } case SOLID: { sqrdefault(s); // takes care of ftex, ctex, floor, ceil and tag s->type = SOLID; s->utex = s->wtex = f.get(); s->vdelta = f.get(); if(version<=2) { f.get(); f.get(); } break; } case 253: // SOLID with all textures during editing (undo) type = SOLID; default: { if(type<0 || type>=MAXTYPE) { if(!silent) conoutf("while reading map at %d: type %d out of range", int(cubicsize - (e - s)), type); f.forceoverread(); continue; } sqrdefault(s); s->type = type; s->floor = f.get(); s->ceil = f.get(); if(s->floor>=s->ceil) s->floor = s->ceil-1; // for pre 12_13 s->wtex = f.get(); s->ftex = f.get(); s->ctex = f.get(); if(version<=2) { f.get(); f.get(); } s->vdelta = f.get(); s->utex = (version>=2) ? f.get() : s->wtex; s->tag = (version>=5) ? f.get() : 0; } } s->defer = 0; t = s; s++; } return !f.overread(); // true: no problem } // headerextra stores additional data in a map file (support since format 10) // data can be persistent or oneway // the format and handling is explicitly designed to handle yet unknown header types to avoid further format version bumps struct headerextra { int len, flags; uchar *data; headerextra() : len(0), flags(0), data(NULL) {} headerextra(int l, int f, uchar *d) : len(l), flags(f), data(NULL) { if(d) { data = new uchar[len]; memcpy(data, d, len); } } ~headerextra() { DELETEA(data); } headerextra *duplicate() { return new headerextra(len, flags, data); } }; vector headerextras; const char *hx_names[] = { "unused", "mapinfo", "modeinfo", "artist", "editundo", "config", "vantage point", "unknown" }; #define addhxpacket(p, len, flags, buffer) { if(p.length() + len < MAXHEADEREXTRA) { putuint(p, len); putuint(p, flags); p.put(buffer, len); } } #define hx_name(t) hx_names[min((t) & HX_TYPEMASK, int(HX_NUM))] void clearheaderextras() { loopvrev(headerextras) delete headerextras.remove(i); } void deleteheaderextra(int n) { if(headerextras.inrange(n)) delete headerextras.remove(n); } void listheaderextras() { loopv(headerextras) conoutf("extra header record %d: %s, %d bytes", i, hx_name(headerextras[i]->flags), headerextras[i]->len); if(!headerextras.length()) conoutf("no extra header records found"); } COMMAND(listheaderextras, ""); int findheaderextra(int type) { loopv(headerextras) if((headerextras[i]->flags & HX_TYPEMASK) == type) return i; return -1; } void unpackheaderextra(uchar *buf, int len) // break the extra data from the mapheader into its pieces { ucharbuf p(buf, len); DEBUG("unpacking " << len << " bytes"); while(1) { int len = getuint(p), flags = getuint(p); if(p.overread() || len > p.remaining()) break; DEBUGCODE(clientlogf(" found headerextra \"%s\", %d bytes%s", hx_name(flags & HX_TYPEMASK), len, flags & HX_FLAG_PERSIST ? ", persistent" : "")); // debug info headerextras.add(new headerextra(len, flags, p.subbuf(len).buf)); } } void parseheaderextra(bool clearnonpersist = true, int ignoretypes = 0) // parse all headerextra packets, delete the nonpersistent ones (like editundos) { DEBUG("parsing " << headerextras.length() << " packets"); loopv(headerextras) { ucharbuf q(headerextras[i]->data, headerextras[i]->len); int type = headerextras[i]->flags & HX_TYPEMASK; DEBUG("packet " << i << " type " << type); bool deletethis = false; // (set deletethis for headers that persist outside headerextras and get reinserted by packheaderextras()) if(!(ignoretypes & (1 << type))) switch(type) { case HX_EDITUNDO: restoreeditundo(q); break; case HX_CONFIG: setcontext("map", "embedded"); execute((const char *)q.buf); // needs to have '\0' at the end resetcontext(); break; case HX_MAPINFO: { string l, c; getstring(l, q, MAXSTRLEN - 1); getstring(c, q, MAXSTRLEN - 1); setmapinfo(l, c); break; } case HX_MODEINFO: case HX_ARTIST: default: break; } if(deletethis || (clearnonpersist && !(headerextras[i]->flags & HX_FLAG_PERSIST))) delete headerextras.remove(i--); } } ucharbuf packheaderextras(int ignoretypes = 0) // serialise all extra data packets to save with the map header { vector buf, tmp; // rewrite some headers every time if(!(ignoretypes & (1 << HX_MAPINFO))) { for(int n; (n = findheaderextra(HX_MAPINFO)) >= 0; ) deleteheaderextra(n); if(mapinfo_license[0]) { sendstring(mapinfo_license, tmp); sendstring(mapinfo_comment, tmp); headerextras.add(new headerextra(tmp.length(), HX_MAPINFO|HX_FLAG_PERSIST, tmp.getbuf())); tmp.setsize(0); } } loopv(headerextras) if(!(ignoretypes & (1 << (headerextras[i]->flags & HX_TYPEMASK)))) { // copy existing persistent hx packets addhxpacket(buf, headerextras[i]->len, headerextras[i]->flags, headerextras[i]->data); } // create non-persistent ones, if wanted if(!(ignoretypes & (1 << HX_EDITUNDO))) { int limit = (MAXHEADEREXTRA - buf.length()) / 3; backupeditundo(tmp, limit, limit); addhxpacket(buf, tmp.length(), HX_EDITUNDO, tmp.getbuf()); } ucharbuf q(new uchar[buf.length()], buf.length()); memcpy(q.buf, buf.getbuf(), q.maxlen); DEBUG("packed " << q.maxlen << " bytes"); return q; } bool embedconfigfile() { if(securemapcheck(getclientmap())) return false; if(unsavededits) { conoutf("There are unsaved edits: they need to be saved or discarded before a config file can be embedded."); return false; } setnames(getclientmap()); int len; uchar *buf = (uchar *)loadfile(mcfname, &len); if(buf) { for(int n; (n = findheaderextra(HX_CONFIG)) >= 0; ) deleteheaderextra(n); headerextras.add(new headerextra(len + 1, HX_CONFIG|HX_FLAG_PERSIST, NULL))->data = buf; backup(mcfname, cbakname); // don't delete the config file, just rename conoutf("embedded map config file \"%s\"", mcfname); } else conoutf("\f3failed to load config file %s", mcfname); return buf != NULL; } COMMANDF(embedconfigfile, "", () { if(embedconfigfile()) save_world(getclientmap()); }); void extractconfigfile() { if(securemapcheck(getclientmap())) return; if(unsavededits) { conoutf("There are unsaved edits: they need to be saved or discarded before the config file can be extracted."); return; } setnames(getclientmap()); int n = findheaderextra(HX_CONFIG); if(n < 0) conoutf("no embedded config found"); else { backup(mcfname, cbakname); // don't overwrite an existing config file, just rename it stream *f = openfile(mcfname, "w"); if(f) { f->write(headerextras[n]->data, headerextras[n]->len > 0 ? headerextras[n]->len - 1 : 0); delete f; conoutf("extracted embedded map config to file %s", mcfname); deleteheaderextra(n); hdr.flags &= ~MHF_AUTOMAPCONFIG; // external config file, manually edited } else conoutf("\f3failed to write config to %s", mcfname); } } COMMAND(extractconfigfile, ""); void automapconfig() { conoutf("\"automatic embedded map config data\" %senabled", hdr.flags & MHF_AUTOMAPCONFIG ? "was already " : ""); hdr.flags |= MHF_AUTOMAPCONFIG; } COMMAND(automapconfig, ""); COMMANDF(getautomapconfig, "", () { intret((hdr.flags & MHF_AUTOMAPCONFIG) != 0); }); void flagmapconfigchange() { // if changes are tracked, because automapcfg is enabled and the change is not read from a config file -> set unsaved edits flag if(execcontext != IEXC_MAPCFG && hdr.flags & MHF_AUTOMAPCONFIG) unsavededits++; } int mapconfigerror = 0; void flagmapconfigerror(int what) { if(execcontext == IEXC_MAPCFG || execcontext == IEXC_MDLCFG) mapconfigerror |= what; } void getcurrentmapconfig(vector &f, bool onlysounds) { if(!onlysounds) { extern int fogcolour, shadowyaw; extern char *loadsky; if(fog != DEFAULT_FOG) cvecprintf(f, "fog %d\n", fog); if(fogcolour != DEFAULT_FOGCOLOUR) cvecprintf(f, "fogcolour 0x%06x\n", fogcolour); if(shadowyaw != DEFAULT_SHADOWYAW) cvecprintf(f, "shadowyaw %d\n", shadowyaw); if(*mapconfigdata.notexturename) cvecprintf(f, "loadnotexture \"%s\"\n", mapconfigdata.notexturename); if(*loadsky) cvecprintf(f, "loadsky \"%s\"\n", loadsky); cvecprintf(f, "%smapmodelreset\n", f.length() ? "\n" : ""); loopi(256) { mapmodelinfo *mmi = getmminfo(i); if(!mmi) break; cvecprintf(f, "mapmodel %d %d %d %s \"%s\"", mmi->rad, mmi->h, mmi->zoff, mmi->scale == 1.0f ? "0" : floatstr(mmi->scale, true), mmshortname(mmi->name)); if(mmi->flags & MMF_CONFIGMASK) cvecprintf(f, " %d", mmi->flags & MMF_CONFIGMASK); f.add('\n'); } cvecprintf(f, "\ntexturereset\n"); loopi(256) { const char *t = gettextureslot(i); if(!t) break; cvecprintf(f, "%s\n", t); } cvecprintf(f, "\n"); } cvecprintf(f, "mapsoundreset\n"); loopv(mapconfigdata.mapsoundlines) { mapsoundline &s = mapconfigdata.mapsoundlines[i]; cvecprintf(f, "mapsound \"ambience/%s\" %d\n", s.name, s.maxuses); } cvecprintf(f, "\n"); f.add('\0'); } #ifdef _DEBUG COMMANDF(dumpmapconfig, "", () { vector buf; updatemapmodeldependencies(); getcurrentmapconfig(buf, false); stream *f = openfile("dumpmapconfig.txt", "w"); if(f) f->write(buf.getbuf(), buf.length() - 1); DELETEP(f); hdr.flags |= MHF_AUTOMAPCONFIG; }); #endif bool clearvantagepoint() { bool yep = false; for(int n; (n = findheaderextra(HX_VANTAGEPOINT)) >= 0; yep = true) deleteheaderextra(n); unsavededits++; return yep; } COMMANDF(clearvantagepoint, "", () { if(!noteditmode("clearvantagepoint") && !multiplayer() && clearvantagepoint()) conoutf("cleared vantage point"); }); void setvantagepoint() { if(multiplayer("setvantagepoint") || (!player1->isspectating() && noteditmode("setvantagepoint"))) return; clearvantagepoint(); short p[5]; storeposition(p); vector buf; loopi(5) putint(buf, p[i]); physent d = *player1; d.radius = d.eyeheight = d.maxeyeheight = d.aboveeye = 0.1; if(collide(&d, false)) { conoutf("\f3collision with map: vantage point not set"); return; } if(!OUTBORD(p[0] / DMF, p[1] / DMF) && iabs(p[2]) < 127 * int(DMF) && p[3] >= 0 && p[3] < 360 && iabs(p[4]) <= 90) { headerextras.add(new headerextra(buf.length(), HX_VANTAGEPOINT|HX_FLAG_PERSIST, buf.getbuf())); conoutf("vantage point set"); } } COMMAND(setvantagepoint, ""); bool getvantagepoint(short p[5]) { int n = findheaderextra(HX_VANTAGEPOINT); if(n >= 0) { ucharbuf q(headerextras[n]->data, headerextras[n]->len); loopi(5) p[i] = getint(q); if(!OUTBORD(p[0] / DMF, p[1] / DMF) && iabs(p[2]) < 127 * int(DMF) && p[3] >= 0 && p[3] < 360 && iabs(p[4]) <= 90) return true; // check for sane values } return false; } COMMANDF(getvantagepoint, "", () { short p[5]; string res = ""; if(getvantagepoint(p)) formatstring(res)("%s %s %s %d %d", floatstr(p[0] / DMF), floatstr(p[1] / DMF), floatstr(p[2] / DMF), p[3], p[4]); result(res); }); bool gotovantagepoint() { short p[5]; if(getvantagepoint(p)) { restoreposition(p); physent d = *player1; d.radius = d.eyeheight = d.maxeyeheight = d.aboveeye = 0.1; if(!collide(&d, false)) return true; // don't use out-of-map vantage points } // if there is no (valid) vantage point set, we go to the first playerstart instead int s = findentity(PLAYERSTART, 0); if(ents.inrange(s)) gotoplayerstart(player1, &ents[s]); entinmap(player1); return false; } COMMANDF(gotovantagepoint, "", () { intret((editmode || (!multiplayer(NULL) && player1->isspectating())) && gotovantagepoint() ? 1 : 0); }); void setmapinfo(const char *newlicense, const char *newcomment) { string s; filtertext(s, newlicense ? newlicense : mapinfo_license, FTXT__MAPINFO_LICENSE, 20); mapinfo_license = exchangestr(mapinfo_license, s); filtertext(s, newcomment ? newcomment : mapinfo_comment, FTXT__MAPINFO_COMMENT, 60); mapinfo_comment = exchangestr(mapinfo_comment, s); } SVARF(mapinfo_license, "", setmapinfo(); ); SVARF(mapinfo_comment, "", setmapinfo(); ); VAR(advancemaprevision, 1, 1, 100); VARP(mapbackupsonsave, 0, 1, 1); void rebuildtexlists() // checks the texlists, if they still contain all possible textures { short h[256]; int mk[3], mt = 0; vector missing; loopk(3) { missing.setsize(0); uchar *p = hdr.texlists[k]; loopi(256) h[i] = 0; loopi(256) h[p[i]]++; loopi(256) if(h[i] == 0) missing.add(i); mt += mk[k] = missing.length(); loopi(256) if(h[p[i]] > 1) { h[p[i]]--; p[i] = missing.pop(); } } if(mt) conoutf("WARNING: rebuildtexlists() fixed %d|%d|%d missing entries", mk[0], mk[1], mk[2]); } static const uchar sortenttab[] = { // 1..9: used in network protocol, 10..19: sorted lights, 20..29: misc, 30..39: clipped ents at the end of the list 99, // NOTUSED // entity slot not in use in map (usually seen at deleted entities) 10, // LIGHT (colored: 11, shadow: 12) // lightsource, attr1 = radius, attr2 = intensity (or attr2..4 = r-g-b) 2, // PLAYERSTART // attr1 = angle, attr2 = team 1, 1, 1, // I_CLIPS, I_AMMO, I_GRENADE, // attr1 = elevation 1, 1, 1, 1, // I_HEALTH, I_HELMET, I_ARMOUR, I_AKIMBO, 30, // MAPMODEL (clipped: 31) // attr1 = angle, attr2 = idx, attr3 = elevation, attr4 = texture, attr5 = pitch, attr6 = roll 21, // CARROT // attr1 = tag, attr2 = type 3, // LADDER // attr1 = height 1, // CTF_FLAG // attr1 = angle, attr2 = red/blue 20, // SOUND // attr1 = idx, attr2 = radius, attr3 = size, attr4 = volume 32, // CLIP // attr1 = elevation, attr2 = xradius, attr3 = yradius, attr4 = height, attr6 = slope, attr7 = shape 33}; // PLCLIP // attr1 = elevation, attr2 = xradius, attr3 = yradius, attr4 = height, attr6 = slope, attr7 = shape struct numbered_persistent_entity { persistent_entity e; int n; }; int cmp_npe(const numbered_persistent_entity *a, const numbered_persistent_entity *b) { ASSERT(a->n != b->n); return a->n - b->n; } void save_world(char *mname, bool skipoptimise, bool addcomfort) { if(!*mname) mname = getclientmap(); if(securemapcheck(mname)) return; DEBUG("writing map \"" << mname << "\""); if(!validmapname(mname)) { conoutf("\f3Invalid map name. It must only contain letters, digits, '-', '_' and be less than %d characters long", MAXMAPNAMELEN); return; } if(!skipoptimise) { // optimisation works on the real world geometry, not on a copy voptimize(); mapmrproper(false); addcomfort = false; // "optimized + undos" is not useful } // get target file ready setnames(mname); if(mapbackupsonsave) backup(cgzname, bakname); stream *f = opengzfile(cgzname, "wb"); if(!f) { conoutf("could not write map to %s", cgzname); return; } // update embedded config file (if used) updatemapmodeldependencies(); bool autoembedconfig = (hdr.flags & MHF_AUTOMAPCONFIG) != 0; if(autoembedconfig) { // write embedded map config backup(mcfname, cbakname); // rename possibly existing external map config file for(int n; (n = findheaderextra(HX_CONFIG)) >= 0; ) deleteheaderextra(n); // delete existing embedded config vector ec; getcurrentmapconfig(ec, false); uchar *ecu = new uchar[ec.length()]; memcpy(ecu, ec.getbuf(), ec.length()); headerextras.add(new headerextra(ec.length(), HX_CONFIG|HX_FLAG_PERSIST, NULL))->data = ecu; } // update (and fix) map header strncpy(hdr.head, "ACMP", 4); // ensure map now declares itself as an AssaultCube map, even if imported as CUBE hdr.version = MAPVERSION; hdr.headersize = sizeof(header); hdr.timestamp = (int) time(NULL); rebuildtexlists(); // create sorted entity list vector sortedents; hdr.numents = 0; ASSERT(MAXENTITIES < (1 << 16)); numbered_persistent_entity npe; loopv(ents) if(ents[i].type != NOTUSED && ents[i].type != DUMMYENT) // omit deleted entities and dummies { hdr.numents++; npe.e = ents[i]; int t = npe.e.type, nt = t < MAXENTTYPES ? sortenttab[t] : 100 + t; if(t == LIGHT) { if(npe.e.attr3 || npe.e.attr4) nt++; // sort white lights before colored ones to fix light bug if(npe.e.attr1 < 0) nt += 2; // sort shadows after lights } else if(t == MAPMODEL) { mapmodelinfo *mmi = getmminfo(npe.e.attr2); if(mmi && mmi->h) nt++; // sort clipped mapmodels right after unclipped mapmodels, but before clips and plclips } npe.n = i | (nt << 16); // numbers have to be unique for the sort to be stable sortedents.add(npe); } sortedents.sort(cmp_npe); if(hdr.numents > MAXENTITIES) { conoutf("too many map entities (%d), only %d will be written to file", hdr.numents, MAXENTITIES); hdr.numents = MAXENTITIES; } // write header and extras to file header tmp = hdr; ucharbuf hx = packheaderextras(addcomfort ? 0 : (1 << HX_EDITUNDO)); // if addcomfort -> add undos/redos int writeextra = 0; if(hx.maxlen) tmp.headersize += writeextra = clamp(hx.maxlen, 0, MAXHEADEREXTRA); tmp.maprevision += advancemaprevision; DEBUG("version " << tmp.version << " headersize " << tmp.headersize << " entities " << tmp.numents << " factor " << tmp.sfactor << " revision " << tmp.maprevision); lilswap(&tmp.version, 4); // version, headersize, sfactor, numents lilswap(&tmp.waterlevel, 1); lilswap(&tmp.maprevision, 4); // maprevision, ambient, flags, timestamp f->write(&tmp, sizeof(header)); if(writeextra) f->write(hx.buf, writeextra); delete[] hx.buf; // write entities loopi(hdr.numents) { persistent_entity &tmp = sortedents[i].e; clampentityattributes(tmp); lilswap((short *)&tmp, 4); lilswap(&tmp.attr5, 1); f->write(&tmp, sizeof(persistent_entity)); } // fix world border if(editmode) { int nonsolid = 0; loop(y, ssize) loop(x, ssize) { if(OUTBORD(x, y)) { sqr *s = S(x, y); if(!SOLID(s)) { sqrdefault(s); s->type = SOLID; nonsolid++; } } else x = ssize - MINBORD - 1; } if(nonsolid) conoutf("\f3fixed %d non-solid world border cubes", nonsolid); } // write map geometry vector rawcubes; rlencodecubes(rawcubes, world, cubicsize, skipoptimise); // if skipoptimize -> keep properties of solid cubes (forces format 10) f->write(rawcubes.getbuf(), rawcubes.length()); delete f; unsavededits = 0; conoutf("wrote map file %s %s%s%s", cgzname, skipoptimise ? "without optimisation" : "(optimised)", addcomfort ? " (including editing history)" : "", autoembedconfig ? " (including map config)" : ""); } VARP(preserveundosonsave, 0, 0, 1); COMMANDF(savemap, "s", (char *name) { save_world(name, preserveundosonsave && editmode, preserveundosonsave && editmode); } ); COMMANDF(savemapoptimised, "s", (char *name) { save_world(name, false, false); } ); void save_world9(char *mname) { if(unsavededits) { conoutf("\f3There are unsaved changes to the map. Please save them to a lossless format first (\"savemap\")."); return; } if(!*mname) { conoutf("\f3You need to specify a map file name."); return; } if(securemapcheck(mname)) return; if(!validmapname(mname)) { conoutf("\f3Invalid map name. It must only contain letters, digits, '-', '_' and be less than %d characters long", MAXMAPNAMELEN); return; } if(findheaderextra(HX_CONFIG) >= 0) { // extract embedded config file first string clientmapbak; copystring(clientmapbak, getclientmap()); copystring(getclientmap(), mname); // hack! extractconfigfile(); copystring(getclientmap(), clientmapbak); } if(headerextras.length()) { conoutf("\f3not writing header extra information:"); listheaderextras(); } setnames(mname); backup(cgzname, bakname); stream *f = opengzfile(cgzname, "wb"); if(!f) { conoutf("could not write map to %s", cgzname); return; } strncpy(hdr.head, "ACMP", 4); // ensure map now declares itself as an AssaultCube map, even if imported as CUBE hdr.version = 9; hdr.headersize = sizeof(header); hdr.timestamp = (int) time(NULL); // non-zero timestamps in format 9 can be used to identify "exported" maps hdr.numents = 0; loopv(ents) if(ents[i].type != NOTUSED && ents[i].type != DUMMYENT) hdr.numents++; if(hdr.numents > MAXENTITIES) { conoutf("too many map entities (%d), only %d will be written to file", hdr.numents, MAXENTITIES); hdr.numents = MAXENTITIES; } header tmp = hdr; tmp.maprevision += advancemaprevision; tmp.flags = 0; tmp.waterlevel /= WATERLEVELSCALING; lilswap(&tmp.version, 4); // version, headersize, sfactor, numents lilswap(&tmp.waterlevel, 1); lilswap(&tmp.maprevision, 4); // maprevision, ambient, flags, timestamp f->write(&tmp, sizeof(header)); int ne = hdr.numents, ec = 0; loopv(ents) { if(ents[i].type != NOTUSED && ents[i].type != DUMMYENT) { if(!ne--) break; persistent_entity tmp = ents[i]; clampentityattributes(tmp); tmp.attr1 /= entscale[tmp.type][0]; tmp.attr2 /= entscale[tmp.type][1]; tmp.attr3 /= entscale[tmp.type][2]; tmp.attr4 /= entscale[tmp.type][3]; if(tmp.attr5 || tmp.attr6 || tmp.attr7) conoutf("\f3lost some attributes for entity #%d (%d)", i, ++ec); lilswap((short *)&tmp, 4); f->write(&tmp, 12); } } vector rawcubes; rlencodecubes(rawcubes, world, cubicsize, false); f->write(rawcubes.getbuf(), rawcubes.length()); delete f; conoutf("wrote map file %s with format 9", cgzname); } COMMANDN(savemap9, save_world9, "s"); void showmapdims() { conoutf(" min X|Y|Z: %3d : %3d : %3d", clmapdims.x1, clmapdims.y1, clmapdims.minfloor); conoutf(" max X|Y|Z: %3d : %3d : %3d", clmapdims.x2, clmapdims.y2, clmapdims.maxceil); conoutf("delta X|Y|Z: %3d : %3d : %3d", clmapdims.xspan, clmapdims.yspan, clmapdims.maxceil - clmapdims.minfloor); } COMMAND(showmapdims, ""); extern void preparectf(bool cleanonly = false); int maploaded = 0; VAR(curmaprevision, 1, 0, 0); COMMANDF(getmaptimestamp, "s", (char *fmt) { result(hdr.timestamp ? timestring((time_t)hdr.timestamp, *fmt != 'U', *fmt == 'U' ? fmt + 1 : fmt) : "no timestamp stored"); }); void changemapflag(int val, int mask) { int old = hdr.flags; if(val) hdr.flags |= mask; else hdr.flags &= ~mask; if(editmode && old != hdr.flags) unsavededits++; } VARF(mapoverride_nowaterreflect, 0, 0, 1, changemapflag(mapoverride_nowaterreflect, MHF_DISABLEWATERREFLECT)); VARF(mapoverride_limitwaveheight, 0, 0, 1, changemapflag(mapoverride_limitwaveheight, MHF_LIMITWATERWAVEHEIGHT)); VARF(mapoverride_nostencilshadows, 0, 0, 1, changemapflag(mapoverride_nostencilshadows, MHF_DISABLESTENCILSHADOWS)); VAR(_ignoreillegalpaths, 0, 0, 1); extern char *mlayout; extern int Mv, Ma, Hhits; extern float Mh; static string lastloadedconfigfile; bool incompatiblemap = false; int load_world(char *mname) // still supports all map formats that have existed since the earliest cube betas! { incompatiblemap = false; const int sizeof_header = sizeof(header), sizeof_baseheader = sizeof_header - sizeof(int) * 16; stopwatch watch; watch.start(); advancemaprevision = 1; setnames(mname); maploaded = getfilesize(ocgzname); if(maploaded > 0) { copystring(cgzname, ocgzname); copystring(mcfname, omcfname); } else maploaded = getfilesize(cgzname); if(!validmapname(mname)) { conoutf("\f3Invalid map name. It must only contain letters, digits, '-', '_' and be less than %d characters long", MAXMAPNAMELEN); return -1; } stream *f = opengzfile(cgzname, "rb"); if(!f) { conoutf("\f3could not read map %s", cgzname); return -2; } if(unsavededits) xmapbackup("load_map_", mname); unsavededits = 0; DEBUG("reading map \"" << cgzname << "\""); header tmp; memset(&tmp, 0, sizeof_header); if(f->read(&tmp, sizeof_baseheader) != sizeof_baseheader || (strncmp(tmp.head, "CUBE", 4)!=0 && strncmp(tmp.head, "ACMP",4)!=0)) { conoutf("\f3while reading map: header malformatted (1)"); delete f; return -3; } lilswap(&tmp.version, 4); // version, headersize, sfactor, numents if(tmp.version > MAPVERSION) { conoutf("\f3this map requires a newer version of AssaultCube"); delete f; return -4; } if(tmp.sfactorLARGEST_FACTOR || tmp.numents > MAXENTITIES) { conoutf("\f3illegal map size"); delete f; return -5; } tmp.headersize = fixmapheadersize(tmp.version, tmp.headersize); int restofhead = min(tmp.headersize, sizeof_header) - sizeof_baseheader; if(f->read(&tmp.waterlevel, restofhead) != restofhead) { conoutf("\f3while reading map: header malformatted (2)"); delete f; return -6; } DEBUG("version " << tmp.version << " headersize " << tmp.headersize << " headerextrasize " << tmp.headersize - int(sizeof(header)) << " entities " << tmp.numents << " factor " << tmp.sfactor << " revision " << tmp.maprevision); clearheaderextras(); if(tmp.headersize > sizeof_header) { int extrasize = tmp.headersize - sizeof_header; if(tmp.version < 9) extrasize = 0; // throw away mediareq... else if(extrasize > MAXHEADEREXTRA) extrasize = MAXHEADEREXTRA; if(extrasize) { // map file actually has extra header data that we want too preserve uchar *extrabuf = new uchar[extrasize]; if(f->read(extrabuf, extrasize) != extrasize) { conoutf("\f3while reading map: header malformatted (3)"); delete f; delete[] extrabuf; return -7; } unpackheaderextra(extrabuf, extrasize); delete[] extrabuf; } f->seek(tmp.headersize, SEEK_SET); } hdr = tmp; mapconfigdata.clear(); rebuildtexlists(); loadingscreen("%s", hdr.maptitle); resetmap(); int res = 0; if(hdr.version>=4) { lilswap(&hdr.waterlevel, 1); if(!hdr.watercolor[3]) setwatercolor(); lilswap(&hdr.maprevision, 4); // maprevision, ambient, flags, timestamp curmaprevision = hdr.maprevision; } else { hdr.waterlevel = -100000; hdr.ambient = 0; } if(hdr.version < 10) hdr.waterlevel *= WATERLEVELSCALING; setfvar("waterlevel", float(hdr.waterlevel) / WATERLEVELSCALING); mapoverride_nowaterreflect = (hdr.flags & MHF_DISABLEWATERREFLECT) ? 1 : 0; mapoverride_limitwaveheight = (hdr.flags & MHF_LIMITWATERWAVEHEIGHT) ? 1 : 0; mapoverride_nostencilshadows = (hdr.flags & MHF_DISABLESTENCILSHADOWS) ? 1 : 0; // read and convert all entities cleartodoentities(); persistent_entity *tempents = new persistent_entity[hdr.numents]; bool oldentityformat = hdr.version < 10; // version < 10 have only 4 attributes and no scaling loopi(hdr.numents) { persistent_entity &e = tempents[i]; f->read(&e, oldentityformat ? 12 : sizeof(persistent_entity)); lilswap((short *)&e, 4); if(oldentityformat) e.attr5 = e.attr6 = e.attr7 = 0; else lilswap(&e.attr5, 1); if(e.type == LIGHT && e.attr1 >= 0) { if(!e.attr2) e.attr2 = 255; // needed for MAPVERSION<=2 if(e.attr1 > 32) e.attr1 = 32; // 12_03 and below (but applied to _all_ files!) } transformoldentitytypes(hdr.version, e.type); if(oldentityformat && e.type < MAXENTTYPES) { if(e.type == CTF_FLAG || e.type == MAPMODEL) e.attr1 = e.attr1 + 7 - (e.attr1 + 7) % 15; // round the angle to the nearest 15-degree-step, like old versions did during rendering if(e.type == LIGHT && e.attr1 < 0) e.attr1 = 0; // negative lights had no meaning before version 10 int ov, ss; persistent_entity oe = e; #define SCALEATTR(x) \ if((ss = abs(entwraparound[e.type][x - 1] / entscale[e.type][x - 1]))) e.attr##x = (int(e.attr##x) % ss + ss) % ss; \ e.attr##x = ov = e.attr##x * entscale[e.type][x - 1]; \ if(ov != e.attr##x) { conoutf("overflow during conversion of attr%d of entity #%d (%s): value %d can no longer be represented - pls fix manually before saving the map",\ x, i, entnames[e.type], oe.attr##x); e.attr##x = oe.attr##x; res |= LWW_ENTATTROVERFLOW; \ defformatstring(desc)("%s: attr%d was %d, value can no longer be represented", entnames[e.type], x, oe.attr##x); addtodoentity(i, desc); incompatiblemap = true; } SCALEATTR(1); SCALEATTR(2); SCALEATTR(3); SCALEATTR(4); //SCALEATTR(5); // no need to scale zeros //SCALEATTR(6); //SCALEATTR(7); #undef SCALEATTR } } // create entities (and update some statistics) calcentitystats(clentstats, tempents, hdr.numents); ents.shrink(0); loopi(hdr.numents) { entity &e = ents.add(); memcpy(&e, &tempents[i], sizeof(persistent_entity)); e.spawned = false; } delete[] tempents; // read world geometry delete[] world; setupworld(hdr.sfactor); if(!mapinfo.numelems || (mapinfo.access(mname) && !cmpf(cgzname, mapinfo[mname]))) world = (sqr *)ents.getbuf(); c2skeepalive(); vector rawcubes; // fetch whole file into buffer loopi(9) { ucharbuf q = rawcubes.reserve(cubicsize); q.len = f->read(q.buf, cubicsize); rawcubes.addbuf(q); if(q.len < cubicsize) break; } delete f; ucharbuf uf(rawcubes.getbuf(), rawcubes.length()); res |= rldecodecubes(uf, world, cubicsize, hdr.version, false) ? 0 : LWW_DECODEERR; // decode file c2skeepalive(); // calculate map statistics servsqr *smallworld = createservworld(world, cubicsize); int we = calcmapdims(clmapdims, smallworld, ssize); if(we) conoutf("world error %d", we); res |= LWW_WORLDERROR * (iabs(we) & 0xf); delete[] smallworld; DELETEA(mlayout); mlayout = new char[cubicsize + 256]; memset(mlayout, 0, cubicsize * sizeof(char)); Mv = Ma = Hhits = 0; char texuse[256]; loopi(256) texuse[i] = 0; loopk(cubicsize) { sqr *s = &world[k]; if(SOLID(s)) mlayout[k] = 127; else { mlayout[k] = s->floor; // FIXME int diff = s->ceil - s->floor; if(diff > 6) { if(diff > MAXMHEIGHT) Hhits += diff - MAXMHEIGHT; Ma += 1; Mv += diff; } texuse[s->utex] = texuse[s->ftex] = texuse[s->ctex] = 1; } texuse[s->wtex] = 1; } Mh = Ma ? (float)Mv/Ma : 0; c2skeepalive(); calclight(); conoutf("read map %s rev %d (%d milliseconds)", cgzname, hdr.maprevision, watch.elapsed()); conoutf("%s", hdr.maptitle); mapconfigerror = 0; pushscontext(IEXC_MAPCFG); // untrusted altogether if(hdr.flags & MHF_AUTOMAPCONFIG) { // full featured embedded config: no need to read any other map config files copystring(lastloadedconfigfile, ""); } else { // map config from files execfile("config/default_map_settings.cfg"); execfile(mcfname); copystring(lastloadedconfigfile, mcfname); } parseheaderextra(); popscontext(); c2skeepalive(); watch.start(); loopi(256) if(texuse[i]) lookupworldtexture(i, autodownload ? true : false); int texloadtime = watch.elapsed(); c2skeepalive(); watch.start(); if(autodownload) resetmdlnotfound(); preload_mapmodels(autodownload ? true : false); int mdlloadtime = watch.elapsed(); c2skeepalive(); watch.start(); audiomgr.preloadmapsounds(autodownload ? true : false); int audioloadtime = watch.elapsed(); c2skeepalive(); watch.start(); int downloaded = downloadpackages(); if(downloaded > 0) clientlogf("downloaded content (%d KB in %d seconds)", downloaded/1024, watch.elapsed()/1000); c2skeepalive(); res |= loadskymap(true) ? 0 : LWW_MISSINGMEDIA * 1; watch.start(); loopi(256) if(texuse[i] && lookupworldtexture(i, false) == notexture && (!_ignoreillegalpaths || gettextureslot(i))) res |= LWW_MISSINGMEDIA * 2; clientlogf("loaded textures (%d milliseconds)", texloadtime+watch.elapsed()); c2skeepalive(); watch.start(); res |= preload_mapmodels(false) ? 0 : LWW_MISSINGMEDIA * 4; clientlogf("loaded mapmodels (%d milliseconds)", mdlloadtime+watch.elapsed()); c2skeepalive(); watch.start(); res |= audiomgr.preloadmapsounds(false) ? 0 : LWW_MISSINGMEDIA * 8; // also set, if soundvol == 0, because no sounds are loaded (or checked) in that case clientlogf("loaded mapsounds (%d milliseconds)", audioloadtime+watch.elapsed()); c2skeepalive(); // determine index of first clipped entity clentstats.firstclip = max(0, ents.length() - 1); // fallback for "no clipped entities at all" loopv(ents) { entity &e = ents[i]; mapmodelinfo *mmi; if(e.type == CLIP || e.type == PLCLIP || (e.type == MAPMODEL && (mmi = getmminfo(e.attr2)) && mmi->h)) { clentstats.firstclip = i; break; } } defformatstring(startmillis)("%d", totalmillis); alias("gametimestart", startmillis, true); startmap(mname); res |= mapconfigerror; if(res) conoutf("\f3unresolved problems occurred during load_world(), warning: 0x%x", res); return res; // negative: error (no map loaded), zero: no problem, positive: some problems (bitmask value) } COMMANDF(loadmap, "s", (char *mapname) { intret(!multiplayer("loadmap") ? load_world(mapname) : -42); }); char *getfiledesc(const char *dir, const char *name, const char *ext) // extract demo and map descriptions { if(!dir || !name || !ext) return NULL; defformatstring(fn)("%s/%s.%s", dir, name, ext); path(fn); string text, demodescalias; if(!strcmp(ext, "dmo")) { stream *f = opengzfile(fn, "rb"); if(!f) return NULL; demoheader hdr; if(f->read(&hdr, sizeof(demoheader))!=sizeof(demoheader) || memcmp(hdr.magic, DEMO_MAGIC, sizeof(hdr.magic))) { delete f; return NULL; } delete f; lilswap(&hdr.version, 1); lilswap(&hdr.protocol, 1); const char *tag = "(incompatible file) "; if(hdr.version == DEMO_VERSION) { if(hdr.protocol == PROTOCOL_VERSION) tag = ""; else if(hdr.protocol == -PROTOCOL_VERSION) tag = "(recorded on modded server) "; } formatstring(text)("%s%s", tag, hdr.desc); text[DHDR_DESCCHARS - 1] = '\0'; formatstring(demodescalias)("demodesc_%s", name); const char *customdesc = getalias(demodescalias); if(customdesc) { int textlen = strlen(text); concatformatstring(text, " \n\f4(Description: \f0%s\f4)", customdesc); ASSERT(MAXSTRLEN > 2 * DHDR_DESCCHARS); text[textlen + DHDR_DESCCHARS - 1] = '\0'; } return newstring(text); } else if(!strcmp(ext, "cgz")) { stream *f = opengzfile(fn, "rb"); if(!f) return NULL; header hdr; if(f->read(&hdr, sizeof(header))!=sizeof(header) || (strncmp(hdr.head, "CUBE", 4) && strncmp(hdr.head, "ACMP",4))) { delete f; return NULL; } delete f; lilswap(&hdr.version, 1); filtertext(hdr.maptitle, hdr.maptitle, FTXT__MAPMSG, 127); formatstring(text)("%s%s", (hdr.version>MAPVERSION) ? "(incompatible file) " : "", hdr.maptitle); text[DHDR_DESCCHARS - 1] = '\0'; return newstring(text); } return NULL; } void enumfiles(char *dir, char *ext) { vector res; vector files; if(!strcasecmp(ext, "dir")) listsubdirs(dir, files, stringsort); else listfiles(dir, *ext ? ext : NULL, files, stringsort); loopv(files) cvecprintf(res, "%s\n", escapestring(files[i])); files.deletearrays(); resultcharvector(res, -1); } COMMAND(enumfiles, "ss"); // support reading and writing binary data in config files static bool hexbinenabled = false; static vector hexbin; void hexbinwrite(stream *f, void *data, int len, bool ascii = true) // write block of binary data as hex values with up to 24 bytes per line { string asc; uchar *s = (uchar *) data; while(len > 0) { int chunk = min(len, 24); f->printf("hexbinchunk"); loopi(chunk) { asc[i] = isalnum(*s) ? *s : '.'; asc[i + 1] = '\0'; f->printf(" %02x", int(*s++)); } if(ascii) f->printf(" // %s\n", asc); else f->printf("\n"); len -= chunk; } } COMMANDF(hexbinchunk, "v", (char **args, int numargs) // read up to 24 bytes from the command's arguments to the hexbin buffer { if(!hexbinenabled) { conoutf("hexbinchunk out of context"); return; } loopi(numargs) hexbin.add(strtol(args[i], NULL, 16)); }); // multi-map editmode extensions (xmap) // // keep several (versions of) maps in memory at the same time // compare maps and visualise differences // // the general assumption is, that ram is cheap, and that a copy of a size-9 map should be below 10MB (including undo data) #define XMAPVERSION 1001001 VARP(persistentxmaps, 0, 1, 1); // save all xmaps on exit, restore them at game start struct xmap { string nick; // unique handle string name; vector headerextras; vector ents, delents; vector mapconfig; vector todoents; vector todoentdescs; sqr *world; header hdr; int ssize, cubicsize, numundo; string mcfname; short position[5]; xmap() : world(NULL), ssize(0), cubicsize(0), numundo(0) { *nick = *name = *mcfname = '\0'; } xmap(const char *nnick) // take the current map and store it in an xmap { copystring(nick, nnick); copystring(name, getclientmap()); hdr = ::hdr; ssize = ::ssize; cubicsize = ::cubicsize; loopv(::headerextras) headerextras.add(::headerextras[i]->duplicate()); world = new sqr[cubicsize]; memcpy(world, ::world, cubicsize * sizeof(sqr)); loopv(::ents) if(::ents[i].type != NOTUSED) ents.add() = ::ents[i]; loopv(deleted_ents) delents.add() = deleted_ents[i]; copystring(mcfname, lastloadedconfigfile); // may have been "official" or not if(hdr.flags & MHF_AUTOMAPCONFIG) getcurrentmapconfig(mapconfig, false); storeposition(position); vector tmp; // add undo/redo data in compressed form as temporary headerextra numundo = backupeditundo(tmp, MAXHEADEREXTRA, MAXHEADEREXTRA); headerextras.add(new headerextra(tmp.length(), HX_EDITUNDO, tmp.getbuf())); loopv(::todoents) { todoents.add(::todoents[i]); todoentdescs.add(newstring(::todoentdescs[i])); } } ~xmap() { headerextras.deletecontents(); delete[] world; ents.setsize(0); delents.setsize(0); mapconfig.setsize(0); todoents.setsize(0); todoentdescs.deletearrays(); } void restoreent(int i) { entity &e = ::ents.add(); memcpy(&e, &ents[i], sizeof(persistent_entity)); e.spawned = true; } void restore() // overwrite the current map with the contents of an xmap { setnames(name); copystring(lastloadedconfigfile, mcfname); ::hdr = hdr; clearheaderextras(); resetmap(true); curmaprevision = hdr.maprevision; setfvar("waterlevel", float(hdr.waterlevel) / WATERLEVELSCALING); ::ents.shrink(0); loopv(ents) restoreent(i); deleted_ents.setsize(0); loopv(delents) deleted_ents.add(delents[i]); delete[] ::world; setupworld(hdr.sfactor); memcpy(::world, world, cubicsize * sizeof(sqr)); calclight(); // includes full remip() loopv(headerextras) ::headerextras.add(headerextras[i]->duplicate()); pushscontext(IEXC_MAPCFG); // untrusted altogether if(mapconfig.length()) execute(mapconfig.getbuf()); else { execfile("config/default_map_settings.cfg"); execfile(lastloadedconfigfile); } parseheaderextra(true, mapconfig.length() ? (1<printf("restorexmap version %d %d %d\n", XMAPVERSION, isbigendian() ? 1 : 0, int(sizeof(world))); // it is a non-portable binary file format, so we have to check... f->printf("restorexmap names \"%s\" \"%s\"\n", name, mcfname); f->printf("restorexmap sizes %d %d %d\n", ssize, cubicsize, numundo); hexbinwrite(f, &hdr, sizeof(header)); f->printf("restorexmap header\n"); uLongf worldsize = cubicsize * sizeof(sqr), gzbufsize = (worldsize * 11) / 10; // gzip the world, so the file will only be big instead of huge uchar *gzbuf = new uchar[gzbufsize]; if(compress2(gzbuf, &gzbufsize, (uchar *)world, worldsize, 9) != Z_OK) gzbufsize = 0; hexbinwrite(f, gzbuf, gzbufsize, false); f->printf("restorexmap world\n"); DELETEA(gzbuf); loopv(headerextras) { hexbinwrite(f, headerextras[i]->data, headerextras[i]->len); f->printf("restorexmap headerextra %d // %s\n", headerextras[i]->flags, hx_name(headerextras[i]->flags)); } int el = ents.length(), all = el + delents.length(); loopi(all) // entities are stored as plain text - you may edit them { persistent_entity &e = i >= el ? delents[i - el] : ents[i]; f->printf("restorexmap %sent %d %d %d %d %d %d %d %d %d %d %d // %s\n", i >= el ? "del": "", e.type, e.x, e.y, e.z, e.attr1, e.attr2, e.attr3, e.attr4, e.attr5, e.attr6, e.attr7, e.type >= 0 && e.type < MAXENTTYPES ? entnames[e.type] : "unknown"); } if(mapconfig.length()) { char *t = newstring(mapconfig.getbuf()), *p, *l = t; while((p = strchr(l, '\n'))) { *p = '\0'; f->printf("restorexmap config %s\n", escapestring(l)); l = p + 1; } delstring(t); } loopv(todoents) f->printf("restorexmap todoent %d %s\n", todoents[i], escapestring(todoentdescs[i])); f->printf("restorexmap position %d %d %d %d %d // EOF, don't touch this\n\n", int(position[0]), int(position[1]), int(position[2]), int(position[3]), int(position[4])); } }; static vector xmaps; static xmap *bak, *xmjigsaw; // only bak needs to be deleted before reuse bool validxmapname(const char *nick) { if(validmapname(nick)) return true; conoutf("sry, %s is not a valid xmap nickname", nick); return false; } void xmapdelete(xmap *&xm) // make sure, we don't point to deleted xmaps { DELETEP(xm); } void xmapbackup(const char *nickprefix, const char *nick) // throw away existing backup and make a new one { xmapdelete(bak); defformatstring(text)("%s%s", nickprefix, nick); bak = new xmap(text); if(unsavededits) conoutf("\f3stored backup of unsaved edits on map '%s'; to restore, type \"/xmap_restore\"", bak->name); } const char *xmapdescstring(xmap *xm, bool shortform = false) { static string s[2]; static int toggle; toggle = !toggle; formatstring(s[toggle])("\"%s\": %s rev %d, %d ents%c size %d, hdrs %d, %d undo steps", xm->nick, xm->name, xm->hdr.maprevision, xm->ents.length(), shortform ? '\0' : ',', xm->hdr.sfactor, xm->headerextras.length() - 1, xm->numundo); return s[toggle]; } xmap *getxmapbynick(const char *nick, int *index = NULL, bool errmsg = true) { if(*nick) loopvrev(xmaps) { if(!strcmp(nick, xmaps[i]->nick)) { if(index) *index = i; return xmaps[i]; } } if(errmsg) conoutf("xmap \"%s\" not found", nick); return NULL; } COMMANDF(xmap_list, "", () // list xmaps (and status) { loopv(xmaps) conoutf("xmap %d %s", i, xmapdescstring(xmaps[i])); if(xmaps.length() == 0) conoutf("no xmaps in memory"); if(bak) conoutf("backup stored before %s", xmapdescstring(bak)); } ); COMMANDF(getxmaplist, "s", (char *what) // return list of xmap nicks and descriptions { vector res; if(strcasecmp(what, "bak")) loopv(xmaps) cvecprintf(res, "%s %s\n", escapestring(xmaps[i]->nick), escapestring(xmapdescstring(xmaps[i]))); else if(bak) cvecprintf(res, "%s %s", escapestring(bak->nick), escapestring(xmapdescstring(bak))); resultcharvector(res, -1); } ); COMMANDF(xmap_store, "s", (const char *nick) // store current map in an xmap buffer { if(noteditmode("xmap_store")) return; // (may also be used in coopedit) if(!*nick || !validxmapname(nick)) return; int i; if(getxmapbynick(nick, &i, false)) { xmap *xm = xmaps.remove(i); xmapdelete(xm); } // overwrite existing same nick xmaps.add(new xmap(nick)); unsavededits = 0; conoutf("stored xmap %s", xmapdescstring(xmaps.last())); } ); COMMANDF(xmap_delete, "s", (const char *nick) // delete xmap buffer { if(!*nick) return; int i; if(getxmapbynick(nick, &i)) { xmap *xm = xmaps.remove(i); xmapdelete(xm); conoutf("deleted xmap \"%s\"", nick); } } ); COMMANDF(xmap_delete_backup, "", () { if(bak) { xmapdelete(bak); conoutf("deleted backup xmap"); }} ); COMMANDF(xmap_keep_backup, "s", (const char *nick) // move backup xmap to more permanent position { if(!bak) { conoutf("no backup xmap available"); return ; } defformatstring(bakdesc)("%s", bak->nick); if(*nick) { if(validxmapname(nick)) copystring(bak->nick, nick); else return; } loopi(42) if(getxmapbynick(bak->nick, NULL, false)) concatstring(bak->nick, "_"); // evade existing nicknames xmaps.add(bak); bak = NULL; conoutf("stored backup xmap \"%s\" as xmap %s", bakdesc, xmapdescstring(xmaps.last())); } ); COMMANDF(xmap_rename, "ss", (const char *oldnick, const char *newnick) // rename xmap buffer { if(!*oldnick || !*newnick) return; xmap *xm = getxmapbynick(oldnick); if(!xm || !validxmapname(newnick) || getxmapbynick(newnick, NULL, false)) return; copystring(xm->nick, newnick); } ); COMMANDF(xmap_restore, "s", (const char *nick) // use xmap as current map { EDITMP("xmap_restore"); if(*nick) { xmap *xm = getxmapbynick(nick); if(!xm) return; xmapbackup("restore_xmap_", nick); // keep backup, so we can restore from the restore :) xm->restore(); unsavededits = 0; conoutf("restored xmap %s", xmapdescstring(xm)); } else if(bak) { bak->restore(); unsavededits = 0; conoutf("restored backup created before %s", xmapdescstring(bak)); } } ); void restorexmap(char **args, int numargs) // read an xmap from a cubescript file { const char *cmdnames[] = { "version", "names", "sizes", "header", "world", "headerextra", "ent", "delent", "config", "todoent", "position", "" }; const char cmdnumarg[] = { 3, 2, 3, 0, 0, 1, 11, 11, 1, 2, 5 }; if(!xmjigsaw || numargs < 1) return; // { conoutf("restorexmap out of context"); return; } bool abort = false; int cmd = getlistindex(args[0], cmdnames, false, -1); if(cmd < 0 || numargs != cmdnumarg[cmd] + 1) { conoutf("restorexmap error"); return; } switch(cmd) { case 0: // version if(ATOI(args[1]) != XMAPVERSION || ATOI(args[2]) != (isbigendian() ? 1 : 0) || ATOI(args[3]) != int(sizeof(world))) { conoutf("restorexmap: file is from different game version"); abort = true; } break; case 1: // names copystring(xmjigsaw->name, args[1]); copystring(xmjigsaw->mcfname, args[2]); break; case 2: // sizes xmjigsaw->ssize = ATOI(args[1]); xmjigsaw->cubicsize = ATOI(args[2]); xmjigsaw->numundo = ATOI(args[3]); break; case 3: // header if(hexbin.length() == sizeof(header)) memcpy(&xmjigsaw->hdr, hexbin.getbuf(), sizeof(header)); else abort = true; break; case 4: // world { int rawworldsize = xmjigsaw->cubicsize * sizeof(sqr); xmjigsaw->world = new sqr[rawworldsize]; uLongf rawsize = rawworldsize; if(uncompress((uchar *)xmjigsaw->world, &rawsize, hexbin.getbuf(), hexbin.length()) != Z_OK || rawsize - rawworldsize != 0) abort = true; break; } case 5: // headerextra xmjigsaw->headerextras.add(new headerextra(hexbin.length(), ATOI(args[1]), hexbin.getbuf())); break; case 6: // ent case 7: // delent { persistent_entity &e = cmd == 6 ? xmjigsaw->ents.add() : xmjigsaw->delents.add(); int a[11]; loopi(11) a[i] = ATOI(args[i + 1]); e.type = a[0]; e.x = a[1]; e.y = a[2]; e.z = a[3]; e.attr1 = a[4]; e.attr2 = a[5]; e.attr3 = a[6]; e.attr4 = a[7]; e.attr5 = a[8]; e.attr6 = a[9]; e.attr7 = a[10]; break; } case 8: // config cvecprintf(xmjigsaw->mapconfig, "%s\n", args[1]); break; case 9: // todoent xmjigsaw->todoents.add(ATOI(args[1])); xmjigsaw->todoentdescs.add(newstring(args[2])); break; case 10: // position - this is also the last command and will finish the xmap { loopi(5) xmjigsaw->position[i] = ATOI(args[i + 1]); int i; if(getxmapbynick(xmjigsaw->nick, &i, false)) { xmap *xm = xmaps.remove(i); xmapdelete(xm); } // overwrite existing same nick if(!xmjigsaw->world) abort = true; else { if(xmjigsaw->mapconfig.length()) xmjigsaw->mapconfig.add('\0'); xmaps.add(xmjigsaw); xmjigsaw = NULL; // no abort! } } } hexbin.setsize(0); if(abort) DELETEP(xmjigsaw); } COMMAND(restorexmap, "v"); static const char *bakprefix = "(backup)", *xmapspath = "mapediting/xmaps"; char *xmapfilename(const char *nick, const char *prefix = "") { static defformatstring(fn)("%s/%s%s.xmap", xmapspath, prefix, nick); return path(fn); } void writexmap(xmap *xm, const char *prefix = "") { stream *f = openfile(xmapfilename(xm->nick, prefix), "w"); if(f) { xm->write(f); delete f; } } void writeallxmaps() // at game exit, write all xmaps to cubescript files in mapediting/xmaps { if(!persistentxmaps) return; loopv(xmaps) writexmap(xmaps[i]); if(unsavededits) xmapbackup("gameend", ""); if(bak) writexmap(bak, bakprefix); } void loadxmap(const char *nick) { DELETEP(xmjigsaw); xmjigsaw = new xmap(); copystring(xmjigsaw->nick, nick); hexbinenabled = true; execfile(xmapfilename(nick)); hexbinenabled = false; hexbin.setsize(0); // just to make sure } int loadallxmaps() // at game start, load all xmaps from mapediting/xmaps { vector xmapnames; string filename; listfiles(xmapspath, "xmap", xmapnames, stringsort); loopv(xmapnames) { loadxmap(xmapnames[i]); copystring(filename, xmapfilename(xmapnames[i])); backup(filename, xmapfilename(xmapnames[i], "backups/")); // move to backup folder - we will write new files at exit delete[] xmapnames[i]; } loopv(xmaps) if(!strncmp(xmaps[i]->nick, bakprefix, strlen(bakprefix))) { xmapdelete(bak); bak = xmaps.remove(i); copystring(bak->nick, bak->nick + strlen(bakprefix)); break; } return xmapnames.length(); } assaultcube-1.2.0.2.1/source/src/worldlight.cpp000066400000000000000000000271721352165075300213160ustar00rootroot00000000000000// worldlight.cpp #include "cube.h" #define LIGHTSCALE 4 void lightray(float bx, float by, const persistent_entity &light, float fade = 1, bool flicker = false) // done in realtime, needs to be fast { float lx = light.x+(flicker ? (rnd(21)-10)*0.1f : 0); float ly = light.y+(flicker ? (rnd(21)-10)*0.1f : 0); float dx = bx-lx; float dy = by-ly; float dist = sqrtf(dx*dx+dy*dy); if(dist<1.0f) return; int reach = light.attr1; int steps = (int)(reach*reach*1.6f/dist); const int PRECBITS = 12; const float PRECF = 4096.0f; int x = (int)(lx*PRECF); int y = (int)(ly*PRECF); int fadescale = (int)(fade*PRECF); int l = light.attr2*fadescale; int stepx = (int)(dx/(float)steps*PRECF); int stepy = (int)(dy/(float)steps*PRECF); int stepl = (int)(l/(float)steps); if(maxtmus) { l /= LIGHTSCALE; stepl /= LIGHTSCALE; if(light.attr3 || light.attr4) // coloured light version, special case because most lights are white { if(flicker) { int dimness = rnd((((255<>(PRECBITS+4))+1); x += stepx*dimness; y += stepy*dimness; } if(OUTBORD(x>>PRECBITS, y>>PRECBITS)) return; int g = light.attr3*fadescale; int stepg = (int)(g/(float)steps); int b = light.attr4*fadescale; int stepb = (int)(b/(float)steps); g /= LIGHTSCALE; stepg /= LIGHTSCALE; b /= LIGHTSCALE; stepb /= LIGHTSCALE; loopi(steps) { sqr *s = S(x>>PRECBITS, y>>PRECBITS); s->r = min((l>>PRECBITS)+s->r, 255); s->g = min((g>>PRECBITS)+s->g, 255); s->b = min((b>>PRECBITS)+s->b, 255); if(SOLID(s)) return; x += stepx; y += stepy; l -= stepl; g -= stepg; b -= stepb; stepl -= 25; stepg -= 25; stepb -= 25; } } else // white light, special optimized version { if(flicker) { int dimness = rnd((((255<>(PRECBITS+4))+1); x += stepx*dimness; y += stepy*dimness; } if(OUTBORD(x>>PRECBITS, y>>PRECBITS)) return; if(hdr.ambient > 0xFF) loopi(steps) { sqr *s = S(x>>PRECBITS, y>>PRECBITS); s->r = min((l>>PRECBITS)+s->r, 255); s->g = min((l>>PRECBITS)+s->g, 255); s->b = min((l>>PRECBITS)+s->b, 255); if(SOLID(s)) return; x += stepx; y += stepy; l -= stepl; stepl -= 25; } else loopi(steps) { sqr *s = S(x>>PRECBITS, y>>PRECBITS); s->r = s->g = s->b = min((l>>PRECBITS)+s->r, 255); if(SOLID(s)) return; x += stepx; y += stepy; l -= stepl; stepl -= 25; } } } else // the old (white) light code, here for the few people with old video cards that don't support overbright { loopi(steps) { sqr *s = S(x>>PRECBITS, y>>PRECBITS); int light = l>>PRECBITS; if(light>s->r) s->r = s->g = s->b = (uchar)light; if(SOLID(s)) return; x += stepx; y += stepy; l -= stepl; } } } void calclightsource(const persistent_entity &l, float fade = 1, bool flicker = true) { int reach = l.attr1; int sx = l.x-reach; int ex = l.x+reach; int sy = l.y-reach; int ey = l.y+reach; const float s = 0.8f; for(float sx2 = (float)sx; sx2<=ex; sx2+=s*2) { lightray(sx2, (float)sy, l, fade, flicker); lightray(sx2, (float)ey, l, fade, flicker); } for(float sy2 = sy+s; sy2<=ey-s; sy2+=s*2) { lightray((float)sx, sy2, l, fade, flicker); lightray((float)ex, sy2, l, fade, flicker); } } void postlightarealine(sqr *s, int len) { loopirev(len) { #define median(m) s->m = (s->m*2 + SW(s,1,0)->m*2 + SW(s,0,1)->m*2 \ + SW(s,-1,0)->m*2 + SW(s,0,-1)->m*2 \ + SW(s,1,1)->m + SW(s,1,-1)->m \ + SW(s,-1,1)->m + SW(s,-1,-1)->m)/14; // median is 4/2/1 instead median(r); median(g); median(b); s += 2; } } void postlightarea(const block &a) // median filter, smooths out random noise in light and makes it more mipable { int ia = (a.xs + 1) >> 1, ib = a.xs - ia;; for(int y = a.ys - 1; y >= 0; y -= 2) { sqr *s = S(a.x,y+a.y); postlightarealine(s, ia); postlightarealine(s + 1, ib); } for(int y = a.ys - 2; y >= 0; y -= 2) { sqr *s = S(a.x,y+a.y); postlightarealine(s, ia); postlightarealine(s + 1, ib); } remip(a); } int lastcalclight = 0; VARP(fullbrightlevel, 0, 176, 255); void fullbrightlight(int level) { if(level < 0) level = fullbrightlevel; loopi(mipsize) world[i].r = world[i].g = world[i].b = level; lastcalclight = totalmillis; } VARF(ambient, 0, 0, 0xFFFFFF, if(!noteditmode("ambient")) { hdr.ambient = ambient; calclight(); unsavededits++;}); void calclight() { if(editmode) { servsqr *servworld = createservworld(world, cubicsize); calcmapdims(clmapdims, servworld, ssize); delete[] servworld; } uchar r = (hdr.ambient>>16) & 0xFF, g = (hdr.ambient>>8) & 0xFF, b = hdr.ambient & 0xFF; if(!r && !g) { if(!b) b = 10; r = g = b; } else if(!maxtmus) r = g = b = max(max(r, g), b); // the old (white) light code, here for the few people with old video cards that don't support overbright sqr *s = S(0,0); loopirev(cubicsize) { s->r = r; s->g = g; s->b = b; s++; } seedMT(ents.length() + hdr.maprevision); // static seed -> nothing random here loopv(ents) { entity &e = ents[i]; if(e.type==LIGHT) calclightsource(e); } popMT(); // undo the static seedMT() from above block bb = { clmapdims.x1 - 1, clmapdims.y1 - 1, clmapdims.xspan + 2, clmapdims.yspan + 2 }; postlightarea(bb); setvar("fullbright", 0); lastcalclight = totalmillis; } struct dlight { physent *owner; vec offset, o; block *area; int reach, fade, expire; uchar r, g, b; float calcintensity() const { if(!fade || lastmillis < expire - fade) return 1.0f; return max(float(expire - lastmillis)/fade, 0.0f); } }; vector dlights; VARP(dynlight, 0, 1, 1); static inline bool insidearea(const block &a, const block &b) { return b.x >= a.x && b.y >= a.y && b.x+b.xs <= a.x+a.xs && b.y+b.ys <= a.y+a.ys; } void preparedynlight(dlight &d) { block area = { (int)d.o.x-d.reach, (int)d.o.y-d.reach, d.reach*2+1, d.reach*2+1 }; if(area.x<1) { area.xs = max(area.xs - (1 - area.x), 0); area.x = 1; } else if(area.x>ssize-2) { area.x = ssize-2; area.xs = 0; } if(area.y<1) { area.ys = max(area.ys - (1 - area.y), 0); area.y = 1; } else if(area.y>ssize-2) { area.y = ssize-2; area.ys = 0; } if(area.x+area.xs>ssize-2) area.xs = ssize-2-area.x; if(area.y+area.ys>ssize-2) area.ys = ssize-2-area.y; if(d.area) { if(insidearea(*d.area, area)) return; freeblock(d.area); } d.area = blockcopy(area); // backup area before rendering in dynlight } void adddynlight(physent *owner, const vec &o, int reach, int expire, int fade, uchar r, uchar g, uchar b) { if(!dynlight) return; dlight &d = dlights.add(); d.owner = owner; d.o = o; if(d.owner) { d.offset = d.o; d.offset.sub(d.owner->o); } else d.offset = vec(0, 0, 0); d.reach = reach; d.fade = fade; d.expire = lastmillis + expire; d.r = r; d.g = g; d.b = b; d.area = NULL; preparedynlight(d); } void cleardynlights() { loopv(dlights) freeblock(dlights[i].area); dlights.shrink(0); } void removedynlights(physent *owner) { loopv(dlights) if(dlights[i].owner==owner) { freeblock(dlights[i].area); dlights.remove(i--); } } void dodynlights() { if(dlights.empty()) return; const block *area = NULL; loopv(dlights) { dlight &d = dlights[i]; if(lastmillis >= d.expire) { freeblock(d.area); dlights.remove(i--); continue; } if(d.owner) { vec oldo(d.o); d.o = d.owner->o; d.o.add(d.offset); if(d.o != oldo) preparedynlight(dlights[i]); } } loopv(dlights) { dlight &d = dlights[i]; persistent_entity l((int)d.o.x, (int)d.o.y, (int)d.o.z, LIGHT, d.reach, d.r, d.g, d.b); calclightsource(l, d.calcintensity(), false); if(area) { if(insidearea(*area, *d.area)) continue; if(!insidearea(*d.area, *area)) postlightarea(*area); } area = d.area; } if(area) postlightarea(*area); lastcalclight = totalmillis; } void undodynlights() { if(dlights.empty()) return; const block *area = NULL; loopvrev(dlights) { const dlight &d = dlights[i]; if(area) { if(insidearea(*area, *d.area)) continue; if(!insidearea(*d.area, *area)) blockpaste(*area); } area = d.area; } if(area) blockpaste(*area); } // utility functions also used by editing code block *blockcopy(const block &s) { block *b = (block *)new uchar[sizeof(block)+s.xs*s.ys*sizeof(sqr)]; *b = s; sqr *q = (sqr *)(b+1), *r = S(s.x,s.y); size_t bs = s.xs * sizeof(sqr); loopirev(s.ys) { memcpy(q, r, bs); q += s.xs; r += ssize; } return b; } void blocktexusage(const block &b, uchar *used) { const sqr *q = (const sqr *)((&b)+1); loopirev(b.xs * b.ys) { // collect used texture slots in block used[q->wtex] = 1; if(q->type != SOLID) { used[q->ctex] = 1; used[q->ftex] = 1; used[q->utex] = 1; } q++; } } void blockpaste(const block &b, int bx, int by, bool light, uchar *texmap) // slow version, editmode only { const sqr *q = (const sqr *)((&b)+1); sqr *dest = 0; uchar tr, tg, tb; for(int y = by; yr; tg = dest->g; tb = dest->b; *dest = *q; if(texmap) { // translate texture slot numbers dest->wtex = texmap[q->wtex]; dest->ctex = texmap[q->ctex]; dest->ftex = texmap[q->ftex]; dest->utex = texmap[q->utex]; } if (light) //edit mode paste { dest->r = tr; dest->g = tg; dest->b = tb; } q++; } block bb = { bx, by, b.xs, b.ys }; remipmore(bb); } void blockpaste(const block &b) // fast version, used by dynlight { const sqr *q = (const sqr *)((&b)+1); sqr *r = S(b.x, b.y); const size_t bs = b.xs * sizeof(sqr); loopirev(b.ys) { memcpy(r, q, bs); r += ssize; q += b.xs; } remipmore(b); } void freeblockp(block *b) { delete[] (uchar *)b; } void freeblock(block *&b) { if(b) { freeblockp(b); b = NULL; } } assaultcube-1.2.0.2.1/source/src/worldocull.cpp000066400000000000000000000134351352165075300213220ustar00rootroot00000000000000// worldocull.cpp: occlusion map and occlusion test #include "cube.h" #define NUMRAYBITS 9 #define NUMRAYS (1 << NUMRAYBITS) #define NUMRAYS4 (NUMRAYS * 4) float rdist[NUMRAYS]; bool ocull = true; float odist = 256; void toggleocull() { ocull = !ocull; } COMMAND(toggleocull, ""); // constructs occlusion map: cast rays in all directions on the 2d plane and record distance. // done exactly once per frame. void disableraytable() { odist = 1e16f; loopi(NUMRAYS) rdist[i] = 1e16f; } void computeraytable(float vx, float vy, float fov) { static int ndist[NUMRAYS]; if(!ocull) { disableraytable(); return; } odist = fog * 1.5f; float apitch = (float)fabs(camera1->pitch); float af = fov/2+max(apitch/1.5f,4.2f); float byaw = (camera1->yaw-90+af)/360*PI2; float syaw = (camera1->yaw-90-af)/360*PI2; const bool vinside = !OUTBORD(vx, vy) && !SOLID(S(int(vx), int(vy))); loopj(NUMRAYS4) { int i = ((j << 2) & (NUMRAYS4 - 1)) | (j >> NUMRAYBITS), k = i / 4; // interleaved ray calculation bool firstquarter = j < NUMRAYS; float angle = i*PI2/NUMRAYS4; if((apitch>45 // must be bigger if fov>120 || (anglesyaw) || (anglesyaw-PI2) || (anglesyaw+PI2)) && vinside) // try to avoid tracing ray if outside of frustrum { float ray = i*8/(float)NUMRAYS4; float dx, dy; if(ray>1 && ray<3) { dx = -(ray-2); dy = 1; } else if(ray>=3 && ray<5) { dx = -1; dy = -(ray-4); } else if(ray>=5 && ray<7) { dx = ray-6; dy = -1; } else { dx = 1; dy = ray>4 ? ray-8 : ray; } float sx = vx; float sy = vy; if(!firstquarter) { int m = min(ndist[k], ndist[(k + 1) & (NUMRAYS - 1)]); if(m-- > 3) { if(m > 100) m = 100; sx += dx * m; // skip to the nearest already found wall, so the last three quarters only clean out the edges sy += dy * m; } } for(;;) { sx += dx; sy += dy; if(SOLID(S(int(sx), int(sy)))) // 90% of time spend in this function is on this line { float dist = (float)(fabs(sx-vx)+fabs(sy-vy)); if(firstquarter || dist > rdist[k]) rdist[k] = dist; if(firstquarter) ndist[k] = max(iabs(sx-vx), iabs(sy-vy)); break; } } } else { rdist[k] = 2; ndist[k] = 0; } } } // test occlusion for a cube... one of the most computationally expensive functions in the engine // as its done for every cube and entity, but its effect is more than worth it! #ifdef __GNUC__ // GCC seems to have trouble inlining these #define ca(xv, yv) ({ float x = (xv), y = (yv); x>y ? y/x : 2-x/y; }) #define ma(xv, yv) ({ float x = (xv), y = (yv); x==0 ? (y>0 ? 2 : -2) : y/x; }) #else static inline float ca(float x, float y) { return x>y ? y/x : 2-x/y; } static inline float ma(float x, float y) { return x==0 ? (y>0 ? 2 : -2) : y/x; } #endif int isoccluded(float vx, float vy, float cx, float cy, float csize) // v = viewer, c = cube to test { // ABC // D E // FGH // - check middle cube? BG // find highest and lowest angle in the occlusion map that this cube spans, based on its most left and right // points on the border from the viewer pov... I see no easier way to do this than this silly code below float xdist = 0, ydist = 0, h = 0, l = 0; if(cx<=vx) // ABDFG { if(cx+csize odist) return 2; if(cy<=vy) // AD { if(cy+csize odist) return 2; h = ca(-(cx-vx), ydist)+4; l = ca(xdist, -(cy-vy))+4; } // A else { h = ma(xdist, -(cy+csize-vy))+4; l = ma(xdist, -(cy-vy))+4; } // D } else { if((ydist = cy-vy) > odist) return 2; h = ca(cy+csize-vy, xdist)+2; l = ca(ydist, -(cx-vx))+2; } // F } else // BG { if(cy<=vy) { if(cy+csize odist) return 2; h = ma(ydist, cx-vx)+6; l = ma(ydist, cx+csize-vx)+6; } // B else return 0; } else { if((ydist = cy-vy) > odist) return 2; h = ma(ydist, -(cx+csize-vx))+2; l = ma(ydist, -(cx-vx))+2; } // G } } else // CEH { if((xdist = cx-vx) > odist) return 2; if(cy<=vy) // CE { if(cy+csize odist) return 2; h = ca(-(cy-vy), xdist)+6; l = ca(ydist, cx+csize-vx)+6; } // C else { h = ma(xdist, cy-vy); l = ma(xdist, cy+csize-vy); } // E } else { if((ydist = cy-vy) > odist) return 2; h = ca(cx+csize-vx, ydist); l = ca(xdist, cy+csize-vy); } // H } float dist = xdist+ydist-1; // 1 needed? int si = int(h*(NUMRAYS/8))+NUMRAYS; // get indexes into occlusion map from angles int ei = int(l*(NUMRAYS/8))+NUMRAYS+1; if(ei<=si) ei += NUMRAYS; for(int i = si; i<=ei; i++) { if(disttype==SEMISOLID) { float c1 = s->floor; float c2 = s->floor; if(s->type==FHF) { c1 -= d1->vdelta/4.0f; c2 -= d2->vdelta/4.0f; } float f1 = s->ceil; float f2 = s->ceil; if(s->type==CHF) { f1 += d1->vdelta/4.0f; f2 += d2->vdelta/4.0f; } //if(f1-c1<=0 && f2-c2<=0) return; render_square(o->wtex, c1, c2, f1, f2, x1<floor; float f2 = s->floor; float c1 = o->floor; float c2 = o->floor; if(o->type==FHF && s->type!=FHF) { c1 -= d1->vdelta/4.0f; c2 -= d2->vdelta/4.0f; } if(s->type==FHF && o->type!=FHF) { f1 -= d1->vdelta/4.0f; f2 -= d2->vdelta/4.0f; } if(f1>=c1 && f2>=c2) goto skip; render_square(o->wtex, f1, f2, c1, c2, x1<ceil; float f2 = o->ceil; float c1 = s->ceil; float c2 = s->ceil; if(o->type==CHF && s->type!=CHF) { f1 += d1->vdelta/4.0f; f2 += d2->vdelta/4.0f; } else if(s->type==CHF && o->type!=CHF) { c1 += d1->vdelta/4.0f; c2 += d2->vdelta/4.0f; } if(c1<=f1 && c2<=f2) return; render_square(o->utex, f1, f2, c1, c2, x1<type) { case SEMISOLID: if(issemi(mip, x+x1, y+y1, x1, y1, x2, y2)) return true; case CORNER: case SOLID: break; default: return true; } switch(SWS(w, x+x2, y+y2, mfactor)->type) { case SEMISOLID: if(issemi(mip, x+x2, y+y2, x1, y1, x2, y2)) return true; case CORNER: case SOLID: break; default: return true; } return false; } bool render_floor, render_ceil; // the core recursive function, renders a rect of cubes at a certain mip level from a viewer perspective // call itself for lower mip levels, on most modern machines however this function will use the higher // mip levels only for perfect mips. void render_seg_new(float vx, float vy, float vh, int mip, int x, int y, int xs, int ys) { sqr *w = wmip[mip]; int mfactor = sfactor - mip; int sz = 1<>mip; int vyy = ((int)vy+(1<>mip; int lx = vxx-lodleft; // these mark the rect inside the current rest that we want to render using a lower mip level int ly = vyy-lodtop; int rx = vxx+lodright; int ry = vyy+lodbot; float fsize = (float)(1<occluded = isoccluded(camera1->o.x, camera1->o.y, (float)(ox<>mip; int pvy = (int)vy>>mip; if(pvx>=0 && pvy>=0 && pvxoccluded = 0; SWS(w, pvx, pvy, mfactor)->occluded = 0; // player cell never occluded } #define df(x) s->floor-(x->vdelta/4.0f) #define dc(x) s->ceil+(x->vdelta/4.0f) // loop through the rect 3 times (for floor/ceil/walls seperately, to facilitate dynamic stripify) // for each we skip occluded cubes (occlusion at higher mip levels is a big time saver!). // during the first loop (ceil) we collect cubes that lie within the lower mip rect and are // also deferred, and render them recursively. Anything left (perfect mips and higher lods) we // render here. #define LOOPH {for(int yy = y; yyoccluded) continue; #define LOOPD sqr *t = SWS(s,1,0,mfactor); \ sqr *v = SWS(s,0,1,mfactor); \ sqr *u = SWS(v,1,0,mfactor); int rendered = 0; LOOPH // floors if(s->defer && mip && xx>=lx && xx=ly && yyoccluded = 1; // shortcut for the other LOOPHs int start = xx; while(xxoccluded = 1;} // collect 2xN rect of lower mip render_seg_new(vx, vy, vh, mip-1, start*2, yy*2, xx*2+2, yy*2+2); continue; } rendered++; switch(s->type) { case SPACE: case CHF: if(s->floor<=vh && render_floor) { sqr *v = SWS(s,0,1,mfactor); render_flat(s->ftex, xx<floor, s, s + 1, v + 1, v, false); if(s->floor < waterlevel && !reflecting) addwaterquad(xx<ftex, xx<floor - s->vdelta/4.0f < waterlevel && !reflecting) addwaterquad(xx<type) { case SPACE: case FHF: if(s->ceil>=vh && render_ceil) { sqr *v = SWS(s,0,1,mfactor); render_flat(s->ctex, xx<ceil, s, s + 1, v + 1, v, true); } break; case CHF: { LOOPD render_flatdelta(s->ctex, xx<type==CORNER) { // cull also bool topleft = true; sqr *h1 = NULL; sqr *h2 = NULL; if(SOLID(z)) { if(SOLID(w)) { render_wall(w, h2 = s, xx+1, yy, xx, yy+1, mip, t, v, false, 4); topleft = false; } else if(SOLID(v)) { render_wall(v, h2 = s, xx, yy, xx+1, yy+1, mip, s, u, false, 5); } } else if(SOLID(t)) { if(SOLID(w)) { render_wall(w, h1 = s, xx+1, yy+1, xx, yy, mip, u, s, false, 6); } else if(SOLID(v)) { render_wall(v, h1 = s, xx, yy+1, xx+1, yy, mip, v, t, false, 7); topleft = false; } } else { normalwall = false; bool wv = w->ceil-w->floor < v->ceil-v->floor; if(z->ceil-z->floor < t->ceil-t->floor) { if(wv) { render_wall(h1 = s, h2 = v, xx+1, yy, xx, yy+1, mip, t, v, false, 4); topleft = false; } else { render_wall(h1 = s, h2 = w, xx, yy, xx+1, yy+1, mip, s, u, false, 5); } } else { if(wv) { render_wall(h2 = s, h1 = v, xx+1, yy+1, xx, yy, mip, u, s, false, 6); } else { render_wall(h2 = s, h1 = w, xx, yy+1, xx+1, yy, mip, v, t, false, 7); topleft = false; } } } render_tris(xx<=vxx && xx!=0 && !SOLID(z) && (!SOLID(s) || z->type!=CORNER) && (z->type!=SEMISOLID || issemi(mip, xx-1, yy, 1, 0, 1, 1))) render_wall(s, z, xx, yy, xx, yy+1, mip, s, v, true, 0); // left if(xx<=vxx && xx!=sz-1 && !SOLID(t) && (!SOLID(s) || t->type!=CORNER) && (t->type!=SEMISOLID || issemi(mip, xx+1, yy, 0, 0, 0, 1))) render_wall(s, t, xx+1, yy, xx+1, yy+1, mip, t, u, false, 1); // right if(yy>=vyy && yy!=0 && !SOLID(w) && (!SOLID(s) || w->type!=CORNER) && (w->type!=SEMISOLID || issemi(mip, xx, yy-1, 0, 1, 1, 1))) render_wall(s, w, xx, yy, xx+1, yy, mip, s, t, false, 2); // top if(yy<=vyy && yy!=sz-1 && !SOLID(v) && (!SOLID(s) || v->type!=CORNER) && (v->type!=SEMISOLID || issemi(mip, xx, yy+1, 0, 0, 1, 0))) render_wall(s, v, xx, yy+1, xx+1, yy+1, mip, v, u, true, 3); // bot } }}} extern vector tagclipcubes; extern bool showtagclipfocus; extern int showtagclips; if(editmode && !showtagclipfocus && showtagclips) LOOPH // tag clips if(mip) { int ix1 = xx<tag & TAGANYCLIP && t->type != SOLID) tagclipcubes.add(ix + (iy << 16)); } } } else if(s->tag & TAGANYCLIP && s->type != SOLID) tagclipcubes.add(xx + (yy << 16)); }}} } void distlod(int &low, int &high, int angle, float widef) { float f = 90.0f/lod/widef; low = (int)((90-angle)/f); high = (int)(angle/f); if(lowisspectating() && player1->spectatemode == SM_OVERVIEW) ? MAX_LOD : MIN_LOD+iabs(pitch)/12; yaw = 360-yaw; float widef = fov/75.0f; int cdist = iabs(yaw%90-45); if(cdist<7) // hack to avoid popup at high fovs at 45 yaw { min_lod = max(min_lod, (int)(MIN_LOD+(10-cdist)/1.0f*widef)); // less if lod worked better widef = 1.0f; } lod = (int)(lod*changelod); if(lodMAX_LOD) lod = MAX_LOD; lodtop = lodbot = lodleft = lodright = min_lod; if(yaw>45 && yaw<=135) { lodleft = lod; distlod(lodtop, lodbot, yaw-45, widef); } else if(yaw>135 && yaw<=225) { lodbot = lod; distlod(lodleft, lodright, yaw-135, widef); } else if(yaw>225 && yaw<=315) { lodright = lod; distlod(lodbot, lodtop, yaw-225, widef); } else { lodtop = lod; distlod(lodright, lodleft, yaw<=45 ? yaw+45 : yaw-315, widef); } render_floor = pitch<0.5f*fovy; render_ceil = -pitch<0.5f*fovy; render_seg_new(vx, vy, vh, MAX_MIP, 0, 0, ssize>>MAX_MIP, ssize>>MAX_MIP); mipstats(stats); } assaultcube-1.2.0.2.1/source/src/zip.cpp000066400000000000000000000617211352165075300177370ustar00rootroot00000000000000#include "cube.h" // zip internals enum { ZIP_LOCAL_FILE_SIGNATURE = 0x04034B50, ZIP_LOCAL_FILE_SIZE = 30, ZIP_FILE_SIGNATURE = 0x02014B50, ZIP_FILE_SIZE = 46, ZIP_DIRECTORY_SIGNATURE = 0x06054B50, ZIP_DIRECTORY_SIZE = 22 }; struct ziplocalfileheader { uint signature; ushort version, flags, compression, modtime, moddate; uint crc32, compressedsize, uncompressedsize; ushort namelength, extralength; }; struct zipfileheader { uint signature; ushort version, needversion, flags, compression, modtime, moddate; uint crc32, compressedsize, uncompressedsize; ushort namelength, extralength, commentlength, disknumber, internalattribs; uint externalattribs, offset; }; struct zipdirectoryheader { uint signature; ushort disknumber, directorydisk, diskentries, entries; uint size, offset; ushort commentlength; }; // manage zips struct zipstream; struct ziparchive; struct zipfile // file in a zip archive { char *name, *fullname; // name from zip, full path name uint header, offset, size, compressedsize; ziparchive *location; zipfile() : name(NULL), fullname(NULL), header(0), offset(~0U), size(0), compressedsize(0), location(NULL) { } ~zipfile() { DELSTRING(name); DELSTRING(fullname); } }; struct ziparchive // zip archive file { char *name; stream *data; vector files; int openfiles; zipstream *owner; ziparchive() : name(NULL), data(NULL), openfiles(0), owner(NULL) { } ~ziparchive() { DELSTRING(name); DELETEP(data); } }; struct memfile { char *name; // file name uchar *buf; // file content int len, refcnt; // file length, current uses }; static bool findzipdirectory(stream *f, zipdirectoryheader &hdr) { if(!f->seek(0, SEEK_END)) return false; uchar buf[1024], *src = NULL; int len = 0, offset = f->tell(), end = max(offset - 0xFFFF - ZIP_DIRECTORY_SIZE, 0); const uint signature = lilswap(ZIP_DIRECTORY_SIGNATURE); while(offset > end) { int carry = min(len, ZIP_DIRECTORY_SIZE-1), next = min((int)sizeof(buf) - carry, offset - end); offset -= next; memmove(&buf[next], buf, carry); if(next + carry < ZIP_DIRECTORY_SIZE || !f->seek(offset, SEEK_SET) || (int)f->read(buf, next) != next) return false; len = next + carry; uchar *search = &buf[next-1]; for(; search >= buf; search--) if(*(uint *)search == signature) break; if(search >= buf) { src = search; break; } } if(!src || &buf[len] - src < ZIP_DIRECTORY_SIZE) return false; hdr.signature = lilswap(*(uint *)src); src += 4; hdr.disknumber = lilswap(*(ushort *)src); src += 2; hdr.directorydisk = lilswap(*(ushort *)src); src += 2; hdr.diskentries = lilswap(*(ushort *)src); src += 2; hdr.entries = lilswap(*(ushort *)src); src += 2; hdr.size = lilswap(*(uint *)src); src += 4; hdr.offset = lilswap(*(uint *)src); src += 4; hdr.commentlength = lilswap(*(ushort *)src); src += 2; if(hdr.signature != ZIP_DIRECTORY_SIGNATURE || hdr.disknumber != hdr.directorydisk || hdr.diskentries != hdr.entries) return false; return true; } #ifndef STANDALONE VAR(dbgzip, 0, 0, 1); #endif static bool readzipdirectory(stream *f, int entries, int offset, int size, vector &files) { uchar *buf = new uchar[size], *src = buf; if(!f->seek(offset, SEEK_SET) || (int)f->read(buf, size) != size) { delete[] buf; return false; } loopi(entries) { if(src + ZIP_FILE_SIZE > &buf[size]) break; zipfileheader hdr; hdr.signature = lilswap(*(uint *)src); src += 4; hdr.version = lilswap(*(ushort *)src); src += 2; hdr.needversion = lilswap(*(ushort *)src); src += 2; hdr.flags = lilswap(*(ushort *)src); src += 2; hdr.compression = lilswap(*(ushort *)src); src += 2; hdr.modtime = lilswap(*(ushort *)src); src += 2; hdr.moddate = lilswap(*(ushort *)src); src += 2; hdr.crc32 = lilswap(*(uint *)src); src += 4; hdr.compressedsize = lilswap(*(uint *)src); src += 4; hdr.uncompressedsize = lilswap(*(uint *)src); src += 4; hdr.namelength = lilswap(*(ushort *)src); src += 2; hdr.extralength = lilswap(*(ushort *)src); src += 2; hdr.commentlength = lilswap(*(ushort *)src); src += 2; hdr.disknumber = lilswap(*(ushort *)src); src += 2; hdr.internalattribs = lilswap(*(ushort *)src); src += 2; hdr.externalattribs = lilswap(*(uint *)src); src += 4; hdr.offset = lilswap(*(uint *)src); src += 4; if(hdr.signature != ZIP_FILE_SIGNATURE) break; if(!hdr.namelength /*|| !hdr.uncompressedsize */|| (hdr.compression && (hdr.compression != Z_DEFLATED || !hdr.compressedsize))) { src += hdr.namelength + hdr.extralength + hdr.commentlength; continue; } if(src + hdr.namelength > &buf[size]) break; string pname; int namelen = min((int)hdr.namelength, (int)sizeof(pname)-1); memcpy(pname, src, namelen); pname[namelen] = '\0'; path(pname); char *name = newstring(pname); zipfile &zf = files.add(); zf.name = name; zf.header = hdr.offset; zf.size = hdr.uncompressedsize; zf.compressedsize = hdr.compression ? hdr.compressedsize : 0; #ifndef STANDALONE if(dbgzip) conoutf("file %s, size %d, compress %d, flags %x", name, hdr.uncompressedsize, hdr.compression, hdr.flags); #endif src += hdr.namelength + hdr.extralength + hdr.commentlength; } delete[] buf; return files.length() > 0; } static bool readlocalfileheader(stream *f, ziplocalfileheader &h, uint offset) { f->seek(offset, SEEK_SET); uchar buf[ZIP_LOCAL_FILE_SIZE]; if(f->read(buf, ZIP_LOCAL_FILE_SIZE) != ZIP_LOCAL_FILE_SIZE) return false; uchar *src = buf; h.signature = lilswap(*(uint *)src); src += 4; h.version = lilswap(*(ushort *)src); src += 2; h.flags = lilswap(*(ushort *)src); src += 2; h.compression = lilswap(*(ushort *)src); src += 2; h.modtime = lilswap(*(ushort *)src); src += 2; h.moddate = lilswap(*(ushort *)src); src += 2; h.crc32 = lilswap(*(uint *)src); src += 4; h.compressedsize = lilswap(*(uint *)src); src += 4; h.uncompressedsize = lilswap(*(uint *)src); src += 4; h.namelength = lilswap(*(ushort *)src); src += 2; h.extralength = lilswap(*(ushort *)src); src += 2; if(h.signature != ZIP_LOCAL_FILE_SIGNATURE) return false; // h.uncompressedsize or h.compressedsize may be zero - so don't validate return true; } // stream interface struct zipstream : stream { enum { BUFSIZE = 16384 }; ziparchive *arch; zipfile *info; z_stream zfile; uchar *buf; int reading; bool ended; zipstream() : arch(NULL), info(NULL), buf(NULL), reading(-1), ended(false) { zfile.zalloc = NULL; zfile.zfree = NULL; zfile.opaque = NULL; zfile.next_in = zfile.next_out = NULL; zfile.avail_in = zfile.avail_out = 0; } ~zipstream() { close(); } void readbuf(uint size = BUFSIZE) { if(!zfile.avail_in) zfile.next_in = (Bytef *)buf; size = min(size, uint(&buf[BUFSIZE] - &zfile.next_in[zfile.avail_in])); if(arch->owner != this) { arch->owner = NULL; if(arch->data->seek(reading, SEEK_SET)) arch->owner = this; else return; } uint remaining = info->offset + info->compressedsize - reading; int n = arch->owner == this ? (int)arch->data->read(zfile.next_in + zfile.avail_in, min(size, remaining)) : 0; zfile.avail_in += n; reading += n; } bool open(ziparchive *a, zipfile *zf) { if(zf->offset == ~0U) { ziplocalfileheader h; a->owner = NULL; if(!readlocalfileheader(a->data, h, zf->header)) return false; zf->offset = zf->header + ZIP_LOCAL_FILE_SIZE + h.namelength + h.extralength; } if(zf->compressedsize && inflateInit2(&zfile, -MAX_WBITS) != Z_OK) return false; a->openfiles++; arch = a; info = zf; reading = zf->offset; ended = false; if(zf->compressedsize) buf = new uchar[BUFSIZE]; return true; } void stopreading() { if(reading < 0) return; #ifndef STANDALONE if(dbgzip) conoutf(info->compressedsize ? "%s: zfile.total_out %d, info->size %u" : "%s: reading %d, info->size %u", info->name, int(info->compressedsize ? zfile.total_out : reading - info->offset), info->size); #endif if(info->compressedsize) inflateEnd(&zfile); reading = -1; } void close() { stopreading(); DELETEA(buf); if(arch) { arch->owner = NULL; arch->openfiles--; arch = NULL; } } long size() { return info->size; } bool end() { return reading < 0 || ended; } long tell() { return reading >= 0 ? (info->compressedsize ? zfile.total_out : reading - info->offset) : -1; } bool seek(long pos, int whence) { if(reading < 0) return false; if(!info->compressedsize) { switch(whence) { case SEEK_END: pos += info->offset + info->size; break; case SEEK_CUR: pos += reading; break; case SEEK_SET: pos += info->offset; break; default: return false; } pos = clamp(pos, long(info->offset), long(info->offset + info->size)); arch->owner = NULL; if(!arch->data->seek(pos, SEEK_SET)) return false; arch->owner = this; reading = pos; ended = false; return true; } switch(whence) { case SEEK_END: pos += info->size; break; case SEEK_CUR: pos += zfile.total_out; break; case SEEK_SET: break; default: return false; } if(pos >= (long)info->size) { reading = info->offset + info->compressedsize; zfile.next_in += zfile.avail_in; zfile.avail_in = 0; zfile.total_in = info->compressedsize; arch->owner = NULL; ended = false; return true; } if(pos < 0) return false; if(pos >= (long)zfile.total_out) pos -= zfile.total_out; else { if(zfile.next_in && zfile.total_in <= uint(zfile.next_in - buf)) { zfile.avail_in += zfile.total_in; zfile.next_in -= zfile.total_in; } else { arch->owner = NULL; zfile.avail_in = 0; zfile.next_in = NULL; reading = info->offset; } inflateReset(&zfile); } uchar skip[512]; while(pos > 0) { int skipped = min(pos, (long)sizeof(skip)); if(read(skip, skipped) != skipped) return false; pos -= skipped; } ended = false; return true; } int read(void *buf, int len) { if(reading < 0 || !buf || !len) return 0; if(!info->compressedsize) { if(arch->owner != this) { arch->owner = NULL; if(!arch->data->seek(reading, SEEK_SET)) { stopreading(); return 0; } arch->owner = this; } int n = (int)arch->data->read(buf, min(len, int(info->size + info->offset - reading))); reading += n; if(n < len) ended = true; return n; } zfile.next_out = (Bytef *)buf; zfile.avail_out = len; while(zfile.avail_out > 0) { if(!zfile.avail_in) readbuf(BUFSIZE); int err = inflate(&zfile, Z_NO_FLUSH); if(err != Z_OK) { if(err == Z_STREAM_END) ended = true; else { #ifndef STANDALONE if(dbgzip) conoutf("inflate error: %s", zError(err)); #endif stopreading(); } break; } } return len - zfile.avail_out; } }; // manage zips as part of the AC virtual filesystem static vector archives; // list of mounted zip files, highest priority first static hashtable zipfiles; // table of all files in all mounted zips static hashtable memfiles; // table of all memfiles static void mountzip(ziparchive &arch, const char *mountdir, const char *stripdir, bool allowconfig) { string mdir = "", fname; if(mountdir) { copystring(mdir, mountdir); if(fixpackagedir(mdir) <= 1) mdir[0] = '\0'; } int striplen = stripdir ? (int)strlen(stripdir) : 0; loopv(arch.files) { // build full path names - and check them zipfile *zf = &arch.files[i]; formatstring(fname)("%s%s", mdir, striplen && !strncmp(zf->name, stripdir, striplen) ? zf->name + striplen : zf->name); path(fname); unixpath(fname); zf->fullname = newstring(fname); zf->location = &arch; filtertext(fname, fname, FTXT__MEDIAFILEPATH); if(strcmp(fname, zf->fullname) || (strncmp("packages/", fname, 9) && (!allowconfig || strncmp("config/", fname, 7)))) { // path is not allowed (illegal characters or illegal path) #if defined(_DEBUG) && !defined(STANDALONE) clientlogf("mountzip: ignored file %s from zip %s", fname, arch.name); #endif DELSTRING(zf->fullname); } else path(zf->fullname); } } static void rebuildzipfilehashtable() { zipfiles.clear(false); loopv(archives) { ziparchive *arch = archives[i]; loopvj(arch->files) { zipfile *zf = &arch->files[j]; if(zf->fullname) zipfiles.access(zf->fullname, zf); } } } void clearmemfiles() // clear list of memfiles and free all associated buffers (unless there are files still open) { bool inuse = false; enumerate(memfiles, memfile, mf, { if(mf.refcnt != 1) inuse = true; }); if(!inuse) { enumerate(memfiles, memfile, mf, { delstring(mf.name); DELETEP(mf.buf); }); memfiles.clear(false); } } bool addmemfile(char *name, uchar *data, int len) { path(name); memfile *mf = memfiles.access(name); if(mf) return false; // not added (already existed) char *nname = newstring(name); mf = &memfiles[nname]; mf->name = nname; mf->buf = new uchar[len]; memcpy(mf->buf, data, len); mf->len = len; mf->refcnt = 1; return true; } #ifndef STANDALONE #ifdef _DEBUG void listmemfiles() { enumerate(memfiles, memfile, mf, { conoutf("\"%s\", %x, len %d, refcnt %d", mf.name, int(int(size_t(mf.buf)) & 0xfffffff), mf.len, mf.refcnt); }); } COMMAND(listmemfiles, ""); #endif // manage zipped mod packages in subdirectory "mods/" including description and preview images // zip packages are restricted to contain files below "packages/" only - unless the zip filename starts with "###", which additionally allows files below "config/" ziparchive *findzip(const char *name) { loopv(archives) if(!strcmp(name, archives[i]->name)) return archives[i]; return NULL; } const char *fixzipname(char *name) // check, if valid path + filename, based on mods/, return NULL if invalid { string tmp; unixpath(name); // changes "name"! filtertext(tmp, name, FTXT__MEDIAFILEPATH); const char *bp = behindpath(tmp), *pd = parentdir(tmp); static defformatstring(pname)("%s%s%s%s", pd, bp != tmp ? "/" : "", !strncmp("###", behindpath(name), 3) ? "###" : "", bp); if(strlen(name) > 40 || strchr(name, '.') || strcmp(pname, name) || *name == '/') return NULL; // illegal filename formatstring(pname)("mods/%s.zip", name); return path(pname); } bool validzipmodname(char *name) // check for valid _downloadable_ zip mod name (no '#' allowed), also changes backslashes to slashes { return fixzipname(name) && !strchr(name, '#'); } VAR(zipcachemaxsize, 0, 512, 1024); // load zip files smaller than 512K straight into RAM void addzipmod(char *name) { const char *pname = fixzipname(name); if(!pname) { conoutf("addzipmod: illegal filename %s", name); return; } ziparchive *exists = findzip(name); if(exists) { // already added zip archives.removeobj(exists); archives.add(exists); // sort to the end of the list rebuildzipfilehashtable(); return; } ziparchive *arch = new ziparchive; arch->name = newstring(name); if(!(arch->data = openfile(pname, "rb"))) { conoutf("could not open file %s", pname); delete arch; return; } int zipsize = arch->data->size(); if(zipsize > 0 && zipsize < zipcachemaxsize * 1024) { uchar *buf = new uchar[zipsize]; if(arch->data->read(buf, zipsize) != zipsize) { conoutf("could not cache file %s", pname); delete[] buf; delete arch; return; } delete arch->data; arch->data = openmemfile(buf, zipsize, NULL); } zipdirectoryheader h; if(!findzipdirectory(arch->data, h) || !readzipdirectory(arch->data, h.entries, h.offset, h.size, arch->files)) { conoutf("could not read directory in zip %s", pname); delete arch; return; } mountzip(*arch, NULL, NULL, !strncmp(behindpath(name), "###", 3)); archives.add(arch); rebuildzipfilehashtable(); DEBUGCODE(clientlogf("added zipmod %s, %d bytes, %d files", pname, zipsize, arch->files.length())); } COMMAND(addzipmod, "s"); void zipmodremove(char *name) { const char *pname = fixzipname(name); ziparchive *exists = pname ? findzip(name) : NULL; if(!exists) { conoutf("zip %s is not loaded", name); return; } if(exists->openfiles) { conoutf("zip %s has %d open files", name, exists->openfiles); return; } conoutf("removed zip %s", exists->name); archives.removeobj(exists); rebuildzipfilehashtable(); delete exists; } COMMAND(zipmodremove, "s"); void zipmodclear() { loopvrev(archives) { ziparchive *a = archives[i]; if(a->openfiles) { conoutf("zip %s has %d open files", a->name, a->openfiles); continue; } delete archives.remove(i); } rebuildzipfilehashtable(); } COMMAND(zipmodclear, ""); void zipmodlist(char *which) // "active", "inactive", "all"(default) { vector res; if(!strcasecmp(which, "active")) { loopv(archives) cvecprintf(res, "%s ", archives[i]->name); } else { bool inactive = !strcasecmp(which, "inactive"); vector files; listfilesrecursive("mods", files); files.sort(stringsort); loopvrev(files) if(files.inrange(i + 1) && !strcmp(files[i], files[i + 1])) delstring(files.remove(i + 1)); // remove doubles loopv(files) { char *f = files[i]; if(!strncmp(f, "mods/", 5) && !strncmp(f + strlen(f) - 4, ".zip", 4)) { f += 5; f[strlen(f) - 4] = '\0'; if(fixzipname(f) && (!inactive || !findzip(f))) cvecprintf(res, "%s ", f); } } files.deletearrays(); } resultcharvector(res, -1); } COMMAND(zipmodlist, "s"); const char *desctxt = "desc.txt", *previewjpg = "preview.jpg", *modrev = "revision_"; // special files in zip containing description or preview void zipmodgetdesc(char *name) // open zip, read desc.txt and mount preview picture { const char *pname = fixzipname(name); stream *f = pname ? openfile(pname, "rb") : NULL, *zf = NULL; vector files; vector res; void *mz = zipmanualopen(f, files); string tmp; if(!f || !mz) conoutf("failed to read/open zip file %s", pname); else { loopv(files) { if(!strcmp(files[i], desctxt)) { if((zf = zipmanualstream(mz, i))) loopk(11) { zf->getline(tmp, MAXSTRLEN / 2); filtertext(tmp, tmp, FTXT__ZIPDESC); if(*tmp) cvecprintf(res, "%s\n", escapestring(tmp)); else break; } } else if(!strcmp(files[i], previewjpg)) { vector *v = new vector; zf = openvecfile(v); int got = zipmanualread(mz, i, zf, 128 * 1024); // max. file size for preview.jpg is 128k formatstring(tmp)("packages/modpreviews/%s.jpg", name); addmemfile(tmp, v->getbuf(), got); if(got == 128 * 1024) conoutf("\f3preview.jpg in zip file %s exceeds maximum file size: file truncated", pname); } DELETEP(zf); } zipmanualclose(mz); } resultcharvector(res, -1); } COMMAND(zipmodgetdesc, "s"); void zipmodgetfiles(char *name) // open zip, read list of files { const char *pname = fixzipname(name); stream *f = pname ? openfile(pname, "rb") : NULL; vector files; vector res; void *mz = zipmanualopen(f, files); if(!f || !mz) conoutf("failed to read/open zip file %s", pname); else { loopv(files) cvecprintf(res, "%s\n", escapestring(files[i])); zipmanualclose(mz); } resultcharvector(res, -1); } COMMAND(zipmodgetfiles, "s"); void zipmodgetrevision(char *name) // open zip, read list of files { const char *pname = fixzipname(name); stream *f = pname ? openfile(pname, "rb") : NULL; vector files; int res = 0, modrevlen = (int)strlen(modrev); void *mz = zipmanualopen(f, files); if(!f || !mz) conoutf("failed to read/open zip file %s", pname); else { loopv(files) if(!strncasecmp(files[i], modrev, modrevlen)) res = atoi(files[i] + modrevlen); zipmanualclose(mz); } intret(res); } COMMAND(zipmodgetrevision, "s"); void writezipmodconfig(stream *f) { f->printf("zipcachemaxsize %d\n", zipcachemaxsize); loopv(archives) f->printf("addzipmod %s\n", archives[i]->name); } #endif // simple interface to read zip contents without mounting them first void *zipmanualopen(stream *f, vector &files) { if(!f) return NULL; zipdirectoryheader h; ziparchive *arch = new ziparchive; if(!findzipdirectory(f, h) || !readzipdirectory(f, h.entries, h.offset, h.size, arch->files)) { delete arch; delete f; return NULL; } arch->data = f; loopv(arch->files) files.add(arch->files[i].name); return (void *)arch; } stream *zipmanualstream(void *a, int n) { ziparchive *arch = (ziparchive *)a; if(arch->files.inrange(n)) { zipstream *s = new zipstream; if(s->open(arch, &arch->files[n])) return s; delete s; } return NULL; } int zipmanualread(void *a, int n, stream *f, int maxlen) { int got = -1; stream *s = zipmanualstream(a, n); if(s) { got = streamcopy(f, s, maxlen); delete s; } return got; } void zipmanualclose(void *a) { ziparchive *arch = (ziparchive *)a; delete arch; // also closes arch->data, the associated file stream! } // AC virtual filesystem bool findzipfile(const char *name) { return zipfiles.access(name) != NULL || memfiles.access(name) != NULL; } stream *openzipfile(const char *name, const char *mode) { for(; *mode; mode++) if(*mode=='w' || *mode=='a') return NULL; // if(!strncmp(name, "zip://", 6)) name += 6; memfile *mf = memfiles.access(name); if(mf) return openmemfile(mf->buf, mf->len, &mf->refcnt); zipfile **zf = zipfiles.access(name); if(zf && *zf) { zipstream *s = new zipstream; if(s->open((*zf)->location, *zf)) return s; delete s; } return NULL; } void listzipfiles(const char *dir, const char *ext, vector &files) // (does not list memfiles) { int extsize = ext ? (int)strlen(ext)+1 : 0, dirsize = (int)strlen(dir); enumerate(zipfiles, zipfile *, zf, { if(strncmp(zf->fullname, dir, dirsize)) continue; const char *name = zf->fullname + dirsize; if(name[0] == PATHDIV) name++; if(strchr(name, PATHDIV)) continue; if(!ext) files.add(newstring(name)); else { int namelength = (int)strlen(name) - extsize; if(namelength > 0 && name[namelength] == '.' && strncmp(name+namelength+1, ext, extsize-1)==0) files.add(newstring(name, namelength)); } }); } void listzipdirs(const char *dir, vector &subdirs) // (does not list memfiles) { int dirsize = (int)strlen(dir); enumerate(zipfiles, zipfile *, zf, { if(strncmp(zf->fullname, dir, dirsize)) continue; const char *name = zf->fullname + dirsize; if(name[0] == PATHDIV) name++; const char *endname = strchr(name, PATHDIV); if(!endname) continue; subdirs.add(newstring(name, endname - name)); }); }