--- /dev/null
+// automatically written on exit, DO NOT MODIFY
+// delete this file to have data/defaults.cfg overwrite these settings
+// modify settings in game, or put settings in autoexec.cfg to override anything
+
+name "xolatile"
+
+loadcrosshair "data/crosshair.png" 0
+
+ammobar 1
+ammobaralign 0
+ammobarcountscale 1.5
+ammobarcountsep 20
+ammobarflip 0
+ammobarhideempty 1
+ammobarhorizontal 0
+ammobarscale 0.5
+ammobarsep 20
+ammobarx 0.025
+ammobary 0.5
+ammohud 1
+aniso 0
+applydialog 1
+armourcolors 1
+aspect 0.0
+attackspawn 1
+autoauth 1
+autocompactvslots 256
+autosortservers 1
+autoupdateservers 1
+bilinear 1
+blood 1
+blurshadowmap 1
+blursmsigma 100
+bumpmodels 1
+chainsawhudgun 1
+clockerror 1000000
+clockfix 0
+compresspng 9
+confade 30
+confilter 11519
+connectname ""
+connectport 0
+conscale 0.33
+consize 5
+contags 3
+crosshaircolors 1
+crosshairfx 1
+crosshairsize 15
+cursorsize 30
+damagecompass 1
+damagecompassalpha 25
+damagecompassfade 1000
+damagecompassmax 200
+damagecompassmin 25
+damagecompasssize 30
+deadpush 2
+deathscore 1
+decalfade 10000
+decals 1
+demodir "demo"
+dynlightdist 1024
+editinview 1
+emitmillis 17
+entcamdir 1
+explodebright 1.0
+fewparticles 100
+filltjoints 1
+fixwav 1
+fov 120
+fpshadowmap 0
+fullbrightmodels 60
+fullconfilter 65535
+fullconsize 75
+gameclock 1
+gameclockalign 0
+gameclockalpha 255
+gameclockcolour 16777215
+gameclocklowcolour 16760896
+gameclockscale 0.75
+gameclockx 0.5
+gameclocky 0.03
+gamma 100
+gpuskel 1
+gui2d 1
+guiautotab 16
+guiclicktab 0
+guifadein 1
+guifollow 1
+guipreviewtime 15
+guipushdist 4
+guisens 1.0
+healthcolors 1
+hidedead 0
+hidefrags 0
+highlightscore 1
+hitcrosshair 425
+hitsound 0
+hudarmour 1
+hudarmourscale 1.0
+hudarmourx 1.0
+hudarmoury 1.0
+hudgun 1
+hudgunsdir ""
+hudgunsway 1
+hudhealth 1
+hudhealthscale 1.0
+hudhealthx 0.0
+hudhealthy 1.0
+hudmaxhealth 1
+hudmaxhealthscale 1.0
+hudmaxhealthx 0.257
+hudmaxhealthy 1.0
+hudscore 1
+hudscorealign 0
+hudscorealpha 255
+hudscoreenemycolour 16728128
+hudscoreplayercolour 6332671
+hudscorescale 1.0
+hudscoresep 200
+hudscorex 0.5
+hudscorey 0.03
+invmouse 0
+jumpspawn 1
+lightthreads 0
+maxcon 200
+maxdecaldistance 512
+maxdecaltris 1024
+maxdynlights 5
+maxfps 60
+maxhistory 1000
+maxparticledistance 1024
+maxparticles 4000
+maxparticletextdistance 128
+maxroll 0
+maxservpings 10
+maxsoundsatonce 7
+maxtexsize 0
+maxtrail 500
+menuautoclose 120
+menudistance 40
+miniconfade 30
+miniconfilter 768
+miniconsize 5
+miniconwidth 40
+minimizedsounds 0
+mouseaccel 0.0
+musicvol 60
+muzzleflash 1
+muzzlelight 1
+nompedit 1
+outlinecolour 0
+outlinemeters 0
+particlesize 100
+particletext 1
+playermodel 0
+ragdoll 1
+ragdollfade 1000
+ragdollmillis 10000
+reducefilter 1
+relativemouse 1
+savebak 2
+scoreboard2d 1
+screenshotdir "screenshot"
+screenshotformat 1
+screenshotquality 97
+searchlan 0
+sensitivity 4.2
+sensitivityscale 1.0
+servpingdecay 15000
+servpingrate 5000
+shaderdetail 3
+shadowmap 1
+shadowmapbias 5
+shadowmapdist 256
+shadowmapintensity 40
+shadowmappeelbias 20
+shadowmapprecision 0
+shadowmapradius 96
+shadowmapsize 9
+showclientnum 1
+showconnecting 0
+showdamagedealt 1
+showdeaths 1
+showfps 1
+showfpsrange 0
+showmat 1
+showmodeinfo 1
+showparticles 1
+showping 1
+showpj 0
+showservinfo 1
+showspectatorping 1
+showspectators 1
+smoothdist 32
+smoothmove 75
+soundvol 255
+spawnwait 0
+speedometer 1
+speedometeralpha 0.5
+speedometercolor 1
+speedometerscale 0.5
+speedometerx 0.5
+speedometery 0.6
+statusbars 1
+statusbarscale 1.0
+statusicons 1
+teamcolorchat 1
+teamcolorfrags 1
+teamcolortext 1
+teamcrosshair 1
+teamhudguns 1
+teamskins 0
+teamsounds 1
+texcompress 1025
+texcompressquality -1
+texgui2d 1
+texguiheight 8
+texguiname 1
+texguiscale 1.5
+texguitime 15
+texguiwidth 15
+texreduce 0
+trilinear 1
+usenp2 0
+vsync 0
+vsynctear 0
+zoomaccel 0.0
+zoomautosens 1
+zoomfov 35
+zoominvel 250
+zoomoutvel 100
+zoomsens 1.0
+
+bind "0" [setweapon FI]
+bind "1" [setweapon SG]
+bind "2" [setweapon CG]
+bind "3" [setweapon RL]
+bind "4" [setweapon RI]
+bind "5" [setweapon GL]
+bind "6" [setweapon PI]
+bind "7" [setweapon FI]
+bind "9" [if (allowthirdperson) [togglevar thirdperson]]
+bind "A" [left]
+bind "BACKQUOTE" [saycommand /]
+bind "BACKSLASH" [edittoggle]
+bind "D" [right]
+bind "DELETE" [delbot]
+bind "DOWN" [backward]
+bind "E" [setweapon 1]
+bind "ESCAPE" [togglemainmenu]
+bind "F" [setweapon 6]
+bind "F1" [set paused (= $paused 0)]
+bind "F11" [toggleconsole]
+bind "F12" [screenshot]
+bind "G" [togglezoom]
+bind "I" [taunt]
+bind "INSERT" [addbot]
+bind "KP_MINUS" [conskip 5]
+bind "KP_PLUS" [screenshot]
+bind "LALT" [setweapon 5]
+bind "LCTRL" [setweapon 3]
+bind "LEFT" [left]
+bind "LSHIFT" [setweapon 0]
+bind "M" [showcustommaps]
+bind "MOUSE1" [attack]
+bind "MOUSE2" [setweapon 5; attack 1; onrelease weapon]
+bind "MOUSE3" [setweapon 5; attack 1; onrelease weapon]
+bind "MOUSE4" [universaldelta 1]
+bind "MOUSE5" [universaldelta -1]
+bind "N" [showgui maps]
+bind "PAUSE" [set paused (= $paused 0)]
+bind "Q" [setweapon 2]
+bind "R" [setweapon 4]
+bind "RIGHT" [right]
+bind "S" [backward]
+bind "SLASH" [saycommand /]
+bind "SPACE" [jump]
+bind "T" [saycommand]
+bind "TAB" [showscores]
+bind "UP" [forward]
+bind "W" [forward]
+bind "Y" [sayteamcommand]
+bind "Z" [togglezoom]
+specbind "MOUSE1" [nextfollow]
+specbind "MOUSE2" [nextfollow -1]
+specbind "MOUSE3" [follow]
+specbind "SPACE" [follow]
+editbind "0" [togglevar allfaces]
+editbind "1" [domodifier 11]
+editbind "2" [domodifier 12]
+editbind "3" [domodifier 13]
+editbind "4" [domodifier 14]
+editbind "5" [togglevar hidehud]
+editbind "6" [togglevar entselsnap]
+editbind "7" [togglevar outline]
+editbind "8" [togglevar wireframe]
+editbind "B" [domodifier 9]
+editbind "BACKSLASH" [edittoggle]
+editbind "C" [editcopy]
+editbind "COMMA" [domodifier 10; onrelease entautoview]
+editbind "DELETE" [editdel]
+editbind "F" [domodifier 2]
+editbind "F2" [showtexgui]
+editbind "F3" [if (cleargui 1) [] [showentgui]]
+editbind "F4" [if (cleargui 1) [] [showgui mapmodels]]
+editbind "F5" [savemap]
+editbind "F6" [notepad (mapcfgname)]
+editbind "F9" [echo (getseltex) : (gettexname (getseltex))]
+editbind "G" [domodifier 1]
+editbind "J" [gotosel]
+editbind "K" [calclight]
+editbind "KP_ENTER" [entselect insel]
+editbind "L" [togglevar fullbright]
+editbind "LALT" [history 0]
+editbind "LCTRL" [set passthrough 1; onrelease [set passthrough 0]]
+editbind "LSHIFT" [editcut]
+editbind "M" [togglevar showmat]
+editbind "MOUSE1" [editdrag]
+editbind "MOUSE2" [editextend]
+editbind "MOUSE3" [selcorners]
+editbind "N" [selentfindall]
+editbind "O" [domodifier 15]
+editbind "P" [domodifier 16]
+editbind "PERIOD" [selentedit]
+editbind "Q" [domodifier 3]
+editbind "R" [domodifier 4]
+editbind "SPACE" [floatspeed 1200; onrelease [floatspeed 120]]
+editbind "T" [saycommand]
+editbind "V" [editpaste]
+editbind "X" [editflip]
+editbind "Y" [domodifier 6]
+
+defaultmodifier = [0]
+delta_edit_0 = [
+ editfacewentpush $arg1 1
+]
+delta_edit_1 = [ nodebug [ gridpower (+ $arg1 $gridpower) ] ]
+delta_edit_10 = [ entautoview $arg1 ]
+delta_edit_11 = [ entproperty 0 (* $arg1 $multiplier) ]
+delta_edit_12 = [ entproperty 1 (* $arg1 $multiplier) ]
+delta_edit_13 = [ entproperty 2 (* $arg1 $multiplier) ]
+delta_edit_14 = [ entproperty 3 (* $arg1 $multiplier) ]
+delta_edit_15 = [ vdelta [voffset (* $arg1 $multiplier2) 0] ]
+delta_edit_16 = [ vdelta [voffset 0 (* $arg1 $multiplier2)] ]
+delta_edit_17 = [ vdelta [vrotate $arg1] ]
+delta_edit_18 = [ vdelta [vscale (if (< $arg1 0) 0.5 2)] ]
+delta_edit_2 = [ editfacewentpush $arg1 0 ]
+delta_edit_3 = [ editfacewentpush $arg1 2 ]
+delta_edit_5 = [ entproperty 0 $arg1 ]
+delta_edit_6 = [ edittex $arg1 ]
+delta_game_0 = [ if (= $arg1 1) [ weapon 2 3 5 4 1 6 0 ] [ weapon 4 1 6 2 3 5 0 ] ]
+domodifier = [ modifier = $arg1; onrelease [ modifier = $defaultmodifier ] ]
+glaremodeltype = [aqmi]
+guirolloveraction = [quit]
+guirollovername = [quit]
+modeltype = [aqmib]
+modifier = [0]
+multiplier = [1]
+multiplier2 = [16]
+newname = [xolatile]
+skelanimlength = [192]
+universaldelta = "^n do [delta_@(if $editing [ result edit ] [ result game ])_@modifier @arg1]^n"
+
+listcomplete clearents [
+ light mapmodel playerstart particles sound
+ shells bullets rockets riflerounds grenades cartridges
+ health healthboost tinyhealth tinyarmour greenarmour yellowarmour quaddamage
+ teleport teledest jumppad
+]
+complete coop "packages/maps" "ogz"
+varcomplete demo "demodir" "dmo"
+listcomplete editmat [air clip noclip gameclip death alpha]
+complete effic "packages/maps" "ogz"
+complete efficteam "packages/maps" "ogz"
+listcomplete entfind [
+ light mapmodel playerstart particles sound
+ shells bullets rockets riflerounds grenades cartridges
+ health healthboost tinyhealth tinyarmour greenarmour yellowarmour quaddamage
+ teleport teledest jumppad
+]
+complete ffa "packages/maps" "ogz"
+complete insta "packages/maps" "ogz"
+complete instateam "packages/maps" "ogz"
+complete map "packages/maps" "ogz"
+listcomplete newent [
+ light mapmodel playerstart particles sound
+ shells bullets rockets riflerounds grenades cartridges
+ health healthboost tinyhealth tinyarmour greenarmour yellowarmour quaddamage
+ teleport teledest jumppad
+]
+complete teamplay "packages/maps" "ogz"
@arg2
//:shadowmap
- //:dynlight
}
] [
@(if (>= $numargs 5) [result $arg5])
vec4 lm = texture2D(lightmap, texcoord1);
//:shadowmap lm
- //:dynlight lm
@arg3
pulse = abs(fract(millis*pulseglowspeed.x)*2.0 - 1.0);
]])
- @(if (|| (! (btopt "i")) (btopt "s")) [result [
- //:dynlight
- ]])
@(if (! (btopt "i")) [result [
//:shadowmap
//:water
@(if (|| (! (btopt "i")) (btopt "s")) [result [
lmc.rgb = max(lmc.rgb*clamp(dot(lmlv, bump), 0.0, 1.0), ambient.xyz);
@(if (btopt "i") [result [
- //:dynlight lmc
@(? (btopt "g") "diffuse.rgb" "gl_FragColor.rgb") = diffuse.rgb * lmc.rgb;
]] [result [
//:shadowmap lmc
- //:dynlight lmc
@(? (|| (btopt "g") (btopt "r")) "diffuse.rgb" "gl_FragColor.rgb") = diffuse.rgb * lmc.rgb;
]])
guibar
]
]
- guilist [
- guicheckbox "^f0dynamic lights^t" maxdynlights 3 0
- if $maxdynlights [
- guibar
- guiradio "^f0medium quality" maxdynlights 3
- guibar
- guiradio "^f2high quality" maxdynlights 5
- ]
- ]
guilist [
guicheckbox "^f0decals^t^t" decals
if $decals [
--- /dev/null
+// automatically written on exit, DO NOT MODIFY
+// modify settings in game
+fullscreen 1
+fullscreendesktop 0
+scr_w 1920
+scr_h 1080
+depthbits 0
+fsaa -1
+usesound 1
+soundchans 32
+soundfreq 44100
+soundbufferlen 1024
// delete this file to have data/defaults.cfg overwrite these settings
// modify settings in game, or put settings in autoexec.cfg to override anything
-name "unnamed"
+name "Anonymous"
ammobar 0
ammohud 1
aniso 0
applydialog 1
+armourcolors 1
aspect 0.0
-ati_skybox_bug 0
attackspawn 1
autoauth 1
autocompactvslots 256
autoupdateservers 1
bilinear 1
blood 1
-blurdepthfx 0
-blurdepthfxsigma 50
-blurglare 4
-blurglareaspect 1
-blurglaresigma 50
blurshadowmap 1
blursmsigma 100
bumpmodels 1
-caustics 1
chainsawhudgun 1
clockerror 1000000
clockfix 0
compresspng 9
-compresstga 1
confade 30
confilter 11519
connectname ""
damagecompassmax 200
damagecompassmin 25
damagecompasssize 30
-damagescreen 1
-damagescreenalpha 45
-damagescreenfactor 7
-damagescreenfade 125
-damagescreenmax 100
-damagescreenmin 10
deadpush 2
deathscore 1
decalfade 10000
decals 1
demodir "demo"
-depthfx 1
-depthfxblend 16
-depthfxemuprecision 1
-depthfxfpscale 4096
-depthfxpartblend 8
-depthfxparts 1
-depthfxscale 64
-depthfxsize 10
dynlightdist 1024
editinview 1
emitmillis 17
entcamdir 1
-envmapmodels 1
-envmapsize 7
explodebright 1.0
fewparticles 100
filltjoints 1
fixwav 1
-flarecutoff 1000
-flaresize 100
fov 100
-fpdepthfx 0
fpshadowmap 0
fullbrightmodels 60
fullconfilter 65535
gameclockx 0.5
gameclocky 0.03
gamma 100
-glare 1
-glarescale 1.0
-glaresize 8
-glassenv 1
-gpumipmap 0
gpuskel 1
-grass 1
-grassdist 256
-grassheight 4
-grassmargin 8
-grassstep 3.0
-grasstaper 0.2
gui2d 1
guiautotab 16
guiclicktab 0
guisens 1.0
healthcolors 1
hidedead 0
-hidefrags 1
+hidefrags 0
highlightscore 1
hitcrosshair 425
hitsound 0
+hudarmour 1
+hudarmourscale 1.0
+hudarmourx 1.0
+hudarmoury 1.0
hudgun 1
hudgunsdir ""
hudgunsway 1
+hudhealth 1
+hudhealthscale 1.0
+hudhealthx 0.0
+hudhealthy 1.0
+hudmaxhealth 1
+hudmaxhealthscale 1.0
+hudmaxhealthx 0.207
+hudmaxhealthy 0.97
hudscore 0
hudscorealign 0
hudscorealpha 255
jumpspawn 1
lightthreads 0
maxcon 200
-maxdebris 25
maxdecaldistance 512
maxdecaltris 1024
maxdynlights 5
maxparticledistance 1024
maxparticles 4000
maxparticletextdistance 128
-maxreflect 2
maxroll 0
maxservpings 10
maxsoundsatonce 7
miniconsize 5
miniconwidth 40
minimizedsounds 0
-motionblur 0
-motionblurmillis 5
-motionblurscale 0.5
mouseaccel 0.0
-mumble 1
musicvol 60
muzzleflash 1
muzzlelight 1
nompedit 1
outlinecolour 0
outlinemeters 0
-particleglare 2
particlesize 100
particletext 1
playermodel 0
-pvsthreads 0
ragdoll 1
ragdollfade 1000
ragdollmillis 10000
reducefilter 1
-reflectdist 2000
-reflectmms 1
-reflectsize 8
relativemouse 1
savebak 2
scoreboard2d 1
screenshotdir "screenshot"
-screenshotformat 2
+screenshotformat 1
screenshotquality 97
searchlan 0
sensitivity 3.0
shadowmapprecision 0
shadowmapradius 96
shadowmapsize 9
-showclientnum 0
+showclientnum 1
showconnecting 0
-showdeaths 0
+showdamagedealt 1
+showdeaths 1
showfps 1
showfpsrange 0
showmat 1
showping 1
showpj 0
showservinfo 1
-showspectatorping 0
+showspectatorping 1
showspectators 1
-skyboxglare 1
smoothdist 32
smoothmove 75
soundvol 255
-sparklyfix 0
spawnwait 0
+speedometer 1
+speedometeralpha 0.5
+speedometercolor 1
+speedometerscale 0.5
+speedometerx 0.5
+speedometery 0.6
statusbars 1
statusbarscale 1.0
statusicons 1
texguiwidth 15
texreduce 0
trilinear 1
-undomegs 8
usenp2 0
-vertwater 1
vsync 0
vsynctear 0
-wallclock 0
-wallclock24 0
-wallclocksecs 0
-waterenvmap 1
-waterfade 1
-waterfallenv 1
-waterfallrefract 1
-waterlod 1
-waterreflect 1
-waterrefract 1
-watersubdiv 2
zoomaccel 0.0
zoomautosens 1
zoomfov 35
editbind "F6" [notepad (mapcfgname)]
editbind "F9" [echo (getseltex) : (gettexname (getseltex))]
editbind "G" [domodifier 1]
-editbind "H" [if $hmapedit [ editface 1 -1 ] [ hmapedit 1 ]]
-editbind "I" [redo]
editbind "J" [gotosel]
editbind "K" [calclight]
-editbind "KP0" [setblendpaintmode 0]
-editbind "KP1" [setblendpaintmode 1]
-editbind "KP2" [setblendpaintmode 2]
-editbind "KP3" [setblendpaintmode 3]
-editbind "KP4" [setblendpaintmode 4]
-editbind "KP5" [setblendpaintmode 5]
-editbind "KP8" [scrollblendbrush -1]
-editbind "KP9" [scrollblendbrush 1]
editbind "KP_ENTER" [entselect insel]
editbind "L" [togglevar fullbright]
-editbind "LALT" [set hmapedit 1; onrelease [set hmapedit 0]]
editbind "LCTRL" [set passthrough 1; onrelease [set passthrough 0]]
editbind "LSHIFT" [editcut]
editbind "M" [togglevar showmat]
-editbind "MOUSE1" [if $blendpaintmode [paintblendmap] [editdrag]]
-editbind "MOUSE2" [if $blendpaintmode [rotateblendbrush] [editextend]]
+editbind "MOUSE1" [editdrag]
+editbind "MOUSE2" [editextend]
editbind "MOUSE3" [selcorners]
editbind "N" [selentfindall]
editbind "O" [domodifier 15]
editbind "R" [domodifier 4]
editbind "SPACE" [cancelsel]
editbind "T" [saycommand]
-editbind "U" [undo; passthroughsel 0]
editbind "V" [editpaste]
editbind "X" [editflip]
editbind "Y" [domodifier 6]
-editbind "Z" [undo; passthroughsel 0]
defaultmodifier = [0]
delta_edit_0 = [
- if $blendpaintmode [
- scrollblendbrush $arg1
- ] [
- editfacewentpush $arg1 1
- ]
+ editfacewentpush $arg1 1
]
delta_edit_1 = [ nodebug [ gridpower (+ $arg1 $gridpower) ] ]
delta_edit_10 = [ entautoview $arg1 ]
delta_edit_18 = [ vdelta [vscale (if (< $arg1 0) 0.5 2)] ]
delta_edit_2 = [ editfacewentpush $arg1 0 ]
delta_edit_3 = [ editfacewentpush $arg1 2 ]
-delta_edit_4 = [ if $blendpaintmode [rotateblendbrush $arg1] [editrotate $arg1] ]
delta_edit_5 = [ entproperty 0 $arg1 ]
delta_edit_6 = [ edittex $arg1 ]
-delta_edit_9 = [ selectbrush $arg1 ]
delta_game_0 = [ if (= $arg1 1) [ weapon 2 3 5 4 1 6 0 ] [ weapon 4 1 6 2 3 5 0 ] ]
domodifier = [ modifier = $arg1; onrelease [ modifier = $defaultmodifier ] ]
modifier = [0]
universaldelta = "^n do [delta_@(if $editing [ result edit ] [ result game ])_@modifier @arg1]^n"
listcomplete clearents [
- light mapmodel playerstart envmap particles sound
+ light mapmodel playerstart particles sound
shells bullets rockets riflerounds grenades cartridges
- health healthboost greenarmour yellowarmour quaddamage
- teleport teledest
- monster carrot jumppad
- base respawnpoint
- spotlight
- box barrel platform elevator
- flag
+ health healthboost tinyhealth tinyarmour greenarmour yellowarmour quaddamage
+ teleport teledest jumppad
]
complete coop "packages/maps" "ogz"
varcomplete demo "demodir" "dmo"
-listcomplete editmat [air water clip glass noclip lava gameclip death alpha]
+listcomplete editmat [air clip noclip gameclip death alpha]
complete effic "packages/maps" "ogz"
complete efficteam "packages/maps" "ogz"
listcomplete entfind [
- light mapmodel playerstart envmap particles sound
+ light mapmodel playerstart particles sound
shells bullets rockets riflerounds grenades cartridges
- health healthboost greenarmour yellowarmour quaddamage
- teleport teledest
- monster carrot jumppad
- base respawnpoint
- spotlight
- box barrel platform elevator
- flag
+ health healthboost tinyhealth tinyarmour greenarmour yellowarmour quaddamage
+ teleport teledest jumppad
]
complete ffa "packages/maps" "ogz"
complete insta "packages/maps" "ogz"
complete instateam "packages/maps" "ogz"
complete map "packages/maps" "ogz"
listcomplete newent [
- light mapmodel playerstart envmap particles sound
+ light mapmodel playerstart particles sound
shells bullets rockets riflerounds grenades cartridges
- health healthboost greenarmour yellowarmour quaddamage
- teleport teledest
- monster carrot jumppad
- base respawnpoint
- spotlight
- box barrel platform elevator
- flag
+ health healthboost tinyhealth tinyarmour greenarmour yellowarmour quaddamage
+ teleport teledest jumppad
]
complete teamplay "packages/maps" "ogz"
--- /dev/null
+// servers connected to are added here automatically
+
engine/command.o \
engine/console.o \
engine/decal.o \
- engine/dynlight.o \
engine/lightmap.o \
engine/main.o \
engine/material.o \
engine/decal.o: shared/iengine.h shared/igame.h engine/world.h engine/octa.h
engine/decal.o: engine/lightmap.h engine/bih.h engine/texture.h
engine/decal.o: engine/model.h
-engine/dynlight.o: engine/engine.h shared/cube.h shared/tools.h shared/geom.h
-engine/dynlight.o: shared/ents.h shared/command.h shared/glexts.h
-engine/dynlight.o: shared/glemu.h shared/iengine.h shared/igame.h
-engine/dynlight.o: engine/world.h engine/octa.h engine/lightmap.h
-engine/dynlight.o: engine/bih.h engine/texture.h engine/model.h
engine/lightmap.o: engine/engine.h shared/cube.h shared/tools.h shared/geom.h
engine/lightmap.o: shared/ents.h shared/command.h shared/glexts.h
engine/lightmap.o: shared/glemu.h shared/iengine.h shared/igame.h
hudmatrix.rotate_around_x(-90*RAD);
hudmatrix.scale(-scale.x, scale.y, scale.z);
vec dir;
- lightreaching(origin, light, dir, false, 0, 0.5f);
+ lightreaching(origin, light, dir, 0, 0.5f);
float intensity = vec(yaw, 0.0f).dot(dir);
light.mul(1.0f + max(intensity, 0.0f));
}
void setkey() {
key = &shaderparamskey::keys[*this];
}
- void setshaderparams(mesh *m, const animstate *as) {
+ void setshaderparams(const animstate *as) {
if(!Shader::lastshader) return;
float mincolor = as->cur.anim&ANIM_FULLBRIGHT ? fullbrightmodels/100.0f : 0.0f;
if(fullbright) {
//~if(force) cleanup();
loadshader();
}
- void setshader(mesh *m, const animstate *as) {
+ void setshader(mesh *m) {
m->setshader(loadshader());
}
void bind(mesh *b, const animstate *as) {
else /*if(as->cur.anim&ANIM_SHADOW)*/ SETMODELSHADER(b, notexturemodel);
return;
}
- setshader(b, as);
- setshaderparams(b, as);
+ setshader(b);
+ setshaderparams(as);
int activetmu = 0;
if(tex!=lasttex) {
glBindTexture(GL_TEXTURE_2D, tex->id);
bool hasframes(int i, int n) const { return i>=0 && i+n<=totalframes(); }
int clipframes(int i, int n) const { return min(n, totalframes() - i); }
virtual void cleanup() {}
- virtual void preload(part *p) {}
- virtual void render(const animstate *as, float pitch, const vec &axis, const vec &forward, dynent *d, part *p) {}
+ virtual void preload(part *) {}
+ virtual void render(const animstate *, float , const vec &, const vec &, dynent *, part *) {}
void bindpos(GLuint ebuf, GLuint vbuf, void *v, int stride) {
if(lastebuf!=ebuf) {
gle::bindebo(ebuf);
}
}
};
- virtual meshgroup *loadmeshes(const char *name, va_list args) { return NULL; }
+ virtual meshgroup *loadmeshes(const char *, va_list ) { return NULL; }
meshgroup *sharemeshes(const char *name, ...) {
static hashnameset<meshgroup *> meshgroups;
if(!meshgroups.access(name)) {
void abortconnect() {
if(!connpeer) return;
- game::connectfail();
+ memset(game::connectpass, 0, sizeof(game::connectpass));
if(connpeer->state!=ENET_PEER_STATE_DISCONNECTED) enet_peer_reset(connpeer);
connpeer = NULL;
if(curpeer) return;
enet_host_flush(clienthost);
connmillis = totalmillis;
connattempts = 0;
- game::connectattempt(servername ? servername : "", serverpassword ? serverpassword : "", address);
+ copystring(game::connectpass, serverpassword ? serverpassword : "");
}
void reconnect(const char *serverpassword) {
decalcenter = center;
decalradius = radius;
decalnormal = dir;
-#if 0
- decaltangent.orthogonal(dir);
-#else
decaltangent = vec(dir.z, -dir.x, dir.y);
decaltangent.sub(vec(dir).mul(decaltangent.dot(dir)));
-#endif
if(flags&DF_ROTATE) decaltangent.rotate(rnd(360)*RAD, dir);
decaltangent.normalize();
decalbitangent.cross(decaltangent, dir);
float facing = n.dot(decalnormal);
if(facing <= 0) continue;
vec p = vec(pos[0]).sub(decalcenter);
-#if 0
- // intersect ray along decal normal with plane
- float dist = n.dot(p) / facing;
- if(fabs(dist) > decalradius) continue;
- vec pcenter = vec(decalnormal).mul(dist).add(decalcenter);
-#else
// travel back along plane normal from the decal center
float dist = n.dot(p);
if(fabs(dist) > decalradius) continue;
vec pcenter = vec(n).mul(dist).add(decalcenter);
-#endif
vec ft, fb;
ft.orthogonal(n);
ft.normalize();
+++ /dev/null
-#include "engine.h"
-
-VARP(maxdynlights, 0, min(3, MAXDYNLIGHTS), MAXDYNLIGHTS);
-VARP(dynlightdist, 0, 1024, 10000);
-
-struct dynlight {
- vec o, hud;
- float radius, initradius, curradius, dist;
- vec color, initcolor, curcolor;
- int fade, peak, expire, flags;
- physent *owner;
- void calcradius() {
- if(fade + peak > 0) {
- int remaining = expire - lastmillis;
- if(flags&DL_EXPAND)
- curradius = initradius + (radius - initradius) * (1.0f - remaining/float(fade + peak));
- else if(!(flags&DL_FLASH) && remaining > fade)
- curradius = initradius + (radius - initradius) * (1.0f - float(remaining - fade)/peak);
- else if(flags&DL_SHRINK)
- curradius = (radius*remaining)/fade;
- else curradius = radius;
- }
- else curradius = radius;
- }
- void calccolor() {
- if(flags&DL_FLASH || peak <= 0) curcolor = color;
- else {
- int peaking = expire - lastmillis - fade;
- if(peaking <= 0) curcolor = color;
- else curcolor.lerp(initcolor, color, 1.0f - float(peaking)/peak);
- }
- float intensity = 1.0f;
- if(fade > 0) {
- int fading = expire - lastmillis;
- if(fading < fade) intensity = float(fading)/fade;
- }
- curcolor.mul(intensity);
- // KLUGE: this prevents nvidia drivers from trying to recompile dynlight fragment programs
- loopk(3) if(fmod(curcolor[k], 1.0f/256) < 0.001f) curcolor[k] += 0.001f;
- }
-};
-
-vector<dynlight> dynlights;
-vector<dynlight *> closedynlights;
-
-void adddynlight(const vec &o, float radius, const vec &color, int fade, int peak, int flags, float initradius, const vec &initcolor, physent *owner) {
- if(!maxdynlights) return;
- if(o.dist(camera1->o) > dynlightdist || radius <= 0) return;
- int insert = 0, expire = fade + peak + lastmillis;
- loopvrev(dynlights) if(expire>=dynlights[i].expire) { insert = i+1; break; }
- dynlight d;
- d.o = d.hud = o;
- d.radius = radius;
- d.initradius = initradius;
- d.color = color;
- d.initcolor = initcolor;
- d.fade = fade;
- d.peak = peak;
- d.expire = expire;
- d.flags = flags;
- d.owner = owner;
- dynlights.insert(insert, d);
-}
-
-void cleardynlights() {
- int faded = -1;
- loopv(dynlights) if(lastmillis<dynlights[i].expire) { faded = i; break; }
- if(faded<0) dynlights.setsize(0);
- else if(faded>0) dynlights.remove(0, faded);
-}
-
-void removetrackeddynlights(physent *owner) {
- loopvrev(dynlights) if(owner ? dynlights[i].owner == owner : dynlights[i].owner != NULL) dynlights.remove(i);
-}
-
-void updatedynlights() {
- cleardynlights();
- game::adddynlights();
- loopv(dynlights) {
- dynlight &d = dynlights[i];
- if(d.owner) game::dynlighttrack(d.owner, d.o, d.hud);
- d.calcradius();
- d.calccolor();
- }
-}
-
-int finddynlights() {
- closedynlights.setsize(0);
- if(!maxdynlights) return 0;
- physent e;
- e.type = ENT_CAMERA;
- loopvj(dynlights) {
- dynlight &d = dynlights[j];
- if(d.curradius <= 0) continue;
- d.dist = camera1->o.dist(d.o) - d.curradius;
- if(d.dist > dynlightdist)
- continue;
- e.o = d.o;
- e.radius = e.xradius = e.yradius = e.eyeheight = e.aboveeye = d.curradius;
- if(!collide(&e, vec(0, 0, 0), 0, false)) continue;
- int insert = 0;
- loopvrev(closedynlights) if(d.dist >= closedynlights[i]->dist) { insert = i+1; break; }
- closedynlights.insert(insert, &d);
- if(closedynlights.length() >= DYNLIGHTMASK) break;
- }
- return closedynlights.length();
-}
-
-bool getdynlight(int n, vec &o, float &radius, vec &color) {
- if(!closedynlights.inrange(n)) return false;
- dynlight &d = *closedynlights[n];
- o = d.o;
- radius = d.curradius;
- color = d.curcolor;
- return true;
-}
-
-void dynlightreaching(const vec &target, vec &color, vec &dir, bool hud) {
- vec dyncolor(0, 0, 0);//, dyndir(0, 0, 0);
- loopv(dynlights) {
- dynlight &d = dynlights[i];
- if(d.curradius<=0) continue;
- vec ray(hud ? d.hud : d.o);
- ray.sub(target);
- float mag = ray.squaredlen();
- if(mag >= d.curradius*d.curradius) continue;
- vec color = d.curcolor;
- color.mul(1 - sqrtf(mag)/d.curradius);
- dyncolor.add(color);
- //dyndir.add(ray.mul(intensity/mag));
- }
-#if 0
- if(!dyndir.iszero()) {
- dyndir.normalize();
- float x = dyncolor.magnitude(), y = color.magnitude();
- if(x+y>0) {
- dir.mul(x);
- dyndir.mul(y);
- dir.add(dyndir).div(x+y);
- if(dir.iszero()) dir = vec(0, 0, 1);
- else dir.normalize();
- }
- }
-#endif
- color.add(dyncolor);
-}
-
-void calcdynlightmask(vtxarray *va) {
- uint mask = 0;
- int offset = 0;
- loopv(closedynlights) {
- dynlight &d = *closedynlights[i];
- if(d.o.dist_to_bb(va->geommin, va->geommax) >= d.curradius) continue;
- mask |= (i+1)<<offset;
- offset += DYNLIGHTBITS;
- if(offset >= maxdynlights*DYNLIGHTBITS) break;
- }
- va->dynlightmask = mask;
-}
-
-int setdynlights(vtxarray *va) {
- if(closedynlights.empty() || !va->dynlightmask) return 0;
- extern bool minimizedynlighttcusage();
- static vec4 posv[MAXDYNLIGHTS];
- static vec colorv[MAXDYNLIGHTS];
- int index = 0;
- for(uint mask = va->dynlightmask; mask; mask >>= DYNLIGHTBITS, index++) {
- dynlight &d = *closedynlights[(mask&DYNLIGHTMASK)-1];
- float scale = 1.0f/d.curradius;
- vec origin = vec(d.o).mul(-scale);
- if(index>0 && minimizedynlighttcusage()) {
- scale /= posv[0].w;
- origin.sub(vec(posv[0]).mul(scale));
- }
- posv[index] = vec4(origin, scale);
- colorv[index] = d.curcolor;
- }
- GLOBALPARAMV(dynlightpos, posv, index);
- GLOBALPARAMV(dynlightcolor, colorv, index);
- return index;
-}
extern int hwtexsize, hwcubetexsize, hwmaxaniso, maxtexsize;
extern Texture *textureload(const char *name, int clamp = 0, bool mipit = true, bool msg = true);
-extern int texalign(const void *data, int w, int bpp);
+extern int texalign(int w, int bpp);
extern void cleanuptexture(Texture *t);
extern uchar *loadalphamask(Texture *t);
extern void loadlayermasks();
extern void loadshaders();
-extern void setuptexparameters(int tnum, void *pixels, int clamp, int filter, GLenum format = GL_RGB, GLenum target = GL_TEXTURE_2D, bool swizzle = false);
-extern void createtexture(int tnum, int w, int h, void *pixels, int clamp, int filter, GLenum component = GL_RGB, GLenum target = GL_TEXTURE_2D, int pw = 0, int ph = 0, int pitch = 0, bool resize = true, GLenum format = GL_FALSE, bool swizzle = false);
+extern void setuptexparameters(int tnum, int clamp, int filter, GLenum format = GL_RGB, GLenum target = GL_TEXTURE_2D);
+extern void createtexture(int tnum, int w, int h, void *pixels, int clamp, int filter, GLenum component = GL_RGB, GLenum target = GL_TEXTURE_2D, int pw = 0, int ph = 0, int pitch = 0, bool resize = true, GLenum format = GL_FALSE);
extern void blurtexture(int n, int bpp, int w, int h, uchar *dst, const uchar *src, int margin = 0);
extern void blurnormals(int n, int w, int h, bvec *dst, const bvec *src, int margin = 0);
extern bool reloadtexture(Texture &tex);
extern int oqfrags;
-// dynlight
-
-extern void updatedynlights();
-extern int finddynlights();
-extern void calcdynlightmask(vtxarray *va);
-extern int setdynlights(vtxarray *va);
-extern bool getdynlight(int n, vec &o, float &radius, vec &color);
-
// material
extern int showmat;
// serverbrowser
extern bool resolverwait(const char *name, ENetAddress *address);
-extern int connectwithtimeout(ENetSocket sock, const char *hostname, const ENetAddress &address);
+extern int connectwithtimeout(ENetSocket sock, const ENetAddress &address);
extern void addserver(const char *name, int port = 0, const char *password = NULL, bool keep = false);
extern void writeservercfg();
extern void renderprogress(float bar, const char *text, GLuint tex = 0, bool background = false);
extern void getfps(int &fps, int &bestdiff, int &worstdiff);
-extern void swapbuffers(bool overlay = true);
+extern void swapbuffers();
extern int getclockmillis();
enum { KR_CONSOLE = 1<<0, KR_GUI = 1<<1, KR_EDITMODE = 1<<2 };
extern void g3d_mainmenu();
// sound
-extern void clearmapsounds();
-extern void checkmapsounds();
extern void updatesounds();
-extern void preloadmapsounds();
#endif
int bpp = lm.bpp;
if(tasklock) SDL_UnlockMutex(tasklock);
glBindTexture(GL_TEXTURE_2D, progresstex);
- glPixelStorei(GL_UNPACK_ALIGNMENT, texalign(data, LM_PACKW, bpp));
+ glPixelStorei(GL_UNPACK_ALIGNMENT, texalign(LM_PACKW, bpp));
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, LM_PACKW, LM_PACKH, bpp > 3 ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, data);
}
renderprogress(bar1, text1, progresstexticks ? progresstex : 0);
return false;
}
-static inline void generatealpha(lightmapworker *w, float tolerance, const vec &pos, uchar &alpha) {
+static inline void generatealpha(lightmapworker *w, const vec &pos, uchar &alpha) {
alpha = 0;
if(w->slot->layermask) {
static const int sdim[] = { 1, 0, 0 }, tdim[] = { 2, 2, 1 };
static int previewlightmapalpha(lightmapworker *w, float lpu, const vec &origin1, const vec &xstep1, const vec &ystep1, const vec &origin2, const vec &xstep2, const vec &ystep2, float side0, float sidestep) {
extern int fullbrightlevel;
- float tolerance = 0.5 / lpu;
uchar *dst = w->colorbuf;
uchar minalpha = 255, maxalpha = 0;
float sidex = side0;
vec(xstep1).mul(x).add(vec(ystep1).mul(y)).add(origin1) :
vec(xstep2).mul(x).add(vec(ystep2).mul(y)).add(origin2);
loopk(3) dst[k] = fullbrightlevel;
- generatealpha(w, tolerance, u, dst[3]);
+ generatealpha(w, u, dst[3]);
minalpha = min(minalpha, dst[3]);
maxalpha = max(maxalpha, dst[3]);
}
return lce.lights;
}
-static inline void addlight(lightmapworker *w, const extentity &light, int cx, int cy, int cz, int size, const vec *v, const vec *n, int numv) {
+static inline void addlight(lightmapworker *w, const extentity &light, int cx, int cy, int cz, int size, const vec *v, const vec *n) {
int radius = light.attr1;
if(radius > 0) {
if(light.o.x + radius < cx || light.o.x - radius > cx + size ||
}
}
-static bool findlights(lightmapworker *w, int cx, int cy, int cz, int size, const vec *v, const vec *n, int numv, const Slot &slot, const VSlot &vslot) {
+static bool findlights(lightmapworker *w, int cx, int cy, int cz, int size, const vec *v, const vec *n, const VSlot &vslot) {
w->lights.setsize(0);
const vector<extentity *> &ents = entities::getents();
static volatile bool usinglightcache = false;
loopv(lights) {
const extentity &light = *ents[lights[i]];
switch(light.type) {
- case ET_LIGHT: addlight(w, light, cx, cy, cz, size, v, n, numv); break;
+ case ET_LIGHT: addlight(w, light, cx, cy, cz, size, v, n); break;
}
}
if(lightlock) { usinglightcache = false; SDL_UnlockMutex(lightlock); }
else loopv(ents) {
const extentity &light = *ents[i];
switch(light.type) {
- case ET_LIGHT: addlight(w, light, cx, cy, cz, size, v, n, numv); break;
+ case ET_LIGHT: addlight(w, light, cx, cy, cz, size, v, n); break;
}
}
if(vslot.layer) return true;
numlitverts += numverts;
}
}
- if(!findlights(w, mo.x, mo.y, mo.z, msz, pos, n, numverts, *vslot.slot, vslot)) {
+ if(!findlights(w, mo.x, mo.y, mo.z, msz, pos, n, vslot)) {
if(surf.numverts&MAXFACEVERTS) surf.numverts |= LAYER_TOP;
continue;
}
}
static Uint32 calclighttimer(Uint32 interval, void *param) {
+ (void) param;
check_calclight_progress = true;
return interval;
}
}
else if(e.type>=ET_GAMESPECIFIC) ambient = 0.4f;
vec target(e.o.x, e.o.y, e.o.z + height);
- lightreaching(target, e.light.color, e.light.dir, false, &e, ambient);
+ lightreaching(target, e.light.color, e.light.dir, &e, ambient);
}
void lightents(bool force) {
shouldlightents = true;
}
-void lightreaching(const vec &target, vec &color, vec &dir, bool fast, extentity *t, float ambient) {
+void lightreaching(const vec &target, vec &color, vec &dir, extentity *t, float ambient) {
if((fullbright && editmode) || lightmaps.empty()) {
color = vec(1, 1, 1);
dir = vec(0, 0, 1);
}
}
glDisable(GL_BLEND);
- if(!restore) swapbuffers(false);
+ if(!restore) swapbuffers();
}
if(!restore) setbackgroundinfo(caption, mapshot, mapname, mapinfo);
}
bgquad(x, y, sz, sz);
glDisable(GL_BLEND);
}
- swapbuffers(false);
+ swapbuffers();
}
int keyrepeatmask = 0, textinputmask = 0;
static int interceptkeysym = 0;
static int interceptevents(void *data, SDL_Event *event) {
+ (void) data;
switch(event->type) {
case SDL_MOUSEMOTION: return 0;
case SDL_KEYDOWN:
if(mousemoved) resetmousemotion();
}
-void swapbuffers(bool overlay) {
+void swapbuffers() {
gle::disable();
SDL_GL_SwapWindow(screen);
}
bool inbetweenframes = false, renderedframe = true;
-static bool findarg(int argc, char **argv, const char *str) {
- for(int i = 1; i<argc; i++) if(strstr(argv[i], str)==argv[i]) return true;
- return false;
-}
-
static int clockrealbase = 0, clockvirtbase = 0;
static void clockreset() { clockrealbase = SDL_GetTicks(); clockvirtbase = totalmillis; }
VARFP(clockerror, 990000, 1000000, 1010000, clockreset());
occludequery *query;
vector<octaentities *> mapmodels;
int hasmerges, mergelevel;
- uint dynlightmask;
bool shadowed;
};
extern void entdrag(const vec &ray);
extern bool hoveringonent(int ent, int orient);
-extern void renderentselection(const vec &o, bool entmoving);
+extern void renderentselection(bool entmoving);
extern float rayent(const vec &o, const vec &ray, float radius, int mode, int size, int &orient, int &ent);
VAR(gridlookup, 0, 0, 1);
glBlendFunc(GL_ONE, GL_ONE);
// cursors
notextureshader->set();
- renderentselection(player->o, entmoving!=0);
+ renderentselection(entmoving!=0);
boxoutline = outline!=0;
enablepolygonoffset(GL_POLYGON_OFFSET_LINE);
if(!moving && !hovering && !hidecursor) {
VARP(nompedit, 0, 1, 1);
-static inline int countblock(cube *c, int n = 8) {
- int r = 0;
- loopi(n) if(c[i].children) r += countblock(c[i].children); else ++r;
- return r;
-}
-
-static int countblock(block3 *b) { return countblock(b->c(), b->size()); }
-
vector<editinfo *> editinfos;
editinfo *localedit = NULL;
}
void landing(physent *d, vec &dir, const vec &floor, bool collided) {
-#if 0
- if(d->physstate == PHYS_FALL) {
- d->timeinair = 0;
- if(dir.z < 0.0f) dir.z = d->vel.z = 0.0f;
- }
-#endif
switchfloor(d, dir, floor);
d->timeinair = 0;
if((d->physstate!=PHYS_STEP_UP && d->physstate!=PHYS_STEP_DOWN) || !collided)
FVAR(faderoll, 0, 0.95f, 1);
VAR(floatspeed, 1, 100, 10000);
-void modifyvelocity(physent *pl, bool local, bool floating, int curtime) {
+void modifyvelocity(physent *pl, bool floating, int curtime) {
bool allowmove = game::allowmove(pl);
if(floating) {
if(pl->jumping && allowmove) {
// local is false for multiplayer prediction
bool moveplayer(physent *pl, int moveres, bool local, int curtime) {
+ (void) local;
int material = lookupmaterial(vec(pl->o.x, pl->o.y, pl->o.z + (3*pl->aboveeye - pl->eyeheight)/4));
bool floating = pl->type==ENT_PLAYER && (pl->state==CS_EDITING || pl->state==CS_SPECTATOR);
float secs = curtime/1000.f;
// apply gravity
if(!floating) modifygravity(pl, curtime);
// apply any player generated changes in velocity
- modifyvelocity(pl, local, floating, curtime);
+ modifyvelocity(pl, floating, curtime);
vec d(pl->vel);
if(!floating) d.mul(0.5f);
d.add(pl->falling);
pl->falling = vec(0, 0, 0);
}
pl->o.add(d);
- }
- else { // apply velocity with collision {
+ } else { // apply velocity with collision {
const float f = 1.0f/moveres;
const int timeinair = pl->timeinair;
int collisions = 0;
glIsVertexArray_ = (PFNGLISVERTEXARRAYPROC) getprocaddress("glIsVertexArrayAPPLE");
hasVAO = true;
}
- if(glversion >= 330 || hasext("GL_ARB_texture_swizzle") || hasext("GL_EXT_texture_swizzle")) {
- hasTSW = true;
- }
if(hasext("GL_EXT_texture_compression_s3tc")) {
hasS3TC = true;
if(!mesa) usetexcompress = 2;
}
if(glversion >= 300 || hasext("GL_EXT_gpu_shader4")) {
// on DX10 or above class cards (i.e. GF8 or RadeonHD) enable expensive features
- extern int maxdynlights, texcompress;
- maxdynlights = MAXDYNLIGHTS;
+ extern int texcompress;
texcompress = max(texcompress, 1024 + 1);
}
}
void gl_drawframe() {
if(deferdrawtextures) drawtextures();
- updatedynlights();
int w = screenw, h = screenh;
aspect = forceaspect ? forceaspect : w/float(h);
fovy = 2*atan2(tan(curfov/2*RAD), aspect)/RAD;
mmi.m = NULL;
}
-void mapmodelcompat(int *rad, int *h, int *tex, char *name, char *shadow) {
- mmodel(name);
-}
-
void mapmodelreset(int *n) {
if(!(identflags&IDF_OVERRIDDEN) && !game::allowedittoggle()) return;
mapmodels.shrink(clamp(*n, 0, mapmodels.length()));
const char *mapmodelname(int i) { return mapmodels.inrange(i) ? mapmodels[i].name : NULL; }
COMMAND(mmodel, "s");
-COMMANDN(mapmodel, mapmodelcompat, "iiiss");
COMMAND(mapmodelreset, "i");
ICOMMAND(mapmodelname, "i", (int *index), { result(mapmodels.inrange(*index) ? mapmodels[*index].name : ""); });
ICOMMAND(mapmodelloaded, "i", (int *index), { intret(mapmodels.inrange(*index) && mapmodels[*index].m ? 1 : 0); });
endbb();
}
-static inline int cullmodel(model *m, const vec ¢er, float radius, int flags, dynent *d = NULL, bool shadow = false) {
+static inline int cullmodel(const vec ¢er, float radius, int flags, dynent *d = NULL) {
if(flags&MDL_CULL_DIST && center.dist(camera1->o)/radius>maxmodelradiusdistance) return MDL_CULL_DIST;
if(flags&MDL_CULL_VFC) {
if(shadowmapping && !isshadowmapcaster(center, radius)) return MDL_CULL_VFC;
center.rotate_around_z(yaw*RAD);
center.add(o);
}
- int culled = cullmodel(m, center, radius, flags, d, shadow);
+ int culled = cullmodel(center, radius, flags, d);
if(culled) {
if(culled&(MDL_CULL_OCCLUDED|MDL_CULL_QUERY) && flags&MDL_CULL_QUERY) {
enablecullmodelquery();
pos.z += radius/2;
}
else if(d->type < ENT_CAMERA) pos.z += 0.75f*(d->eyeheight + d->aboveeye);
- lightreaching(pos, light->color, light->dir, (flags&MDL_LIGHT_FAST)!=0);
- dynlightreaching(pos, light->color, light->dir, (flags&MDL_HUD)!=0);
+ lightreaching(pos, light->color, light->dir);
light->millis = lastmillis;
}
}
else if(flags&MDL_LIGHT) {
if(!light) {
- lightreaching(pos, lightcolor, lightdir, (flags&MDL_LIGHT_FAST)!=0);
- dynlightreaching(pos, lightcolor, lightdir, (flags&MDL_HUD)!=0);
+ lightreaching(pos, lightcolor, lightdir);
}
else if(light->millis!=lastmillis) {
- lightreaching(pos, light->color, light->dir, (flags&MDL_LIGHT_FAST)!=0);
- dynlightreaching(pos, light->color, light->dir, (flags&MDL_HUD)!=0);
+ lightreaching(pos, light->color, light->dir);
light->millis = lastmillis;
}
}
if(light) { lightcolor = light->color; lightdir = light->dir; }
- if(flags&MDL_DYNLIGHT) dynlightreaching(pos, lightcolor, lightdir, (flags&MDL_HUD)!=0);
}
if(a) for(int i = 0; a[i].tag; i++) {
if(a[i].name) a[i].m = loadmodel(a[i].name);
virtual void render() = 0;
virtual bool haswork() = 0;
virtual void cleanup() {}
- virtual void seedemitter(particleemitter &pe, const vec &o, const vec &d, int fade, float size, int gravity) {
+ virtual void seedemitter(particleemitter &, const vec &, const vec &, int , float , int ) {
}
//blend = 0 => remove it
void calc(particle *p, int &blend, int &ts, vec &o, vec &d, bool step = true) {
};
static texticonrenderer texticons("packages/hud/items.png", PT_TEXTICON|PT_LERP);
-template<int T>
-static inline void modifyblend(const vec &o, int &blend) {
- blend = min(blend<<2, 255);
-}
-
-template<>
-inline void modifyblend<PT_TAPE>(const vec &o, int &blend) {
-}
-
template<int T>
static inline void genpos(const vec &o, const vec &d, float size, int grav, int ts, partvert *vs) {
+ (void) o; (void) size; (void) d; (void) grav; (void) ts; (void) vs;
vec udir = vec(camup).sub(camright).mul(size);
vec vdir = vec(camup).add(camright).mul(size);
vs[0].pos = vec(o.x + udir.x, o.y + udir.y, o.z + udir.z);
template<>
inline void genpos<PT_TAPE>(const vec &o, const vec &d, float size, int ts, int grav, partvert *vs) {
+ (void) o; (void) size; (void) d; (void) grav; (void) ts; (void) vs;
vec dir1 = d, dir2 = d, c;
dir1.sub(o);
dir2.sub(camera1->o);
template<>
inline void genpos<PT_TRAIL>(const vec &o, const vec &d, float size, int ts, int grav, partvert *vs) {
+ (void) o; (void) size; (void) d; (void) grav; (void) ts; (void) vs;
vec e = d;
if(grav) e.z -= float(ts)/grav;
e.div(-75.0f).add(o);
template<int T>
static inline void genrotpos(const vec &o, const vec &d, float size, int grav, int ts, partvert *vs, int rot) {
+ (void) o; (void) size; (void) d; (void) grav; (void) ts; (void) vs; (void) rot;
genpos<T>(o, d, size, grav, ts, vs);
}
template<>
inline void genrotpos<PT_PART>(const vec &o, const vec &d, float size, int grav, int ts, partvert *vs, int rot) {
+ (void) o; (void) size; (void) d; (void) grav; (void) ts; (void) vs; (void) rot;
const vec *coeffs = rotcoeffs[rot];
(vs[0].pos = o).add(vec(camright).mul(coeffs[0].x*size)).add(vec(camup).mul(coeffs[0].y*size));
(vs[1].pos = o).add(vec(camright).mul(coeffs[1].x*size)).add(vec(camup).mul(coeffs[1].y*size));
int blend, ts;
calc(p, blend, ts, o, d);
if(blend <= 1 || p->fade <= 5) p->fade = -1; //mark to remove on next pass (i.e. after render)
- modifyblend<T>(o, blend);
+ blend = min(blend<<2, 255);
if(regen) {
p->flags &= ~0x80;
#define SETTEXCOORDS(u1c, u2c, v1c, v2c, body) { \
VSlot *vslot, *texgenvslot;
vec2 texgenscroll;
int texgendim;
- int visibledynlights;
- uint dynlightmask;
- renderstate() : colormask(true), depthmask(true), blending(false), alphaing(0), vbuf(0), vattribs(false), vquery(false), colorscale(1, 1, 1), alphascale(0), slot(NULL), texgenslot(NULL), vslot(NULL), texgenvslot(NULL), texgenscroll(0, 0), texgendim(-1), visibledynlights(0), dynlightmask(0) {
+ renderstate() : colormask(true), depthmask(true), blending(false), alphaing(0), vbuf(0), vattribs(false), vquery(false), colorscale(1, 1, 1), alphascale(0), slot(NULL), texgenslot(NULL), vslot(NULL), texgenvslot(NULL), texgenscroll(0, 0), texgendim(-1) {
loopk(8) textures[k] = 0;
}
};
int compare(const geombatch &b) const {
if(va->vbuf < b.va->vbuf) return -1;
if(va->vbuf > b.va->vbuf) return 1;
- if(va->dynlightmask < b.va->dynlightmask) return -1;
- if(va->dynlightmask > b.va->dynlightmask) return 1;
if(vslot.slot->shader < b.vslot.slot->shader) return -1;
if(vslot.slot->shader > b.vslot.slot->shader) return 1;
if(vslot.slot->params.length() < b.vslot.slot->params.length()) return -1;
tmu++;
}
if(changed) glActiveTexture_(GL_TEXTURE0);
- if(cur.dynlightmask != b.va->dynlightmask) {
- cur.visibledynlights = setdynlights(b.va);
- cur.dynlightmask = b.va->dynlightmask;
- }
}
static void changeslottmus(renderstate &cur, int pass, Slot &slot, VSlot &vslot) {
cur.vslot = &vslot;
}
-static void changeshader(renderstate &cur, Shader *s, Slot &slot, VSlot &vslot, bool shadowed) {
- if(!cur.blending && !cur.alphaing) {
- if(shadowed) s->setvariant(cur.visibledynlights, 3, slot, vslot);
- else s->setvariant(cur.visibledynlights, 2, slot, vslot);
- }
- else if(shadowed) s->setvariant(cur.visibledynlights, 1, slot, vslot);
- else if(!cur.visibledynlights) s->set(slot, vslot);
- else s->setvariant(cur.visibledynlights-1, 0, slot, vslot);
-}
-
static void changetexgen(renderstate &cur, int dim, Slot &slot, VSlot &vslot) {
if(cur.texgenslot != &slot || cur.texgenvslot != &vslot) {
Texture *curtex = !cur.texgenslot || cur.texgenslot->sts.empty() ? notexture : cur.texgenslot->sts[0].t,
ushort len = curbatch->es.length[curbatch->va->shadowed ? 0 : 1];
if(len) {
if(rendered < 0) {
- changeshader(cur, b.vslot.slot->shader, *b.vslot.slot, b.vslot, false);
rendered = 0;
gbatches++;
}
if(shadowed) for(geombatch *curbatch = shadowed;; curbatch = &geombatches[curbatch->batch]) {
if(curbatch->va->shadowed && curbatch->es.length[1] > curbatch->es.length[0]) {
if(rendered < 1) {
- changeshader(cur, b.vslot.slot->shader, *b.vslot.slot, b.vslot, true);
rendered = 1;
gbatches++;
}
case RENDERPASS_LIGHTMAP:
if(!cur.alphaing) vverts += va->verts;
va->shadowed = false;
- va->dynlightmask = 0;
if(!drawtex && !cur.alphaing) {
va->shadowed = isshadowmapreceiver(va);
- calcdynlightmask(va);
}
if(doquery) startvaquery(va, { if(geombatches.length()) renderbatches(cur, pass); });
mergetexs(cur, va);
cleanupbb();
}
-void setupgeom(renderstate &cur) {
+void setupgeom() {
GLOBALPARAMF(colorparams, 2, 2, 2, 1);
GLOBALPARAM(camera, camera1->o);
GLOBALPARAMF(ambient, ambientcolor.x/255.0f, ambientcolor.y/255.0f, ambientcolor.z/255.0f);
}
if(!doZP) {
if(shadowmap && mainpass) rendershadowmap();
- setupgeom(cur);
+ setupgeom();
if(doSM) pushshadowmap();
}
- finddynlights();
resetbatches();
int blends = 0;
for(vtxarray *va = visibleva; va; va = va->next) {
if(doZP) {
glFlush();
if(shadowmap && mainpass) rendershadowmap();
- setupgeom(cur);
+ setupgeom();
if(doSM) pushshadowmap();
if(!multipassing) { multipassing = true; glDepthFunc(GL_LEQUAL); }
cur.texgendim = -1;
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
if(cur.vattribs) disablevattribs(cur, false);
if(cur.vbuf) disablevbuf(cur);
- setupgeom(cur);
+ setupgeom();
glDepthFunc(GL_LEQUAL);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
}
void conoutfv(int type, const char *fmt, va_list args) {
+ (void) type;
logoutfv(fmt, args);
}
#endif
return enet_address_set_host(address, name) >= 0;
}
-int connectwithtimeout(ENetSocket sock, const char *hostname, const ENetAddress &remoteaddress) {
+int connectwithtimeout(ENetSocket sock, const ENetAddress &remoteaddress) {
return enet_socket_connect(sock, &remoteaddress);
}
#endif
if(wait || serveraddress.host == ENET_HOST_ANY || !enet_socket_bind(sock, &serveraddress)) {
enet_socket_set_option(sock, ENET_SOCKOPT_NONBLOCK, 1);
if(wait) {
- if(!connectwithtimeout(sock, mastername, masteraddress)) return sock;
+ if(!connectwithtimeout(sock, masteraddress)) return sock;
}
else if(!enet_socket_connect(sock, &masteraddress)) return sock;
}
#endif
#ifdef STANDALONE
-int main(int argc, char **argv) {
+int main(void) {
if(enet_initialize()<0) fatal("Unable to initialise network module");
atexit(enet_deinitialize);
enet_time_set(0);
#define CONNLIMIT 20000
-int connectwithtimeout(ENetSocket sock, const char *hostname, const ENetAddress &address) {
- defformatstring(text, "connecting to %s... (esc to abort)", hostname);
+int connectwithtimeout(ENetSocket sock, const ENetAddress &address) {
+ defformatstring(text, "connecting to server... (esc to abort)");
renderprogress(0, text);
ENetSocketSet readset, writeset;
if(!enet_socket_connect(sock, &address)) for(int starttime = SDL_GetTicks(), timeout = 0; timeout <= CONNLIMIT;) {
bool Shader::isnull(const Shader *s) { return !s; }
-static void genattriblocs(Shader &s, const char *vs, const char *ps, Shader *reusevs, Shader *reuseps) {
+static void genattriblocs(Shader &s, const char *vs, Shader *reusevs) {
static int len = strlen("//:attrib");
string name;
int loc;
}
}
-static void genuniformlocs(Shader &s, const char *vs, const char *ps, Shader *reusevs, Shader *reuseps) {
+static void genuniformlocs(Shader &s, const char *vs, Shader *reusevs) {
static int len = strlen("//:uniform");
string name, blockname;
int binding, stride;
else loopv(slotparams) s.defaultparams.add(slotparams[i]);
s.attriblocs.setsize(0);
s.uniformlocs.setsize(0);
- genattriblocs(s, vs, ps, s.reusevs, s.reuseps);
- genuniformlocs(s, vs, ps, s.reusevs, s.reuseps);
+ genattriblocs(s, vs, s.reusevs);
+ genuniformlocs(s, vs, s.reusevs);
if(!s.compile()) {
s.cleanup(true);
if(variant) shaders.remove(rname);
newshader(s.type, varname, vschanged ? vsv.getbuf() : reuse, pschanged ? psv.getbuf() : reuse, &s, row);
}
-bool minimizedynlighttcusage() { return glversion < 300 && maxvaryings < 48; }
-
-static void gendynlightvariant(Shader &s, const char *sname, const char *vs, const char *ps, int row = 0) {
- int numlights = minimizedynlighttcusage() ? 1 : MAXDYNLIGHTS;
- const char *vspragma = strstr(vs, "//:dynlight"), *pspragma = strstr(ps, "//:dynlight");
- if(!vspragma || !pspragma) return;
- string pslight;
- vspragma += strcspn(vspragma, "\n");
- if(*vspragma) vspragma++;
- if(sscanf(pspragma, "//:dynlight %100s", pslight)!=1) return;
- pspragma += strcspn(pspragma, "\n");
- if(*pspragma) pspragma++;
- const char *vsmain = findglslmain(vs), *psmain = findglslmain(ps);
- if(vsmain > vspragma) vsmain = vs;
- if(psmain > pspragma) psmain = ps;
- vector<char> vsdl, psdl;
- loopi(MAXDYNLIGHTS) {
- vsdl.setsize(0);
- psdl.setsize(0);
- if(vsmain >= vs) vsdl.put(vs, vsmain - vs);
- if(psmain >= ps) psdl.put(ps, psmain - ps);
- defformatstring(pos, "uniform vec4 dynlightpos[%d];\n", i+1);
- vsdl.put(pos, strlen(pos));
- psdl.put(pos, strlen(pos));
- defformatstring(color, "uniform vec3 dynlightcolor[%d];\n", i+1);
- psdl.put(color, strlen(color));
- loopk(min(i+1, numlights)) {
- defformatstring(dir, "%sdynlight%ddir%s", !k ? "varying vec3 " : " ", k, k==i || k+1==numlights ? ";\n" : ",");
- vsdl.put(dir, strlen(dir));
- psdl.put(dir, strlen(dir));
- }
- vsdl.put(vsmain, vspragma-vsmain);
- psdl.put(psmain, pspragma-psmain);
- loopk(i+1) {
- defformatstring(tc,
- k<numlights ?
- "dynlight%ddir = vvertex.xyz*dynlightpos[%d].w + dynlightpos[%d].xyz;\n" :
- "vec3 dynlight%ddir = dynlight0dir*dynlightpos[%d].w + dynlightpos[%d].xyz;\n",
- k, k, k);
- if(k < numlights) vsdl.put(tc, strlen(tc));
- else psdl.put(tc, strlen(tc));
- defformatstring(dl,
- "%s.rgb += dynlightcolor[%d] * (1.0 - clamp(dot(dynlight%ddir, dynlight%ddir), 0.0, 1.0));\n",
- pslight, k, k, k);
- psdl.put(dl, strlen(dl));
- }
- vsdl.put(vspragma, strlen(vspragma)+1);
- psdl.put(pspragma, strlen(pspragma)+1);
- defformatstring(name, "<dynlight %d>%s", i+1, sname);
- Shader *variant = newshader(s.type, name, vsdl.getbuf(), psdl.getbuf(), &s, row);
- if(!variant) return;
- }
-}
-
static void genshadowmapvariant(Shader &s, const char *sname, const char *vs, const char *ps, int row = 1) {
const char *vspragma = strstr(vs, "//:shadowmap"), *pspragma = strstr(ps, "//:shadowmap");
if(!vspragma || !pspragma) return;
defformatstring(name, "<shadowmap>%s", sname);
Shader *variant = newshader(s.type, name, vssm.getbuf(), pssm.getbuf(), &s, row);
if(!variant) return;
- if(strstr(vs, "//:dynlight")) gendynlightvariant(s, name, vssm.getbuf(), pssm.getbuf(), row);
}
static void genuniformdefs(vector<char> &vsbuf, vector<char> &psbuf, const char *vs, const char *ps, Shader *variant = NULL) {
Shader *s = newshader(*type, name, vs, ps);
if(s) {
if(strstr(vs, "//:shadowmap")) genshadowmapvariant(*s, s->name, vs, ps);
- if(strstr(vs, "//:dynlight")) gendynlightvariant(*s, s->name, vs, ps);
}
slotparams.shrink(0);
}
GENSHADER(s->defaultparams.length(), genuniformdefs(vsbuf, psbuf, vs, ps, s));
Shader *v = newshader(*type, varname, vs, ps, s, *row);
if(v) {
- if(strstr(vs, "//:dynlight")) gendynlightvariant(*s, varname, vs, ps, *row);
if(strstr(ps, "//:variant") || strstr(vs, "//:variant")) gengenericvariant(*s, varname, vs, ps, *row);
}
}
vec center = vec(va->shadowmapmin).add(vec(va->shadowmapmax)).mul(0.5f);
calcshadowmapbb(center, xyrad, zrad, x1, y1, x2, y2);
return shadowmaptex.checkblurtiles(x1, y1, x2, y2, 2);
-
-#if 0
- // cheaper inexact test
- float dz = va->o.z + va->size/2 - shadowfocus.z;
- float cx = shadowfocus.x + dz*shadowdir.x, cy = shadowfocus.y + dz*shadowdir.y;
- float skew = va->size/2*SHADOWSKEW;
- if(!shadowmap || !shadowmaptex ||
- va->o.z + va->size <= shadowfocus.z - shadowmapdist || va->o.z >= shadowmapmaxz ||
- va->o.x + va->size <= cx - shadowmapradius-skew || va->o.x >= cx + shadowmapradius+skew ||
- va->o.y + va->size <= cy - shadowmapradius-skew || va->o.y >= cy + shadowmapradius+skew)
- return false;
- return true;
-#endif
}
bool isshadowmapcaster(const vec &o, float rad) {
return numverts;
}
template<class T>
- static inline void fillvert(T &vv, int j, vert &v) {
+ static inline void fillvert(T &vv, vert &v) {
vv.tc = v.tc;
}
template<class T>
void fillverts(T *vdata) {
vdata += voffset;
- loopi(numverts) fillvert(vdata[i], i, verts[i]);
+ loopi(numverts) fillvert(vdata[i], verts[i]);
}
void interpverts(const dualquat * RESTRICT bdata1, const dualquat * RESTRICT bdata2, bool tangents, void * RESTRICT vdata, skin &s) {
const int blendoffset = ((skelmeshgroup *)group)->skel->numgpubones;
vector<soundchannel> channels;
int maxchannels = 0;
-soundchannel &newchannel(int n, soundslot *slot, const vec *loc = NULL, extentity *ent = NULL, int flags = 0, int radius = 0) {
+soundchannel &newchannel(int n, soundslot *slot, const vec *loc = NULL, extentity *ent = NULL, int radius = 0) {
if(ent) {
loc = &ent->o;
ent->flags |= EF_SOUND;
bool playing(const soundchannel &chan, const soundconfig &config) const {
return chan.inuse && config.hasslot(chan.slot, slots);
}
-} gamesounds, mapsounds;
+} gamesounds;
void registersound(char *name, int *vol) { intret(gamesounds.addsound(name, *vol, 0)); }
COMMAND(registersound, "si");
-void mapsound(char *name, int *vol, int *maxuses) { intret(mapsounds.addsound(name, *vol, *maxuses < 0 ? 0 : max(1, *maxuses))); }
-COMMAND(mapsound, "sii");
-
void altsound(char *name, int *vol) { gamesounds.addalt(name, *vol); }
COMMAND(altsound, "si");
-void altmapsound(char *name, int *vol) { mapsounds.addalt(name, *vol); }
-COMMAND(altmapsound, "si");
-
ICOMMAND(numsounds, "", (), intret(gamesounds.configs.length()));
-ICOMMAND(nummapsounds, "", (), intret(mapsounds.configs.length()));
void soundreset() {
gamesounds.reset();
}
COMMAND(soundreset, "");
-void mapsoundreset() {
- mapsounds.reset();
-}
-COMMAND(mapsoundreset, "");
-
void resetchannels() {
loopv(channels) if(channels[i].inuse) freechannel(i);
channels.shrink(0);
stopmusic();
cleanupsamples();
gamesounds.clear();
- mapsounds.clear();
samples.clear();
Mix_CloseAudio();
resetchannels();
}
-void stopmapsounds() {
- loopv(channels) if(channels[i].inuse && channels[i].ent) {
- Mix_HaltChannel(i);
- freechannel(i);
- }
-}
-
-void clearmapsounds() {
- stopmapsounds();
- mapsounds.clear();
-}
-
-void stopmapsound(extentity *e) {
- loopv(channels) {
- soundchannel &chan = channels[i];
- if(chan.inuse && chan.ent == e) {
- Mix_HaltChannel(i);
- freechannel(i);
- }
- }
-}
-
-void checkmapsounds() {
- const vector<extentity *> &ents = entities::getents();
- loopv(ents) {
- extentity &e = *ents[i];
- if(e.type!=ET_SOUND) continue;
- if(camera1->o.dist(e.o) < e.attr2) {
- if(!(e.flags&EF_SOUND)) playsound(e.attr1, NULL, &e, SND_MAP, -1);
- }
- else if(e.flags&EF_SOUND) stopmapsound(&e);
- }
-}
-
VAR(stereo, 0, 1, 1);
bool updatechannel(soundchannel &chan) {
if(minimized && !minimizedsounds) stopsounds();
else {
reclaimchannels();
- if(mainmenu) stopmapsounds();
- else checkmapsounds();
syncchannels();
}
if(music) {
gamesounds.preloadsound(n);
}
-void preloadmapsound(int n) {
- mapsounds.preloadsound(n);
-}
-
-void preloadmapsounds() {
- const vector<extentity *> &ents = entities::getents();
- loopv(ents) {
- extentity &e = *ents[i];
- if(e.type==ET_SOUND) mapsounds.preloadsound(e.attr1);
- }
-}
-
-int playsound(int n, const vec *loc, extentity *ent, int flags, int loops, int fade, int chanid, int radius, int expire) {
+int playsound(int n, const vec *loc, extentity *ent, int loops, int fade, int chanid, int radius, int expire) {
if(nosound || !soundvol || (minimized && !minimizedsounds)) return -1;
- soundtype &sounds = ent || flags&SND_MAP ? mapsounds : gamesounds;
+ soundtype &sounds = gamesounds;
if(!sounds.configs.inrange(n)) { conoutf(CON_WARN, "unregistered sound: %d", n); return -1; }
soundconfig &config = sounds.configs[n];
if(loc) {
}
}
if(fade < 0) return -1;
- soundslot &slot = sounds.slots[config.chooseslot(flags)];
+ soundslot &slot = sounds.slots[config.chooseslot(0)];
if(!slot.sample->chunk && !slot.sample->load()) return -1;
chanid = -1;
loopv(channels) if(!channels[i].inuse) { chanid = i; break; }
if(chanid < 0 && channels.length() < maxchannels) chanid = channels.length();
if(chanid < 0) loopv(channels) if(!channels[i].volume) { chanid = i; break; }
if(chanid < 0) return -1;
- soundchannel &chan = newchannel(chanid, &slot, loc, ent, flags, radius);
+ soundchannel &chan = newchannel(chanid, &slot, loc, ent, radius);
updatechannel(chan);
int playing = -1;
if(fade) {
return true;
}
-int playsoundname(const char *s, const vec *loc, int vol, int flags, int loops, int fade, int chanid, int radius, int expire) {
+int playsoundname(const char *s, const vec *loc, int vol, int loops, int fade, int chanid, int radius, int expire) {
if(!vol) vol = 100;
int id = gamesounds.findsound(s, vol);
if(id < 0) id = gamesounds.addsound(s, vol);
- return playsound(id, loc, NULL, flags, loops, fade, chanid, radius, expire);
+ return playsound(id, loc, NULL, loops, fade, chanid, radius, expire);
}
ICOMMAND(sound, "i", (int *n), playsound(*n));
}
}
-static void reorientrgtc(GLenum format, int blocksize, int w, int h, uchar *src, uchar *dst, bool flipx, bool flipy, bool swapxy) {
+static void reorientrgtc(int blocksize, int w, int h, uchar *src, uchar *dst, bool flipx, bool flipy, bool swapxy) {
int bx1 = 0, by1 = 0, bx2 = min(w, 4), by2 = min(h, 4), bw = (w+3)/4, bh = (h+3)/4, stridex = blocksize, stridey = blocksize;
if(swapxy) stridex *= bw; else stridey *= bh;
if(flipx) { dst += (bw-1)*stridex; stridex = -stridex; bx1 += 4-bx2; bx2 = 4; }
s.replace(d);
}
-void swizzleimage(ImageData &s) {
- if(s.bpp==2) {
- ImageData d(s.w, s.h, 4);
- readwritetex(d, s, { dst[0] = dst[1] = dst[2] = src[0]; dst[3] = src[1]; });
- s.replace(d);
- }
- else if(s.bpp==1) {
- ImageData d(s.w, s.h, 3);
- readwritetex(d, s, { dst[0] = dst[1] = dst[2] = src[0]; });
- s.replace(d);
- }
-}
-
void texreorient(ImageData &s, bool flipx, bool flipy, bool swapxy, int type = TEX_DIFFUSE) {
ImageData d(swapxy ? s.h : s.w, swapxy ? s.w : s.h, s.bpp, s.levels, s.align, s.compressed);
switch(s.compressed) {
case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT: {
uchar *dst = d.data, *src = s.data;
loopi(s.levels) {
- reorientrgtc(s.compressed, s.bpp, max(s.w>>i, 1), max(s.h>>i, 1), src, dst, flipx, flipy, swapxy);
+ reorientrgtc(s.bpp, max(s.w>>i, 1), max(s.h>>i, 1), src, dst, flipx, flipy, swapxy);
src += s.calclevelsize(i);
dst += d.calclevelsize(i);
}
}
void texmad(ImageData &s, const vec &mul, const vec &add) {
- if(s.bpp < 3 && (mul.x != mul.y || mul.y != mul.z || add.x != add.y || add.y != add.z))
- swizzleimage(s);
int maxk = min(int(s.bpp), 3);
writetex(s,
loopk(maxk) dst[k] = uchar(clamp(dst[k]*mul[k] + 255*add[k], 0.0f, 255.0f));
}
}
-void uploadtexture(int tnum, GLenum target, GLenum internal, int tw, int th, GLenum format, GLenum type, void *pixels, int pw, int ph, int pitch, bool mipmap) {
+void uploadtexture(GLenum target, GLenum internal, int tw, int th, GLenum format, GLenum type, void *pixels, int pw, int ph, int pitch, bool mipmap) {
int bpp = formatsize(format), row = 0, rowalign = 0;
if(!pitch) pitch = pw*bpp;
uchar *buf = NULL;
}
else if(tw*bpp != pitch) {
row = pitch/bpp;
- rowalign = texalign(pixels, pitch, 1);
+ rowalign = texalign(pitch, 1);
while(rowalign > 0 && ((row*bpp + rowalign - 1)/rowalign)*rowalign != pitch) rowalign >>= 1;
if(!rowalign) {
row = 0;
for(int level = 0, align = 0, mw = tw, mh = th;; level++) {
uchar *src = buf ? buf : (uchar *)pixels;
if(buf) pitch = mw*bpp;
- int srcalign = row > 0 ? rowalign : texalign(src, pitch, 1);
+ int srcalign = row > 0 ? rowalign : texalign(pitch, 1);
if(align != srcalign) glPixelStorei(GL_UNPACK_ALIGNMENT, align = srcalign);
if(row > 0) glPixelStorei(GL_UNPACK_ROW_LENGTH, row);
glTexImage2D(target, level, internal, mw, mh, 0, format, type, src);
return subtarget;
}
-const GLint *swizzlemask(GLenum format) {
- static const GLint luminance[4] = { GL_RED, GL_RED, GL_RED, GL_ONE };
- static const GLint luminancealpha[4] = { GL_RED, GL_RED, GL_RED, GL_GREEN };
- switch(format) {
- case GL_RED: return luminance;
- case GL_RG: return luminancealpha;
- }
- return NULL;
-}
-
-void setuptexparameters(int tnum, void *pixels, int clamp, int filter, GLenum format, GLenum target, bool swizzle) {
+void setuptexparameters(int tnum, int clamp, int filter, GLenum format, GLenum target) {
glBindTexture(target, tnum);
glTexParameteri(target, GL_TEXTURE_WRAP_S, clamp&1 ? GL_CLAMP_TO_EDGE : (clamp&0x100 ? GL_MIRRORED_REPEAT : GL_REPEAT));
glTexParameteri(target, GL_TEXTURE_WRAP_T, clamp&2 ? GL_CLAMP_TO_EDGE : (clamp&0x200 ? GL_MIRRORED_REPEAT : GL_REPEAT));
(bilinear ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_LINEAR) :
(bilinear ? GL_LINEAR_MIPMAP_NEAREST : GL_NEAREST_MIPMAP_NEAREST)) :
(filter && bilinear ? GL_LINEAR : GL_NEAREST));
- if(swizzle && hasTRG && hasTSW) {
- const GLint *mask = swizzlemask(format);
- if(mask) glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, mask);
- }
}
static GLenum textype(GLenum &component, GLenum &format) {
return type;
}
-void createtexture(int tnum, int w, int h, void *pixels, int clamp, int filter, GLenum component, GLenum subtarget, int pw, int ph, int pitch, bool resize, GLenum format, bool swizzle) {
+void createtexture(int tnum, int w, int h, void *pixels, int clamp, int filter, GLenum component, GLenum subtarget, int pw, int ph, int pitch, bool resize, GLenum format) {
GLenum target = textarget(subtarget), type = textype(component, format);
- if(filter >= 0 && clamp >= 0) setuptexparameters(tnum, pixels, clamp, filter, format, target, swizzle);
+ if(filter >= 0 && clamp >= 0) setuptexparameters(tnum, clamp, filter, format, target);
if(!pw) pw = w;
if(!ph) ph = h;
int tw = w, th = h;
resizetexture(w, h, mipmap, false, target, 0, tw, th);
if(mipmap) component = compressedformat(component, tw, th);
}
- uploadtexture(tnum, subtarget, component, tw, th, format, type, pixels, pw, ph, pitch, mipmap);
+ uploadtexture(subtarget, component, tw, th, format, type, pixels, pw, ph, pitch, mipmap);
}
-void createcompressedtexture(int tnum, int w, int h, uchar *data, int align, int blocksize, int levels, int clamp, int filter, GLenum format, GLenum subtarget, bool swizzle = false) {
+void createcompressedtexture(int tnum, int w, int h, uchar *data, int align, int blocksize, int levels, int clamp, int filter, GLenum format, GLenum subtarget) {
GLenum target = textarget(subtarget);
- if(filter >= 0 && clamp >= 0) setuptexparameters(tnum, data, clamp, filter, format, target);
+ if(filter >= 0 && clamp >= 0) setuptexparameters(tnum, clamp, filter, format, target);
uploadcompressedtexture(target, subtarget, format, w, h, data, align, blocksize, levels, filter > 1);
}
Texture *notexture = NULL; // used as default, ensured to be loaded
-static GLenum texformat(int bpp, bool swizzle = false) {
+static GLenum texformat(int bpp) {
switch(bpp) {
- case 1: return hasTRG && (hasTSW || !glcompat || !swizzle) ? GL_RED : GL_LUMINANCE;
- case 2: return hasTRG && (hasTSW || !glcompat || !swizzle) ? GL_RG : GL_LUMINANCE_ALPHA;
+ case 1: return hasTRG && (hasTSW || !glcompat) ? GL_RED : GL_LUMINANCE;
+ case 2: return hasTRG && (hasTSW || !glcompat) ? GL_RG : GL_LUMINANCE_ALPHA;
case 3: return GL_RGB;
case 4: return GL_RGBA;
default: return 0;
}
}
-int texalign(const void *data, int w, int bpp) {
+int texalign(int w, int bpp) {
int stride = w*bpp;
if(stride&1) return 1;
if(stride&2) return 2;
t->w = t->h = t->xs = t->ys = t->bpp = 0;
return t;
}
- bool swizzle = !(clamp&0x10000);
GLenum format;
if(s.compressed) {
format = uncompressedformat(s.compressed);
t->type |= Texture::COMPRESSED;
}
else {
- format = texformat(s.bpp, swizzle);
+ format = texformat(s.bpp);
t->bpp = s.bpp;
- if(swizzle && hasTRG && !hasTSW && swizzlemask(format)) {
- swizzleimage(s);
- format = texformat(s.bpp, swizzle);
- t->bpp = s.bpp;
- }
}
if(alphaformat(format)) t->type |= Texture::ALPHA;
t->w = t->xs = s.w;
if(t->w > 1) t->w /= 2;
if(t->h > 1) t->h /= 2;
}
- createcompressedtexture(t->id, t->w, t->h, data, s.align, s.bpp, levels, clamp, filter, s.compressed, GL_TEXTURE_2D, swizzle);
+ createcompressedtexture(t->id, t->w, t->h, data, s.align, s.bpp, levels, clamp, filter, s.compressed, GL_TEXTURE_2D);
}
else {
resizetexture(t->w, t->h, mipit, canreduce, GL_TEXTURE_2D, compress, t->w, t->h);
GLenum component = compressedformat(format, t->w, t->h, compress);
- createtexture(t->id, t->w, t->h, s.data, clamp, filter, component, GL_TEXTURE_2D, t->xs, t->ys, s.pitch, false, format, swizzle);
+ createtexture(t->id, t->w, t->h, s.data, clamp, filter, component, GL_TEXTURE_2D, t->xs, t->ys, s.pitch, false, format);
}
return t;
}
if(matchstring(cmd, len, "mirror")) {
if(wrap) *wrap |= 0x300;
}
- else if(matchstring(cmd, len, "noswizzle")) {
- if(wrap) *wrap |= 0x10000;
- }
}
return true;
}
else { readwritergbatex(c, s, dst[3] = src[3]; ); }
}
-static void addname(vector<char> &key, Slot &slot, Slot::Tex &t, bool combined = false, const char *prefix = NULL) {
+static void addname(vector<char> &key, Slot::Tex &t, bool combined = false, const char *prefix = NULL) {
if(combined) key.add('&');
if(prefix) { while(*prefix) key.add(*prefix++); }
defformatstring(tname, "packages/%s", t.name);
static void texcombine(Slot &s, int index, Slot::Tex &t, bool forceload = false) {
vector<char> key;
- addname(key, s, t);
+ addname(key, t);
int texmask = 0;
if(!forceload) switch(t.type) {
case TEX_DIFFUSE:
if(i<0) break;
texmask |= 1<<s.sts[i].type;
s.sts[i].combined = index;
- addname(key, s, s.sts[i], true);
+ addname(key, s.sts[i], true);
break;
}
}
linkslotshader(slot, false);
linkvslotshader(vslot, false);
vector<char> name;
- if(vslot.colorscale == vec(1, 1, 1)) addname(name, slot, slot.sts[0], false, "<thumbnail>");
+ if(vslot.colorscale == vec(1, 1, 1)) addname(name, slot.sts[0], false, "<thumbnail>");
else {
defformatstring(prefix, "<thumbnail:%.2f/%.2f/%.2f>", vslot.colorscale.x, vslot.colorscale.y, vslot.colorscale.z);
- addname(name, slot, slot.sts[0], false, prefix);
+ addname(name, slot.sts[0], false, prefix);
}
VSlot *layer = vslot.layer ? &lookupvslot(vslot.layer, false) : NULL;
if(layer) {
- if(layer->colorscale == vec(1, 1, 1)) addname(name, *layer->slot, layer->slot->sts[0], true, "<layer>");
+ if(layer->colorscale == vec(1, 1, 1)) addname(name, layer->slot->sts[0], true, "<layer>");
else {
defformatstring(prefix, "<layer:%.2f/%.2f/%.2f>", vslot.colorscale.x, vslot.colorscale.y, vslot.colorscale.z);
- addname(name, *layer->slot, layer->slot->sts[0], true, prefix);
+ addname(name, layer->slot->sts[0], true, prefix);
}
}
name.add('\0');
concatstring(buf, imageexts[format]);
}
ImageData image(screenw, screenh, 3);
- glPixelStorei(GL_PACK_ALIGNMENT, texalign(image.data, screenw, 3));
+ glPixelStorei(GL_PACK_ALIGNMENT, texalign(screenw, 3));
glReadPixels(0, 0, screenw, screenh, GL_RGB, GL_UNSIGNED_BYTE, image.data);
saveimage(path(buf), format, image, true);
}
void entflip() {
if(noentedit()) return;
- int d = dimension(sel.orient);
- float mid = sel.s[d]*sel.grid/2+sel.o[d];
- groupeditpure(e.o[d] -= (e.o[d]-mid)*2);
+ int d = dimension(sel.orient); (void) d;
+ groupeditpure(e.o[d] -= (e.o[d]-(sel.s[d]*sel.grid/2+sel.o[d]))*2);
}
void entrotate(int *cw) {
if(noentedit()) return;
int d = dimension(sel.orient);
int dd = (*cw<0) == dimcoord(sel.orient) ? R[d] : C[d];
- float mid = sel.s[dd]*sel.grid/2+sel.o[dd];
vec s(sel.o.v);
groupeditpure(
- e.o[dd] -= (e.o[dd]-mid)*2;
+ e.o[dd] -= (e.o[dd]-(sel.s[dd]*sel.grid/2+sel.o[dd]))*2;
e.o.sub(s);
swap(e.o[R[d]], e.o[C[d]]);
e.o.add(s);
void entdrag(const vec &ray) {
if(noentedit() || !haveselent()) return;
- float r = 0, c = 0;
+ float r = 0, c = 0; (void) r; (void) c;
static vec v, handle;
vec eo, es;
int d = dimension(entorient),
gle::attrib(eo.x, es.y, eo.z); gle::attrib(eo.x, es.y, es.z);
}
-void renderentselection(const vec &o, bool entmoving) {
+void renderentselection(bool entmoving) {
if(noentedit()) return;
vec eo, es;
if(entgroup.length()) {
keepents = max(keepents, idx+1);
}
keepents = 0;
- int j = 0;
}
COMMAND(newent, "siiiii");
COMMAND(entpaste, "");
void entset(char *what, int *a1, int *a2, int *a3, int *a4, int *a5) {
+ (void) a1; (void) a2; (void) a3; (void) a4; (void) a5;
if(noentedit()) return;
int type = findtype(what);
if(type != ET_EMPTY)
}
void entattr(int *attr, int *val, int *numargs) {
+ (void) val;
if(*numargs >= 2) {
if(*attr >= 0 && *attr <= 4)
groupedit(
void resetmap() {
clearoverrides();
- clearmapsounds();
resetlightmaps();
clearslots();
clearparticles();
preloadusedmapmodels(true);
game::preload();
flushpreloadedmodels();
- preloadmapsounds();
entitiesinoctanodes();
initlights();
allchanged(true);
float weapmaxdist(int weap) {
return guns[weap].range + 4;
}
- bool weaprange(fpsent *d, int weap, float dist) {
+ bool weaprange(int weap, float dist) {
float mindist = weapmindist(weap), maxdist = weapmaxdist(weap);
return dist >= mindist*mindist && dist <= maxdist*maxdist;
}
return false;
}
bool canshoot(fpsent *d, fpsent *e) {
- if(weaprange(d, d->gunselect, e->o.squaredist(d->o)) && targetable(d, e))
+ if(weaprange(d->gunselect, e->o.squaredist(d->o)) && targetable(d, e))
return d->ammo[d->gunselect] > 0 && lastmillis - d->lastaction >= d->gunwait;
return false;
}
bool canshoot(fpsent *d) {
return !d->ai->becareful && d->ammo[d->gunselect] > 0 && lastmillis - d->lastaction >= d->gunwait;
}
- bool hastarget(fpsent *d, aistate &b, fpsent *e, float yaw, float pitch, float dist) {
+ bool hastarget(fpsent *d, float yaw, float pitch, float dist) {
// add margins of error
- if(weaprange(d, d->gunselect, dist) || (d->skill <= 100 && !rnd(d->skill))) {
+ if(weaprange(d->gunselect, dist) || (d->skill <= 100 && !rnd(d->skill))) {
if(d->gunselect == GUN_FIST) return true;
float skew = clamp(float(lastmillis-d->ai->enemymillis)/float((d->skill*guns[d->gunselect].attackdelay/200.f)), 0.f, guns[d->gunselect].projspeed ? 0.25f : 1e16f),
offy = yaw-d->yaw, offp = pitch-d->pitch;
if(d->ai) DELETEP(d->ai);
}
void init(fpsent *d, int at, int ocn, int sk, int bn, int pm, const char *name, const char *team) {
+ (void) bn; (void) pm;
loadwaypoints();
fpsent *o = newclient(ocn);
d->aitype = at;
if(d->skill <= 100) return d->health <= (111-d->skill)/4;
return false;
}
- bool enemy(fpsent *d, aistate &b, const vec &pos, float guard = SIGHTMIN, int pursue = 0) {
+ bool enemy(fpsent *d, aistate &b, float guard = SIGHTMIN, int pursue = 0) {
fpsent *t = NULL;
vec dp = d->headpos();
float mindist = guard*guard, bestdist = 1e16f;
return true;
}
bool defend(fpsent *d, aistate &b, const vec &pos, float guard, float wander, int walk) {
- bool hasenemy = enemy(d, b, pos, wander, d->gunselect == GUN_FIST ? 1 : 0);
+ bool hasenemy = enemy(d, b, wander, d->gunselect == GUN_FIST ? 1 : 0);
if(!walk) {
if(d->feetpos().squaredist(pos) <= guard*guard) {
b.idle = hasenemy ? 2 : 1;
if(d->ammo[GUN_GL] > 5) return true;
return false;
}
- void assist(fpsent *d, aistate &b, vector<interest> &interests, bool all, bool force) {
- loopv(players) {
- fpsent *e = players[i];
- if(e == d || (!all && e->aitype != AI_NONE) || !isteam(d->team, e->team)) continue;
- interest &n = interests.add();
- n.state = AI_S_DEFEND;
- n.node = e->lastnode;
- n.target = e->clientnum;
- n.targtype = AI_T_PLAYER;
- n.score = e->o.squaredist(d->o)/(hasgoodammo(d) ? 1e8f : (force ? 1e4f : 1e2f));
- }
- }
- static void tryitem(fpsent *d, extentity &e, int id, aistate &b, vector<interest> &interests, bool force = false) {
+ static void tryitem(fpsent *d, extentity &e, int id, vector<interest> &interests) {
float score = 0;
switch(e.type) {
case I_HEALTH:
n.node = closestwaypoint(e.o, SIGHTMIN, true);
n.target = id;
n.targtype = AI_T_ENTITY;
- n.score = d->feetpos().squaredist(e.o)/(force ? -1 : score);
+ n.score = d->feetpos().squaredist(e.o)/score;
}
}
- void items(fpsent *d, aistate &b, vector<interest> &interests, bool force = false) {
+ void items(fpsent *d, vector<interest> &interests) {
loopv(entities::ents) {
extentity &e = *(extentity *)entities::ents[i];
if(!e.spawned() || e.nopickup() || !d->canpickup(e.type)) continue;
- tryitem(d, e, i, b, interests, force);
+ tryitem(d, e, i, interests);
}
}
static vector<int> targets;
- bool parseinterests(fpsent *d, aistate &b, vector<interest> &interests, bool override, bool ignore) {
+ bool parseinterests(fpsent *d, aistate &b, vector<interest> &interests, bool ignore) {
while(!interests.empty()) {
int q = interests.length()-1;
loopi(interests.length()-1) if(interests[i].score < interests[q].score) q = i;
}
return false;
}
- bool find(fpsent *d, aistate &b, bool override = false) {
+ bool find(fpsent *d, aistate &b) {
static vector<interest> interests;
interests.setsize(0);
if(!m_noitems) {
if((!m_noammo && !hasgoodammo(d)) || d->health < min(d->skill - 15, 75))
- items(d, b, interests);
+ items(d, interests);
else {
static vector<int> nearby;
nearby.setsize(0);
loopv(nearby) {
int id = nearby[i];
extentity &e = *(extentity *)entities::ents[id];
- if(d->canpickup(e.type)) tryitem(d, e, id, b, interests);
- }
- }
- }
- if(m_teammode) assist(d, b, interests);
- return parseinterests(d, b, interests, override);
- }
- bool findassist(fpsent *d, aistate &b, bool override = false) {
- static vector<interest> interests;
- interests.setsize(0);
- assist(d, b, interests);
- while(!interests.empty()) {
- int q = interests.length()-1;
- loopi(interests.length()-1) if(interests[i].score < interests[q].score) q = i;
- interest n = interests.removeunordered(q);
- bool proceed = true;
- switch(n.state) {
- case AI_S_DEFEND: { // don't get into herds {
- int members = 0;
- proceed = !checkothers(targets, d, n.state, n.targtype, n.target, true, &members) && members > 1;
- break;
+ if(d->canpickup(e.type)) tryitem(d, e, id, interests);
}
- default: break;
- }
- if(proceed && makeroute(d, b, n.node)) {
- d->ai->switchstate(b, n.state, n.targtype, n.target);
- return true;
}
}
- return false;
+ return parseinterests(d, b, interests);
}
void damaged(fpsent *d, fpsent *e) {
if(d->ai && canmove(d) && targetable(d, e)) { // see if this ai is interested in a grudge {
void spawned(fpsent *d) {
if(d->ai) setup(d);
}
- void killed(fpsent *d, fpsent *e) {
+ void killed(fpsent *d) {
if(d->ai) d->ai->reset();
}
void itemspawned(int ent) {
}
return -1;
}
- bool anynode(fpsent *d, aistate &b, int len = NUMPREVNODES) {
+ bool anynode(fpsent *d, int len = NUMPREVNODES) {
if(iswaypoint(d->lastnode)) loopk(2) {
d->ai->clear(k ? true : false);
int n = randomlink(d, d->lastnode);
}
}
b.override = false;
- return anynode(d, b);
+ return anynode(d);
}
void jumpto(fpsent *d, aistate &b, const vec &pos) {
vec off = vec(pos).sub(d->feetpos()), dir(off.x, off.y, 0);
}
scaleyawpitch(d->yaw, d->pitch, yaw, pitch, frame, sskew);
if(insight || quick) {
- if(canshoot(d, e) && hastarget(d, b, e, yaw, pitch, dp.squaredist(ep))) {
+ if(canshoot(d, e) && hastarget(d, yaw, pitch, dp.squaredist(ep))) {
d->attacking = true;
d->ai->lastaction = lastmillis;
result = 3;
if(targetable(d, e)) {
vec ep = getaimpos(d, e);
float dist = ep.squaredist(d->headpos());
- if(weaprange(d, weap, dist)) return true;
+ if(weaprange(weap, dist)) return true;
}
return false;
}
}
return process(d, b) >= 2;
}
- void timeouts(fpsent *d, aistate &b) {
+ void timeouts(fpsent *d) {
if(d->blocked) {
d->ai->blocktime += lastmillis-d->ai->lastrun;
if(d->ai->blocktime > (d->ai->blockseq+1)*1000) {
}
}
}
- void logic(fpsent *d, aistate &b, bool run) {
+ void logic(fpsent *d, aistate &b) {
bool allowmove = canmove(d) && b.type != AI_S_WAIT;
if(d->state != CS_ALIVE || !allowmove) d->stopmoving();
if(d->state == CS_ALIVE) {
if(!intermission) {
if(d->ragdoll) cleanragdoll(d);
moveplayer(d, 10, true);
- if(allowmove && !b.idle) timeouts(d, b);
+ if(allowmove && !b.idle) timeouts(d);
if(d->quadmillis) entities::checkquad(curtime, d);
entities::checkitems(d);
}
}
}
}
- logic(d, c, run);
+ logic(d, c);
break;
}
if(d->ai->trywipe) d->ai->wipe();
extern bool violence(fpsent *d, aistate &b, fpsent *e, int pursue = 0);
extern bool patrol(fpsent *d, aistate &b, const vec &pos, float guard = SIGHTMIN, float wander = SIGHTMAX, int walk = 1, bool retry = false);
extern bool defend(fpsent *d, aistate &b, const vec &pos, float guard = SIGHTMIN, float wander = SIGHTMAX, int walk = 1);
- extern void assist(fpsent *d, aistate &b, vector<interest> &interests, bool all = false, bool force = false);
- extern bool parseinterests(fpsent *d, aistate &b, vector<interest> &interests, bool override = false, bool ignore = false);
+ extern bool parseinterests(fpsent *d, aistate &b, vector<interest> &interests, bool ignore = false);
extern void spawned(fpsent *d);
extern void damaged(fpsent *d, fpsent *e);
- extern void killed(fpsent *d, fpsent *e);
+ extern void killed(fpsent *d);
extern void itemspawned(int ent);
extern void render();
}
messages.put(buf, p.length());
return true;
}
- void connectattempt(const char *name, const char *password, const ENetAddress &address) {
- copystring(connectpass, password);
- }
- void connectfail() {
- memset(connectpass, 0, sizeof(connectpass));
- }
void gameconnect(bool _remote) {
remote = _remote;
if(editmode) toggleedit();
if(!entities::ents.inrange(i)) break;
entities::setspawn(i, true);
ai::itemspawned(i);
- playsound(S_ITEMSPAWN, &entities::ents[i]->o, NULL, 0, 0, 0, -1, 0, 1500);
- #if 0
- const char *name = entities::itemname(i);
- if(name) particle_text(entities::ents[i]->o, name, PART_TEXT, 2000, 0x32FF64, 4.0f, -8);
- #endif
+ playsound(S_ITEMSPAWN, &entities::ents[i]->o, NULL, 0, 0, -1, 0, 1500);
int icon = entities::itemicon(i);
if(icon >= 0) particle_icon(vec(0.0f, 0.0f, 4.0f).add(entities::ents[i]->o), icon%4, icon/4, PART_HUD_ICON, 2000, 0xFFFFFF, 2.0f, -8);
break;
}
case N_ANNOUNCE: {
int t = getint(p);
- if (t==I_QUAD) { playsound(S_V_QUAD10, NULL, NULL, 0, 0, 0, -1, 0, 3000); conoutf(CON_GAMEINFO, "\f2quad damage will spawn in 10 seconds!"); }
- else if(t==I_BOOST) { playsound(S_V_BOOST10, NULL, NULL, 0, 0, 0, -1, 0, 3000); conoutf(CON_GAMEINFO, "\f2health boost will spawn in 10 seconds!"); }
+ if (t==I_QUAD) { playsound(S_V_QUAD10, NULL, NULL, 0, 0, -1, 0, 3000); conoutf(CON_GAMEINFO, "\f2quad damage will spawn in 10 seconds!"); }
+ else if(t==I_BOOST) { playsound(S_V_BOOST10, NULL, NULL, 0, 0, -1, 0, 3000); conoutf(CON_GAMEINFO, "\f2health boost will spawn in 10 seconds!"); }
break;
}
case N_NEWMAP: {
if(!mdl) continue;
preloadmodel(mdl);
}
- loopv(ents) {
- extentity &e = *ents[i];
- switch(e.type) {
- case TELEPORT:
- if(e.attr2 > 0) preloadmodel(mapmodelname(e.attr2));
- [[fallthrough]];
- case JUMPPAD:
- if(e.attr4 > 0) preloadmapsound(e.attr4);
- break;
- }
- }
}
void renderentities() {
loopv(ents) {
//particle_text(d->abovehead(), is.name, PART_TEXT, 2000, 0xFFC864, 4.0f, -8);
particle_icon(d->abovehead(), is.icon%4, is.icon/4, PART_HUD_ICON_GREY, 2000, 0xFFFFFF, 2.0f, -8);
}
- playsound(itemstats[type-I_SHELLS].sound, d!=h ? &d->o : NULL, NULL, 0, 0, 0, -1, 0, 1500);
+ playsound(itemstats[type-I_SHELLS].sound, d!=h ? &d->o : NULL, NULL, 0, 0, -1, 0, 1500);
d->pickup(type);
switch(type) {
case I_TINYARMOUR: pwitemspicked[0]++; break;
if(d==h) switch(type) {
case I_BOOST:
conoutf(CON_GAMEINFO, "\f2you got the health boost!");
- playsound(S_V_BOOST, NULL, NULL, 0, 0, 0, -1, 0, 3000);
+ playsound(S_V_BOOST, NULL, NULL, 0, 0, -1, 0, 3000);
break;
case I_QUAD:
conoutf(CON_GAMEINFO, "\f2you got the quad!");
- playsound(S_V_QUAD, NULL, NULL, 0, 0, 0, -1, 0, 3000);
+ playsound(S_V_QUAD, NULL, NULL, 0, 0, -1, 0, 3000);
break;
}
}
if(ents.inrange(tp) && ents[tp]->type == TELEPORT) {
extentity &e = *ents[tp];
if(e.attr4 >= 0) {
- int snd = S_TELEPORT, flags = 0;
- if(e.attr4 > 0) { snd = e.attr4; flags = SND_MAP; }
+ int snd = S_TELEPORT;
+ if(e.attr4 > 0) snd = e.attr4;
fpsent *h = followingplayer(player1);
- playsound(snd, d==h ? NULL : &e.o, NULL, flags);
- if(d!=h && ents.inrange(td) && ents[td]->type == TELEDEST) playsound(snd, &ents[td]->o, NULL, flags);
+ playsound(snd, d==h ? NULL : &e.o, NULL);
+ if(d!=h && ents.inrange(td) && ents[td]->type == TELEDEST) playsound(snd, &ents[td]->o, NULL);
}
}
if(local && d->clientnum >= 0) {
if(ents.inrange(jp) && ents[jp]->type == JUMPPAD) {
extentity &e = *ents[jp];
if(e.attr4 >= 0) {
- int snd = S_JUMPPAD, flags = 0;
- if(e.attr4 > 0) { snd = e.attr4; flags = SND_MAP; }
- playsound(snd, d == followingplayer(player1) ? NULL : &e.o, NULL, flags);
+ int snd = S_JUMPPAD;
+ if(e.attr4 > 0) snd = e.attr4;
+ playsound(snd, d == followingplayer(player1) ? NULL : &e.o, NULL);
}
}
if(local && d->clientnum >= 0) {
}
}
deathstate(d);
- ai::killed(d, actor);
+ ai::killed(d);
}
void timeupdate(int secs) {
server::timeupdate(secs);
if(notify && d->name[0]) conoutf("\f4leave:\f7 %s", colorname(d));
removeweapons(d);
removetrackedparticles(d);
- removetrackeddynlights(d);
players.removeobj(d);
DELETEP(clients[cn]);
cleardynentcache();
}
VARP(teamsounds, 0, 1, 1);
void teamsound(bool sameteam, int n, const vec *loc) {
- playsound(n, loc, NULL, teamsounds ? (m_teammode && sameteam ? SND_USE_ALT : SND_NO_ALT) : 0);
+ playsound(n, loc, NULL);
}
void teamsound(fpsent *d, int n, const vec *loc) {
teamsound(isteam(d->team, player1->team), n, loc);
// client
extern bool connected, remote, demoplayback;
extern string servinfo;
+ extern string connectpass;
extern vector<uchar> messages;
extern int parseplayer(const char *arg);
extern void ignore(int cn);
sway.z = swayup*(fabs(sinf(steps)) - 1);
sway.add(swaydir).add(d->o);
if(!hudgunsway) sway = d->o;
-
-#if 0
- if(player1->state!=CS_DEAD && player1->quadmillis) {
- float t = 0.5f + 0.5f*sinf(2*M_PI*lastmillis/1000.0f);
- color.y = color.y*(1-t) + t;
- }
-#endif
const playermodelinfo &mdl = getplayermodelinfo(d);
defformatstring(gunname, "%s/%s", hudgunsdir[0] ? hudgunsdir : mdl.hudguns, guns[d->gunselect].file);
if((m_teammode || teamskins) && teamhudguns)
void sendwelcome(clientinfo *ci);
void setupdemorecord() {
if(!m_mp(gamemode) || m_edit) return;
- demotmp = opentempfile("demorecord", "w+b");
+ demotmp = opentempfile();
if(!demotmp) return;
stream *f = opengzfile(NULL, "wb", demotmp);
if(!f) { DELETEP(demotmp); return; }
clientinfo *ci = getinfo(sender);
if(ci->state.state==CS_SPECTATOR && !ci->privilege && !ci->local) return;
if(mapdata) DELETEP(mapdata);
- mapdata = opentempfile("mapdata", "w+b");
+ mapdata = opentempfile();
if(!mapdata) { sendf(sender, 1, "ris", N_SERVMSG, "failed to open temporary file for map"); return; }
mapdata->write(data, len);
sendservmsgf("[%s sent a map to server, \"/getmap\" to receive it]", colorname(ci));
if((gun==GUN_RL || gun==GUN_GL) && explodebright < 1) color = vec::hexcolor(color).mul(explodebright).tohexcolor();
/// REPLACE THIS SHIT WITH SMOKE AND FIRE EFFECT LIKE IN XONOTIC
//~particle_fireball(v, guns[gun].exprad, gun!=GUN_GL ? PART_EXPLOSION : PART_EXPLOSION_BLUE, gun!=GUN_GL ? -1 : int((guns[gun].exprad-4.0f)*15), color, 4.0f);
- if(gun==GUN_RL) adddynlight(v, 1.15f*guns[gun].exprad, vec(2, 1.5f, 1), 700, 100, 0, guns[gun].exprad/2, vec(1, 0.75f, 0.5f));
- else if(gun==GUN_GL) adddynlight(v, 1.15f*guns[gun].exprad, vec(0.5f, 1.5f, 2), 600, 100, 0, 8, vec(0.25f, 1, 1));
- else adddynlight(v, 1.15f*guns[gun].exprad, vec(2, 1.5f, 1), 700, 100);
if(!local) return;
int numdyn = numdynents();
loopi(numdyn) {
particle_flare(hudgunorigin(gun, from, rays[i], d), rays[i], 300, PART_STREAK, 0xFFC864, 0.28f);
if(!local) adddecal(DECAL_BULLET, rays[i], vec(from).sub(rays[i]).safenormalize(), 2.0f);
}
- if(muzzlelight) adddynlight(hudgunorigin(gun, d->o, to, d), 30, vec(0.5f, 0.375f, 0.25f), 100, 100, DL_FLASH, 0, vec(0, 0, 0), d);
break;
}
case GUN_CG:
if(muzzleflash && d->muzzle.x >= 0)
particle_flare(d->muzzle, d->muzzle, gun==GUN_CG ? 100 : 200, PART_MUZZLE_FLASH1, 0xFFFFFF, gun==GUN_CG ? 2.25f : 1.25f, d);
if(!local) adddecal(DECAL_BULLET, to, vec(from).sub(to).safenormalize(), 2.0f);
- if(muzzlelight) adddynlight(hudgunorigin(gun, d->o, to, d), gun==GUN_CG ? 30 : 15, vec(0.5f, 0.375f, 0.25f), gun==GUN_CG ? 50 : 100, gun==GUN_CG ? 50 : 100, DL_FLASH, 0, vec(0, 0, 0), d);
break;
}
case GUN_RL:
up.z += dist/8;
if(muzzleflash && d->muzzle.x >= 0)
particle_flare(d->muzzle, d->muzzle, 200, PART_MUZZLE_FLASH2, 0xFFFFFF, 1.5f, d);
- if(muzzlelight) adddynlight(hudgunorigin(gun, d->o, to, d), 20, vec(0.5f, 0.375f, 0.25f), 100, 100, DL_FLASH, 0, vec(0, 0, 0), d);
newbouncer(from, up, local, id, d, BNC_GRENADE, guns[gun].ttl, guns[gun].projspeed);
break;
}
if(muzzleflash && d->muzzle.x >= 0)
particle_flare(d->muzzle, d->muzzle, 150, PART_MUZZLE_FLASH3, 0xFFFFFF, 1.25f, d);
if(!local) adddecal(DECAL_BULLET, to, vec(from).sub(to).safenormalize(), 3.0f);
- if(muzzlelight) adddynlight(hudgunorigin(gun, d->o, to, d), 25, vec(0.5f, 0.375f, 0.25f), 75, 75, DL_FLASH, 0, vec(0, 0, 0), d);
break;
}
bool looped = false;
case S_CHAINSAW_ATTACK:
if(d->attacksound >= 0) looped = true;
d->attacksound = sound;
- d->attackchan = playsound(sound, d==h ? NULL : &d->o, NULL, 0, -1, 100, d->attackchan);
+ d->attackchan = playsound(sound, d==h ? NULL : &d->o, NULL, -1, 100, d->attackchan);
break;
default:
playsound(sound, d==h ? NULL : &d->o);
d.mul(min(newdist, dist)).add(owner->o);
}
}
- void dynlighttrack(physent *owner, vec &o, vec &hud) {
- if(owner->type!=ENT_PLAYER && owner->type!=ENT_AI) return;
- fpsent *pl = (fpsent *)owner;
- if(pl->muzzle.x < 0 || pl->lastattackgun != pl->gunselect) return;
- o = pl->muzzle;
- hud = owner == followingplayer(player1) ? vec(pl->o).add(vec(0, 0, 2)) : pl->muzzle;
- }
float intersectdist = 1e16f;
bool intersect(dynent *d, const vec &from, const vec &to, float &dist) { // if lineseg hits entity bounding box {
vec bottom(d->o), top(d->o);
if(d->gunselect == GUN_PISTOL && d->ai) d->gunwait += int(d->gunwait*(((101-d->skill)+rnd(111-d->skill))/100.f));
d->totalshots += guns[d->gunselect].damage*(d->quadmillis ? 4 : 1)*guns[d->gunselect].rays;
}
- void adddynlights() {
- loopv(projs) {
- projectile &p = projs[i];
- if(p.gun!=GUN_RL) continue;
- vec pos(p.o);
- pos.add(vec(p.offset).mul(p.offsetmillis/float(OFFSETMILLIS)));
- adddynlight(pos, 20, vec(1, 0.75f, 0.5f));
- }
- loopv(bouncers) {
- bouncer &bnc = *bouncers[i];
- if(bnc.bouncetype!=BNC_GRENADE) continue;
- vec pos = bnc.offsetpos();
- adddynlight(pos, 8, vec(0.25f, 1, 1));
- }
- }
static const char * const projnames[2] = { "projectiles/grenade", "projectiles/rocket" };
void preloadbouncers() {
loopi(sizeof(projnames)/sizeof(projnames[0])) preloadmodel(projnames[i]);
if(gun >= 0 && gun < NUMGUNS &&
d->clientnum >= 0 && d->state == CS_ALIVE &&
d->lastattackgun == gun && lastmillis - d->lastaction < guns[gun].attackdelay + 50) {
- d->attackchan = playsound(d->attacksound, local ? NULL : &d->o, NULL, 0, -1, -1, d->attackchan);
+ d->attackchan = playsound(d->attacksound, local ? NULL : &d->o, NULL, -1, -1, d->attackchan);
if(d->attackchan < 0) d->attacksound = -1;
}
else d->stopattacksound();
if(d->idlesound != sound) {
if(d->idlesound >= 0) d->stopidlesound();
if(sound >= 0) {
- d->idlechan = playsound(sound, local ? NULL : &d->o, NULL, 0, -1, 100, d->idlechan, radius);
+ d->idlechan = playsound(sound, local ? NULL : &d->o, NULL, -1, 100, d->idlechan, radius);
if(d->idlechan >= 0) d->idlesound = sound;
}
}
else if(sound >= 0) {
- d->idlechan = playsound(sound, local ? NULL : &d->o, NULL, 0, -1, -1, d->idlechan, radius);
+ d->idlechan = playsound(sound, local ? NULL : &d->o, NULL, -1, -1, d->idlechan, radius);
if(d->idlechan < 0) d->idlesound = -1;
}
}
}\r
}\r
if(rh > 0) numtex++;\r
-#if 0\r
- if(sw <= 0)\r {
-\r
- if(FT_Load_Char(f, ' ', FT_LOAD_DEFAULT))\r
- fatal("cube2font: failed loading space character");\r
- sw = (f->glyph->advance.x+0x3F)>>6;\r
- }\r
-#endif\r
if(sh <= 0) sh = y2 - y1;\r
if(sw <= 0) sw = sh/3;\r
writetexs(argv[2], chars, numchars, numtex, tw, th);\r
writecfg(argv[2], chars, numchars, x1, y1, x2, y2, sw, sh, argc, argv);\r
- for(i = 0; i < numchars; i++)\r {
-\r
+ for(i = 0; i < numchars; i++) {\r
if(chars[i].alpha != chars[i].color) FT_Done_Glyph((FT_Glyph)chars[i].alpha);\r
FT_Done_Glyph((FT_Glyph)chars[i].color);\r
}\r
extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays_;
extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays_;
extern PFNGLISVERTEXARRAYPROC glIsVertexArray_;
-
-#ifndef GL_ARB_texture_swizzle
-#define GL_ARB_texture_swizzle 1
-#define GL_TEXTURE_SWIZZLE_R 0x8E42
-#define GL_TEXTURE_SWIZZLE_G 0x8E43
-#define GL_TEXTURE_SWIZZLE_B 0x8E44
-#define GL_TEXTURE_SWIZZLE_A 0x8E45
-#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46
-#endif
};
extern void lightent(extentity &e, float height = 8.0f);
-extern void lightreaching(const vec &target, vec &color, vec &dir, bool fast = false, extentity *e = 0, float ambient = 0.4f);
+extern void lightreaching(const vec &target, vec &color, vec &dir, extentity *e = 0, float ambient = 0.4f);
extern entity *brightestlight(const vec &target, const vec &dir);
enum { RAY_BB = 1, RAY_POLY = 3, RAY_ALPHAPOLY = 7, RAY_ENTS = 9, RAY_CLIPMAT = 16, RAY_SKIPFIRST = 32, RAY_EDITMAT = 64, RAY_SHADOW = 128, RAY_PASS = 256 };
DL_FLASH = 1<<2
};
-extern void adddynlight(const vec &o, float radius, const vec &color, int fade = 0, int peak = 0, int flags = 0, float initradius = 0, const vec &initcolor = vec(0, 0, 0), physent *owner = NULL);
-extern void dynlightreaching(const vec &target, vec &color, vec &dir, bool hud = false);
-extern void removetrackeddynlights(physent *owner = NULL);
-
// rendergl
extern physent *camera1;
extern vec worldpos, camdir, camright, camup;
SND_USE_ALT = 1<<2
};
-extern int playsound(int n, const vec *loc = NULL, extentity *ent = NULL, int flags = 0, int loops = 0, int fade = 0, int chanid = -1, int radius = 0, int expire = -1);
-extern int playsoundname(const char *s, const vec *loc = NULL, int vol = 0, int flags = 0, int loops = 0, int fade = 0, int chanid = -1, int radius = 0, int expire = -1);
+extern int playsound(int n, const vec *loc = NULL, extentity *ent = NULL, int loops = 0, int fade = 0, int chanid = -1, int radius = 0, int expire = -1);
+extern int playsoundname(const char *s, const vec *loc = NULL, int vol = 0, int loops = 0, int fade = 0, int chanid = -1, int radius = 0, int expire = -1);
extern void preloadsound(int n);
extern void preloadmapsound(int n);
extern bool stopsound(int n, int chanid, int fade = 0);
}
namespace game {
+ extern string connectpass;
extern void gamedisconnect(bool cleanup);
extern void parsepacketclient(int chan, packetbuf &p);
- extern void connectattempt(const char *name, const char *password, const ENetAddress &address);
- extern void connectfail();
extern void gameconnect(bool _remote);
extern bool allowedittoggle();
extern void edittoggled(bool on);
extern bool allowthirdperson(bool msg = false);
extern bool detachcamera();
extern bool collidecamera();
- extern void adddynlights();
extern void particletrack(physent *owner, vec &o, vec &d);
- extern void dynlighttrack(physent *owner, vec &o, vec &hud);
extern int maxsoundradius(int n);
extern bool serverinfostartcolumn(g3d_gui *g, int i);
extern void serverinfoendcolumn(g3d_gui *g, int i);
char *path(const char *s, bool copy) {
static string tmp;
- copystring(tmp, s);
- path(tmp);
- return tmp;
+ if (copy) {
+ copystring(tmp, s);
+ path(tmp);
+ return tmp;
+ } else {
+ return (char *) s;
+ }
}
const char *parentdir(const char *directory) {
}
static int rwopsclose(SDL_RWops *rw) {
+ (void) rw;
return 0;
}
file = fopen(name, mode);
return file!=NULL;
}
- bool opentemp(const char *name, const char *mode) {
+ bool opentemp() {
if(file) return false;
file = tmpfile();
return file!=NULL;
return openrawfile(filename, mode);
}
-stream *opentempfile(const char *name, const char *mode) {
- const char *found = findfile(name, mode);
+stream *opentempfile() {
filestream *file = new filestream;
- if(!file->opentemp(found ? found : name, mode)) { delete file; return NULL; }
+ if(!file->opentemp()) { delete file; return NULL; }
return file;
}
template<class U> static inline const char *getkey(const U &elem) { return elem.name; }
template<class U> static inline const char *getkey(U *elem) { return elem->name; }
static inline T &getdata(T &elem) { return elem; }
- template<class K> static inline void setkey(T &elem, const K &key) {}
+ template<class K> static inline void setkey(T &, const K &) {}
template<class V>
T &add(const V &elem) {
return basetype::access(getkey(elem), elem);
extern stream *openrawfile(const char *filename, const char *mode);
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 *opentempfile();
extern stream *opengzfile(const char *filename, const char *mode, stream *file = NULL, int level = Z_BEST_COMPRESSION);
extern stream *openutf8file(const char *filename, const char *mode, stream *file = NULL);
extern char *loadfile(const char *fn, size_t *size, bool utf8 = true);
return true;
}
-static bool readzipdirectory(const char *archname, FILE *f, int entries, int offset, uint size, vector<zipfile> &files) {
+static bool readzipdirectory(FILE *f, int entries, int offset, uint size, vector<zipfile> &files) {
uchar *buf = new (false) uchar[size], *src = buf;
if(!buf || fseek(f, offset, SEEK_SET) < 0 || fread(buf, 1, size, f) != size) { delete[] buf; return false; }
loopi(entries) {
}
zipdirectoryheader h;
vector<zipfile> files;
- if(!findzipdirectory(f, h) || !readzipdirectory(pname, f, h.entries, h.offset, h.size, files)) {
+ if(!findzipdirectory(f, h) || !readzipdirectory(f, h.entries, h.offset, h.size, files)) {
conoutf(CON_ERROR, "could not read directory in zip %s", pname);
fclose(f);
return false;