// File: FreeSlave[P]vhlt/hlrad/loadtextures.cpp
// Function: TryOpenWadFiles()
void TryOpenWadFiles ()
{
	if (!g_wadfiles_opened)
	{
		g_wadfiles_opened = true;
#ifdef ZHLT_NOWADDIR
		char filename[_MAX_PATH];
		safe_snprintf(filename, _MAX_PATH, "%s.wa_", g_Mapname);
	   if (q_exists (filename))
	   {
		OpenWadFile (filename, true);
	   }
	   else
	   {
		Warning ("Couldn't open %s", filename);
#endif
		Log ("Opening wad files from directories:\n");
		if (!g_waddirs)
		{
			Warning ("No wad directories have been set.");
		}
		else
		{
			waddir_t *dir;
			for (dir = g_waddirs; dir; dir = dir->next)
			{
				Log ("  %s\n", dir->path);
			}
		}
		const char *value = ValueForKey (&g_entities[0], "wad");
		char path[MAX_VAL];
		int i, j;
		for (i = 0, j = 0; i < strlen(value) + 1; i++)
		{
			if (value[i] == ';' || value[i] == '\0')
			{
				path[j] = '\0';
				if (path[0])
				{
					char name[MAX_VAL];
					ExtractFile (path, name);
					DefaultExtension (name, ".wad");
					OpenWadFile (name);
				}
				j = 0;
			}
			else
			{
				path[j] = value[i];
				j++;
			}
		}
#ifdef ZHLT_NOWADDIR
	   }
#endif
		CheckFatal ();
	}
}

// Assembly:
subq $0x3038, %rsp           # imm = 0x3038
testb $0x1, 0x5263282(%rip)   # 0x52a79e0
jne 0x4497a
movb $0x1, 0x5263275(%rip)   # 0x52a79e0
leaq 0x2030(%rsp), %rdi
movl $0x1000, %esi           # imm = 0x1000
leaq 0x27359(%rip), %rdx     # 0x6bad8
leaq 0x38bda(%rip), %rcx     # 0x7d360
movb $0x0, %al
callq 0x94e0
leaq 0x2030(%rsp), %rdi
callq 0xaad0
testb $0x1, %al
jne 0x447a0
jmp 0x447b7
leaq 0x2030(%rsp), %rdi
movl $0x1, %esi
callq 0x44200
jmp 0x44975
leaq 0x2030(%rsp), %rsi
leaq 0x29dc2(%rip), %rdi     # 0x6e588
movb $0x0, %al
callq 0xb9f0
leaq 0x29e80(%rip), %rdi     # 0x6e654
movb $0x0, %al
callq 0xb0d0
cmpq $0x0, 0x52631ed(%rip)   # 0x52a79d0
jne 0x447f5
leaq 0x29e8d(%rip), %rdi     # 0x6e679
movb $0x0, %al
callq 0xb9f0
jmp 0x44840
movq 0x52631d4(%rip), %rax   # 0x52a79d0
movq %rax, 0x2028(%rsp)
cmpq $0x0, 0x2028(%rsp)
je 0x4483e
movq 0x2028(%rsp), %rsi
addq $0x8, %rsi
leaq 0x29e79(%rip), %rdi     # 0x6e69b
movb $0x0, %al
callq 0xb0d0
movq 0x2028(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x2028(%rsp)
jmp 0x44804
jmp 0x44840
leaq 0x202fbf9(%rip), %rdi   # 0x2074440
leaq 0x29e54(%rip), %rsi     # 0x6e6a2
callq 0x7d50
movq %rax, 0x2020(%rsp)
movl $0x0, 0x101c(%rsp)
movl $0x0, 0x1018(%rsp)
movslq 0x101c(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x2020(%rsp), %rdi
callq 0x4170
movq %rax, %rcx
movq 0x8(%rsp), %rax
addq $0x1, %rcx
cmpq %rcx, %rax
jae 0x44973
movq 0x2020(%rsp), %rax
movslq 0x101c(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3b, %eax
je 0x448d2
movq 0x2020(%rsp), %rax
movslq 0x101c(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x44928
movslq 0x1018(%rsp), %rax
movb $0x0, 0x1020(%rsp,%rax)
cmpb $0x0, 0x1020(%rsp)
je 0x4491b
leaq 0x1020(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x9230
leaq 0x10(%rsp), %rdi
leaq 0x29d97(%rip), %rsi     # 0x6e6a1
callq 0x9100
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x44200
movl $0x0, 0x1018(%rsp)
jmp 0x4495b
movq 0x2020(%rsp), %rax
movslq 0x101c(%rsp), %rcx
movb (%rax,%rcx), %cl
movslq 0x1018(%rsp), %rax
movb %cl, 0x1020(%rsp,%rax)
movl 0x1018(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1018(%rsp)
jmp 0x4495d
movl 0x101c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x101c(%rsp)
jmp 0x44871
jmp 0x44975
callq 0xb560
addq $0x3038, %rsp           # imm = 0x3038
retq
nopw %cs:(%rax,%rax)