Wing Commander II
Reconstructed Win32 source (1996)
Toggle main menu visibility
Loading...
Searching...
No Matches
pload.c
Go to the documentation of this file.
1
/*
2
* Packet loader (Library\Source\Pload.c).
3
*
4
* Retail object 0x446580-0x44670F (link order; see docs/ORDER.md).
5
*/
6
#include "
game.h
"
7
8
/* Function start: 0x446580 */
9
void
ResetStringBuilder
(
TextContext
*context)
10
{
11
context->
textCursor
= context->
text
;
12
*context->
textCursor
= 0;
13
}
14
15
/* Function start: 0x4465A0 */
16
void
*
PacketLoad
(
const
char
*filename,
short
section,
17
void
*destination,
short
flags,
18
void
*decompressionWorkspace,
19
int
registerHandle)
20
{
21
unsigned
char
*data;
22
PacketSectionHandle
handle;
23
24
data = 0;
25
if
(
OpenPacketSection
(filename, section, &handle) != 0) {
26
switch
(handle.
compression
) {
27
case
1:
28
SystemDebugPrintf
(
29
"[SYSTEM] : ERROR\n"
30
"Library\\Source\\Pload.c PacketLoad Compressed data in '%s'\n"
,
31
filename);
32
SystemDebugPrintf
(
"[SYSTEM] : Exiting prematurely\n"
);
33
ClearDebugPauseFlags
();
34
PumpMessagesDuringWait
();
35
exit(0);
36
break
;
37
default
:
38
if
(handle.
dataSize
== 0) {
39
data = 0;
40
g_nPacketError
= 8;
41
break
;
42
}
43
data = destination;
44
if
(data == 0) {
45
g_26_pLibraryCurrentLastPacketAllocation
=
AllocateTaggedMemory
(
46
handle.
dataSize
, (
short
)(flags | 0x40));
47
data =
g_26_pLibraryCurrentLastPacketAllocation
;
48
if
(data == 0)
49
g_nPacketError
= 4;
50
}
51
if
(data != 0) {
52
if
(registerHandle != 0 &&
53
IsPushedPacketHandle
(data) == 0)
54
exit_squadron
(
55
"qq PacketLoad with non-pushed dest"
);
56
if
(
ReadPacketSectionData
(
57
&handle, data, handle.
dataSize
) == 0)
58
data = 0;
59
}
60
break
;
61
}
62
CloseDataFileByHandle
((
unsigned
short
*)&handle);
63
}
64
return
data;
65
}
PumpMessagesDuringWait
char PumpMessagesDuringWait(void)
Definition
console.cpp:46
PacketLoad
void * PacketLoad(const char *filename, short section, void *destination, short flags, void *decompressionWorkspace, int registerHandle)
Definition
pload.c:16
IsPushedPacketHandle
int IsPushedPacketHandle(void *handle)
Definition
memapi.c:53
ReadPacketSectionData
short ReadPacketSectionData(PacketSectionHandle *handle, void *destination, unsigned int length)
Definition
resread.c:10
OpenPacketSection
short OpenPacketSection(const char *filename, short section, PacketSectionHandle *handle)
Definition
packet.c:14
CloseDataFileByHandle
void CloseDataFileByHandle(unsigned short *handle)
Definition
packet.c:72
AllocateTaggedMemory
void * AllocateTaggedMemory(unsigned int size, short flags)
Definition
memapi.c:92
ClearDebugPauseFlags
void ClearDebugPauseFlags(void)
Definition
console.cpp:82
ResetStringBuilder
void ResetStringBuilder(TextContext *context)
Definition
pload.c:9
exit_squadron
void exit_squadron(const char *msg,...)
Definition
message.c:44
SystemDebugPrintf
void SystemDebugPrintf(const char *format,...)
Definition
console.cpp:30
game.h
Shared Win32 declarations, types and library interfaces.
g_nPacketError
short g_nPacketError
Definition
datafile.c:10
g_26_pLibraryCurrentLastPacketAllocation
void * g_26_pLibraryCurrentLastPacketAllocation
Definition
eventmgr.c:2504
PacketSectionHandle
Definition
game_data.h:1172
PacketSectionHandle::compression
short compression
Definition
game_data.h:1176
PacketSectionHandle::dataSize
unsigned int dataSize
Definition
game_data.h:1179
TextContext
Definition
game.h:283
TextContext::text
char * text
Definition
game.h:290
TextContext::textCursor
char * textCursor
Definition
game.h:291
src
pload.c
Generated by
1.18.0