// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/g_spawn.c
// Function: SP_worldspawn
void SP_worldspawn (edict_t *ent)
{
	ent->movetype = MOVETYPE_PUSH;
	ent->solid = SOLID_BSP;
	ent->inuse = true;			// since the world doesn't use G_Spawn()
	ent->s.modelindex = 1;		// world model is always index 1

	//---------------

	// reserve some spots for dead player bodies for coop / deathmatch
	InitBodyQue ();

	// set configstrings for items
	SetItemNames ();

	if (st.nextmap)
		strcpy (level.nextmap, st.nextmap);

	// make some data visible to the server

	if (ent->message && ent->message[0])
	{
		gi.configstring (CS_NAME, ent->message);
		strncpy (level.level_name, ent->message, sizeof level.level_name - 1);
	}
	else
		strncpy (level.level_name, level.mapname, sizeof level.level_name);

	if (st.sky && st.sky[0])
		gi.configstring (CS_SKY, st.sky);
	else
		gi.configstring (CS_SKY, "unit1_");

	gi.configstring (CS_SKYROTATE, va("%f", st.skyrotate) );

	gi.configstring (CS_SKYAXIS, va("%f %f %f",
		st.skyaxis[0], st.skyaxis[1], st.skyaxis[2]) );

	gi.configstring (CS_CDTRACK, va("%i", ent->sounds) );

	gi.configstring (CS_MAXCLIENTS, va("%i", (int)(maxclients->value) ) );

	// status bar program
	if (deathmatch->value)
		gi.configstring (CS_STATUSBAR, dm_statusbar);
	else
		gi.configstring (CS_STATUSBAR, single_statusbar);

	//---------------


	// help icon for statusbar
	gi.imageindex ("i_help");
	level.pic_health = gi.imageindex ("i_health");
	gi.imageindex ("help");
	gi.imageindex ("field_3");

	if (!st.gravity)
		gi.cvar_set("sv_gravity", "800");
	else
		gi.cvar_set("sv_gravity", st.gravity);

	snd_fry = gi.soundindex ("player/fry.wav");	// standing in lava / slime

	PrecacheItem (FindItem ("Blaster"));

	gi.soundindex ("player/lava1.wav");
	gi.soundindex ("player/lava2.wav");

	gi.soundindex ("misc/pc_up.wav");
	gi.soundindex ("misc/talk1.wav");

	gi.soundindex ("misc/udeath.wav");

	// gibs
	gi.soundindex ("items/respawn1.wav");

	// sexed sounds
	gi.soundindex ("*death1.wav");
	gi.soundindex ("*death2.wav");
	gi.soundindex ("*death3.wav");
	gi.soundindex ("*death4.wav");
	gi.soundindex ("*fall1.wav");
	gi.soundindex ("*fall2.wav");	
	gi.soundindex ("*gurp1.wav");		// drowning damage
	gi.soundindex ("*gurp2.wav");	
	gi.soundindex ("*jump1.wav");		// player jump
	gi.soundindex ("*pain25_1.wav");
	gi.soundindex ("*pain25_2.wav");
	gi.soundindex ("*pain50_1.wav");
	gi.soundindex ("*pain50_2.wav");
	gi.soundindex ("*pain75_1.wav");
	gi.soundindex ("*pain75_2.wav");
	gi.soundindex ("*pain100_1.wav");
	gi.soundindex ("*pain100_2.wav");

	// sexed models
	// THIS ORDER MUST MATCH THE DEFINES IN g_local.h
	// you can add more, max 15
	gi.modelindex ("#w_blaster.md2");
	gi.modelindex ("#w_shotgun.md2");
	gi.modelindex ("#w_sshotgun.md2");
	gi.modelindex ("#w_machinegun.md2");
	gi.modelindex ("#w_chaingun.md2");
	gi.modelindex ("#a_grenades.md2");
	gi.modelindex ("#w_glauncher.md2");
	gi.modelindex ("#w_rlauncher.md2");
	gi.modelindex ("#w_hyperblaster.md2");
	gi.modelindex ("#w_railgun.md2");
	gi.modelindex ("#w_bfg.md2");
 	gi.modelindex ("#w_plasma.md2"); // SKWiD MOD

	//-------------------

	gi.soundindex ("player/gasp1.wav");		// gasping for air
	gi.soundindex ("player/gasp2.wav");		// head breaking surface, not gasping

	gi.soundindex ("player/watr_in.wav");	// feet hitting water
	gi.soundindex ("player/watr_out.wav");	// feet leaving water

	gi.soundindex ("player/watr_un.wav");	// head going underwater
	
	gi.soundindex ("player/u_breath1.wav");
	gi.soundindex ("player/u_breath2.wav");

	gi.soundindex ("items/pkup.wav");		// bonus item pickup
	gi.soundindex ("world/land.wav");		// landing thud
	gi.soundindex ("misc/h2ohit1.wav");		// landing splash

	gi.soundindex ("items/damage.wav");
	gi.soundindex ("items/protect.wav");
	gi.soundindex ("items/protect4.wav");
	gi.soundindex ("weapons/noammo.wav");

	gi.soundindex ("infantry/inflies1.wav");

	sm_meat_index = gi.modelindex ("models/objects/gibs/sm_meat/tris.md2");
	gi.modelindex ("models/objects/gibs/arm/tris.md2");
	gi.modelindex ("models/objects/gibs/bone/tris.md2");
	gi.modelindex ("models/objects/gibs/bone2/tris.md2");
	gi.modelindex ("models/objects/gibs/chest/tris.md2");
	gi.modelindex ("models/objects/gibs/skull/tris.md2");
	gi.modelindex ("models/objects/gibs/head2/tris.md2");

//
// Setup light animation tables. 'a' is total darkness, 'z' is doublebright.
//

	// 0 normal
	gi.configstring(CS_LIGHTS+0, "m");
	
	// 1 FLICKER (first variety)
	gi.configstring(CS_LIGHTS+1, "mmnmmommommnonmmonqnmmo");
	
	// 2 SLOW STRONG PULSE
	gi.configstring(CS_LIGHTS+2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba");
	
	// 3 CANDLE (first variety)
	gi.configstring(CS_LIGHTS+3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg");
	
	// 4 FAST STROBE
	gi.configstring(CS_LIGHTS+4, "mamamamamama");
	
	// 5 GENTLE PULSE 1
	gi.configstring(CS_LIGHTS+5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj");
	
	// 6 FLICKER (second variety)
	gi.configstring(CS_LIGHTS+6, "nmonqnmomnmomomno");
	
	// 7 CANDLE (second variety)
	gi.configstring(CS_LIGHTS+7, "mmmaaaabcdefgmmmmaaaammmaamm");
	
	// 8 CANDLE (third variety)
	gi.configstring(CS_LIGHTS+8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa");
	
	// 9 SLOW STROBE (fourth variety)
	gi.configstring(CS_LIGHTS+9, "aaaaaaaazzzzzzzz");
	
	// 10 FLUORESCENT FLICKER
	gi.configstring(CS_LIGHTS+10, "mmamammmmammamamaaamammma");

	// 11 SLOW PULSE NOT FADE TO BLACK
	gi.configstring(CS_LIGHTS+11, "abcdefghijklmnopqrrqponmlkjihgfedcba");
	
	// styles 32-62 are assigned by the light program for switchable lights

	// 63 testing
	gi.configstring(CS_LIGHTS+63, "a");
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x2, 0x118(%rdi)
movl $0x3, 0x108(%rdi)
pushq $0x1
popq %rax
movl %eax, 0x60(%rdi)
movl %eax, 0x28(%rdi)
callq 0x18b90
callq 0x18ea0
movq 0x2f4e7(%rip), %r15     # 0x66668
movq 0x18(%r15), %rsi
testq %rsi, %rsi
je 0x3719b
movl $0x88, %edi
addq 0x2fc0a(%rip), %rdi     # 0x66da0
callq 0x182c0
movq 0x130(%rbx), %rsi
testq %rsi, %rsi
je 0x371ce
cmpb $0x0, (%rsi)
je 0x371ce
movq 0x2f44d(%rip), %rax     # 0x66600
xorl %edi, %edi
callq *0x30(%rax)
movq 0x130(%rbx), %rsi
movq 0x2fbda(%rip), %rdi     # 0x66da0
addq $0x8, %rdi
pushq $0x3f
jmp 0x371df
movq 0x2fbcb(%rip), %rsi     # 0x66da0
leaq 0x8(%rsi), %rdi
addq $0x48, %rsi
pushq $0x40
popq %rdx
callq 0x181e0
movq (%r15), %rsi
testq %rsi, %rsi
je 0x371f2
cmpb $0x0, (%rsi)
jne 0x371f9
leaq 0x1d912(%rip), %rsi     # 0x54b0b
movq 0x2f400(%rip), %r14     # 0x66600
pushq $0x2
popq %rdi
callq *0x30(%r14)
movq 0x30(%r14), %r12
cvtss2sd 0x8(%r15), %xmm0
leaq 0x1d482(%rip), %rdi     # 0x5469a
movb $0x1, %al
callq 0x194e0
pushq $0x4
popq %rdi
movq %rax, %rsi
callq *%r12
movq 0x30(%r14), %r12
cvtss2sd 0xc(%r15), %xmm0
cvtss2sd 0x10(%r15), %xmm1
cvtss2sd 0x14(%r15), %xmm2
leaq 0x1d44f(%rip), %rdi     # 0x54694
movb $0x3, %al
callq 0x194e0
pushq $0x3
popq %rdi
movq %rax, %rsi
callq *%r12
movq 0x30(%r14), %r12
movl 0x28c(%rbx), %esi
leaq 0x17608(%rip), %rbx     # 0x4e86e
movq %rbx, %rdi
xorl %eax, %eax
callq 0x194e0
pushq $0x1
popq %rdi
movq %rax, %rsi
callq *%r12
movq 0x30(%r14), %r12
movq 0x2f2ac(%rip), %rax     # 0x66530
movq (%rax), %rax
cvttss2si 0x20(%rax), %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x194e0
pushq $0x1e
popq %rdi
movq %rax, %rsi
callq *%r12
movq 0x2fc1a(%rip), %rax     # 0x66ec0
movq (%rax), %rax
xorps %xmm0, %xmm0
ucomiss 0x20(%rax), %xmm0
movq 0x2f261(%rip), %rax     # 0x66518
movq 0x2f212(%rip), %rcx     # 0x664d0
cmovneq %rax, %rcx
cmovpq %rax, %rcx
movq (%rcx), %rsi
pushq $0x5
popq %rdi
callq *0x30(%r14)
leaq 0x1d83b(%rip), %rdi     # 0x54b12
callq *0x50(%r14)
leaq 0x1bd3b(%rip), %rdi     # 0x5301d
callq *0x50(%r14)
movq 0x2fab3(%rip), %rcx     # 0x66da0
movl %eax, 0x12c(%rcx)
leaq 0x1d81a(%rip), %rdi     # 0x54b14
callq *0x50(%r14)
leaq 0x1d814(%rip), %rdi     # 0x54b19
callq *0x50(%r14)
movq 0x48(%r15), %rax
testq %rax, %rax
leaq 0x1cad2(%rip), %rsi     # 0x53de9
cmovneq %rax, %rsi
leaq 0x1cabc(%rip), %rdi     # 0x53dde
callq *0x128(%r14)
leaq 0x1d7f1(%rip), %rdi     # 0x54b21
callq *0x48(%r14)
movq 0x2f1c5(%rip), %rcx     # 0x66500
movl %eax, (%rcx)
leaq 0x1b4d3(%rip), %rdi     # 0x52817
callq 0x18a80
movq %rax, %rdi
callq 0x187f0
leaq 0x180d0(%rip), %rdi     # 0x4f428
callq *0x48(%r14)
leaq 0x1d7cd(%rip), %rdi     # 0x54b30
callq *0x48(%r14)
leaq 0x1d7d3(%rip), %rdi     # 0x54b41
callq *0x48(%r14)
leaq 0x1a9f6(%rip), %rdi     # 0x51d6f
callq *0x48(%r14)
leaq 0x1c3b6(%rip), %rdi     # 0x5373a
callq *0x48(%r14)
leaq 0x1d7c1(%rip), %rdi     # 0x54b50
callq *0x48(%r14)
leaq 0x1d7c9(%rip), %rdi     # 0x54b63
callq *0x48(%r14)
leaq 0x1d7ca(%rip), %rdi     # 0x54b6f
callq *0x48(%r14)
leaq 0x1d7cb(%rip), %rdi     # 0x54b7b
callq *0x48(%r14)
leaq 0x1d7cc(%rip), %rdi     # 0x54b87
callq *0x48(%r14)
leaq 0x1d7cd(%rip), %rdi     # 0x54b93
callq *0x48(%r14)
leaq 0x1d7cd(%rip), %rdi     # 0x54b9e
callq *0x48(%r14)
leaq 0x1d7cd(%rip), %rdi     # 0x54ba9
callq *0x48(%r14)
leaq 0x1d7cd(%rip), %rdi     # 0x54bb4
callq *0x48(%r14)
leaq 0x1d7cd(%rip), %rdi     # 0x54bbf
callq *0x48(%r14)
leaq 0x1d7cd(%rip), %rdi     # 0x54bca
callq *0x48(%r14)
leaq 0x1d7d0(%rip), %rdi     # 0x54bd8
callq *0x48(%r14)
leaq 0x1d7d3(%rip), %rdi     # 0x54be6
callq *0x48(%r14)
leaq 0x1d7d6(%rip), %rdi     # 0x54bf4
callq *0x48(%r14)
leaq 0x1d7d9(%rip), %rdi     # 0x54c02
callq *0x48(%r14)
leaq 0x1d7dc(%rip), %rdi     # 0x54c10
callq *0x48(%r14)
leaq 0x1d7df(%rip), %rdi     # 0x54c1e
callq *0x48(%r14)
leaq 0x1d7e3(%rip), %rdi     # 0x54c2d
callq *0x48(%r14)
leaq 0x1d7e7(%rip), %rdi     # 0x54c3c
callq *0x40(%r14)
leaq 0x1d7eb(%rip), %rdi     # 0x54c4b
callq *0x40(%r14)
leaq 0x1d7ef(%rip), %rdi     # 0x54c5a
callq *0x40(%r14)
leaq 0x1d7f4(%rip), %rdi     # 0x54c6a
callq *0x40(%r14)
leaq 0x1d7fb(%rip), %rdi     # 0x54c7c
callq *0x40(%r14)
leaq 0x1d800(%rip), %rdi     # 0x54c8c
callq *0x40(%r14)
leaq 0x1d805(%rip), %rdi     # 0x54c9c
callq *0x40(%r14)
leaq 0x1d80b(%rip), %rdi     # 0x54cad
callq *0x40(%r14)
leaq 0x1d811(%rip), %rdi     # 0x54cbe
callq *0x40(%r14)
leaq 0x1d81a(%rip), %rdi     # 0x54cd2
callq *0x40(%r14)
leaq 0x1d81e(%rip), %rdi     # 0x54ce1
callq *0x40(%r14)
leaq 0x1d81e(%rip), %rdi     # 0x54cec
callq *0x40(%r14)
leaq 0x1d821(%rip), %rdi     # 0x54cfa
callq *0x48(%r14)
leaq 0x1d827(%rip), %rdi     # 0x54d0b
callq *0x48(%r14)
leaq 0x1d82d(%rip), %rdi     # 0x54d1c
callq *0x48(%r14)
leaq 0x1d835(%rip), %rdi     # 0x54d2f
callq *0x48(%r14)
leaq 0x1d83e(%rip), %rdi     # 0x54d43
callq *0x48(%r14)
leaq 0x1d846(%rip), %rdi     # 0x54d56
callq *0x48(%r14)
leaq 0x1d850(%rip), %rdi     # 0x54d6b
callq *0x48(%r14)
leaq 0x1b633(%rip), %rdi     # 0x52b59
callq *0x48(%r14)
leaq 0x1c56a(%rip), %rdi     # 0x53a9b
callq *0x48(%r14)
leaq 0x1c54e(%rip), %rdi     # 0x53a8a
callq *0x48(%r14)
leaq 0x1aa8f(%rip), %rdi     # 0x51fd6
callq *0x48(%r14)
leaq 0x1aa95(%rip), %rdi     # 0x51fe7
callq *0x48(%r14)
leaq 0x1b6ad(%rip), %rdi     # 0x52c0a
callq *0x48(%r14)
leaq 0x187c7(%rip), %rdi     # 0x4fd2f
callq *0x48(%r14)
leaq 0x1d80d(%rip), %rdi     # 0x54d80
callq *0x48(%r14)
leaq 0x1c1cc(%rip), %rdi     # 0x5374a
callq *0x40(%r14)
movq 0x2fa67(%rip), %rcx     # 0x66ff0
movl %eax, (%rcx)
leaq 0x1c32c(%rip), %rdi     # 0x538be
callq *0x40(%r14)
leaq 0x1d7f9(%rip), %rdi     # 0x54d96
callq *0x40(%r14)
leaq 0x1d810(%rip), %rdi     # 0x54db8
callq *0x40(%r14)
leaq 0x1d828(%rip), %rdi     # 0x54ddb
callq *0x40(%r14)
leaq 0x1bf84(%rip), %rdi     # 0x53542
callq *0x40(%r14)
leaq 0x1bf56(%rip), %rdi     # 0x5351f
callq *0x40(%r14)
leaq 0x16c8b(%rip), %rsi     # 0x4e25f
movl $0x320, %edi            # imm = 0x320
callq *0x30(%r14)
leaq 0x1d81a(%rip), %rsi     # 0x54dfe
movl $0x321, %edi            # imm = 0x321
callq *0x30(%r14)
leaq 0x1d822(%rip), %rsi     # 0x54e16
movl $0x322, %edi            # imm = 0x322
callq *0x30(%r14)
leaq 0x1d846(%rip), %rsi     # 0x54e4a
movl $0x323, %edi            # imm = 0x323
callq *0x30(%r14)
leaq 0x1d859(%rip), %rsi     # 0x54e6d
movl $0x324, %edi            # imm = 0x324
callq *0x30(%r14)
leaq 0x1d856(%rip), %rsi     # 0x54e7a
movl $0x325, %edi            # imm = 0x325
callq *0x30(%r14)
leaq 0x1d868(%rip), %rsi     # 0x54e9c
movl $0x326, %edi            # imm = 0x326
callq *0x30(%r14)
leaq 0x1d86a(%rip), %rsi     # 0x54eae
movl $0x327, %edi            # imm = 0x327
callq *0x30(%r14)
leaq 0x1d877(%rip), %rsi     # 0x54ecb
movl $0x328, %edi            # imm = 0x328
callq *0x30(%r14)
leaq 0x1d892(%rip), %rsi     # 0x54ef6
movl $0x329, %edi            # imm = 0x329
callq *0x30(%r14)
leaq 0x1d893(%rip), %rsi     # 0x54f07
movl $0x32a, %edi            # imm = 0x32A
callq *0x30(%r14)
leaq 0x1d89d(%rip), %rsi     # 0x54f21
movl $0x32b, %edi            # imm = 0x32B
callq *0x30(%r14)
movq 0x30(%r14), %rax
leaq 0x17030(%rip), %rsi     # 0x4e6c8
movl $0x35f, %edi            # imm = 0x35F
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmpq *%rax