Wing Commander
Reconstructed Win32 source (1996)
Toggle main menu visibility
Loading...
Searching...
No Matches
pload.c
Go to the documentation of this file.
1
/**
2
* @file
3
* @ingroup data
4
* @brief The packet loader.
5
*
6
* Address range 42b050-42b15f. PacketLoad's diagnostic names its source,
7
* `Library\Source\Pload.c`, the only original path the game core keeps.
8
*/
9
#include "
wc1.h
"
10
11
/* Linker commons defined here; LINK orders them by identifier hash. */
12
struct
Shape
*
pTgtLockShapePtr
;
/* 0x005a6bf4 */
13
unsigned
char
*
apTextFonts
[4];
/* 0x005a6c00 */
14
FontWorkspace
**
apFontWorkspaces
[4];
/* 0x005a6c10 */
15
FixedVector
aDirectionViewRightVector
[
DIRECTION_VIEW_COUNT
];
/* 0x005a6c20 */
16
FixedVector
aDirectionViewUpVectorArray
[
DIRECTION_VIEW_COUNT
];
/* 0x005a6f10 */
17
FixedVector
aDirectionViewForwardVector
[
DIRECTION_VIEW_COUNT
];
/* 0x005a7200 */
18
19
/* Function start: 0x42B050 */
20
void
* __stdcall
PacketLoad
(
const
char
*filename,
short
section,
21
void
*destination,
unsigned
short
flags,
22
void
*decompressionWorkspace)
23
{
24
unsigned
char
*packet;
25
PacketSectionHandle
handle;
26
int
compression;
27
28
packet = 0;
29
if
(
OpenPacketSection
(filename, section, &handle) != 0) {
30
compression = handle.
compression
;
31
switch
(compression) {
32
case
1:
33
SystemDebugPrintf
(
34
"[SYSTEM] : ERROR\n"
35
"Library\\Source\\Pload.c PacketLoad Compressed data in '%s'\n"
,
36
filename);
37
SystemDebugPrintf
(
"[SYSTEM] : Exiting prematurely\n"
);
38
ClearDebugPauseFlags
();
39
PumpMessagesDuringWait
();
40
exit(0);
41
packet =
DecompressPacketSection
(
42
&handle, destination, flags, decompressionWorkspace);
43
break
;
44
default
:
45
if
(handle.
dataSize
== 0) {
46
nPacketError
= 8;
47
}
else
{
48
packet = destination;
49
if
(packet == 0) {
50
packet =
AllocateTaggedMemory
(
51
handle.
dataSize
,
52
(
unsigned
short
)(flags | 0x40));
53
pLastPacketAllocation
= packet;
54
if
(packet == 0)
55
nPacketError
= 4;
56
}
57
if
(packet != 0) {
58
if
(
IsPushedPacketHandle
(packet) == 0)
59
exit_squadron
(
60
"qq PacketLoad with non-pushed dest"
);
61
if
(
ReadPacketSectionData
(
62
&handle, packet, handle.
dataSize
) == 0)
63
packet = 0;
64
}
65
}
66
break
;
67
}
68
CloseDataFileByHandle
(&handle);
69
}
70
return
packet;
71
}
pLastPacketAllocation
void * pLastPacketAllocation
Definition
install.c:17
nPacketError
short nPacketError
Definition
mono.c:15
aDirectionViewUpVectorArray
FixedVector aDirectionViewUpVectorArray[DIRECTION_VIEW_COUNT]
Definition
pload.c:16
aDirectionViewForwardVector
FixedVector aDirectionViewForwardVector[DIRECTION_VIEW_COUNT]
Definition
pload.c:17
apTextFonts
unsigned char * apTextFonts[4]
Definition
pload.c:13
pTgtLockShapePtr
struct Shape * pTgtLockShapePtr
Definition
pload.c:12
apFontWorkspaces
FontWorkspace ** apFontWorkspaces[4]
Definition
pload.c:14
aDirectionViewRightVector
FixedVector aDirectionViewRightVector[DIRECTION_VIEW_COUNT]
Definition
pload.c:15
FixedVector
Definition
wcdata.h:321
FontWorkspace
Definition
wc1base.h:225
PacketSectionHandle
Definition
wcdata.h:752
PacketSectionHandle::compression
short compression
Definition
wcdata.h:756
PacketSectionHandle::dataSize
unsigned int dataSize
Definition
wcdata.h:759
Shape
Definition
wc1base.h:90
wc1.h
Umbrella header for the game core.
SystemDebugPrintf
void SystemDebugPrintf(const char *fmt,...)
Definition
pilot.cpp:182
AllocateTaggedMemory
void * AllocateTaggedMemory(int size, unsigned short flags)
Definition
ending.c:31
OpenPacketSection
short __stdcall OpenPacketSection(const char *filename, short section, PacketSectionHandle *handle)
Definition
view.c:371
CloseDataFileByHandle
void __stdcall CloseDataFileByHandle(PacketSectionHandle *p)
Definition
view.c:438
PumpMessagesDuringWait
char PumpMessagesDuringWait(void)
Definition
pilot.cpp:188
IsPushedPacketHandle
int IsPushedPacketHandle(void *handle)
Definition
screen.c:481
ReadPacketSectionData
short __stdcall ReadPacketSectionData(PacketSectionHandle *handle, void *destination, unsigned int length)
Definition
killbrd.c:894
ClearDebugPauseFlags
void ClearDebugPauseFlags(void)
Definition
pilot.cpp:229
exit_squadron
void exit_squadron(const char *msg)
Definition
main.c:122
PacketLoad
void *__stdcall PacketLoad(const char *filename, short section, void *destination, unsigned short flags, void *decompressionWorkspace)
Definition
pload.c:20
DecompressPacketSection
void *__stdcall DecompressPacketSection(PacketSectionHandle *handle, void *destination, unsigned short flags, void *decompressionWorkspace)
Definition
view.c:444
DIRECTION_VIEW_COUNT
#define DIRECTION_VIEW_COUNT
Definition
wcdata.h:1007
src
pload.c
Generated by
1.18.0