This commit is contained in:
Christoph Oelckers 2016-01-22 01:11:08 +01:00
commit 1a631670fb
26 changed files with 4440 additions and 4293 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,256 +1,256 @@
/* 7zTypes.h -- Basic types /* 7zTypes.h -- Basic types
2013-11-12 : Igor Pavlov : Public domain */ 2013-11-12 : Igor Pavlov : Public domain */
#ifndef __7Z_TYPES_H #ifndef __7Z_TYPES_H
#define __7Z_TYPES_H #define __7Z_TYPES_H
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#endif #endif
#include <stddef.h> #include <stddef.h>
#ifndef EXTERN_C_BEGIN #ifndef EXTERN_C_BEGIN
#ifdef __cplusplus #ifdef __cplusplus
#define EXTERN_C_BEGIN extern "C" { #define EXTERN_C_BEGIN extern "C" {
#define EXTERN_C_END } #define EXTERN_C_END }
#else #else
#define EXTERN_C_BEGIN #define EXTERN_C_BEGIN
#define EXTERN_C_END #define EXTERN_C_END
#endif #endif
#endif #endif
EXTERN_C_BEGIN EXTERN_C_BEGIN
#define SZ_OK 0 #define SZ_OK 0
#define SZ_ERROR_DATA 1 #define SZ_ERROR_DATA 1
#define SZ_ERROR_MEM 2 #define SZ_ERROR_MEM 2
#define SZ_ERROR_CRC 3 #define SZ_ERROR_CRC 3
#define SZ_ERROR_UNSUPPORTED 4 #define SZ_ERROR_UNSUPPORTED 4
#define SZ_ERROR_PARAM 5 #define SZ_ERROR_PARAM 5
#define SZ_ERROR_INPUT_EOF 6 #define SZ_ERROR_INPUT_EOF 6
#define SZ_ERROR_OUTPUT_EOF 7 #define SZ_ERROR_OUTPUT_EOF 7
#define SZ_ERROR_READ 8 #define SZ_ERROR_READ 8
#define SZ_ERROR_WRITE 9 #define SZ_ERROR_WRITE 9
#define SZ_ERROR_PROGRESS 10 #define SZ_ERROR_PROGRESS 10
#define SZ_ERROR_FAIL 11 #define SZ_ERROR_FAIL 11
#define SZ_ERROR_THREAD 12 #define SZ_ERROR_THREAD 12
#define SZ_ERROR_ARCHIVE 16 #define SZ_ERROR_ARCHIVE 16
#define SZ_ERROR_NO_ARCHIVE 17 #define SZ_ERROR_NO_ARCHIVE 17
typedef int SRes; typedef int SRes;
#ifdef _WIN32 #ifdef _WIN32
typedef DWORD WRes; typedef DWORD WRes;
/* typedef unsigned WRes; */ /* typedef unsigned WRes; */
#else #else
typedef int WRes; typedef int WRes;
#endif #endif
#ifndef RINOK #ifndef RINOK
#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; } #define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }
#endif #endif
typedef unsigned char Byte; typedef unsigned char Byte;
typedef short Int16; typedef short Int16;
typedef unsigned short UInt16; typedef unsigned short UInt16;
#ifdef _LZMA_UINT32_IS_ULONG #ifdef _LZMA_UINT32_IS_ULONG
typedef long Int32; typedef long Int32;
typedef unsigned long UInt32; typedef unsigned long UInt32;
#else #else
typedef int Int32; typedef int Int32;
typedef unsigned int UInt32; typedef unsigned int UInt32;
#endif #endif
#ifdef _SZ_NO_INT_64 #ifdef _SZ_NO_INT_64
/* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers. /* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers.
NOTES: Some code will work incorrectly in that case! */ NOTES: Some code will work incorrectly in that case! */
typedef long Int64; typedef long Int64;
typedef unsigned long UInt64; typedef unsigned long UInt64;
#else #else
#if defined(_MSC_VER) || defined(__BORLANDC__) #if defined(_MSC_VER) || defined(__BORLANDC__)
typedef __int64 Int64; typedef __int64 Int64;
typedef unsigned __int64 UInt64; typedef unsigned __int64 UInt64;
#define UINT64_CONST(n) n #define UINT64_CONST(n) n
#else #else
typedef long long int Int64; typedef long long int Int64;
typedef unsigned long long int UInt64; typedef unsigned long long int UInt64;
#define UINT64_CONST(n) n ## ULL #define UINT64_CONST(n) n ## ULL
#endif #endif
#endif #endif
#ifdef _LZMA_NO_SYSTEM_SIZE_T #ifdef _LZMA_NO_SYSTEM_SIZE_T
typedef UInt32 SizeT; typedef UInt32 SizeT;
#else #else
typedef size_t SizeT; typedef size_t SizeT;
#endif #endif
typedef int Bool; typedef int Bool;
#define True 1 #define True 1
#define False 0 #define False 0
#ifdef _WIN32 #ifdef _WIN32
#define MY_STD_CALL __stdcall #define MY_STD_CALL __stdcall
#else #else
#define MY_STD_CALL #define MY_STD_CALL
#endif #endif
#ifdef _MSC_VER #ifdef _MSC_VER
#if _MSC_VER >= 1300 #if _MSC_VER >= 1300
#define MY_NO_INLINE __declspec(noinline) #define MY_NO_INLINE __declspec(noinline)
#else #else
#define MY_NO_INLINE #define MY_NO_INLINE
#endif #endif
#define MY_CDECL __cdecl #define MY_CDECL __cdecl
#define MY_FAST_CALL __fastcall #define MY_FAST_CALL __fastcall
#else #else
#define MY_NO_INLINE #define MY_NO_INLINE
#define MY_CDECL #define MY_CDECL
#define MY_FAST_CALL #define MY_FAST_CALL
#endif #endif
/* The following interfaces use first parameter as pointer to structure */ /* The following interfaces use first parameter as pointer to structure */
typedef struct typedef struct
{ {
Byte (*Read)(void *p); /* reads one byte, returns 0 in case of EOF or error */ Byte (*Read)(void *p); /* reads one byte, returns 0 in case of EOF or error */
} IByteIn; } IByteIn;
typedef struct typedef struct
{ {
void (*Write)(void *p, Byte b); void (*Write)(void *p, Byte b);
} IByteOut; } IByteOut;
typedef struct typedef struct
{ {
SRes (*Read)(void *p, void *buf, size_t *size); SRes (*Read)(void *p, void *buf, size_t *size);
/* if (input(*size) != 0 && output(*size) == 0) means end_of_stream. /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
(output(*size) < input(*size)) is allowed */ (output(*size) < input(*size)) is allowed */
} ISeqInStream; } ISeqInStream;
/* it can return SZ_ERROR_INPUT_EOF */ /* it can return SZ_ERROR_INPUT_EOF */
SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size); SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size);
SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType); SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType);
SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf); SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf);
typedef struct typedef struct
{ {
size_t (*Write)(void *p, const void *buf, size_t size); size_t (*Write)(void *p, const void *buf, size_t size);
/* Returns: result - the number of actually written bytes. /* Returns: result - the number of actually written bytes.
(result < size) means error */ (result < size) means error */
} ISeqOutStream; } ISeqOutStream;
typedef enum typedef enum
{ {
SZ_SEEK_SET = 0, SZ_SEEK_SET = 0,
SZ_SEEK_CUR = 1, SZ_SEEK_CUR = 1,
SZ_SEEK_END = 2 SZ_SEEK_END = 2
} ESzSeek; } ESzSeek;
typedef struct typedef struct
{ {
SRes (*Read)(void *p, void *buf, size_t *size); /* same as ISeqInStream::Read */ SRes (*Read)(void *p, void *buf, size_t *size); /* same as ISeqInStream::Read */
SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin); SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
} ISeekInStream; } ISeekInStream;
typedef struct typedef struct
{ {
SRes (*Look)(void *p, const void **buf, size_t *size); SRes (*Look)(void *p, const void **buf, size_t *size);
/* if (input(*size) != 0 && output(*size) == 0) means end_of_stream. /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
(output(*size) > input(*size)) is not allowed (output(*size) > input(*size)) is not allowed
(output(*size) < input(*size)) is allowed */ (output(*size) < input(*size)) is allowed */
SRes (*Skip)(void *p, size_t offset); SRes (*Skip)(void *p, size_t offset);
/* offset must be <= output(*size) of Look */ /* offset must be <= output(*size) of Look */
SRes (*Read)(void *p, void *buf, size_t *size); SRes (*Read)(void *p, void *buf, size_t *size);
/* reads directly (without buffer). It's same as ISeqInStream::Read */ /* reads directly (without buffer). It's same as ISeqInStream::Read */
SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin); SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
} ILookInStream; } ILookInStream;
SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size); SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size);
SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset); SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset);
/* reads via ILookInStream::Read */ /* reads via ILookInStream::Read */
SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType); SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType);
SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size); SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size);
#define LookToRead_BUF_SIZE (1 << 14) #define LookToRead_BUF_SIZE (1 << 14)
typedef struct typedef struct
{ {
ILookInStream s; ILookInStream s;
ISeekInStream *realStream; ISeekInStream *realStream;
size_t pos; size_t pos;
size_t size; size_t size;
Byte buf[LookToRead_BUF_SIZE]; Byte buf[LookToRead_BUF_SIZE];
} CLookToRead; } CLookToRead;
void LookToRead_CreateVTable(CLookToRead *p, int lookahead); void LookToRead_CreateVTable(CLookToRead *p, int lookahead);
void LookToRead_Init(CLookToRead *p); void LookToRead_Init(CLookToRead *p);
typedef struct typedef struct
{ {
ISeqInStream s; ISeqInStream s;
ILookInStream *realStream; ILookInStream *realStream;
} CSecToLook; } CSecToLook;
void SecToLook_CreateVTable(CSecToLook *p); void SecToLook_CreateVTable(CSecToLook *p);
typedef struct typedef struct
{ {
ISeqInStream s; ISeqInStream s;
ILookInStream *realStream; ILookInStream *realStream;
} CSecToRead; } CSecToRead;
void SecToRead_CreateVTable(CSecToRead *p); void SecToRead_CreateVTable(CSecToRead *p);
typedef struct typedef struct
{ {
SRes (*Progress)(void *p, UInt64 inSize, UInt64 outSize); SRes (*Progress)(void *p, UInt64 inSize, UInt64 outSize);
/* Returns: result. (result != SZ_OK) means break. /* Returns: result. (result != SZ_OK) means break.
Value (UInt64)(Int64)-1 for size means unknown value. */ Value (UInt64)(Int64)-1 for size means unknown value. */
} ICompressProgress; } ICompressProgress;
typedef struct typedef struct
{ {
void *(*Alloc)(void *p, size_t size); void *(*Alloc)(void *p, size_t size);
void (*Free)(void *p, void *address); /* address can be 0 */ void (*Free)(void *p, void *address); /* address can be 0 */
} ISzAlloc; } ISzAlloc;
#define IAlloc_Alloc(p, size) (p)->Alloc((p), size) #define IAlloc_Alloc(p, size) (p)->Alloc((p), size)
#define IAlloc_Free(p, a) (p)->Free((p), a) #define IAlloc_Free(p, a) (p)->Free((p), a)
#ifdef _WIN32 #ifdef _WIN32
#define CHAR_PATH_SEPARATOR '\\' #define CHAR_PATH_SEPARATOR '\\'
#define WCHAR_PATH_SEPARATOR L'\\' #define WCHAR_PATH_SEPARATOR L'\\'
#define STRING_PATH_SEPARATOR "\\" #define STRING_PATH_SEPARATOR "\\"
#define WSTRING_PATH_SEPARATOR L"\\" #define WSTRING_PATH_SEPARATOR L"\\"
#else #else
#define CHAR_PATH_SEPARATOR '/' #define CHAR_PATH_SEPARATOR '/'
#define WCHAR_PATH_SEPARATOR L'/' #define WCHAR_PATH_SEPARATOR L'/'
#define STRING_PATH_SEPARATOR "/" #define STRING_PATH_SEPARATOR "/"
#define WSTRING_PATH_SEPARATOR L"/" #define WSTRING_PATH_SEPARATOR L"/"
#endif #endif
EXTERN_C_END EXTERN_C_END
#endif #endif

View file

@ -1,69 +1,69 @@
/* BraIA64.c -- Converter for IA-64 code /* BraIA64.c -- Converter for IA-64 code
2013-11-12 : Igor Pavlov : Public domain */ 2013-11-12 : Igor Pavlov : Public domain */
#include "Precomp.h" #include "Precomp.h"
#include "Bra.h" #include "Bra.h"
static const Byte kBranchTable[32] = static const Byte kBranchTable[32] =
{ {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4, 4, 6, 6, 0, 0, 7, 7, 4, 4, 6, 6, 0, 0, 7, 7,
4, 4, 0, 0, 4, 4, 0, 0 4, 4, 0, 0, 4, 4, 0, 0
}; };
SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
{ {
SizeT i; SizeT i;
if (size < 16) if (size < 16)
return 0; return 0;
size -= 16; size -= 16;
for (i = 0; i <= size; i += 16) for (i = 0; i <= size; i += 16)
{ {
UInt32 instrTemplate = data[i] & 0x1F; UInt32 instrTemplate = data[i] & 0x1F;
UInt32 mask = kBranchTable[instrTemplate]; UInt32 mask = kBranchTable[instrTemplate];
UInt32 bitPos = 5; UInt32 bitPos = 5;
int slot; int slot;
for (slot = 0; slot < 3; slot++, bitPos += 41) for (slot = 0; slot < 3; slot++, bitPos += 41)
{ {
UInt32 bytePos, bitRes; UInt32 bytePos, bitRes;
UInt64 instruction, instNorm; UInt64 instruction, instNorm;
int j; int j;
if (((mask >> slot) & 1) == 0) if (((mask >> slot) & 1) == 0)
continue; continue;
bytePos = (bitPos >> 3); bytePos = (bitPos >> 3);
bitRes = bitPos & 0x7; bitRes = bitPos & 0x7;
instruction = 0; instruction = 0;
for (j = 0; j < 6; j++) for (j = 0; j < 6; j++)
instruction += (UInt64)data[i + j + bytePos] << (8 * j); instruction += (UInt64)data[i + j + bytePos] << (8 * j);
instNorm = instruction >> bitRes; instNorm = instruction >> bitRes;
if (((instNorm >> 37) & 0xF) == 0x5 && ((instNorm >> 9) & 0x7) == 0) if (((instNorm >> 37) & 0xF) == 0x5 && ((instNorm >> 9) & 0x7) == 0)
{ {
UInt32 src = (UInt32)((instNorm >> 13) & 0xFFFFF); UInt32 src = (UInt32)((instNorm >> 13) & 0xFFFFF);
UInt32 dest; UInt32 dest;
src |= ((UInt32)(instNorm >> 36) & 1) << 20; src |= ((UInt32)(instNorm >> 36) & 1) << 20;
src <<= 4; src <<= 4;
if (encoding) if (encoding)
dest = ip + (UInt32)i + src; dest = ip + (UInt32)i + src;
else else
dest = src - (ip + (UInt32)i); dest = src - (ip + (UInt32)i);
dest >>= 4; dest >>= 4;
instNorm &= ~((UInt64)(0x8FFFFF) << 13); instNorm &= ~((UInt64)(0x8FFFFF) << 13);
instNorm |= ((UInt64)(dest & 0xFFFFF) << 13); instNorm |= ((UInt64)(dest & 0xFFFFF) << 13);
instNorm |= ((UInt64)(dest & 0x100000) << (36 - 20)); instNorm |= ((UInt64)(dest & 0x100000) << (36 - 20));
instruction &= (1 << bitRes) - 1; instruction &= (1 << bitRes) - 1;
instruction |= (instNorm << bitRes); instruction |= (instNorm << bitRes);
for (j = 0; j < 6; j++) for (j = 0; j < 6; j++)
data[i + j + bytePos] = (Byte)(instruction >> (8 * j)); data[i + j + bytePos] = (Byte)(instruction >> (8 * j));
} }
} }
} }
return i; return i;
} }

View file

@ -1,32 +1,32 @@
/* Compiler.h /* Compiler.h
2015-08-02 : Igor Pavlov : Public domain */ 2015-08-02 : Igor Pavlov : Public domain */
#ifndef __7Z_COMPILER_H #ifndef __7Z_COMPILER_H
#define __7Z_COMPILER_H #define __7Z_COMPILER_H
#ifdef _MSC_VER #ifdef _MSC_VER
#ifdef UNDER_CE #ifdef UNDER_CE
#define RPC_NO_WINDOWS_H #define RPC_NO_WINDOWS_H
/* #pragma warning(disable : 4115) // '_RPC_ASYNC_STATE' : named type definition in parentheses */ /* #pragma warning(disable : 4115) // '_RPC_ASYNC_STATE' : named type definition in parentheses */
#pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union #pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union
#pragma warning(disable : 4214) // nonstandard extension used : bit field types other than int #pragma warning(disable : 4214) // nonstandard extension used : bit field types other than int
#endif #endif
#if _MSC_VER >= 1300 #if _MSC_VER >= 1300
#pragma warning(disable : 4996) // This function or variable may be unsafe #pragma warning(disable : 4996) // This function or variable may be unsafe
#else #else
#pragma warning(disable : 4511) // copy constructor could not be generated #pragma warning(disable : 4511) // copy constructor could not be generated
#pragma warning(disable : 4512) // assignment operator could not be generated #pragma warning(disable : 4512) // assignment operator could not be generated
#pragma warning(disable : 4514) // unreferenced inline function has been removed #pragma warning(disable : 4514) // unreferenced inline function has been removed
#pragma warning(disable : 4702) // unreachable code #pragma warning(disable : 4702) // unreachable code
#pragma warning(disable : 4710) // not inlined #pragma warning(disable : 4710) // not inlined
#pragma warning(disable : 4786) // identifier was truncated to '255' characters in the debug information #pragma warning(disable : 4786) // identifier was truncated to '255' characters in the debug information
#endif #endif
#endif #endif
#define UNUSED_VAR(x) (void)x; #define UNUSED_VAR(x) (void)x;
/* #define UNUSED_VAR(x) x=x; */ /* #define UNUSED_VAR(x) x=x; */
#endif #endif

View file

@ -1,64 +1,64 @@
/* Delta.c -- Delta converter /* Delta.c -- Delta converter
2009-05-26 : Igor Pavlov : Public domain */ 2009-05-26 : Igor Pavlov : Public domain */
#include "Precomp.h" #include "Precomp.h"
#include "Delta.h" #include "Delta.h"
void Delta_Init(Byte *state) void Delta_Init(Byte *state)
{ {
unsigned i; unsigned i;
for (i = 0; i < DELTA_STATE_SIZE; i++) for (i = 0; i < DELTA_STATE_SIZE; i++)
state[i] = 0; state[i] = 0;
} }
static void MyMemCpy(Byte *dest, const Byte *src, unsigned size) static void MyMemCpy(Byte *dest, const Byte *src, unsigned size)
{ {
unsigned i; unsigned i;
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
dest[i] = src[i]; dest[i] = src[i];
} }
void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size) void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size)
{ {
Byte buf[DELTA_STATE_SIZE]; Byte buf[DELTA_STATE_SIZE];
unsigned j = 0; unsigned j = 0;
MyMemCpy(buf, state, delta); MyMemCpy(buf, state, delta);
{ {
SizeT i; SizeT i;
for (i = 0; i < size;) for (i = 0; i < size;)
{ {
for (j = 0; j < delta && i < size; i++, j++) for (j = 0; j < delta && i < size; i++, j++)
{ {
Byte b = data[i]; Byte b = data[i];
data[i] = (Byte)(b - buf[j]); data[i] = (Byte)(b - buf[j]);
buf[j] = b; buf[j] = b;
} }
} }
} }
if (j == delta) if (j == delta)
j = 0; j = 0;
MyMemCpy(state, buf + j, delta - j); MyMemCpy(state, buf + j, delta - j);
MyMemCpy(state + delta - j, buf, j); MyMemCpy(state + delta - j, buf, j);
} }
void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size) void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size)
{ {
Byte buf[DELTA_STATE_SIZE]; Byte buf[DELTA_STATE_SIZE];
unsigned j = 0; unsigned j = 0;
MyMemCpy(buf, state, delta); MyMemCpy(buf, state, delta);
{ {
SizeT i; SizeT i;
for (i = 0; i < size;) for (i = 0; i < size;)
{ {
for (j = 0; j < delta && i < size; i++, j++) for (j = 0; j < delta && i < size; i++, j++)
{ {
buf[j] = data[i] = (Byte)(buf[j] + data[i]); buf[j] = data[i] = (Byte)(buf[j] + data[i]);
} }
} }
} }
if (j == delta) if (j == delta)
j = 0; j = 0;
MyMemCpy(state, buf + j, delta - j); MyMemCpy(state, buf + j, delta - j);
MyMemCpy(state + delta - j, buf, j); MyMemCpy(state + delta - j, buf, j);
} }

View file

@ -1,19 +1,19 @@
/* Delta.h -- Delta converter /* Delta.h -- Delta converter
2013-01-18 : Igor Pavlov : Public domain */ 2013-01-18 : Igor Pavlov : Public domain */
#ifndef __DELTA_H #ifndef __DELTA_H
#define __DELTA_H #define __DELTA_H
#include "7zTypes.h" #include "7zTypes.h"
EXTERN_C_BEGIN EXTERN_C_BEGIN
#define DELTA_STATE_SIZE 256 #define DELTA_STATE_SIZE 256
void Delta_Init(Byte *state); void Delta_Init(Byte *state);
void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size); void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size);
void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size); void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size);
EXTERN_C_END EXTERN_C_END
#endif #endif

View file

@ -1,85 +1,85 @@
/* Ppmd.h -- PPMD codec common code /* Ppmd.h -- PPMD codec common code
2013-01-18 : Igor Pavlov : Public domain 2013-01-18 : Igor Pavlov : Public domain
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */ This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
#ifndef __PPMD_H #ifndef __PPMD_H
#define __PPMD_H #define __PPMD_H
#include "CpuArch.h" #include "CpuArch.h"
EXTERN_C_BEGIN EXTERN_C_BEGIN
#ifdef MY_CPU_32BIT #ifdef MY_CPU_32BIT
#define PPMD_32BIT #define PPMD_32BIT
#endif #endif
#define PPMD_INT_BITS 7 #define PPMD_INT_BITS 7
#define PPMD_PERIOD_BITS 7 #define PPMD_PERIOD_BITS 7
#define PPMD_BIN_SCALE (1 << (PPMD_INT_BITS + PPMD_PERIOD_BITS)) #define PPMD_BIN_SCALE (1 << (PPMD_INT_BITS + PPMD_PERIOD_BITS))
#define PPMD_GET_MEAN_SPEC(summ, shift, round) (((summ) + (1 << ((shift) - (round)))) >> (shift)) #define PPMD_GET_MEAN_SPEC(summ, shift, round) (((summ) + (1 << ((shift) - (round)))) >> (shift))
#define PPMD_GET_MEAN(summ) PPMD_GET_MEAN_SPEC((summ), PPMD_PERIOD_BITS, 2) #define PPMD_GET_MEAN(summ) PPMD_GET_MEAN_SPEC((summ), PPMD_PERIOD_BITS, 2)
#define PPMD_UPDATE_PROB_0(prob) ((prob) + (1 << PPMD_INT_BITS) - PPMD_GET_MEAN(prob)) #define PPMD_UPDATE_PROB_0(prob) ((prob) + (1 << PPMD_INT_BITS) - PPMD_GET_MEAN(prob))
#define PPMD_UPDATE_PROB_1(prob) ((prob) - PPMD_GET_MEAN(prob)) #define PPMD_UPDATE_PROB_1(prob) ((prob) - PPMD_GET_MEAN(prob))
#define PPMD_N1 4 #define PPMD_N1 4
#define PPMD_N2 4 #define PPMD_N2 4
#define PPMD_N3 4 #define PPMD_N3 4
#define PPMD_N4 ((128 + 3 - 1 * PPMD_N1 - 2 * PPMD_N2 - 3 * PPMD_N3) / 4) #define PPMD_N4 ((128 + 3 - 1 * PPMD_N1 - 2 * PPMD_N2 - 3 * PPMD_N3) / 4)
#define PPMD_NUM_INDEXES (PPMD_N1 + PPMD_N2 + PPMD_N3 + PPMD_N4) #define PPMD_NUM_INDEXES (PPMD_N1 + PPMD_N2 + PPMD_N3 + PPMD_N4)
#pragma pack(push, 1) #pragma pack(push, 1)
/* Most compilers works OK here even without #pragma pack(push, 1), but some GCC compilers need it. */ /* Most compilers works OK here even without #pragma pack(push, 1), but some GCC compilers need it. */
/* SEE-contexts for PPM-contexts with masked symbols */ /* SEE-contexts for PPM-contexts with masked symbols */
typedef struct typedef struct
{ {
UInt16 Summ; /* Freq */ UInt16 Summ; /* Freq */
Byte Shift; /* Speed of Freq change; low Shift is for fast change */ Byte Shift; /* Speed of Freq change; low Shift is for fast change */
Byte Count; /* Count to next change of Shift */ Byte Count; /* Count to next change of Shift */
} CPpmd_See; } CPpmd_See;
#define Ppmd_See_Update(p) if ((p)->Shift < PPMD_PERIOD_BITS && --(p)->Count == 0) \ #define Ppmd_See_Update(p) if ((p)->Shift < PPMD_PERIOD_BITS && --(p)->Count == 0) \
{ (p)->Summ <<= 1; (p)->Count = (Byte)(3 << (p)->Shift++); } { (p)->Summ <<= 1; (p)->Count = (Byte)(3 << (p)->Shift++); }
typedef struct typedef struct
{ {
Byte Symbol; Byte Symbol;
Byte Freq; Byte Freq;
UInt16 SuccessorLow; UInt16 SuccessorLow;
UInt16 SuccessorHigh; UInt16 SuccessorHigh;
} CPpmd_State; } CPpmd_State;
#pragma pack(pop) #pragma pack(pop)
typedef typedef
#ifdef PPMD_32BIT #ifdef PPMD_32BIT
CPpmd_State * CPpmd_State *
#else #else
UInt32 UInt32
#endif #endif
CPpmd_State_Ref; CPpmd_State_Ref;
typedef typedef
#ifdef PPMD_32BIT #ifdef PPMD_32BIT
void * void *
#else #else
UInt32 UInt32
#endif #endif
CPpmd_Void_Ref; CPpmd_Void_Ref;
typedef typedef
#ifdef PPMD_32BIT #ifdef PPMD_32BIT
Byte * Byte *
#else #else
UInt32 UInt32
#endif #endif
CPpmd_Byte_Ref; CPpmd_Byte_Ref;
#define PPMD_SetAllBitsIn256Bytes(p) \ #define PPMD_SetAllBitsIn256Bytes(p) \
{ unsigned i; for (i = 0; i < 256 / sizeof(p[0]); i += 8) { \ { unsigned i; for (i = 0; i < 256 / sizeof(p[0]); i += 8) { \
p[i+7] = p[i+6] = p[i+5] = p[i+4] = p[i+3] = p[i+2] = p[i+1] = p[i+0] = ~(size_t)0; }} p[i+7] = p[i+6] = p[i+5] = p[i+4] = p[i+3] = p[i+2] = p[i+1] = p[i+0] = ~(size_t)0; }}
EXTERN_C_END EXTERN_C_END
#endif #endif

File diff suppressed because it is too large Load diff

View file

@ -1,140 +1,140 @@
/* Ppmd7.h -- PPMdH compression codec /* Ppmd7.h -- PPMdH compression codec
2010-03-12 : Igor Pavlov : Public domain 2010-03-12 : Igor Pavlov : Public domain
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */ This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
/* This code supports virtual RangeDecoder and includes the implementation /* This code supports virtual RangeDecoder and includes the implementation
of RangeCoder from 7z, instead of RangeCoder from original PPMd var.H. of RangeCoder from 7z, instead of RangeCoder from original PPMd var.H.
If you need the compatibility with original PPMd var.H, you can use external RangeDecoder */ If you need the compatibility with original PPMd var.H, you can use external RangeDecoder */
#ifndef __PPMD7_H #ifndef __PPMD7_H
#define __PPMD7_H #define __PPMD7_H
#include "Ppmd.h" #include "Ppmd.h"
EXTERN_C_BEGIN EXTERN_C_BEGIN
#define PPMD7_MIN_ORDER 2 #define PPMD7_MIN_ORDER 2
#define PPMD7_MAX_ORDER 64 #define PPMD7_MAX_ORDER 64
#define PPMD7_MIN_MEM_SIZE (1 << 11) #define PPMD7_MIN_MEM_SIZE (1 << 11)
#define PPMD7_MAX_MEM_SIZE (0xFFFFFFFF - 12 * 3) #define PPMD7_MAX_MEM_SIZE (0xFFFFFFFF - 12 * 3)
struct CPpmd7_Context_; struct CPpmd7_Context_;
typedef typedef
#ifdef PPMD_32BIT #ifdef PPMD_32BIT
struct CPpmd7_Context_ * struct CPpmd7_Context_ *
#else #else
UInt32 UInt32
#endif #endif
CPpmd7_Context_Ref; CPpmd7_Context_Ref;
typedef struct CPpmd7_Context_ typedef struct CPpmd7_Context_
{ {
UInt16 NumStats; UInt16 NumStats;
UInt16 SummFreq; UInt16 SummFreq;
CPpmd_State_Ref Stats; CPpmd_State_Ref Stats;
CPpmd7_Context_Ref Suffix; CPpmd7_Context_Ref Suffix;
} CPpmd7_Context; } CPpmd7_Context;
#define Ppmd7Context_OneState(p) ((CPpmd_State *)&(p)->SummFreq) #define Ppmd7Context_OneState(p) ((CPpmd_State *)&(p)->SummFreq)
typedef struct typedef struct
{ {
CPpmd7_Context *MinContext, *MaxContext; CPpmd7_Context *MinContext, *MaxContext;
CPpmd_State *FoundState; CPpmd_State *FoundState;
unsigned OrderFall, InitEsc, PrevSuccess, MaxOrder, HiBitsFlag; unsigned OrderFall, InitEsc, PrevSuccess, MaxOrder, HiBitsFlag;
Int32 RunLength, InitRL; /* must be 32-bit at least */ Int32 RunLength, InitRL; /* must be 32-bit at least */
UInt32 Size; UInt32 Size;
UInt32 GlueCount; UInt32 GlueCount;
Byte *Base, *LoUnit, *HiUnit, *Text, *UnitsStart; Byte *Base, *LoUnit, *HiUnit, *Text, *UnitsStart;
UInt32 AlignOffset; UInt32 AlignOffset;
Byte Indx2Units[PPMD_NUM_INDEXES]; Byte Indx2Units[PPMD_NUM_INDEXES];
Byte Units2Indx[128]; Byte Units2Indx[128];
CPpmd_Void_Ref FreeList[PPMD_NUM_INDEXES]; CPpmd_Void_Ref FreeList[PPMD_NUM_INDEXES];
Byte NS2Indx[256], NS2BSIndx[256], HB2Flag[256]; Byte NS2Indx[256], NS2BSIndx[256], HB2Flag[256];
CPpmd_See DummySee, See[25][16]; CPpmd_See DummySee, See[25][16];
UInt16 BinSumm[128][64]; UInt16 BinSumm[128][64];
} CPpmd7; } CPpmd7;
void Ppmd7_Construct(CPpmd7 *p); void Ppmd7_Construct(CPpmd7 *p);
Bool Ppmd7_Alloc(CPpmd7 *p, UInt32 size, ISzAlloc *alloc); Bool Ppmd7_Alloc(CPpmd7 *p, UInt32 size, ISzAlloc *alloc);
void Ppmd7_Free(CPpmd7 *p, ISzAlloc *alloc); void Ppmd7_Free(CPpmd7 *p, ISzAlloc *alloc);
void Ppmd7_Init(CPpmd7 *p, unsigned maxOrder); void Ppmd7_Init(CPpmd7 *p, unsigned maxOrder);
#define Ppmd7_WasAllocated(p) ((p)->Base != NULL) #define Ppmd7_WasAllocated(p) ((p)->Base != NULL)
/* ---------- Internal Functions ---------- */ /* ---------- Internal Functions ---------- */
extern const Byte PPMD7_kExpEscape[16]; extern const Byte PPMD7_kExpEscape[16];
#ifdef PPMD_32BIT #ifdef PPMD_32BIT
#define Ppmd7_GetPtr(p, ptr) (ptr) #define Ppmd7_GetPtr(p, ptr) (ptr)
#define Ppmd7_GetContext(p, ptr) (ptr) #define Ppmd7_GetContext(p, ptr) (ptr)
#define Ppmd7_GetStats(p, ctx) ((ctx)->Stats) #define Ppmd7_GetStats(p, ctx) ((ctx)->Stats)
#else #else
#define Ppmd7_GetPtr(p, offs) ((void *)((p)->Base + (offs))) #define Ppmd7_GetPtr(p, offs) ((void *)((p)->Base + (offs)))
#define Ppmd7_GetContext(p, offs) ((CPpmd7_Context *)Ppmd7_GetPtr((p), (offs))) #define Ppmd7_GetContext(p, offs) ((CPpmd7_Context *)Ppmd7_GetPtr((p), (offs)))
#define Ppmd7_GetStats(p, ctx) ((CPpmd_State *)Ppmd7_GetPtr((p), ((ctx)->Stats))) #define Ppmd7_GetStats(p, ctx) ((CPpmd_State *)Ppmd7_GetPtr((p), ((ctx)->Stats)))
#endif #endif
void Ppmd7_Update1(CPpmd7 *p); void Ppmd7_Update1(CPpmd7 *p);
void Ppmd7_Update1_0(CPpmd7 *p); void Ppmd7_Update1_0(CPpmd7 *p);
void Ppmd7_Update2(CPpmd7 *p); void Ppmd7_Update2(CPpmd7 *p);
void Ppmd7_UpdateBin(CPpmd7 *p); void Ppmd7_UpdateBin(CPpmd7 *p);
#define Ppmd7_GetBinSumm(p) \ #define Ppmd7_GetBinSumm(p) \
&p->BinSumm[Ppmd7Context_OneState(p->MinContext)->Freq - 1][p->PrevSuccess + \ &p->BinSumm[Ppmd7Context_OneState(p->MinContext)->Freq - 1][p->PrevSuccess + \
p->NS2BSIndx[Ppmd7_GetContext(p, p->MinContext->Suffix)->NumStats - 1] + \ p->NS2BSIndx[Ppmd7_GetContext(p, p->MinContext->Suffix)->NumStats - 1] + \
(p->HiBitsFlag = p->HB2Flag[p->FoundState->Symbol]) + \ (p->HiBitsFlag = p->HB2Flag[p->FoundState->Symbol]) + \
2 * p->HB2Flag[Ppmd7Context_OneState(p->MinContext)->Symbol] + \ 2 * p->HB2Flag[Ppmd7Context_OneState(p->MinContext)->Symbol] + \
((p->RunLength >> 26) & 0x20)] ((p->RunLength >> 26) & 0x20)]
CPpmd_See *Ppmd7_MakeEscFreq(CPpmd7 *p, unsigned numMasked, UInt32 *scale); CPpmd_See *Ppmd7_MakeEscFreq(CPpmd7 *p, unsigned numMasked, UInt32 *scale);
/* ---------- Decode ---------- */ /* ---------- Decode ---------- */
typedef struct typedef struct
{ {
UInt32 (*GetThreshold)(void *p, UInt32 total); UInt32 (*GetThreshold)(void *p, UInt32 total);
void (*Decode)(void *p, UInt32 start, UInt32 size); void (*Decode)(void *p, UInt32 start, UInt32 size);
UInt32 (*DecodeBit)(void *p, UInt32 size0); UInt32 (*DecodeBit)(void *p, UInt32 size0);
} IPpmd7_RangeDec; } IPpmd7_RangeDec;
typedef struct typedef struct
{ {
IPpmd7_RangeDec p; IPpmd7_RangeDec p;
UInt32 Range; UInt32 Range;
UInt32 Code; UInt32 Code;
IByteIn *Stream; IByteIn *Stream;
} CPpmd7z_RangeDec; } CPpmd7z_RangeDec;
void Ppmd7z_RangeDec_CreateVTable(CPpmd7z_RangeDec *p); void Ppmd7z_RangeDec_CreateVTable(CPpmd7z_RangeDec *p);
Bool Ppmd7z_RangeDec_Init(CPpmd7z_RangeDec *p); Bool Ppmd7z_RangeDec_Init(CPpmd7z_RangeDec *p);
#define Ppmd7z_RangeDec_IsFinishedOK(p) ((p)->Code == 0) #define Ppmd7z_RangeDec_IsFinishedOK(p) ((p)->Code == 0)
int Ppmd7_DecodeSymbol(CPpmd7 *p, IPpmd7_RangeDec *rc); int Ppmd7_DecodeSymbol(CPpmd7 *p, IPpmd7_RangeDec *rc);
/* ---------- Encode ---------- */ /* ---------- Encode ---------- */
typedef struct typedef struct
{ {
UInt64 Low; UInt64 Low;
UInt32 Range; UInt32 Range;
Byte Cache; Byte Cache;
UInt64 CacheSize; UInt64 CacheSize;
IByteOut *Stream; IByteOut *Stream;
} CPpmd7z_RangeEnc; } CPpmd7z_RangeEnc;
void Ppmd7z_RangeEnc_Init(CPpmd7z_RangeEnc *p); void Ppmd7z_RangeEnc_Init(CPpmd7z_RangeEnc *p);
void Ppmd7z_RangeEnc_FlushData(CPpmd7z_RangeEnc *p); void Ppmd7z_RangeEnc_FlushData(CPpmd7z_RangeEnc *p);
void Ppmd7_EncodeSymbol(CPpmd7 *p, CPpmd7z_RangeEnc *rc, int symbol); void Ppmd7_EncodeSymbol(CPpmd7 *p, CPpmd7z_RangeEnc *rc, int symbol);
EXTERN_C_END EXTERN_C_END
#endif #endif

View file

@ -1,189 +1,189 @@
/* Ppmd7Dec.c -- PPMdH Decoder /* Ppmd7Dec.c -- PPMdH Decoder
2010-03-12 : Igor Pavlov : Public domain 2010-03-12 : Igor Pavlov : Public domain
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */ This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
#include "Precomp.h" #include "Precomp.h"
#include "Ppmd7.h" #include "Ppmd7.h"
#define kTopValue (1 << 24) #define kTopValue (1 << 24)
Bool Ppmd7z_RangeDec_Init(CPpmd7z_RangeDec *p) Bool Ppmd7z_RangeDec_Init(CPpmd7z_RangeDec *p)
{ {
unsigned i; unsigned i;
p->Code = 0; p->Code = 0;
p->Range = 0xFFFFFFFF; p->Range = 0xFFFFFFFF;
if (p->Stream->Read((void *)p->Stream) != 0) if (p->Stream->Read((void *)p->Stream) != 0)
return False; return False;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
p->Code = (p->Code << 8) | p->Stream->Read((void *)p->Stream); p->Code = (p->Code << 8) | p->Stream->Read((void *)p->Stream);
return (p->Code < 0xFFFFFFFF); return (p->Code < 0xFFFFFFFF);
} }
static UInt32 Range_GetThreshold(void *pp, UInt32 total) static UInt32 Range_GetThreshold(void *pp, UInt32 total)
{ {
CPpmd7z_RangeDec *p = (CPpmd7z_RangeDec *)pp; CPpmd7z_RangeDec *p = (CPpmd7z_RangeDec *)pp;
return (p->Code) / (p->Range /= total); return (p->Code) / (p->Range /= total);
} }
static void Range_Normalize(CPpmd7z_RangeDec *p) static void Range_Normalize(CPpmd7z_RangeDec *p)
{ {
if (p->Range < kTopValue) if (p->Range < kTopValue)
{ {
p->Code = (p->Code << 8) | p->Stream->Read((void *)p->Stream); p->Code = (p->Code << 8) | p->Stream->Read((void *)p->Stream);
p->Range <<= 8; p->Range <<= 8;
if (p->Range < kTopValue) if (p->Range < kTopValue)
{ {
p->Code = (p->Code << 8) | p->Stream->Read((void *)p->Stream); p->Code = (p->Code << 8) | p->Stream->Read((void *)p->Stream);
p->Range <<= 8; p->Range <<= 8;
} }
} }
} }
static void Range_Decode(void *pp, UInt32 start, UInt32 size) static void Range_Decode(void *pp, UInt32 start, UInt32 size)
{ {
CPpmd7z_RangeDec *p = (CPpmd7z_RangeDec *)pp; CPpmd7z_RangeDec *p = (CPpmd7z_RangeDec *)pp;
p->Code -= start * p->Range; p->Code -= start * p->Range;
p->Range *= size; p->Range *= size;
Range_Normalize(p); Range_Normalize(p);
} }
static UInt32 Range_DecodeBit(void *pp, UInt32 size0) static UInt32 Range_DecodeBit(void *pp, UInt32 size0)
{ {
CPpmd7z_RangeDec *p = (CPpmd7z_RangeDec *)pp; CPpmd7z_RangeDec *p = (CPpmd7z_RangeDec *)pp;
UInt32 newBound = (p->Range >> 14) * size0; UInt32 newBound = (p->Range >> 14) * size0;
UInt32 symbol; UInt32 symbol;
if (p->Code < newBound) if (p->Code < newBound)
{ {
symbol = 0; symbol = 0;
p->Range = newBound; p->Range = newBound;
} }
else else
{ {
symbol = 1; symbol = 1;
p->Code -= newBound; p->Code -= newBound;
p->Range -= newBound; p->Range -= newBound;
} }
Range_Normalize(p); Range_Normalize(p);
return symbol; return symbol;
} }
void Ppmd7z_RangeDec_CreateVTable(CPpmd7z_RangeDec *p) void Ppmd7z_RangeDec_CreateVTable(CPpmd7z_RangeDec *p)
{ {
p->p.GetThreshold = Range_GetThreshold; p->p.GetThreshold = Range_GetThreshold;
p->p.Decode = Range_Decode; p->p.Decode = Range_Decode;
p->p.DecodeBit = Range_DecodeBit; p->p.DecodeBit = Range_DecodeBit;
} }
#define MASK(sym) ((signed char *)charMask)[sym] #define MASK(sym) ((signed char *)charMask)[sym]
int Ppmd7_DecodeSymbol(CPpmd7 *p, IPpmd7_RangeDec *rc) int Ppmd7_DecodeSymbol(CPpmd7 *p, IPpmd7_RangeDec *rc)
{ {
size_t charMask[256 / sizeof(size_t)]; size_t charMask[256 / sizeof(size_t)];
if (p->MinContext->NumStats != 1) if (p->MinContext->NumStats != 1)
{ {
CPpmd_State *s = Ppmd7_GetStats(p, p->MinContext); CPpmd_State *s = Ppmd7_GetStats(p, p->MinContext);
unsigned i; unsigned i;
UInt32 count, hiCnt; UInt32 count, hiCnt;
if ((count = rc->GetThreshold(rc, p->MinContext->SummFreq)) < (hiCnt = s->Freq)) if ((count = rc->GetThreshold(rc, p->MinContext->SummFreq)) < (hiCnt = s->Freq))
{ {
Byte symbol; Byte symbol;
rc->Decode(rc, 0, s->Freq); rc->Decode(rc, 0, s->Freq);
p->FoundState = s; p->FoundState = s;
symbol = s->Symbol; symbol = s->Symbol;
Ppmd7_Update1_0(p); Ppmd7_Update1_0(p);
return symbol; return symbol;
} }
p->PrevSuccess = 0; p->PrevSuccess = 0;
i = p->MinContext->NumStats - 1; i = p->MinContext->NumStats - 1;
do do
{ {
if ((hiCnt += (++s)->Freq) > count) if ((hiCnt += (++s)->Freq) > count)
{ {
Byte symbol; Byte symbol;
rc->Decode(rc, hiCnt - s->Freq, s->Freq); rc->Decode(rc, hiCnt - s->Freq, s->Freq);
p->FoundState = s; p->FoundState = s;
symbol = s->Symbol; symbol = s->Symbol;
Ppmd7_Update1(p); Ppmd7_Update1(p);
return symbol; return symbol;
} }
} }
while (--i); while (--i);
if (count >= p->MinContext->SummFreq) if (count >= p->MinContext->SummFreq)
return -2; return -2;
p->HiBitsFlag = p->HB2Flag[p->FoundState->Symbol]; p->HiBitsFlag = p->HB2Flag[p->FoundState->Symbol];
rc->Decode(rc, hiCnt, p->MinContext->SummFreq - hiCnt); rc->Decode(rc, hiCnt, p->MinContext->SummFreq - hiCnt);
PPMD_SetAllBitsIn256Bytes(charMask); PPMD_SetAllBitsIn256Bytes(charMask);
MASK(s->Symbol) = 0; MASK(s->Symbol) = 0;
i = p->MinContext->NumStats - 1; i = p->MinContext->NumStats - 1;
do { MASK((--s)->Symbol) = 0; } while (--i); do { MASK((--s)->Symbol) = 0; } while (--i);
} }
else else
{ {
UInt16 *prob = Ppmd7_GetBinSumm(p); UInt16 *prob = Ppmd7_GetBinSumm(p);
if (rc->DecodeBit(rc, *prob) == 0) if (rc->DecodeBit(rc, *prob) == 0)
{ {
Byte symbol; Byte symbol;
*prob = (UInt16)PPMD_UPDATE_PROB_0(*prob); *prob = (UInt16)PPMD_UPDATE_PROB_0(*prob);
symbol = (p->FoundState = Ppmd7Context_OneState(p->MinContext))->Symbol; symbol = (p->FoundState = Ppmd7Context_OneState(p->MinContext))->Symbol;
Ppmd7_UpdateBin(p); Ppmd7_UpdateBin(p);
return symbol; return symbol;
} }
*prob = (UInt16)PPMD_UPDATE_PROB_1(*prob); *prob = (UInt16)PPMD_UPDATE_PROB_1(*prob);
p->InitEsc = PPMD7_kExpEscape[*prob >> 10]; p->InitEsc = PPMD7_kExpEscape[*prob >> 10];
PPMD_SetAllBitsIn256Bytes(charMask); PPMD_SetAllBitsIn256Bytes(charMask);
MASK(Ppmd7Context_OneState(p->MinContext)->Symbol) = 0; MASK(Ppmd7Context_OneState(p->MinContext)->Symbol) = 0;
p->PrevSuccess = 0; p->PrevSuccess = 0;
} }
for (;;) for (;;)
{ {
CPpmd_State *ps[256], *s; CPpmd_State *ps[256], *s;
UInt32 freqSum, count, hiCnt; UInt32 freqSum, count, hiCnt;
CPpmd_See *see; CPpmd_See *see;
unsigned i, num, numMasked = p->MinContext->NumStats; unsigned i, num, numMasked = p->MinContext->NumStats;
do do
{ {
p->OrderFall++; p->OrderFall++;
if (!p->MinContext->Suffix) if (!p->MinContext->Suffix)
return -1; return -1;
p->MinContext = Ppmd7_GetContext(p, p->MinContext->Suffix); p->MinContext = Ppmd7_GetContext(p, p->MinContext->Suffix);
} }
while (p->MinContext->NumStats == numMasked); while (p->MinContext->NumStats == numMasked);
hiCnt = 0; hiCnt = 0;
s = Ppmd7_GetStats(p, p->MinContext); s = Ppmd7_GetStats(p, p->MinContext);
i = 0; i = 0;
num = p->MinContext->NumStats - numMasked; num = p->MinContext->NumStats - numMasked;
do do
{ {
int k = (int)(MASK(s->Symbol)); int k = (int)(MASK(s->Symbol));
hiCnt += (s->Freq & k); hiCnt += (s->Freq & k);
ps[i] = s++; ps[i] = s++;
i -= k; i -= k;
} }
while (i != num); while (i != num);
see = Ppmd7_MakeEscFreq(p, numMasked, &freqSum); see = Ppmd7_MakeEscFreq(p, numMasked, &freqSum);
freqSum += hiCnt; freqSum += hiCnt;
count = rc->GetThreshold(rc, freqSum); count = rc->GetThreshold(rc, freqSum);
if (count < hiCnt) if (count < hiCnt)
{ {
Byte symbol; Byte symbol;
CPpmd_State **pps = ps; CPpmd_State **pps = ps;
for (hiCnt = 0; (hiCnt += (*pps)->Freq) <= count; pps++); for (hiCnt = 0; (hiCnt += (*pps)->Freq) <= count; pps++);
s = *pps; s = *pps;
rc->Decode(rc, hiCnt - s->Freq, s->Freq); rc->Decode(rc, hiCnt - s->Freq, s->Freq);
Ppmd_See_Update(see); Ppmd_See_Update(see);
p->FoundState = s; p->FoundState = s;
symbol = s->Symbol; symbol = s->Symbol;
Ppmd7_Update2(p); Ppmd7_Update2(p);
return symbol; return symbol;
} }
if (count >= freqSum) if (count >= freqSum)
return -2; return -2;
rc->Decode(rc, hiCnt, freqSum - hiCnt); rc->Decode(rc, hiCnt, freqSum - hiCnt);
see->Summ = (UInt16)(see->Summ + freqSum); see->Summ = (UInt16)(see->Summ + freqSum);
do { MASK(ps[--i]->Symbol) = 0; } while (i != 0); do { MASK(ps[--i]->Symbol) = 0; } while (i != 0);
} }
} }

View file

@ -1,10 +1,10 @@
/* Precomp.h -- StdAfx /* Precomp.h -- StdAfx
2013-11-12 : Igor Pavlov : Public domain */ 2013-11-12 : Igor Pavlov : Public domain */
#ifndef __7Z_PRECOMP_H #ifndef __7Z_PRECOMP_H
#define __7Z_PRECOMP_H #define __7Z_PRECOMP_H
#include "Compiler.h" #include "Compiler.h"
/* #include "7zTypes.h" */ /* #include "7zTypes.h" */
#endif #endif

View file

@ -881,7 +881,7 @@ public:
bool intersects(AActor *other) const bool intersects(AActor *other) const
{ {
fixed_t blockdist = radius + other->radius; fixed_t blockdist = radius + other->radius;
return ( abs(X() - other->Y()) < blockdist && abs(Y() - other->Y()) < blockdist); return ( abs(X() - other->X()) < blockdist && abs(Y() - other->Y()) < blockdist);
} }
// 'absolute' is reserved for a linked portal implementation which needs // 'absolute' is reserved for a linked portal implementation which needs

View file

@ -77,6 +77,7 @@
#include "decallib.h" #include "decallib.h"
#include "p_terrain.h" #include "p_terrain.h"
#include "version.h" #include "version.h"
#include "p_effect.h"
#include "g_shared/a_pickups.h" #include "g_shared/a_pickups.h"
@ -4464,6 +4465,7 @@ enum EACSFunctions
ACSF_GetMaxInventory, ACSF_GetMaxInventory,
ACSF_SetSectorDamage, ACSF_SetSectorDamage,
ACSF_SetSectorTerrain, ACSF_SetSectorTerrain,
ACSF_SpawnParticle,
/* Zandronum's - these must be skipped when we reach 99! /* Zandronum's - these must be skipped when we reach 99!
-100:ResetMap(0), -100:ResetMap(0),
@ -5988,7 +5990,35 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
} }
} }
break; break;
case ACSF_SpawnParticle:
{
fixed_t x = args[0];
fixed_t y = args[1];
fixed_t z = args[2];
fixed_t xvel = args[3];
fixed_t yvel = args[4];
fixed_t zvel = args[5];
PalEntry color = args[6];
int lifetime = args[7];
bool fullbright = argCount > 8 ? !!args[8] : false;
int startalpha = argCount > 9 ? args[9] : 0xFF; // Byte trans
int size = argCount > 10 ? args[10] : 1;
int fadestep = argCount > 11 ? args[11] : -1;
fixed_t accelx = argCount > 12 ? args[12] : 0;
fixed_t accely = argCount > 13 ? args[13] : 0;
fixed_t accelz = argCount > 14 ? args[14] : 0;
startalpha = clamp<int>(startalpha, 0, 0xFF); // Clamp to byte
lifetime = clamp<int>(lifetime, 0, 0xFF); // Clamp to byte
fadestep = clamp<int>(fadestep, -1, 0xFF); // Clamp to byte inc. -1 (indicating automatic)
size = clamp<int>(size, 0, 0xFF); // Clamp to byte
if (lifetime != 0)
P_SpawnParticle(x, y, z, xvel, yvel, zvel, color, fullbright, startalpha, lifetime, size, fadestep, accelx, accely, accelz);
}
break;
default: default:
break; break;
} }

View file

@ -1345,22 +1345,30 @@ static void HandleReply(player_t *player, bool isconsole, int nodenum, int reply
if (reply->NextNode != 0) if (reply->NextNode != 0)
{ {
int rootnode = npc->ConversationRoot; int rootnode = npc->ConversationRoot;
unsigned next = (unsigned)(rootnode + (reply->NextNode < 0 ? -1 : 1) * reply->NextNode - 1); const bool isNegative = reply->NextNode < 0;
const unsigned next = (unsigned)(rootnode + (isNegative ? -1 : 1) * reply->NextNode - 1);
if (next < StrifeDialogues.Size()) if (next < StrifeDialogues.Size())
{ {
npc->Conversation = StrifeDialogues[next]; npc->Conversation = StrifeDialogues[next];
if (gameaction != ga_slideshow) if (isNegative)
{ {
P_StartConversation (npc, player->mo, player->ConversationFaceTalker, false); if (gameaction != ga_slideshow)
return; {
} P_StartConversation (npc, player->mo, player->ConversationFaceTalker, false);
else return;
{ }
S_StopSound (npc, CHAN_VOICE); else
{
S_StopSound (npc, CHAN_VOICE);
}
} }
} }
else
{
Printf ("Next node %u is invalid, no such dialog page\n", next);
}
} }
npc->angle = player->ConversationNPCAngle; npc->angle = player->ConversationNPCAngle;

View file

@ -284,6 +284,31 @@ void P_ThinkParticles ()
} }
} }
void P_SpawnParticle(fixed_t x, fixed_t y, fixed_t z, fixed_t velx, fixed_t vely, fixed_t velz, PalEntry color, bool fullbright, BYTE startalpha, BYTE lifetime, BYTE size, int fadestep, fixed_t accelx, fixed_t accely, fixed_t accelz)
{
particle_t *particle = NewParticle();
if (particle)
{
particle->x = x;
particle->y = y;
particle->z = z;
particle->velx = velx;
particle->vely = vely;
particle->velz = velz;
particle->color = ParticleColor(color);
particle->trans = startalpha;
if (fadestep < 0) fadestep = FADEFROMTTL(lifetime);
particle->fade = fadestep;
particle->ttl = lifetime;
particle->accx = accelx;
particle->accy = accely;
particle->accz = accelz;
particle->bright = fullbright;
particle->size = size;
}
}
// //
// P_RunEffects // P_RunEffects
// //

View file

@ -83,6 +83,7 @@ particle_t *JitterParticle (int ttl);
particle_t *JitterParticle (int ttl, float drift); particle_t *JitterParticle (int ttl, float drift);
void P_ThinkParticles (void); void P_ThinkParticles (void);
void P_SpawnParticle(fixed_t x, fixed_t y, fixed_t z, fixed_t velx, fixed_t vely, fixed_t velz, PalEntry color, bool fullbright, BYTE startalpha, BYTE lifetime, BYTE size, int fadestep, fixed_t accelx, fixed_t accely, fixed_t accelz);
void P_InitEffects (void); void P_InitEffects (void);
void P_RunEffects (void); void P_RunEffects (void);

File diff suppressed because it is too large Load diff

View file

@ -878,6 +878,7 @@ FArchive &operator<< (FArchive &arc, secspecial_t &p)
int special; int special;
arc << special; arc << special;
sector_t sec; sector_t sec;
memset(&sec, 0, sizeof(sec));
P_InitSectorSpecial(&sec, special, true); P_InitSectorSpecial(&sec, special, true);
sec.GetSpecial(&p); sec.GetSpecial(&p);
} }

View file

@ -1,134 +1,134 @@
/* /*
** pathexpander.cpp ** pathexpander.cpp
** Utility class for expanding a given path with a range of directories ** Utility class for expanding a given path with a range of directories
** **
**--------------------------------------------------------------------------- **---------------------------------------------------------------------------
** Copyright 2015 Christoph Oelckers ** Copyright 2015 Christoph Oelckers
** All rights reserved. ** All rights reserved.
** **
** Redistribution and use in source and binary forms, with or without ** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions ** modification, are permitted provided that the following conditions
** are met: ** are met:
** **
** 1. Redistributions of source code must retain the above copyright ** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer. ** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright ** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the ** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution. ** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products ** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission. ** derived from this software without specific prior written permission.
** **
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**--------------------------------------------------------------------------- **---------------------------------------------------------------------------
** **
*/ */
#include "pathexpander.h" #include "pathexpander.h"
#include "cmdlib.h" #include "cmdlib.h"
#include "w_wad.h" #include "w_wad.h"
//============================================================================ //============================================================================
// //
// //
// //
//============================================================================ //============================================================================
static FString BuildPath(const FString &base, const char *name) static FString BuildPath(const FString &base, const char *name)
{ {
FString current; FString current;
if (base.IsNotEmpty()) if (base.IsNotEmpty())
{ {
current = base; current = base;
if (current[current.Len() - 1] != '/') current += '/'; if (current[current.Len() - 1] != '/') current += '/';
} }
current += name; current += name;
return current; return current;
} }
//============================================================================ //============================================================================
// //
// This is meant to find and open files for reading. // This is meant to find and open files for reading.
// //
//============================================================================ //============================================================================
FileReader *PathExpander::openFileReader(const char *name, int *plumpnum) FileReader *PathExpander::openFileReader(const char *name, int *plumpnum)
{ {
FileReader *fp; FileReader *fp;
FString current_filename; FString current_filename;
if (!name || !(*name)) if (!name || !(*name))
{ {
return 0; return 0;
} }
/* First try the given name */ /* First try the given name */
current_filename = name; current_filename = name;
FixPathSeperator(current_filename); FixPathSeperator(current_filename);
if (openmode != OM_FILE) if (openmode != OM_FILE)
{ {
int lumpnum = Wads.CheckNumForFullName(current_filename); int lumpnum = Wads.CheckNumForFullName(current_filename);
if (lumpnum >= 0) if (lumpnum >= 0)
{ {
fp = Wads.ReopenLumpNum(lumpnum); fp = Wads.ReopenLumpNum(lumpnum);
if (plumpnum) *plumpnum = lumpnum; if (plumpnum) *plumpnum = lumpnum;
return fp; return fp;
} }
if (openmode == OM_LUMP) // search the path list when not loading the main config if (openmode == OM_LUMP) // search the path list when not loading the main config
{ {
for (unsigned int plp = PathList.Size(); plp-- != 0; ) for (unsigned int plp = PathList.Size(); plp-- != 0; )
{ /* Try along the path then */ { /* Try along the path then */
current_filename = BuildPath(PathList[plp], name); current_filename = BuildPath(PathList[plp], name);
lumpnum = Wads.CheckNumForFullName(current_filename); lumpnum = Wads.CheckNumForFullName(current_filename);
if (lumpnum >= 0) if (lumpnum >= 0)
{ {
fp = Wads.ReopenLumpNum(lumpnum); fp = Wads.ReopenLumpNum(lumpnum);
if (plumpnum) *plumpnum = lumpnum; if (plumpnum) *plumpnum = lumpnum;
return fp; return fp;
} }
} }
return NULL; return NULL;
} }
} }
if (plumpnum) *plumpnum = -1; if (plumpnum) *plumpnum = -1;
fp = new FileReader; fp = new FileReader;
if (fp->Open(current_filename)) return fp; if (fp->Open(current_filename)) return fp;
if (name[0] != '/') if (name[0] != '/')
{ {
for (unsigned int plp = PathList.Size(); plp-- != 0; ) for (unsigned int plp = PathList.Size(); plp-- != 0; )
{ /* Try along the path then */ { /* Try along the path then */
current_filename = BuildPath(PathList[plp], name); current_filename = BuildPath(PathList[plp], name);
if (fp->Open(current_filename)) return fp; if (fp->Open(current_filename)) return fp;
} }
} }
delete fp; delete fp;
/* Nothing could be opened. */ /* Nothing could be opened. */
return NULL; return NULL;
} }
/* This adds a directory to the path list */ /* This adds a directory to the path list */
void PathExpander::addToPathlist(const char *s) void PathExpander::addToPathlist(const char *s)
{ {
FString copy = s; FString copy = s;
FixPathSeperator(copy); FixPathSeperator(copy);
PathList.Push(copy); PathList.Push(copy);
} }
void PathExpander::clearPathlist() void PathExpander::clearPathlist()
{ {
PathList.Clear(); PathList.Clear();
} }

View file

@ -1,31 +1,31 @@
#ifndef __PATHEXPANDER_H #ifndef __PATHEXPANDER_H
#define __PATHEXPANDER_H #define __PATHEXPANDER_H
#include "tarray.h" #include "tarray.h"
#include "zstring.h" #include "zstring.h"
#include "files.h" #include "files.h"
class PathExpander class PathExpander
{ {
TArray<FString> PathList; TArray<FString> PathList;
public: public:
int openmode; int openmode;
enum enum
{ {
OM_FILEORLUMP = 0, OM_FILEORLUMP = 0,
OM_LUMP, OM_LUMP,
OM_FILE OM_FILE
}; };
PathExpander(int om = OM_FILEORLUMP) PathExpander(int om = OM_FILEORLUMP)
{ {
openmode = om; openmode = om;
} }
void addToPathlist(const char *s); void addToPathlist(const char *s);
void clearPathlist(); void clearPathlist();
FileReader *openFileReader(const char *name, int *plumpnum); FileReader *openFileReader(const char *name, int *plumpnum);
}; };
#endif #endif

View file

@ -94,7 +94,7 @@ WildMIDIDevice::WildMIDIDevice(const char *args)
SampleRate = clamp(SampleRate, 11025, 65535); SampleRate = clamp(SampleRate, 11025, 65535);
} }
if (args == NULL || *args == 0) args = wildmidi_config; if (args == NULL || *args == 0) args = wildmidi_config;
if (CurrentConfig.CompareNoCase(args) != 0 || SampleRate != WildMidi_GetSampleRate()) if (CurrentConfig.CompareNoCase(args) != 0 || SampleRate != WildMidi_GetSampleRate())
{ {

View file

@ -51,6 +51,7 @@
#include "s_sound.h" #include "s_sound.h"
#include "cmdlib.h" #include "cmdlib.h"
#include "p_lnspec.h" #include "p_lnspec.h"
#include "p_effect.h"
#include "p_enemy.h" #include "p_enemy.h"
#include "a_action.h" #include "a_action.h"
#include "decallib.h" #include "decallib.h"
@ -2627,6 +2628,75 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnDebris)
} }
} }
//===========================================================================
//
// A_SpawnParticle
//
//===========================================================================
enum SPFflag
{
SPF_FULLBRIGHT = 1,
SPF_RELPOS = 1 << 1,
SPF_RELVEL = 1 << 2,
SPF_RELACCEL = 1 << 3,
SPF_RELANG = 1 << 4,
};
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnParticle)
{
ACTION_PARAM_START(15);
ACTION_PARAM_FIXED(xoff, 0);
ACTION_PARAM_FIXED(yoff, 1);
ACTION_PARAM_FIXED(zoff, 2);
ACTION_PARAM_FIXED(xvel, 3);
ACTION_PARAM_FIXED(yvel, 4);
ACTION_PARAM_FIXED(zvel, 5);
ACTION_PARAM_COLOR(color, 6);
ACTION_PARAM_INT(lifetime, 7);
ACTION_PARAM_INT(flags, 8);
ACTION_PARAM_FIXED(startalphaf, 9);
ACTION_PARAM_INT(size, 10);
ACTION_PARAM_FIXED(fadestepf, 11);
ACTION_PARAM_FIXED(accelx, 12);
ACTION_PARAM_FIXED(accely, 13);
ACTION_PARAM_FIXED(accelz, 14);
ACTION_PARAM_ANGLE(angle, 15);
BYTE startalpha = (BYTE)Scale(clamp(startalphaf, 0, FRACUNIT), 255, FRACUNIT);
int fadestep = fadestepf < 0? -1 : Scale(clamp(fadestepf, 0, FRACUNIT), 255, FRACUNIT);
lifetime = clamp<int>(lifetime, 0, 0xFF); // Clamp to byte
size = clamp<int>(size, 0, 0xFF); // Clamp to byte
if (lifetime != 0)
{
const angle_t ang = (angle + ((flags & SPF_RELANG) ? self->angle : 0)) >> ANGLETOFINESHIFT;
fixedvec3 pos;
//[MC] Code ripped right out of A_SpawnItemEx.
if (flags & SPF_RELPOS)
{
// in relative mode negative y values mean 'left' and positive ones mean 'right'
// This is the inverse orientation of the absolute mode!
const fixed_t xof1 = xoff;
xoff = FixedMul(xof1, finecosine[ang]) + FixedMul(yoff, finesine[ang]);
yoff = FixedMul(xof1, finesine[ang]) - FixedMul(yoff, finecosine[ang]);
}
if (flags & SPF_RELVEL)
{
const fixed_t newxvel = FixedMul(xvel, finecosine[ang]) + FixedMul(yvel, finesine[ang]);
yvel = FixedMul(xvel, finesine[ang]) - FixedMul(yvel, finecosine[ang]);
xvel = newxvel;
}
if (flags & SPF_RELACCEL)
{
fixed_t newaccelx = FixedMul(accelx, finecosine[ang]) + FixedMul(accely, finesine[ang]);
accely = FixedMul(accelx, finesine[ang]) - FixedMul(accely, finecosine[ang]);
accelx = newaccelx;
}
pos = self->Vec3Offset(xoff, yoff, zoff);
P_SpawnParticle(pos.x, pos.y, pos.z, xvel, yvel, zvel, color, !!(flags & SPF_FULLBRIGHT), startalpha, lifetime, size, fadestep, accelx, accely, accelz);
}
}
//=========================================================================== //===========================================================================
// //

View file

@ -1,37 +1,37 @@
/* /*
** file_io.cpp ** file_io.cpp
** ZDoom compatible file IO interface for WildMIDI ** ZDoom compatible file IO interface for WildMIDI
** (This file was completely redone to remove the low level IO code references) ** (This file was completely redone to remove the low level IO code references)
** **
**--------------------------------------------------------------------------- **---------------------------------------------------------------------------
** Copyright 2010 Christoph Oelckers ** Copyright 2010 Christoph Oelckers
** All rights reserved. ** All rights reserved.
** **
** Redistribution and use in source and binary forms, with or without ** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions ** modification, are permitted provided that the following conditions
** are met: ** are met:
** **
** 1. Redistributions of source code must retain the above copyright ** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer. ** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright ** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the ** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution. ** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products ** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission. ** derived from this software without specific prior written permission.
** **
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**--------------------------------------------------------------------------- **---------------------------------------------------------------------------
** **
*/ */
#include <errno.h> #include <errno.h>
@ -48,36 +48,36 @@ unsigned char *_WM_BufferFile(const char *filename, unsigned long int *size, boo
FileReader *fp; FileReader *fp;
int lumpnum; int lumpnum;
if (ismain) if (ismain)
{ {
wmPathExpander.openmode = PathExpander::OM_FILEORLUMP; wmPathExpander.openmode = PathExpander::OM_FILEORLUMP;
wmPathExpander.clearPathlist(); wmPathExpander.clearPathlist();
#ifdef _WIN32 #ifdef _WIN32
wmPathExpander.addToPathlist("C:\\TIMIDITY"); wmPathExpander.addToPathlist("C:\\TIMIDITY");
wmPathExpander.addToPathlist("\\TIMIDITY"); wmPathExpander.addToPathlist("\\TIMIDITY");
wmPathExpander.addToPathlist(progdir); wmPathExpander.addToPathlist(progdir);
#else #else
wmPathExpander.addToPathlist("/usr/local/lib/timidity"); wmPathExpander.addToPathlist("/usr/local/lib/timidity");
wmPathExpander.addToPathlist("/etc/timidity"); wmPathExpander.addToPathlist("/etc/timidity");
wmPathExpander.addToPathlist("/etc"); wmPathExpander.addToPathlist("/etc");
#endif #endif
} }
if (!(fp = wmPathExpander.openFileReader(filename, &lumpnum))) if (!(fp = wmPathExpander.openFileReader(filename, &lumpnum)))
return NULL; return NULL;
if (ismain) if (ismain)
{ {
if (lumpnum > 0) if (lumpnum > 0)
{ {
wmPathExpander.openmode = PathExpander::OM_LUMP; wmPathExpander.openmode = PathExpander::OM_LUMP;
wmPathExpander.clearPathlist(); // when reading from a PK3 we don't want to use any external path wmPathExpander.clearPathlist(); // when reading from a PK3 we don't want to use any external path
} }
else else
{ {
wmPathExpander.openmode = PathExpander::OM_FILE; wmPathExpander.openmode = PathExpander::OM_FILE;
} }
} }

View file

@ -234,6 +234,7 @@ ACTOR Actor native //: Thinker
action native A_SetScale(float scalex, float scaley = 0, int ptr = AAPTR_DEFAULT); action native A_SetScale(float scalex, float scaley = 0, int ptr = AAPTR_DEFAULT);
action native A_SetMass(int mass); action native A_SetMass(int mass);
action native A_SpawnDebris(class<Actor> spawntype, bool transfer_translation = false, float mult_h = 1, float mult_v = 1); action native A_SpawnDebris(class<Actor> spawntype, bool transfer_translation = false, float mult_h = 1, float mult_v = 1);
action native A_SpawnParticle(float xoff, float yoff, float zoff, float velx, float vely, float velz, color color1, int lifetime, int flags = 0, float startalpha = 1, int size = 1, float fadestep = -1, float accelx = 0.0, float accely = 0.0, float accelz = 0.0, float angle = 0);
action native A_CheckSight(state label); action native A_CheckSight(state label);
action native A_ExtChase(bool usemelee, bool usemissile, bool playactive = true, bool nightmarefast = false); action native A_ExtChase(bool usemelee, bool usemissile, bool playactive = true, bool nightmarefast = false);
action native A_DropInventory(class<Inventory> itemtype); action native A_DropInventory(class<Inventory> itemtype);

View file

@ -511,6 +511,17 @@ enum
CBF_SETONPTR = 1 << 4, //Sets the pointer change on the actor doing the checking instead of self. CBF_SETONPTR = 1 << 4, //Sets the pointer change on the actor doing the checking instead of self.
}; };
enum
{
SPF_FULLBRIGHT = 1,
SPF_RELPOS = 1 << 1,
SPF_RELVEL = 1 << 2,
SPF_RELACCEL = 1 << 3,
SPF_RELANG = 1 << 4,
SPF_RELATIVE = SPF_RELPOS|SPF_RELVEL|SPF_RELACCEL|SPF_RELANG
};
// This is only here to provide one global variable for testing. // This is only here to provide one global variable for testing.
native int testglobalvar; native int testglobalvar;

View file

@ -1,29 +1,29 @@
/***** BFG Scorches ********************************************************/ /***** BFG Scorches ********************************************************/
decal BFGLightning1 decal BFGLightning1
{ {
pic BFGLITE1 pic BFGLITE1
shade "80 80 ff" shade "80 80 ff"
fullbright fullbright
randomflipx randomflipx
animator GoAway2 animator GoAway2
lowerdecal BFGScorch lowerdecal BFGScorch
} }
decal BFGLightning2 decal BFGLightning2
{ {
pic BFGLITE2 pic BFGLITE2
shade "80 80 ff" shade "80 80 ff"
fullbright fullbright
randomflipy randomflipy
animator GoAway2 animator GoAway2
lowerdecal BFGScorch lowerdecal BFGScorch
} }
decalgroup BFGLightning decalgroup BFGLightning
{ {
BFGLightning1 1 BFGLightning1 1
BFGLightning2 1 BFGLightning2 1
} }