// File: /workspace/github_c_makefile_star2_O3/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)
movl $0x1, %eax
movl %eax, 0x60(%rdi)
movl %eax, 0x28(%rdi)
callq 0x18af0
callq 0x18d80
movq 0x2e331(%rip), %r15     # 0x68668
movq 0x18(%r15), %rsi
testq %rsi, %rsi
je 0x3a351
movl $0x88, %edi
addq 0x2ea54(%rip), %rdi     # 0x68da0
callq 0x182a0
movq 0x130(%rbx), %rsi
testq %rsi, %rsi
je 0x3a387
cmpb $0x0, (%rsi)
je 0x3a387
movq 0x2e297(%rip), %rax     # 0x68600
xorl %edi, %edi
callq *0x30(%rax)
movq 0x130(%rbx), %rsi
movq 0x2ea24(%rip), %rdi     # 0x68da0
addq $0x8, %rdi
movl $0x3f, %edx
jmp 0x3a39b
movq 0x2ea12(%rip), %rsi     # 0x68da0
leaq 0x8(%rsi), %rdi
addq $0x48, %rsi
movl $0x40, %edx
callq 0x181c0
movq (%r15), %rsi
testq %rsi, %rsi
je 0x3a3ad
cmpb $0x0, (%rsi)
jne 0x3a3b4
leaq 0x1e777(%rip), %rsi     # 0x58b2b
movq 0x2e245(%rip), %r14     # 0x68600
movl $0x2, %edi
callq *0x30(%r14)
movq 0x30(%r14), %r12
cvtss2sd 0x8(%r15), %xmm0
leaq 0x1e2e5(%rip), %rdi     # 0x586ba
movb $0x1, %al
callq 0x19340
movl $0x4, %edi
movq %rax, %rsi
callq *%r12
movq 0x30(%r14), %r12
xorps %xmm0, %xmm0
cvtss2sd 0xc(%r15), %xmm0
cvtss2sd 0x10(%r15), %xmm1
cvtss2sd 0x14(%r15), %xmm2
leaq 0x1e2ad(%rip), %rdi     # 0x586b4
movb $0x3, %al
callq 0x19340
movl $0x3, %edi
movq %rax, %rsi
callq *%r12
movq 0x30(%r14), %r12
movl 0x28c(%rbx), %esi
leaq 0x18444(%rip), %rbx     # 0x5286e
movq %rbx, %rdi
xorl %eax, %eax
callq 0x19340
movl $0x1, %edi
movq %rax, %rsi
callq *%r12
movq 0x30(%r14), %r12
movq 0x2e0e6(%rip), %rax     # 0x68530
movq (%rax), %rax
cvttss2si 0x20(%rax), %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x19340
movl $0x1e, %edi
movq %rax, %rsi
callq *%r12
movq 0x2ea52(%rip), %rax     # 0x68ec0
movq (%rax), %rax
xorps %xmm0, %xmm0
ucomiss 0x20(%rax), %xmm0
movq 0x2e099(%rip), %rax     # 0x68518
movq 0x2e04a(%rip), %rcx     # 0x684d0
cmovneq %rax, %rcx
cmovpq %rax, %rcx
movq (%rcx), %rsi
movl $0x5, %edi
callq *0x30(%r14)
leaq 0x1e691(%rip), %rdi     # 0x58b32
callq *0x50(%r14)
leaq 0x1cb91(%rip), %rdi     # 0x5703d
callq *0x50(%r14)
movq 0x2e8e9(%rip), %rcx     # 0x68da0
movl %eax, 0x12c(%rcx)
leaq 0x1e670(%rip), %rdi     # 0x58b34
callq *0x50(%r14)
leaq 0x1e66a(%rip), %rdi     # 0x58b39
callq *0x50(%r14)
movq 0x48(%r15), %rax
testq %rax, %rax
leaq 0x1d928(%rip), %rsi     # 0x57e09
cmovneq %rax, %rsi
leaq 0x1d912(%rip), %rdi     # 0x57dfe
callq *0x128(%r14)
leaq 0x1e647(%rip), %rdi     # 0x58b41
callq *0x48(%r14)
movq 0x2dffb(%rip), %rcx     # 0x68500
movl %eax, (%rcx)
leaq 0x1c329(%rip), %rdi     # 0x56837
callq 0x189e0
movq %rax, %rdi
callq 0x18790
leaq 0x18f06(%rip), %rdi     # 0x53428
callq *0x48(%r14)
leaq 0x1e623(%rip), %rdi     # 0x58b50
callq *0x48(%r14)
leaq 0x1e629(%rip), %rdi     # 0x58b61
callq *0x48(%r14)
leaq 0x1b84c(%rip), %rdi     # 0x55d8f
callq *0x48(%r14)
leaq 0x1d20c(%rip), %rdi     # 0x5775a
callq *0x48(%r14)
leaq 0x1e617(%rip), %rdi     # 0x58b70
callq *0x48(%r14)
leaq 0x1e61f(%rip), %rdi     # 0x58b83
callq *0x48(%r14)
leaq 0x1e620(%rip), %rdi     # 0x58b8f
callq *0x48(%r14)
leaq 0x1e621(%rip), %rdi     # 0x58b9b
callq *0x48(%r14)
leaq 0x1e622(%rip), %rdi     # 0x58ba7
callq *0x48(%r14)
leaq 0x1e623(%rip), %rdi     # 0x58bb3
callq *0x48(%r14)
leaq 0x1e623(%rip), %rdi     # 0x58bbe
callq *0x48(%r14)
leaq 0x1e623(%rip), %rdi     # 0x58bc9
callq *0x48(%r14)
leaq 0x1e623(%rip), %rdi     # 0x58bd4
callq *0x48(%r14)
leaq 0x1e623(%rip), %rdi     # 0x58bdf
callq *0x48(%r14)
leaq 0x1e623(%rip), %rdi     # 0x58bea
callq *0x48(%r14)
leaq 0x1e626(%rip), %rdi     # 0x58bf8
callq *0x48(%r14)
leaq 0x1e629(%rip), %rdi     # 0x58c06
callq *0x48(%r14)
leaq 0x1e62c(%rip), %rdi     # 0x58c14
callq *0x48(%r14)
leaq 0x1e62f(%rip), %rdi     # 0x58c22
callq *0x48(%r14)
leaq 0x1e632(%rip), %rdi     # 0x58c30
callq *0x48(%r14)
leaq 0x1e635(%rip), %rdi     # 0x58c3e
callq *0x48(%r14)
leaq 0x1e639(%rip), %rdi     # 0x58c4d
callq *0x48(%r14)
leaq 0x1e63d(%rip), %rdi     # 0x58c5c
callq *0x40(%r14)
leaq 0x1e641(%rip), %rdi     # 0x58c6b
callq *0x40(%r14)
leaq 0x1e645(%rip), %rdi     # 0x58c7a
callq *0x40(%r14)
leaq 0x1e64a(%rip), %rdi     # 0x58c8a
callq *0x40(%r14)
leaq 0x1e651(%rip), %rdi     # 0x58c9c
callq *0x40(%r14)
leaq 0x1e656(%rip), %rdi     # 0x58cac
callq *0x40(%r14)
leaq 0x1e65b(%rip), %rdi     # 0x58cbc
callq *0x40(%r14)
leaq 0x1e661(%rip), %rdi     # 0x58ccd
callq *0x40(%r14)
leaq 0x1e667(%rip), %rdi     # 0x58cde
callq *0x40(%r14)
leaq 0x1e670(%rip), %rdi     # 0x58cf2
callq *0x40(%r14)
leaq 0x1e674(%rip), %rdi     # 0x58d01
callq *0x40(%r14)
leaq 0x1e674(%rip), %rdi     # 0x58d0c
callq *0x40(%r14)
leaq 0x1e677(%rip), %rdi     # 0x58d1a
callq *0x48(%r14)
leaq 0x1e67d(%rip), %rdi     # 0x58d2b
callq *0x48(%r14)
leaq 0x1e683(%rip), %rdi     # 0x58d3c
callq *0x48(%r14)
leaq 0x1e68b(%rip), %rdi     # 0x58d4f
callq *0x48(%r14)
leaq 0x1e694(%rip), %rdi     # 0x58d63
callq *0x48(%r14)
leaq 0x1e69c(%rip), %rdi     # 0x58d76
callq *0x48(%r14)
leaq 0x1e6a6(%rip), %rdi     # 0x58d8b
callq *0x48(%r14)
leaq 0x1c489(%rip), %rdi     # 0x56b79
callq *0x48(%r14)
leaq 0x1d3c0(%rip), %rdi     # 0x57abb
callq *0x48(%r14)
leaq 0x1d3a4(%rip), %rdi     # 0x57aaa
callq *0x48(%r14)
leaq 0x1b8e5(%rip), %rdi     # 0x55ff6
callq *0x48(%r14)
leaq 0x1b8eb(%rip), %rdi     # 0x56007
callq *0x48(%r14)
leaq 0x1c503(%rip), %rdi     # 0x56c2a
callq *0x48(%r14)
leaq 0x195fd(%rip), %rdi     # 0x53d2f
callq *0x48(%r14)
leaq 0x1e663(%rip), %rdi     # 0x58da0
callq *0x48(%r14)
leaq 0x1d022(%rip), %rdi     # 0x5776a
callq *0x40(%r14)
movq 0x2e89d(%rip), %rcx     # 0x68ff0
movl %eax, (%rcx)
leaq 0x1d182(%rip), %rdi     # 0x578de
callq *0x40(%r14)
leaq 0x1e64f(%rip), %rdi     # 0x58db6
callq *0x40(%r14)
leaq 0x1e666(%rip), %rdi     # 0x58dd8
callq *0x40(%r14)
leaq 0x1e67e(%rip), %rdi     # 0x58dfb
callq *0x40(%r14)
leaq 0x1cdda(%rip), %rdi     # 0x57562
callq *0x40(%r14)
leaq 0x1cdac(%rip), %rdi     # 0x5753f
callq *0x40(%r14)
leaq 0x17ac1(%rip), %rsi     # 0x5225f
movl $0x320, %edi            # imm = 0x320
callq *0x30(%r14)
leaq 0x1e670(%rip), %rsi     # 0x58e1e
movl $0x321, %edi            # imm = 0x321
callq *0x30(%r14)
leaq 0x1e678(%rip), %rsi     # 0x58e36
movl $0x322, %edi            # imm = 0x322
callq *0x30(%r14)
leaq 0x1e69c(%rip), %rsi     # 0x58e6a
movl $0x323, %edi            # imm = 0x323
callq *0x30(%r14)
leaq 0x1e6af(%rip), %rsi     # 0x58e8d
movl $0x324, %edi            # imm = 0x324
callq *0x30(%r14)
leaq 0x1e6ac(%rip), %rsi     # 0x58e9a
movl $0x325, %edi            # imm = 0x325
callq *0x30(%r14)
leaq 0x1e6be(%rip), %rsi     # 0x58ebc
movl $0x326, %edi            # imm = 0x326
callq *0x30(%r14)
leaq 0x1e6c0(%rip), %rsi     # 0x58ece
movl $0x327, %edi            # imm = 0x327
callq *0x30(%r14)
leaq 0x1e6cd(%rip), %rsi     # 0x58eeb
movl $0x328, %edi            # imm = 0x328
callq *0x30(%r14)
leaq 0x1e6e8(%rip), %rsi     # 0x58f16
movl $0x329, %edi            # imm = 0x329
callq *0x30(%r14)
leaq 0x1e6e9(%rip), %rsi     # 0x58f27
movl $0x32a, %edi            # imm = 0x32A
callq *0x30(%r14)
leaq 0x1e6f3(%rip), %rsi     # 0x58f41
movl $0x32b, %edi            # imm = 0x32B
callq *0x30(%r14)
movq 0x30(%r14), %rax
leaq 0x17e66(%rip), %rsi     # 0x526c8
movl $0x35f, %edi            # imm = 0x35F
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmpq *%rax