Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/atsb/NakedAVP
Browse files Browse the repository at this point in the history
  • Loading branch information
atsb committed Apr 14, 2023
2 parents b3201a7 + 6105b36 commit 7e9aa03
Show file tree
Hide file tree
Showing 13 changed files with 105 additions and 105 deletions.
44 changes: 22 additions & 22 deletions src/avp/win95/projload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3128,34 +3128,34 @@ void LoadModuleData()
GLOBALASSERT(env_rif);

/* TODO: dir separator */
HANDLE file = CreateFile ("avp_rifs/module.bbb", GENERIC_WRITE, 0, 0, CREATE_ALWAYS,
HANDLE file = AVPCreateFile ("avp_rifs/module.bbb", GENERIC_WRITE, 0, 0, CREATE_ALWAYS,
FILE_FLAG_RANDOM_ACCESS, 0);
unsigned long byteswritten;
WriteFile(file,&Global_VDB_Ptr->VDB_World,sizeof(VECTORCH),&byteswritten,0);
WriteFile(file,&Global_VDB_Ptr->VDB_Mat,sizeof(MATRIXCH),&byteswritten,0);
AVPWriteFile(file,&Global_VDB_Ptr->VDB_World,sizeof(VECTORCH),&byteswritten,0);
AVPWriteFile(file,&Global_VDB_Ptr->VDB_Mat,sizeof(MATRIXCH),&byteswritten,0);

CloseHandle(file);
AVPCloseHandle(file);

/* TODO: dir separator */
file = CreateFile ("avp_rifs/module.aaa", GENERIC_READ, 0, 0, OPEN_EXISTING,
file = AVPCreateFile ("avp_rifs/module.aaa", GENERIC_READ, 0, 0, OPEN_EXISTING,
FILE_FLAG_RANDOM_ACCESS, 0);

if(file==INVALID_HANDLE_VALUE) return;

if(!env_rif->fc)
{
CloseHandle(file);
AVPCloseHandle(file);
NewOnScreenMessage("MODULE UPDATING REQUIRES -KEEPRIF OPTION.");
return;
}

int file_size=GetFileSize(file,0);
int file_size=AVPGetFileSize(file,0);
GLOBALASSERT((file_size % 4)==0);
int pos=0;
unsigned long bytesread;
{
char name[60];
ReadFile(file,name,60,&bytesread,0);
AVPReadFile(file,name,60,&bytesread,0);

int i=0;
char* name1=&name[0];
Expand All @@ -3180,8 +3180,8 @@ void LoadModuleData()

if(_stricmp(name1,name2))
{
CloseHandle(file);
DeleteFile("avp_rifs\\module.aaa");
AVPCloseHandle(file);
AVPDeleteFile("avp_rifs\\module.aaa");
return;
}

Expand All @@ -3192,7 +3192,7 @@ void LoadModuleData()
while(pos<file_size)
{
int obj_index;
ReadFile(file,&obj_index,4,&bytesread,0);
AVPReadFile(file,&obj_index,4,&bytesread,0);
pos+=4;

Object_Chunk* obj=env_rif->fc->get_object_by_index(obj_index);
Expand All @@ -3201,7 +3201,7 @@ void LoadModuleData()
MODULE* this_mod=&MainScene.sm_module[obj->program_object_index+2];

int numlinks;
ReadFile(file,&numlinks,4,&bytesread,0);
AVPReadFile(file,&numlinks,4,&bytesread,0);
pos+=4;

if(!numlinks) continue;
Expand All @@ -3218,8 +3218,8 @@ void LoadModuleData()
{
int linked_index;
int branch_no;
ReadFile(file,&linked_index,4,&bytesread,0);
ReadFile(file,&branch_no,4,&bytesread,0);
AVPReadFile(file,&linked_index,4,&bytesread,0);
AVPReadFile(file,&branch_no,4,&bytesread,0);
pos+=8;

Object_Chunk* linked_module=env_rif->fc->get_object_by_index(linked_index);
Expand Down Expand Up @@ -3279,8 +3279,8 @@ void LoadModuleData()
*((int *)this_mod->m_vmptr[vmod_no].vmod_name) = vmac_no;
}

CloseHandle(file);
DeleteFile("avp_rifs\\module.aaa");
AVPCloseHandle(file);
AVPDeleteFile("avp_rifs\\module.aaa");
}
#endif

Expand Down Expand Up @@ -3354,7 +3354,7 @@ static BOOL WarnedAboutDiskSpace=FALSE;
static void MakeBackupFile(File_Chunk* fc)
{
unsigned long spc,bps,numclust,total;
if(GetDiskFreeSpace(0,&spc,&bps,&numclust,&total))
if(AVPGetDiskFreeSpace(0,&spc,&bps,&numclust,&total))
{
unsigned int freespace=spc*bps*numclust;
if(freespace<40000000)
Expand All @@ -3370,7 +3370,7 @@ static void MakeBackupFile(File_Chunk* fc)
}
WarnedAboutDiskSpace=FALSE;

CreateDirectory("avp_rifs\\Backup",0);
AVPCreateDirectory("avp_rifs\\Backup",0);
int length=strlen(fc->filename);
int pos=length;
while(pos>=0 && fc->filename[pos]!='\\')pos--;
Expand All @@ -3386,16 +3386,16 @@ static void MakeBackupFile(File_Chunk* fc)
strncpy(&Name1[length],"B0.rif",7);
strncpy(&Name2[length],"B1.rif",7);

DeleteFile(Name1);
AVPDeleteFile(Name1);

for (int i=0;i<9;i++)
{
Name1[length+1]=i+'0';
Name2[length+1]=i+'1';
MoveFile(Name2,Name1);
AVPMoveFile(Name2,Name1);
}
Name2[length+1]='9';
CopyFile(fc->filename,Name2,FALSE);
AVPCopyFile(fc->filename,Name2,FALSE);

delete [] Name1;
delete [] Name2;
Expand All @@ -3416,7 +3416,7 @@ void save_preplaced_decals()

{

DWORD attributes = GetFileAttributes(env_rif->fc->filename);
DWORD attributes = AVPGetFileAttributes(env_rif->fc->filename);
if (0xffffffff!=attributes)
{
if (attributes & FILE_ATTRIBUTE_READONLY)
Expand Down
4 changes: 2 additions & 2 deletions src/avp/win95/strachnk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ BOOL AVP_Strategy_Chunk::output_chunk (HANDLE &hand)

data_block = this->make_data_block_from_chunk();

ok = WriteFile (hand, (long *) data_block, (unsigned long) chunk_size, &junk, 0);
ok = AVPWriteFile (hand, (long *) data_block, (unsigned long) chunk_size, &junk, 0);

delete [] data_block;

Expand Down Expand Up @@ -252,7 +252,7 @@ BOOL AVP_External_Strategy_Chunk::output_chunk (HANDLE &hand)

data_block = this->make_data_block_from_chunk();

ok = WriteFile (hand, (long *) data_block, (unsigned long) chunk_size, &junk, 0);
ok = AVPWriteFile (hand, (long *) data_block, (unsigned long) chunk_size, &junk, 0);

delete [] data_block;

Expand Down
2 changes: 1 addition & 1 deletion src/files.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ void InitGameDirectories(char *argv0)
gamedir = I_GetUserDir();
#endif

#if define __linux__
#if defined __linux__
gamedir = "/usr/local/games/AliensVsPredator/";
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/win95/animchnk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ BOOL Animation_Chunk::output_chunk (HANDLE &hand)

data_block = this->make_data_block_from_chunk();

ok = WriteFile (hand, (long *) data_block, (unsigned long) chunk_size, &junk, 0);
ok = AVPWriteFile (hand, (long *) data_block, (unsigned long) chunk_size, &junk, 0);

delete [] data_block;

Expand Down
22 changes: 11 additions & 11 deletions src/win95/chunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,29 @@ void list_chunks_in_file(List<int> * pList, HANDLE hand, char const * chunk_id)
// assuming we start at the front of a parent chunk,
// containing the child chunk specified

int init_file_pos = SetFilePointer (hand,0,0,FILE_CURRENT);
int init_file_pos = AVPSetFilePointer (hand,0,0,FILE_CURRENT);
int file_pos;
int file_length = GetFileSize(hand, 0);
int file_length = AVPGetFileSize(hand, 0);

SetFilePointer (hand,8,0,FILE_CURRENT);
AVPSetFilePointer (hand,8,0,FILE_CURRENT);

int chunk_length;
int sub_chunk_ln;

ReadFile (hand, (long *) &chunk_length, 4, &bytes_read, 0);
AVPReadFile (hand, (long *) &chunk_length, 4, &bytes_read, 0);

if ((init_file_pos + chunk_length) > file_length) return;

while ((file_pos = SetFilePointer (hand,0,0,FILE_CURRENT))
while ((file_pos = AVPSetFilePointer (hand,0,0,FILE_CURRENT))
< (init_file_pos + chunk_length) && ok) {

ok = ReadFile (hand, (long *) buffer, 8, &bytes_read, 0);
ok = AVPReadFile (hand, (long *) buffer, 8, &bytes_read, 0);
if (strncmp(buffer, chunk_id, 8) == 0)
pList->add_entry(file_pos);

ok = ReadFile (hand, (long *) &sub_chunk_ln, 4, &bytes_read, 0);
ok = AVPReadFile (hand, (long *) &sub_chunk_ln, 4, &bytes_read, 0);

SetFilePointer (hand,sub_chunk_ln-12,0,FILE_CURRENT);
AVPSetFilePointer (hand,sub_chunk_ln-12,0,FILE_CURRENT);
}
}

Expand Down Expand Up @@ -121,7 +121,7 @@ BOOL Chunk::output_chunk (HANDLE & hand)

if (data_block)
{
ok = WriteFile (hand, (long *) data_block, (unsigned long) chunk_size, &junk, 0);
ok = AVPWriteFile (hand, (long *) data_block, (unsigned long) chunk_size, &junk, 0);
delete [] data_block;

if (!ok) return FALSE;
Expand Down Expand Up @@ -279,11 +279,11 @@ BOOL Chunk_With_Children::output_chunk (HANDLE &hand)
Chunk * child_ptr = children;
BOOL ok;

ok = WriteFile (hand, (long *) identifier, 8, &junk, 0);
ok = AVPWriteFile (hand, (long *) identifier, 8, &junk, 0);

if (!ok) return FALSE;

ok = WriteFile (hand, (long *) &chunk_size, 4, &junk, 0);
ok = AVPWriteFile (hand, (long *) &chunk_size, 4, &junk, 0);

if (!ok) return FALSE;

Expand Down
2 changes: 1 addition & 1 deletion src/win95/enumchnk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ BOOL Enum_Header_Chunk::output_chunk (HANDLE & hand)

data_block = make_data_block_from_chunk();

ok = WriteFile (hand, (long *) data_block, (unsigned long) chunk_size, &junk, 0);
ok = AVPWriteFile (hand, (long *) data_block, (unsigned long) chunk_size, &junk, 0);

delete [] data_block;

Expand Down
2 changes: 1 addition & 1 deletion src/win95/envchunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ BOOL Environment_Data_Header_Chunk::output_chunk (HANDLE & hand)

data_block = make_data_block_from_chunk();

ok = WriteFile (hand, (long *) data_block, (unsigned long) chunk_size, &junk, 0);
ok = AVPWriteFile (hand, (long *) data_block, (unsigned long) chunk_size, &junk, 0);

delete [] data_block;

Expand Down
2 changes: 1 addition & 1 deletion src/win95/gsprchnk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ BOOL AllSprites_Header_Chunk::output_chunk (HANDLE & hand)

data_block = make_data_block_from_chunk();

ok = WriteFile (hand, (long *) data_block, (unsigned long) chunk_size, &junk, 0);
ok = AVPWriteFile (hand, (long *) data_block, (unsigned long) chunk_size, &junk, 0);

delete [] data_block;

Expand Down
Loading

0 comments on commit 7e9aa03

Please sign in to comment.