Wing Commander
Reconstructed Win32 source (1996)
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. */
12struct Shape *pTgtLockShapePtr; /* 0x005a6bf4 */
13unsigned char *apTextFonts[4]; /* 0x005a6c00 */
14FontWorkspace **apFontWorkspaces[4]; /* 0x005a6c10 */
18
19/* Function start: 0x42B050 */
20void * __stdcall PacketLoad(const char *filename, short section,
21 void *destination, unsigned short flags,
22 void *decompressionWorkspace)
23{
24 unsigned char *packet;
26 int compression;
27
28 packet = 0;
29 if (OpenPacketSection(filename, section, &handle) != 0) {
30 compression = handle.compression;
31 switch (compression) {
32 case 1:
34 "[SYSTEM] : ERROR\n"
35 "Library\\Source\\Pload.c PacketLoad Compressed data in '%s'\n",
36 filename);
37 SystemDebugPrintf("[SYSTEM] : Exiting prematurely\n");
40 exit(0);
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)
60 "qq PacketLoad with non-pushed dest");
62 &handle, packet, handle.dataSize) == 0)
63 packet = 0;
64 }
65 }
66 break;
67 }
68 CloseDataFileByHandle(&handle);
69 }
70 return packet;
71}
void * pLastPacketAllocation
Definition install.c:17
short nPacketError
Definition mono.c:15
FixedVector aDirectionViewUpVectorArray[DIRECTION_VIEW_COUNT]
Definition pload.c:16
FixedVector aDirectionViewForwardVector[DIRECTION_VIEW_COUNT]
Definition pload.c:17
unsigned char * apTextFonts[4]
Definition pload.c:13
struct Shape * pTgtLockShapePtr
Definition pload.c:12
FontWorkspace ** apFontWorkspaces[4]
Definition pload.c:14
FixedVector aDirectionViewRightVector[DIRECTION_VIEW_COUNT]
Definition pload.c:15
unsigned int dataSize
Definition wcdata.h:759
Umbrella header for the game core.
void SystemDebugPrintf(const char *fmt,...)
Definition pilot.cpp:182
void * AllocateTaggedMemory(int size, unsigned short flags)
Definition ending.c:31
short __stdcall OpenPacketSection(const char *filename, short section, PacketSectionHandle *handle)
Definition view.c:371
void __stdcall CloseDataFileByHandle(PacketSectionHandle *p)
Definition view.c:438
char PumpMessagesDuringWait(void)
Definition pilot.cpp:188
int IsPushedPacketHandle(void *handle)
Definition screen.c:481
short __stdcall ReadPacketSectionData(PacketSectionHandle *handle, void *destination, unsigned int length)
Definition killbrd.c:894
void ClearDebugPauseFlags(void)
Definition pilot.cpp:229
void exit_squadron(const char *msg)
Definition main.c:122
void *__stdcall PacketLoad(const char *filename, short section, void *destination, unsigned short flags, void *decompressionWorkspace)
Definition pload.c:20
void *__stdcall DecompressPacketSection(PacketSectionHandle *handle, void *destination, unsigned short flags, void *decompressionWorkspace)
Definition view.c:444
#define DIRECTION_VIEW_COUNT
Definition wcdata.h:1007