mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-05 06:00:33 -04:00
you can now visit caredbar!
This commit is contained in:
parent
bf59962724
commit
3b903e2b52
55 changed files with 953 additions and 1428 deletions
|
@ -1,64 +0,0 @@
|
|||
.model small
|
||||
.386
|
||||
|
||||
DGROUP group _DATA
|
||||
|
||||
extrn _start_poss:word
|
||||
extrn _end_poss:word
|
||||
extrn _scr_max_x:dword
|
||||
extrn _scr_next_line:dword
|
||||
|
||||
_TEXT segment byte public 'CODE' use32
|
||||
assume CS:_TEXT
|
||||
assume DS:DGROUP
|
||||
|
||||
public draw_flat_triangle_
|
||||
draw_flat_triangle_:
|
||||
dft_lp2:mov ebx,edi
|
||||
movsx edx,_start_poss[esi*2]
|
||||
lea edi,[ebx+edx*2]
|
||||
cmp dx,_end_poss[esi*2]
|
||||
jz dft_skpa
|
||||
jl dft_dirr
|
||||
std
|
||||
cmp edx,0
|
||||
js dft_skpa
|
||||
cmp edx,_scr_max_x
|
||||
jbe dft_drr1
|
||||
mov edi,_scr_max_x
|
||||
lea edi,[ebx+edi*2]
|
||||
jmp dft_drr1
|
||||
dft_dirr:cld
|
||||
cmp edx,_scr_max_x
|
||||
jg dft_skpa
|
||||
cmp edx,0
|
||||
jns dft_drr1
|
||||
mov edi,ebx
|
||||
dft_drr1:movsx edx,_end_poss[esi*2]
|
||||
cmp edx,0
|
||||
jns dft_dc1
|
||||
xor edx,edx
|
||||
jmp dft_dc2
|
||||
dft_dc1:cmp edx,_scr_max_x
|
||||
jna dft_dc2
|
||||
mov edx,_scr_max_x
|
||||
dft_dc2:shl edx,1
|
||||
add edx,ebx
|
||||
dft_lp1: stosw
|
||||
cmp edi,edx
|
||||
jnz dft_lp1
|
||||
dft_skpa:
|
||||
stosw
|
||||
mov edi,_scr_next_line
|
||||
lea edi,[ebx+edi]
|
||||
inc esi
|
||||
dec ecx
|
||||
jnz dft_lp2
|
||||
cld
|
||||
ret
|
||||
_TEXT ends
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ int DlgDialogy::GetDialogID(const char *name)
|
|||
{
|
||||
Pathname dialogPath=_dlgpath;
|
||||
dialogPath.SetFilename(name);
|
||||
FILE *f=fopen(dialogPath,"r");
|
||||
FILE *f=fopen_icase(dialogPath,"r");
|
||||
if (f==0) return -1;
|
||||
int id;
|
||||
char dialog[40];
|
||||
|
@ -90,7 +90,7 @@ int DlgDialogy::GetDialogID(const char *name)
|
|||
|
||||
void DlgDialogy::LoadDialogyDlg()
|
||||
{
|
||||
FILE *f=fopen(_dlgpath,"r");
|
||||
FILE *f=fopen_icase(_dlgpath,"r");
|
||||
if (f==0) return;
|
||||
|
||||
int p=0;
|
||||
|
@ -149,7 +149,7 @@ void DlgDialogy::OnEdit()
|
|||
|
||||
void DlgDialogy::OnOK()
|
||||
{
|
||||
FILE *f=fopen(_dlgpath,"w");
|
||||
FILE *f=fopen_icase(_dlgpath,"w");
|
||||
if (f==0)
|
||||
{
|
||||
AfxMessageBox(IDS_UNABLETOSAVEDIALOGYDLG,MB_ICONEXCLAMATION);
|
||||
|
@ -236,9 +236,9 @@ void DlgDialogy::OnAdd()
|
|||
dlgName.SetFiletitle(nw.vJmeno);
|
||||
dlgName.SetExtension(".dlg");
|
||||
wList.SetItemText(p,1,dlgName.GetFilename());
|
||||
if (_access(dlgName,0)!=0)
|
||||
if (_check_file_exists(dlgName)!=0)
|
||||
{
|
||||
FILE *f=fopen(dlgName,"w");
|
||||
FILE *f=fopen_icase(dlgName,"w");
|
||||
fprintf(f,"DIALOG(%d)\n",nw.vCislo);
|
||||
fprintf(f,"{\nPICTURE (\"SCREEN\")\nDESC (\"Popis\")\nSTANDARD (1)\n}\n\nSENTENCE (1,0)\n{\n\n}");
|
||||
fclose(f);
|
||||
|
|
|
@ -109,7 +109,7 @@ void DlgNovyDialog::DialogRules()
|
|||
CString name;
|
||||
wJmeno.GetWindowText(name);
|
||||
dlgSource.SetFiletitle(name);
|
||||
wCislo.EnableWindow(access(dlgSource,0)==-1);
|
||||
wCislo.EnableWindow(check_file_exists(dlgSource)==-1);
|
||||
}
|
||||
|
||||
void DlgNovyDialog::OnEditchangeJmeno()
|
||||
|
|
|
@ -496,7 +496,7 @@ bool Pathname::CreateFolder(void *security_descriptor)
|
|||
char *buff=(char *)alloca(len);
|
||||
for (int i=1;GetPart(i,buff,len,-1);i++)
|
||||
{
|
||||
if (begpart==-1 && _access(buff,0)!=0) begpart=i;
|
||||
if (begpart==-1 && _check_file_exists(buff)!=0) begpart=i;
|
||||
if (begpart!=-1)
|
||||
{
|
||||
if (begpart==-1) begpart=i;
|
||||
|
|
377
GIF/Decoder.c
377
GIF/Decoder.c
|
@ -1,377 +0,0 @@
|
|||
/* DECODE.C - An LZW decoder for GIF
|
||||
* Copyright (C) 1987, by Steven A. Bennett
|
||||
*
|
||||
* Permission is given by the author to freely redistribute and include
|
||||
* this code in any program as int32_t as this credit is given where due.
|
||||
*
|
||||
* In accordance with the above, I want to credit Steve Wilhite who wrote
|
||||
* the code which this is heavily inspired by...
|
||||
*
|
||||
* GIF and 'Graphics Interchange Format' are trademarks (tm) of
|
||||
* Compuserve, Incorporated, an H&R Block Company.
|
||||
*
|
||||
* Release Notes: This file contains a decoder routine for GIF images
|
||||
* which is similar, structurally, to the original routine by Steve Wilhite.
|
||||
* It is, however, somewhat noticably faster in most cases.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <malloc.h>
|
||||
#include "std.h"
|
||||
#include "errs.h"
|
||||
|
||||
IMPORT TEXT *malloc(); /* Standard C library allocation */
|
||||
|
||||
/* IMPORT INT get_byte()
|
||||
*
|
||||
* - This external (machine specific) function is expected to return
|
||||
* either the next byte from the GIF file, or a negative number, as
|
||||
* defined in ERRS.H.
|
||||
*/
|
||||
IMPORT INT get_byte();
|
||||
|
||||
/* IMPORT INT out_line(pixels, linelen)
|
||||
* UBYTE pixels[];
|
||||
* INT linelen;
|
||||
*
|
||||
* - This function takes a full line of pixels (one byte per pixel) and
|
||||
* displays them (or does whatever your program wants with them...). It
|
||||
* should return zero, or negative if an error or some other event occurs
|
||||
* which would require aborting the decode process... Note that the length
|
||||
* passed will almost always be equal to the line length passed to the
|
||||
* decoder function, with the sole exception occurring when an ending code
|
||||
* occurs in an odd place in the GIF file... In any case, linelen will be
|
||||
* equal to the number of pixels passed...
|
||||
*/
|
||||
IMPORT INT out_line();
|
||||
|
||||
/* IMPORT INT bad_code_count;
|
||||
*
|
||||
* This value is the only other global required by the using program, and
|
||||
* is incremented each time an out of range code is read by the decoder.
|
||||
* When this value is non-zero after a decode, your GIF file is probably
|
||||
* corrupt in some way...
|
||||
*/
|
||||
//IMPORT INT bad_code_count;
|
||||
int bad_code_count;
|
||||
|
||||
#define NULL 0
|
||||
#define MAX_CODES 4095
|
||||
|
||||
/* Static variables */
|
||||
LOCAL WORD curr_size; /* The current code size */
|
||||
LOCAL WORD clear; /* Value for a clear code */
|
||||
LOCAL WORD ending; /* Value for a ending code */
|
||||
LOCAL WORD newcodes; /* First available code */
|
||||
LOCAL WORD top_slot; /* Highest code for current size */
|
||||
LOCAL WORD slot; /* Last read code */
|
||||
|
||||
/* The following static variables are used
|
||||
* for seperating out codes
|
||||
*/
|
||||
LOCAL WORD navail_bytes = 0; /* # bytes left in block */
|
||||
LOCAL WORD nbits_left = 0; /* # bits left in current byte */
|
||||
LOCAL UTINY b1; /* Current byte */
|
||||
LOCAL UTINY byte_buff[257]; /* Current block */
|
||||
LOCAL UTINY *pbytes; /* Pointer to next byte in block */
|
||||
|
||||
LOCAL LONG code_mask[13] = {
|
||||
0,
|
||||
0x0001, 0x0003,
|
||||
0x0007, 0x000F,
|
||||
0x001F, 0x003F,
|
||||
0x007F, 0x00FF,
|
||||
0x01FF, 0x03FF,
|
||||
0x07FF, 0x0FFF
|
||||
};
|
||||
|
||||
|
||||
/* This function initializes the decoder for reading a new image.
|
||||
*/
|
||||
LOCAL WORD init_exp(size)
|
||||
WORD size;
|
||||
{
|
||||
curr_size = size + 1;
|
||||
top_slot = 1 << curr_size;
|
||||
clear = 1 << size;
|
||||
ending = clear + 1;
|
||||
slot = newcodes = ending + 1;
|
||||
navail_bytes = nbits_left = 0;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* get_next_code()
|
||||
* - gets the next code from the GIF file. Returns the code, or else
|
||||
* a negative number in case of file errors...
|
||||
*/
|
||||
LOCAL WORD get_next_code()
|
||||
{
|
||||
WORD i, x;
|
||||
ULONG ret;
|
||||
|
||||
if (nbits_left == 0)
|
||||
{
|
||||
if (navail_bytes <= 0)
|
||||
{
|
||||
|
||||
/* Out of bytes in current block, so read next block
|
||||
*/
|
||||
pbytes = byte_buff;
|
||||
if ((navail_bytes = get_byte()) < 0)
|
||||
return(navail_bytes);
|
||||
else if (navail_bytes)
|
||||
{
|
||||
for (i = 0; i < navail_bytes; ++i)
|
||||
{
|
||||
if ((x = get_byte()) < 0)
|
||||
return(x);
|
||||
byte_buff[i] = x;
|
||||
}
|
||||
}
|
||||
}
|
||||
b1 = *pbytes++;
|
||||
nbits_left = 8;
|
||||
--navail_bytes;
|
||||
}
|
||||
|
||||
ret = b1 >> (8 - nbits_left);
|
||||
while (curr_size > nbits_left)
|
||||
{
|
||||
if (navail_bytes <= 0)
|
||||
{
|
||||
|
||||
/* Out of bytes in current block, so read next block
|
||||
*/
|
||||
pbytes = byte_buff;
|
||||
if ((navail_bytes = get_byte()) < 0)
|
||||
return(navail_bytes);
|
||||
else if (navail_bytes)
|
||||
{
|
||||
for (i = 0; i < navail_bytes; ++i)
|
||||
{
|
||||
if ((x = get_byte()) < 0)
|
||||
return(x);
|
||||
byte_buff[i] = x;
|
||||
}
|
||||
}
|
||||
}
|
||||
b1 = *pbytes++;
|
||||
ret |= b1 << nbits_left;
|
||||
nbits_left += 8;
|
||||
--navail_bytes;
|
||||
}
|
||||
nbits_left -= curr_size;
|
||||
ret &= code_mask[curr_size];
|
||||
return((WORD)(ret));
|
||||
}
|
||||
|
||||
|
||||
/* The reason we have these seperated like this instead of using
|
||||
* a structure like the original Wilhite code did, is because this
|
||||
* stuff generally produces significantly faster code when compiled...
|
||||
* This code is full of similar speedups... (For a good book on writing
|
||||
* C for speed or for space optomisation, see Efficient C by Tom Plum,
|
||||
* published by Plum-Hall Associates...)
|
||||
*/
|
||||
LOCAL UTINY stack[MAX_CODES + 1]; /* Stack for storing pixels */
|
||||
LOCAL UTINY suffix[MAX_CODES + 1]; /* Suffix table */
|
||||
LOCAL UWORD prefix[MAX_CODES + 1]; /* Prefix linked list */
|
||||
|
||||
/* WORD decoder(linewidth)
|
||||
* WORD linewidth; * Pixels per line of image *
|
||||
*
|
||||
* - This function decodes an LZW image, according to the method used
|
||||
* in the GIF spec. Every *linewidth* "characters" (ie. pixels) decoded
|
||||
* will generate a call to out_line(), which is a user specific function
|
||||
* to display a line of pixels. The function gets it's codes from
|
||||
* get_next_code() which is responsible for reading blocks of data and
|
||||
* seperating them into the proper size codes. Finally, get_byte() is
|
||||
* the global routine to read the next byte from the GIF file.
|
||||
*
|
||||
* It is generally a good idea to have linewidth correspond to the actual
|
||||
* width of a line (as specified in the Image header) to make your own
|
||||
* code a bit simpler, but it isn't absolutely necessary.
|
||||
*
|
||||
* Returns: 0 if successful, else negative. (See ERRS.H)
|
||||
*
|
||||
*/
|
||||
|
||||
WORD decoder(linewidth)
|
||||
WORD linewidth;
|
||||
{
|
||||
FAST UTINY *sp, *bufptr;
|
||||
UTINY *buf;
|
||||
FAST WORD code, fc, oc, bufcnt;
|
||||
WORD c, size, ret;
|
||||
|
||||
/* Initialize for decoding a new image...
|
||||
*/
|
||||
if ((size = get_byte()) < 0)
|
||||
return(size);
|
||||
if (size < 2 || 9 < size)
|
||||
return(BAD_CODE_SIZE);
|
||||
init_exp(size);
|
||||
|
||||
/* Initialize in case they forgot to put in a clear code.
|
||||
* (This shouldn't happen, but we'll try and decode it anyway...)
|
||||
*/
|
||||
oc = fc = 0;
|
||||
|
||||
/* Allocate space for the decode buffer
|
||||
*/
|
||||
if ((buf = (UTINY *)malloc(linewidth + 1)) == NULL)
|
||||
return(OUT_OF_MEMORY);
|
||||
|
||||
/* Set up the stack pointer and decode buffer pointer
|
||||
*/
|
||||
sp = stack;
|
||||
bufptr = buf;
|
||||
bufcnt = linewidth;
|
||||
|
||||
/* This is the main loop. For each code we get we pass through the
|
||||
* linked list of prefix codes, pushing the corresponding "character" for
|
||||
* each code onto the stack. When the list reaches a single "character"
|
||||
* we push that on the stack too, and then start unstacking each
|
||||
* character for output in the correct order. Special handling is
|
||||
* included for the clear code, and the whole thing ends when we get
|
||||
* an ending code.
|
||||
*/
|
||||
while ((c = get_next_code()) != ending)
|
||||
{
|
||||
|
||||
/* If we had a file error, return without completing the decode
|
||||
*/
|
||||
if (c < 0)
|
||||
{
|
||||
free(buf);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* If the code is a clear code, reinitialize all necessary items.
|
||||
*/
|
||||
if (c == clear)
|
||||
{
|
||||
curr_size = size + 1;
|
||||
slot = newcodes;
|
||||
top_slot = 1 << curr_size;
|
||||
|
||||
/* Continue reading codes until we get a non-clear code
|
||||
* (Another unlikely, but possible case...)
|
||||
*/
|
||||
while ((c = get_next_code()) == clear)
|
||||
;
|
||||
|
||||
/* If we get an ending code immediately after a clear code
|
||||
* (Yet another unlikely case), then break out of the loop.
|
||||
*/
|
||||
if (c == ending)
|
||||
break;
|
||||
|
||||
/* Finally, if the code is beyond the range of already set codes,
|
||||
* (This one had better NOT happen... I have no idea what will
|
||||
* result from this, but I doubt it will look good...) then set it
|
||||
* to color zero.
|
||||
*/
|
||||
if (c >= slot)
|
||||
c = 0;
|
||||
|
||||
oc = fc = c;
|
||||
|
||||
/* And let us not forget to put the char into the buffer... And
|
||||
* if, on the off chance, we were exactly one pixel from the end
|
||||
* of the line, we have to send the buffer to the out_line()
|
||||
* routine...
|
||||
*/
|
||||
*bufptr++ = c;
|
||||
if (--bufcnt == 0)
|
||||
{
|
||||
if ((ret = out_line(buf, linewidth)) < 0)
|
||||
{
|
||||
free(buf);
|
||||
return(ret);
|
||||
}
|
||||
bufptr = buf;
|
||||
bufcnt = linewidth;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* In this case, it's not a clear code or an ending code, so
|
||||
* it must be a code code... So we can now decode the code into
|
||||
* a stack of character codes. (Clear as mud, right?)
|
||||
*/
|
||||
code = c;
|
||||
|
||||
/* Here we go again with one of those off chances... If, on the
|
||||
* off chance, the code we got is beyond the range of those already
|
||||
* set up (Another thing which had better NOT happen...) we trick
|
||||
* the decoder into thinking it actually got the last code read.
|
||||
* (Hmmn... I'm not sure why this works... But it does...)
|
||||
*/
|
||||
if (code >= slot)
|
||||
{
|
||||
if (code > slot)
|
||||
++bad_code_count;
|
||||
code = oc;
|
||||
*sp++ = fc;
|
||||
}
|
||||
|
||||
/* Here we scan back along the linked list of prefixes, pushing
|
||||
* helpless characters (ie. suffixes) onto the stack as we do so.
|
||||
*/
|
||||
while (code >= newcodes)
|
||||
{
|
||||
*sp++ = suffix[code];
|
||||
code = prefix[code];
|
||||
}
|
||||
|
||||
/* Push the last character on the stack, and set up the new
|
||||
* prefix and suffix, and if the required slot number is greater
|
||||
* than that allowed by the current bit size, increase the bit
|
||||
* size. (NOTE - If we are all full, we *don't* save the new
|
||||
* suffix and prefix... I'm not certain if this is correct...
|
||||
* it might be more proper to overwrite the last code...
|
||||
*/
|
||||
*sp++ = code;
|
||||
if (slot < top_slot)
|
||||
{
|
||||
suffix[slot] = fc = code;
|
||||
prefix[slot++] = oc;
|
||||
oc = c;
|
||||
}
|
||||
if (slot >= top_slot)
|
||||
if (curr_size < 12)
|
||||
{
|
||||
top_slot <<= 1;
|
||||
++curr_size;
|
||||
}
|
||||
|
||||
/* Now that we've pushed the decoded string (in reverse order)
|
||||
* onto the stack, lets pop it off and put it into our decode
|
||||
* buffer... And when the decode buffer is full, write another
|
||||
* line...
|
||||
*/
|
||||
while (sp > stack)
|
||||
{
|
||||
*bufptr++ = *(--sp);
|
||||
if (--bufcnt == 0)
|
||||
{
|
||||
if ((ret = out_line(buf, linewidth)) < 0)
|
||||
{
|
||||
free(buf);
|
||||
return(ret);
|
||||
}
|
||||
bufptr = buf;
|
||||
bufcnt = linewidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ret = 0;
|
||||
if (bufcnt != linewidth)
|
||||
ret = out_line(buf, (linewidth - bufcnt));
|
||||
free(buf);
|
||||
return(ret);
|
||||
}
|
||||
|
14
GIF/Errs.h
14
GIF/Errs.h
|
@ -1,14 +0,0 @@
|
|||
/* Various error codes used by decoder
|
||||
* and my own routines... It's okay
|
||||
* for you to define whatever you want,
|
||||
* as int32_t as it's negative... It will be
|
||||
* returned intact up the various subroutine
|
||||
* levels...
|
||||
*/
|
||||
#define OUT_OF_MEMORY -10
|
||||
#define BAD_CODE_SIZE -20
|
||||
#define READ_ERROR -1
|
||||
#define WRITE_ERROR -2
|
||||
#define OPEN_ERROR -3
|
||||
#define CREATE_ERROR -4
|
||||
|
16
GIF/GIF.H
16
GIF/GIF.H
|
@ -1,16 +0,0 @@
|
|||
#ifndef _GIF__H
|
||||
#define _GIF__H
|
||||
|
||||
char gif_file [512000];
|
||||
char *gif_picture;
|
||||
char gif_palette [768];
|
||||
int x_0, x_1, y_0, y_1, gif_size;
|
||||
long int gif_pozice=0;
|
||||
int RaW=0;
|
||||
|
||||
int gif_to_buffer (char *filename);
|
||||
|
||||
#define LENGHTGIF 512000
|
||||
|
||||
#endif
|
||||
|
147
GIF/GIF2.C
147
GIF/GIF2.C
|
@ -1,147 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <conio.h>
|
||||
#include <string.h>
|
||||
#include <dos.h>
|
||||
#include "..\types.h"
|
||||
#include "decoder.c"
|
||||
#include "..\bgraph.h"
|
||||
|
||||
|
||||
char *gif_buffer,*gif_ptr;
|
||||
char *decomp_buff,*decomp_ptr;
|
||||
char *comp_buff,*comp_ptr;
|
||||
|
||||
int g_xsize,g_ysize;
|
||||
char paleta[768];
|
||||
|
||||
int get_byte()
|
||||
{
|
||||
return(*gif_ptr++);
|
||||
}
|
||||
|
||||
int curline;
|
||||
char *obrazovka;
|
||||
|
||||
int out_line(char *data,int linelen)
|
||||
{
|
||||
memcpy(obrazovka,data,linelen);
|
||||
memcpy(decomp_ptr,data,linelen);
|
||||
decomp_ptr+=linelen;
|
||||
obrazovka+=640;
|
||||
if (++curline>=g_ysize) return (curline);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void setpalette(char *paleta)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0;i<256;i++)
|
||||
{
|
||||
outp(0x3c6,0xff);
|
||||
outp(0x3c8,i);
|
||||
outp(0x3c9,*paleta++>>2);
|
||||
outp(0x3c9,*paleta++>>2);
|
||||
outp(0x3c9,*paleta++>>2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void load_gif(char *filename)
|
||||
{
|
||||
FILE *pic;
|
||||
long lengif;
|
||||
|
||||
|
||||
pic=fopen(filename,"rb");
|
||||
if (pic==NULL) return;
|
||||
fseek(pic,0,SEEK_END);
|
||||
lengif=ftell(pic);
|
||||
gif_buffer=(char *)malloc(lengif);gif_ptr=gif_buffer;
|
||||
fseek(pic,6,SEEK_SET);
|
||||
fread(&g_xsize,2,1,pic);
|
||||
fread(&g_ysize,2,1,pic);
|
||||
decomp_buff=(char *)malloc(g_xsize*g_ysize);decomp_ptr=decomp_buff;
|
||||
fseek (pic, 0x0d, SEEK_SET);
|
||||
fread(&paleta,768,1,pic);
|
||||
setpalette(paleta);
|
||||
fseek (pic, 0x317, SEEK_SET);
|
||||
lengif-=0x317;
|
||||
fread(gif_buffer,lengif,1,pic);
|
||||
curline=0;
|
||||
decoder(g_xsize);
|
||||
fclose(pic);
|
||||
free(gif_buffer);
|
||||
}
|
||||
|
||||
#define save_nibble(x) if (nibble_sel) {*(comp_ptr++)|=(x)<<4;nibble_sel=!nibble_sel;} else {*(comp_ptr)=(x);nibble_sel=!nibble_sel;}
|
||||
|
||||
int Hi_coder_1()
|
||||
{
|
||||
char palette[8];
|
||||
long state[8];
|
||||
char nibble_sel=0;
|
||||
long picsize,cntr=0;
|
||||
long r_size=0;
|
||||
|
||||
memset(palette,0x0,8);
|
||||
memset(state,0x0,4*8);
|
||||
picsize=g_xsize*g_ysize;
|
||||
|
||||
while (picsize)
|
||||
{
|
||||
char i,b;
|
||||
|
||||
b=*decomp_ptr++;cntr++;
|
||||
for (i=0;i<8;i++) if (palette[i]==b) break;
|
||||
if (i!=8)
|
||||
{
|
||||
save_nibble(i);
|
||||
state[i]=cntr;
|
||||
r_size++;
|
||||
}
|
||||
else
|
||||
{
|
||||
long min=0x7fffffff;char sl=0;
|
||||
|
||||
for (i=0;i<8;i++)
|
||||
if (state[i]<min)
|
||||
{
|
||||
min=state[i];sl=i;
|
||||
}
|
||||
palette[sl]=b;
|
||||
state[sl]=cntr;
|
||||
save_nibble(sl+8);
|
||||
save_nibble(b & 0xf);
|
||||
save_nibble(b >> 4);
|
||||
r_size+=3;
|
||||
}
|
||||
picsize--;
|
||||
}
|
||||
r_size>>=1;
|
||||
return r_size;
|
||||
}
|
||||
|
||||
|
||||
void prepare_compress()
|
||||
{
|
||||
comp_buff=(char *)malloc(512000);
|
||||
comp_ptr=comp_buff;
|
||||
decomp_ptr=decomp_buff;
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
initmode256("..\xlat256.pal");
|
||||
memset(lbuffer,0xff,640*480);
|
||||
getchar();
|
||||
obrazovka=(char *)lbuffer;
|
||||
load_gif("desk_d.gif");
|
||||
prepare_compress();
|
||||
Hi_coder_1();
|
||||
getchar();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "gif.h"
|
||||
|
||||
unsigned short new_palette [256];
|
||||
|
||||
void main (int argc, char *argv[])
|
||||
{
|
||||
FILE *xed;
|
||||
char gif[13];
|
||||
int x,y;
|
||||
|
||||
memmove (gif, argv[1], 13);
|
||||
xed=fopen("new.xed","wb");
|
||||
|
||||
gif_to_buffer (gif);
|
||||
|
||||
y=0;
|
||||
for (x=0; x<=767; x+=3)
|
||||
{
|
||||
new_palette[y]=gif_palette[(x+2)];
|
||||
new_palette[y]|=gif_palette[(x+1)]<<5; //*32;
|
||||
new_palette[y]|=gif_palette[x]<<10; //*1024;
|
||||
y++;
|
||||
}
|
||||
|
||||
fputc (x_0,xed);
|
||||
fputc (x_1,xed);
|
||||
fputc (y_0,xed);
|
||||
fputc (y_1,xed);
|
||||
fputc (8,xed);
|
||||
fputc (0,xed);
|
||||
|
||||
fwrite (new_palette, 256, 2, xed);
|
||||
fwrite (gif_picture, gif_size, 1, xed);
|
||||
|
||||
fclose (xed);
|
||||
}
|
||||
|
61
GIF/Gif.c
61
GIF/Gif.c
|
@ -1,61 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <conio.h>
|
||||
#include <string.h>
|
||||
#include <dos.h>
|
||||
#include "decoder.c"
|
||||
#include "gif.h"
|
||||
|
||||
int get_byte ()
|
||||
{
|
||||
int x;
|
||||
x=gif_file[gif_pozice];
|
||||
gif_pozice++;
|
||||
if (gif_pozice==LENGHTGIF) return (READ_ERROR); else return (x);
|
||||
}
|
||||
|
||||
int out_line (char *pixels, int linelen)
|
||||
{
|
||||
memmove ((gif_picture+linelen*RaW), pixels, linelen);
|
||||
RaW++;
|
||||
if (RaW<=480) return (RaW); else return (0);
|
||||
}
|
||||
|
||||
int gif_to_buffer (char *filename)
|
||||
{
|
||||
FILE *picture;
|
||||
int x;
|
||||
char mezi[4];
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Nacteni GIFu
|
||||
//-------------------------------------------------------------------------
|
||||
picture=fopen(filename,"rb");
|
||||
|
||||
// Read size and alloc memory
|
||||
fseek (picture, 6, SEEK_SET);
|
||||
fread (mezi, 4, 1, picture);
|
||||
gif_size=(mezi[0]+mezi[1]*256)*(mezi[2]+mezi[3]*256);
|
||||
x_0=mezi[0];
|
||||
x_1=mezi[1];
|
||||
y_0=mezi[2];
|
||||
y_1=mezi[3];
|
||||
gif_picture=(char*)malloc( (gif_size*sizeof(gif_picture)) );
|
||||
|
||||
// Read and prepare palette
|
||||
fseek (picture, 0x0d, SEEK_SET);
|
||||
fread (gif_palette, 768, 1, picture);
|
||||
for (x=0; x<=768; x++) gif_palette[x]>>=3;
|
||||
|
||||
// Read coded picture
|
||||
fseek (picture, 0x317, SEEK_SET);
|
||||
fread (gif_file, LENGHTGIF, 1, picture);
|
||||
|
||||
// Decode picture
|
||||
RaW=0;
|
||||
decoder (640);
|
||||
fclose (picture);
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
16
GIF/STD.H
16
GIF/STD.H
|
@ -1,16 +0,0 @@
|
|||
/* STD.H - My own standard header file...
|
||||
*/
|
||||
|
||||
#define LOCAL static
|
||||
#define IMPORT extern
|
||||
|
||||
#define FAST register
|
||||
|
||||
typedef short WORD;
|
||||
typedef unsigned short UWORD;
|
||||
typedef char TEXT;
|
||||
typedef unsigned char UTINY;
|
||||
typedef long LONG;
|
||||
typedef unsigned long ULONG;
|
||||
typedef int INT;
|
||||
|
69
MAPS/MAPY.H
69
MAPS/MAPY.H
|
@ -180,7 +180,8 @@ typedef struct titem
|
|||
char fly_flags; //158 fly_flags
|
||||
word sound; // Rezevovano
|
||||
short v_letu[16]; //192 cisla obrazku vyjadrujici letici predmet
|
||||
int cena;
|
||||
short cena_low;
|
||||
short cena_high;
|
||||
char animace;
|
||||
char hitpos;
|
||||
char shiftup; //posunuti ve vyklenku
|
||||
|
@ -282,41 +283,41 @@ void load_item_map(void *data,int size);
|
|||
#define MAGLOB_LEAVEMAP 0 // v urcitou nastavenou hodinu a minutu dene
|
||||
#define MAGLOB_STARTSLEEP 1 // postavy maji jit spat.
|
||||
#define MAGLOB_ENDSLEEP 2 // postavy se probouzi
|
||||
#define MAGLOB_CLICKSAVE 3 // před otevřením SAVE dialogu
|
||||
#define MAGLOB_AFTERSAVE 4 // po uložení hry
|
||||
#define MAGLOB_BEFOREMAGIC 5 // před vyvoláním kouzla
|
||||
#define MAGLOB_AFTERMAGIC 6 //po vyvolání kouzla
|
||||
#define MAGLOB_BEFOREMAPOPEN 7 //před otevřením mapy
|
||||
#define MAGLOB_AFTERMAPOPEN 8 //po uzavření mapy
|
||||
#define MAGLOB_BEFOREBATTLE 9 //před spuštěním souboje
|
||||
#define MAGLOB_AFTERBATTLE 10 //po ukončení souboje
|
||||
#define MAGLOB_BEFOREBOOK 11 //pred otevřením knihy
|
||||
#define MAGLOB_AFTERBOOK 12 //po uzavření knihy
|
||||
#define MAGLOB_ONROUND 13 //při každém kole nebo po 10s
|
||||
#define MAGLOB_ONDEADMAN 14 //při umrtí muže
|
||||
#define MAGLOB_ONDEADWOMAN 15 //při umrtí ženy
|
||||
#define MAGLOB_ONDEADALL 16 //při umrtí všech postav
|
||||
#define MAGLOB_ONHITMAN 17 //při zásahu muže
|
||||
#define MAGLOB_ONHITWOMAN 18 //při zásahu ženy
|
||||
#define MAGLOB_ONNEWRUNE 19 //při nalezení nové runy
|
||||
#define MAGLOB_ONPICKITEM 20 //při sebrání předmětu (pro speciální předměty)
|
||||
#define MAGLOB_ONSTEP 21 //při kroku (před animaci)
|
||||
#define MAGLOB_ONTURN 22 //při otočení (před animaci)
|
||||
#define MAGLOB_ALARM 23 //při spuštění alarmu
|
||||
#define MAGLOB_CLICKSAVE 3 // p<EFBFBD>ed otev<65>en<65>m SAVE dialogu
|
||||
#define MAGLOB_AFTERSAVE 4 // po ulo<EFBFBD>en<EFBFBD> hry
|
||||
#define MAGLOB_BEFOREMAGIC 5 // p<EFBFBD>ed vyvol<6F>n<EFBFBD>m kouzla
|
||||
#define MAGLOB_AFTERMAGIC 6 //po vyvol<EFBFBD>n<EFBFBD> kouzla
|
||||
#define MAGLOB_BEFOREMAPOPEN 7 //p<EFBFBD>ed otev<65>en<65>m mapy
|
||||
#define MAGLOB_AFTERMAPOPEN 8 //po uzav<EFBFBD>en<EFBFBD> mapy
|
||||
#define MAGLOB_BEFOREBATTLE 9 //p<EFBFBD>ed spu<70>t<EFBFBD>n<EFBFBD>m souboje
|
||||
#define MAGLOB_AFTERBATTLE 10 //po ukon<EFBFBD>en<EFBFBD> souboje
|
||||
#define MAGLOB_BEFOREBOOK 11 //pred otev<EFBFBD>en<EFBFBD>m knihy
|
||||
#define MAGLOB_AFTERBOOK 12 //po uzav<EFBFBD>en<EFBFBD> knihy
|
||||
#define MAGLOB_ONROUND 13 //p<EFBFBD>i ka<6B>d<EFBFBD>m kole nebo po 10s
|
||||
#define MAGLOB_ONDEADMAN 14 //p<EFBFBD>i umrt<72> mu<6D>e
|
||||
#define MAGLOB_ONDEADWOMAN 15 //p<EFBFBD>i umrt<72> <20>eny
|
||||
#define MAGLOB_ONDEADALL 16 //p<EFBFBD>i umrt<72> v<>ech postav
|
||||
#define MAGLOB_ONHITMAN 17 //p<EFBFBD>i z<>sahu mu<6D>e
|
||||
#define MAGLOB_ONHITWOMAN 18 //p<EFBFBD>i z<>sahu <20>eny
|
||||
#define MAGLOB_ONNEWRUNE 19 //p<EFBFBD>i nalezen<65> nov<6F> runy
|
||||
#define MAGLOB_ONPICKITEM 20 //p<EFBFBD>i sebr<62>n<EFBFBD> p<>edm<64>tu (pro speci<63>ln<6C> p<>edm<64>ty)
|
||||
#define MAGLOB_ONSTEP 21 //p<EFBFBD>i kroku (p<>ed animaci)
|
||||
#define MAGLOB_ONTURN 22 //p<EFBFBD>i oto<74>en<65> (p<>ed animaci)
|
||||
#define MAGLOB_ALARM 23 //p<EFBFBD>i spu<70>t<EFBFBD>n<EFBFBD> alarmu
|
||||
#define MAGLOB_ONFIREMAGIC 24
|
||||
#define MAGLOB_ONWATERMAGIC 25
|
||||
#define MAGLOB_ONGROUNDMAGIC 26
|
||||
#define MAGLOB_ONAIRMAGIC 27
|
||||
#define MAGLOB_ONMINDMAGIC 28
|
||||
#define MAGLOB_ONSPELLID1 29 //při jednom konrétním kouzle
|
||||
#define MAGLOB_ONSPELLID2 30 //při jednom konrétním kouzle
|
||||
#define MAGLOB_ONSPELLID3 31 //při jednom konrétním kouzle
|
||||
#define MAGLOB_ONSPELLID4 32 //při jednom konrétním kouzle
|
||||
#define MAGLOB_ONSPELLID5 33 //při jednom konrétním kouzle
|
||||
#define MAGLOB_ONSPELLID6 34 //při jednom konrétním kouzle
|
||||
#define MAGLOB_ONSPELLID7 35 //při jednom konrétním kouzle
|
||||
#define MAGLOB_ONSPELLID8 36 //při jednom konrétním kouzle
|
||||
#define MAGLOB_ONSPELLID9 37 //při jednom konrétním kouzle
|
||||
#define MAGLOB_ONSPELLID1 29 //p<EFBFBD>i jednom konr<6E>tn<74>m kouzle
|
||||
#define MAGLOB_ONSPELLID2 30 //p<EFBFBD>i jednom konr<6E>tn<74>m kouzle
|
||||
#define MAGLOB_ONSPELLID3 31 //p<EFBFBD>i jednom konr<6E>tn<74>m kouzle
|
||||
#define MAGLOB_ONSPELLID4 32 //p<EFBFBD>i jednom konr<6E>tn<74>m kouzle
|
||||
#define MAGLOB_ONSPELLID5 33 //p<EFBFBD>i jednom konr<6E>tn<74>m kouzle
|
||||
#define MAGLOB_ONSPELLID6 34 //p<EFBFBD>i jednom konr<6E>tn<74>m kouzle
|
||||
#define MAGLOB_ONSPELLID7 35 //p<EFBFBD>i jednom konr<6E>tn<74>m kouzle
|
||||
#define MAGLOB_ONSPELLID8 36 //p<EFBFBD>i jednom konr<6E>tn<74>m kouzle
|
||||
#define MAGLOB_ONSPELLID9 37 //p<EFBFBD>i jednom konr<6E>tn<74>m kouzle
|
||||
#define MAGLOB_ONTIMER1 38 //cas - pocet hernich sekund od nastaveni
|
||||
#define MAGLOB_ONTIMER2 39 //cas - pocet hernich sekund od nastaveni
|
||||
#define MAGLOB_ONTIMER3 40 //cas - pocet hernich sekund od nastaveni
|
||||
|
@ -330,7 +331,7 @@ void load_item_map(void *data,int size);
|
|||
#define MAGLOB_ONFLUTE7 48 //zahrani urcite melodie
|
||||
#define MAGLOB_ONFLUTE8 49 //zahrani urcite melodie
|
||||
|
||||
#define MAGLOB_NEXTID 50 //musí být poslední
|
||||
#define MAGLOB_NEXTID 50 //mus<EFBFBD> b<>t posledn<64>
|
||||
|
||||
|
||||
|
||||
|
@ -541,8 +542,8 @@ typedef struct tmob
|
|||
short lives; //pocet zivotu potvory
|
||||
short cislo_vzoru; //informace urcujici ze ktereho vzoru byl mob vytvoren
|
||||
short speed; //rychlost pohybu
|
||||
short dohled; //kam dohl‚dne
|
||||
short dosah; //okam‘ik za‡ tku souboje
|
||||
short dohled; //kam dohl<EFBFBD>dne
|
||||
short dosah; //okam<EFBFBD>ik za<7A><61>tku souboje
|
||||
char stay_strategy; //chovani moba ve statickem modu (nepronasleduje)
|
||||
char walk_data; //cislo potrebne pro pohyb moba v bludisti
|
||||
word bonus; //bonus za zabiti
|
||||
|
|
|
@ -13,7 +13,7 @@ FILE *f;
|
|||
main()
|
||||
{
|
||||
int i;
|
||||
f=fopen("CRC.C","rb");
|
||||
f=fopen_icase("CRC.C","rb");
|
||||
memset(data,0,sizeof(data));
|
||||
delka=fread(data,1,sizeof(data),f);
|
||||
fclose(f);
|
||||
|
|
|
@ -249,7 +249,7 @@ void proved_d(char *code,char *text)
|
|||
main()
|
||||
{
|
||||
char code,text[300];
|
||||
dlg=fopen("test.txt","r");
|
||||
dlg=fopen_icase("test.txt","r");
|
||||
read_pargh();
|
||||
proved_goto(1);
|
||||
proved_d(&code,text);
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <platform.h>
|
||||
#include <iostream>
|
||||
#include <filesystem>
|
||||
#include <regex>
|
||||
|
@ -50,7 +51,7 @@ void save_dump(const uint16_t *screen_addr,
|
|||
}
|
||||
sprintf(c, "dump%04d.bmp", ++dump_counter);
|
||||
SEND_LOG("(DUMP) Saving screen shot named '%s'", c);
|
||||
f = fopen(c, "wb");
|
||||
f = fopen_icase(c, "wb");
|
||||
fputc('B', f);
|
||||
fputc('M', f);
|
||||
i = width * height * 3 + 0x36;
|
||||
|
|
|
@ -33,8 +33,8 @@ void open_files(char *src,char *tgr)
|
|||
if (c>d) d=strchr(tgr,0);
|
||||
strcpy(d,".ENC");
|
||||
}
|
||||
source=fopen(src,"rb");
|
||||
target=fopen(tgr,"wb");
|
||||
source=fopen_icase(src,"rb");
|
||||
target=fopen_icase(tgr,"wb");
|
||||
}
|
||||
|
||||
void close_files()
|
||||
|
|
|
@ -108,7 +108,8 @@ void smeruj_moba(TMOB *m,int smer)
|
|||
|
||||
void save_enemy_paths(TMPFILE_WR *f)
|
||||
{
|
||||
int i,s;
|
||||
short i;
|
||||
int s;
|
||||
word *w;
|
||||
|
||||
for(i=0;i<MAX_MOBS;i++) if (mob_paths[i]!=NULL)
|
||||
|
@ -119,8 +120,8 @@ void save_enemy_paths(TMPFILE_WR *f)
|
|||
temp_storage_write(&s,1*sizeof(s),f);
|
||||
temp_storage_write(mob_path_ptr[i],s*2,f);
|
||||
}
|
||||
s=-1;
|
||||
temp_storage_write(&s,1*2,f);
|
||||
i=-1;
|
||||
temp_storage_write(&i,1*2,f);
|
||||
}
|
||||
|
||||
int load_enemy_paths(TMPFILE_RD *f)
|
||||
|
|
296
game/gamesave.c
296
game/gamesave.c
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include <assert.h>
|
||||
#include <sys/stat.h>
|
||||
#define STATE_CUR_VER 1
|
||||
#define STATE_CUR_VER 2
|
||||
|
||||
#define _GAME_ST "_GAME.TMP"
|
||||
#define _GLOBAL_ST "_GLOBEV.TMP"
|
||||
|
@ -110,7 +110,7 @@ int load_org_map(char *filename,TSTENA **sides,TSECTOR **sectors,TMAP_EDIT_INFO
|
|||
char *c;
|
||||
|
||||
c=find_map_path(filename);
|
||||
f=fopen(c,"rb");free(c);
|
||||
f=fopen_icase(c,"rb");free(c);
|
||||
if (f==NULL) return -1;
|
||||
do
|
||||
{
|
||||
|
@ -163,7 +163,7 @@ void save_daction(TMPFILE_WR *f,int count,D_ACTION *ptr)
|
|||
|
||||
void load_daction(TMPFILE_RD *fsta)
|
||||
{
|
||||
int i,j;
|
||||
uint16_t i,j;
|
||||
i=0;
|
||||
while (d_action!=NULL) //vymaz pripadne delaited actions
|
||||
{
|
||||
|
@ -184,30 +184,30 @@ void load_daction(TMPFILE_RD *fsta)
|
|||
|
||||
void save_items(TMPFILE_WR *f)
|
||||
{
|
||||
int i,j;
|
||||
int32_t i,j;
|
||||
short *c;
|
||||
|
||||
for(i=0;i<mapsize*4;i++)
|
||||
if (map_items[i]!=NULL)
|
||||
{
|
||||
for(j=1,c=map_items[i];*c;c++,j++);
|
||||
temp_storage_write(&i,2,f);
|
||||
temp_storage_write(&j,2,f);
|
||||
temp_storage_write(&i,sizeof(i),f);
|
||||
temp_storage_write(&j,sizeof(j),f);
|
||||
temp_storage_write(map_items[i],2*j,f);
|
||||
}
|
||||
i=-1;
|
||||
temp_storage_write(&i,2,f);
|
||||
temp_storage_write(&i,sizeof(i),f);
|
||||
}
|
||||
|
||||
void restore_items(TMPFILE_RD *f)
|
||||
{
|
||||
short i,j;
|
||||
int32_t i,j;
|
||||
|
||||
for(i=0;i<mapsize*4;i++) if (map_items[i]!=NULL) free(map_items[i]);
|
||||
memset(map_items,0,mapsize*16);
|
||||
while(temp_storage_read(&i,1*2,f) && i!=-1)
|
||||
while(temp_storage_read(&i,sizeof(i),f) && i!=-1)
|
||||
{
|
||||
temp_storage_read(&j,1*2,f);
|
||||
temp_storage_read(&j,sizeof(j),f);
|
||||
map_items[i]=(short *)getmem(j*2);
|
||||
temp_storage_read(map_items[i],2*j,f);
|
||||
}
|
||||
|
@ -283,27 +283,33 @@ int load_vyklenky(TMPFILE_RD *fsta)
|
|||
void save_all_fly(TMPFILE_WR *fsta)
|
||||
{
|
||||
LETICI_VEC *f;
|
||||
int32_t sz = 1;
|
||||
|
||||
f=letici_veci;
|
||||
temp_storage_write(&f,1*sizeof(f),fsta);
|
||||
while (f!=NULL)
|
||||
{
|
||||
short *c;
|
||||
temp_storage_write(f,1*sizeof(*f),fsta);
|
||||
|
||||
sz = sizeof(*f);
|
||||
temp_storage_write(&sz,sizeof(sz),fsta);
|
||||
temp_storage_write(f,sz,fsta);
|
||||
c=f->items;
|
||||
if (c!=NULL) do temp_storage_write(c,1*2,fsta); while (*c++);
|
||||
f=f->next;
|
||||
}
|
||||
sz = 0;
|
||||
temp_storage_write(&sz,sizeof(sz),fsta);
|
||||
}
|
||||
|
||||
int load_all_fly(TMPFILE_RD *fsta)
|
||||
{
|
||||
LETICI_VEC *f=NULL,*n,*p;
|
||||
p=letici_veci;
|
||||
while (p!=NULL) {stop_fly(letici_veci,0);p=p->next;}
|
||||
temp_storage_read(&f,1*sizeof(f),fsta);
|
||||
p=letici_veci;
|
||||
while (f!=NULL)
|
||||
LETICI_VEC *n;
|
||||
int32_t sz;
|
||||
|
||||
destroy_all_fly();
|
||||
|
||||
temp_storage_read(&sz,sizeof(sz),fsta);
|
||||
while (sz == sizeof(LETICI_VEC))
|
||||
{
|
||||
short items[100],*c;
|
||||
n=New(LETICI_VEC);
|
||||
|
@ -311,21 +317,17 @@ int load_all_fly(TMPFILE_RD *fsta)
|
|||
if (temp_storage_read(n,1*sizeof(*n),fsta)!=sizeof(*n))
|
||||
{
|
||||
free(n);
|
||||
if (p!=NULL) p->next=NULL;
|
||||
return -2;
|
||||
}
|
||||
if (n->items!=NULL)
|
||||
{
|
||||
do
|
||||
temp_storage_read(c,1*2,fsta);
|
||||
temp_storage_read(c,2,fsta);
|
||||
while (*c++);
|
||||
n->items=NewArr(short,c-items);
|
||||
memcpy(n->items,items,(c-items)*sizeof(short));
|
||||
}
|
||||
if (p==NULL) p=letici_veci=n;else p->next=n;
|
||||
p=n;
|
||||
f=n->next;
|
||||
n->next=NULL;
|
||||
add_fly(n);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -338,14 +340,13 @@ int save_map_state() //uklada stav mapy pro savegame (neuklada aktualni pozici);
|
|||
char sta[200];
|
||||
char *bf = NULL;
|
||||
TMPFILE_WR *fsta;
|
||||
int i;
|
||||
int32_t i;
|
||||
int32_t siz;
|
||||
TSTENA *org_sides;
|
||||
TSECTOR *org_sectors;
|
||||
short res=-1;
|
||||
unsigned char ver=0;
|
||||
|
||||
restore_sound_names();
|
||||
strcpy(sta,level_fname);
|
||||
fsta=temp_storage_create(sta);if (fsta==NULL) unable_open_temp(sta);
|
||||
SEND_LOG("(SAVELOAD) Saving map state for current map");
|
||||
|
@ -367,32 +368,32 @@ int save_map_state() //uklada stav mapy pro savegame (neuklada aktualni pozici);
|
|||
for(i=0;i<mapsize*4;i++) //save changed sides
|
||||
if (memcmp(map_sides+i,org_sides+i,sizeof(TSTENA)))
|
||||
{
|
||||
temp_storage_write(&i,1*2,fsta);
|
||||
temp_storage_write(&i,sizeof(i),fsta);
|
||||
temp_storage_write(map_sides+i,1*sizeof(TSTENA),fsta);
|
||||
}
|
||||
i=-1;
|
||||
temp_storage_write(&i,1*2,fsta);
|
||||
temp_storage_write(&i,sizeof(i),fsta);
|
||||
for(i=0;i<mapsize;i++) //save changed sectors
|
||||
if (memcmp(map_sectors+i,org_sectors+i,sizeof(TSECTOR)))
|
||||
{
|
||||
temp_storage_write(&i,1*2,fsta);
|
||||
temp_storage_write(&i,sizeof(i),fsta);
|
||||
temp_storage_write(map_sectors+i,1*sizeof(TSECTOR),fsta);
|
||||
}
|
||||
i=-1;
|
||||
temp_storage_write(&i,1*2,fsta);
|
||||
temp_storage_write(&i,sizeof(i),fsta);
|
||||
for(i=0;i<MAX_MOBS;i++) if (mobs[i].vlajky & MOB_LIVE)
|
||||
{
|
||||
temp_storage_write(&i,1*2,fsta);
|
||||
temp_storage_write(mobs+i,1*sizeof(TMOB),fsta); //save_mobmap
|
||||
temp_storage_write(&i,sizeof(i),fsta);
|
||||
temp_storage_write(mobs+i,sizeof(TMOB),fsta); //save_mobmap
|
||||
}
|
||||
i=-1;
|
||||
temp_storage_write(&i,1*2,fsta);
|
||||
temp_storage_write(&i,sizeof(i),fsta);
|
||||
i=mapsize*4;
|
||||
temp_storage_write(&i,1*sizeof(i),fsta); //save flag maps //<-------------------------
|
||||
temp_storage_write(flag_map,1*i,fsta);
|
||||
temp_storage_write(&i,sizeof(i),fsta); //save flag maps //<-------------------------
|
||||
temp_storage_write(flag_map,i,fsta);
|
||||
save_daction(fsta,0,d_action); //save dactions//<-------------------------
|
||||
temp_storage_write(¯o_block_size,1*sizeof(macro_block_size),fsta);
|
||||
if (macro_block_size)temp_storage_write(macro_block,1*macro_block_size,fsta);//save_macros
|
||||
temp_storage_write(¯o_state_block.count,1*sizeof(macro_state_block.count),fsta);
|
||||
if (macro_state_block.count)temp_storage_write(macro_state_block.states,1*macro_state_block.count,fsta);//save_macros
|
||||
if (save_codelocks(fsta)) goto err;
|
||||
save_items(fsta);
|
||||
save_vyklenky(fsta);
|
||||
|
@ -418,7 +419,7 @@ int load_map_state() //obnovuje stav mapy; nutno volat po zavolani load_map;
|
|||
char sta[200];
|
||||
char *bf = NULL;
|
||||
TMPFILE_RD *fsta;
|
||||
int i;
|
||||
int32_t i;
|
||||
int32_t siz;
|
||||
short res=-2;
|
||||
unsigned char ver=0;
|
||||
|
@ -440,9 +441,9 @@ int load_map_state() //obnovuje stav mapy; nutno volat po zavolani load_map;
|
|||
for (i=0;i<mapsize;i++)
|
||||
if ((bf[i>>3]>>(i & 7)) & 1) map_coord[i].flags|=MC_DISCLOSED;
|
||||
load_map_description(fsta);
|
||||
while (temp_storage_read(&i,1*2,fsta) && i<=mapsize*4)
|
||||
while (temp_storage_read(&i,sizeof(i),fsta) && i > 0 && i<=mapsize*4)
|
||||
if (temp_storage_read(map_sides+i,1*sizeof(TSTENA),fsta)!=sizeof(TSTENA)) goto err;
|
||||
while (temp_storage_read(&i,1*2,fsta) && i<=mapsize)
|
||||
while (temp_storage_read(&i,sizeof(i),fsta) && i >0 && i<=mapsize)
|
||||
if (temp_storage_read(map_sectors+i,1*sizeof(TSECTOR),fsta)!=sizeof(TSECTOR)) goto err;
|
||||
if (reset_mobiles) //reloads mobiles if flag present
|
||||
{
|
||||
|
@ -459,22 +460,23 @@ int load_map_state() //obnovuje stav mapy; nutno volat po zavolani load_map;
|
|||
else
|
||||
{
|
||||
for(i=0;i<MAX_MOBS;(mobs[i].vlajky &=~MOB_LIVE),i++);
|
||||
while (temp_storage_read(&i,1*2,fsta) && i<=MAX_MOBS)
|
||||
while (temp_storage_read(&i,sizeof(i),fsta) && i>=0 && i<=MAX_MOBS)
|
||||
if (temp_storage_read(mobs+i,1*sizeof(TMOB),fsta)!=sizeof(TMOB)) goto err;
|
||||
}
|
||||
for(i=0;i<MAX_MOBS;i++) mobs[i].vlajky &=~MOB_IN_BATTLE;
|
||||
refresh_mob_map();
|
||||
temp_storage_read(&i,1*sizeof(i),fsta);
|
||||
temp_storage_read(flag_map,1*i,fsta);
|
||||
temp_storage_read(&i,sizeof(i),fsta);
|
||||
temp_storage_read(flag_map,i,fsta);
|
||||
load_daction(fsta);
|
||||
temp_storage_read(&i,1*sizeof(macro_block_size),fsta);
|
||||
if (macro_block_size && i==macro_block_size) {
|
||||
temp_storage_read(macro_block,1*macro_block_size,fsta);
|
||||
size_t stsz;
|
||||
temp_storage_read(&stsz,sizeof(macro_state_block.count),fsta);
|
||||
if (macro_state_block.count == stsz) {
|
||||
temp_storage_read(macro_state_block.states,macro_state_block.count,fsta);
|
||||
}
|
||||
else
|
||||
{
|
||||
temp_storage_skip(fsta,i);
|
||||
SEND_LOG("(ERROR) Multiaction: Sizes mismatch %d != %d",i,macro_block_size);
|
||||
temp_storage_skip(fsta,stsz);
|
||||
SEND_LOG("(ERROR) Multiaction: Sizes mismatch %lu != %lu",stsz,macro_state_block.count);
|
||||
}
|
||||
if (load_codelocks(fsta)) goto err;
|
||||
restore_items(fsta);
|
||||
|
@ -503,76 +505,26 @@ void restore_current_map() //pouze obnovuje ulozeny stav aktualni mapy
|
|||
load_map_state(); //nahrej ulozenou mapu
|
||||
for(i=1;i<mapsize*4;i++) call_macro(i,MC_STARTLEV);
|
||||
}
|
||||
/*
|
||||
_inline unsigned char rotate(unsigned char c)
|
||||
{
|
||||
return (c >> 1) | (c << 7);
|
||||
|
||||
__asm
|
||||
{
|
||||
mov al,c
|
||||
rol al,1;
|
||||
}
|
||||
}
|
||||
*/
|
||||
//#pragma aux rotate parm [al] value [al]="rol al,1";
|
||||
|
||||
/* errors
|
||||
-1 end of file
|
||||
1 disk error
|
||||
2 internal error
|
||||
3 checksum error
|
||||
*/
|
||||
int pack_status_file(FILE *f,const char *status_name)
|
||||
{
|
||||
char rcheck=0;
|
||||
int32_t fsz;
|
||||
char *buffer,*c;
|
||||
unsigned char name_len;
|
||||
|
||||
SEND_LOG("(SAVELOAD) Packing status file '%s'",status_name);
|
||||
fsz = temp_storage_find(status_name);
|
||||
if (fsz < 0) return 2;
|
||||
name_len = (unsigned char)strlen(status_name);
|
||||
uint32_t extra = 1+name_len+4;
|
||||
c=buffer=getmem(fsz+extra);
|
||||
*c = name_len;
|
||||
++c;
|
||||
memcpy(c,status_name, name_len);
|
||||
c += name_len;
|
||||
memcpy(c,&fsz,4);
|
||||
|
||||
temp_storage_retrieve(status_name, c, fsz);
|
||||
|
||||
fsz+=extra;
|
||||
rcheck=(fwrite(buffer,1,fsz,f)!=(unsigned)fsz);
|
||||
free(buffer);
|
||||
return rcheck;
|
||||
}
|
||||
|
||||
int unpack_status_file(FILE *f)
|
||||
{
|
||||
char rcheck=0;
|
||||
uint32_t fsz;
|
||||
char *buffer;
|
||||
unsigned char namelen = 0;
|
||||
char name[256];
|
||||
|
||||
fread(&namelen, 1,1, f);
|
||||
if (namelen == 0) return -1;
|
||||
fread(name, 1, namelen, f);
|
||||
SEND_LOG("(SAVELOAD) Unpacking status file '%s'",name);
|
||||
fread(&fsz,1,4,f);
|
||||
buffer=(char *)getmem(fsz);
|
||||
if (fread(buffer,1,fsz,f)!=(unsigned)fsz) return 1;
|
||||
temp_storage_store(name, buffer, fsz);
|
||||
free(buffer);
|
||||
return rcheck;
|
||||
}
|
||||
|
||||
static void add_status_file(FILE *f, const char *name, size_t sz, void *data) {
|
||||
size_t name_size = strlen(name);
|
||||
uint8_t name_size_b;
|
||||
if (name_size > 255) name_size_b = 255; else name_size_b = (uint8_t)name_size;
|
||||
fwrite(&name_size_b,1,1,f);
|
||||
fwrite(name, 1, name_size_b, f);
|
||||
uint32_t data_size = sz;
|
||||
fwrite(&data_size,1,sizeof(data_size),f);
|
||||
fwrite(data, 1,data_size, f);
|
||||
}
|
||||
|
||||
static void pack_status_file_cb(const char *name, void *ctx) {
|
||||
pack_status_file((FILE *)ctx, name);
|
||||
FILE *f = ctx;
|
||||
int32_t sz = temp_storage_find(name);
|
||||
assert(sz > 0);
|
||||
void *data = getmem(sz);
|
||||
temp_storage_retrieve(name, data, sz);
|
||||
add_status_file(f, name, sz, data);
|
||||
free(data);
|
||||
}
|
||||
|
||||
int pack_all_status(FILE *f)
|
||||
|
@ -583,14 +535,54 @@ int pack_all_status(FILE *f)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
typedef enum enum_all_status_callback_result_t {
|
||||
|
||||
enum_status_cont_skip, //continue, skip this block
|
||||
enum_status_cont_read, //continue, i read this block
|
||||
enum_status_skip_stop, //stop, skip this block
|
||||
enum_status_read_stop, //stop, don't skip i read this block
|
||||
enum_status_error //error
|
||||
|
||||
} ENUM_ALL_STATUS_CALLBACK_RESULT;
|
||||
|
||||
//return 1 success, 0 stopped, -1 error
|
||||
static int enum_all_status(FILE *f, ENUM_ALL_STATUS_CALLBACK_RESULT (*cb)(FILE *, const char *, size_t , void *), void *ctx) {
|
||||
while(1) {
|
||||
uint8_t name_size_b;
|
||||
if (fread(&name_size_b, 1,1,f)==0) return 1;
|
||||
char *name = (char *)alloca(name_size_b+1);
|
||||
if (fread(name, 1, name_size_b, f) != name_size_b) return -1;
|
||||
name[name_size_b] = 0;
|
||||
uint32_t data_size;
|
||||
if (fread(&data_size,1,sizeof(uint32_t),f) != sizeof(uint32_t)) return -1;
|
||||
ENUM_ALL_STATUS_CALLBACK_RESULT st = cb(f, name, data_size, ctx);
|
||||
switch (st) {
|
||||
case enum_status_error: return 0;
|
||||
case enum_status_cont_skip: fseek(f, data_size, SEEK_CUR);break;
|
||||
case enum_status_cont_read: break;
|
||||
case enum_status_skip_stop: fseek(f, data_size, SEEK_CUR);return 0;
|
||||
case enum_status_read_stop: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static ENUM_ALL_STATUS_CALLBACK_RESULT unpack_status_callback(FILE *f, const char *name, size_t datasize, void *) {
|
||||
void *buff = getmem(datasize);
|
||||
if (fread(buff, 1, datasize, f) != datasize) {
|
||||
free(buff);
|
||||
return enum_status_error;;
|
||||
}
|
||||
temp_storage_store(name, buff, datasize);
|
||||
free(buff);
|
||||
return enum_status_cont_read;
|
||||
}
|
||||
|
||||
int unpack_all_status(FILE *f)
|
||||
{
|
||||
int i;
|
||||
|
||||
i=0;
|
||||
while (!i) i=unpack_status_file(f);
|
||||
if (i==-1) i=0;
|
||||
return i;
|
||||
int r = enum_all_status(f, &unpack_status_callback, NULL);
|
||||
if (r) return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int save_basic_info()
|
||||
|
@ -778,7 +770,7 @@ int save_game(int slotnum,char *gamename)
|
|||
if ((r=save_basic_info())!=0) return r;
|
||||
save_book();
|
||||
save_global_events();
|
||||
svf=fopen(ssn,"wb");
|
||||
svf=fopen_icase(ssn,"wb");
|
||||
if (svf==NULL)
|
||||
{
|
||||
char buff[256];
|
||||
|
@ -814,7 +806,7 @@ int load_game(int slotnum)
|
|||
concat(sn,pathtable[SR_SAVES],_SLOT_SAV);
|
||||
ssn=alloca(strlen(sn)+3);
|
||||
sprintf(ssn,sn,slotnum);
|
||||
svf=fopen(ssn,"rb");
|
||||
svf=fopen_icase(ssn,"rb");
|
||||
if (svf==NULL) return 1;
|
||||
fseek(svf,SAVE_NAME_SIZE,SEEK_CUR);
|
||||
r=unpack_all_status(svf);
|
||||
|
@ -843,43 +835,55 @@ int load_game(int slotnum)
|
|||
return r;
|
||||
}
|
||||
|
||||
typedef struct load_specific_file_callback_data_t {
|
||||
const char *name;
|
||||
size_t size;
|
||||
void *data;
|
||||
|
||||
} LOAD_SPECIFIC_FILE_CALLBACK_DATA;
|
||||
|
||||
static ENUM_ALL_STATUS_CALLBACK_RESULT load_specific_file_callback(FILE *f, const char *name, size_t datasize, void *ctx) {
|
||||
LOAD_SPECIFIC_FILE_CALLBACK_DATA *me = ctx;
|
||||
if (stricmp(name, me->name) == 0) {
|
||||
void *d = getmem(datasize);
|
||||
if (fread(d, 1, datasize, f) != datasize) {
|
||||
free(d);
|
||||
return enum_status_error;
|
||||
}
|
||||
me->size = datasize;
|
||||
me->data = d;
|
||||
return enum_status_read_stop;
|
||||
} else {
|
||||
return enum_status_cont_skip;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void load_specific_file(int slot_num,char *filename,void **out,int32_t *size) //call it in task!
|
||||
{
|
||||
FILE *slot;
|
||||
char *c,*d;
|
||||
int32_t siz;
|
||||
char fname[12];
|
||||
char succes=0;
|
||||
|
||||
concat(c,pathtable[SR_SAVES],_SLOT_SAV);
|
||||
d=alloca(strlen(c)+2);
|
||||
sprintf(d,c,slot_num);
|
||||
slot=fopen(d,"rb");
|
||||
slot=fopen_icase(d,"rb");
|
||||
if (slot==NULL)
|
||||
{
|
||||
*out=NULL;
|
||||
return;
|
||||
}
|
||||
fseek(slot,SAVE_NAME_SIZE,SEEK_CUR);
|
||||
fread(fname,1,12,slot);
|
||||
while(fname[0] && !succes)
|
||||
{
|
||||
task_sleep();
|
||||
if (task_quitmsg()) break;
|
||||
fread(&siz,1,4,slot);
|
||||
if (!strncmp(fname,filename,12)) succes=1; else
|
||||
{
|
||||
fseek(slot,siz,SEEK_CUR);
|
||||
fread(fname,1,12,slot);
|
||||
|
||||
LOAD_SPECIFIC_FILE_CALLBACK_DATA ctx;
|
||||
ctx.name = filename;
|
||||
|
||||
*out = NULL;
|
||||
*size = 0;
|
||||
if (enum_all_status(slot, &load_specific_file_callback, &ctx) == 0){
|
||||
*out = ctx.data;
|
||||
*size = ctx.size;
|
||||
}
|
||||
}
|
||||
if (succes)
|
||||
{
|
||||
*out=getmem(siz);
|
||||
fread(*out,1,siz,slot);
|
||||
*size=siz;
|
||||
}
|
||||
else *out=NULL;
|
||||
fclose(slot);
|
||||
}
|
||||
|
||||
|
@ -913,7 +917,7 @@ void read_slot_list()
|
|||
{
|
||||
FILE *f;
|
||||
sprintf(name,mask,i);
|
||||
f=fopen(name,"rb");
|
||||
f=fopen_icase(name,"rb");
|
||||
if (f!=NULL)
|
||||
{
|
||||
fread(slotname,1,SAVE_NAME_SIZE,f);
|
||||
|
|
|
@ -630,6 +630,7 @@ void hi_8bit_correct(void **p,int32_t *s);
|
|||
void pcx_8bit_nopal(void **p,int32_t *s);
|
||||
void set_background(void **p,int32_t *s);
|
||||
void wav_load(void **p,int32_t *s);
|
||||
void load_mob_legacy_format(void **p, int32_t *s);
|
||||
void wire_main_functs(void);
|
||||
void ukaz_kompas(char mode);
|
||||
void *timming(EVENT_MSG *msg,void **data);
|
||||
|
@ -886,7 +887,8 @@ typedef struct titem
|
|||
char unused;
|
||||
short sound; //cislo zvuku
|
||||
short v_letu[16]; //192
|
||||
int cena;
|
||||
unsigned short cena;
|
||||
unsigned short cena_high;
|
||||
char weapon_attack; //relativni handle k souboru s animaci utok
|
||||
char hitpos; //pozice zasahu animace
|
||||
char shiftup;
|
||||
|
@ -978,7 +980,7 @@ void destroy_items(short *items); //nici predmety v mysi
|
|||
void do_items_specs(void); //vola specialni akci predmetu v mysi
|
||||
short duplic_item(short item); //duplikuje vec a vraci id cislo klonu
|
||||
int advance_vls(int id);
|
||||
short create_unique_item(TITEM *it);//vytvari jedinecnou vec pro hru (jako duplikat niceho :-))
|
||||
short create_unique_item(const TITEM *it);//vytvari jedinecnou vec pro hru (jako duplikat niceho :-))
|
||||
int calculate_weight(THUMAN *p);
|
||||
int weigth_defect(THUMAN *p);
|
||||
|
||||
|
@ -1009,9 +1011,14 @@ typedef struct tshop
|
|||
int shop_id;
|
||||
int list_size;
|
||||
short spec_max; //maximalni pocet specialnich predmetu
|
||||
TPRODUCT *list;
|
||||
const TPRODUCT *list;
|
||||
}TSHOP;
|
||||
|
||||
typedef struct tshop_all_state {
|
||||
const TPRODUCT *first_product;
|
||||
int32_t *first_state;
|
||||
size_t count_states;
|
||||
} TSHOP_ALL_STATE;
|
||||
|
||||
void enter_shop(int shopid);
|
||||
void load_shops(void);
|
||||
|
@ -1158,28 +1165,28 @@ typedef struct tma_sound
|
|||
|
||||
typedef struct tma_text
|
||||
{
|
||||
uint8_t action,flags,eflags,pflags;
|
||||
int32_t textindex;
|
||||
uint8_t action,flags,eflags,pflags; //4
|
||||
int32_t textindex; //8
|
||||
}TMA_TEXT;
|
||||
|
||||
typedef struct tma_send_action
|
||||
{
|
||||
uint8_t action,flags,eflags,change_bits;
|
||||
unsigned short sector,side,s_action;
|
||||
char delay;
|
||||
uint8_t action,flags,eflags,change_bits; //4
|
||||
unsigned short sector,side,s_action; //10
|
||||
char delay; //11
|
||||
}TMA_SEND_ACTION;
|
||||
|
||||
typedef struct tma_fireball
|
||||
{
|
||||
uint8_t action,flags,eflags;
|
||||
short xpos,ypos,zpos,speed,item;
|
||||
uint8_t action,flags,eflags; //3 + padding = 4
|
||||
short xpos,ypos,zpos,speed,item; //14
|
||||
}TMA_FIREBALL;
|
||||
|
||||
typedef struct tma_loadlev
|
||||
{
|
||||
uint8_t action,flags,eflags;
|
||||
short start_pos;
|
||||
char dir;
|
||||
uint8_t action,flags,eflags; //3+padding
|
||||
short start_pos; //6
|
||||
char dir; //7
|
||||
char name[13];
|
||||
}TMA_LOADLEV;
|
||||
|
||||
|
@ -1187,7 +1194,7 @@ typedef struct tma_loadlev
|
|||
|
||||
typedef struct tma_dropitm
|
||||
{
|
||||
uint8_t action,flags,eflags;
|
||||
uint8_t action,flags,eflags; //3+padding
|
||||
short item;
|
||||
}TMA_DROPITM;
|
||||
|
||||
|
@ -1201,19 +1208,19 @@ typedef struct tma_codelock
|
|||
|
||||
typedef struct tma_cancelaction
|
||||
{
|
||||
uint8_t action,flags,eflags,pflags;
|
||||
uint8_t action,flags,eflags,pflags; //4
|
||||
short sector,dir;
|
||||
}TMA_ACTN;
|
||||
|
||||
typedef struct tma_swapsectors
|
||||
{
|
||||
uint8_t action,flags,eflags,pflags;
|
||||
uint8_t action,flags,eflags,pflags; //4
|
||||
short sector1,sector2;
|
||||
}TMA_SWAPS;
|
||||
|
||||
typedef struct tma_wound
|
||||
{
|
||||
uint8_t action,flags,eflags,pflags;
|
||||
uint8_t action,flags,eflags,pflags; //4
|
||||
short minor,major;
|
||||
}TMA_WOUND;
|
||||
|
||||
|
@ -1221,20 +1228,20 @@ typedef struct tma_wound
|
|||
|
||||
typedef struct tma_lock
|
||||
{
|
||||
uint8_t action,flags,eflags;
|
||||
uint8_t action,flags,eflags; //3+padding
|
||||
short key_id;
|
||||
short thieflevel;
|
||||
}TMA_LOCK;
|
||||
|
||||
typedef struct tma_two_parms
|
||||
{
|
||||
uint8_t action,flags,eflags;
|
||||
uint8_t action,flags,eflags; //3+padding
|
||||
short parm1,parm2;
|
||||
}TMA_TWOP;
|
||||
|
||||
typedef struct tma_create_unique
|
||||
{
|
||||
uint8_t action,flags,eflags;
|
||||
uint8_t action,flags,eflags; //3+padding
|
||||
TITEM item;
|
||||
}TMA_UNIQUE;
|
||||
|
||||
|
@ -1267,21 +1274,32 @@ typedef union tmulti_action
|
|||
struct tma_sound sound;
|
||||
struct tma_text text;
|
||||
struct tma_send_action send_a;
|
||||
struct tma_fireball fireball;
|
||||
struct tma_loadlev loadlev;
|
||||
struct tma_dropitm dropi;
|
||||
struct tma_fireball fireball; //p
|
||||
struct tma_loadlev loadlev; //p
|
||||
struct tma_dropitm dropi; //p
|
||||
struct tma_codelock clock;
|
||||
struct tma_cancelaction cactn;
|
||||
struct tma_lock lock;
|
||||
struct tma_lock lock; //p
|
||||
struct tma_swapsectors swaps;
|
||||
struct tma_wound wound;
|
||||
struct tma_two_parms twop;
|
||||
struct tma_create_unique uniq;
|
||||
struct tma_two_parms twop; //p
|
||||
struct tma_create_unique uniq; //p
|
||||
struct tma_globe globe;
|
||||
struct tma_ifsec ifsec;
|
||||
}TMULTI_ACTION;
|
||||
|
||||
extern int **macros; //tabulka maker
|
||||
typedef struct tmulti_action_record_t {
|
||||
const TMULTI_ACTION *action_list;
|
||||
size_t count;
|
||||
} TMULTI_ACTION_RECORD;
|
||||
|
||||
typedef struct tmulti_action_states_t {
|
||||
uint8_t *states;
|
||||
size_t count;
|
||||
} TMULTI_ACTION_STATE;
|
||||
|
||||
extern TMULTI_ACTION_RECORD *macros; //tabulka maker
|
||||
extern TMULTI_ACTION_STATE macro_state_block;
|
||||
extern void *macro_block; //alokovany blok maker (pri unloadu free!)
|
||||
extern int macro_block_size; //velikost bloku;
|
||||
|
||||
|
@ -1346,6 +1364,7 @@ void draw_fly_items(int celx,int cely,int sector,int side);
|
|||
void add_fly(LETICI_VEC *p);
|
||||
void build_fly_map(void);
|
||||
void destroy_fly_map(void);
|
||||
void destroy_all_fly();
|
||||
void stop_fly(LETICI_VEC *p,char zvuk);
|
||||
|
||||
|
||||
|
@ -1381,12 +1400,11 @@ extern char **sound_table;
|
|||
|
||||
void init_tracks(void);
|
||||
void recalc_volumes(int sector,int side);
|
||||
void play_effekt(int x,int y,int xd,int yd,int side,int sided,TMA_SOUND *p);
|
||||
void play_effekt(int x,int y,int xd,int yd,int side,int sided,const TMA_SOUND *p);
|
||||
void create_playlist(char *playlist);
|
||||
const char *get_next_music_from_playlist(void);
|
||||
const char * end_of_song_callback(void *ctx);
|
||||
void purge_playlist(void);
|
||||
void restore_sound_names(void);
|
||||
void play_sample_at_sector(int sample,int sector1,int sector2,int track, char loop);
|
||||
void play_sample_at_channel(int sample,int channel,int vol);
|
||||
void stop_track(int track);
|
||||
|
@ -1439,7 +1457,7 @@ typedef struct tmob
|
|||
char name[30]; //jmeno moba
|
||||
short casting;
|
||||
short adjusting[6*16]; //volba stredu pro animace
|
||||
word sector,dir; //pozice
|
||||
unsigned short sector,dir; //pozice
|
||||
char locx,locy; //presna pozice
|
||||
char headx,heady; //pozice kam mob miri
|
||||
short anim_counter; //citac animaci
|
||||
|
@ -1452,7 +1470,7 @@ typedef struct tmob
|
|||
short dosah; //okam<61>ik za<7A><61>tku souboje
|
||||
char stay_strategy; //chovani moba ve statickem modu (nepronasleduje)
|
||||
char walk_data; //cislo potrebne pro pohyb moba v bludisti
|
||||
word bonus; //bonus za zabiti
|
||||
unsigned short bonus; //bonus za zabiti
|
||||
char flee_num; //pravdepodobnost uteku
|
||||
char anim_counts[6]; //pocet animacnich policek pro kazdy pohyb
|
||||
char mobs_name[7]; //zaklad jmena souboru pro moba
|
||||
|
@ -1464,14 +1482,14 @@ typedef struct tmob
|
|||
short next; //Cislo dalsiho moba, ktery stoji na jeho pozici
|
||||
char actions; //pocet akci ktere muze potvora provest v kole
|
||||
char hit_pos; //animacni pozice, kdy potvora zasahne
|
||||
word sounds[4]; //zvuky z listu
|
||||
unsigned short sounds[4]; //zvuky z listu
|
||||
signed char palette; // pocet pouzitelnych palet / cislo palety
|
||||
char mode; //akce potvory
|
||||
short dialog; //cislo dialogu, -1 kdyz neni;
|
||||
char dialog_flags; //vlajky mapovane do dialogu;
|
||||
word money; //penize
|
||||
word specproc; //specproc
|
||||
word dostal; //pocet zivotu, ktere mu byly ubrany poslednim zasahem
|
||||
unsigned short money; //penize
|
||||
unsigned short specproc; //specproc
|
||||
unsigned short dostal; //pocet zivotu, ktere mu byly ubrany poslednim zasahem
|
||||
char user_data; //data uzivatelem definovane - treba pro spec.
|
||||
}TMOB;
|
||||
|
||||
|
@ -1644,7 +1662,7 @@ void check_global_fletna(THE_TIMER *t);
|
|||
void fletna_glob_add_note(uint8_t note);
|
||||
|
||||
|
||||
char *find_map_path(char *filename); //vyhledava jmeno mapy v alternativnich cestach.
|
||||
char *find_map_path(const char *filename); //vyhledava jmeno mapy v alternativnich cestach.
|
||||
//Vysledny retezec je nutne uvolnit (free) !
|
||||
TMPFILE_RD *enc_open(char *filename); //dekoduje a otevira TXT soubor (ENC)
|
||||
void enc_close(TMPFILE_RD *fil);
|
||||
|
@ -1695,7 +1713,7 @@ void wire_global_map(void);
|
|||
void wire_automap_file(char *mapfile);
|
||||
char set_select_mode(char mode);
|
||||
|
||||
void macro_load_another_map(TMA_LOADLEV *);
|
||||
void macro_load_another_map(const TMA_LOADLEV *);
|
||||
|
||||
void PodporaStitu(THUMAN *h, short *vlastnosti);
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ static char test_kriterii(void)
|
|||
hodn=temp_storage_find(text);
|
||||
/* char c[200];
|
||||
sprintf(c,"%s.TMP",text);
|
||||
hodn=!access(c,0);*/
|
||||
hodn=!check_file_exists(c);*/
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -329,7 +329,7 @@ static char proved_prikaz()
|
|||
cti_retezec(20,prikaz,1,1);
|
||||
fclose(glbm);
|
||||
s=find_map_path(prikaz);
|
||||
if ((glbm=fopen(s,"r"))==NULL) error(s);
|
||||
if ((glbm=fopen_icase(s,"r"))==NULL) error(s);
|
||||
free(s);
|
||||
return 0;
|
||||
}
|
||||
|
@ -375,7 +375,7 @@ static void do_script(void)
|
|||
|
||||
s=find_map_path(GLOBMAP);
|
||||
linecounter=0;
|
||||
glbm=fopen(s,"r");
|
||||
glbm=fopen_icase(s,"r");
|
||||
free(s);
|
||||
if (glbm==NULL) error("Chyb<EFBFBD> uveden<65> soubor...");
|
||||
ODD=cti_oddelovac();
|
||||
|
|
|
@ -1318,14 +1318,14 @@ void check_global_fletna(THE_TIMER *t)
|
|||
|
||||
//---------------------------------------
|
||||
|
||||
char *find_map_path(char *filename)
|
||||
char *find_map_path(const char *filename)
|
||||
{
|
||||
char *p1,*p;
|
||||
|
||||
if (pathtable[SR_MAP2]!=NULL)
|
||||
{
|
||||
concat(p1,pathtable[SR_MAP2],filename);
|
||||
if (!access(p1,0)) goto found;
|
||||
if (check_file_exists(p1)) goto found;
|
||||
}
|
||||
concat(p1,pathtable[SR_MAP],filename);
|
||||
found:
|
||||
|
@ -1353,7 +1353,7 @@ TMPFILE_RD *enc_open(char *filename)
|
|||
int size;
|
||||
char *encdata;
|
||||
|
||||
f=fopen(filename,"r");
|
||||
f=fopen_icase(filename,"r");
|
||||
if (f!=NULL) {
|
||||
encdata = load_file_to_string(f, &size);
|
||||
fclose(f);
|
||||
|
@ -1364,7 +1364,7 @@ TMPFILE_RD *enc_open(char *filename)
|
|||
c=strrchr(enc,'.');
|
||||
if (c==NULL) c=strchr(enc,0);
|
||||
strcpy(c,".ENC");
|
||||
f=fopen(enc,"rb");
|
||||
f=fopen_icase(enc,"rb");
|
||||
if (f==NULL) return NULL;
|
||||
encdata = load_file_to_string(f, &size);
|
||||
fclose(f);
|
||||
|
|
148
game/inv.c
148
game/inv.c
|
@ -17,6 +17,8 @@
|
|||
#include "engine1.h"
|
||||
#include <pcx.h>
|
||||
#include "globals.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define neprezbrojit() (battle && (battle_mode!=MD_PREZBROJIT || select_player!=human_selected-postavy))
|
||||
|
@ -58,10 +60,12 @@ int item_in_cursor=0;
|
|||
void (*inv_redraw)();
|
||||
|
||||
TSHOP *cur_shop;
|
||||
TSHOP **shop_list=NULL;int max_shops=0; //shop_list=prima spojeni s obchody
|
||||
TSHOP **shop_list=NULL;
|
||||
int max_shops=0; //shop_list=prima spojeni s obchody
|
||||
void *shop_hacek=NULL; //hacek za ktery visi cely shop strom (free(shop_hacek) - odalokuje shopy)
|
||||
//hacek lze ulozit do savegame -> ulozi se cely stav obchodu
|
||||
int32_t shop_hacek_size=0; //toto je jeho delka
|
||||
static TSHOP_ALL_STATE shop_all_state;
|
||||
|
||||
#define ico_extract(icnnum) (((char*)ablock(ikon_libs+(icnnum)/IT_LIB_SIZE))+IT_ICONE_SIZE*((icnnum)%IT_LIB_SIZE))
|
||||
|
||||
|
@ -177,7 +181,7 @@ void load_items()
|
|||
}
|
||||
} while (1);
|
||||
name=find_map_path(ITEM_FILE);
|
||||
f=fopen(name,"rb");free(name);
|
||||
f=fopen_icase(name,"rb");free(name);
|
||||
if (f==NULL)
|
||||
{
|
||||
closemode();
|
||||
|
@ -209,6 +213,11 @@ void load_items()
|
|||
case SV_ITLIST:
|
||||
glob_items=p;
|
||||
it_count_orgn=item_count=size/sizeof(TITEM);
|
||||
for (int i = 0; i < it_count_orgn; ++i) {
|
||||
if (glob_items[i].cena_high != 0) {
|
||||
SEND_LOG("(ITEMS) Over-priced item %i %s %d > 65535", i, glob_items[i].jmeno, glob_items[i].cena + 65536*glob_items[i].cena_high);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SV_SNDLIST:
|
||||
hs=hl_ptr;
|
||||
|
@ -311,7 +320,7 @@ short duplic_item(short item)
|
|||
return i+1;
|
||||
}
|
||||
|
||||
short create_unique_item(TITEM *it)
|
||||
short create_unique_item(const TITEM *it)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -1769,11 +1778,11 @@ static char MakeItemCombinations(short *itm1, short *itm2)
|
|||
FILE *table;
|
||||
|
||||
concat(fname,pathtable[SR_MAP],"COMBITEM.DAT");
|
||||
table=fopen(fname,"r");
|
||||
table=fopen_icase(fname,"r");
|
||||
if (table==0 && pathtable[SR_MAP2][0])
|
||||
{
|
||||
concat(fname,pathtable[SR_MAP2],fname);
|
||||
table=fopen(fname,"r");
|
||||
table=fopen_icase(fname,"r");
|
||||
}
|
||||
if (table==0) return 0;
|
||||
cnt=fscanf(table,"%d %d -> %d %d",&src1,&src2,&trg1,&trg2);
|
||||
|
@ -2456,32 +2465,43 @@ static void rebuild_shops(void)
|
|||
c+=4;
|
||||
char *d = c;
|
||||
size_t reqsize = 0;
|
||||
size_t products = 0;
|
||||
for(i=0;i<max_shops;i++) {
|
||||
TSHOP s;
|
||||
d = load_TSHOP(d, &s);
|
||||
reqsize += sizeof(TSHOP);
|
||||
reqsize += sizeof(TSHOP)+sizeof(TSHOP *); //shop and its state + pointer to it
|
||||
for (int j = 0; j < s.products; ++j) {
|
||||
TPRODUCT p;
|
||||
d = load_TPRODUCT(d, &p);
|
||||
reqsize += sizeof(TPRODUCT);
|
||||
reqsize += sizeof(TPRODUCT) + sizeof(int32_t); //each product one state
|
||||
++products;
|
||||
}
|
||||
}
|
||||
char *newhacek = getmem(reqsize);
|
||||
TPRODUCT *products = (TPRODUCT *)(newhacek+max_shops*sizeof(TSHOP));
|
||||
TSHOP *shops = (TSHOP *)newhacek;
|
||||
SEND_LOG("(SHOP) Loaded total %d shops, %lu products, %lu bytes total memory", max_shops, products, reqsize);
|
||||
void *newhacek = getmem(reqsize);
|
||||
shop_list = (TSHOP **)newhacek;
|
||||
TSHOP *shop_iter = (TSHOP *)(shop_list+max_shops);
|
||||
TPRODUCT *prod_iter = (TPRODUCT *)(shop_iter+max_shops);
|
||||
shop_all_state.first_product = prod_iter;
|
||||
shop_all_state.count_states = products;
|
||||
shop_all_state.first_state = (int32_t *)(prod_iter+products);
|
||||
int32_t *state_iter = shop_all_state.first_state;
|
||||
|
||||
for(i=0;i<max_shops;i++) {
|
||||
c = load_TSHOP(c, shops+i);
|
||||
shops[i].list = products;
|
||||
for (int j = 0; j < shops[i].products; ++j) {
|
||||
c = load_TPRODUCT(c, products);
|
||||
products++;
|
||||
shop_list[i] = shop_iter;
|
||||
c = load_TSHOP(c, shop_iter);
|
||||
shop_iter->list = prod_iter;
|
||||
for (int j = 0; j < shop_iter->products; ++j) {
|
||||
c = load_TPRODUCT(c, prod_iter);
|
||||
*state_iter += prod_iter->pocet;
|
||||
++prod_iter;
|
||||
++state_iter;
|
||||
}
|
||||
shop_list[i] = shops+i;
|
||||
SEND_LOG("(SHOP) Shop found: '%s', products %d",shops[i].keeper,shops[i].products);
|
||||
++shop_iter;
|
||||
SEND_LOG("(SHOP) Shop found: '%s', products %d",shop_list[i]->keeper,shop_list[i]->products);
|
||||
}
|
||||
free(shop_hacek);
|
||||
shop_hacek = newhacek;
|
||||
|
||||
}
|
||||
|
||||
void load_shops(void)
|
||||
|
@ -2507,10 +2527,16 @@ void load_shops(void)
|
|||
rebuild_shops();
|
||||
}
|
||||
|
||||
static int32_t *get_product_count(const TPRODUCT *p) {
|
||||
int32_t index = p - shop_all_state.first_product;
|
||||
assert(index >= 0 && index < (int32_t)shop_all_state.count_states);
|
||||
return shop_all_state.first_state + index;
|
||||
}
|
||||
|
||||
static void rebuild_keepers_items()
|
||||
{
|
||||
int i;
|
||||
TPRODUCT *p;
|
||||
const TPRODUCT *p;
|
||||
int remain;
|
||||
char c;
|
||||
|
||||
|
@ -2521,7 +2547,7 @@ static void rebuild_keepers_items()
|
|||
remain=cur_shop->list_size-top_item;
|
||||
p=cur_shop->list+top_item;
|
||||
for(i=0;i<8 && remain>0;remain--,p++)
|
||||
if (p->trade_flags & SHP_SELL && p->pocet)
|
||||
if (p->trade_flags & SHP_SELL && *get_product_count(p))
|
||||
{
|
||||
shp_item_pos[i]=p-cur_shop->list;
|
||||
shp_item_map[i++]=p->item+1;
|
||||
|
@ -2538,7 +2564,7 @@ static int make_offer(int i)
|
|||
i--;
|
||||
for(j=0;j<cur_shop->list_size;j++)
|
||||
{
|
||||
TPRODUCT *p=cur_shop->list+j;
|
||||
const TPRODUCT *p=cur_shop->list+j;
|
||||
if (p->item==i && p->trade_flags & SHP_BUY) return p->cena-(p->cena*cur_shop->koef/100);
|
||||
}
|
||||
return 0;
|
||||
|
@ -2550,19 +2576,19 @@ static int get_sell_price(int i) //cislo predmetu
|
|||
i--;
|
||||
for(j=0;j<cur_shop->list_size;j++)
|
||||
{
|
||||
TPRODUCT *p=cur_shop->list+j;
|
||||
if (p->item==i && p->trade_flags & SHP_SELL && p->pocet>0) return p->cena+(p->cena*cur_shop->koef/100);
|
||||
const TPRODUCT *p=cur_shop->list+j;
|
||||
if (p->item==i && p->trade_flags & SHP_SELL && *get_product_count(p)>0) return p->cena+(p->cena*cur_shop->koef/100);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static TPRODUCT *find_sell_product(int i) //cislo predmetu
|
||||
static const TPRODUCT *find_sell_product(int i) //cislo predmetu
|
||||
{
|
||||
int j;
|
||||
i--;
|
||||
for(j=0;j<cur_shop->list_size;j++)
|
||||
{
|
||||
TPRODUCT *p=cur_shop->list+j;
|
||||
const TPRODUCT *p=cur_shop->list+j;
|
||||
if (p->item==i) return p;
|
||||
}
|
||||
return NULL;
|
||||
|
@ -2575,10 +2601,10 @@ static void sell_item(int i)
|
|||
i--;
|
||||
for(j=0;j<cur_shop->list_size;j++)
|
||||
{
|
||||
TPRODUCT *p=cur_shop->list+j;
|
||||
const TPRODUCT *p=cur_shop->list+j;
|
||||
if (p->item==i)
|
||||
{
|
||||
p->pocet--;
|
||||
(*get_product_count(p))--;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -2590,10 +2616,10 @@ static void buy_item(int i)
|
|||
i--;
|
||||
for(j=0;j<cur_shop->list_size;j++)
|
||||
{
|
||||
TPRODUCT *p=cur_shop->list+j;
|
||||
const TPRODUCT *p=cur_shop->list+j;
|
||||
if (p->item==i)
|
||||
{
|
||||
p->pocet++;
|
||||
(*get_product_count(p))++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -2641,20 +2667,20 @@ static void redraw_shop()
|
|||
|
||||
static void block_next()
|
||||
{
|
||||
TPRODUCT *p=cur_shop->list+top_item;
|
||||
const TPRODUCT *p=cur_shop->list+top_item;
|
||||
int remain=cur_shop->list_size-top_item;
|
||||
int i,j;
|
||||
|
||||
if (remain<8) return;
|
||||
j=top_item;
|
||||
for(i=0;i<8 && remain>0;j++,remain--,p++) if (p->pocet && p->trade_flags & SHP_SELL) i++;
|
||||
for(i=0;i<8 && remain>0;j++,remain--,p++) if (*get_product_count(p) && p->trade_flags & SHP_SELL) i++;
|
||||
if (i!=8 || !remain) return;
|
||||
top_item=j;
|
||||
}
|
||||
|
||||
static void block_back()
|
||||
{
|
||||
TPRODUCT *p=cur_shop->list+top_item;
|
||||
const TPRODUCT *p=cur_shop->list+top_item;
|
||||
int i,j;
|
||||
|
||||
|
||||
|
@ -2662,7 +2688,7 @@ static void block_back()
|
|||
else
|
||||
{
|
||||
j=top_item;
|
||||
for(i=0;i<8 && j>0;j--,p--) if (p->pocet && p->trade_flags & SHP_SELL) i++;
|
||||
for(i=0;i<8 && j>0;j--,p--) if (*get_product_count(p) && p->trade_flags & SHP_SELL) i++;
|
||||
if (i==8) top_item=j; else top_item=0;
|
||||
}
|
||||
return;
|
||||
|
@ -2744,7 +2770,7 @@ char shop_keeper_click(int id, int xa, int ya, int xr, int yr) {
|
|||
wire_shop();
|
||||
} else {
|
||||
int p;
|
||||
TPRODUCT *pp;
|
||||
const TPRODUCT *pp;
|
||||
|
||||
pp = find_sell_product(z);
|
||||
sprintf(c, texty[102], price);
|
||||
|
@ -2753,7 +2779,7 @@ char shop_keeper_click(int id, int xa, int ya, int xr, int yr) {
|
|||
if (p == 2)
|
||||
price = -1;
|
||||
if (p == 1)
|
||||
price = smlouvat(price, pp->cena, pp->pocet, money, 0);
|
||||
price = smlouvat(price, pp->cena, *get_product_count(pp), money, 0);
|
||||
if (price >= 0) {
|
||||
play_sample_at_channel(H_SND_OBCHOD, 1, 100);
|
||||
buy_item(z);
|
||||
|
@ -2777,7 +2803,7 @@ char shop_bag_click(int id,int xa,int ya,int xr,int yr)
|
|||
{
|
||||
char s[200],p;
|
||||
int price,z;
|
||||
TPRODUCT *pp;
|
||||
const TPRODUCT *pp;
|
||||
if (cur_owner>-1)
|
||||
{
|
||||
id=bag_click(id,xa,ya,xr,yr);
|
||||
|
@ -2809,13 +2835,13 @@ char shop_bag_click(int id,int xa,int ya,int xr,int yr)
|
|||
if (price>money)
|
||||
{
|
||||
p=message(2,0,0,"",texty[104],texty[230],texty[78]);
|
||||
if (!p) price=smlouvat(price,pp->cena,pp->pocet,money,1);else price=-1;
|
||||
if (!p) price=smlouvat(price,pp->cena,*get_product_count(pp),money,1);else price=-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(s,texty[101],price);
|
||||
p=message(3,0,1,texty[118],s,texty[77],texty[230],texty[78]);
|
||||
if (p==1) price=smlouvat(price,pp->cena,pp->pocet,money,1);else
|
||||
if (p==1) price=smlouvat(price,pp->cena,*get_product_count(pp),money,1);else
|
||||
if (p==2) price=-1;
|
||||
}
|
||||
if (price>=0)
|
||||
|
@ -2978,16 +3004,16 @@ static void reroll_shop(TSHOP *p)
|
|||
{
|
||||
int i,j,r;
|
||||
int poc_spec=0;
|
||||
TPRODUCT *pr;
|
||||
const TPRODUCT *pr;
|
||||
|
||||
SEND_LOG("(SHOP) Shops reroll: '%s' ",p->keeper);
|
||||
pr=p->list;
|
||||
for(i=0;i<p->list_size;i++,pr++)
|
||||
{
|
||||
if (pr->trade_flags & SHP_AUTOADD && pr->pocet<pr->max_pocet) pr->pocet++;
|
||||
if (pr->trade_flags & SHP_AUTOADD && *get_product_count(pr)<pr->max_pocet) (*get_product_count(pr))++;
|
||||
if (pr->trade_flags & SHP_SPECIAL)
|
||||
{
|
||||
poc_spec++;if (pr->pocet>0) pr->pocet=0;
|
||||
poc_spec++;if (*get_product_count(pr)>0) *get_product_count(pr)=0;
|
||||
}
|
||||
}
|
||||
pr=p->list;
|
||||
|
@ -2997,7 +3023,9 @@ static void reroll_shop(TSHOP *p)
|
|||
r=rnd(poc_spec)+1;
|
||||
for(j=0;i<r;j++) if (pr[j].trade_flags & SHP_SPECIAL) i++;
|
||||
j--;
|
||||
pr[j].pocet=rnd(pr[j].max_pocet)+1;
|
||||
const TPRODUCT *sel = pr+j;
|
||||
int maxp = MAX(sel->max_pocet,1);
|
||||
*get_product_count(pr+j)=rnd(maxp)+1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3009,39 +3037,23 @@ void reroll_all_shops()
|
|||
|
||||
char save_shops()
|
||||
{
|
||||
TMPFILE_WR *f;
|
||||
int res=0;
|
||||
|
||||
SEND_LOG("(SHOP) Saving shops...");
|
||||
if (max_shops==0 || shop_hacek==NULL) return 0;
|
||||
f = temp_storage_create(_SHOP_ST);
|
||||
if (f==NULL) return 1;
|
||||
temp_storage_write(&max_shops,1*sizeof(max_shops),f);
|
||||
temp_storage_write(&shop_hacek_size,1*sizeof(shop_hacek_size),f);
|
||||
temp_storage_write(shop_hacek,1*shop_hacek_size,f);
|
||||
temp_storage_close_wr(f);
|
||||
return res;
|
||||
if (shop_all_state.count_states == 0) {
|
||||
temp_storage_delete(_SHOP_ST);
|
||||
return 0;
|
||||
}
|
||||
temp_storage_store(_SHOP_ST, shop_all_state.first_state, shop_all_state.count_states*sizeof(*shop_all_state.first_state));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
char load_saved_shops()
|
||||
{
|
||||
TMPFILE_RD *f;
|
||||
int res=0;
|
||||
int i=0,j=0;
|
||||
|
||||
SEND_LOG("(SHOP) Loading saved shops...");
|
||||
f=temp_storage_open(_SHOP_ST);
|
||||
if (f==NULL) return 0;
|
||||
temp_storage_read(&i,1*sizeof(max_shops),f);
|
||||
temp_storage_read(&j,1*sizeof(shop_hacek_size),f);
|
||||
if (i!=max_shops || j!=shop_hacek_size)
|
||||
{
|
||||
temp_storage_close_rd(f);
|
||||
int32_t sz = temp_storage_find(_SHOP_ST);
|
||||
int32_t needsz = shop_all_state.count_states*(sizeof(*shop_all_state.first_state));
|
||||
if (sz != needsz) return 0;
|
||||
temp_storage_retrieve(_SHOP_ST, shop_all_state.first_state, sz);
|
||||
return 0;
|
||||
}
|
||||
res=(temp_storage_read(shop_hacek,1*shop_hacek_size,f)!=(unsigned)shop_hacek_size);
|
||||
temp_storage_close_rd(f);
|
||||
rebuild_shops();
|
||||
return res;
|
||||
}
|
||||
|
|
434
game/macros.c
434
game/macros.c
|
@ -19,9 +19,12 @@
|
|||
#include "specproc.h"
|
||||
#include "temp_storage.h"
|
||||
|
||||
int **macros=NULL;
|
||||
void *macro_block;
|
||||
int macro_block_size;
|
||||
#include <assert.h>
|
||||
TMULTI_ACTION_RECORD *macros; //tabulka make
|
||||
TMULTI_ACTION_STATE macro_state_block;
|
||||
static const TMULTI_ACTION *first_macro;
|
||||
void *macro_block = NULL;
|
||||
int macro_block_size = 0;
|
||||
int32_t sound_side_flags=0; //kopie flagu steny pro zvuk
|
||||
static char codelock_memory[16][8];
|
||||
static short rand_value;
|
||||
|
@ -46,24 +49,102 @@ char save_load_trigger(short load)
|
|||
return trig_group;
|
||||
}
|
||||
|
||||
static inline size_t read_4b(const char *c) {
|
||||
size_t b1 = c[0];
|
||||
size_t b2 = c[1];
|
||||
size_t b3 = c[2];
|
||||
size_t b4 = c[3];
|
||||
return b1 | (b2<<8) | (b3 << 16) | (b4 << 24);
|
||||
}
|
||||
|
||||
static void read_macro_item(const char *iter, size_t sz, TMULTI_ACTION *target) {
|
||||
assert (sz <= sizeof(TMULTI_ACTION));
|
||||
char action = ((const TMULTI_ACTION *)iter)->general.action;
|
||||
char fixpad = action == MA_FIREB
|
||||
|| action == MA_LOADL
|
||||
|| action == MA_DROPI
|
||||
|| action == MA_CREAT
|
||||
|| action == MA_LOCK
|
||||
|| action == MA_CUNIQ
|
||||
|| action == MA_GUNIQ
|
||||
|| action == MA_IFJMP
|
||||
|| action == MA_HAVIT
|
||||
|| action == MA_RANDJ
|
||||
|| action == MA_ISFLG
|
||||
|| action == MA_PICKI
|
||||
|| action == MA_SNDEX
|
||||
|| action == MA_IFACT
|
||||
|| action == MA_CALLS
|
||||
|| action == MA_MOVEG
|
||||
|| action == MA_CHFLG
|
||||
|| action == MA_WBOOK
|
||||
|| action == MA_GOMOB
|
||||
|| action == MA_SHRMA
|
||||
|| action == MA_MONEY
|
||||
|| action == MA_PLAYA;
|
||||
if (fixpad) {
|
||||
char *src = (char *)(iter)+3;
|
||||
char *dst = (char *)(target)+4;
|
||||
memcpy(target, iter, 3);
|
||||
memcpy(dst, src, sz - 3);
|
||||
} else {
|
||||
memcpy(target, iter, sz);
|
||||
}
|
||||
}
|
||||
|
||||
void load_macros(int size,void *data)
|
||||
{
|
||||
int *r;
|
||||
|
||||
if (macros!=NULL) free(macros);
|
||||
macros=(int **)getmem(mapsize*sizeof(int *)*4);
|
||||
memset(macros,0,mapsize*sizeof(char *)*4);
|
||||
memset(codelock_memory,0,sizeof(codelock_memory));
|
||||
r=data;
|
||||
while (*r)
|
||||
{
|
||||
macros[*r]=r+1;
|
||||
r++;
|
||||
while(*r) r=(int *)((char *)r+*r+4);
|
||||
r++;
|
||||
char *iter = data;
|
||||
size_t count_s = mapsize*4;
|
||||
size_t count_m = 0;
|
||||
size_t i;
|
||||
while ((i = read_4b(iter)) != 0) {
|
||||
iter += 4;
|
||||
while ((i = read_4b(iter)) != 0) {
|
||||
iter += 4 + i;
|
||||
++count_m;
|
||||
}
|
||||
macro_block=data;
|
||||
macro_block_size=size;
|
||||
iter +=4;
|
||||
}
|
||||
|
||||
//records[count_s] + states[count_m] + data[count_m]
|
||||
|
||||
size_t total_size = sizeof(TMULTI_ACTION_RECORD) * count_s + count_m + sizeof(TMULTI_ACTION)*count_m;
|
||||
macro_block = getmem(total_size);
|
||||
memset(macro_block,0, total_size);
|
||||
macros = macro_block;
|
||||
macro_state_block.states = (uint8_t *)(macros+count_s);
|
||||
macro_state_block.count = count_m;
|
||||
TMULTI_ACTION *m_iter = (TMULTI_ACTION *)(macro_state_block.states + count_m);
|
||||
TMULTI_ACTION *m_end = m_iter + count_m;
|
||||
first_macro = m_iter;
|
||||
|
||||
iter = data;
|
||||
|
||||
while ((i = read_4b(iter)) != 0) {
|
||||
assert(m_iter < m_end);
|
||||
assert(i < (size_t)mapsize*4);
|
||||
TMULTI_ACTION_RECORD *r = macros+i;
|
||||
size_t count = 0;
|
||||
r->action_list = m_iter;
|
||||
iter += 4;
|
||||
i = read_4b(iter);
|
||||
iter += 4;
|
||||
if (i) { do {
|
||||
read_macro_item(iter, i, m_iter);
|
||||
++m_iter;
|
||||
iter += i;
|
||||
i = read_4b(iter);
|
||||
iter += 4;
|
||||
++count;
|
||||
} while (i != 0);
|
||||
}
|
||||
r->count = count;
|
||||
}
|
||||
|
||||
assert((char *)m_iter == (char *)macro_block+total_size);
|
||||
macro_block_size = total_size;
|
||||
}
|
||||
|
||||
void macro_disp_text(int text,char glob)
|
||||
|
@ -72,7 +153,7 @@ void macro_disp_text(int text,char glob)
|
|||
else bott_disp_text(level_texts[text]);
|
||||
}
|
||||
|
||||
void macro_fireball(TMA_FIREBALL *z,int sector,int dir)
|
||||
void macro_fireball(const TMA_FIREBALL *z,int sector,int dir)
|
||||
{
|
||||
LETICI_VEC *fly;
|
||||
TITEM *it;
|
||||
|
@ -97,7 +178,7 @@ void macro_fireball(TMA_FIREBALL *z,int sector,int dir)
|
|||
add_fly(fly);
|
||||
}
|
||||
|
||||
void macro_sound(TMA_SOUND *p,int psect,int pdir,int sect,int dir)
|
||||
void macro_sound(const TMA_SOUND *p,int psect,int pdir,int sect,int dir)
|
||||
{
|
||||
char up=4;
|
||||
if (sound_side_flags & SD_PRIM_FORV) up=2;
|
||||
|
@ -110,12 +191,12 @@ void macro_sound(TMA_SOUND *p,int psect,int pdir,int sect,int dir)
|
|||
}
|
||||
}
|
||||
|
||||
void macro_send_act(TMA_SEND_ACTION *p)
|
||||
void macro_send_act(const TMA_SEND_ACTION *p)
|
||||
{
|
||||
delay_action(p->s_action,p->sector,p->side,p->change_bits<<24,0,p->delay);
|
||||
}
|
||||
|
||||
void macro_load_another_map(TMA_LOADLEV *z)
|
||||
void macro_load_another_map(const TMA_LOADLEV *z)
|
||||
{
|
||||
int i,j=0;
|
||||
|
||||
|
@ -159,11 +240,11 @@ static void macro_create_item(short item)
|
|||
}
|
||||
|
||||
|
||||
static char decode_lock(char znak,char *string,uint8_t codenum)
|
||||
static char decode_lock(char znak,const char *string,uint8_t codenum)
|
||||
{
|
||||
char *memory;
|
||||
char *endm;
|
||||
char *ends;
|
||||
const char *ends;
|
||||
int i;
|
||||
|
||||
memory=codelock_memory[codenum];
|
||||
|
@ -202,7 +283,7 @@ void cancel_action(int sector,int dir)
|
|||
}
|
||||
}
|
||||
|
||||
char if_lock(int side,int key_id,int level,TMA_LOCK *lk)
|
||||
char if_lock(int side,int key_id,int level,const TMA_LOCK *lk)
|
||||
{
|
||||
int c;
|
||||
|
||||
|
@ -240,12 +321,6 @@ char if_lock(int side,int key_id,int level,TMA_LOCK *lk)
|
|||
{
|
||||
sprintf(s,texty[154+h->female],h->jmeno);
|
||||
bott_disp_text(s);
|
||||
//if (abs(level-thlev)<10 && h->vlastnosti[VLS_THIEF]<100)
|
||||
// {
|
||||
//h->vlastnosti[VLS_THIEF]++;
|
||||
//h->stare_vls[VLS_THIEF]++;
|
||||
//}
|
||||
lk->thieflevel=1;
|
||||
return 0;
|
||||
}
|
||||
sprintf(s,texty[156+h->female],h->jmeno);
|
||||
|
@ -299,7 +374,7 @@ void propadnout(int sector)
|
|||
postavy_propadnout(sector);
|
||||
}
|
||||
|
||||
static void swap_sectors(TMA_SWAPS *sws)
|
||||
static void swap_sectors(const TMA_SWAPS *sws)
|
||||
{
|
||||
TSECTOR *ss1=&map_sectors[sws->sector1],*ss2=&map_sectors[sws->sector2];
|
||||
TSTENA *sd1=&map_sides[sws->sector1<<2],*sd2=&map_sides[sws->sector2<<2];
|
||||
|
@ -314,7 +389,7 @@ static void swap_sectors(TMA_SWAPS *sws)
|
|||
recheck_button(sws->sector2,0);
|
||||
}
|
||||
|
||||
static void hit_1_player(int postava,TMA_WOUND *w,int chaos)
|
||||
static void hit_1_player(int postava,const TMA_WOUND *w,int chaos)
|
||||
{
|
||||
int mode=w->pflags>>1;
|
||||
int zivel=mode-2;
|
||||
|
@ -347,7 +422,7 @@ static void hit_1_player(int postava,TMA_WOUND *w,int chaos)
|
|||
player_hit(h,dostal,0);
|
||||
}
|
||||
|
||||
static void hit_player(TMA_WOUND *w,int sector)
|
||||
static void hit_player(const TMA_WOUND *w,int sector)
|
||||
{
|
||||
int i,pocet,r;
|
||||
|
||||
|
@ -365,23 +440,17 @@ static void hit_player(TMA_WOUND *w,int sector)
|
|||
bott_draw(1);
|
||||
}
|
||||
|
||||
static TMULTI_ACTION *go_macro(int side,int abs_pos)
|
||||
static TMULTI_ACTION_RECORD go_macro(int side,int abs_pos)
|
||||
{
|
||||
int *r;
|
||||
int mcsiz;
|
||||
TMULTI_ACTION_RECORD ret = macros[side];
|
||||
|
||||
|
||||
program_counter=abs_pos;
|
||||
r=macros[side];
|
||||
if (r==NULL) return NULL;
|
||||
mcsiz=*r++;
|
||||
while (abs_pos--)
|
||||
{
|
||||
r=(int *)((char *)r+mcsiz);
|
||||
mcsiz=*r++;
|
||||
if (!mcsiz) return NULL;
|
||||
if (ret.action_list!=NULL && ret.count > (size_t)abs_pos) {
|
||||
ret.action_list += abs_pos;
|
||||
ret.count -= abs_pos;
|
||||
}
|
||||
return (TMULTI_ACTION *)r;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char monster_in_game(void)
|
||||
|
@ -413,7 +482,7 @@ static char monster_in_room(int sector)
|
|||
return monster_test;
|
||||
}
|
||||
|
||||
static int if_jump(TMA_TWOP *i,int side,int abs_pos)
|
||||
static int if_jump(const TMA_TWOP *i,int side,int abs_pos)
|
||||
{
|
||||
TSTENA *sd=map_sides+side;
|
||||
int go,test,flag;
|
||||
|
@ -433,7 +502,7 @@ static int if_jump(TMA_TWOP *i,int side,int abs_pos)
|
|||
if (ok) return go+abs_pos;else return -1;
|
||||
}
|
||||
|
||||
static int if_have_item(TMA_TWOP *i,int abs_pos)
|
||||
static int if_have_item(const TMA_TWOP *i,int abs_pos)
|
||||
{
|
||||
int go,test,ip;
|
||||
char ok=0;
|
||||
|
@ -445,7 +514,7 @@ static int if_have_item(TMA_TWOP *i,int abs_pos)
|
|||
if (ok) return go+abs_pos;else return -1;
|
||||
}
|
||||
|
||||
static int ma_randjmp(TMA_TWOP *i,int abs_pos)
|
||||
static int ma_randjmp(const TMA_TWOP *i,int abs_pos)
|
||||
{
|
||||
int go,test;
|
||||
char ok=0;
|
||||
|
@ -458,7 +527,7 @@ static int ma_randjmp(TMA_TWOP *i,int abs_pos)
|
|||
}
|
||||
|
||||
|
||||
static int ma_test_action(TMA_TWOP *i,int act,int abs_pos)
|
||||
static int ma_test_action(const TMA_TWOP *i,int act,int abs_pos)
|
||||
{
|
||||
int go,test;
|
||||
char ok=0;
|
||||
|
@ -471,7 +540,7 @@ static int ma_test_action(TMA_TWOP *i,int act,int abs_pos)
|
|||
}
|
||||
|
||||
|
||||
static int ma_if_flag(TMA_TWOP *i,int abs_pos)
|
||||
static int ma_if_flag(const TMA_TWOP *i,int abs_pos)
|
||||
{
|
||||
int go,test;
|
||||
char ok=0;
|
||||
|
@ -483,7 +552,7 @@ static int ma_if_flag(TMA_TWOP *i,int abs_pos)
|
|||
if (ok) return go+abs_pos;else return -1;
|
||||
}
|
||||
|
||||
static int ma_picki(TMA_TWOP *i,int abs_pos)
|
||||
static int ma_picki(const TMA_TWOP *i,int abs_pos)
|
||||
{
|
||||
int go,test;
|
||||
char ok=0;
|
||||
|
@ -495,7 +564,7 @@ static int ma_picki(TMA_TWOP *i,int abs_pos)
|
|||
if (ok) return go+abs_pos;else return -1;
|
||||
}
|
||||
|
||||
static void ma_wbook(TMA_LOADLEV *l)
|
||||
static void ma_wbook(const TMA_LOADLEV *l)
|
||||
{
|
||||
char *s;
|
||||
s=find_map_path(l->name);
|
||||
|
@ -563,7 +632,7 @@ static void build_trig_group(char mode,int side)
|
|||
}
|
||||
}
|
||||
|
||||
static int ma_play_anim(char *filename,char cls)
|
||||
static int ma_play_anim(const char *filename,char cls)
|
||||
{
|
||||
char *a;
|
||||
|
||||
|
@ -600,7 +669,7 @@ static void ma_control_mob(int from,int to)
|
|||
send_mob_to(m,path);
|
||||
}
|
||||
|
||||
static void ma_drop_money(int sect,int side,TMULTI_ACTION *q)
|
||||
static void ma_drop_money(int sect,int side,const TMULTI_ACTION *q)
|
||||
{
|
||||
int x;
|
||||
x=rnd(q->twop.parm2-q->twop.parm1+1);
|
||||
|
@ -617,7 +686,7 @@ void macro_change_music(int textindex)
|
|||
change_music(get_next_music_from_playlist());
|
||||
}
|
||||
|
||||
void macro_register_global_event(TMULTI_ACTION *q)
|
||||
void macro_register_global_event(const TMULTI_ACTION *q)
|
||||
{
|
||||
GlobEventList[q->globe.event].cancel=q->globe.cancel;
|
||||
GlobEventList[q->globe.event].sector=q->globe.sector;
|
||||
|
@ -647,105 +716,192 @@ void call_macro(int side,int flags)
|
|||
|
||||
|
||||
|
||||
void call_macro_ex(int side,int flags, int runatside)
|
||||
{
|
||||
TMULTI_ACTION *z,*p;
|
||||
int *r;
|
||||
int mcsiz;
|
||||
int c;
|
||||
|
||||
void call_macro_ex(int side, int flags, int runatside) {
|
||||
const TMULTI_ACTION *z;
|
||||
short saved_trigger;
|
||||
short ls=last_send_action;
|
||||
short ls = last_send_action;
|
||||
short save_rand;
|
||||
|
||||
if (side>=mapsize*4) return;
|
||||
if (runatside>=mapsize*4) return;
|
||||
save_rand=rand_value;rand_value=-1;
|
||||
r=macros[runatside];
|
||||
program_counter=0;
|
||||
if (r==NULL) return;
|
||||
if (side >= mapsize * 4)
|
||||
return;
|
||||
if (runatside >= mapsize * 4)
|
||||
return;
|
||||
save_rand = rand_value;
|
||||
rand_value = -1;
|
||||
TMULTI_ACTION_RECORD mrec = macros[runatside];
|
||||
program_counter = 0;
|
||||
int count_actions = 0;
|
||||
if (mrec.action_list == NULL)
|
||||
return;
|
||||
SEND_LOG("(MULTIACTIONS) Start: Side %.1f Call %X",(float)(runatside/4)+((float)(runatside & 3)/10),flags);
|
||||
saved_trigger=save_load_trigger(-1);
|
||||
if (flags & (MC_PASSSUC | MC_PASSFAIL | MC_EXIT)) build_trig_group(TRIG_GROUP,0);else build_trig_group(TRIG_SECTOR,side);
|
||||
while ((mcsiz=*r)!=0)
|
||||
{
|
||||
r++;
|
||||
zde:
|
||||
z=(TMULTI_ACTION *)r;
|
||||
if (z->general.flags & flags)
|
||||
{
|
||||
c=-1;
|
||||
switch (z->general.action)
|
||||
{
|
||||
case MA_GEN:break;
|
||||
case MA_SOUND:macro_sound(&z->sound,side>>2,side & 3,viewsector,viewdir);break;
|
||||
case MA_TEXTG:macro_disp_text(z->text.textindex,1);break;
|
||||
case MA_TEXTL:macro_disp_text(z->text.textindex,0);break;
|
||||
case MA_SENDA:macro_send_act(&z->send_a);break;
|
||||
case MA_FIREB:macro_fireball(&z->fireball,side>>2,side & 3);break;
|
||||
case MA_DESTI:if (picked_item!=NULL)
|
||||
{
|
||||
saved_trigger = save_load_trigger(-1);
|
||||
if (flags & (MC_PASSSUC | MC_PASSFAIL | MC_EXIT))
|
||||
build_trig_group(TRIG_GROUP, 0);
|
||||
else
|
||||
build_trig_group(TRIG_SECTOR, side);
|
||||
while (mrec.count != 0) {
|
||||
z = mrec.action_list;
|
||||
if (z->general.flags & flags) {
|
||||
int jmp_to = -1;
|
||||
char force_cancel = 0;
|
||||
int stindex = z - first_macro;
|
||||
if (!z->general.once || !macro_state_block.states[stindex]) {
|
||||
macro_state_block.states[stindex] = 1;
|
||||
count_actions++;
|
||||
switch (z->general.action) {
|
||||
default:
|
||||
break;
|
||||
case MA_GEN:
|
||||
break;
|
||||
case MA_SOUND:
|
||||
macro_sound(&z->sound, side >> 2, side & 3, viewsector,
|
||||
viewdir);
|
||||
break;
|
||||
case MA_TEXTG:
|
||||
macro_disp_text(z->text.textindex, 1);
|
||||
break;
|
||||
case MA_TEXTL:
|
||||
macro_disp_text(z->text.textindex, 0);
|
||||
break;
|
||||
case MA_SENDA:
|
||||
macro_send_act(&z->send_a);
|
||||
break;
|
||||
case MA_FIREB:
|
||||
macro_fireball(&z->fireball, side >> 2, side & 3);
|
||||
break;
|
||||
case MA_DESTI:
|
||||
if (picked_item != NULL) {
|
||||
destroy_items(picked_item);
|
||||
free(picked_item);
|
||||
picked_item=NULL;
|
||||
picked_item = NULL;
|
||||
pick_set_cursor();
|
||||
}
|
||||
break;
|
||||
case MA_LOADL:macro_load_another_map(&z->loadlev);break;
|
||||
case MA_DROPI:macro_drop_item(side>>2,side & 0x3,z->dropi.item);break;
|
||||
case MA_CREAT:macro_create_item(z->dropi.item);break;
|
||||
case MA_DIALG:start_dialog(z->text.textindex,-1);break;
|
||||
case MA_SSHOP:enter_shop(z->text.textindex);break;
|
||||
case MA_CLOCK:z->general.cancel=decode_lock(z->clock.znak,z->clock.string,z->clock.codenum);break;
|
||||
case MA_CACTN:cancel_action(z->cactn.sector,z->cactn.dir);break;
|
||||
case MA_LOCK :z->general.cancel=if_lock(side,z->lock.key_id,z->lock.thieflevel,&z->lock);break;
|
||||
case MA_SWAPS:swap_sectors(&z->swaps);break;
|
||||
case MA_WOUND:hit_player(&z->wound,side>>2);break;
|
||||
case MA_IFJMP:c=if_jump(&z->twop,side,program_counter);break;
|
||||
case MA_STORY:write_story_text(level_texts[z->text.textindex]);break;
|
||||
case MA_HAVIT:c=if_have_item(&z->twop,program_counter);break;
|
||||
case MA_SNDEX:ma_send_experience(z->twop.parm1);break;
|
||||
case MA_IFACT:c=ma_test_action(&z->twop,ls,program_counter);break;
|
||||
case MA_CALLS:if (call_map_event(z->twop.parm1,side>>2,side & 3,z->twop.parm2,flags)) call_macro(side,MC_SPEC_SUCC);break;
|
||||
case MA_MOVEG:ma_move_group(z->twop.parm1,z->twop.parm2 & 3,z->twop.parm2>>7);break;
|
||||
case MA_PLAYA:ma_play_anim(z->loadlev.name,z->loadlev.dir);break;
|
||||
case MA_ISFLG:c=ma_if_flag(&z->twop,program_counter);break;
|
||||
case MA_CHFLG:change_flag(z->twop.parm1,(char)z->twop.parm2);break;
|
||||
case MA_CUNIQ:macro_drop_item(side>>2,side & 0x3,create_unique_item(&z->uniq.item)-1);break;
|
||||
case MA_MONEY:ma_drop_money(side>>2,side & 0x3,z);break;
|
||||
case MA_GUNIQ:macro_create_item(create_unique_item(&z->uniq.item)-1);break;
|
||||
case MA_PICKI:c=ma_picki(&z->twop,program_counter);break;
|
||||
case MA_WBOOK:ma_wbook(&z->loadlev);break;
|
||||
case MA_RANDJ:c=ma_randjmp(&z->twop,program_counter);break;
|
||||
case MA_ENDGM:unwire_proc();send_message(E_CLOSE_MAP,(void *)255);break;
|
||||
case MA_GOMOB:ma_control_mob(z->twop.parm1,z->twop.parm2);break;
|
||||
case MA_SHRMA:call_macro_ex(side,flags,z->twop.parm1*4+z->twop.parm2);break;
|
||||
case MA_MUSIC:macro_change_music(z->text.textindex);break;
|
||||
case MA_GLOBE:macro_register_global_event(z);break;
|
||||
}
|
||||
if (c!=-1) p=go_macro(runatside,c);else p=NULL;
|
||||
if (p!=NULL) {r=(int *)p;program_counter=c;mcsiz=r[-1];goto zde;}
|
||||
if (z->general.once)
|
||||
{
|
||||
z->general.action=0;
|
||||
z->general.once=0;
|
||||
if (z->general.cancel)
|
||||
{
|
||||
z->general.cancel=0;
|
||||
goto end;
|
||||
case MA_LOADL:
|
||||
macro_load_another_map(&z->loadlev);
|
||||
break;
|
||||
case MA_DROPI:
|
||||
macro_drop_item(side >> 2, side & 0x3, z->dropi.item);
|
||||
break;
|
||||
case MA_CREAT:
|
||||
macro_create_item(z->dropi.item);
|
||||
break;
|
||||
case MA_DIALG:
|
||||
start_dialog(z->text.textindex, -1);
|
||||
break;
|
||||
case MA_SSHOP:
|
||||
enter_shop(z->text.textindex);
|
||||
break;
|
||||
case MA_CLOCK:
|
||||
force_cancel = decode_lock(z->clock.znak, z->clock.string,
|
||||
z->clock.codenum);
|
||||
break;
|
||||
case MA_CACTN:
|
||||
cancel_action(z->cactn.sector, z->cactn.dir);
|
||||
break;
|
||||
case MA_LOCK:
|
||||
force_cancel = if_lock(side, z->lock.key_id,
|
||||
z->lock.thieflevel, &z->lock);
|
||||
break;
|
||||
case MA_SWAPS:
|
||||
swap_sectors(&z->swaps);
|
||||
break;
|
||||
case MA_WOUND:
|
||||
hit_player(&z->wound, side >> 2);
|
||||
break;
|
||||
case MA_IFJMP:
|
||||
jmp_to = if_jump(&z->twop, side, program_counter);
|
||||
break;
|
||||
case MA_STORY:
|
||||
write_story_text(level_texts[z->text.textindex]);
|
||||
break;
|
||||
case MA_HAVIT:
|
||||
jmp_to = if_have_item(&z->twop, program_counter);
|
||||
break;
|
||||
case MA_SNDEX:
|
||||
ma_send_experience(z->twop.parm1);
|
||||
break;
|
||||
case MA_IFACT:
|
||||
jmp_to = ma_test_action(&z->twop, ls, program_counter);
|
||||
break;
|
||||
case MA_CALLS:
|
||||
if (call_map_event(z->twop.parm1, side >> 2, side & 3,
|
||||
z->twop.parm2, flags))
|
||||
call_macro(side, MC_SPEC_SUCC);
|
||||
break;
|
||||
case MA_MOVEG:
|
||||
ma_move_group(z->twop.parm1, z->twop.parm2 & 3,
|
||||
z->twop.parm2 >> 7);
|
||||
break;
|
||||
case MA_PLAYA:
|
||||
ma_play_anim(z->loadlev.name, z->loadlev.dir);
|
||||
break;
|
||||
case MA_ISFLG:
|
||||
jmp_to = ma_if_flag(&z->twop, program_counter);
|
||||
break;
|
||||
case MA_CHFLG:
|
||||
change_flag(z->twop.parm1, (char) z->twop.parm2);
|
||||
break;
|
||||
case MA_CUNIQ:
|
||||
macro_drop_item(side >> 2, side & 0x3,
|
||||
create_unique_item(&z->uniq.item) - 1);
|
||||
break;
|
||||
case MA_MONEY:
|
||||
ma_drop_money(side >> 2, side & 0x3, z);
|
||||
break;
|
||||
case MA_GUNIQ:
|
||||
macro_create_item(create_unique_item(&z->uniq.item) - 1);
|
||||
break;
|
||||
case MA_PICKI:
|
||||
jmp_to = ma_picki(&z->twop, program_counter);
|
||||
break;
|
||||
case MA_WBOOK:
|
||||
ma_wbook(&z->loadlev);
|
||||
break;
|
||||
case MA_RANDJ:
|
||||
jmp_to = ma_randjmp(&z->twop, program_counter);
|
||||
break;
|
||||
case MA_ENDGM:
|
||||
unwire_proc();
|
||||
send_message(E_CLOSE_MAP, (void*) 255);
|
||||
break;
|
||||
case MA_GOMOB:
|
||||
ma_control_mob(z->twop.parm1, z->twop.parm2);
|
||||
break;
|
||||
case MA_SHRMA:
|
||||
call_macro_ex(side, flags,
|
||||
z->twop.parm1 * 4 + z->twop.parm2);
|
||||
break;
|
||||
case MA_MUSIC:
|
||||
macro_change_music(z->text.textindex);
|
||||
break;
|
||||
case MA_GLOBE:
|
||||
macro_register_global_event(z);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (z->general.cancel) return;
|
||||
}
|
||||
r=(int *)((char *)r+mcsiz);
|
||||
if (jmp_to != -1) {
|
||||
mrec = go_macro(runatside, jmp_to);
|
||||
program_counter = jmp_to;
|
||||
} else if (z->general.cancel || force_cancel) {
|
||||
break;
|
||||
} else {
|
||||
program_counter++;
|
||||
++mrec.action_list;
|
||||
--mrec.count;
|
||||
}
|
||||
end:
|
||||
rand_value=save_rand;
|
||||
} else {
|
||||
program_counter++;
|
||||
++mrec.action_list;
|
||||
--mrec.count;
|
||||
}
|
||||
}
|
||||
rand_value = save_rand;
|
||||
save_load_trigger(saved_trigger);
|
||||
SEND_LOG("(MULTIACTIONS) End: Side %.1f Call %X",(float)(runatside/4)+((float)(runatside & 3)/10),flags);
|
||||
}
|
||||
|
||||
SEND_LOG("(MULTIACTIONS) End: Sector %d, Side %d, Call %X, Actions: %d",runatside/4,runatside & 3,flags,count_actions);
|
||||
|
||||
}
|
||||
|
||||
char save_codelocks(TMPFILE_WR *fsta)
|
||||
{
|
||||
|
|
|
@ -226,7 +226,7 @@ int load_map(char *filename)
|
|||
if (level_preload) show_loading_picture("LOADING.HI");
|
||||
change_music("?");
|
||||
zobraz_mysku();
|
||||
f=fopen(c,"rb");
|
||||
f=fopen_icase(c,"rb");
|
||||
if (level_fname!=NULL) free(level_fname);
|
||||
level_fname=(char *)getmem(strlen(filename)+1);
|
||||
strcpy(level_fname,filename);
|
||||
|
@ -315,8 +315,8 @@ int load_map(char *filename)
|
|||
int32_t h;char *p;
|
||||
|
||||
alock(H_ENEMY);
|
||||
p=ablock(H_ENEMY);p+=8;
|
||||
h=get_handle_size(H_ENEMY)-8;
|
||||
p=ablock(H_ENEMY);
|
||||
h=get_handle_size(H_ENEMY);
|
||||
load_enemies(temp,size,&ofsts,(TMOB *)p,h);
|
||||
aunlock(H_ENEMY);
|
||||
}
|
||||
|
@ -416,7 +416,6 @@ void leave_current_map()
|
|||
SEND_LOG("(GAME) Leaving current map ... start");
|
||||
add_leaving_place(viewsector);
|
||||
kill_all_sounds();
|
||||
restore_sound_names();
|
||||
remove_all_mob_spells();
|
||||
regen_all_mobs();
|
||||
if (save_map) save_map_state(); //do tempu se zabali status mapy
|
||||
|
@ -443,7 +442,6 @@ void leave_current_map()
|
|||
if (macro_block!=NULL)
|
||||
{
|
||||
free(macro_block);
|
||||
free(macros);
|
||||
macros=NULL;
|
||||
macro_block=NULL;
|
||||
macro_block_size=0;
|
||||
|
@ -677,6 +675,15 @@ void calc_fly()
|
|||
|
||||
}
|
||||
|
||||
void destroy_all_fly() {
|
||||
while (letici_veci) {
|
||||
TFLY *f = letici_veci;
|
||||
letici_veci = f->next;
|
||||
if (f->items) free(f->items);
|
||||
free(f);
|
||||
}
|
||||
}
|
||||
|
||||
extern int32_t sound_side_flags;
|
||||
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ TDREGISTERS registred[]=
|
|||
{H_IDESKA,"ideska.pcx",pcx_8bit_decomp,SR_BGRAFIKA},
|
||||
{H_IMRIZ1,"imriz1.pcx",pcx_8bit_decomp,SR_BGRAFIKA},
|
||||
{H_RAMECEK,"ramecek.pcx",pcx_8bit_decomp,SR_BGRAFIKA},
|
||||
{H_ENEMY,"enemy.dat",NULL,SR_MAP},
|
||||
{H_ENEMY,"enemy.dat",load_mob_legacy_format,SR_MAP},
|
||||
{H_BATTLE_BAR,"souboje.pcx",pcx_8bit_decomp,SR_BGRAFIKA},
|
||||
{H_BATTLE_MASK,"m_souboj.pcx",pcx_8bit_decomp,SR_BGRAFIKA},
|
||||
{H_MZASAH1,"mzasah1.pcx",pcx_8bit_decomp,SR_BGRAFIKA},
|
||||
|
@ -443,6 +443,37 @@ void hi_8bit_correct(void **p,int32_t *s)
|
|||
}
|
||||
|
||||
|
||||
void load_mob_legacy_format(void **p, int32_t *s) {
|
||||
const int sz = 376;
|
||||
int count = *s / sz;;
|
||||
char *c = *p;
|
||||
TMOB *out = getmem(count * sizeof(TMOB));
|
||||
|
||||
memset(out, 0 , sizeof(TMOB)*count);
|
||||
c+=8;
|
||||
for (int i = 0; i < count ; i++) {
|
||||
TMOB *m = out+i;
|
||||
char *d = (char *)m;
|
||||
size_t ofs = 0;
|
||||
size_t nx = offsetof(TMOB,experience);
|
||||
memcpy(d, c, nx);
|
||||
c+=nx-2; //first padding 2
|
||||
d+=nx;
|
||||
ofs=nx;
|
||||
nx = offsetof(TMOB, dialog_flags);
|
||||
memcpy(d, c, nx - ofs);
|
||||
c+=nx - ofs -1; //second padding 1
|
||||
d+=nx;
|
||||
ofs=nx;
|
||||
nx = sizeof(TMOB);
|
||||
memcpy(d, c, nx - ofs); //last padding 1
|
||||
c+=nx - ofs - 1;
|
||||
}
|
||||
free(*p);
|
||||
*p =out;
|
||||
*s = count * sizeof(TMOB);
|
||||
}
|
||||
|
||||
void set_background(void **p,int32_t *s)
|
||||
{
|
||||
word *data;
|
||||
|
@ -1243,7 +1274,7 @@ static void config_skeldal(const char *line)
|
|||
|
||||
strcpy(s,"Chyba v INI souboru: Neznama promenna - ");
|
||||
strncat(s,line,i);
|
||||
SEND_LOG("(ERROR) %s",s,NULL);
|
||||
SEND_LOG("(ERROR) %s",s);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1252,7 +1283,7 @@ static void config_skeldal(const char *line)
|
|||
char s[256];
|
||||
|
||||
sprintf(s,"Chyba v INI souboru: Ocekava se ciselna hodnota\n%s\n",line);
|
||||
SEND_LOG("(ERROR) %s",s,NULL);
|
||||
SEND_LOG("(ERROR) %s",s);
|
||||
}
|
||||
do_config_skeldal(i,ndata,data);
|
||||
}
|
||||
|
@ -1260,14 +1291,14 @@ static void config_skeldal(const char *line)
|
|||
|
||||
static void configure(char *filename)
|
||||
{
|
||||
SEND_LOG("(GAME) Reading config. file '%s'",filename,NULL);
|
||||
SEND_LOG("(GAME) Reading config. file '%s'",filename);
|
||||
cur_config=read_config(filename);
|
||||
if (cur_config==NULL)
|
||||
{
|
||||
char s[256];
|
||||
|
||||
sprintf(s,"\nNemohu precist konfiguracni soubor \"%s\".\n",filename);
|
||||
SEND_LOG("(ERROR) %s",s,NULL);
|
||||
SEND_LOG("(ERROR) %s",s);
|
||||
puts(s);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -1278,7 +1309,7 @@ static void configure(char *filename)
|
|||
|
||||
static int update_config(void)
|
||||
{
|
||||
SEND_LOG("(GAME) Updating config. file '%s'",CONFIG_NAME,NULL);
|
||||
SEND_LOG("(GAME) Updating config. file '%s'",CONFIG_NAME);
|
||||
add_field_num(&cur_config,sinit[1].heslo,zoom_speed(-1));
|
||||
add_field_num(&cur_config,sinit[2].heslo,turn_speed(-1));
|
||||
if (check_snd_effect(SND_MUSIC)) add_field_num(&cur_config,sinit[3].heslo,get_snd_effect(SND_MUSIC));
|
||||
|
@ -1478,6 +1509,7 @@ static void game_big_circle(char enforced)
|
|||
for(r=0;r<mapsize*4;r++) call_macro(r,MC_STARTLEV);
|
||||
recalc_volumes(viewsector,viewdir);
|
||||
loadlevel.name[0]=0;
|
||||
reroll_all_shops();
|
||||
|
||||
enter_game();
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
typedef unsigned short SND_FIND_TABLE[2];
|
||||
typedef struct snd_info
|
||||
{
|
||||
TMA_SOUND *data; //4
|
||||
const TMA_SOUND *data; //4
|
||||
short xpos,ypos,side; //10
|
||||
word volume,block; //14
|
||||
}SND_INFO;
|
||||
|
@ -241,7 +241,7 @@ void wav_load(void **p,int32_t *s)
|
|||
}*/
|
||||
}
|
||||
|
||||
void play_effekt(int x,int y,int xd,int yd,int side,int sided,TMA_SOUND *p)
|
||||
void play_effekt(int x,int y,int xd,int yd,int side,int sided,const TMA_SOUND *p)
|
||||
{
|
||||
int chan;
|
||||
int blockid;
|
||||
|
@ -264,21 +264,18 @@ void play_effekt(int x,int y,int xd,int yd,int side,int sided,TMA_SOUND *p)
|
|||
if (rnd(100)>50) set_channel_volume(chan,rnd(vol),vol);
|
||||
else set_channel_volume(chan,vol,rnd(vol));
|
||||
}
|
||||
else
|
||||
else {
|
||||
if (calcul_volume(chan,x-xd,y-yd,/*side-*/sided,p->volume)) return;
|
||||
if (p->filename[0]==1) memcpy(&blockid,&p->filename[1],4);
|
||||
else
|
||||
{
|
||||
blockid=find_handle(p->filename,wav_load);
|
||||
if (blockid==-1)
|
||||
{
|
||||
def_handle(end_ptr,p->filename,wav_load,SR_ZVUKY);
|
||||
blockid=end_ptr++;
|
||||
if (level_preload) apreload(blockid);
|
||||
}
|
||||
memcpy(&p->filename[1],&blockid,4);
|
||||
p->filename[0]=1;
|
||||
|
||||
blockid = find_handle(p->filename, wav_load);
|
||||
if (blockid == -1) {
|
||||
def_handle(end_ptr, p->filename, wav_load, SR_ZVUKY);
|
||||
blockid = end_ptr++;
|
||||
if (level_preload)
|
||||
apreload(blockid);
|
||||
}
|
||||
|
||||
alock(blockid);
|
||||
s=ablock(blockid);
|
||||
s+=p->offset+sizeof(struct t_wave)+4;
|
||||
|
@ -292,46 +289,6 @@ void play_effekt(int x,int y,int xd,int yd,int side,int sided,TMA_SOUND *p)
|
|||
chan_state[chan]=p->soundid;
|
||||
track_state[p->soundid]=chan;
|
||||
}
|
||||
|
||||
void restore_sound_name(TMA_SOUND *p)
|
||||
{
|
||||
int blockid;
|
||||
THANDLE_DATA *h;
|
||||
|
||||
if (p->filename[0]==1)
|
||||
{
|
||||
memcpy(&blockid,&p->filename[1],4);
|
||||
do
|
||||
{
|
||||
h=get_handle(blockid);
|
||||
if (h->status==BK_SAME_AS) blockid=h->seekpos;else blockid=-1;
|
||||
}
|
||||
while (blockid!=-1);
|
||||
strncpy(p->filename,h->src_file,12);
|
||||
}
|
||||
}
|
||||
|
||||
void restore_sound_names()
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0;i<mapsize*4;i++)
|
||||
if (macros[i]!=NULL)
|
||||
{
|
||||
int *r,mcsiz;
|
||||
TMULTI_ACTION *z;
|
||||
|
||||
r=macros[i];
|
||||
while ((mcsiz=*r)!=0)
|
||||
{
|
||||
r++;
|
||||
z=(TMULTI_ACTION *)r;
|
||||
if (z->general.action==MA_SOUND) restore_sound_name(&z->sound);
|
||||
r=(int *)((char *)r+mcsiz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void recalc_volumes(int sector,int side)
|
||||
{
|
||||
int i;
|
||||
|
@ -441,9 +398,9 @@ const char *get_next_music_from_playlist()
|
|||
while (step);
|
||||
playing_track=i;
|
||||
snprintf(d,sizeof(d),"%s%s",pathtable[SR_MUSIC],cur_playlist[i]+1);
|
||||
if (access(d,0) == -1) {
|
||||
if (!check_file_exists(d)) {
|
||||
snprintf(d,sizeof(d),"%s%s",pathtable[SR_ORGMUSIC],cur_playlist[i]+1);
|
||||
if (access(d,0) == -1) {
|
||||
if (!check_file_exists(d)) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ void temp_storage_store(const char *name, const void *data, int32_t size) {
|
|||
auto &v =temp_fsystem[std::string(name)];
|
||||
v.clear();
|
||||
v.resize(size+1);
|
||||
v[size] = 0;
|
||||
v.resize(size);
|
||||
std::copy(b,e, v.begin());
|
||||
v[size] = 0;
|
||||
}
|
||||
|
@ -61,6 +63,8 @@ void temp_storage_clear() {
|
|||
TMPFILE_RD* temp_storage_open(const char *name) {
|
||||
auto iter = temp_fsystem.find(std::string_view(name));
|
||||
if (iter == temp_fsystem.end()) return NULL;
|
||||
iter->second.push_back(0); //put extra zero at the end
|
||||
iter->second.resize(iter->second.size()-1);
|
||||
return new TMPFILE_RD{std::basic_string_view<uint8_t>(iter->second.data(), iter->second.size())};
|
||||
}
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ static void load_specific_file(char *slotname,char *filename,void **out,int32_t
|
|||
char fname[12];
|
||||
char succes=0;
|
||||
|
||||
slot=fopen(slotname,"rb");
|
||||
slot=fopen_icase(slotname,"rb");
|
||||
if (slot==NULL)
|
||||
{
|
||||
*out=NULL;
|
||||
|
@ -459,7 +459,7 @@ char *scan_saves(char *text,char *path,char mustexists)
|
|||
{
|
||||
sprintf(szBuff,"%sSLOT%02d.SAV",path,i);
|
||||
cprintf("%d. ",(i+1)%10);
|
||||
f=fopen(szBuff,"rb");
|
||||
f=fopen_icase(szBuff,"rb");
|
||||
if (f!=NULL)
|
||||
{
|
||||
fread(szBuff,1,34,f);szBuff[34]=0;
|
||||
|
@ -492,7 +492,7 @@ int tracemap(char *name)
|
|||
int type;
|
||||
int32_t size,s;
|
||||
|
||||
f=fopen(name,"rb");
|
||||
f=fopen_icase(name,"rb");
|
||||
if (f==NULL) return -1;
|
||||
do
|
||||
{
|
||||
|
@ -545,7 +545,7 @@ void save_savegame(char *soubor)
|
|||
void *p;
|
||||
int s;
|
||||
|
||||
f=fopen(soubor,"wb");
|
||||
f=fopen_icase(soubor,"wb");
|
||||
strcpy(szBuff,"TRANSAV");
|
||||
fwrite(szBuff,SAVE_NAME_SIZE,1,f);
|
||||
strcpy(szBuff,"_GAME.TMP");
|
||||
|
|
|
@ -219,7 +219,7 @@ static char purge_map()
|
|||
if (buffer[0]==0) return 0;
|
||||
strupr(buffer);
|
||||
concat(c,pathtable[SR_TEMP],buffer);
|
||||
if (strcmp(buffer,ALL) && access(c,0))
|
||||
if (strcmp(buffer,ALL) && check_file_exists_ex(c))
|
||||
{
|
||||
wzputs("Soubor nenalezen!");
|
||||
return 0;
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
void install_wizard(void);
|
||||
|
||||
|
||||
|
|
|
@ -68,13 +68,13 @@ void save_stringtable(char *filename,char *backup_name)
|
|||
int num,rd;
|
||||
int oldnum=-1,i;
|
||||
|
||||
fb=fopen(backup_name,"rt");
|
||||
fb=fopen_icase(backup_name,"rt");
|
||||
if (fb==NULL)
|
||||
{
|
||||
puts("Cannot open backup file for reading.");
|
||||
exit(1);
|
||||
}
|
||||
fo=fopen(filename,"wt");
|
||||
fo=fopen_icase(filename,"wt");
|
||||
if (fo==NULL)
|
||||
{
|
||||
puts("Cannot open target file for writting.");
|
||||
|
|
|
@ -24,7 +24,7 @@ void ReadScript(char *script)
|
|||
int j=0;
|
||||
char *pcx;
|
||||
unsigned short *wpcx;
|
||||
scr=fopen(script,"rt");
|
||||
scr=fopen_icase(script,"rt");
|
||||
if (scr==NULL) Error("Nemohu otevrit soubor: %s",script);
|
||||
i=fscanf(scr,"%s",szBuff);
|
||||
while (i!=EOF)
|
||||
|
@ -36,7 +36,7 @@ void ReadScript(char *script)
|
|||
{
|
||||
sprintf(szBuff,IKNNAME,icount++);
|
||||
printf("Sestavuji soubor %s\n",szBuff);
|
||||
trg=fopen(szBuff,"wb");
|
||||
trg=fopen_icase(szBuff,"wb");
|
||||
if (trg==NULL) Error("Nelze zapisovat do souboru %s",szBuff);
|
||||
}
|
||||
if (!fwrite(pcx,PCXSIZE,1,trg)) Error("Chyba nastala pri zapisu do souboru %s",szBuff);
|
||||
|
|
|
@ -15,7 +15,7 @@ int load_file(char *filename)
|
|||
{
|
||||
int32_t size;
|
||||
|
||||
bmp=fopen(filename,"rb");
|
||||
bmp=fopen_icase(filename,"rb");
|
||||
if (!bmp) return -1;
|
||||
fseek(bmp,0,SEEK_END);
|
||||
size=ftell(bmp);
|
||||
|
@ -80,7 +80,7 @@ void conv_hicolor()
|
|||
|
||||
int save_file_hi(char *newname)
|
||||
{
|
||||
bmp=fopen(newname,"wb");
|
||||
bmp=fopen_icase(newname,"wb");
|
||||
if (!bmp) return -1;
|
||||
fwrite(&xsize,1,2,bmp);
|
||||
fwrite(&ysize,1,2,bmp);
|
||||
|
@ -172,7 +172,7 @@ void conv_256color()
|
|||
|
||||
int save_file_256(char *newname)
|
||||
{
|
||||
bmp=fopen(newname,"wb");
|
||||
bmp=fopen_icase(newname,"wb");
|
||||
if (!bmp) return -1;
|
||||
fwrite(&xsize,1,2,bmp);
|
||||
fwrite(&ysize,1,2,bmp);
|
||||
|
|
|
@ -36,7 +36,7 @@ char global_name[256];
|
|||
void init(char *filename )
|
||||
{
|
||||
pgm=program;
|
||||
source=fopen(filename,"r");
|
||||
source=fopen_icase(filename,"r");
|
||||
cur_spell=0;
|
||||
if (source==NULL)
|
||||
{
|
||||
|
@ -116,7 +116,7 @@ int build_tables()
|
|||
|
||||
void save_tab(char *name)
|
||||
{
|
||||
target=fopen(name,"wb");
|
||||
target=fopen_icase(name,"wb");
|
||||
if (target==NULL)
|
||||
{
|
||||
printf("SAVE: Chyba pri ukladani souboru %s \n",name);
|
||||
|
|
168
libs/devices.c
168
libs/devices.c
|
@ -8,24 +8,22 @@
|
|||
|
||||
/* Data touched at mouse callback time -- they are in a structure to
|
||||
simplify calculating the size of the region to lock.
|
||||
*/
|
||||
*/
|
||||
|
||||
extern MS_EVENT win_mouseEvent;
|
||||
|
||||
|
||||
TMS_BASIC_INFO ms_basic_info={0};
|
||||
TMS_BASIC_INFO ms_basic_info = { 0 };
|
||||
static char ms_keys;
|
||||
|
||||
/*
|
||||
void get_ms_event(MS_EVENT *event)
|
||||
void get_ms_event(MS_EVENT *event)
|
||||
{
|
||||
CheckMessageQueue();
|
||||
*event=win_mouseEvent;
|
||||
win_mouseEvent.event=0;
|
||||
}
|
||||
*/
|
||||
char cz_table_small_normal[] =
|
||||
{ 0x20, 0x31, 0x21, 0x33, 0x34, 0x35, 0x37, 0xad,
|
||||
*/
|
||||
char cz_table_small_normal[] = { 0x20, 0x31, 0x21, 0x33, 0x34, 0x35, 0x37, 0xad,
|
||||
0x39, 0x30, 0x38, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x82, 0x2b, 0x88, 0xa8,
|
||||
0x87, 0xa9, 0x91, 0x98, 0xa0, 0xa1, 0x22, 0x96, 0x3f, 0x3d, 0x3a, 0x5f,
|
||||
0x32, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b,
|
||||
|
@ -34,105 +32,87 @@ char cz_table_small_normal[] =
|
|||
0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x2f,
|
||||
0x7c, 0x28, 0x3b, 0x20 };
|
||||
char cz_table_small_carka[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
|
||||
0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34,
|
||||
0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40,
|
||||
0x8f, 0x42, 0x43, 0x44, 0x90, 0x46, 0x47, 0x48, 0x8b, 0x4a, 0x4b, 0x8a,
|
||||
0x4d, 0x4e, 0x95, 0x50, 0x51, 0xab, 0x53, 0x54, 0x97, 0x56, 0x57, 0x58,
|
||||
0x9d, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0xa0, 0x62, 0x63, 0x64,
|
||||
0x82, 0x66, 0x67, 0x68, 0xa1, 0x6a, 0x6b, 0x8d, 0x6d, 0x6e, 0xa2, 0x70,
|
||||
0x71, 0xaa, 0x73, 0x74, 0xa3, 0x76, 0x77, 0x78, 0x98, 0x7a, 0x7b, 0x7c,
|
||||
0x7d, 0x7e, 0x20 };
|
||||
char cz_table_small_hacek[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
|
||||
0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34,
|
||||
0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40,
|
||||
0x41, 0x42, 0x80, 0x85, 0x89, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x9c,
|
||||
0x4d, 0xa5, 0xa7, 0x50, 0x51, 0x9e, 0x9b, 0x86, 0xa6, 0x56, 0x57, 0x58,
|
||||
0x59, 0x92, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x87, 0x83,
|
||||
0x88, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x8c, 0x6d, 0xa4, 0x93, 0x70,
|
||||
0x71, 0xa9, 0xa8, 0x9f, 0x96, 0x76, 0x77, 0x78, 0x79, 0x91, 0x7b, 0x7c,
|
||||
0x7d, 0x7e, 0x20 };
|
||||
char cz_table_caps_normal[] =
|
||||
{ 0x20, 0x31, 0x21, 0x33, 0x34, 0x35, 0x37, 0xad,
|
||||
0x39, 0x30, 0x38, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
|
||||
|
||||
0x90, 0x2b, 0x89, 0x9b, 0x80, 0x9e, 0x92, 0x9d, 0x8f, 0x8b,
|
||||
|
||||
0x22, 0x96, 0x3f, 0x3d, 0x3a, 0x5f,
|
||||
char cz_table_small_carka[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
|
||||
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
|
||||
0x40, 0x8f, 0x42, 0x43, 0x44, 0x90, 0x46, 0x47, 0x48, 0x8b, 0x4a, 0x4b,
|
||||
0x8a, 0x4d, 0x4e, 0x95, 0x50, 0x51, 0xab, 0x53, 0x54, 0x97, 0x56, 0x57,
|
||||
0x58, 0x9d, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0xa0, 0x62, 0x63,
|
||||
0x64, 0x82, 0x66, 0x67, 0x68, 0xa1, 0x6a, 0x6b, 0x8d, 0x6d, 0x6e, 0xa2,
|
||||
0x70, 0x71, 0xaa, 0x73, 0x74, 0xa3, 0x76, 0x77, 0x78, 0x98, 0x7a, 0x7b,
|
||||
0x7c, 0x7d, 0x7e, 0x20 };
|
||||
char cz_table_small_hacek[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
|
||||
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
|
||||
0x40, 0x41, 0x42, 0x80, 0x85, 0x89, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b,
|
||||
0x9c, 0x4d, 0xa5, 0xa7, 0x50, 0x51, 0x9e, 0x9b, 0x86, 0xa6, 0x56, 0x57,
|
||||
0x58, 0x59, 0x92, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x87,
|
||||
0x83, 0x88, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x8c, 0x6d, 0xa4, 0x93,
|
||||
0x70, 0x71, 0xa9, 0xa8, 0x9f, 0x96, 0x76, 0x77, 0x78, 0x79, 0x91, 0x7b,
|
||||
0x7c, 0x7d, 0x7e, 0x20 };
|
||||
char cz_table_caps_normal[] = { 0x20, 0x31, 0x21, 0x33, 0x34, 0x35, 0x37, 0xad,
|
||||
0x39, 0x30, 0x38, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x90, 0x2b, 0x89, 0x9b,
|
||||
0x80, 0x9e, 0x92, 0x9d, 0x8f, 0x8b, 0x22, 0x96, 0x3f, 0x3d, 0x3a, 0x5f,
|
||||
0x32, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b,
|
||||
0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
|
||||
0x78, 0x79, 0x7a, 0xa3, 0x5c, 0x29, 0x36, 0x3d, 0x3b, 0x41, 0x42, 0x43,
|
||||
0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x2f,
|
||||
0x7c, 0x28, 0x3b, 0x20 };
|
||||
char cz_table_caps_carka[] =
|
||||
{ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||
char cz_table_caps_carka[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
|
||||
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
|
||||
0x40,
|
||||
0x40, 0xa0, 0x62, 0x63, 0x64, 0x82, 0x66, 0x67, 0x68, 0xa1, 0x6a, 0x6b,
|
||||
0x8d, 0x6d, 0x6e, 0xa2, 0x70, 0x71, 0xaa, 0x73, 0x74, 0xa3, 0x76, 0x77,
|
||||
0x78, 0x98, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x8f, 0x42, 0x43,
|
||||
0x44, 0x90, 0x46, 0x47, 0x48, 0x8b, 0x4a, 0x4b, 0x8a, 0x4d, 0x4e, 0x95,
|
||||
0x50, 0x51, 0xab, 0x53, 0x54, 0x97, 0x56, 0x57, 0x58, 0x9d, 0x5a, 0x7b,
|
||||
0x7c, 0x7d, 0x7e, 0x20 };
|
||||
char cz_table_caps_hacek[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
|
||||
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
|
||||
0x40, 0x61, 0x62, 0x87, 0x83, 0x88, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b,
|
||||
0x8c, 0x6d, 0xa4, 0x93, 0x70, 0x71, 0xa9, 0xa8, 0x9f, 0x96, 0x76, 0x77,
|
||||
0x78, 0x79, 0x91, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x41, 0x42, 0x80,
|
||||
0x85, 0x89, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x9c, 0x4d, 0xa5, 0xa7,
|
||||
0x50, 0x51, 0x9e, 0x9b, 0x86, 0xa6, 0x56, 0x57, 0x58, 0x59, 0x92, 0x7b,
|
||||
0x7c, 0x7d, 0x7e, 0x20 };
|
||||
char *cz_key_tabs[] = { cz_table_small_normal, cz_table_small_carka,
|
||||
cz_table_small_hacek, cz_table_caps_normal, cz_table_caps_carka,
|
||||
cz_table_caps_hacek };
|
||||
|
||||
0xa0, 0x62, 0x63, 0x64, 0x82, 0x66, 0x67, 0x68, 0xa1, 0x6a,
|
||||
0x6b, 0x8d, 0x6d, 0x6e, 0xa2, 0x70, 0x71, 0xaa, 0x73, 0x74,
|
||||
0xa3, 0x76, 0x77, 0x78, 0x98, 0x7a,
|
||||
|
||||
0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60,
|
||||
|
||||
0x8f, 0x42, 0x43, 0x44, 0x90, 0x46, 0x47, 0x48, 0x8b, 0x4a,
|
||||
0x4b, 0x8a, 0x4d, 0x4e, 0x95, 0x50, 0x51, 0xab, 0x53, 0x54,
|
||||
0x97, 0x56, 0x57, 0x58, 0x9d, 0x5a,
|
||||
|
||||
0x7b, 0x7c, 0x7d, 0x7e, 0x20 };
|
||||
char cz_table_caps_hacek[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
|
||||
0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34,
|
||||
0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40,
|
||||
|
||||
0x61, 0x62, 0x87, 0x83, 0x88, 0x66, 0x67, 0x68, 0x69, 0x6a,
|
||||
0x6b, 0x8c, 0x6d, 0xa4, 0x93, 0x70, 0x71, 0xa9, 0xa8, 0x9f,
|
||||
0x96, 0x76, 0x77, 0x78, 0x79, 0x91,
|
||||
|
||||
0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60,
|
||||
|
||||
0x41, 0x42, 0x80, 0x85, 0x89, 0x46, 0x47, 0x48, 0x49, 0x4a,
|
||||
0x4b, 0x9c, 0x4d, 0xa5, 0xa7, 0x50, 0x51, 0x9e, 0x9b, 0x86,
|
||||
0xa6, 0x56, 0x57, 0x58, 0x59, 0x92,
|
||||
|
||||
|
||||
0x7b, 0x7c, 0x7d, 0x7e, 0x20 };
|
||||
char *cz_key_tabs[]={cz_table_small_normal,cz_table_small_carka,cz_table_small_hacek,
|
||||
cz_table_caps_normal, cz_table_caps_carka, cz_table_caps_hacek};
|
||||
|
||||
void keyboard(EVENT_MSG *msg,void *user_data)
|
||||
{
|
||||
void keyboard(EVENT_MSG *msg, void *user_data) {
|
||||
int i;
|
||||
static uint8_t cz_mode=0;
|
||||
char c,d;
|
||||
static uint8_t cz_mode = 0;
|
||||
char c, d;
|
||||
|
||||
msg;user_data;
|
||||
if (msg->msg==E_WATCH)
|
||||
{
|
||||
*otevri_zavoru=1;
|
||||
if (!_bios_keybrd(_KEYBRD_READY)) return;
|
||||
i=_bios_keybrd(_KEYBRD_READ);
|
||||
d=i>>8;
|
||||
c=i & 0xff;
|
||||
if (c=='+' && d<55 && !cz_mode) cz_mode=2;
|
||||
else if (c=='=' && d<55 && !cz_mode) cz_mode=1;
|
||||
else if (c>32 && c<127 && d<=53)
|
||||
{
|
||||
if (get_capslock_state()) cz_mode +=3;
|
||||
c=cz_key_tabs[cz_mode][c-32];
|
||||
i=d;
|
||||
i=(i<<8)+c;
|
||||
send_message(E_KEYBOARD,i);
|
||||
cz_mode=0;
|
||||
}
|
||||
else
|
||||
send_message(E_KEYBOARD,i);
|
||||
msg;
|
||||
user_data;
|
||||
if (msg->msg == E_WATCH) {
|
||||
*otevri_zavoru = 1;
|
||||
if (!_bios_keybrd(_KEYBRD_READY))
|
||||
return;
|
||||
i = _bios_keybrd(_KEYBRD_READ);
|
||||
d = i >> 8;
|
||||
c = i & 0xff;
|
||||
if (c == '+' && d < 55 && !cz_mode)
|
||||
cz_mode = 2;
|
||||
else if (c == '=' && d < 55 && !cz_mode)
|
||||
cz_mode = 1;
|
||||
else if (c > 32 && c < 127 && d <= 53) {
|
||||
if (get_capslock_state())
|
||||
cz_mode += 3;
|
||||
c = cz_key_tabs[cz_mode][c - 32];
|
||||
i = d;
|
||||
i = (i << 8) + c;
|
||||
send_message(E_KEYBOARD, i);
|
||||
cz_mode = 0;
|
||||
} else
|
||||
send_message(E_KEYBOARD, i);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char ms_get_keycount()
|
||||
{
|
||||
char ms_get_keycount() {
|
||||
return ms_keys;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,5 +19,5 @@ main()
|
|||
|
||||
err_stack=malloc(16384);
|
||||
install_dos_error(err_proc,(char *)err_stack+16384);
|
||||
f=fopen("a:\test","r");
|
||||
f=fopen_icase("a:\test","r");
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ T_EVENT_ROOT *add_event_message(T_EVENT_ROOT **tree,int msg)
|
|||
r1->next=r;
|
||||
}
|
||||
r->event_msg=msg;
|
||||
//r->used=0;
|
||||
r->used=0;
|
||||
r->list=NULL;
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ main(int argc,char **argv)
|
|||
puts("File not found");
|
||||
return 1;
|
||||
}
|
||||
f=fopen(argv[3],"w");
|
||||
f=fopen_icase(argv[3],"w");
|
||||
fwrite(z,1,s,f);
|
||||
fclose(f);
|
||||
puts("File successfuly expanded");
|
||||
|
|
|
@ -23,7 +23,7 @@ main(int argc,char **argv)
|
|||
close_manager();
|
||||
return 1;
|
||||
}
|
||||
f=fopen(argv[3],"wb");
|
||||
f=fopen_icase(argv[3],"wb");
|
||||
fwrite(z,1,s,f);
|
||||
fclose(f);
|
||||
puts("File successfuly expanded");
|
||||
|
|
|
@ -657,7 +657,7 @@ void do_it_events(EVENT_MSG *msg,void **user_data)
|
|||
o_aktual->call_event(&msg2, o_aktual);
|
||||
o_aktual->on_enter();
|
||||
if (p != NULL)
|
||||
o_aktual->call_event(msg, o_aktual);
|
||||
o_aktual->call_event(&fwmsg, o_aktual);
|
||||
}
|
||||
}
|
||||
destroy_message(&fwmsg);
|
||||
|
|
|
@ -13,7 +13,7 @@ TSTR_LIST read_config(const char *filename)
|
|||
TSTR_LIST ls;
|
||||
char buff[256];
|
||||
|
||||
f=fopen(filename,"r");
|
||||
f=fopen_icase(filename,"r");
|
||||
if (f==NULL) return NULL;
|
||||
ls=create_list(256);
|
||||
while (!feof(f))
|
||||
|
@ -112,7 +112,7 @@ int save_config(TSTR_LIST ls,const char *filename)
|
|||
{
|
||||
int i,cnt,err=0;
|
||||
FILE *f;
|
||||
f=fopen(filename,"w");
|
||||
f=fopen_icase(filename,"w");
|
||||
if (f==NULL) return -1;
|
||||
cnt=str_count(ls);
|
||||
for(i=0;i<cnt && !err;i++) if (ls[i]!=NULL)
|
||||
|
|
|
@ -24,7 +24,7 @@ void error_extend(char *file,int seek)
|
|||
FILE *f;
|
||||
int c,i=0,ls=0,ls0=0,ls1=0,ls2=0;
|
||||
|
||||
f=fopen(file,"r");
|
||||
f=fopen_icase(file,"r");
|
||||
if (f==NULL) return;
|
||||
c=getc(f);
|
||||
while (c!=EOF && ls2<seek)
|
||||
|
@ -153,7 +153,7 @@ void xlat_text(FILE *source,FILE *target)
|
|||
if (count && lastcom)
|
||||
{
|
||||
char c[255];
|
||||
sprintf(c,"Nespr vn˜ po‡et parametr– u p©¡kazu '%s'",cm);
|
||||
sprintf(c,"Nespr<EFBFBD>vn<EFBFBD> po<70>et parametr<74> u p<><70>kazu '%s'",cm);
|
||||
error(c,ftell(source));
|
||||
}
|
||||
else
|
||||
|
@ -249,7 +249,7 @@ void open_include(char *name)
|
|||
FILE *inc;
|
||||
char *p;
|
||||
|
||||
inc=fopen(name,"r");
|
||||
inc=fopen_icase(name,"r");
|
||||
if (inc==NULL)
|
||||
{
|
||||
char s[256];
|
||||
|
@ -273,7 +273,7 @@ main(int argc,char *argv[])
|
|||
puts("Program vyzaduje dva parametry: LEX_LIB source_file target_file");
|
||||
exit(0);
|
||||
}
|
||||
target_file=fopen(argv[2],"w");
|
||||
target_file=fopen_icase(argv[2],"w");
|
||||
open_include(argv[1]);
|
||||
fclose(target_file);
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ void *load_file(char *filename)
|
|||
|
||||
if (mman_action!=NULL) mman_action(MMA_READ);
|
||||
SEND_LOG("(LOAD) Loading file '%s'",filename);
|
||||
f=fopen(filename, "rb");
|
||||
f=fopen_icase(filename, "rb");
|
||||
if (f==NULL) {
|
||||
load_error(filename);
|
||||
return NULL;
|
||||
|
@ -157,7 +157,7 @@ static int test_file_exist_DOS(int group,char *filename)
|
|||
f=alloca(strlen(mman_pathlist[group])+strlen(filename)+1);
|
||||
strcpy(f,mman_pathlist[group]);
|
||||
strcat(f,filename);
|
||||
if (access(f,0)) return 0;
|
||||
if (!check_file_exists(f)) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -381,7 +381,7 @@ void init_manager(char *filename,char *swap_is_not_supported) // filename= Jmeno
|
|||
memset(_handles,0,sizeof(_handles));
|
||||
if (filename!=NULL)
|
||||
{
|
||||
bmf=fopen(filename,"rb");
|
||||
bmf=fopen_icase(filename,"rb");
|
||||
if (bmf)
|
||||
{
|
||||
main_file_name=(char *)getmem(strlen(filename)+1);
|
||||
|
@ -412,7 +412,7 @@ void *load_swaped_block(THANDLE_DATA *h)
|
|||
}
|
||||
|
||||
|
||||
int find_same(char *name,void *decomp)
|
||||
int find_same(const char *name,void *decomp)
|
||||
{
|
||||
THANDLE_DATA *p;
|
||||
int i,j;
|
||||
|
@ -429,7 +429,7 @@ int find_same(char *name,void *decomp)
|
|||
return -1;
|
||||
}
|
||||
|
||||
int find_handle(char *name,void *decomp)
|
||||
int find_handle(const char *name,void *decomp)
|
||||
{
|
||||
return find_same(name,decomp);
|
||||
}
|
||||
|
@ -440,7 +440,7 @@ int test_file_exist(int group,char *filename)
|
|||
return 1;
|
||||
}
|
||||
|
||||
THANDLE_DATA *def_handle(int handle,char *filename,void *decompress,char path)
|
||||
THANDLE_DATA *def_handle(int handle,const char *filename,void *decompress,char path)
|
||||
{
|
||||
THANDLE_DATA *h;
|
||||
int i;
|
||||
|
@ -842,7 +842,7 @@ char add_patch_file(char *filename)
|
|||
SEND_LOG("Adding patch: %s",filename);
|
||||
if (!patch) return 2;
|
||||
if (!bmf) return 3;
|
||||
patch=fopen(filename,"rb");
|
||||
patch=fopen_icase(filename,"rb");
|
||||
if (!patch) return 1;
|
||||
fseek(patch,4,SEEK_SET);
|
||||
fread(&l,1,4,patch);
|
||||
|
|
|
@ -75,7 +75,7 @@ void *getmem(int32_t size); //alokace pameti pres memman. alokovat pomoci
|
|||
void *grealloc(void *m,int32_t size); //realokace pameti pres memman
|
||||
void *load_file(char *filename); //obycejne natahne soubor do pameti a vrati ukazatel.
|
||||
void init_manager(char *filename,char *swp); //inicializuje manager. Jmeno filename i swapname nejsou povinne (musi byt NULL kdyz nejsou pouzity)
|
||||
THANDLE_DATA *def_handle(int handle,char *filename,void *decompress,char path); //deklaruje rukojet. promenna decompress je ukazatel na funkci ktera upravi data pred vracenim ukazatele
|
||||
THANDLE_DATA *def_handle(int handle,const char *filename,void *decompress,char path); //deklaruje rukojet. promenna decompress je ukazatel na funkci ktera upravi data pred vracenim ukazatele
|
||||
void *ablock(int handle); //vraci ukazatel bloku spojeneho s handlem
|
||||
void alock(int handle); //zamyka blok
|
||||
void aunlock(int handle); //odmyka blok
|
||||
|
@ -87,7 +87,7 @@ void close_manager(void); //uzavre manager a uvolni veskerou pam
|
|||
void undef_handle(int handle); //uvolni hadle k dalsimu pouziti
|
||||
THANDLE_DATA *zneplatnit_block(int handle); //zneplatni data bloku
|
||||
THANDLE_DATA *get_handle(int handle); //vraci informace o rukojeti
|
||||
int find_handle(char *name,void *decomp); //hleda mezi rukojeti stejnou definici
|
||||
int find_handle(const char *name,void *decomp); //hleda mezi rukojeti stejnou definici
|
||||
int test_file_exist(int group,char *filename); //testuje zda soubor existuje v ramci mmanageru
|
||||
void *afile(char *filename,int group,int32_t *blocksize); //nahraje do pameti soubor registrovany v ramci mmanageru
|
||||
int32_t get_handle_size(int handle);
|
||||
|
@ -118,7 +118,7 @@ void display_status(void); //zobrazi na display status memmanageru
|
|||
char *get_time_str(void);
|
||||
int q_current_task(void);
|
||||
void send_log_impl(int task, const char *format, ...) __attribute__((format(printf, 2, 3)));
|
||||
#define OPEN_LOG(log) memcpy(stderr,fopen(log,"w"),sizeof(FILE));
|
||||
#define OPEN_LOG(log) memcpy(stderr,fopen_icase(log,"w"),sizeof(FILE));
|
||||
#define SEND_LOG(...) send_log_impl(q_current_task(), __VA_ARGS__)
|
||||
#define CLOSE_LOG(void) fclose(logfile);
|
||||
#else
|
||||
|
|
17
libs/pcx.c
17
libs/pcx.c
|
@ -5,6 +5,8 @@
|
|||
/*#include "..\types.h"*/
|
||||
#include "pcx.h"
|
||||
#include "memman.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
/*#include "..\bgraph.h"*/
|
||||
|
||||
#define SHADE_STEPS 5
|
||||
|
@ -95,7 +97,8 @@ int load_pcx(char *pcx,int32_t fsize,int conv_type,char **buffer, ... )
|
|||
{
|
||||
unsigned short paleta2[256];
|
||||
char *paleta1;
|
||||
char *ptr1;unsigned short *ptr2;
|
||||
char *ptr1;
|
||||
unsigned short *ptr2;
|
||||
char *ptr3;
|
||||
int i;
|
||||
PCXHEADER pcxdata;
|
||||
|
@ -145,10 +148,14 @@ int load_pcx(char *pcx,int32_t fsize,int conv_type,char **buffer, ... )
|
|||
}
|
||||
if (conv_type==A_FADE_PAL)
|
||||
{
|
||||
int *i,tr,tg,tb;
|
||||
int tr,tg,tb;
|
||||
|
||||
i=(int *)&buffer;i++;
|
||||
tr=*i++;tg=*i++;tb=*i++;
|
||||
va_list lst;
|
||||
va_start(lst, buffer);
|
||||
tr=va_arg(lst,int);
|
||||
tg=va_arg(lst,int);
|
||||
tb=va_arg(lst,int);
|
||||
va_end(lst);
|
||||
palette_shadow(paleta1,(unsigned short (*)[256])ptr1,tr,tg,tb);
|
||||
ptr1+=SHADE_PAL;
|
||||
}
|
||||
|
@ -178,7 +185,7 @@ int open_pcx(char *filename,int type,char **buffer,...)
|
|||
char *src;
|
||||
int32_t fsize;
|
||||
|
||||
pcx=fopen(filename,"rb");
|
||||
pcx=fopen_icase(filename,"rb");
|
||||
if (pcx==NULL) return -1;
|
||||
fseek(pcx,0,SEEK_END);
|
||||
fsize=ftell(pcx);
|
||||
|
|
|
@ -166,7 +166,7 @@ void save_font(char *filename,word bufsiz)
|
|||
{
|
||||
FILE *f;
|
||||
|
||||
f=fopen(filename,"wb");
|
||||
f=fopen_icase(filename,"wb");
|
||||
fwrite(char_table,sizeof(char_table),1,f);
|
||||
fwrite(font_buffer,bufsiz,1,f);
|
||||
fclose(f);
|
||||
|
|
|
@ -208,7 +208,7 @@ int load_string_list(TSTR_LIST *list,const char *filename)
|
|||
int i,j,lin=0;
|
||||
FILE *f;
|
||||
|
||||
f=fopen(filename,"r");
|
||||
f=fopen_icase(filename,"r");
|
||||
if (*list==NULL) *list=create_list(256);
|
||||
if (f==NULL) return -1;
|
||||
do
|
||||
|
|
|
@ -416,7 +416,7 @@ int open_backsound(char *filename)
|
|||
lastname[127]=0;
|
||||
strncpy(lastname,filename,127);
|
||||
}
|
||||
bsnd=fopen(lastname,"rb");
|
||||
bsnd=fopen_icase(lastname,"rb");
|
||||
if (bsnd==NULL)
|
||||
{
|
||||
clear_buffer=32;
|
||||
|
|
|
@ -326,7 +326,7 @@ void CColEditDlg::OnInsert()
|
|||
if (fdlg.DoModal()==IDOK)
|
||||
{
|
||||
TCHAR buff[256];
|
||||
FILE *f=_tfopen(fdlg.GetPathName(),_T("r"));
|
||||
FILE *f=_tfopen_icase(fdlg.GetPathName(),_T("r"));
|
||||
_fgetts(buff,256,f);
|
||||
bool ok=false;
|
||||
if (_tcscmp(buff,_T("JASC-PAL\n"))==0)
|
||||
|
|
|
@ -134,7 +134,7 @@ void DlgOpen::OnOK()
|
|||
name.Format(_T("IKONY%02d.LIB"),i);
|
||||
_selected=_umisteni+name;
|
||||
}
|
||||
while (_taccess( _selected,0)==0);
|
||||
while (_tcheck_file_exists( _selected)==0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -176,7 +176,7 @@ void read_palette(char *filename,void *paleta)
|
|||
FILE *f;
|
||||
int32_t l;
|
||||
|
||||
f=fopen(filename,"rb");
|
||||
f=fopen_icase(filename,"rb");
|
||||
if (f==NULL) return;
|
||||
fseek(f,0,SEEK_END);
|
||||
l=ftell(f);
|
||||
|
@ -203,7 +203,7 @@ int save_pcx(char *filename,int x1,int y1,int x2,int y2)
|
|||
head.hdpi=x2-x1+1;
|
||||
head.vdpi=y2-y1+1;
|
||||
head.mplanes=1;
|
||||
f=fopen(filename,"wb");
|
||||
f=fopen_icase(filename,"wb");
|
||||
if (f==NULL) return -1;
|
||||
fwrite(&head,1,sizeof(head),f);
|
||||
for(y=y1;y<=y2;y++)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
SET(files error.cpp legacy_coroutines.cpp platform.cpp int2ascii.c istr.c)
|
||||
SET(files error.cpp legacy_coroutines.cpp platform.cpp int2ascii.c istr.c file_access.cpp)
|
||||
|
||||
add_library(skeldal_platform_libs ${files})
|
||||
set_property(TARGET skeldal_platform_libs PROPERTY CXX_STANDARD 20)
|
||||
|
|
64
platform/file_access.cpp
Normal file
64
platform/file_access.cpp
Normal file
|
@ -0,0 +1,64 @@
|
|||
#include "platform.h"
|
||||
#include <filesystem>
|
||||
|
||||
|
||||
std::filesystem::path break_and_compose_path(const std::string_view &pathname, char sep) {
|
||||
auto p = pathname.rfind(sep);
|
||||
if (p == pathname.npos) {
|
||||
if (pathname == "." || pathname == "..") return std::filesystem::canonical(".");
|
||||
else if (pathname.empty()) return std::filesystem::current_path().root_path();
|
||||
else if (pathname == std::filesystem::current_path().root_name())
|
||||
return pathname;
|
||||
else return std::filesystem::current_path()/pathname;
|
||||
|
||||
}
|
||||
return break_and_compose_path(pathname.substr(0,p), sep) / pathname.substr(p+1);
|
||||
}
|
||||
|
||||
|
||||
std::filesystem::path convert_pathname_to_path(const std::string_view &pathname) {
|
||||
auto p = pathname.find('\\');
|
||||
if (p == pathname.npos) {
|
||||
p = pathname.find('/');
|
||||
if (p == pathname.npos) {
|
||||
return std::filesystem::current_path()/pathname;
|
||||
}
|
||||
return break_and_compose_path(pathname, '/');
|
||||
}
|
||||
return break_and_compose_path(pathname, '\\');
|
||||
}
|
||||
|
||||
std::filesystem::path try_to_find_file(const std::filesystem::path &p) {
|
||||
if (!std::filesystem::exists(p)) {
|
||||
std::filesystem::path parent;
|
||||
if (p.has_relative_path()) {
|
||||
parent = try_to_find_file(p.parent_path());
|
||||
}
|
||||
if (std::filesystem::exists(parent)) {
|
||||
auto iter = std::filesystem::directory_iterator(parent);
|
||||
auto end = std::filesystem::directory_iterator();
|
||||
std::filesystem::path n = p.filename();
|
||||
while (iter != end) {
|
||||
const std::filesystem::directory_entry &e = *iter;
|
||||
auto fn = e.path().filename();
|
||||
if (stricmp(n.c_str(), fn.c_str()) == 0) {
|
||||
return e.path();
|
||||
}
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
else return p;
|
||||
}
|
||||
|
||||
|
||||
char check_file_exists(const char *pathname) {
|
||||
std::filesystem::path path = try_to_find_file(convert_pathname_to_path(pathname));
|
||||
return std::filesystem::exists(path)?1:0;
|
||||
|
||||
}
|
||||
FILE *fopen_icase(const char *pathname, const char *mode) {
|
||||
std::filesystem::path path = try_to_find_file(convert_pathname_to_path(pathname));
|
||||
return fopen(path.c_str(), mode);
|
||||
}
|
|
@ -41,7 +41,14 @@ struct MsgQueue {
|
|||
|
||||
static std::queue<MsgQueue> msg_queue;
|
||||
|
||||
void flush_message_queue();
|
||||
static void flush_message_queue();
|
||||
|
||||
static void task_after_wakeup(TaskInfo *info) {
|
||||
info->wake_up_msg = -1;
|
||||
info->_wake_up_after = {};
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void switch_to_task(TaskInfo *task) {
|
||||
if (task == current_task_inst) return;
|
||||
|
@ -52,6 +59,7 @@ static void switch_to_task(TaskInfo *task) {
|
|||
resume_master_flag.notify_all();
|
||||
me->resume_flag.wait(false);
|
||||
me->resume_flag = false;
|
||||
task_after_wakeup(me);
|
||||
} else if (current_task_inst == NULL) {
|
||||
if (task->exited) return ;
|
||||
current_task_inst = task;
|
||||
|
@ -68,6 +76,7 @@ static void switch_to_task(TaskInfo *task) {
|
|||
task->resume_flag.notify_all();
|
||||
me->resume_flag.wait(false);
|
||||
me->resume_flag = false;
|
||||
task_after_wakeup(me);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,7 +100,7 @@ static void clean_up_current_task() {
|
|||
resume_master_flag.notify_all();
|
||||
}
|
||||
|
||||
void flush_message_queue() {
|
||||
static void flush_message_queue() {
|
||||
while (!msg_queue.empty()) {
|
||||
auto m = msg_queue.front();
|
||||
msg_queue.pop();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef _SKELDAL_PLATFORM_HEADER_
|
||||
#define _SKELDAL_PLATFORM_HEADER_
|
||||
|
@ -38,6 +39,9 @@ char get_control_key_state(void);
|
|||
char get_shift_key_state(void);
|
||||
char get_capslock_state(void);
|
||||
void display_error(const char *text);
|
||||
///returns -1 if doesn't exists
|
||||
char check_file_exists(const char *pathname);
|
||||
FILE *fopen_icase(const char *pathname, const char *mode);
|
||||
|
||||
int stricmp(const char *a, const char *b);
|
||||
#define MIN(a, b) ((a)<(b)?(a):(b))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue