Update to ZDoom r1083. Not fully tested yet!

- Converted most sprintf (and all wsprintf) calls to either mysnprintf or
  FStrings, depending on the situation.
- Changed the strings in the wbstartstruct to be FStrings.
- Changed myvsnprintf() to output nothing if count is greater than INT_MAX.
  This is so that I can use a series of mysnprintf() calls and advance the
  pointer for each one. Once the pointer goes beyond the end of the buffer,
  the count will go negative, but since it's an unsigned type it will be
  seen as excessively huge instead. This should not be a problem, as there's
  no reason for ZDoom to be using text buffers larger than 2 GB anywhere.
- Ripped out the disabled bit from FGameConfigFile::MigrateOldConfig().
- Changed CalcMapName() to return an FString instead of a pointer to a static
  buffer.
- Changed startmap in d_main.cpp into an FString.
- Changed CheckWarpTransMap() to take an FString& as the first argument.
- Changed d_mapname in g_level.cpp into an FString.
- Changed DoSubstitution() in ct_chat.cpp to place the substitutions in an
  FString.
- Fixed: The MAPINFO parser wrote into the string buffer to construct a map
  name when given a Hexen map number. This was fine with the old scanner
  code, but only a happy coincidence prevents it from crashing with the new
  code.
- Added the 'B' conversion specifier to StringFormat::VWorker() for printing
  binary numbers.
- Added CMake support for building with MinGW, MSYS, and NMake. Linux support
  is probably broken until I get around to booting into Linux again. Niceties
  provided over the existing Makefiles they're replacing:
  * All command-line builds can use the same build system, rather than having
    a separate one for MinGW and another for Linux.
  * Microsoft's NMake tool is supported as a target.
  * Progress meters.
  * Parallel makes work from a fresh checkout without needing to be primed
    first with a single-threaded make.
  * Porting to other architectures should be simplified, whenever that day
    comes.
- Replaced the makewad tool with zipdir. This handles the dependency tracking
  itself instead of generating an external makefile to do it, since I couldn't
  figure out how to generate a makefile with an external tool and include it
  with a CMake-generated makefile. Where makewad used a master list of files
  to generate the package file, zipdir just zips the entire contents of one or
  more directories.


git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@138 b0f79afe-0144-0410-b225-9a4edf0717df
This commit is contained in:
Christoph Oelckers 2008-07-23 18:35:55 +00:00
parent 3839d89923
commit d65fc51c06
841 changed files with 2180 additions and 34802 deletions

View file

@ -173,7 +173,7 @@ IMPLEMENT_SERIAL. For a class that won't be saved to disk, do this:
should be sure to change if you change the structs. The code for
serializing sector_t and line_t can be found in P_SerializeWorld() in
p_saveg.cpp. The code for serializing player_t is in p_user.cpp as
player_s::Serialize().
player_t::Serialize().
To determine the type of an object, you can use the IsA() and IsKindOf()
methods of DObject. IsA() tests if the object is an instance of a
@ -210,8 +210,8 @@ END_POINTERS
If you add pointers to any class, you need to update this list accordingly.
The player class uses a hack, because it is not derived from DObject, to
clear pointers. See player_s::FixPointers() in p_user.cpp if you add any
pointers to player_s.
clear pointers. See player_t::FixPointers() in p_user.cpp if you add any
pointers to player_t.
When you want to destroy any object derived from DThinker (this includes all
actors), call that object's Destroy() method. Do not use delete, because it

View file

@ -1,4 +1,36 @@
July 21, 2008
- Converted most sprintf (and all wsprintf) calls to either mysnprintf or
FStrings, depending on the situation.
- Changed the strings in the wbstartstruct to be FStrings.
- Changed myvsnprintf() to output nothing if count is greater than INT_MAX.
This is so that I can use a series of mysnprintf() calls and advance the
pointer for each one. Once the pointer goes beyond the end of the buffer,
the count will go negative, but since it's an unsigned type it will be
seen as excessively huge instead. This should not be a problem, as there's
no reason for ZDoom to be using text buffers larger than 2 GB anywhere.
- Ripped out the disabled bit from FGameConfigFile::MigrateOldConfig().
- Changed CalcMapName() to return an FString instead of a pointer to a static
buffer.
- Changed startmap in d_main.cpp into an FString.
- Changed CheckWarpTransMap() to take an FString& as the first argument.
- Changed d_mapname in g_level.cpp into an FString.
- Changed DoSubstitution() in ct_chat.cpp to place the substitutions in an
FString.
- Fixed: The MAPINFO parser wrote into the string buffer to construct a map
name when given a Hexen map number. This was fine with the old scanner
code, but only a happy coincidence prevents it from crashing with the new
code.
July 21, 2008 (Changes by Graf Zahl)
- Added MF4_BOSSDEATH to the Minotaur.
- Fixed: The boss brain looped to the wrong state.
- Converted Heretic's Staff, GoldWand, Crossbow and Gauntlets to DECORATE.
- fixed: Morphing to a class without a face definition crashed.
- Converted all of Heretic's actors except the weapons to DECORATE.
- Added the option to define the ActorInfos for native classes in DECORATE.
July 20, 2008 (Changes by Graf Zahl)
- Fixed: When copying visplanes the sky texture was forgotten.
- converted the boss brain to DECORATE.
- added an abstract base class for special map spots that are maintained in
lists and rewrote the boss brain, the mace and DSparil to use it.
@ -22,6 +54,31 @@ July 18, 2008 (Changes by Graf Zahl)
- Added const char &operator[] (unsigned int index) to FString class.
- Added Skulltag's Teleport_NoStop action special.
July 17, 2008
- Added the 'B' conversion specifier to StringFormat::VWorker() for printing
binary numbers.
July 16, 2008
- Added CMake support for building with MinGW, MSYS, and NMake. Linux support
is probably broken until I get around to booting into Linux again. Niceties
provided over the existing Makefiles they're replacing:
* All command-line builds can use the same build system, rather than having
a separate one for MinGW and another for Linux.
* Microsoft's NMake tool is supported as a target.
* Progress meters.
* Parallel makes work from a fresh checkout without needing to be primed
first with a single-threaded make.
* Porting to other architectures should be simplified, whenever that day
comes.
July 15, 2008
- Replaced the makewad tool with zipdir. This handles the dependency tracking
itself instead of generating an external makefile to do it, since I couldn't
figure out how to generate a makefile with an external tool and include it
with a CMake-generated makefile. Where makewad used a master list of files
to generate the package file, zipdir just zips the entire contents of one or
more directories.
July 15, 2008 (Changes by Graf Zahl)
- Fixed: Strife's EntityBoss didn't copy friendliness information to the
sub-entities.
@ -47,6 +104,10 @@ July 12, 2008 (Changes by Graf Zahl)
- Fixed: ACS's ActivatorSound must check if the activator is valid.
- Changed stats drawing so that multi-line strings can be used.
July 9, 2008
- Added the gdtoa package from netlib's fp library so that ZDoom's printf-style
formatting can be entirely independant of the CRT.
July 5, 2008
- Added a check to G_DoSaveGame() to prevent saving when you're not actually
in a level.

View file

@ -26,10 +26,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wadsrc", "wadsrc\wadsrc.vcp
{24A19C02-F041-4AB0-A1A1-02E1E88EDBD3} = {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "makewad", "tools\makewad\makewad.vcproj", "{24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}"
ProjectSection(ProjectDependencies) = postProject
{F9D9E7D4-E1A2-4866-9E85-B1B14137EE63} = {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "updaterevision", "tools\updaterevision\updaterevision.vcproj", "{6077B7D6-349F-4077-B552-3BC302EF5859}"
EndProject
@ -47,6 +43,12 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lights", "wadsrc_lights\lights.vcproj", "{31090871-A623-4BBC-A167-DE821CD1240C}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dumb_static", "dumb\vc6\dumb_static\dumb_static.vcproj", "{8997289F-10BF-4678-8BAA-3BB509C84953}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zipdir", "tools\zipdir\zipdir.vcproj", "{24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}"
ProjectSection(ProjectDependencies) = postProject
{F9D9E7D4-E1A2-4866-9E85-B1B14137EE63} = {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gdtoa", "gdtoa\gdtoa.vcproj", "{B68E0ABF-B627-48A3-A92F-D8F827A75054}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

View file

@ -55,8 +55,8 @@
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
AdditionalIncludeDirectories="src\win32,src\sound,src,zlib,src\g_shared,src\g_doom,src\g_raven,src\g_heretic,src\g_hexen,src\g_strife;flac;jpeg-6b;snes_spc\snes_spc"
PreprocessorDefinitions="NDEBUG,WIN32,_WIN32,_WINDOWS,USEASM,HAVE_STRUPR,HAVE_FILELENGTH,SILENT_INSTANT_FLOORS"
AdditionalIncludeDirectories="src\win32,src\sound,src,zlib,src\g_shared,src\g_doom,src\g_raven,src\g_heretic,src\g_hexen,src\g_strife;flac;jpeg-6b;snes_spc\snes_spc;gdtoa"
PreprocessorDefinitions="NDEBUG,WIN32,_WIN32,_WINDOWS,USEASM,NO_MANIFEST"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
@ -172,8 +172,8 @@
Name="VCCLCompilerTool"
Optimization="0"
InlineFunctionExpansion="0"
AdditionalIncludeDirectories="src\win32;src\sound;src;zlib;src\g_shared;src\g_doom;src\g_raven;src\g_heretic;src\g_hexen;src\g_strife;flac;jpeg-6b;snes_spc\snes_spc"
PreprocessorDefinitions="WIN32,_DEBUG,_WIN32,_WINDOWS,USEASM,_CRTDBG_MAP_ALLOC,HAVE_STRUPR,HAVE_FILELENGTH"
AdditionalIncludeDirectories="src\win32;src\sound;src;zlib;src\g_shared;src\g_doom;src\g_raven;src\g_heretic;src\g_hexen;src\g_strife;flac;jpeg-6b;snes_spc\snes_spc;gdtoa"
PreprocessorDefinitions="WIN32,_DEBUG,_WIN32,_WINDOWS,USEASM,_CRTDBG_MAP_ALLOC,NO_MANIFEST"
MinimalRebuild="true"
RuntimeLibrary="1"
EnableFunctionLevelLinking="true"
@ -1552,37 +1552,39 @@
<Tool
Name="VCCustomBuildTool"
Description="Assembling $(InputPath)..."
CommandLine="nasm -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
CommandLine="nasm -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot; -isrc/&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName).obj"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
Description="Assembling $(InputPath)..."
CommandLine="nasm -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot; -isrc/&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
Outputs="$(IntDir)/$(InputName).obj"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Assembling $(InputPath)..."
CommandLine="nasm -g -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
CommandLine="nasm -g -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot; -isrc/&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName).obj"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCustomBuildTool"
Description="Assembling $(InputPath)..."
CommandLine="nasm -o $(IntDir)\$(InputName).obj -f win32 $(InputPath)&#x0D;&#x0A;"
Outputs="$(IntDir)/$(InputName).obj"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
Description="Assembling $(InputPath)..."
CommandLine="nasm -o $(IntDir)\$(InputName).obj -f win32 $(InputPath)&#x0D;&#x0A;"
CommandLine="nasm -g -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot; -isrc/&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
Outputs="$(IntDir)/$(InputName).obj"
/>
</FileConfiguration>
@ -1596,37 +1598,39 @@
<Tool
Name="VCCustomBuildTool"
Description="Assembling $(InputPath)..."
CommandLine="nasm -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
CommandLine="nasm -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot; -isrc/&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName).obj"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
Description="Assembling $(InputPath)..."
CommandLine="nasm -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot; -isrc/&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
Outputs="$(IntDir)/$(InputName).obj"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Assembling $(InputPath)..."
CommandLine="nasm -g -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
CommandLine="nasm -g -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot; -isrc/&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName).obj"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCustomBuildTool"
Description="Assembling $(InputPath)..."
CommandLine="nasm -o $(IntDir)\$(InputName).obj -f win32 $(InputPath)&#x0D;&#x0A;"
Outputs="$(IntDir)/$(InputName).obj"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
Description="Assembling $(InputPath)..."
CommandLine="nasm -o $(IntDir)\$(InputName).obj -f win32 $(InputPath)&#x0D;&#x0A;"
CommandLine="nasm -g -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot; -isrc/&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
Outputs="$(IntDir)/$(InputName).obj"
/>
</FileConfiguration>
@ -1640,38 +1644,40 @@
<Tool
Name="VCCustomBuildTool"
Description="Assembling $(InputPath)..."
CommandLine="nasm -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
CommandLine="nasm -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot; -isrc/&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName).obj"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
Description="Assembling $(InputPath)..."
CommandLine="nasm -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot; -isrc/&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
Outputs="$(IntDir)/$(InputName).obj"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Assembling $(InputPath)..."
CommandLine="nasm -g -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName).obj"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCustomBuildTool"
Description="Assembling $(InputPath)..."
CommandLine="nasm -o $(IntDir)\$(InputName).obj -f win32 $(InputPath)&#x0D;&#x0A;"
CommandLine="nasm -g -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot; -isrc/&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName).obj"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
Description="Assembling $(InputPath)..."
CommandLine="nasm -o $(IntDir)\$(InputName).obj -f win32 $(InputPath)&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName).obj"
CommandLine="nasm -g -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot; -isrc/&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
Outputs="$(IntDir)/$(InputName).obj"
/>
</FileConfiguration>
</File>
@ -1684,38 +1690,40 @@
<Tool
Name="VCCustomBuildTool"
Description="Assembling $(InputPath)..."
CommandLine="nasm -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
CommandLine="nasm -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot; -isrc/&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName).obj"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
Description="Assembling $(InputPath)..."
CommandLine="nasm -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot; -isrc/&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
Outputs="$(IntDir)/$(InputName).obj"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Assembling $(InputPath)..."
CommandLine="nasm -g -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName).obj"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCustomBuildTool"
Description="Assembling $(InputPath)..."
CommandLine="nasm -o $(IntDir)\$(InputName).obj -f win32 $(InputPath)&#x0D;&#x0A;"
CommandLine="nasm -g -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot; -isrc/&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName).obj"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
Description="Assembling $(InputPath)..."
CommandLine="nasm -o $(IntDir)\$(InputName).obj -f win32 $(InputPath)&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName).obj"
CommandLine="nasm -g -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot; -isrc/&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
Outputs="$(IntDir)/$(InputName).obj"
/>
</FileConfiguration>
</File>
@ -1728,38 +1736,40 @@
<Tool
Name="VCCustomBuildTool"
Description="Assembling $(InputPath)..."
CommandLine="nasm -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
CommandLine="nasm -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot; -isrc/&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName).obj"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
Description="Assembling $(InputPath)..."
CommandLine="nasm -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot; -isrc/&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
Outputs="$(IntDir)/$(InputName).obj"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Assembling $(InputPath)..."
CommandLine="nasm -g -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName).obj"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCustomBuildTool"
Description="Assembling $(InputPath)..."
CommandLine="nasm -o $(IntDir)\$(InputName).obj -f win32 $(InputPath)&#x0D;&#x0A;"
CommandLine="nasm -g -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot; -isrc/&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName).obj"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
Description="Assembling $(InputPath)..."
CommandLine="nasm -o $(IntDir)\$(InputName).obj -f win32 $(InputPath)&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName).obj"
CommandLine="nasm -g -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot; -isrc/&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
Outputs="$(IntDir)/$(InputName).obj"
/>
</FileConfiguration>
</File>
@ -2768,6 +2778,10 @@
RelativePath="docs\classes.txt"
>
</File>
<File
RelativePath=".\src\CMakeLists.txt"
>
</File>
<File
RelativePath="docs\colors.txt"
>

View file

@ -11,6 +11,9 @@
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
@ -77,6 +80,69 @@
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
@ -142,6 +208,71 @@
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
WholeProgramOptimization="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
EnableIntrinsicFunctions="true"
OmitFramePointers="true"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
StringPooling="true"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
@ -274,6 +405,10 @@
>
</File>
</Filter>
<File
RelativePath=".\CMakeLists.txt"
>
</File>
<File
RelativePath=".\readme-zdoom.txt"
>

View file

@ -11,6 +11,9 @@
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
@ -77,6 +80,69 @@
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
@ -114,7 +180,73 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
CallingConvention="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
WholeProgramOptimization="false"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
StringPooling="true"
ExceptionHandling="0"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -220,6 +352,84 @@
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release DLL|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="2"
WholeProgramOptimization="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
WholeProgramOptimization="false"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
StringPooling="true"
ExceptionHandling="0"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
CallingConvention="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug DLL|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
@ -293,6 +503,81 @@
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug DLL|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OptimizeReferences="1"
EnableCOMDATFolding="1"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
@ -377,12 +662,10 @@
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
<File
RelativePath=".\CMakeLists.txt"
>
</Filter>
</File>
<File
RelativePath=".\readme.txt"
>

View file

@ -3,7 +3,7 @@
; See the included license file "BUILDLIC.TXT" for license info.
; This file has been modified from Ken Silverman's original release
%include "src/valgrind.inc"
%include "valgrind.inc"
SECTION .data

View file

@ -733,7 +733,7 @@ void AM_loadPics ()
for (i = 0; i < 10; i++)
{
sprintf (namebuf, "AMMNUM%d", i);
mysnprintf (namebuf, countof(namebuf), "AMMNUM%d", i);
marknums[i] = TexMan.CheckForTexture (namebuf, FTexture::TEX_MiscPatch);
}

View file

@ -327,7 +327,8 @@ bool FCajunMaster::SpawnBot (const char *name, int color)
}
if (TEAMINFO_IsValidTeam (thebot->lastteam))
{ // Keep the bot on the same team when switching levels
sprintf (concat+strlen(concat), "\\team\\%d\n", thebot->lastteam);
mysnprintf (concat + strlen(concat), countof(concat) - strlen(concat),
"\\team\\%d\n", thebot->lastteam);
}
Net_WriteString (concat);
}
@ -602,7 +603,7 @@ bool FCajunMaster::LoadBots ()
}
}
appendinfo (newinfo->info, "team");
sprintf (teamstr, "%d", teamnum);
mysnprintf (teamstr, countof(teamstr), "%d", teamnum);
appendinfo (newinfo->info, teamstr);
gotteam = true;
break;

View file

@ -275,7 +275,7 @@ static const char *KeyName (int key)
if (KeyNames[key])
return KeyNames[key];
sprintf (name, "#%d", key);
mysnprintf (name, countof(name), "#%d", key);
return name;
}

View file

@ -247,7 +247,7 @@ CCMD (idclev)
{
int epsd, map;
char buf[2];
char *mapname;
FString mapname;
buf[0] = argv[1][0] - '0';
buf[1] = argv[1][1] - '0';
@ -283,9 +283,9 @@ CCMD (hxvisit)
if ((argv.argc() > 1) && (*(argv[1] + 2) == 0) && *(argv[1] + 1) && *argv[1])
{
char mapname[9];
FString mapname("&wt@");
sprintf (mapname, "&wt@%c%c", argv[1][0], argv[1][1]);
mapname << argv[1][0] << argv[1][1];
if (CheckWarpTransMap (mapname, false))
{

View file

@ -1174,7 +1174,7 @@ void C_DrawConsole (bool hw2d)
if (TickerLabel)
{
tickbegin = (int)strlen (TickerLabel) + 2;
sprintf (tickstr, "%s: ", TickerLabel);
mysnprintf (tickstr, countof(tickstr), "%s: ", TickerLabel);
}
if (tickend > 256 - ConFont->GetCharWidth(0x12))
tickend = 256 - ConFont->GetCharWidth(0x12);
@ -1184,7 +1184,8 @@ void C_DrawConsole (bool hw2d)
tickstr[tickend + 2] = ' ';
if (TickerPercent)
{
sprintf (tickstr + tickend + 3, "%d%%", Scale (TickerAt, 100, TickerMax));
mysnprintf (tickstr + tickend + 3, countof(tickstr) - tickend - 3,
"%d%%", Scale (TickerAt, 100, TickerMax));
}
else
{

View file

@ -268,15 +268,15 @@ char *FBaseCVar::ToString (UCVarValue value, ECVarType type)
return value.String;
case CVAR_Int:
sprintf (cstrbuf, "%i", value.Int);
mysnprintf (cstrbuf, countof(cstrbuf), "%i", value.Int);
break;
case CVAR_Float:
sprintf (cstrbuf, "%g", value.Float);
mysnprintf (cstrbuf, countof(cstrbuf), "%g", value.Float);
break;
case CVAR_GUID:
FormatGUID (cstrbuf, *value.pGUID);
FormatGUID (cstrbuf, countof(cstrbuf), *value.pGUID);
break;
default:
@ -356,7 +356,7 @@ UCVarValue FBaseCVar::FromInt (int value, ECVarType type)
break;
case CVAR_String:
sprintf (cstrbuf, "%i", value);
mysnprintf (cstrbuf, countof(cstrbuf), "%i", value);
ret.String = cstrbuf;
break;
@ -390,7 +390,7 @@ UCVarValue FBaseCVar::FromFloat (float value, ECVarType type)
break;
case CVAR_String:
sprintf (cstrbuf, "%g", value);
mysnprintf (cstrbuf, countof(cstrbuf), "%g", value);
ret.String = cstrbuf;
break;
@ -891,7 +891,7 @@ UCVarValue FColorCVar::FromInt2 (int value, ECVarType type)
if (type == CVAR_String)
{
UCVarValue ret;
sprintf (cstrbuf, "%02x %02x %02x",
mysnprintf (cstrbuf, countof(cstrbuf), "%02x %02x %02x",
RPART(value), GPART(value), BPART(value));
ret.String = cstrbuf;
return ret;

View file

@ -246,13 +246,13 @@ static int ListActionCommands (const char *pattern)
for (i = 0; i < NUM_ACTIONS; ++i)
{
if (pattern == NULL || CheckWildcards (pattern,
(sprintf (matcher, "+%s", ActionMaps[i].Name), matcher)))
(mysnprintf (matcher, countof(matcher), "+%s", ActionMaps[i].Name), matcher)))
{
Printf ("+%s\n", ActionMaps[i].Name);
count++;
}
if (pattern == NULL || CheckWildcards (pattern,
(sprintf (matcher, "-%s", ActionMaps[i].Name), matcher)))
(mysnprintf (matcher, countof(matcher), "-%s", ActionMaps[i].Name), matcher)))
{
Printf ("-%s\n", ActionMaps[i].Name);
count++;

View file

@ -351,7 +351,7 @@ static FStringProd *DoubleToString (FProduction *prod)
char buf[128];
FStringProd *newprod;
sprintf (buf, "%g", static_cast<FDoubleProd *>(prod)->Value);
mysnprintf (buf, countof(buf), "%g", static_cast<FDoubleProd *>(prod)->Value);
newprod = NewStringProd (buf);
M_Free (prod);
return newprod;

View file

@ -315,9 +315,9 @@ bool CheckWildcards (const char *pattern, const char *text)
// [RH] Print a GUID to a text buffer using the standard format.
void FormatGUID (char *text, const GUID &guid)
void FormatGUID (char *buffer, size_t buffsize, const GUID &guid)
{
sprintf (text, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
mysnprintf (buffer, buffsize, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
(uint32)guid.Data1, guid.Data2, guid.Data3,
guid.Data4[0], guid.Data4[1],
guid.Data4[2], guid.Data4[3],
@ -375,7 +375,7 @@ void CreatePath(const char * fn)
if (c!='\\' && c!='/')
{
sprintf(name, "%s/", fn);
mysnprintf(name, countof(name), "%s/", fn);
DoCreatePath(name);
}
else DoCreatePath(fn);

View file

@ -48,7 +48,7 @@ void ReplaceString (char **ptr, const char *str);
bool CheckWildcards (const char *pattern, const char *text);
void FormatGUID (char *text, const GUID &guid);
void FormatGUID (char *buffer, size_t buffsize, const GUID &guid);
const char *myasctime ();

View file

@ -99,12 +99,6 @@ ACTOR(PlayerSkinCheck)
ACTOR(QueueCorpse)
ACTOR(DeQueueCorpse)
ACTOR(SetGravity)
// Special code pointers for Strife's player - not to be used elsewhere!
ACTOR(ItBurnsItBurns)
ACTOR(CrispyPlayer)
ACTOR(DropFire)
ACTOR(ClearTarget)
ACTOR(LookEx)
ACTOR(JumpIfTargetInLOS)
@ -113,3 +107,54 @@ ACTOR(DamageChildren)
ACTOR(CheckForReload)
ACTOR(ResetReloadCounter)
ACTOR(ClearReFire)
// Heretic stuff
ACTOR(Feathers)
ACTOR(BeakRaise)
ACTOR(BeakAttackPL1)
ACTOR(BeakAttackPL2)
ACTOR(Sor1Pain)
ACTOR(Sor1Chase)
ACTOR(Srcr1Attack)
ACTOR(SorcererRise)
ACTOR(Srcr2Decide)
ACTOR(Srcr2Attack)
ACTOR(Sor2DthInit)
ACTOR(Sor2DthLoop)
ACTOR(BlueSpark)
ACTOR(GenWizard)
ACTOR(TimeBomb)
ACTOR(ImpDeath)
ACTOR(ImpXDeath1)
ACTOR(ImpExplode)
ACTOR(PodPain)
ACTOR(RemovePod)
ACTOR(MakePod)
ACTOR(AccTeleGlitter)
ACTOR(VolcanoSet)
ACTOR(VolcanoBlast)
ACTOR(VolcBallImpact)
ACTOR(LichAttack)
ACTOR(LichIceImpact)
ACTOR(LichFireGrow)
ACTOR(WhirlwindSeek)
ACTOR(KnightAttack)
ACTOR(DripBlood)
ACTOR(GhostOff)
ACTOR(WizAtk1)
ACTOR(WizAtk2)
ACTOR(WizAtk3)
ACTOR(StaffAttack)
ACTOR(FireGoldWandPL1)
ACTOR(FireGoldWandPL2)
ACTOR(FireCrossbowPL1)
ACTOR(FireCrossbowPL2)
ACTOR(GauntletAttack)
// Special code pointers for Strife's player - not to be used elsewhere!
ACTOR(ItBurnsItBurns)
ACTOR(CrispyPlayer)
ACTOR(DropFire)

View file

@ -55,7 +55,7 @@ static void CT_ClearChatMessage ();
static void CT_AddChar (char c);
static void CT_BackSpace ();
static void ShoveChatStr (const char *str, BYTE who);
static bool DoSubstitution (char *out, const char *in);
static bool DoSubstitution (FString &out, const char *in);
static int len;
static BYTE ChatQueue[QUEUESIZE];
@ -309,7 +309,7 @@ static void CT_ClearChatMessage ()
static void ShoveChatStr (const char *str, BYTE who)
{
char substBuff[256];
FString substBuff;
if (str[0] == '/' &&
(str[1] == 'm' || str[1] == 'M') &&
@ -341,20 +341,20 @@ static void ShoveChatStr (const char *str, BYTE who)
//
//===========================================================================
static bool DoSubstitution (char *out, const char *in)
static bool DoSubstitution (FString &out, const char *in)
{
player_t *player = &players[consoleplayer];
AWeapon *weapon = player->ReadyWeapon;
const char *a, *b;
a = in;
while ((b = strchr (a, '$')))
out = "";
while ( (b = strchr(a, '$')) )
{
strncpy (out, a, b - a);
out += b - a;
out.AppendCStrPart(a, b - a);
a = ++b;
while (*b && isalpha (*b))
while (*b && isalpha(*b))
{
++b;
}
@ -363,71 +363,69 @@ static bool DoSubstitution (char *out, const char *in)
if (len == 6)
{
if (strnicmp (a, "health", 6) == 0)
if (strnicmp(a, "health", 6) == 0)
{
out += sprintf (out, "%d", player->health);
out.AppendFormat("%d", player->health);
}
else if (strnicmp (a, "weapon", 6) == 0)
else if (strnicmp(a, "weapon", 6) == 0)
{
if (weapon == NULL)
{
out += sprintf (out, "no weapon");
out += "no weapon";
}
else
{
out += sprintf (out, "%s", weapon->GetClass()->TypeName.GetChars());
out += weapon->GetClass()->TypeName;
}
}
}
else if (len == 5)
{
if (strnicmp (a, "armor", 5) == 0)
if (strnicmp(a, "armor", 5) == 0)
{
AInventory *armor = player->mo->FindInventory<ABasicArmor>();
int armorpoints = armor != NULL ? armor->Amount : 0;
out += sprintf (out, "%d", armorpoints);
out.AppendFormat("%d", armor != NULL ? armor->Amount : 0);
}
}
else if (len == 9)
{
if (strnicmp (a, "ammocount", 9) == 0)
if (strnicmp(a, "ammocount", 9) == 0)
{
if (weapon == NULL)
{
out += sprintf (out, "0");
out += '0';
}
else
{
out += sprintf (out, "%d", weapon->Ammo1 != NULL ? weapon->Ammo1->Amount : 0);
out.AppendFormat("%d", weapon->Ammo1 != NULL ? weapon->Ammo1->Amount : 0);
if (weapon->Ammo2 != NULL)
{
out += sprintf (out, "/%d", weapon->Ammo2->Amount);
out.AppendFormat("/%d", weapon->Ammo2->Amount);
}
}
}
}
else if (len == 4)
{
if (strnicmp (a, "ammo", 4) == 0)
if (strnicmp(a, "ammo", 4) == 0)
{
if (weapon == NULL || weapon->Ammo1 == NULL)
{
out += sprintf (out, "no ammo");
out += "no ammo";
}
else
{
out += sprintf (out, "%s", weapon->Ammo1->GetClass()->TypeName.GetChars());
out.AppendFormat("%s", weapon->Ammo1->GetClass()->TypeName.GetChars());
if (weapon->Ammo2 != NULL)
{
out += sprintf (out, "/%s", weapon->Ammo2->GetClass()->TypeName.GetChars());
out.AppendFormat("/%s", weapon->Ammo2->GetClass()->TypeName.GetChars());
}
}
}
}
else if (len == 0)
{
*out++ = '$';
*out = 0;
out += '$';
if (*b == '$')
{
b++;
@ -435,9 +433,8 @@ static bool DoSubstitution (char *out, const char *in)
}
else
{
*out++ = '$';
strncpy (out, a, len);
out += len;
out += '$';
out.AppendCStrPart(a, len);
}
a = b;
}
@ -448,7 +445,7 @@ static bool DoSubstitution (char *out, const char *in)
return false;
}
strcpy (out, a);
out += a;
return true;
}

View file

@ -1755,11 +1755,11 @@ static int PatchPars (int dummy)
if (moredata) {
// At least 3 items on this line, must be E?M? format
sprintf (mapname, "E%cM%c", *Line2, *space);
mysnprintf (mapname, countof(mapname), "E%cM%c", *Line2, *space);
par = atoi (moredata + 1);
} else {
// Only 2 items, must be MAP?? format
sprintf (mapname, "MAP%02d", atoi(Line2) % 100);
mysnprintf (mapname, countof(mapname), "MAP%02d", atoi(Line2) % 100);
par = atoi (space);
}
@ -1939,7 +1939,7 @@ static int PatchText (int oldSize)
{ // Music names are never >6 chars
char musname[9];
level_info_t *info = LevelInfos;
sprintf (musname, "d_%s", oldStr);
mysnprintf (musname, countof(musname), "d_%s", oldStr);
while (info->level_name)
{
@ -2577,7 +2577,7 @@ void FinishDehPatch ()
// Create a new class that will serve as the actual pickup
char typeNameBuilder[32];
sprintf (typeNameBuilder, "DehackedPickup%d", touchedIndex);
mysnprintf (typeNameBuilder, countof(typeNameBuilder), "DehackedPickup%d", touchedIndex);
PClass *subclass = RUNTIME_CLASS(ADehackedPickup)->CreateDerivedClass
(typeNameBuilder, sizeof(ADehackedPickup));
AActor *defaults2 = GetDefaultByType (subclass);

View file

@ -187,7 +187,7 @@ bool devparm; // started game with -devparm
const char *D_DrawIcon; // [RH] Patch name of icon to draw on next refresh
int NoWipe; // [RH] Allow wipe? (Needs to be set each time)
bool singletics = false; // debug flag to cancel adaptiveness
char startmap[8];
FString startmap;
bool autostart;
bool advancedemo;
FILE *debugfile;
@ -1053,7 +1053,7 @@ void D_DoAdvanceDemo (void)
{
BorderNeedRefresh = screen->GetPageCount ();
democount++;
sprintf (demoname + 4, "%d", democount);
mysnprintf (demoname + 4, countof(demoname) - 4, "%d", democount);
if (Wads.CheckNumForName (demoname) < 0)
{
demosequence = 0;
@ -1865,7 +1865,7 @@ static const char *BaseFileSearch (const char *file, const char *ext, bool lookf
if (lookfirstinprogdir)
{
sprintf (wad, "%s%s%s", progdir.GetChars(), progdir[progdir.Len() - 1] != '/' ? "/" : "", file);
mysnprintf (wad, countof(wad), "%s%s%s", progdir.GetChars(), progdir[progdir.Len() - 1] != '/' ? "/" : "", file);
if (FileExists (wad))
{
return wad;
@ -1874,7 +1874,7 @@ static const char *BaseFileSearch (const char *file, const char *ext, bool lookf
if (FileExists (file))
{
sprintf (wad, "%s", file);
mysnprintf (wad, countof(wad), "%s", file);
return wad;
}
@ -1914,7 +1914,7 @@ static const char *BaseFileSearch (const char *file, const char *ext, bool lookf
}
if (dir != NULL)
{
sprintf (wad, "%s%s%s", dir, dir[strlen (dir) - 1] != '/' ? "/" : "", file);
mysnprintf (wad, countof(wad), "%s%s%s", dir, dir[strlen (dir) - 1] != '/' ? "/" : "", file);
if (FileExists (wad))
{
return wad;
@ -2246,11 +2246,11 @@ void D_DoomMain (void)
// get skill / episode / map from parms
if (gameinfo.gametype != GAME_Hexen)
{
strcpy (startmap, (gameinfo.flags & GI_MAPxx) ? "MAP01" : "E1M1");
startmap = (gameinfo.flags & GI_MAPxx) ? "MAP01" : "E1M1";
}
else
{
strcpy (startmap, "&wt@01");
startmap = "&wt@01";
}
autostart = false;
@ -2282,7 +2282,7 @@ void D_DoomMain (void)
}
}
strncpy (startmap, CalcMapName (ep, map), 8);
startmap = CalcMapName (ep, map);
autostart = true;
}
@ -2296,7 +2296,7 @@ void D_DoomMain (void)
}
else
{
strncpy (startmap, Args->GetArg (p+1), 8);
startmap = Args->GetArg (p + 1);
Args->GetArg (p)[0] = '-';
autostart = true;
}
@ -2358,7 +2358,7 @@ void D_DoomMain (void)
if (autostart)
{
FString temp;
temp.Format ("Warp to map %s, Skill %d ", startmap, gameskill + 1);
temp.Format ("Warp to map %s, Skill %d ", startmap.GetChars(), gameskill + 1);
StartScreen->AppendStatusLine(temp);
}

View file

@ -1379,7 +1379,7 @@ bool DoArbitrate (void *userdata)
stream = &netbuffer[4];
s = ReadString (&stream);
strncpy (startmap, s, 8);
startmap = FString(s, 8);
delete[] s;
rngseed = ReadLong (&stream);
C_ReadCVars (&stream);
@ -1600,10 +1600,10 @@ void D_CheckNetGame (void)
if (Args->CheckParm ("-debugfile"))
{
char filename[20];
sprintf (filename,"debug%i.txt",consoleplayer);
Printf ("debug output to: %s\n",filename);
debugfile = fopen (filename,"w");
char filename[20];
mysnprintf (filename, countof(filename), "debug%i.txt", consoleplayer);
Printf ("debug output to: %s\n", filename);
debugfile = fopen (filename, "w");
}
if (netgame)

View file

@ -411,7 +411,7 @@ void D_UserInfoChanged (FBaseCVar *cvar)
if (4 + strlen(cvar->GetName()) + escaped_val.Len() > 256)
I_Error ("User info descriptor too big");
sprintf (foo, "\\%s\\%s", cvar->GetName(), escaped_val.GetChars());
mysnprintf (foo, countof(foo), "\\%s\\%s", cvar->GetName(), escaped_val.GetChars());
Net_WriteByte (DEM_UINFCHANGED);
Net_WriteString (foo);

View file

@ -145,7 +145,14 @@ void PClass::StaticFreeData (PClass *type)
delete type->ActorInfo;
type->ActorInfo = NULL;
}
delete type;
if (type->bRuntimeClass != 2)
{
delete type;
}
else
{
type->Symbols.ReleaseSymbols();
}
}
else
{
@ -290,6 +297,42 @@ PClass *PClass::CreateDerivedClass (FName name, unsigned int size)
return type;
}
// This is used by DECORATE to assign ActorInfos to internal classes
void PClass::InitializeActorInfo ()
{
Symbols.SetParentTable (&ParentClass->Symbols);
Defaults = new BYTE[Size];
if (ParentClass->Defaults != NULL)
{
memcpy (Defaults, ParentClass->Defaults, Size);
if (Size > ParentClass->Size)
{
memset (Defaults + ParentClass->Size, 0, Size - ParentClass->Size);
}
}
else
{
memset (Defaults, 0, Size);
}
bRuntimeClass = 2; // Class is internal but actor data external
FActorInfo *info = ActorInfo = new FActorInfo;
info->Class = this;
info->GameFilter = GAME_Any;
info->SpawnID = 0;
info->DoomEdNum = -1;
info->OwnedStates = NULL;
info->NumOwnedStates = 0;
info->Replacement = NULL;
info->Replacee = NULL;
info->StateList = NULL;
info->DamageFactors = NULL;
info->PainChances = NULL;
m_RuntimeActors.Push (this);
}
// Create the FlatPointers array, if it doesn't exist already.
// It comprises all the Pointers from superclasses plus this class's own Pointers.
// If this class does not define any new Pointers, then FlatPointers will be set

View file

@ -103,7 +103,7 @@ struct PClass
PClass *HashNext;
FMetaTable Meta;
BYTE *Defaults;
bool bRuntimeClass; // class was defined at run-time, not compile-time
BYTE bRuntimeClass; // class was defined at run-time, not compile-time
unsigned short ClassIndex;
PSymbolTable Symbols;
@ -113,6 +113,7 @@ struct PClass
void InsertIntoHash ();
DObject *CreateNew () const;
PClass *CreateDerivedClass (FName name, unsigned int size);
void InitializeActorInfo ();
void BuildFlatPointers ();
void FreeStateList();

View file

@ -68,7 +68,7 @@ extern GameMission_t gamemission;
// Selected skill type, map etc.
//
extern char startmap[8]; // [RH] Actual map name now
extern FString startmap; // [RH] Actual map name now
extern bool autostart;

View file

@ -153,23 +153,23 @@ enum
//
// Fixed point, 32bit as 16.16.
//
#define FRACBITS 16
#define FRACUNIT (1<<FRACBITS)
#define FRACBITS 16
#define FRACUNIT (1<<FRACBITS)
typedef SDWORD fixed_t;
typedef DWORD dsfixed_t; // fixedpt used by span drawer
typedef SDWORD fixed_t;
typedef DWORD dsfixed_t; // fixedpt used by span drawer
#define FIXED_MAX (signed)(0x7fffffff)
#define FIXED_MIN (signed)(0x80000000)
#define FIXED_MAX (signed)(0x7fffffff)
#define FIXED_MIN (signed)(0x80000000)
#define DWORD_MIN ((uint32)0)
#define DWORD_MAX ((uint32)0xffffffff)
#ifdef __GNUC__
#define GCCPRINTF(stri,firstargi) __attribute__((format(printf,stri,firstargi)))
#define GCCFORMAT(stri) __attribute__((format(printf,stri,0)))
#define GCCNOWARN __attribute__((unused))
#define GCCPRINTF(stri,firstargi) __attribute__((format(printf,stri,firstargi)))
#define GCCFORMAT(stri) __attribute__((format(printf,stri,0)))
#define GCCNOWARN __attribute__((unused))
#else
#define GCCPRINTF(a,b)
#define GCCFORMAT(a)
@ -184,6 +184,10 @@ int STACK_ARGS Printf (const char *, ...) GCCPRINTF(1,2);
// [RH] Same here:
int STACK_ARGS DPrintf (const char *, ...) GCCPRINTF(1,2);
extern "C" int mysnprintf(char *buffer, size_t count, const char *format, ...) GCCPRINTF(3,4);
extern "C" int myvsnprintf(char *buffer, size_t count, const char *format, va_list argptr) GCCFORMAT(3);
// game print flags
enum
{

View file

@ -997,7 +997,7 @@ void F_BunnyScroll (void)
laststage = stage;
}
sprintf (name, "END%d", (int)stage);
mysnprintf (name, countof(name), "END%d", (int)stage);
screen->DrawTexture (TexMan(name), (320-13*8)/2, (200-8*8)/2, DTA_320x200, true, TAG_DONE);
}
}

View file

@ -1960,13 +1960,13 @@ static void PutSaveComment (FILE *file)
// Get level name
//strcpy (comment, level.level_name);
sprintf(comment, "%s - %s", level.mapname, level.level_name);
mysnprintf(comment, countof(comment), "%s - %s", level.mapname, level.level_name);
len = (WORD)strlen (comment);
comment[len] = '\n';
// Append elapsed time
levelTime = level.time / TICRATE;
sprintf (comment+len+1, "time: %02d:%02d:%02d",
mysnprintf (comment + len + 1, countof(comment) - len - 1, "time: %02d:%02d:%02d",
levelTime/3600, (levelTime%3600)/60, levelTime%60);
comment[len+16] = 0;

View file

@ -12,166 +12,22 @@
#include "d_event.h"
#include "gstrings.h"
void P_UpdateBeak (AActor *actor);
static FRandom pr_chickenplayerthink ("ChickenPlayerThink");
static FRandom pr_chicattack ("ChicAttack");
static FRandom pr_feathers ("Feathers");
static FRandom pr_beakatkpl1 ("BeakAtkPL1");
static FRandom pr_beakatkpl2 ("BeakAtkPL2");
void A_BeakRaise (AActor *);
void A_BeakAttackPL1 (AActor *);
void A_BeakAttackPL2 (AActor *);
void A_Feathers (AActor *);
void A_ChicAttack (AActor *);
void P_UpdateBeak (AActor *);
// Beak puff ----------------------------------------------------------------
class ABeakPuff : public AStaffPuff
{
DECLARE_STATELESS_ACTOR (ABeakPuff, AStaffPuff)
public:
void BeginPlay ();
};
IMPLEMENT_STATELESS_ACTOR (ABeakPuff, Heretic, -1, 0)
PROP_Mass (5)
PROP_RenderStyle (STYLE_Translucent)
PROP_Alpha (HR_SHADOW)
PROP_AttackSound ("chicken/attack")
END_DEFAULTS
void ABeakPuff::BeginPlay ()
{
Super::BeginPlay ();
momz = FRACUNIT;
}
// Beak ---------------------------------------------------------------------
class ABeak : public AWeapon
{
DECLARE_ACTOR (ABeak, AWeapon)
};
class ABeakPowered : public ABeak
{
DECLARE_STATELESS_ACTOR (ABeakPowered, ABeak)
};
FState ABeak::States[] =
{
#define S_BEAKREADY 0
S_NORMAL (BEAK, 'A', 1, A_WeaponReady , &States[S_BEAKREADY]),
#define S_BEAKDOWN (S_BEAKREADY+1)
S_NORMAL (BEAK, 'A', 1, A_Lower , &States[S_BEAKDOWN]),
#define S_BEAKUP (S_BEAKDOWN+1)
S_NORMAL (BEAK, 'A', 1, A_BeakRaise , &States[S_BEAKUP]),
#define S_BEAKATK1 (S_BEAKUP+1)
S_NORMAL (BEAK, 'A', 18, A_BeakAttackPL1 , &States[S_BEAKREADY]),
#define S_BEAKATK2 (S_BEAKATK1+1)
S_NORMAL (BEAK, 'A', 12, A_BeakAttackPL2 , &States[S_BEAKREADY])
};
IMPLEMENT_ACTOR (ABeak, Heretic, -1, 0)
PROP_Weapon_SelectionOrder (10000)
PROP_Weapon_Flags (WIF_DONTBOB|WIF_BOT_MELEE)
PROP_Weapon_UpState (S_BEAKUP)
PROP_Weapon_DownState (S_BEAKDOWN)
PROP_Weapon_ReadyState (S_BEAKREADY)
PROP_Weapon_AtkState (S_BEAKATK1)
PROP_Weapon_HoldAtkState (S_BEAKATK1)
PROP_Weapon_YAdjust (15)
PROP_Weapon_SisterType ("BeakPowered")
END_DEFAULTS
IMPLEMENT_STATELESS_ACTOR (ABeakPowered, Heretic, -1, 0)
PROP_Weapon_Flags (WIF_DONTBOB|WIF_BOT_MELEE|WIF_POWERED_UP)
PROP_Weapon_AtkState (S_BEAKATK2)
PROP_Weapon_HoldAtkState (S_BEAKATK2)
PROP_Weapon_SisterType ("Beak")
END_DEFAULTS
// Chicken player -----------------------------------------------------------
class AChickenPlayer : public APlayerPawn
{
DECLARE_ACTOR (AChickenPlayer, APlayerPawn)
DECLARE_CLASS (AChickenPlayer, APlayerPawn)
public:
void MorphPlayerThink ();
};
FState AChickenPlayer::States[] =
{
#define S_CHICPLAY 0
S_NORMAL (CHKN, 'A', -1, NULL , NULL),
#define S_CHICPLAY_RUN (S_CHICPLAY+1)
S_NORMAL (CHKN, 'A', 3, NULL , &States[S_CHICPLAY_RUN+1]),
S_NORMAL (CHKN, 'B', 3, NULL , &States[S_CHICPLAY_RUN+2]),
S_NORMAL (CHKN, 'A', 3, NULL , &States[S_CHICPLAY_RUN+3]),
S_NORMAL (CHKN, 'B', 3, NULL , &States[S_CHICPLAY_RUN+0]),
#define S_CHICPLAY_ATK (S_CHICPLAY_RUN+4)
S_NORMAL (CHKN, 'C', 12, NULL , &States[S_CHICPLAY]),
#define S_CHICPLAY_PAIN (S_CHICPLAY_ATK+1)
S_NORMAL (CHKN, 'D', 4, A_Feathers , &States[S_CHICPLAY_PAIN+1]),
S_NORMAL (CHKN, 'C', 4, A_Pain , &States[S_CHICPLAY]),
#define S_CHICPLAY_DIE (S_CHICPLAY_PAIN+2)
S_NORMAL (CHKN, 'E', 6, A_Scream , &States[S_CHICPLAY_DIE+1]),
S_NORMAL (CHKN, 'F', 6, A_Feathers , &States[S_CHICPLAY_DIE+2]),
S_NORMAL (CHKN, 'G', 6, NULL , &States[S_CHICPLAY_DIE+3]),
S_NORMAL (CHKN, 'H', 6, A_NoBlocking , &States[S_CHICPLAY_DIE+4]),
S_NORMAL (CHKN, 'I', 6, NULL , &States[S_CHICPLAY_DIE+5]),
S_NORMAL (CHKN, 'J', 6, NULL , &States[S_CHICPLAY_DIE+6]),
S_NORMAL (CHKN, 'K', 6, NULL , &States[S_CHICPLAY_DIE+7]),
S_NORMAL (CHKN, 'L', -1, NULL , NULL)
};
IMPLEMENT_ACTOR (AChickenPlayer, Heretic, -1, 0)
PROP_SpawnHealth (30)
PROP_RadiusFixed (16)
PROP_HeightFixed (24)
PROP_PainChance (255)
PROP_SpeedFixed (1)
PROP_Gravity (FRACUNIT/8)
PROP_Flags (MF_SOLID|MF_SHOOTABLE|MF_DROPOFF|MF_NOTDMATCH|MF_FRIENDLY)
PROP_Flags2 (MF2_WINDTHRUST|MF2_SLIDE|MF2_PASSMOBJ|MF2_PUSHWALL|MF2_FLOORCLIP|MF2_TELESTOMP)
PROP_Flags3 (MF3_NOBLOCKMONST)
PROP_Flags4 (MF4_NOSKIN)
PROP_SpawnState (S_CHICPLAY)
PROP_SeeState (S_CHICPLAY_RUN)
PROP_PainState (S_CHICPLAY_PAIN)
PROP_MissileState (S_CHICPLAY_ATK)
PROP_MeleeState (S_CHICPLAY_ATK)
PROP_DeathState (S_CHICPLAY_DIE)
// [GRB]
PROP_PlayerPawn_JumpZ (FRACUNIT)
PROP_PlayerPawn_ViewHeight (21*FRACUNIT)
PROP_PlayerPawn_ForwardMove1 (FRACUNIT * 2500 / 2048)
PROP_PlayerPawn_ForwardMove2 (FRACUNIT * 2500 / 2048)
PROP_PlayerPawn_SideMove1 (FRACUNIT * 2500 / 2048)
PROP_PlayerPawn_SideMove2 (FRACUNIT * 2500 / 2048)
PROP_PlayerPawn_MorphWeapon ("Beak")
PROP_PainSound ("chicken/pain")
PROP_DeathSound ("chicken/death")
END_DEFAULTS
AT_GAME_SET(ChickenPlayer)
{
RUNTIME_CLASS(AChickenPlayer)->Meta.SetMetaString(APMETA_SoundClass, "chicken");
}
IMPLEMENT_CLASS(AChickenPlayer)
void AChickenPlayer::MorphPlayerThink ()
{
@ -200,102 +56,6 @@ void AChickenPlayer::MorphPlayerThink ()
}
}
// Chicken (non-player) -----------------------------------------------------
class AChicken : public AMorphedMonster
{
DECLARE_ACTOR (AChicken, AMorphedMonster)
};
FState AChicken::States[] =
{
#define S_CHICKEN_LOOK 0
S_NORMAL (CHKN, 'A', 10, A_Look , &States[S_CHICKEN_LOOK+1]),
S_NORMAL (CHKN, 'B', 10, A_Look , &States[S_CHICKEN_LOOK+0]),
#define S_CHICKEN_WALK (S_CHICKEN_LOOK+2)
S_NORMAL (CHKN, 'A', 3, A_Chase , &States[S_CHICKEN_WALK+1]),
S_NORMAL (CHKN, 'B', 3, A_Chase , &States[S_CHICKEN_WALK+0]),
#define S_CHICKEN_PAIN (S_CHICKEN_WALK+2)
S_NORMAL (CHKN, 'D', 5, A_Feathers , &States[S_CHICKEN_PAIN+1]),
S_NORMAL (CHKN, 'C', 5, A_Pain , &States[S_CHICKEN_WALK+0]),
#define S_CHICKEN_ATK (S_CHICKEN_PAIN+2)
S_NORMAL (CHKN, 'A', 8, A_FaceTarget , &States[S_CHICKEN_ATK+1]),
S_NORMAL (CHKN, 'C', 10, A_ChicAttack , &States[S_CHICKEN_WALK+0]),
#define S_CHICKEN_DIE (S_CHICKEN_ATK+2)
S_NORMAL (CHKN, 'E', 6, A_Scream , &States[S_CHICKEN_DIE+1]),
S_NORMAL (CHKN, 'F', 6, A_Feathers , &States[S_CHICKEN_DIE+2]),
S_NORMAL (CHKN, 'G', 6, NULL , &States[S_CHICKEN_DIE+3]),
S_NORMAL (CHKN, 'H', 6, A_NoBlocking , &States[S_CHICKEN_DIE+4]),
S_NORMAL (CHKN, 'I', 6, NULL , &States[S_CHICKEN_DIE+5]),
S_NORMAL (CHKN, 'J', 6, NULL , &States[S_CHICKEN_DIE+6]),
S_NORMAL (CHKN, 'K', 6, NULL , &States[S_CHICKEN_DIE+7]),
S_NORMAL (CHKN, 'L', -1, NULL , NULL)
};
IMPLEMENT_ACTOR (AChicken, Heretic, -1, 122)
PROP_SpawnHealth (10)
PROP_RadiusFixed (9)
PROP_HeightFixed (22)
PROP_Mass (40)
PROP_SpeedFixed (4)
PROP_PainChance (200)
PROP_Flags (MF_SOLID|MF_SHOOTABLE)
PROP_Flags2 (MF2_MCROSS|MF2_WINDTHRUST|MF2_FLOORCLIP|MF2_PASSMOBJ|MF2_PUSHWALL)
PROP_Flags3 (MF3_DONTMORPH|MF3_ISMONSTER)
PROP_SpawnState (S_CHICKEN_LOOK)
PROP_SeeState (S_CHICKEN_WALK)
PROP_PainState (S_CHICKEN_PAIN)
PROP_MeleeState (S_CHICKEN_ATK)
PROP_DeathState (S_CHICKEN_DIE)
PROP_SeeSound ("chicken/pain")
PROP_AttackSound ("chicken/attack")
PROP_PainSound ("chicken/pain")
PROP_DeathSound ("chicken/death")
PROP_ActiveSound ("chicken/active")
PROP_Obituary("$OB_CHICKEN")
END_DEFAULTS
// Feather ------------------------------------------------------------------
class AFeather : public AActor
{
DECLARE_ACTOR (AFeather, AActor)
};
FState AFeather::States[] =
{
#define S_FEATHER 0
S_NORMAL (CHKN, 'M', 3, NULL , &States[S_FEATHER+1]),
S_NORMAL (CHKN, 'N', 3, NULL , &States[S_FEATHER+2]),
S_NORMAL (CHKN, 'O', 3, NULL , &States[S_FEATHER+3]),
S_NORMAL (CHKN, 'P', 3, NULL , &States[S_FEATHER+4]),
S_NORMAL (CHKN, 'Q', 3, NULL , &States[S_FEATHER+5]),
S_NORMAL (CHKN, 'P', 3, NULL , &States[S_FEATHER+6]),
S_NORMAL (CHKN, 'O', 3, NULL , &States[S_FEATHER+7]),
S_NORMAL (CHKN, 'N', 3, NULL , &States[S_FEATHER+0]),
#define S_FEATHERX (S_FEATHER+8)
S_NORMAL (CHKN, 'N', 6, NULL , NULL)
};
IMPLEMENT_ACTOR (AFeather, Heretic, -1, 121)
PROP_RadiusFixed (2)
PROP_HeightFixed (4)
PROP_Gravity (FRACUNIT/8)
PROP_Flags (MF_MISSILE|MF_DROPOFF)
PROP_Flags2 (MF2_NOTELEPORT|MF2_CANNOTPUSH|MF2_WINDTHRUST)
PROP_Flags3 (MF3_DONTSPLASH)
PROP_SpawnState (S_FEATHER)
PROP_DeathState (S_FEATHERX)
END_DEFAULTS
//----------------------------------------------------------------------------
//
// PROC A_ChicAttack
@ -338,12 +98,12 @@ void A_Feathers (AActor *actor)
}
for (i = 0; i < count; i++)
{
mo = Spawn<AFeather> (actor->x, actor->y, actor->z+20*FRACUNIT, NO_REPLACE);
mo = Spawn("Feather", actor->x, actor->y, actor->z+20*FRACUNIT, NO_REPLACE);
mo->target = actor;
mo->momx = pr_feathers.Random2() << 8;
mo->momy = pr_feathers.Random2() << 8;
mo->momz = FRACUNIT + (pr_feathers() << 9);
mo->SetState (&AFeather::States[S_FEATHER+(pr_feathers()&7)]);
mo->SetState (mo->SpawnState + (pr_feathers()&7));
}
}
@ -413,7 +173,7 @@ void A_BeakAttackPL1 (AActor *actor)
damage = 1 + (pr_beakatkpl1()&3);
angle = player->mo->angle;
slope = P_AimLineAttack (player->mo, angle, MELEERANGE, &linetarget);
P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, RUNTIME_CLASS(ABeakPuff), true);
P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, "BeakPuff", true);
if (linetarget)
{
player->mo->angle = R_PointToAngle2 (player->mo->x,
@ -446,7 +206,7 @@ void A_BeakAttackPL2 (AActor *actor)
damage = pr_beakatkpl2.HitDice (4);
angle = player->mo->angle;
slope = P_AimLineAttack (player->mo, angle, MELEERANGE, &linetarget);
P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, RUNTIME_CLASS(ABeakPuff), true);
P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, "BeakPuff", true);
if (linetarget)
{
player->mo->angle = R_PointToAngle2 (player->mo->x,

View file

@ -17,368 +17,6 @@ static FRandom pr_s2d ("Srcr2Decide");
static FRandom pr_s2a ("Srcr2Attack");
static FRandom pr_bluespark ("BlueSpark");
void A_Sor1Chase (AActor *);
void A_Sor1Pain (AActor *);
void A_Srcr1Attack (AActor *);
void A_SorZap (AActor *);
void A_SorcererRise (AActor *);
void A_SorRise (AActor *);
void A_SorSightSnd (AActor *);
void A_Srcr2Decide (AActor *);
void A_Srcr2Attack (AActor *);
void A_Sor2DthInit (AActor *);
void A_SorDSph (AActor *);
void A_Sor2DthLoop (AActor *);
void A_SorDExp (AActor *);
void A_SorDBon (AActor *);
void A_BlueSpark (AActor *);
void A_GenWizard (AActor *);
// Boss spot ----------------------------------------------------------------
class ABossSpot : public ASpecialSpot
{
DECLARE_STATELESS_ACTOR (ABossSpot, ASpecialSpot)
};
IMPLEMENT_STATELESS_ACTOR (ABossSpot, Heretic, 56, 141)
PROP_RenderFlags (RF_INVISIBLE)
END_DEFAULTS
// Sorcerer (D'Sparil on his serpent) ---------------------------------------
class ASorcerer1 : public AActor
{
DECLARE_ACTOR (ASorcerer1, AActor)
};
FState ASorcerer1::States[] =
{
#define S_SRCR1_LOOK 0
S_NORMAL (SRCR, 'A', 10, A_Look , &States[S_SRCR1_LOOK+1]),
S_NORMAL (SRCR, 'B', 10, A_Look , &States[S_SRCR1_LOOK+0]),
#define S_SRCR1_WALK (S_SRCR1_LOOK+2)
S_NORMAL (SRCR, 'A', 5, A_Sor1Chase , &States[S_SRCR1_WALK+1]),
S_NORMAL (SRCR, 'B', 5, A_Sor1Chase , &States[S_SRCR1_WALK+2]),
S_NORMAL (SRCR, 'C', 5, A_Sor1Chase , &States[S_SRCR1_WALK+3]),
S_NORMAL (SRCR, 'D', 5, A_Sor1Chase , &States[S_SRCR1_WALK+0]),
#define S_SRCR1_PAIN (S_SRCR1_WALK+4)
S_NORMAL (SRCR, 'Q', 6, A_Sor1Pain , &States[S_SRCR1_WALK+0]),
#define S_SRCR1_ATK (S_SRCR1_PAIN+1)
S_NORMAL (SRCR, 'Q', 7, A_FaceTarget , &States[S_SRCR1_ATK+1]),
S_NORMAL (SRCR, 'R', 6, A_FaceTarget , &States[S_SRCR1_ATK+2]),
S_NORMAL (SRCR, 'S', 10, A_Srcr1Attack , &States[S_SRCR1_WALK+0]),
S_NORMAL (SRCR, 'S', 10, A_FaceTarget , &States[S_SRCR1_ATK+4]),
S_NORMAL (SRCR, 'Q', 7, A_FaceTarget , &States[S_SRCR1_ATK+5]),
S_NORMAL (SRCR, 'R', 6, A_FaceTarget , &States[S_SRCR1_ATK+6]),
S_NORMAL (SRCR, 'S', 10, A_Srcr1Attack , &States[S_SRCR1_WALK+0]),
#define S_SRCR1_DIE (S_SRCR1_ATK+7)
S_NORMAL (SRCR, 'E', 7, NULL , &States[S_SRCR1_DIE+1]),
S_NORMAL (SRCR, 'F', 7, A_Scream , &States[S_SRCR1_DIE+2]),
S_NORMAL (SRCR, 'G', 7, NULL , &States[S_SRCR1_DIE+3]),
S_NORMAL (SRCR, 'H', 6, NULL , &States[S_SRCR1_DIE+4]),
S_NORMAL (SRCR, 'I', 6, NULL , &States[S_SRCR1_DIE+5]),
S_NORMAL (SRCR, 'J', 6, NULL , &States[S_SRCR1_DIE+6]),
S_NORMAL (SRCR, 'K', 6, NULL , &States[S_SRCR1_DIE+7]),
S_NORMAL (SRCR, 'L', 25, A_SorZap , &States[S_SRCR1_DIE+8]),
S_NORMAL (SRCR, 'M', 5, NULL , &States[S_SRCR1_DIE+9]),
S_NORMAL (SRCR, 'N', 5, NULL , &States[S_SRCR1_DIE+10]),
S_NORMAL (SRCR, 'O', 4, NULL , &States[S_SRCR1_DIE+11]),
S_NORMAL (SRCR, 'L', 20, A_SorZap , &States[S_SRCR1_DIE+12]),
S_NORMAL (SRCR, 'M', 5, NULL , &States[S_SRCR1_DIE+13]),
S_NORMAL (SRCR, 'N', 5, NULL , &States[S_SRCR1_DIE+14]),
S_NORMAL (SRCR, 'O', 4, NULL , &States[S_SRCR1_DIE+15]),
S_NORMAL (SRCR, 'L', 12, NULL , &States[S_SRCR1_DIE+16]),
S_NORMAL (SRCR, 'P', -1, A_SorcererRise , NULL)
};
IMPLEMENT_ACTOR (ASorcerer1, Heretic, 7, 142)
PROP_SpawnHealth (2000)
PROP_RadiusFixed (28)
PROP_HeightFixed (100)
PROP_Mass (800)
PROP_SpeedFixed (16)
PROP_PainChance (56)
PROP_Flags (MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL)
PROP_Flags2 (MF2_MCROSS|MF2_FLOORCLIP|MF2_PASSMOBJ|MF2_PUSHWALL|MF2_BOSS)
PROP_Flags3 (MF3_DONTMORPH|MF3_NORADIUSDMG|MF3_NOTARGET)
PROP_Flags4 (MF4_NOICEDEATH)
PROP_SpawnState (S_SRCR1_LOOK)
PROP_SeeState (S_SRCR1_WALK)
PROP_PainState (S_SRCR1_PAIN)
PROP_MissileState (S_SRCR1_ATK)
PROP_DeathState (S_SRCR1_DIE)
PROP_SeeSound ("dsparilserpent/sight")
PROP_AttackSound ("dsparilserpent/attack")
PROP_PainSound ("dsparilserpent/pain")
PROP_DeathSound ("dsparilserpent/death")
PROP_ActiveSound ("dsparilserpent/active")
PROP_Obituary("$OB_DSPARIL1")
PROP_HitObituary("$OB_DSPARIL1HIT")
END_DEFAULTS
// Sorcerer FX 1 ------------------------------------------------------------
class ASorcererFX1 : public AActor
{
DECLARE_ACTOR (ASorcererFX1, AActor)
};
FState ASorcererFX1::States[] =
{
#define S_SRCRFX1 0
S_BRIGHT (FX14, 'A', 6, NULL , &States[S_SRCRFX1+1]),
S_BRIGHT (FX14, 'B', 6, NULL , &States[S_SRCRFX1+2]),
S_BRIGHT (FX14, 'C', 6, NULL , &States[S_SRCRFX1+0]),
#define S_SRCRFXI1 (S_SRCRFX1+3)
S_BRIGHT (FX14, 'D', 5, NULL , &States[S_SRCRFXI1+1]),
S_BRIGHT (FX14, 'E', 5, NULL , &States[S_SRCRFXI1+2]),
S_BRIGHT (FX14, 'F', 5, NULL , &States[S_SRCRFXI1+3]),
S_BRIGHT (FX14, 'G', 5, NULL , &States[S_SRCRFXI1+4]),
S_BRIGHT (FX14, 'H', 5, NULL , NULL)
};
IMPLEMENT_ACTOR (ASorcererFX1, Heretic, -1, 144)
PROP_RadiusFixed (10)
PROP_HeightFixed (10)
PROP_SpeedFixed (20)
PROP_Damage (10)
PROP_DamageType (NAME_Fire)
PROP_Flags (MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY)
PROP_Flags2 (MF2_NOTELEPORT)
PROP_RenderStyle (STYLE_Add)
PROP_SpawnState (S_SRCRFX1)
PROP_DeathState (S_SRCRFXI1)
END_DEFAULTS
AT_SPEED_SET (SorcererFX1, speed)
{
SimpleSpeedSetter (ASorcererFX1, 20*FRACUNIT, 28*FRACUNIT, speed);
}
// Sorcerer 2 (D'Sparil without his serpent) --------------------------------
FState ASorcerer2::States[] =
{
#define S_SOR2_LOOK 0
S_NORMAL (SOR2, 'M', 10, A_Look , &States[S_SOR2_LOOK+1]),
S_NORMAL (SOR2, 'N', 10, A_Look , &States[S_SOR2_LOOK+0]),
#define S_SOR2_WALK (S_SOR2_LOOK+2)
S_NORMAL (SOR2, 'M', 4, A_Chase , &States[S_SOR2_WALK+1]),
S_NORMAL (SOR2, 'N', 4, A_Chase , &States[S_SOR2_WALK+2]),
S_NORMAL (SOR2, 'O', 4, A_Chase , &States[S_SOR2_WALK+3]),
S_NORMAL (SOR2, 'P', 4, A_Chase , &States[S_SOR2_WALK+0]),
#define S_SOR2_RISE (S_SOR2_WALK+4)
S_NORMAL (SOR2, 'A', 4, NULL , &States[S_SOR2_RISE+1]),
S_NORMAL (SOR2, 'B', 4, NULL , &States[S_SOR2_RISE+2]),
S_NORMAL (SOR2, 'C', 4, A_SorRise , &States[S_SOR2_RISE+3]),
S_NORMAL (SOR2, 'D', 4, NULL , &States[S_SOR2_RISE+4]),
S_NORMAL (SOR2, 'E', 4, NULL , &States[S_SOR2_RISE+5]),
S_NORMAL (SOR2, 'F', 4, NULL , &States[S_SOR2_RISE+6]),
S_NORMAL (SOR2, 'G', 12, A_SorSightSnd , &States[S_SOR2_WALK+0]),
#define S_SOR2_PAIN (S_SOR2_RISE+7)
S_NORMAL (SOR2, 'Q', 3, NULL , &States[S_SOR2_PAIN+1]),
S_NORMAL (SOR2, 'Q', 6, A_Pain , &States[S_SOR2_WALK+0]),
#define S_SOR2_ATK (S_SOR2_PAIN+2)
S_NORMAL (SOR2, 'R', 9, A_Srcr2Decide , &States[S_SOR2_ATK+1]),
S_NORMAL (SOR2, 'S', 9, A_FaceTarget , &States[S_SOR2_ATK+2]),
S_NORMAL (SOR2, 'T', 20, A_Srcr2Attack , &States[S_SOR2_WALK+0]),
#define S_SOR2_TELE (S_SOR2_ATK+3)
S_NORMAL (SOR2, 'L', 6, NULL , &States[S_SOR2_TELE+1]),
S_NORMAL (SOR2, 'K', 6, NULL , &States[S_SOR2_TELE+2]),
S_NORMAL (SOR2, 'J', 6, NULL , &States[S_SOR2_TELE+3]),
S_NORMAL (SOR2, 'I', 6, NULL , &States[S_SOR2_TELE+4]),
S_NORMAL (SOR2, 'H', 6, NULL , &States[S_SOR2_TELE+5]),
S_NORMAL (SOR2, 'G', 6, NULL , &States[S_SOR2_WALK+0]),
#define S_SOR2_DIE (S_SOR2_TELE+6)
S_NORMAL (SDTH, 'A', 8, A_Sor2DthInit , &States[S_SOR2_DIE+1]),
S_NORMAL (SDTH, 'B', 8, NULL , &States[S_SOR2_DIE+2]),
S_NORMAL (SDTH, 'C', 8, A_SorDSph , &States[S_SOR2_DIE+3]),
S_NORMAL (SDTH, 'D', 7, NULL , &States[S_SOR2_DIE+4]),
S_NORMAL (SDTH, 'E', 7, NULL , &States[S_SOR2_DIE+5]),
S_NORMAL (SDTH, 'F', 7, A_Sor2DthLoop , &States[S_SOR2_DIE+6]),
S_NORMAL (SDTH, 'G', 6, A_SorDExp , &States[S_SOR2_DIE+7]),
S_NORMAL (SDTH, 'H', 6, NULL , &States[S_SOR2_DIE+8]),
S_NORMAL (SDTH, 'I', 18, NULL , &States[S_SOR2_DIE+9]),
S_NORMAL (SDTH, 'J', 6, A_NoBlocking , &States[S_SOR2_DIE+10]),
S_NORMAL (SDTH, 'K', 6, A_SorDBon , &States[S_SOR2_DIE+11]),
S_NORMAL (SDTH, 'L', 6, NULL , &States[S_SOR2_DIE+12]),
S_NORMAL (SDTH, 'M', 6, NULL , &States[S_SOR2_DIE+13]),
S_NORMAL (SDTH, 'N', 6, NULL , &States[S_SOR2_DIE+14]),
S_NORMAL (SDTH, 'O', -1, A_BossDeath , NULL)
};
IMPLEMENT_ACTOR (ASorcerer2, Heretic, -1, 143)
PROP_SpawnHealth (3500)
PROP_RadiusFixed (16)
PROP_HeightFixed (70)
PROP_Mass (300)
PROP_SpeedFixed (14)
PROP_PainChance (32)
PROP_Flags (MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL|MF_DROPOFF)
PROP_Flags2 (MF2_MCROSS|MF2_FLOORCLIP|MF2_PASSMOBJ|MF2_PUSHWALL|MF2_BOSS)
PROP_Flags3 (MF3_DONTMORPH|MF3_FULLVOLACTIVE|MF3_NORADIUSDMG|MF3_NOTARGET)
PROP_Flags4 (MF4_NOICEDEATH)
PROP_SpawnState (S_SOR2_LOOK)
PROP_SeeState (S_SOR2_WALK)
PROP_PainState (S_SOR2_PAIN)
PROP_MissileState (S_SOR2_ATK)
PROP_DeathState (S_SOR2_DIE)
PROP_SeeSound ("dsparil/sight")
PROP_AttackSound ("dsparil/attack")
PROP_PainSound ("dsparil/pain")
PROP_ActiveSound ("dsparil/active")
PROP_Obituary("$OB_DSPARIL2")
PROP_HitObituary("$OB_DSPARIL2HIT")
END_DEFAULTS
// Sorcerer 2 FX 1 ----------------------------------------------------------
class ASorcerer2FX1 : public AActor
{
DECLARE_ACTOR (ASorcerer2FX1, AActor)
public:
void GetExplodeParms (int &damage, int &distance, bool &hurtSource);
};
FState ASorcerer2FX1::States[] =
{
#define S_SOR2FX1 0
S_BRIGHT (FX16, 'A', 3, A_BlueSpark , &States[S_SOR2FX1+1]),
S_BRIGHT (FX16, 'B', 3, A_BlueSpark , &States[S_SOR2FX1+2]),
S_BRIGHT (FX16, 'C', 3, A_BlueSpark , &States[S_SOR2FX1+0]),
#define S_SOR2FXI1 (S_SOR2FX1+3)
S_BRIGHT (FX16, 'G', 5, A_Explode , &States[S_SOR2FXI1+1]),
S_BRIGHT (FX16, 'H', 5, NULL , &States[S_SOR2FXI1+2]),
S_BRIGHT (FX16, 'I', 5, NULL , &States[S_SOR2FXI1+3]),
S_BRIGHT (FX16, 'J', 5, NULL , &States[S_SOR2FXI1+4]),
S_BRIGHT (FX16, 'K', 5, NULL , &States[S_SOR2FXI1+5]),
S_BRIGHT (FX16, 'L', 5, NULL , NULL)
};
IMPLEMENT_ACTOR (ASorcerer2FX1, Heretic, -1, 145)
PROP_RadiusFixed (10)
PROP_HeightFixed (6)
PROP_SpeedFixed (20)
PROP_Damage (1)
PROP_Flags (MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY)
PROP_Flags2 (MF2_NOTELEPORT)
PROP_RenderStyle (STYLE_Add)
PROP_SpawnState (S_SOR2FX1)
PROP_DeathState (S_SOR2FXI1)
END_DEFAULTS
AT_SPEED_SET (Sorcerer2FX1, speed)
{
SimpleSpeedSetter (ASorcerer2FX1, 20*FRACUNIT, 28*FRACUNIT, speed);
}
void ASorcerer2FX1::GetExplodeParms (int &damage, int &distance, bool &hurtSource)
{
damage = 80 + (pr_s2fx1() & 31);
}
// Sorcerer 2 FX Spark ------------------------------------------------------
class ASorcerer2FXSpark : public AActor
{
DECLARE_ACTOR (ASorcerer2FXSpark, AActor)
};
FState ASorcerer2FXSpark::States[] =
{
#define S_SOR2FXSPARK 0
S_BRIGHT (FX16, 'D', 12, NULL , &States[S_SOR2FXSPARK+1]),
S_BRIGHT (FX16, 'E', 12, NULL , &States[S_SOR2FXSPARK+2]),
S_BRIGHT (FX16, 'F', 12, NULL , NULL)
};
IMPLEMENT_ACTOR (ASorcerer2FXSpark, Heretic, -1, 0)
PROP_RadiusFixed (20)
PROP_HeightFixed (16)
PROP_Flags (MF_NOBLOCKMAP|MF_NOGRAVITY)
PROP_Flags2 (MF2_NOTELEPORT|MF2_CANNOTPUSH)
PROP_RenderStyle (STYLE_Add)
PROP_SpawnState (S_SOR2FXSPARK)
END_DEFAULTS
// Sorcerer 2 FX 2 ----------------------------------------------------------
class ASorcerer2FX2 : public AActor
{
DECLARE_ACTOR (ASorcerer2FX2, AActor)
};
FState ASorcerer2FX2::States[] =
{
#define S_SOR2FX2 0
S_BRIGHT (FX11, 'A', 35, NULL , &States[S_SOR2FX2+1]),
S_BRIGHT (FX11, 'A', 5, A_GenWizard , &States[S_SOR2FX2+2]),
S_BRIGHT (FX11, 'B', 5, NULL , &States[S_SOR2FX2+1]),
#define S_SOR2FXI2 (S_SOR2FX2+3)
S_BRIGHT (FX11, 'C', 5, NULL , &States[S_SOR2FXI2+1]),
S_BRIGHT (FX11, 'D', 5, NULL , &States[S_SOR2FXI2+2]),
S_BRIGHT (FX11, 'E', 5, NULL , &States[S_SOR2FXI2+3]),
S_BRIGHT (FX11, 'F', 5, NULL , &States[S_SOR2FXI2+4]),
S_BRIGHT (FX11, 'G', 5, NULL , NULL)
};
IMPLEMENT_ACTOR (ASorcerer2FX2, Heretic, -1, 146)
PROP_RadiusFixed (10)
PROP_HeightFixed (6)
PROP_SpeedFixed (6)
PROP_Damage (10)
PROP_Flags (MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY)
PROP_Flags2 (MF2_NOTELEPORT)
PROP_RenderStyle (STYLE_Add)
PROP_SpawnState (S_SOR2FX2)
PROP_DeathState (S_SOR2FXI2)
END_DEFAULTS
// Sorcerer 2 Telefade ------------------------------------------------------
class ASorcerer2Telefade : public AActor
{
DECLARE_ACTOR (ASorcerer2Telefade, AActor)
};
FState ASorcerer2Telefade::States[] =
{
#define S_SOR2TELEFADE 0
S_NORMAL (SOR2, 'G', 8, NULL , &States[S_SOR2TELEFADE+1]),
S_NORMAL (SOR2, 'H', 6, NULL , &States[S_SOR2TELEFADE+2]),
S_NORMAL (SOR2, 'I', 6, NULL , &States[S_SOR2TELEFADE+3]),
S_NORMAL (SOR2, 'J', 6, NULL , &States[S_SOR2TELEFADE+4]),
S_NORMAL (SOR2, 'K', 6, NULL , &States[S_SOR2TELEFADE+5]),
S_NORMAL (SOR2, 'L', 6, NULL , NULL)
};
IMPLEMENT_ACTOR (ASorcerer2Telefade, Heretic, -1, 0)
PROP_Flags (MF_NOBLOCKMAP)
PROP_SpawnState (S_SOR2TELEFADE)
END_DEFAULTS
//----------------------------------------------------------------------------
//
// PROC A_Sor1Pain
@ -433,19 +71,21 @@ void A_Srcr1Attack (AActor *actor)
P_TraceBleed (damage, actor->target, actor);
return;
}
const PClass *fx = PClass::FindClass("SorcererFX1");
if (actor->health > (actor->GetDefault()->health/3)*2)
{ // Spit one fireball
P_SpawnMissileZ (actor, actor->z + 48*FRACUNIT, actor->target, RUNTIME_CLASS(ASorcererFX1));
P_SpawnMissileZ (actor, actor->z + 48*FRACUNIT, actor->target, fx );
}
else
{ // Spit three fireballs
mo = P_SpawnMissileZ (actor, actor->z + 48*FRACUNIT, actor->target, RUNTIME_CLASS(ASorcererFX1));
mo = P_SpawnMissileZ (actor, actor->z + 48*FRACUNIT, actor->target, fx);
if (mo != NULL)
{
momz = mo->momz;
angle = mo->angle;
P_SpawnMissileAngleZ (actor, actor->z + 48*FRACUNIT, RUNTIME_CLASS(ASorcererFX1), angle-ANGLE_1*3, momz);
P_SpawnMissileAngleZ (actor, actor->z + 48*FRACUNIT, RUNTIME_CLASS(ASorcererFX1), angle+ANGLE_1*3, momz);
P_SpawnMissileAngleZ (actor, actor->z + 48*FRACUNIT, fx, angle-ANGLE_1*3, momz);
P_SpawnMissileAngleZ (actor, actor->z + 48*FRACUNIT, fx, angle+ANGLE_1*3, momz);
}
if (actor->health < actor->GetDefault()->health/3)
{ // Maybe attack again
@ -456,7 +96,7 @@ void A_Srcr1Attack (AActor *actor)
else
{ // Set state to attack again
actor->special1 = 1;
actor->SetState (&ASorcerer1::States[S_SRCR1_ATK+3]);
actor->SetState (actor->FindState("Missile2"));
}
}
}
@ -473,8 +113,8 @@ void A_SorcererRise (AActor *actor)
AActor *mo;
actor->flags &= ~MF_SOLID;
mo = Spawn<ASorcerer2> (actor->x, actor->y, actor->z, ALLOW_REPLACE);
mo->SetState (&ASorcerer2::States[S_SOR2_RISE]);
mo = Spawn("Sorcerer2", actor->x, actor->y, actor->z, ALLOW_REPLACE);
mo->SetState (mo->FindState("Rise"));
mo->angle = actor->angle;
mo->CopyFriendliness (actor, true);
}
@ -496,7 +136,7 @@ void P_DSparilTeleport (AActor *actor)
DSpotState *state = DSpotState::GetSpotState();
if (state == NULL) return;
spot = state->GetSpotWithMinDistance(RUNTIME_CLASS(ABossSpot), actor->x, actor->y, 128*FRACUNIT);
spot = state->GetSpotWithMinDistance(PClass::FindClass("BossSpot"), actor->x, actor->y, 128*FRACUNIT);
if (spot == NULL) return;
prevX = actor->x;
@ -504,9 +144,9 @@ void P_DSparilTeleport (AActor *actor)
prevZ = actor->z;
if (P_TeleportMove (actor, spot->x, spot->y, spot->z, false))
{
mo = Spawn<ASorcerer2Telefade> (prevX, prevY, prevZ, ALLOW_REPLACE);
mo = Spawn("Sorcerer2Telefade", prevX, prevY, prevZ, ALLOW_REPLACE);
S_Sound (mo, CHAN_BODY, "misc/teleport", 1, ATTN_NORM);
actor->SetState (&ASorcerer2::States[S_SOR2_TELE]);
actor->SetState (actor->FindState("Teleport"));
S_Sound (actor, CHAN_BODY, "misc/teleport", 1, ATTN_NORM);
actor->z = actor->floorz;
actor->angle = spot->angle;
@ -565,14 +205,17 @@ void A_Srcr2Attack (AActor *actor)
chance = actor->health < actor->GetDefault()->health/2 ? 96 : 48;
if (pr_s2a() < chance)
{ // Wizard spawners
P_SpawnMissileAngle (actor, RUNTIME_CLASS(ASorcerer2FX2),
actor->angle-ANG45, FRACUNIT/2);
P_SpawnMissileAngle (actor, RUNTIME_CLASS(ASorcerer2FX2),
actor->angle+ANG45, FRACUNIT/2);
const PClass *fx = PClass::FindClass("Sorcerer2FX2");
if (fx)
{
P_SpawnMissileAngle (actor, fx, actor->angle-ANG45, FRACUNIT/2);
P_SpawnMissileAngle (actor, fx, actor->angle+ANG45, FRACUNIT/2);
}
}
else
{ // Blue bolt
P_SpawnMissile (actor, actor->target, RUNTIME_CLASS(ASorcerer2FX1));
P_SpawnMissile (actor, actor->target, PClass::FindClass("Sorcerer2FX1"));
}
}
@ -589,7 +232,7 @@ void A_BlueSpark (AActor *actor)
for (i = 0; i < 2; i++)
{
mo = Spawn<ASorcerer2FXSpark> (actor->x, actor->y, actor->z, ALLOW_REPLACE);
mo = Spawn("Sorcerer2FXSpark", actor->x, actor->y, actor->z, ALLOW_REPLACE);
mo->momx = pr_bluespark.Random2() << 9;
mo->momy = pr_bluespark.Random2() << 9;
mo->momz = FRACUNIT + (pr_bluespark()<<8);
@ -606,9 +249,10 @@ void A_GenWizard (AActor *actor)
{
AActor *mo;
mo = Spawn<AWizard> (actor->x, actor->y, actor->z - GetDefault<AWizard>()->height/2, ALLOW_REPLACE);
mo = Spawn("Wizard", actor->x, actor->y, actor->z, ALLOW_REPLACE);
if (mo != NULL)
{
mo->z -= mo->GetDefault()->height/2;
if (!P_TestMobjLocation (mo))
{ // Didn't fit
mo->Destroy ();
@ -650,19 +294,7 @@ void A_Sor2DthLoop (AActor *actor)
{
if (--actor->special1)
{ // Need to loop
actor->SetState (&ASorcerer2::States[S_SOR2_DIE+3]);
actor->SetState (actor->FindState("DeathLoop"));
}
}
//----------------------------------------------------------------------------
//
// D'Sparil Sound Routines
//
//----------------------------------------------------------------------------
void A_SorZap (AActor *actor) {S_Sound (actor, CHAN_BODY, "dsparil/zap", 1, ATTN_NONE);}
void A_SorRise (AActor *actor) {S_Sound (actor, CHAN_BODY, "dsparil/rise", 1, ATTN_NONE);}
void A_SorDSph (AActor *actor) {S_Sound (actor, CHAN_BODY, "dsparil/scream", 1, ATTN_NONE);}
void A_SorDExp (AActor *actor) {S_Sound (actor, CHAN_BODY, "dsparil/explode", 1, ATTN_NONE);}
void A_SorDBon (AActor *actor) {S_Sound (actor, CHAN_BODY, "dsparil/bones", 1, ATTN_NONE);}
void A_SorSightSnd (AActor *actor) {S_Sound (actor, CHAN_BODY, "dsparil/sight", 1, ATTN_NONE);}

View file

@ -10,25 +10,13 @@
class AArtiTomeOfPower : public APowerupGiver
{
DECLARE_ACTOR (AArtiTomeOfPower, APowerupGiver)
DECLARE_CLASS (AArtiTomeOfPower, APowerupGiver)
public:
bool Use (bool pickup);
};
FState AArtiTomeOfPower::States[] =
{
S_NORMAL (PWBK, 'A', 350, NULL, &States[0])
};
IMPLEMENT_ACTOR (AArtiTomeOfPower, Heretic, 86, 134)
PROP_Flags (MF_SPECIAL|MF_COUNTITEM)
PROP_Flags2 (MF2_FLOATBOB)
PROP_SpawnState (0)
PROP_Inventory_PickupFlash (1)
PROP_Inventory_Icon ("ARTIPWBK")
PROP_PowerupGiver_Powerup ("PowerWeaponLevel2")
PROP_Inventory_PickupMessage("$TXT_ARTITOMEOFPOWER")
END_DEFAULTS
IMPLEMENT_CLASS (AArtiTomeOfPower)
bool AArtiTomeOfPower::Use (bool pickup)
{
@ -55,70 +43,28 @@ bool AArtiTomeOfPower::Use (bool pickup)
// Time bomb ----------------------------------------------------------------
class AActivatedTimeBomb : public AActor
void A_TimeBomb(AActor *self)
{
DECLARE_ACTOR (AActivatedTimeBomb, AActor)
public:
void PreExplode ()
{
z += 32*FRACUNIT;
alpha = OPAQUE;
}
};
FState AActivatedTimeBomb::States[] =
{
S_NORMAL (FBMB, 'A', 10, NULL , &States[1]),
S_NORMAL (FBMB, 'B', 10, NULL , &States[2]),
S_NORMAL (FBMB, 'C', 10, NULL , &States[3]),
S_NORMAL (FBMB, 'D', 10, NULL , &States[4]),
S_NORMAL (FBMB, 'E', 6, A_Scream , &States[5]),
S_BRIGHT (XPL1, 'A', 4, A_Explode, &States[6]),
S_BRIGHT (XPL1, 'B', 4, NULL , &States[7]),
S_BRIGHT (XPL1, 'C', 4, NULL , &States[8]),
S_BRIGHT (XPL1, 'D', 4, NULL , &States[9]),
S_BRIGHT (XPL1, 'E', 4, NULL , &States[10]),
S_BRIGHT (XPL1, 'F', 4, NULL , NULL)
};
IMPLEMENT_ACTOR (AActivatedTimeBomb, Heretic, -1, 0)
PROP_Flags (MF_NOGRAVITY)
PROP_RenderStyle (STYLE_Translucent)
PROP_Alpha (HR_SHADOW)
PROP_SpawnState (0)
PROP_DeathSound ("misc/timebomb")
END_DEFAULTS
self->z += 32*FRACUNIT;
self->RenderStyle = STYLE_Add;
self->alpha = FRACUNIT;
A_Explode(self);
}
class AArtiTimeBomb : public AInventory
{
DECLARE_ACTOR (AArtiTimeBomb, AInventory)
DECLARE_CLASS (AArtiTimeBomb, AInventory)
public:
bool Use (bool pickup);
};
FState AArtiTimeBomb::States[] =
{
S_NORMAL (FBMB, 'E', 350, NULL, &States[0]),
};
IMPLEMENT_ACTOR (AArtiTimeBomb, Heretic, 34, 72)
PROP_Flags (MF_SPECIAL|MF_COUNTITEM)
PROP_Flags2 (MF2_FLOATBOB)
PROP_SpawnState (0)
PROP_Inventory_DefMaxAmount
PROP_Inventory_PickupFlash (1)
PROP_Inventory_FlagsSet (IF_INVBAR|IF_FANCYPICKUPSOUND)
PROP_Inventory_Icon ("ARTIFBMB")
PROP_Inventory_PickupSound ("misc/p_pkup")
PROP_Inventory_PickupMessage("$TXT_ARTIFIREBOMB")
END_DEFAULTS
IMPLEMENT_CLASS (AArtiTimeBomb)
bool AArtiTimeBomb::Use (bool pickup)
{
angle_t angle = Owner->angle >> ANGLETOFINESHIFT;
AActor *mo = Spawn<AActivatedTimeBomb> (
AActor *mo = Spawn("ActivatedTimeBomb",
Owner->x + 24*finecosine[angle],
Owner->y + 24*finesine[angle],
Owner->z - Owner->floorclip, ALLOW_REPLACE);

View file

@ -21,25 +21,6 @@ class APhoenixPuff : public AActor
DECLARE_ACTOR (APhoenixPuff, AActor)
};
class ASorcerer2 : public AActor
{
DECLARE_ACTOR (ASorcerer2, AActor)
};
class AWizard : public AActor
{
DECLARE_ACTOR (AWizard, AActor)
public:
void NoBlockingSet ();
};
void P_DSparilTeleport (AActor *actor);
class AStaffPuff : public AActor
{
DECLARE_ACTOR (AStaffPuff, AActor)
public:
void BeginPlay ();
};
#endif //__A_HERETICGLOBAL_H__

View file

@ -8,218 +8,6 @@
#include "gstrings.h"
static FRandom pr_imp ("ImpExplode");
static FRandom pr_impmeatk ("ImpMeAttack");
static FRandom pr_impmsatk ("ImpMsAttack");
static FRandom pr_impmsatk2 ("ImpMsAttack2");
void A_ImpExplode (AActor *);
void A_ImpMeAttack (AActor *);
void A_ImpMsAttack (AActor *);
void A_ImpMsAttack2 (AActor *);
void A_ImpDeath (AActor *);
void A_ImpXDeath1 (AActor *);
void A_ImpXDeath2 (AActor *);
// Heretic imp (as opposed to the Doom variety) -----------------------------
class AHereticImp : public AActor
{
DECLARE_ACTOR (AHereticImp, AActor)
};
FState AHereticImp::States[] =
{
#define S_IMP_LOOK 0
S_NORMAL (IMPX, 'A', 10, A_Look , &States[S_IMP_LOOK+1]),
S_NORMAL (IMPX, 'B', 10, A_Look , &States[S_IMP_LOOK+2]),
S_NORMAL (IMPX, 'C', 10, A_Look , &States[S_IMP_LOOK+3]),
S_NORMAL (IMPX, 'B', 10, A_Look , &States[S_IMP_LOOK+0]),
#define S_IMP_FLY (S_IMP_LOOK+4)
S_NORMAL (IMPX, 'A', 3, A_Chase , &States[S_IMP_FLY+1]),
S_NORMAL (IMPX, 'A', 3, A_Chase , &States[S_IMP_FLY+2]),
S_NORMAL (IMPX, 'B', 3, A_Chase , &States[S_IMP_FLY+3]),
S_NORMAL (IMPX, 'B', 3, A_Chase , &States[S_IMP_FLY+4]),
S_NORMAL (IMPX, 'C', 3, A_Chase , &States[S_IMP_FLY+5]),
S_NORMAL (IMPX, 'C', 3, A_Chase , &States[S_IMP_FLY+6]),
S_NORMAL (IMPX, 'B', 3, A_Chase , &States[S_IMP_FLY+7]),
S_NORMAL (IMPX, 'B', 3, A_Chase , &States[S_IMP_FLY+0]),
#define S_IMP_MEATK (S_IMP_FLY+8)
S_NORMAL (IMPX, 'D', 6, A_FaceTarget , &States[S_IMP_MEATK+1]),
S_NORMAL (IMPX, 'E', 6, A_FaceTarget , &States[S_IMP_MEATK+2]),
S_NORMAL (IMPX, 'F', 6, A_ImpMeAttack , &States[S_IMP_FLY+0]),
#define S_IMP_MSATK1 (S_IMP_MEATK+3)
S_NORMAL (IMPX, 'A', 10, A_FaceTarget , &States[S_IMP_MSATK1+1]),
S_NORMAL (IMPX, 'B', 6, A_ImpMsAttack , &States[S_IMP_MSATK1+2]),
S_NORMAL (IMPX, 'C', 6, NULL , &States[S_IMP_MSATK1+3]),
S_NORMAL (IMPX, 'B', 6, NULL , &States[S_IMP_MSATK1+4]),
S_NORMAL (IMPX, 'A', 6, NULL , &States[S_IMP_MSATK1+5]),
S_NORMAL (IMPX, 'B', 6, NULL , &States[S_IMP_MSATK1+2]),
#define S_IMP_PAIN (S_IMP_MSATK1+6)
S_NORMAL (IMPX, 'G', 3, NULL , &States[S_IMP_PAIN+1]),
S_NORMAL (IMPX, 'G', 3, A_Pain , &States[S_IMP_FLY+0]),
#define S_IMP_DIE (S_IMP_PAIN+2)
S_NORMAL (IMPX, 'G', 4, A_ImpDeath , &States[S_IMP_DIE+1]),
S_NORMAL (IMPX, 'H', 5, NULL , &States[S_IMP_DIE+1]),
#define S_IMP_XDIE (S_IMP_DIE+2)
S_NORMAL (IMPX, 'S', 5, A_ImpXDeath1 , &States[S_IMP_XDIE+1]),
S_NORMAL (IMPX, 'T', 5, NULL , &States[S_IMP_XDIE+2]),
S_NORMAL (IMPX, 'U', 5, NULL , &States[S_IMP_XDIE+3]),
S_NORMAL (IMPX, 'V', 5, A_ImpXDeath2 , &States[S_IMP_XDIE+4]),
S_NORMAL (IMPX, 'W', 5, NULL , &States[S_IMP_XDIE+4]),
#define S_IMP_CRASH (S_IMP_XDIE+5)
S_NORMAL (IMPX, 'I', 7, A_ImpExplode , &States[S_IMP_CRASH+1]),
S_NORMAL (IMPX, 'J', 7, A_Scream , &States[S_IMP_CRASH+2]),
S_NORMAL (IMPX, 'K', 7, NULL , &States[S_IMP_CRASH+3]),
S_NORMAL (IMPX, 'L', -1, NULL , NULL),
#define S_IMP_XCRASH (S_IMP_CRASH+4)
S_NORMAL (IMPX, 'X', 7, NULL , &States[S_IMP_XCRASH+1]),
S_NORMAL (IMPX, 'Y', 7, NULL , &States[S_IMP_XCRASH+2]),
S_NORMAL (IMPX, 'Z', -1, NULL , NULL)
};
IMPLEMENT_ACTOR (AHereticImp, Heretic, 66, 5)
PROP_SpawnHealth (40)
PROP_RadiusFixed (16)
PROP_HeightFixed (36)
PROP_Mass (50)
PROP_SpeedFixed (10)
PROP_PainChance (200)
PROP_Flags (MF_SOLID|MF_SHOOTABLE|MF_FLOAT|MF_NOGRAVITY|MF_COUNTKILL)
PROP_Flags2 (MF2_MCROSS|MF2_SPAWNFLOAT|MF2_PASSMOBJ|MF2_PUSHWALL)
PROP_Flags3 (MF3_DONTOVERLAP)
PROP_Flags4 (MF4_MISSILEMORE)
PROP_SpawnState (S_IMP_LOOK)
PROP_SeeState (S_IMP_FLY)
PROP_PainState (S_IMP_PAIN)
PROP_MeleeState (S_IMP_MEATK)
PROP_MissileState (S_IMP_MSATK1)
PROP_CrashState (S_IMP_CRASH)
PROP_DeathState (S_IMP_DIE)
PROP_XDeathState (S_IMP_XDIE)
PROP_SeeSound ("himp/sight")
PROP_AttackSound ("himp/attack")
PROP_PainSound ("himp/pain")
PROP_DeathSound ("himp/death")
PROP_ActiveSound ("himp/active")
PROP_Obituary("$OB_HERETICIMP")
PROP_HitObituary("$OB_HERETICIMPHIT")
END_DEFAULTS
// Heretic imp leader -------------------------------------------------------
class AHereticImpLeader : public AHereticImp
{
DECLARE_ACTOR (AHereticImpLeader, AHereticImp)
};
FState AHereticImpLeader::States[] =
{
#define S_IMP_MSATK2 0
S_NORMAL (IMPX, 'D', 6, A_FaceTarget , &States[S_IMP_MSATK2+1]),
S_NORMAL (IMPX, 'E', 6, A_FaceTarget , &States[S_IMP_MSATK2+2]),
S_NORMAL (IMPX, 'F', 6, A_ImpMsAttack2 , &AHereticImp::States[S_IMP_FLY]),
};
IMPLEMENT_ACTOR (AHereticImpLeader, Heretic, 5, 7)
PROP_SpawnHealth (80)
PROP_MeleeState (PROP_CLEAR_STATE)
PROP_MissileState (S_IMP_MSATK2)
PROP_Flags4Clear(MF4_MISSILEMORE) // The imp leader does have a 'normal' missile range!
PROP_AttackSound ("himp/leaderattack")
END_DEFAULTS
// Heretic imp chunk 1 ------------------------------------------------------
class AHereticImpChunk1 : public AActor
{
DECLARE_ACTOR (AHereticImpChunk1, AActor)
};
FState AHereticImpChunk1::States[] =
{
S_NORMAL (IMPX, 'M', 5, NULL , &States[1]),
S_NORMAL (IMPX, 'N', 700, NULL , &States[2]),
S_NORMAL (IMPX, 'O', 700, NULL , NULL)
};
IMPLEMENT_ACTOR (AHereticImpChunk1, Heretic, -1, 0)
PROP_Mass (5)
PROP_Radius (4)
PROP_SpawnState (0)
END_DEFAULTS
// Heretic imp chunk 2 ------------------------------------------------------
class AHereticImpChunk2 : public AActor
{
DECLARE_ACTOR (AHereticImpChunk2, AActor)
};
FState AHereticImpChunk2::States[] =
{
S_NORMAL (IMPX, 'P', 5, NULL , &States[1]),
S_NORMAL (IMPX, 'Q', 700, NULL , &States[2]),
S_NORMAL (IMPX, 'R', 700, NULL , NULL)
};
IMPLEMENT_ACTOR (AHereticImpChunk2, Heretic, -1, 0)
PROP_Mass (5)
PROP_Radius (4)
PROP_SpawnState (0)
END_DEFAULTS
// Heretic imp ball ---------------------------------------------------------
class AHereticImpBall : public AActor
{
DECLARE_ACTOR (AHereticImpBall, AActor)
};
FState AHereticImpBall::States[] =
{
#define S_IMPFX 0
S_BRIGHT (FX10, 'A', 6, NULL , &States[S_IMPFX+1]),
S_BRIGHT (FX10, 'B', 6, NULL , &States[S_IMPFX+2]),
S_BRIGHT (FX10, 'C', 6, NULL , &States[S_IMPFX+0]),
#define S_IMPFXI (S_IMPFX+3)
S_BRIGHT (FX10, 'D', 5, NULL , &States[S_IMPFXI+1]),
S_BRIGHT (FX10, 'E', 5, NULL , &States[S_IMPFXI+2]),
S_BRIGHT (FX10, 'F', 5, NULL , &States[S_IMPFXI+3]),
S_BRIGHT (FX10, 'G', 5, NULL , NULL)
};
IMPLEMENT_ACTOR (AHereticImpBall, Heretic, -1, 10)
PROP_RadiusFixed (8)
PROP_HeightFixed (8)
PROP_SpeedFixed (10)
PROP_Damage (1)
PROP_Flags (MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY)
PROP_Flags2 (MF2_WINDTHRUST|MF2_NOTELEPORT)
PROP_RenderStyle (STYLE_Add)
PROP_SpawnState (S_IMPFX)
PROP_DeathState (S_IMPFXI)
END_DEFAULTS
AT_SPEED_SET (HereticImpBall, speed)
{
SimpleSpeedSetter (AHereticImpBall, 10*FRACUNIT, 20*FRACUNIT, speed);
}
//----------------------------------------------------------------------------
//
@ -233,100 +21,21 @@ void A_ImpExplode (AActor *self)
self->flags &= ~MF_NOGRAVITY;
chunk = Spawn<AHereticImpChunk1> (self->x, self->y, self->z, ALLOW_REPLACE);
chunk = Spawn("HereticImpChunk1", self->x, self->y, self->z, ALLOW_REPLACE);
chunk->momx = pr_imp.Random2 () << 10;
chunk->momy = pr_imp.Random2 () << 10;
chunk->momz = 9*FRACUNIT;
chunk = Spawn<AHereticImpChunk2> (self->x, self->y, self->z, ALLOW_REPLACE);
chunk = Spawn("HereticImpChunk2", self->x, self->y, self->z, ALLOW_REPLACE);
chunk->momx = pr_imp.Random2 () << 10;
chunk->momy = pr_imp.Random2 () << 10;
chunk->momz = 9*FRACUNIT;
if (self->special1 == 666)
{ // Extreme death crash
self->SetState (&AHereticImp::States[S_IMP_XCRASH]);
self->SetState (self->FindState("XCrash"));
}
}
//----------------------------------------------------------------------------
//
// PROC A_ImpMeAttack
//
//----------------------------------------------------------------------------
void A_ImpMeAttack (AActor *self)
{
if (!self->target)
{
return;
}
S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
if (self->CheckMeleeRange ())
{
int damage = 5+(pr_impmeatk()&7);
P_DamageMobj (self->target, self, self, damage, NAME_Melee);
P_TraceBleed (damage, self->target, self);
}
}
//----------------------------------------------------------------------------
//
// PROC A_ImpMsAttack
//
//----------------------------------------------------------------------------
void A_ImpMsAttack (AActor *self)
{
AActor *dest;
angle_t an;
int dist;
if (!self->target || pr_impmsatk() > 64)
{
self->SetState (self->SeeState);
return;
}
dest = self->target;
self->flags |= MF_SKULLFLY;
S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
A_FaceTarget (self);
an = self->angle >> ANGLETOFINESHIFT;
self->momx = FixedMul (12*FRACUNIT, finecosine[an]);
self->momy = FixedMul (12*FRACUNIT, finesine[an]);
dist = P_AproxDistance (dest->x - self->x, dest->y - self->y);
dist = dist/(12*FRACUNIT);
if (dist < 1)
{
dist = 1;
}
self->momz = (dest->z + (dest->height>>1) - self->z)/dist;
}
//----------------------------------------------------------------------------
//
// PROC A_ImpMsAttack2
//
// Fireball attack of the imp leader.
//
//----------------------------------------------------------------------------
void A_ImpMsAttack2 (AActor *self)
{
if (!self->target)
{
return;
}
S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
if (self->CheckMeleeRange ())
{
int damage = 5+(pr_impmsatk2()&7);
P_DamageMobj (self->target, self, self, damage, NAME_Melee);
P_TraceBleed (damage, self->target, self);
return;
}
P_SpawnMissile (self, self->target, RUNTIME_CLASS(AHereticImpBall));
}
//----------------------------------------------------------------------------
//
// PROC A_ImpDeath
@ -337,10 +46,6 @@ void A_ImpDeath (AActor *self)
{
self->flags &= ~MF_SOLID;
self->flags2 |= MF2_FLOORCLIP;
if (self->z <= self->floorz)
{
//self->SetState (&AHereticImp::States[S_IMP_CRASH]);
}
}
//----------------------------------------------------------------------------
@ -357,18 +62,3 @@ void A_ImpXDeath1 (AActor *self)
self->special1 = 666; // Flag the crash routine
}
//----------------------------------------------------------------------------
//
// PROC A_ImpXDeath2
//
//----------------------------------------------------------------------------
void A_ImpXDeath2 (AActor *self)
{
self->flags &= ~MF_NOGRAVITY;
if (self->z <= self->floorz)
{
self->SetState (&AHereticImp::States[S_IMP_CRASH]);
}
}

View file

@ -18,129 +18,6 @@ static FRandom pr_volcano ("VolcanoSet");
static FRandom pr_blast ("VolcanoBlast");
static FRandom pr_impact ("VolcBallImpact");
// --- Pods -----------------------------------------------------------------
void A_PodPain (AActor *);
void A_RemovePod (AActor *);
void A_MakePod (AActor *);
// Pod ----------------------------------------------------------------------
class APod : public AActor
{
DECLARE_ACTOR (APod, AActor)
HAS_OBJECT_POINTERS
public:
void BeginPlay ();
TObjPtr<AActor> Generator;
void Serialize (FArchive &arc);
};
IMPLEMENT_POINTY_CLASS (APod)
DECLARE_POINTER (Generator)
END_POINTERS;
void APod::Serialize (FArchive &arc)
{
Super::Serialize (arc);
arc << Generator;
}
FState APod::States[] =
{
#define S_POD_WAIT 0
S_NORMAL (PPOD, 'A', 10, NULL , &States[S_POD_WAIT+0]),
#define S_POD_PAIN (S_POD_WAIT+1)
S_NORMAL (PPOD, 'B', 14, A_PodPain , &States[S_POD_WAIT+0]),
#define S_POD_DIE (S_POD_PAIN+1)
S_BRIGHT (PPOD, 'C', 5, A_RemovePod , &States[S_POD_DIE+1]),
S_BRIGHT (PPOD, 'D', 5, A_Scream , &States[S_POD_DIE+2]),
S_BRIGHT (PPOD, 'E', 5, A_Explode , &States[S_POD_DIE+3]),
S_BRIGHT (PPOD, 'F', 10, NULL , &AActor::States[S_FREETARGMOBJ]),
#define S_POD_GROW (S_POD_DIE+4)
S_NORMAL (PPOD, 'I', 3, NULL , &States[S_POD_GROW+1]),
S_NORMAL (PPOD, 'J', 3, NULL , &States[S_POD_GROW+2]),
S_NORMAL (PPOD, 'K', 3, NULL , &States[S_POD_GROW+3]),
S_NORMAL (PPOD, 'L', 3, NULL , &States[S_POD_GROW+4]),
S_NORMAL (PPOD, 'M', 3, NULL , &States[S_POD_GROW+5]),
S_NORMAL (PPOD, 'N', 3, NULL , &States[S_POD_GROW+6]),
S_NORMAL (PPOD, 'O', 3, NULL , &States[S_POD_GROW+7]),
S_NORMAL (PPOD, 'P', 3, NULL , &States[S_POD_WAIT+0])
};
BEGIN_DEFAULTS (APod, Heretic, 2035, 125)
PROP_SpawnHealth (45)
PROP_RadiusFixed (16)
PROP_HeightFixed (54)
PROP_PainChance (255)
PROP_Flags (MF_SOLID|MF_NOBLOOD|MF_SHOOTABLE|MF_DROPOFF)
PROP_Flags2 (MF2_WINDTHRUST|MF2_PUSHABLE|MF2_SLIDE|MF2_PASSMOBJ|MF2_TELESTOMP)
PROP_Flags3 (MF3_DONTMORPH|MF3_NOBLOCKMONST|MF3_DONTGIB)
PROP_Flags5 (MF5_OLDRADIUSDMG)
PROP_SpawnState (S_POD_WAIT)
PROP_PainState (S_POD_PAIN)
PROP_DeathState (S_POD_DIE)
PROP_DeathSound ("world/podexplode")
END_DEFAULTS
void APod::BeginPlay ()
{
Super::BeginPlay ();
Generator = NULL;
}
// Pod goo (falls from pod when damaged) ------------------------------------
class APodGoo : public AActor
{
DECLARE_ACTOR (APodGoo, AActor)
};
FState APodGoo::States[] =
{
#define S_PODGOO 0
S_NORMAL (PPOD, 'G', 8, NULL , &States[S_PODGOO+1]),
S_NORMAL (PPOD, 'H', 8, NULL , &States[S_PODGOO+0]),
#define S_PODGOOX (S_PODGOO+2)
S_NORMAL (PPOD, 'G', 10, NULL , NULL)
};
IMPLEMENT_ACTOR (APodGoo, Heretic, -1, 0)
PROP_RadiusFixed (2)
PROP_HeightFixed (4)
PROP_Gravity (FRACUNIT/8)
PROP_Flags (MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF)
PROP_Flags2 (MF2_NOTELEPORT|MF2_CANNOTPUSH)
PROP_SpawnState (S_PODGOO)
END_DEFAULTS
// Pod generator ------------------------------------------------------------
class APodGenerator : public AActor
{
DECLARE_ACTOR (APodGenerator, AActor)
};
FState APodGenerator::States[] =
{
S_NORMAL (TNT1, 'A', 35, A_MakePod , &States[0])
};
IMPLEMENT_ACTOR (APodGenerator, Heretic, 43, 126)
PROP_Flags (MF_NOBLOCKMAP|MF_NOSECTOR)
PROP_SpawnState (0)
END_DEFAULTS
// --- Pod action functions -------------------------------------------------
//----------------------------------------------------------------------------
//
// PROC A_PodPain
@ -160,7 +37,7 @@ void A_PodPain (AActor *actor)
}
for (count = chance > 240 ? 2 : 1; count; count--)
{
goo = Spawn<APodGoo> (actor->x, actor->y, actor->z + 48*FRACUNIT, ALLOW_REPLACE);
goo = Spawn("PodGoo", actor->x, actor->y, actor->z + 48*FRACUNIT, ALLOW_REPLACE);
goo->target = actor;
goo->momx = pr_podpain.Random2() << 9;
goo->momy = pr_podpain.Random2() << 9;
@ -178,7 +55,7 @@ void A_RemovePod (AActor *actor)
{
AActor *mo;
if ( (mo = static_cast<APod *>(actor)->Generator) )
if ( (mo = actor->master))
{
if (mo->special1 > 0)
{
@ -197,7 +74,7 @@ void A_RemovePod (AActor *actor)
void A_MakePod (AActor *actor)
{
APod *mo;
AActor *mo;
fixed_t x;
fixed_t y;
fixed_t z;
@ -209,142 +86,20 @@ void A_MakePod (AActor *actor)
x = actor->x;
y = actor->y;
z = actor->z;
mo = Spawn<APod> (x, y, ONFLOORZ, ALLOW_REPLACE);
mo = Spawn("Pod", x, y, ONFLOORZ, ALLOW_REPLACE);
if (!P_CheckPosition (mo, x, y))
{ // Didn't fit
mo->Destroy ();
return;
}
mo->SetState (&APod::States[S_POD_GROW]);
mo->SetState (mo->FindState("Grow"));
P_ThrustMobj (mo, pr_makepod()<<24, (fixed_t)(4.5*FRACUNIT));
S_Sound (mo, CHAN_BODY, "world/podgrow", 1, ATTN_IDLE);
actor->special1++; // Increment generated pod count
mo->Generator = actor; // Link the generator to the pod
mo->master = actor; // Link the generator to the pod
return;
}
// --- Teleglitter ----------------------------------------------------------
void A_SpawnTeleGlitter (AActor *);
void A_SpawnTeleGlitter2 (AActor *);
void A_AccTeleGlitter (AActor *);
// Teleglitter generator 1 --------------------------------------------------
class ATeleGlitterGenerator1 : public AActor
{
DECLARE_ACTOR (ATeleGlitterGenerator1, AActor)
};
FState ATeleGlitterGenerator1::States[] =
{
S_NORMAL (TGLT, 'A', 8, A_SpawnTeleGlitter , &States[0])
};
IMPLEMENT_ACTOR (ATeleGlitterGenerator1, Heretic, 74, 166)
PROP_Flags (MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOSECTOR)
PROP_SpawnState (0)
END_DEFAULTS
// Teleglitter generator 2 --------------------------------------------------
class ATeleGlitterGenerator2 : public AActor
{
DECLARE_ACTOR (ATeleGlitterGenerator2, AActor)
};
FState ATeleGlitterGenerator2::States[] =
{
S_NORMAL (TGLT, 'F', 8, A_SpawnTeleGlitter2 , &States[0])
};
IMPLEMENT_ACTOR (ATeleGlitterGenerator2, Heretic, 52, 167)
PROP_Flags (MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOSECTOR)
PROP_SpawnState (0)
END_DEFAULTS
// Teleglitter 1 ------------------------------------------------------------
class ATeleGlitter1 : public AActor
{
DECLARE_ACTOR (ATeleGlitter1, AActor)
};
FState ATeleGlitter1::States[] =
{
S_BRIGHT (TGLT, 'A', 2, NULL , &States[1]),
S_BRIGHT (TGLT, 'B', 2, A_AccTeleGlitter , &States[2]),
S_BRIGHT (TGLT, 'C', 2, NULL , &States[3]),
S_BRIGHT (TGLT, 'D', 2, A_AccTeleGlitter , &States[4]),
S_BRIGHT (TGLT, 'E', 2, NULL , &States[0])
};
IMPLEMENT_ACTOR (ATeleGlitter1, Heretic, -1, 0)
PROP_Flags (MF_NOBLOCKMAP|MF_NOGRAVITY|MF_MISSILE)
PROP_RenderStyle (STYLE_Add)
PROP_SpawnState (0)
PROP_Damage (0)
END_DEFAULTS
// Teleglitter 2 ------------------------------------------------------------
class ATeleGlitter2 : public AActor
{
DECLARE_ACTOR (ATeleGlitter2, AActor)
};
FState ATeleGlitter2::States[] =
{
S_BRIGHT (TGLT, 'F', 2, NULL , &States[1]),
S_BRIGHT (TGLT, 'G', 2, A_AccTeleGlitter , &States[2]),
S_BRIGHT (TGLT, 'H', 2, NULL , &States[3]),
S_BRIGHT (TGLT, 'I', 2, A_AccTeleGlitter , &States[4]),
S_BRIGHT (TGLT, 'J', 2, NULL , &States[0])
};
IMPLEMENT_ACTOR (ATeleGlitter2, Heretic, -1, 0)
PROP_Flags (MF_NOBLOCKMAP|MF_NOGRAVITY|MF_MISSILE)
PROP_RenderStyle (STYLE_Add)
PROP_SpawnState (0)
PROP_Damage (0)
END_DEFAULTS
// --- Teleglitter action functions -----------------------------------------
//----------------------------------------------------------------------------
//
// PROC A_SpawnTeleGlitter
//
//----------------------------------------------------------------------------
void A_SpawnTeleGlitter (AActor *actor)
{
AActor *mo;
fixed_t x = actor->x+((pr_teleg()&31)-16)*FRACUNIT;
fixed_t y = actor->y+((pr_teleg()&31)-16)*FRACUNIT;
mo = Spawn<ATeleGlitter1> (x, y,
actor->Sector->floorplane.ZatPoint (actor->x, actor->y), ALLOW_REPLACE);
mo->momz = FRACUNIT/4;
}
//----------------------------------------------------------------------------
//
// PROC A_SpawnTeleGlitter2
//
//----------------------------------------------------------------------------
void A_SpawnTeleGlitter2 (AActor *actor)
{
AActor *mo;
fixed_t x = actor->x+((pr_teleg2()&31)-16)*FRACUNIT;
fixed_t y = actor->y+((pr_teleg2()&31)-16)*FRACUNIT;
mo = Spawn<ATeleGlitter2> (x, y,
actor->Sector->floorplane.ZatPoint (actor->x, actor->y), ALLOW_REPLACE);
mo->momz = FRACUNIT/4;
}
//----------------------------------------------------------------------------
//
// PROC A_AccTeleGlitter
@ -359,135 +114,9 @@ void A_AccTeleGlitter (AActor *actor)
}
}
// --- Volcano --------------------------------------------------------------
void A_VolcanoSet (AActor *);
void A_VolcanoBlast (AActor *);
void A_VolcBallImpact (AActor *);
extern void A_BeastPuff (AActor *);
// Volcano ------------------------------------------------------------------
class AVolcano : public AActor
{
DECLARE_ACTOR (AVolcano, AActor)
};
FState AVolcano::States[] =
{
S_NORMAL (VLCO, 'A', 350, NULL , &States[1]),
S_NORMAL (VLCO, 'A', 35, A_VolcanoSet , &States[2]),
S_NORMAL (VLCO, 'B', 3, NULL , &States[3]),
S_NORMAL (VLCO, 'C', 3, NULL , &States[4]),
S_NORMAL (VLCO, 'D', 3, NULL , &States[5]),
S_NORMAL (VLCO, 'B', 3, NULL , &States[6]),
S_NORMAL (VLCO, 'C', 3, NULL , &States[7]),
S_NORMAL (VLCO, 'D', 3, NULL , &States[8]),
S_NORMAL (VLCO, 'E', 10, A_VolcanoBlast , &States[1])
};
IMPLEMENT_ACTOR (AVolcano, Heretic, 87, 150)
PROP_RadiusFixed (12)
PROP_HeightFixed (20)
PROP_Flags (MF_SOLID)
PROP_SpawnState (0)
END_DEFAULTS
// Volcano blast ------------------------------------------------------------
class AVolcanoBlast : public AActor
{
DECLARE_ACTOR (AVolcanoBlast, AActor)
};
FState AVolcanoBlast::States[] =
{
#define S_VOLCANOBALL 0
S_NORMAL (VFBL, 'A', 4, A_BeastPuff , &States[S_VOLCANOBALL+1]),
S_NORMAL (VFBL, 'B', 4, A_BeastPuff , &States[S_VOLCANOBALL+0]),
#define S_VOLCANOBALLX (S_VOLCANOBALL+2)
S_NORMAL (XPL1, 'A', 4, A_VolcBallImpact , &States[S_VOLCANOBALLX+1]),
S_NORMAL (XPL1, 'B', 4, NULL , &States[S_VOLCANOBALLX+2]),
S_NORMAL (XPL1, 'C', 4, NULL , &States[S_VOLCANOBALLX+3]),
S_NORMAL (XPL1, 'D', 4, NULL , &States[S_VOLCANOBALLX+4]),
S_NORMAL (XPL1, 'E', 4, NULL , &States[S_VOLCANOBALLX+5]),
S_NORMAL (XPL1, 'F', 4, NULL , NULL)
};
IMPLEMENT_ACTOR (AVolcanoBlast, Heretic, -1, 123)
PROP_RadiusFixed (8)
PROP_HeightFixed (8)
PROP_SpeedFixed (2)
PROP_Damage (2)
PROP_DamageType (NAME_Fire)
PROP_Gravity (FRACUNIT/8)
PROP_Flags (MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF)
PROP_Flags2 (MF2_NOTELEPORT)
PROP_SpawnState (S_VOLCANOBALL)
PROP_DeathState (S_VOLCANOBALLX)
PROP_DeathSound ("world/volcano/blast")
END_DEFAULTS
// Volcano T Blast ----------------------------------------------------------
class AVolcanoTBlast : public AActor
{
DECLARE_ACTOR (AVolcanoTBlast, AActor)
};
FState AVolcanoTBlast::States[] =
{
#define S_VOLCANOTBALL 0
S_NORMAL (VTFB, 'A', 4, NULL , &States[S_VOLCANOTBALL+1]),
S_NORMAL (VTFB, 'B', 4, NULL , &States[S_VOLCANOTBALL+0]),
#define S_VOLCANOTBALLX (S_VOLCANOTBALL+2)
S_NORMAL (SFFI, 'C', 4, NULL , &States[S_VOLCANOTBALLX+1]),
S_NORMAL (SFFI, 'B', 4, NULL , &States[S_VOLCANOTBALLX+2]),
S_NORMAL (SFFI, 'A', 4, NULL , &States[S_VOLCANOTBALLX+3]),
S_NORMAL (SFFI, 'B', 4, NULL , &States[S_VOLCANOTBALLX+4]),
S_NORMAL (SFFI, 'C', 4, NULL , &States[S_VOLCANOTBALLX+5]),
S_NORMAL (SFFI, 'D', 4, NULL , &States[S_VOLCANOTBALLX+6]),
S_NORMAL (SFFI, 'E', 4, NULL , NULL)
};
IMPLEMENT_ACTOR (AVolcanoTBlast, Heretic, -1, 124)
PROP_RadiusFixed (8)
PROP_HeightFixed (6)
PROP_SpeedFixed (2)
PROP_Damage (1)
PROP_DamageType (NAME_Fire)
PROP_Gravity (FRACUNIT/8)
PROP_Flags (MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF)
PROP_Flags2 (MF2_NOTELEPORT)
PROP_SpawnState (S_VOLCANOTBALL)
PROP_DeathState (S_VOLCANOTBALLX)
END_DEFAULTS
//----------------------------------------------------------------------------
//
// PROC A_BeastPuff
//
//----------------------------------------------------------------------------
void A_BeastPuff (AActor *actor)
{
if (pr_volcano() > 64)
{
fixed_t x, y, z;
x = actor->x + (pr_volcano.Random2 () << 10);
y = actor->y + (pr_volcano.Random2 () << 10);
z = actor->z + (pr_volcano.Random2 () << 10);
Spawn ("Puffy", x, y, z, ALLOW_REPLACE);
}
}//----------------------------------------------------------------------------
//
// PROC A_VolcanoSet
//
//----------------------------------------------------------------------------
@ -513,7 +142,7 @@ void A_VolcanoBlast (AActor *volcano)
count = 1 + (pr_blast() % 3);
for (i = 0; i < count; i++)
{
blast = Spawn<AVolcanoBlast> (volcano->x, volcano->y,
blast = Spawn("VolcanoBlast", volcano->x, volcano->y,
volcano->z + 44*FRACUNIT, ALLOW_REPLACE);
blast->target = volcano;
angle = pr_blast () << 24;
@ -549,7 +178,7 @@ void A_VolcBallImpact (AActor *ball)
P_RadiusAttack (ball, ball->target, 25, 25, NAME_Fire, true);
for (i = 0; i < 4; i++)
{
tiny = Spawn<AVolcanoTBlast> (ball->x, ball->y, ball->z, ALLOW_REPLACE);
tiny = Spawn("VolcanoTBlast", ball->x, ball->y, ball->z, ALLOW_REPLACE);
tiny->target = ball;
angle = i*ANG90;
tiny->angle = angle;

File diff suppressed because it is too large Load diff

View file

@ -11,235 +11,14 @@ static FRandom pr_foo ("WhirlwindDamage");
static FRandom pr_atk ("LichAttack");
static FRandom pr_seek ("WhirlwindSeek");
void A_LichAttack (AActor *);
void A_LichIceImpact (AActor *);
void A_LichFireGrow (AActor *);
void A_WhirlwindSeek (AActor *);
// Ironlich -----------------------------------------------------------------
class AIronlich : public AActor
{
DECLARE_ACTOR (AIronlich, AActor)
public:
void NoBlockingSet ();
};
FState AIronlich::States[] =
{
#define S_HEAD_LOOK 0
S_NORMAL (LICH, 'A', 10, A_Look , &States[S_HEAD_LOOK]),
#define S_HEAD_FLOAT (S_HEAD_LOOK+1)
S_NORMAL (LICH, 'A', 4, A_Chase , &States[S_HEAD_FLOAT]),
#define S_HEAD_ATK (S_HEAD_FLOAT+1)
S_NORMAL (LICH, 'A', 5, A_FaceTarget , &States[S_HEAD_ATK+1]),
S_NORMAL (LICH, 'B', 20, A_LichAttack , &States[S_HEAD_FLOAT]),
#define S_HEAD_PAIN (S_HEAD_ATK+2)
S_NORMAL (LICH, 'A', 4, NULL , &States[S_HEAD_PAIN+1]),
S_NORMAL (LICH, 'A', 4, A_Pain , &States[S_HEAD_FLOAT]),
#define S_HEAD_DIE (S_HEAD_PAIN+2)
S_NORMAL (LICH, 'C', 7, NULL , &States[S_HEAD_DIE+1]),
S_NORMAL (LICH, 'D', 7, A_Scream , &States[S_HEAD_DIE+2]),
S_NORMAL (LICH, 'E', 7, NULL , &States[S_HEAD_DIE+3]),
S_NORMAL (LICH, 'F', 7, NULL , &States[S_HEAD_DIE+4]),
S_NORMAL (LICH, 'G', 7, A_NoBlocking , &States[S_HEAD_DIE+5]),
S_NORMAL (LICH, 'H', 7, NULL , &States[S_HEAD_DIE+6]),
S_NORMAL (LICH, 'I', -1, A_BossDeath , NULL)
};
IMPLEMENT_ACTOR (AIronlich, Heretic, 6, 20)
PROP_SpawnHealth (700)
PROP_RadiusFixed (40)
PROP_HeightFixed (72)
PROP_Mass (325)
PROP_SpeedFixed (6)
PROP_PainChance (32)
PROP_Flags (MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL|MF_NOBLOOD)
PROP_Flags2 (MF2_MCROSS|MF2_PASSMOBJ|MF2_PUSHWALL)
PROP_Flags3 (MF3_DONTMORPH|MF3_DONTSQUASH)
PROP_Flags4 (MF4_BOSSDEATH)
PROP_SpawnState (S_HEAD_LOOK)
PROP_SeeState (S_HEAD_FLOAT)
PROP_PainState (S_HEAD_PAIN)
PROP_MissileState (S_HEAD_ATK)
PROP_DeathState (S_HEAD_DIE)
PROP_SeeSound ("ironlich/sight")
PROP_AttackSound ("ironlich/attack")
PROP_PainSound ("ironlich/pain")
PROP_DeathSound ("ironlich/death")
PROP_ActiveSound ("ironlich/active")
PROP_Obituary("$OB_IRONLICH")
PROP_HitObituary("$OB_IRONLICHHIT")
END_DEFAULTS
void AIronlich::NoBlockingSet ()
{
P_DropItem (this, "BlasterAmmo", 10, 84);
P_DropItem (this, "ArtiEgg", 0, 51);
}
// Head FX 1 ----------------------------------------------------------------
class AHeadFX1 : public AActor
{
DECLARE_ACTOR (AHeadFX1, AActor)
};
FState AHeadFX1::States[] =
{
#define S_HEADFX1 0
S_BRIGHT (FX05, 'A', 6, NULL , &States[S_HEADFX1+1]),
S_BRIGHT (FX05, 'B', 6, NULL , &States[S_HEADFX1+2]),
S_BRIGHT (FX05, 'C', 6, NULL , &States[S_HEADFX1+0]),
#define S_HEADFXI1 (S_HEADFX1+3)
S_BRIGHT (FX05, 'D', 5, A_LichIceImpact , &States[S_HEADFXI1+1]),
S_BRIGHT (FX05, 'E', 5, NULL , &States[S_HEADFXI1+2]),
S_BRIGHT (FX05, 'F', 5, NULL , &States[S_HEADFXI1+3]),
S_BRIGHT (FX05, 'G', 5, NULL , NULL)
};
IMPLEMENT_ACTOR (AHeadFX1, Heretic, -1, 164)
PROP_RadiusFixed (12)
PROP_HeightFixed (6)
PROP_SpeedFixed (13)
PROP_Damage (1)
PROP_Flags (MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY)
PROP_Flags2 (MF2_NOTELEPORT|MF2_THRUGHOST)
PROP_RenderStyle (STYLE_Add)
PROP_SpawnState (S_HEADFX1)
PROP_DeathState (S_HEADFXI1)
END_DEFAULTS
AT_SPEED_SET (HeadFX1, speed)
{
SimpleSpeedSetter (AHeadFX1, 13*FRACUNIT, 20*FRACUNIT, speed);
}
// Head FX 2 ----------------------------------------------------------------
class AHeadFX2 : public AActor
{
DECLARE_ACTOR (AHeadFX2, AActor)
};
FState AHeadFX2::States[] =
{
#define S_HEADFX2 0
S_BRIGHT (FX05, 'H', 6, NULL , &States[S_HEADFX2+1]),
S_BRIGHT (FX05, 'I', 6, NULL , &States[S_HEADFX2+2]),
S_BRIGHT (FX05, 'J', 6, NULL , &States[S_HEADFX2+0]),
#define S_HEADFXI2 (S_HEADFX2+3)
S_BRIGHT (FX05, 'D', 5, NULL , &States[S_HEADFXI2+1]),
S_BRIGHT (FX05, 'E', 5, NULL , &States[S_HEADFXI2+2]),
S_BRIGHT (FX05, 'F', 5, NULL , &States[S_HEADFXI2+3]),
S_BRIGHT (FX05, 'G', 5, NULL , NULL)
};
IMPLEMENT_ACTOR (AHeadFX2, Heretic, -1, 0)
PROP_RadiusFixed (12)
PROP_HeightFixed (6)
PROP_SpeedFixed (8)
PROP_Damage (3)
PROP_Flags (MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY)
PROP_Flags2 (MF2_NOTELEPORT)
PROP_RenderStyle (STYLE_Add)
PROP_SpawnState (S_HEADFX2)
PROP_DeathState (S_HEADFXI2)
END_DEFAULTS
// Head FX 3 ----------------------------------------------------------------
class AHeadFX3 : public AActor
{
DECLARE_ACTOR (AHeadFX3, AActor)
};
FState AHeadFX3::States[] =
{
#define S_HEADFX3 0
S_BRIGHT (FX06, 'A', 4, A_LichFireGrow , &States[S_HEADFX3+1]),
S_BRIGHT (FX06, 'B', 4, A_LichFireGrow , &States[S_HEADFX3+2]),
S_BRIGHT (FX06, 'C', 4, A_LichFireGrow , &States[S_HEADFX3+0]),
S_BRIGHT (FX06, 'A', 5, NULL , &States[S_HEADFX3+4]),
S_BRIGHT (FX06, 'B', 5, NULL , &States[S_HEADFX3+5]),
S_BRIGHT (FX06, 'C', 5, NULL , &States[S_HEADFX3+3]),
#define S_HEADFXI3 (S_HEADFX3+6)
S_BRIGHT (FX06, 'D', 5, NULL , &States[S_HEADFXI3+1]),
S_BRIGHT (FX06, 'E', 5, NULL , &States[S_HEADFXI3+2]),
S_BRIGHT (FX06, 'F', 5, NULL , &States[S_HEADFXI3+3]),
S_BRIGHT (FX06, 'G', 5, NULL , NULL)
};
IMPLEMENT_ACTOR (AHeadFX3, Heretic, -1, 0)
PROP_RadiusFixed (14)
PROP_HeightFixed (12)
PROP_SpeedFixed (10)
PROP_Damage (5)
PROP_Flags (MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY)
PROP_Flags2 (MF2_WINDTHRUST|MF2_NOTELEPORT)
PROP_RenderStyle (STYLE_Add)
PROP_SpawnState (S_HEADFX3)
PROP_DeathState (S_HEADFXI3)
END_DEFAULTS
AT_SPEED_SET (HeadFX3, speed)
{
SimpleSpeedSetter (AHeadFX3, 10*FRACUNIT, 18*FRACUNIT, speed);
}
// Whirlwind ----------------------------------------------------------------
class AWhirlwind : public AActor
{
DECLARE_ACTOR (AWhirlwind, AActor)
DECLARE_CLASS (AWhirlwind, AActor)
public:
int DoSpecialDamage (AActor *target, int damage);
};
FState AWhirlwind::States[] =
{
#define S_HEADFX4 0
S_NORMAL (FX07, 'D', 3, NULL , &States[S_HEADFX4+1]),
S_NORMAL (FX07, 'E', 3, NULL , &States[S_HEADFX4+2]),
S_NORMAL (FX07, 'F', 3, NULL , &States[S_HEADFX4+3]),
S_NORMAL (FX07, 'G', 3, NULL , &States[S_HEADFX4+4]),
S_NORMAL (FX07, 'A', 3, A_WhirlwindSeek , &States[S_HEADFX4+5]),
S_NORMAL (FX07, 'B', 3, A_WhirlwindSeek , &States[S_HEADFX4+6]),
S_NORMAL (FX07, 'C', 3, A_WhirlwindSeek , &States[S_HEADFX4+4]),
#define S_HEADFXI4 (S_HEADFX4+7)
S_NORMAL (FX07, 'G', 4, NULL , &States[S_HEADFXI4+1]),
S_NORMAL (FX07, 'F', 4, NULL , &States[S_HEADFXI4+2]),
S_NORMAL (FX07, 'E', 4, NULL , &States[S_HEADFXI4+3]),
S_NORMAL (FX07, 'D', 4, NULL , NULL)
};
IMPLEMENT_ACTOR (AWhirlwind, Heretic, -1, 165)
PROP_RadiusFixed (16)
PROP_HeightFixed (74)
PROP_SpeedFixed (10)
PROP_Damage (1)
PROP_Flags (MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY)
PROP_Flags2 (MF2_NOTELEPORT|MF2_SEEKERMISSILE)
PROP_Flags3 (MF3_EXPLOCOUNT)
PROP_RenderStyle (STYLE_Translucent)
PROP_Alpha (HR_SHADOW)
PROP_SpawnState (S_HEADFX4)
PROP_DeathState (S_HEADFXI4)
END_DEFAULTS
IMPLEMENT_CLASS(AWhirlwind)
int AWhirlwind::DoSpecialDamage (AActor *target, int damage)
{
@ -309,18 +88,18 @@ void A_LichAttack (AActor *actor)
randAttack = pr_atk ();
if (randAttack < atkResolve1[dist])
{ // Ice ball
P_SpawnMissile (actor, target, RUNTIME_CLASS(AHeadFX1));
P_SpawnMissile (actor, target, PClass::FindClass("HeadFX1"));
S_Sound (actor, CHAN_BODY, "ironlich/attack2", 1, ATTN_NORM);
}
else if (randAttack < atkResolve2[dist])
{ // Fire column
baseFire = P_SpawnMissile (actor, target, RUNTIME_CLASS(AHeadFX3));
baseFire = P_SpawnMissile (actor, target, PClass::FindClass("HeadFX3"));
if (baseFire != NULL)
{
baseFire->SetState (&AHeadFX3::States[S_HEADFX3+3]); // Don't grow
baseFire->SetState (baseFire->FindState("NoGrow"));
for (i = 0; i < 5; i++)
{
fire = Spawn<AHeadFX3> (baseFire->x, baseFire->y,
fire = Spawn("HeadFX3", baseFire->x, baseFire->y,
baseFire->z, ALLOW_REPLACE);
if (i == 0)
{
@ -394,7 +173,7 @@ void A_LichIceImpact (AActor *ice)
for (i = 0; i < 8; i++)
{
shard = Spawn<AHeadFX2> (ice->x, ice->y, ice->z, ALLOW_REPLACE);
shard = Spawn("HeadFX2", ice->x, ice->y, ice->z, ALLOW_REPLACE);
angle = i*ANG45;
shard->target = ice->target;
shard->angle = angle;
@ -419,7 +198,7 @@ void A_LichFireGrow (AActor *fire)
if (fire->health == 0)
{
fire->Damage = fire->GetDefault()->Damage;
fire->SetState (&AHeadFX3::States[S_HEADFX3+3]);
fire->SetState (fire->FindState("NoGrow"));
}
}

View file

@ -11,170 +11,6 @@
static FRandom pr_dripblood ("DripBlood");
static FRandom pr_knightatk ("KnightAttack");
void A_KnightAttack (AActor *);
void A_DripBlood (AActor *);
void A_AxeSound (AActor *);
// Knight -------------------------------------------------------------------
class AKnight : public AActor
{
DECLARE_ACTOR (AKnight, AActor)
public:
void NoBlockingSet ();
};
FState AKnight::States[] =
{
#define S_KNIGHT_STND 0
S_NORMAL (KNIG, 'A', 10, A_Look , &States[S_KNIGHT_STND+1]),
S_NORMAL (KNIG, 'B', 10, A_Look , &States[S_KNIGHT_STND+0]),
#define S_KNIGHT_WALK (S_KNIGHT_STND+2)
S_NORMAL (KNIG, 'A', 4, A_Chase , &States[S_KNIGHT_WALK+1]),
S_NORMAL (KNIG, 'B', 4, A_Chase , &States[S_KNIGHT_WALK+2]),
S_NORMAL (KNIG, 'C', 4, A_Chase , &States[S_KNIGHT_WALK+3]),
S_NORMAL (KNIG, 'D', 4, A_Chase , &States[S_KNIGHT_WALK+0]),
#define S_KNIGHT_ATK (S_KNIGHT_WALK+4)
S_NORMAL (KNIG, 'E', 10, A_FaceTarget , &States[S_KNIGHT_ATK+1]),
S_NORMAL (KNIG, 'F', 8, A_FaceTarget , &States[S_KNIGHT_ATK+2]),
S_NORMAL (KNIG, 'G', 8, A_KnightAttack , &States[S_KNIGHT_ATK+3]),
S_NORMAL (KNIG, 'E', 10, A_FaceTarget , &States[S_KNIGHT_ATK+4]),
S_NORMAL (KNIG, 'F', 8, A_FaceTarget , &States[S_KNIGHT_ATK+5]),
S_NORMAL (KNIG, 'G', 8, A_KnightAttack , &States[S_KNIGHT_WALK+0]),
#define S_KNIGHT_PAIN (S_KNIGHT_ATK+6)
S_NORMAL (KNIG, 'H', 3, NULL , &States[S_KNIGHT_PAIN+1]),
S_NORMAL (KNIG, 'H', 3, A_Pain , &States[S_KNIGHT_WALK+0]),
#define S_KNIGHT_DIE (S_KNIGHT_PAIN+2)
S_NORMAL (KNIG, 'I', 6, NULL , &States[S_KNIGHT_DIE+1]),
S_NORMAL (KNIG, 'J', 6, A_Scream , &States[S_KNIGHT_DIE+2]),
S_NORMAL (KNIG, 'K', 6, NULL , &States[S_KNIGHT_DIE+3]),
S_NORMAL (KNIG, 'L', 6, A_NoBlocking , &States[S_KNIGHT_DIE+4]),
S_NORMAL (KNIG, 'M', 6, NULL , &States[S_KNIGHT_DIE+5]),
S_NORMAL (KNIG, 'N', 6, NULL , &States[S_KNIGHT_DIE+6]),
S_NORMAL (KNIG, 'O', -1, NULL , NULL)
};
IMPLEMENT_ACTOR (AKnight, Heretic, 64, 6)
PROP_SpawnHealth (200)
PROP_RadiusFixed (24)
PROP_HeightFixed (78)
PROP_Mass (150)
PROP_SpeedFixed (12)
PROP_PainChance (100)
PROP_Flags (MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL)
PROP_Flags2 (MF2_MCROSS|MF2_FLOORCLIP|MF2_PASSMOBJ|MF2_PUSHWALL)
PROP_SpawnState (S_KNIGHT_STND)
PROP_SeeState (S_KNIGHT_WALK)
PROP_PainState (S_KNIGHT_PAIN)
PROP_MeleeState (S_KNIGHT_ATK)
PROP_MissileState (S_KNIGHT_ATK)
PROP_DeathState (S_KNIGHT_DIE)
PROP_SeeSound ("hknight/sight")
PROP_AttackSound ("hknight/attack")
PROP_PainSound ("hknight/pain")
PROP_DeathSound ("hknight/death")
PROP_ActiveSound ("hknight/active")
PROP_Obituary("$OB_BONEKNIGHT")
PROP_HitObituary("$OB_BONEKNIGHTHIT")
END_DEFAULTS
void AKnight::NoBlockingSet ()
{
P_DropItem (this, "CrossbowAmmo", 5, 84);
}
// Knight ghost -------------------------------------------------------------
class AKnightGhost : public AKnight
{
DECLARE_STATELESS_ACTOR (AKnightGhost, AKnight)
};
IMPLEMENT_STATELESS_ACTOR (AKnightGhost, Heretic, 65, 129)
PROP_FlagsSet (MF_SHADOW)
PROP_Flags3 (MF3_GHOST)
PROP_RenderStyle (STYLE_Translucent)
PROP_Alpha (HR_SHADOW)
END_DEFAULTS
// Knight axe ---------------------------------------------------------------
class AKnightAxe : public AActor
{
DECLARE_ACTOR (AKnightAxe, AActor)
};
FState AKnightAxe::States[] =
{
#define S_SPINAXE 0
S_BRIGHT (SPAX, 'A', 3, A_AxeSound , &States[S_SPINAXE+1]),
S_BRIGHT (SPAX, 'B', 3, NULL , &States[S_SPINAXE+2]),
S_BRIGHT (SPAX, 'C', 3, NULL , &States[S_SPINAXE+0]),
#define S_SPINAXEX (S_SPINAXE+3)
S_BRIGHT (SPAX, 'D', 6, NULL , &States[S_SPINAXEX+1]),
S_BRIGHT (SPAX, 'E', 6, NULL , &States[S_SPINAXEX+2]),
S_BRIGHT (SPAX, 'F', 6, NULL , NULL)
};
IMPLEMENT_ACTOR (AKnightAxe, Heretic, -1, 127)
PROP_RadiusFixed (10)
PROP_HeightFixed (8)
PROP_SpeedFixed (9)
PROP_Damage (2)
PROP_Flags (MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY)
PROP_Flags2 (MF2_WINDTHRUST|MF2_NOTELEPORT|MF2_THRUGHOST)
PROP_SpawnState (S_SPINAXE)
PROP_DeathState (S_SPINAXEX)
PROP_DeathSound ("hknight/hit")
END_DEFAULTS
AT_SPEED_SET (KnightAxe, speed)
{
SimpleSpeedSetter (AKnightAxe, 9*FRACUNIT, 18*FRACUNIT, speed);
}
// Red axe ------------------------------------------------------------------
class ARedAxe : public AKnightAxe
{
DECLARE_ACTOR (ARedAxe, AKnightAxe)
};
FState ARedAxe::States[] =
{
#define S_REDAXE 0
S_BRIGHT (RAXE, 'A', 5, A_DripBlood , &States[S_REDAXE+1]),
S_BRIGHT (RAXE, 'B', 5, A_DripBlood , &States[S_REDAXE+0]),
#define S_REDAXEX (S_REDAXE+2)
S_BRIGHT (RAXE, 'C', 6, NULL , &States[S_REDAXEX+1]),
S_BRIGHT (RAXE, 'D', 6, NULL , &States[S_REDAXEX+2]),
S_BRIGHT (RAXE, 'E', 6, NULL , NULL)
};
IMPLEMENT_ACTOR (ARedAxe, Heretic, -1, 128)
PROP_Damage (7)
PROP_FlagsSet (MF_NOBLOCKMAP)
PROP_Flags2Clear (MF2_WINDTHRUST)
PROP_SpawnState (S_REDAXE)
PROP_DeathState (S_REDAXEX)
END_DEFAULTS
AT_SPEED_SET (RedAxe, speed)
{
SimpleSpeedSetter (ARedAxe, 9*FRACUNIT, 18*FRACUNIT, speed);
}
//----------------------------------------------------------------------------
//
// PROC A_DripBlood
@ -218,20 +54,10 @@ void A_KnightAttack (AActor *actor)
S_Sound (actor, CHAN_BODY, actor->AttackSound, 1, ATTN_NORM);
if (actor->flags & MF_SHADOW || pr_knightatk () < 40)
{ // Red axe
P_SpawnMissileZ (actor, actor->z + 36*FRACUNIT, actor->target, RUNTIME_CLASS(ARedAxe));
P_SpawnMissileZ (actor, actor->z + 36*FRACUNIT, actor->target, PClass::FindClass("RedAxe"));
return;
}
// Green axe
P_SpawnMissileZ (actor, actor->z + 36*FRACUNIT, actor->target, RUNTIME_CLASS(AKnightAxe));
P_SpawnMissileZ (actor, actor->z + 36*FRACUNIT, actor->target, PClass::FindClass("KnightAxe"));
}
//---------------------------------------------------------------------------
//
// PROC A_AxeSound
//
//---------------------------------------------------------------------------
void A_AxeSound (AActor *actor)
{
S_Sound (actor, CHAN_BODY, "hknight/axewhoosh", 1, ATTN_NORM);
}

View file

@ -10,126 +10,6 @@
static FRandom pr_wizatk3 ("WizAtk3");
void A_WizAtk1 (AActor *);
void A_WizAtk2 (AActor *);
void A_WizAtk3 (AActor *);
void A_GhostOff (AActor *);
// Class definitions --------------------------------------------------------
FState AWizard::States[] =
{
#define S_WIZARD_LOOK 0
S_NORMAL (WZRD, 'A', 10, A_Look , &States[S_WIZARD_LOOK+1]),
S_NORMAL (WZRD, 'B', 10, A_Look , &States[S_WIZARD_LOOK+0]),
#define S_WIZARD_WALK (S_WIZARD_LOOK+2)
S_NORMAL (WZRD, 'A', 3, A_Chase , &States[S_WIZARD_WALK+1]),
S_NORMAL (WZRD, 'A', 4, A_Chase , &States[S_WIZARD_WALK+2]),
S_NORMAL (WZRD, 'A', 3, A_Chase , &States[S_WIZARD_WALK+3]),
S_NORMAL (WZRD, 'A', 4, A_Chase , &States[S_WIZARD_WALK+4]),
S_NORMAL (WZRD, 'B', 3, A_Chase , &States[S_WIZARD_WALK+5]),
S_NORMAL (WZRD, 'B', 4, A_Chase , &States[S_WIZARD_WALK+6]),
S_NORMAL (WZRD, 'B', 3, A_Chase , &States[S_WIZARD_WALK+7]),
S_NORMAL (WZRD, 'B', 4, A_Chase , &States[S_WIZARD_WALK+0]),
#define S_WIZARD_ATK (S_WIZARD_WALK+8)
S_NORMAL (WZRD, 'C', 4, A_WizAtk1 , &States[S_WIZARD_ATK+1]),
S_NORMAL (WZRD, 'C', 4, A_WizAtk2 , &States[S_WIZARD_ATK+2]),
S_NORMAL (WZRD, 'C', 4, A_WizAtk1 , &States[S_WIZARD_ATK+3]),
S_NORMAL (WZRD, 'C', 4, A_WizAtk2 , &States[S_WIZARD_ATK+4]),
S_NORMAL (WZRD, 'C', 4, A_WizAtk1 , &States[S_WIZARD_ATK+5]),
S_NORMAL (WZRD, 'C', 4, A_WizAtk2 , &States[S_WIZARD_ATK+6]),
S_NORMAL (WZRD, 'C', 4, A_WizAtk1 , &States[S_WIZARD_ATK+7]),
S_NORMAL (WZRD, 'C', 4, A_WizAtk2 , &States[S_WIZARD_ATK+8]),
S_NORMAL (WZRD, 'D', 12, A_WizAtk3 , &States[S_WIZARD_WALK+0]),
#define S_WIZARD_PAIN (S_WIZARD_ATK+9)
S_NORMAL (WZRD, 'E', 3, A_GhostOff , &States[S_WIZARD_PAIN+1]),
S_NORMAL (WZRD, 'E', 3, A_Pain , &States[S_WIZARD_WALK+0]),
#define S_WIZARD_DIE (S_WIZARD_PAIN+2)
S_NORMAL (WZRD, 'F', 6, A_GhostOff , &States[S_WIZARD_DIE+1]),
S_NORMAL (WZRD, 'G', 6, A_Scream , &States[S_WIZARD_DIE+2]),
S_NORMAL (WZRD, 'H', 6, NULL , &States[S_WIZARD_DIE+3]),
S_NORMAL (WZRD, 'I', 6, NULL , &States[S_WIZARD_DIE+4]),
S_NORMAL (WZRD, 'J', 6, A_NoBlocking , &States[S_WIZARD_DIE+5]),
S_NORMAL (WZRD, 'K', 6, NULL , &States[S_WIZARD_DIE+6]),
S_NORMAL (WZRD, 'L', 6, NULL , &States[S_WIZARD_DIE+7]),
S_NORMAL (WZRD, 'M', -1, NULL , NULL)
};
IMPLEMENT_ACTOR (AWizard, Heretic, 15, 19)
PROP_SpawnHealth (180)
PROP_RadiusFixed (16)
PROP_HeightFixed (68)
PROP_Mass (100)
PROP_SpeedFixed (12)
PROP_PainChance (64)
PROP_Flags (MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL|MF_FLOAT|MF_NOGRAVITY)
PROP_Flags2 (MF2_MCROSS|MF2_PASSMOBJ|MF2_PUSHWALL)
PROP_Flags3 (MF3_DONTOVERLAP)
PROP_SpawnState (S_WIZARD_LOOK)
PROP_SeeState (S_WIZARD_WALK)
PROP_PainState (S_WIZARD_PAIN)
PROP_MissileState (S_WIZARD_ATK)
PROP_DeathState (S_WIZARD_DIE)
PROP_SeeSound ("wizard/sight")
PROP_AttackSound ("wizard/attack")
PROP_PainSound ("wizard/pain")
PROP_DeathSound ("wizard/death")
PROP_ActiveSound ("wizard/active")
PROP_Obituary("$OB_WIZARD")
PROP_HitObituary("$OB_WIZARDHIT")
END_DEFAULTS
void AWizard::NoBlockingSet ()
{
P_DropItem (this, "BlasterAmmo", 10, 84);
P_DropItem (this, "ArtiTomeOfPower", 0, 4);
}
class AWizardFX1 : public AActor
{
DECLARE_ACTOR (AWizardFX1, AActor)
};
FState AWizardFX1::States[] =
{
#define S_WIZFX1 0
S_BRIGHT (FX11, 'A', 6, NULL , &States[S_WIZFX1+1]),
S_BRIGHT (FX11, 'B', 6, NULL , &States[S_WIZFX1+0]),
#define S_WIZFXI1 (S_WIZFX1+2)
S_BRIGHT (FX11, 'C', 5, NULL , &States[S_WIZFXI1+1]),
S_BRIGHT (FX11, 'D', 5, NULL , &States[S_WIZFXI1+2]),
S_BRIGHT (FX11, 'E', 5, NULL , &States[S_WIZFXI1+3]),
S_BRIGHT (FX11, 'F', 5, NULL , &States[S_WIZFXI1+4]),
S_BRIGHT (FX11, 'G', 5, NULL , NULL)
};
IMPLEMENT_ACTOR (AWizardFX1, Heretic, -1, 140)
PROP_RadiusFixed (10)
PROP_HeightFixed (6)
PROP_SpeedFixed (18)
PROP_Damage (3)
PROP_Flags (MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY)
PROP_Flags2 (MF2_NOTELEPORT)
PROP_RenderStyle (STYLE_Add)
PROP_SpawnState (S_WIZFX1)
PROP_DeathState (S_WIZFXI1)
END_DEFAULTS
AT_SPEED_SET (WizardFX1, speed)
{
SimpleSpeedSetter (AWizardFX1, 18*FRACUNIT, 24*FRACUNIT, speed);
}
// --- Action functions -----------------------------------------------------
//----------------------------------------------------------------------------
//
// PROC A_GhostOff
@ -191,10 +71,11 @@ void A_WizAtk3 (AActor *actor)
P_TraceBleed (damage, actor->target, actor);
return;
}
mo = P_SpawnMissile (actor, actor->target, RUNTIME_CLASS(AWizardFX1));
const PClass *fx = PClass::FindClass("WizardFX1");
mo = P_SpawnMissile (actor, actor->target, fx);
if (mo != NULL)
{
P_SpawnMissileAngle(actor, RUNTIME_CLASS(AWizardFX1), mo->angle-(ANG45/8), mo->momz);
P_SpawnMissileAngle(actor, RUNTIME_CLASS(AWizardFX1), mo->angle+(ANG45/8), mo->momz);
P_SpawnMissileAngle(actor, fx, mo->angle-(ANG45/8), mo->momz);
P_SpawnMissileAngle(actor, fx, mo->angle+(ANG45/8), mo->momz);
}
}

View file

@ -780,12 +780,18 @@ static void G_DoParseMapInfo (int lump)
break;
case MITL_MAP: // map <MAPNAME> <Nice Name>
{
char maptemp[8];
char *mapname;
levelflags = defaultinfo.flags;
sc.MustGetString ();
if (IsNum (sc.String))
mapname = sc.String;
if (IsNum (mapname))
{ // MAPNAME is a number; assume a Hexen wad
int map = atoi (sc.String);
sprintf (sc.String, "MAP%02d", map);
int mapnum = atoi (mapname);
mysnprintf (maptemp, countof(maptemp), "MAP%02d", mapnum);
mapname = maptemp;
HexenHack = true;
// Hexen levels are automatically nointermission,
// no auto sound sequences, falling damage,
@ -800,7 +806,7 @@ static void G_DoParseMapInfo (int lump)
| LEVEL_MONSTERFALLINGDAMAGE
| LEVEL_HEXENHACK;
}
levelindex = FindWadLevelInfo (sc.String);
levelindex = FindWadLevelInfo (mapname);
if (levelindex == -1)
{
levelindex = wadlevelinfos.Reserve(1);
@ -824,13 +830,13 @@ static void G_DoParseMapInfo (int lump)
{
levelinfo->WallHorizLight = levelinfo->WallVertLight = 0;
}
uppercopy (levelinfo->mapname, sc.String);
uppercopy (levelinfo->mapname, mapname);
sc.MustGetString ();
if (sc.String[0] == '$')
{
// For consistency with other definitions allow $Stringtablename here, too.
levelflags |= LEVEL_LOOKUPLEVELNAME;
ReplaceString (&levelinfo->level_name, sc.String+1);
ReplaceString (&levelinfo->level_name, sc.String + 1);
}
else
{
@ -874,6 +880,7 @@ static void G_DoParseMapInfo (int lump)
}
}
break;
}
case MITL_CLUSTERDEF: // clusterdef <clusternum>
sc.MustGetNumber ();
@ -999,22 +1006,26 @@ static void ParseMapInfoLower (FScanner &sc,
case MITYPE_MAPNAME: {
EndSequence newSeq;
bool useseq = false;
char maptemp[8];
char *mapname;
sc.MustGetString ();
if (IsNum (sc.String))
mapname = sc.String;
if (IsNum (mapname))
{
int map = atoi (sc.String);
int mapnum = atoi (mapname);
if (HexenHack)
{
sprintf (sc.String, "&wt@%02d", map);
mysnprintf (maptemp, countof(maptemp), "&wt@%02d", mapnum);
}
else
{
sprintf (sc.String, "MAP%02d", map);
mysnprintf (maptemp, countof(maptemp), "MAP%02d", mapnum);
}
mapname = maptemp;
}
if (sc.Compare ("endgame"))
if (stricmp (mapname, "endgame") == 0)
{
newSeq.Advanced = true;
newSeq.EndType = END_Pic1;
@ -1064,7 +1075,7 @@ static void ParseMapInfoLower (FScanner &sc,
}
useseq = true;
}
else if (strnicmp (sc.String, "EndGame", 7) == 0)
else if (strnicmp (mapname, "EndGame", 7) == 0)
{
int type;
switch (sc.String[7])
@ -1080,46 +1091,46 @@ static void ParseMapInfoLower (FScanner &sc,
newSeq.EndType = type;
useseq = true;
}
else if (sc.Compare ("endpic"))
else if (stricmp (mapname, "endpic") == 0)
{
sc.MustGetString ();
newSeq.EndType = END_Pic;
newSeq.PicName = sc.String;
useseq = true;
}
else if (sc.Compare ("endbunny"))
else if (stricmp (mapname, "endbunny") == 0)
{
newSeq.EndType = END_Bunny;
useseq = true;
}
else if (sc.Compare ("endcast"))
else if (stricmp (mapname, "endcast") == 0)
{
newSeq.EndType = END_Cast;
useseq = true;
}
else if (sc.Compare ("enddemon"))
else if (stricmp (mapname, "enddemon") == 0)
{
newSeq.EndType = END_Demon;
useseq = true;
}
else if (sc.Compare ("endchess"))
else if (stricmp (mapname, "endchess") == 0)
{
newSeq.EndType = END_Chess;
useseq = true;
}
else if (sc.Compare ("endunderwater"))
else if (stricmp (mapname, "endunderwater") == 0)
{
newSeq.EndType = END_Underwater;
useseq = true;
}
else if (sc.Compare ("endbuystrife"))
else if (stricmp (mapname, "endbuystrife") == 0)
{
newSeq.EndType = END_BuyStrife;
useseq = true;
}
else
{
strncpy ((char *)(info + handler->data1), sc.String, 8);
strncpy ((char *)(info + handler->data1), mapname, 8);
}
if (useseq)
{
@ -1550,26 +1561,22 @@ void P_RemoveDefereds (void)
}
}
bool CheckWarpTransMap (char mapname[9], bool substitute)
bool CheckWarpTransMap (FString &mapname, bool substitute)
{
if (mapname[0] == '&' && (mapname[1]&223) == 'W' &&
(mapname[2]&223) == 'T' && mapname[3] == '@')
if (mapname[0] == '&' && (mapname[1] & 0xDF) == 'W' &&
(mapname[2] & 0xDF) == 'T' && mapname[3] == '@')
{
level_info_t *lev = FindLevelByWarpTrans (atoi (mapname + 4));
level_info_t *lev = FindLevelByWarpTrans (atoi (&mapname[4]));
if (lev != NULL)
{
strncpy (mapname, lev->mapname, 8);
mapname[8] = 0;
mapname = lev->mapname;
return true;
}
else if (substitute)
{
mapname[0] = 'M';
mapname[1] = 'A';
mapname[2] = 'P';
mapname[3] = mapname[4];
mapname[4] = mapname[5];
mapname[5] = 0;
char a = mapname[4], b = mapname[5];
mapname = "MAP";
mapname << a << b;
}
}
return false;
@ -1580,12 +1587,12 @@ bool CheckWarpTransMap (char mapname[9], bool substitute)
// Can be called by the startup code or the menu task,
// consoleplayer, playeringame[] should be set.
//
static char d_mapname[256];
static FString d_mapname;
static int d_skill=-1;
void G_DeferedInitNew (const char *mapname, int newskill)
{
strncpy (d_mapname, mapname, 8);
d_mapname = mapname;
d_skill = newskill;
CheckWarpTransMap (d_mapname, true);
gameaction = ga_newgame2;
@ -1625,10 +1632,11 @@ CCMD (open)
}
if (argv.argc() > 1)
{
sprintf(d_mapname, "file:%s", argv[1]);
d_mapname = "file:";
d_mapname += argv[1];
if (!P_CheckMapData(d_mapname))
{
Printf ("No map %s\n", d_mapname);
Printf ("No map %s\n", d_mapname.GetChars());
}
else
{
@ -1679,7 +1687,10 @@ void G_DoNewGame (void)
{
G_NewInit ();
playeringame[consoleplayer] = 1;
if (d_skill != -1) gameskill = d_skill;
if (d_skill != -1)
{
gameskill = d_skill;
}
G_InitNew (d_mapname, false);
gameaction = ga_nothing;
}
@ -2004,34 +2015,30 @@ void G_DoCompleted (void)
AM_Stop ();
wminfo.finished_ep = level.cluster - 1;
strncpy (wminfo.lname0, level.info->pname, 8);
strncpy (wminfo.current, level.mapname, 8);
wminfo.lname0 = level.info->pname;
wminfo.current = level.mapname;
if (deathmatch &&
(dmflags & DF_SAME_LEVEL) &&
!(level.flags & LEVEL_CHANGEMAPCHEAT))
{
strncpy (wminfo.next, level.mapname, 8);
strncpy (wminfo.lname1, level.info->pname, 8);
wminfo.next = level.mapname;
wminfo.lname1 = level.info->pname;
}
else
{
if (strncmp (nextlevel, "enDSeQ", 6) == 0)
{
strncpy (wminfo.next, nextlevel, 8);
wminfo.lname1[0] = 0;
wminfo.next = FString(nextlevel, 8);
wminfo.lname1 = "";
}
else
{
level_info_t *nextinfo = FindLevelInfo (nextlevel);
strncpy (wminfo.next, nextinfo->mapname, 8);
strncpy (wminfo.lname1, nextinfo->pname, 8);
wminfo.next = nextinfo->mapname;
wminfo.lname1 = nextinfo->pname;
}
}
wminfo.next[8]=0;
wminfo.lname0[8]=0;
wminfo.lname1[8]=0;
wminfo.current[8]=0;
CheckWarpTransMap (wminfo.next, true);
@ -2632,21 +2639,18 @@ bool FLevelLocals::IsFreelookAllowed() const
return !(dmflags & DF_NO_FREELOOK);
}
char *CalcMapName (int episode, int level)
FString CalcMapName (int episode, int level)
{
static char lumpname[9];
FString lumpname;
if (gameinfo.flags & GI_MAPxx)
{
sprintf (lumpname, "MAP%02d", level);
lumpname.Format("MAP%02d", level);
}
else
{
lumpname[0] = 'E';
lumpname[1] = '0' + episode;
lumpname[2] = 'M';
lumpname[3] = '0' + level;
lumpname[4] = 0;
lumpname = "";
lumpname << 'E' << ('0' + episode) << 'M' << ('0' + level);
}
return lumpname;
}
@ -2745,11 +2749,11 @@ const char *G_MaybeLookupLevelName (level_info_t *ininfo)
// Strip out the header from the localized string
if (info->mapname[0] == 'E' && info->mapname[2] == 'M')
{
sprintf (checkstring, "%s: ", info->mapname);
mysnprintf (checkstring, countof(checkstring), "%s: ", info->mapname);
}
else if (info->mapname[0] == 'M' && info->mapname[1] == 'A' && info->mapname[2] == 'P')
{
sprintf (checkstring, "%d: ", atoi(info->mapname + 3));
mysnprintf (checkstring, countof(checkstring), "%d: ", atoi(info->mapname + 3));
}
thename = strstr (lookedup, checkstring);
if (thename == NULL)

View file

@ -356,7 +356,7 @@ extern FWorldGlobalArray ACS_GlobalArrays[NUM_GLOBALVARS];
extern bool savegamerestore;
// mapname will be changed if it is a valid warptrans
bool CheckWarpTransMap (char mapname[9], bool substitute);
bool CheckWarpTransMap (FString &mapname, bool substitute);
void G_InitNew (const char *mapname, bool bTitleLevel);
@ -391,7 +391,7 @@ level_info_t *FindLevelInfo (const char *mapname);
level_info_t *FindLevelByNum (int num);
level_info_t *CheckLevelRedirect (level_info_t *info);
char *CalcMapName (int episode, int level);
FString CalcMapName (int episode, int level);
void G_ParseMapInfo (void);
void G_UnloadMapInfo ();

View file

@ -110,7 +110,7 @@ FState AMinotaur::States[] =
S_NORMAL (MNTR, 'E', 5, NULL , &States[S_MNTR_FADEOUT+6]),
S_NORMAL (MNTR, 'E', 5, A_MinotaurFade1 , &States[S_MNTR_FADEOUT+7]),
S_NORMAL (MNTR, 'E', 5, A_MinotaurFade0 , &States[S_MNTR_FADEOUT+8]),
S_NORMAL (MNTR, 'E', 10, NULL , NULL),
S_NORMAL (MNTR, 'E', 10, A_BossDeath , NULL),
};
IMPLEMENT_ACTOR (AMinotaur, Heretic, 9, 0)
@ -124,6 +124,7 @@ IMPLEMENT_ACTOR (AMinotaur, Heretic, 9, 0)
PROP_Flags (MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL|MF_DROPOFF)
PROP_Flags2 (MF2_FLOORCLIP|MF2_PASSMOBJ|MF2_BOSS|MF2_PUSHWALL)
PROP_Flags3 (MF3_NORADIUSDMG|MF3_DONTMORPH|MF3_NOTARGET)
PROP_Flags4 (MF4_BOSSDEATH)
PROP_SpawnState (S_MNTR_LOOK)
PROP_SeeState (S_MNTR_WALK)

View file

@ -41,7 +41,7 @@ void P_SpawnDirt (AActor *actor, fixed_t radius)
z = actor->z + (pr_dirt()<<9) + FRACUNIT;
char fmt[8];
sprintf(fmt, "Dirt%d", 1 + pr_dirt()%6);
mysnprintf(fmt, countof(fmt), "Dirt%d", 1 + pr_dirt()%6);
dtype = PClass::FindClass(fmt);
if (dtype)
{

View file

@ -151,12 +151,15 @@ bool P_MorphPlayer (player_t *activator, player_t *p, const PClass *spawntype, i
// taking events, set up the face, if any;
// this is only needed for old-skool skins
// and for the original DOOM status bar.
if ((p == &players[consoleplayer]) &&
(strcmp(spawntype->Meta.GetMetaString (APMETA_Face), "None") != 0))
if (p == &players[consoleplayer])
{
StatusBar->SetFace(&skins[p->MorphedPlayerClass]);
}
const char *face = spawntype->Meta.GetMetaString (APMETA_Face);
if (face != NULL && strcmp(face, "None") != 0)
{
StatusBar->SetFace(&skins[p->MorphedPlayerClass]);
}
}
return true;
}

View file

@ -922,7 +922,8 @@ CCMD (weaponsection)
tackOn = fullSection + 4;
}
sprintf (tackOn, ".%s.WeaponSlots", WeaponSection.GetChars());
mysnprintf (tackOn, countof(fullSection) - (tackOn - fullSection),
".%s.WeaponSlots", WeaponSection.GetChars());
if (GameConfig->SetSection (fullSection))
{
LocalWeapons.RestoreSlots (*GameConfig);
@ -1032,7 +1033,7 @@ void FWeaponSlots::SaveSlots (FConfigFile &config)
}
if (index > 0)
{
sprintf (keyname, "Slot[%d]", i);
mysnprintf (keyname, countof(keyname), "Slot[%d]", i);
config.SetValueForKey (keyname, buff);
}
}

View file

@ -179,7 +179,7 @@ static void DrawHudNumber(int color, int num, int x, int y, int trans=0xc000)
{
char text[15];
sprintf(text, "%d", num);
mysnprintf(text, countof(text), "%d", num);
DrawHudText(color, text, x, y, trans);
}
@ -206,7 +206,7 @@ static void DrawStatus(player_t * CPlayer, int x, int y)
DTA_KeepRatio, true,
DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, 0xc000, TAG_DONE);
sprintf(tempstr, "%i ", CPlayer->accuracy);
mysnprintf(tempstr, countof(tempstr), "%i ", CPlayer->accuracy);
screen->DrawText(hudcolor_stats, x+space, y, tempstr,
DTA_KeepRatio, true,
DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, 0xc000, TAG_DONE);
@ -216,7 +216,7 @@ static void DrawStatus(player_t * CPlayer, int x, int y)
DTA_KeepRatio, true,
DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, 0xc000, TAG_DONE);
sprintf(tempstr, "%i ", CPlayer->stamina);
mysnprintf(tempstr, countof(tempstr), "%i ", CPlayer->stamina);
screen->DrawText(hudcolor_stats, x+space, y, tempstr,
DTA_KeepRatio, true,
DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, 0xc000, TAG_DONE);
@ -235,7 +235,7 @@ static void DrawStatus(player_t * CPlayer, int x, int y)
DTA_KeepRatio, true,
DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, 0xc000, TAG_DONE);
sprintf(tempstr, "%i/%i ", multiplayer? CPlayer->secretcount : level.found_secrets, level.total_secrets);
mysnprintf(tempstr, countof(tempstr), "%i/%i ", multiplayer? CPlayer->secretcount : level.found_secrets, level.total_secrets);
screen->DrawText(hudcolor_stats, x+space, y, tempstr,
DTA_KeepRatio, true,
DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, 0xc000, TAG_DONE);
@ -248,7 +248,7 @@ static void DrawStatus(player_t * CPlayer, int x, int y)
DTA_KeepRatio, true,
DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, 0xc000, TAG_DONE);
sprintf(tempstr, "%i/%i ", multiplayer? CPlayer->itemcount : level.found_items, level.total_items);
mysnprintf(tempstr, countof(tempstr), "%i/%i ", multiplayer? CPlayer->itemcount : level.found_items, level.total_items);
screen->DrawText(hudcolor_stats, x+space, y, tempstr,
DTA_KeepRatio, true,
DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, 0xc000, TAG_DONE);
@ -261,7 +261,7 @@ static void DrawStatus(player_t * CPlayer, int x, int y)
DTA_KeepRatio, true,
DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, 0xc000, TAG_DONE);
sprintf(tempstr, "%i/%i ", multiplayer? CPlayer->killcount : level.killed_monsters, level.total_monsters);
mysnprintf(tempstr, countof(tempstr), "%i/%i ", multiplayer? CPlayer->killcount : level.killed_monsters, level.total_monsters);
screen->DrawText(hudcolor_stats, x+space, y, tempstr,
DTA_KeepRatio, true,
DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, 0xc000, TAG_DONE);
@ -548,7 +548,7 @@ static int DrawAmmo(player_t * CPlayer, int x, int y)
int maxammo = inv->MaxAmount;
int ammo = ammoitem? ammoitem->Amount : 0;
sprintf(buf,"%3d/%3d", ammo,maxammo);
mysnprintf(buf, countof(buf), "%3d/%3d", ammo, maxammo);
int tex_width= clamp<int>(ConFont->StringWidth(buf)-def_width, 0, 1000);
@ -692,7 +692,7 @@ static void DrawInventory(player_t * CPlayer, int x,int y)
{
char buffer[10];
int xx;
sprintf(buffer,"%d",rover->Amount);
mysnprintf(buffer, countof(buffer), "%d", rover->Amount);
if (rover->Amount>=1000) xx = 32 - IndexFont->StringWidth(buffer);
else xx = 22;
@ -764,17 +764,17 @@ static void DrawCoordinates(player_t * CPlayer)
int xpos = vwidth - SmallFont->StringWidth("X: -00000")-6;
int ypos = 18;
sprintf(coordstr, "X: %d", x>>FRACBITS);
mysnprintf(coordstr, countof(coordstr), "X: %d", x>>FRACBITS);
screen->DrawText(hudcolor_xyco, xpos, ypos, coordstr,
DTA_KeepRatio, true,
DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, TAG_DONE);
sprintf(coordstr, "Y: %d", y>>FRACBITS);
mysnprintf(coordstr, countof(coordstr), "Y: %d", y>>FRACBITS);
screen->DrawText(hudcolor_xyco, xpos, ypos+h, coordstr,
DTA_KeepRatio, true,
DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, TAG_DONE);
sprintf(coordstr, "Z: %d", z>>FRACBITS);
mysnprintf(coordstr, countof(coordstr), "Z: %d", z>>FRACBITS);
screen->DrawText(hudcolor_xyco, xpos, ypos+2*h, coordstr,
DTA_KeepRatio, true,
DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, TAG_DONE);
@ -864,15 +864,15 @@ void DrawHUD()
if (am_showtotaltime)
{
seconds = level.totaltime / TICRATE;
sprintf(printstr, "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60);
mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60);
DrawHudText(hudcolor_ttim, printstr, hudwidth-length, bottom, FRACUNIT);
bottom -= fonth;
}
if (am_showtime)
{
seconds= level.time /TICRATE;
sprintf(printstr, "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60);
seconds = level.time /TICRATE;
mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60);
DrawHudText(hudcolor_time, printstr, hudwidth-length, bottom, FRACUNIT);
bottom -= fonth;
@ -880,12 +880,12 @@ void DrawHUD()
if (level.clusterflags&CLUSTER_HUB)
{
seconds= level.maptime /TICRATE;
sprintf(printstr, "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60);
mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60);
DrawHudText(hudcolor_ltim, printstr, hudwidth-length, bottom, FRACUNIT);
}
}
sprintf(printstr,"%s: %s",level.mapname,level.level_name);
mysnprintf(printstr, countof(printstr), "%s: %s", level.mapname, level.level_name);
screen->DrawText(hudcolor_titl, 1, hudheight-fonth-1, printstr,
DTA_KeepRatio, true,
DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, TAG_DONE);

View file

@ -109,10 +109,10 @@ CUSTOM_CVAR (Int, crosshair, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
num = -num;
}
size = (SCREENWIDTH < 640) ? 'S' : 'B';
sprintf (name, "XHAIR%c%d", size, num);
mysnprintf (name, countof(name), "XHAIR%c%d", size, num);
if ((lump = Wads.CheckNumForName (name, ns_graphics)) == -1)
{
sprintf (name, "XHAIR%c1", size);
mysnprintf (name, countof(name), "XHAIR%c1", size);
if ((lump = Wads.CheckNumForName (name, ns_graphics)) == -1)
{
strcpy (name, "XHAIRS1");
@ -1155,7 +1155,7 @@ void DBaseStatusBar::Draw (EHudState state)
value = &CPlayer->mo->z;
for (i = 2, value = &CPlayer->mo->z; i >= 0; y -= height, --value, --i)
{
sprintf (line, "%c: %d", labels[i], *value >> FRACBITS);
mysnprintf (line, countof(line), "%c: %d", labels[i], *value >> FRACBITS);
screen->DrawText (CR_GREEN, xpos, y, line,
DTA_KeepRatio, true,
DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight,
@ -1184,13 +1184,13 @@ void DBaseStatusBar::Draw (EHudState state)
y = 8;
if (am_showtime)
{
sprintf (line, "%02d:%02d:%02d", time/3600, (time%3600)/60, time%60); // Time
mysnprintf (line, countof(line), "%02d:%02d:%02d", time/3600, (time%3600)/60, time%60); // Time
screen->DrawText (CR_GREY, SCREENWIDTH - 80*CleanXfac, y, line, DTA_CleanNoMove, true, TAG_DONE);
y+=8*CleanYfac;
}
if (am_showtotaltime)
{
sprintf (line, "%02d:%02d:%02d", totaltime/3600, (totaltime%3600)/60, totaltime%60); // Total time
mysnprintf (line, countof(line), "%02d:%02d:%02d", totaltime/3600, (totaltime%3600)/60, totaltime%60); // Total time
screen->DrawText (CR_GREY, SCREENWIDTH - 80*CleanXfac, y, line, DTA_CleanNoMove, true, TAG_DONE);
}
@ -1233,7 +1233,7 @@ void DBaseStatusBar::Draw (EHudState state)
i = 0;
if (cluster == NULL || !(cluster->flags & CLUSTER_HUB))
{
i = sprintf (line, "%s: ", level.mapname);
i = mysnprintf (line, countof(line), "%s: ", level.mapname);
}
line[i] = TEXTCOLOR_ESCAPE;
line[i+1] = CR_GREY + 'A';
@ -1249,9 +1249,8 @@ void DBaseStatusBar::Draw (EHudState state)
// Draw monster count
if (am_showmonsters)
{
sprintf (line, "MONSTERS:"
TEXTCOLOR_GREY " %d/%d",
level.killed_monsters, level.total_monsters);
mysnprintf (line, countof(line), "MONSTERS:" TEXTCOLOR_GREY " %d/%d",
level.killed_monsters, level.total_monsters);
screen->DrawText (highlight, 8, y, line,
DTA_CleanNoMove, true, TAG_DONE);
y += height;
@ -1260,9 +1259,8 @@ void DBaseStatusBar::Draw (EHudState state)
// Draw secret count
if (am_showsecrets)
{
sprintf (line, "SECRETS:"
TEXTCOLOR_GREY " %d/%d",
level.found_secrets, level.total_secrets);
mysnprintf (line, countof(line), "SECRETS:" TEXTCOLOR_GREY " %d/%d",
level.found_secrets, level.total_secrets);
screen->DrawText (highlight, 8, y, line,
DTA_CleanNoMove, true, TAG_DONE);
y += height;
@ -1271,9 +1269,8 @@ void DBaseStatusBar::Draw (EHudState state)
// Draw item count
if (am_showitems)
{
sprintf (line, "ITEMS:"
TEXTCOLOR_GREY " %d/%d",
level.found_items, level.total_items);
mysnprintf (line, countof(line), "ITEMS:" TEXTCOLOR_GREY " %d/%d",
level.found_items, level.total_items);
screen->DrawText (highlight, 8, y, line,
DTA_CleanNoMove, true, TAG_DONE);
}
@ -1661,16 +1658,16 @@ void DBaseStatusBar::AddFaceToImageCollectionActual (void *skn, FImageCollection
{
for (j = 0; j < ST_NUMSTRAIGHTFACES; j++)
{
sprintf (names[facenum++], "%sST%d%d", prefix, i, j);
mysnprintf (names[facenum++], countof(names[0]), "%sST%d%d", prefix, i, j);
}
sprintf (names[facenum++], "%sTR%d0", prefix, i); // turn right
sprintf (names[facenum++], "%sTL%d0", prefix, i); // turn left
sprintf (names[facenum++], "%sOUCH%d", prefix, i); // ouch!
sprintf (names[facenum++], "%sEVL%d", prefix, i); // evil grin ;)
sprintf (names[facenum++], "%sKILL%d", prefix, i); // pissed off
mysnprintf (names[facenum++], countof(names[0]), "%sTR%d0", prefix, i); // turn right
mysnprintf (names[facenum++], countof(names[0]), "%sTL%d0", prefix, i); // turn left
mysnprintf (names[facenum++], countof(names[0]), "%sOUCH%d", prefix, i); // ouch!
mysnprintf (names[facenum++], countof(names[0]), "%sEVL%d", prefix, i); // evil grin ;)
mysnprintf (names[facenum++], countof(names[0]), "%sKILL%d", prefix, i); // pissed off
}
sprintf (names[facenum++], "%sGOD0", prefix);
sprintf (names[facenum++], "%sDEAD0", prefix);
mysnprintf (names[facenum++], countof(names[0]), "%sGOD0", prefix);
mysnprintf (names[facenum++], countof(names[0]), "%sDEAD0", prefix);
images->Add (nameptrs, ST_NUMFACES, namespc);
}

View file

@ -577,7 +577,7 @@ void A_AlienSpectreDeath (AActor *self)
{
return;
}
sprintf (voc, "svox/voc%d", log);
mysnprintf (voc, countof(voc), "svox/voc%d", log);
S_Sound (CHAN_VOICE, voc, 1, ATTN_NORM);
player->player->SetLogNumber (log);
}

View file

@ -33,7 +33,7 @@ const char *ACoin::PickupMessage ()
{
static char msg[64];
sprintf (msg, GStrings("TXT_XGOLD"), Amount);
mysnprintf (msg, countof(msg), GStrings("TXT_XGOLD"), Amount);
return msg;
}
}

View file

@ -84,7 +84,7 @@ void A_GiveQuestItem (AActor *self)
char messageid[64];
sprintf(messageid, "TXT_QUEST_%d", questitem);
mysnprintf(messageid, countof(messageid), "TXT_QUEST_%d", questitem);
const char * name = GStrings[messageid];
if (name != NULL)

View file

@ -584,7 +584,7 @@ private:
{
case POP_Log:
// Draw the latest log message.
sprintf (buff, "%02d:%02d:%02d",
mysnprintf (buff, countof(buff), "%02d:%02d:%02d",
(level.time/TICRATE)/3600,
((level.time/TICRATE)%3600)/60,
(level.time/TICRATE)%60);

View file

@ -142,100 +142,6 @@ void FGameConfigFile::MigrateOldConfig ()
// Set default key bindings. These will be overridden
// by the bindings in the config file if it exists.
C_SetDefaultBindings ();
#if 0 // Disabled for now, maybe forever.
int i;
char *execcommand;
i = strlen (GetPathName ()) + 8;
execcommand = new char[i];
sprintf (execcommand, "exec \"%s\"", GetPathName ());
execcommand[i-5] = 'c';
execcommand[i-4] = 'f';
execcommand[i-3] = 'g';
cvar_defflags = CVAR_ARCHIVE;
C_DoCommand (execcommand);
cvar_defflags = 0;
delete[] execcommand;
FBaseCVar *configver = FindCVar ("configver", NULL);
if (configver != NULL)
{
UCVarValue oldver = configver->GetGenericRep (CVAR_Float);
if (oldver.Float < 118.f)
{
C_DoCommand ("alias idclip noclip");
C_DoCommand ("alias idspispopd noclip");
if (oldver.Float < 117.2f)
{
dimamount = *dimamount * 0.25f;
if (oldver.Float <= 113.f)
{
C_DoCommand ("bind t messagemode; bind \\ +showscores;"
"bind f12 spynext; bind sysrq screenshot");
if (C_GetBinding (KEY_F5) && !stricmp (C_GetBinding (KEY_F5), "menu_video"))
{
C_ChangeBinding ("menu_display", KEY_F5);
}
}
}
}
delete configver;
}
// Change all impulses to slot commands
for (i = 0; i < NUM_KEYS; i++)
{
char slotcmd[8] = "slot ";
char *bind, *numpart;
bind = C_GetBinding (i);
if (bind != NULL && strnicmp (bind, "impulse ", 8) == 0)
{
numpart = strchr (bind, ' ');
if (numpart != NULL && strlen (numpart) < 4)
{
strcpy (slotcmd + 5, numpart);
C_ChangeBinding (slotcmd, i);
}
}
}
// Migrate and delete some obsolete cvars
FBaseCVar *oldvar;
UCVarValue oldval;
oldvar = FindCVar ("autoexec", NULL);
if (oldvar != NULL)
{
oldval = oldvar->GetGenericRep (CVAR_String);
if (oldval.String[0])
{
SetSection ("Doom.AutoExec", true);
SetValueForKey ("Path", oldval.String, true);
}
delete oldvar;
}
oldvar = FindCVar ("def_patch", NULL);
if (oldvar != NULL)
{
oldval = oldvar->GetGenericRep (CVAR_String);
if (oldval.String[0])
{
SetSection ("Doom.DefaultDehacked", true);
SetValueForKey ("Path", oldval.String, true);
}
delete oldvar;
}
oldvar = FindCVar ("vid_noptc", NULL);
if (oldvar != NULL)
{
delete oldvar;
}
#endif
}
void FGameConfigFile::DoGlobalSetup ()
@ -334,15 +240,17 @@ void FGameConfigFile::DoGameSetup (const char *gamename)
{
MigrateOldConfig ();
}
subsection = section + sprintf (section, "%s.", gamename);
sublen = countof(section) - 1 - mysnprintf (section, countof(section), "%s.", gamename);
subsection = section + countof(section) - sublen - 1;
section[countof(section) - 1] = '\0';
strcpy (subsection, "UnknownConsoleVariables");
strncpy (subsection, "UnknownConsoleVariables", sublen);
if (SetSection (section))
{
ReadCVars (0);
}
strcpy (subsection, "ConsoleVariables");
strncpy (subsection, "ConsoleVariables", sublen);
if (SetSection (section))
{
ReadCVars (0);
@ -355,19 +263,19 @@ void FGameConfigFile::DoGameSetup (const char *gamename)
// The NetServerInfo section will be read when it's determined that
// a netgame is being played.
strcpy (subsection, "LocalServerInfo");
strncpy (subsection, "LocalServerInfo", sublen);
if (SetSection (section))
{
ReadCVars (0);
}
strcpy (subsection, "Player");
strncpy (subsection, "Player", sublen);
if (SetSection (section))
{
ReadCVars (0);
}
strcpy (subsection, "Bindings");
strncpy (subsection, "Bindings", sublen);
if (!SetSection (section))
{ // Config has no bindings for the given game
if (!bMigrating)
@ -384,7 +292,7 @@ void FGameConfigFile::DoGameSetup (const char *gamename)
}
}
strcpy (subsection, "DoubleBindings");
strncpy (subsection, "DoubleBindings", sublen);
if (SetSection (section))
{
while (NextInSection (key, value))
@ -393,7 +301,7 @@ void FGameConfigFile::DoGameSetup (const char *gamename)
}
}
strcpy (subsection, "ConsoleAliases");
strncpy (subsection, "ConsoleAliases", sublen);
if (SetSection (section))
{
const char *name = NULL;
@ -415,7 +323,7 @@ void FGameConfigFile::DoGameSetup (const char *gamename)
// Separated from DoGameSetup because it needs all the weapons properly defined
void FGameConfigFile::DoWeaponSetup (const char *gamename)
{
strcpy (subsection, "WeaponSlots");
strncpy (subsection, "WeaponSlots", sublen);
if (!SetSection (section) || !LocalWeapons.RestoreSlots (*this))
{
@ -425,7 +333,7 @@ void FGameConfigFile::DoWeaponSetup (const char *gamename)
void FGameConfigFile::ReadNetVars ()
{
strcpy (subsection, "NetServerInfo");
strncpy (subsection, "NetServerInfo", sublen);
if (SetSection (section))
{
ReadCVars (0);
@ -455,19 +363,20 @@ void FGameConfigFile::ArchiveGameData (const char *gamename)
{
char section[32*3], *subsection;
subsection = section + sprintf (section, "%s.", gamename);
sublen = countof(section) - 1 - mysnprintf (section, countof(section), "%s.", gamename);
subsection = section + countof(section) - 1 - sublen;
strcpy (subsection, "Player");
strncpy (subsection, "Player", sublen);
SetSection (section, true);
ClearCurrentSection ();
C_ArchiveCVars (this, 4);
strcpy (subsection, "ConsoleVariables");
strncpy (subsection, "ConsoleVariables", sublen);
SetSection (section, true);
ClearCurrentSection ();
C_ArchiveCVars (this, 0);
strcpy (subsection, netgame ? "NetServerInfo" : "LocalServerInfo");
strncpy (subsection, netgame ? "NetServerInfo" : "LocalServerInfo", sublen);
if (!netgame || consoleplayer == 0)
{ // Do not overwrite this section if playing a netgame, and
// this machine was not the initial host.
@ -476,35 +385,35 @@ void FGameConfigFile::ArchiveGameData (const char *gamename)
C_ArchiveCVars (this, 5);
}
strcpy (subsection, "UnknownConsoleVariables");
strncpy (subsection, "UnknownConsoleVariables", sublen);
SetSection (section, true);
ClearCurrentSection ();
C_ArchiveCVars (this, 2);
strcpy (subsection, "ConsoleAliases");
strncpy (subsection, "ConsoleAliases", sublen);
SetSection (section, true);
ClearCurrentSection ();
C_ArchiveAliases (this);
M_SaveCustomKeys (this, section, subsection);
M_SaveCustomKeys (this, section, subsection, sublen);
strcpy (subsection, "Bindings");
SetSection (section, true);
ClearCurrentSection ();
C_ArchiveBindings (this, false);
strcpy (subsection, "DoubleBindings");
strncpy (subsection, "DoubleBindings", sublen);
SetSection (section, true);
ClearCurrentSection ();
C_ArchiveBindings (this, true);
if (WeaponSection.IsEmpty())
{
strcpy (subsection, "WeaponSlots");
strncpy (subsection, "WeaponSlots", sublen);
}
else
{
sprintf (subsection, "%s.WeaponSlots", WeaponSection.GetChars());
mysnprintf (subsection, sublen, "%s.WeaponSlots", WeaponSection.GetChars());
}
SetSection (section, true);
ClearCurrentSection ();
@ -535,7 +444,7 @@ FString FGameConfigFile::GetConfigPath (bool tryProg)
if (pathval != NULL)
return FString(pathval);
#ifndef unix
#ifdef _WIN32
path = NULL;
HRESULT hr;
@ -602,7 +511,7 @@ void FGameConfigFile::AddAutoexec (DArgs *list, const char *game)
const char *key;
const char *value;
sprintf (section, "%s.AutoExec", game);
mysnprintf (section, countof(section), "%s.AutoExec", game);
if (bMigrating)
{

View file

@ -69,6 +69,7 @@ private:
char section[64];
char *subsection;
size_t sublen;
};
extern FString WeaponSection;

View file

@ -213,7 +213,7 @@ static void HU_DoDrawScores (player_t *player, player_t *sortedplayers[MAXPLAYER
if (teams[i].players)
{
char score[80];
sprintf (score, "%d", teams[i].score);
mysnprintf (score, countof(score), "%d", teams[i].score);
screen->SetFont (BigFont);
screen->DrawText (teams[i].GetTextColor (), scorexwidth, gamestate == GS_INTERMISSION ? y * 4 / 5 : y / 2, score,
@ -277,9 +277,9 @@ static void HU_DrawTimeRemaining (int y)
seconds = timeleft / TICRATE;
if (hours)
sprintf (str, "Level ends in %02d:%02d:%02d", hours, minutes, seconds);
mysnprintf (str, countof(str), "Level ends in %02d:%02d:%02d", hours, minutes, seconds);
else
sprintf (str, "Level ends in %02d:%02d", minutes, seconds);
mysnprintf (str, countof(str), "Level ends in %02d:%02d", minutes, seconds);
screen->DrawText (CR_GREY, SCREENWIDTH/2 - SmallFont->StringWidth (str)/2*CleanXfac,
y, str, DTA_CleanNoMove, true, TAG_DONE);
@ -321,7 +321,7 @@ static void HU_DrawPlayer (player_t *player, bool highlight, int x, int y, int h
deathmatch ? color = sb_deathmatch_yourplayercolor : color = sb_cooperative_yourplayercolor;
}
sprintf (str, "%d", deathmatch ? player->fragcount : player->killcount);
mysnprintf (str, countof(str), "%d", deathmatch ? player->fragcount : player->killcount);
screen->DrawText (color, SCREENWIDTH / 4, y, player->playerstate == PST_DEAD && !deathmatch ? "DEAD" : str,
DTA_CleanNoMove, true, TAG_DONE);

View file

@ -900,7 +900,7 @@ const char *neterror (void)
case WSAEDISCON: return "EDISCON";
default:
sprintf (neterr, "%d", code);
mysnprintf (neterr, countof(neterr), "%d", code);
return neterr;
}
}

View file

@ -32,8 +32,8 @@
**
*/
#include "i_system.h"
#include <malloc.h>
#include "i_system.h"
#ifndef _MSC_VER
#define _NORMAL_BLOCK 0

View file

@ -241,7 +241,7 @@ void cht_DoCheat (player_t *player, int cheat)
int killcount = P_Massacre ();
// killough 3/22/98: make more intelligent about plural
// Ty 03/27/98 - string(s) *not* externalized
sprintf (msgbuild, "%d Monster%s Killed", killcount, killcount==1 ? "" : "s");
mysnprintf (msgbuild, countof(msgbuild), "%d Monster%s Killed", killcount, killcount==1 ? "" : "s");
msg = msgbuild;
}
break;

View file

@ -1401,7 +1401,7 @@ void M_QuickSave ()
M_SaveGame (0);
return;
}
sprintf (tempstring, GStrings("QSPROMPT"), quickSaveSlot->Title);
mysnprintf (tempstring, countof(tempstring), GStrings("QSPROMPT"), quickSaveSlot->Title);
strcpy (savegamestring, quickSaveSlot->Title);
M_StartMessage (tempstring, M_QuickSaveResponse, true);
}
@ -1437,7 +1437,7 @@ void M_QuickLoad ()
M_LoadGame (0);
return;
}
sprintf (tempstring, GStrings("QLPROMPT"), quickSaveSlot->Title);
mysnprintf (tempstring, countof(tempstring), GStrings("QLPROMPT"), quickSaveSlot->Title);
M_StartMessage (tempstring, M_QuickLoadResponse, true);
}
@ -1519,20 +1519,20 @@ void M_DrawHereticMainMenu ()
{
int frame = (MenuTime / 5) % 7;
sprintf (name, "FBUL%c0", (frame+2)%7 + 'A');
mysnprintf (name, countof(name), "FBUL%c0", (frame+2)%7 + 'A');
screen->DrawTexture (TexMan[name], 37, 80, DTA_Clean, true, TAG_DONE);
sprintf (name, "FBUL%c0", frame + 'A');
mysnprintf (name, countof(name), "FBUL%c0", frame + 'A');
screen->DrawTexture (TexMan[name], 278, 80, DTA_Clean, true, TAG_DONE);
}
else
{
int frame = (MenuTime / 3) % 18;
sprintf (name, "M_SKL%.2d", 17 - frame);
mysnprintf (name, countof(name), "M_SKL%.2d", 17 - frame);
screen->DrawTexture (TexMan[name], 40, 10, DTA_Clean, true, TAG_DONE);
sprintf (name, "M_SKL%.2d", frame);
mysnprintf (name, countof(name), "M_SKL%.2d", frame);
screen->DrawTexture (TexMan[name], 232, 10, DTA_Clean, true, TAG_DONE);
}
}
@ -1666,7 +1666,7 @@ static void DrawClassMenu(void)
}
screen->DrawTexture (TexMan[boxLumpName[classnum]], 174, 8, DTA_Clean, true, TAG_DONE);
sprintf (name, walkLumpName[classnum], ((MenuTime >> 3) & 3) + 1);
mysnprintf (name, countof(name), walkLumpName[classnum], ((MenuTime >> 3) & 3) + 1);
screen->DrawTexture (TexMan[name], 174+24, 8+12, DTA_Clean, true, TAG_DONE);
}
@ -2609,9 +2609,8 @@ static void SendNewColor (int red, int green, int blue)
{
char command[24];
sprintf (command, "color \"%02x %02x %02x\"", red, green, blue);
mysnprintf (command, countof(command), "color \"%02x %02x %02x\"", red, green, blue);
C_DoCommand (command);
R_GetPlayerTranslation (MAKERGB (red, green, blue), &skins[PlayerSkin], translationtables[TRANSLATION_Players][MAXPLAYERS]);
}
@ -2967,7 +2966,7 @@ bool M_SaveLoadResponder (event_t *ev)
case GK_F1:
if (!SelSaveGame->Filename.IsEmpty())
{
sprintf (workbuf, "File on disk:\n%s", SelSaveGame->Filename.GetChars());
mysnprintf (workbuf, countof(workbuf), "File on disk:\n%s", SelSaveGame->Filename.GetChars());
if (SaveComment != NULL)
{
V_FreeBrokenLines (SaveComment);

View file

@ -41,7 +41,7 @@ void M_ScreenShot (const char *filename);
void M_LoadDefaults ();
bool M_SaveDefaults (const char *filename);
void M_SaveCustomKeys (FConfigFile *config, char *section, char *subsection);
void M_SaveCustomKeys (FConfigFile *config, char *section, char *subsection, size_t sublen);
FString GetUserFile (const char *path, bool nodir=false);

View file

@ -1440,7 +1440,7 @@ void M_InitVideoModesMenu ()
{
/*
Depths[currval].value = currval;
sprintf (name, "%d bit", i);
mysnprintf (name, countof(name), "%d bit", i);
Depths[currval].name = copystring (name);
*/
BitTranslate[currval++] = i;
@ -1496,13 +1496,13 @@ void M_SizeDisplay (int diff)
CCMD (sizedown)
{
M_SizeDisplay (-1);
S_Sound (CHAN_VOICE, "menu/change", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/change", 1, ATTN_NONE);
}
CCMD (sizeup)
{
M_SizeDisplay (1);
S_Sound (CHAN_VOICE, "menu/change", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/change", 1, ATTN_NONE);
}
// Draws a string in the console font, scaled to the 8x8 cells
@ -1784,7 +1784,7 @@ void M_OptDrawer ()
{
char tbuf[16];
sprintf (tbuf, "%d.", item->b.position);
mysnprintf (tbuf, countof(tbuf), "%d.", item->b.position);
x = CurrentMenu->indent - SmallFont->StringWidth (tbuf);
screen->DrawText (CR_GREY, x, y, tbuf, DTA_Clean, true, TAG_DONE);
}
@ -2077,10 +2077,10 @@ void M_OptDrawer ()
{
if (printed)
{
fillptr += sprintf (fillptr, " ");
fillptr += mysnprintf (fillptr, countof(flagsblah) - (fillptr - flagsblah), " ");
}
printed = true;
fillptr += sprintf (fillptr, "%s = %d", vars[i]->GetName (), **vars[i]);
fillptr += mysnprintf (fillptr, countof(flagsblah) - (fillptr - flagsblah), "%s = %d", vars[i]->GetName (), **vars[i]);
}
}
screen->DrawText (ValueColor,
@ -2177,7 +2177,7 @@ void M_OptResponder (event_t *ev)
CurrentMenu->items[CurrentItem].a.selmode = modecol;
}
S_Sound (CHAN_VOICE, "menu/cursor", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/cursor", 1, ATTN_NONE);
}
break;
@ -2241,7 +2241,7 @@ void M_OptResponder (event_t *ev)
if (CurrentMenu->items[CurrentItem].type == screenres)
CurrentMenu->items[CurrentItem].a.selmode = modecol;
S_Sound (CHAN_VOICE, "menu/cursor", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/cursor", 1, ATTN_NONE);
}
break;
@ -2263,7 +2263,7 @@ void M_OptResponder (event_t *ev)
{
++CurrentItem;
}
S_Sound (CHAN_VOICE, "menu/cursor", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/cursor", 1, ATTN_NONE);
}
break;
@ -2286,7 +2286,7 @@ void M_OptResponder (event_t *ev)
{
++CurrentItem;
}
S_Sound (CHAN_VOICE, "menu/cursor", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/cursor", 1, ATTN_NONE);
}
break;
@ -2324,12 +2324,12 @@ void M_OptResponder (event_t *ev)
else
item->a.cvar->SetGenericRep (newval, CVAR_Float);
}
S_Sound (CHAN_VOICE, "menu/change", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/change", 1, ATTN_NONE);
break;
case palettegrid:
SelColorIndex = (SelColorIndex - 1) & 15;
S_Sound (CHAN_VOICE, "menu/cursor", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/cursor", 1, ATTN_NONE);
break;
case discretes:
@ -2359,14 +2359,14 @@ void M_OptResponder (event_t *ev)
if (item->e.values == Depths)
BuildModesList (SCREENWIDTH, SCREENHEIGHT, DisplayBits);
}
S_Sound (CHAN_VOICE, "menu/change", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/change", 1, ATTN_NONE);
break;
case ediscrete:
value = item->a.cvar->GetGenericRep(CVAR_String);
value.String = const_cast<char *>(M_FindPrevVal(value.String, item->e.enumvalues, (int)item->b.numvalues));
item->a.cvar->SetGenericRep(value, CVAR_String);
S_Sound (CHAN_VOICE, "menu/change", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/change", 1, ATTN_NONE);
break;
case bitmask:
@ -2385,7 +2385,7 @@ void M_OptResponder (event_t *ev)
value.Int = (value.Int & ~bmask) | int(item->e.values[cur].value);
item->a.cvar->SetGenericRep (value, CVAR_Int);
}
S_Sound (CHAN_VOICE, "menu/change", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/change", 1, ATTN_NONE);
break;
case discrete_guid:
@ -2400,14 +2400,14 @@ void M_OptResponder (event_t *ev)
*(item->a.guidcvar) = item->e.guidvalues[cur].ID;
}
S_Sound (CHAN_VOICE, "menu/change", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/change", 1, ATTN_NONE);
break;
case inverter:
value = item->a.cvar->GetGenericRep (CVAR_Float);
value.Float = -value.Float;
item->a.cvar->SetGenericRep (value, CVAR_Float);
S_Sound (CHAN_VOICE, "menu/change", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/change", 1, ATTN_NONE);
break;
case screenres:
@ -2431,7 +2431,7 @@ void M_OptResponder (event_t *ev)
item->a.selmode = col;
}
}
S_Sound (CHAN_VOICE, "menu/cursor", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/cursor", 1, ATTN_NONE);
break;
default:
@ -2473,12 +2473,12 @@ void M_OptResponder (event_t *ev)
else
item->a.cvar->SetGenericRep (newval, CVAR_Float);
}
S_Sound (CHAN_VOICE, "menu/change", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/change", 1, ATTN_NONE);
break;
case palettegrid:
SelColorIndex = (SelColorIndex + 1) & 15;
S_Sound (CHAN_VOICE, "menu/cursor", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/cursor", 1, ATTN_NONE);
break;
case discretes:
@ -2508,14 +2508,14 @@ void M_OptResponder (event_t *ev)
if (item->e.values == Depths)
BuildModesList (SCREENWIDTH, SCREENHEIGHT, DisplayBits);
}
S_Sound (CHAN_VOICE, "menu/change", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/change", 1, ATTN_NONE);
break;
case ediscrete:
value = item->a.cvar->GetGenericRep(CVAR_String);
value.String = const_cast<char *>(M_FindNextVal(value.String, item->e.enumvalues, (int)item->b.numvalues));
item->a.cvar->SetGenericRep(value, CVAR_String);
S_Sound (CHAN_VOICE, "menu/change", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/change", 1, ATTN_NONE);
break;
case bitmask:
@ -2534,7 +2534,7 @@ void M_OptResponder (event_t *ev)
value.Int = (value.Int & ~bmask) | int(item->e.values[cur].value);
item->a.cvar->SetGenericRep (value, CVAR_Int);
}
S_Sound (CHAN_VOICE, "menu/change", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/change", 1, ATTN_NONE);
break;
case discrete_guid:
@ -2549,14 +2549,14 @@ void M_OptResponder (event_t *ev)
*(item->a.guidcvar) = item->e.guidvalues[cur].ID;
}
S_Sound (CHAN_VOICE, "menu/change", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/change", 1, ATTN_NONE);
break;
case inverter:
value = item->a.cvar->GetGenericRep (CVAR_Float);
value.Float = -value.Float;
item->a.cvar->SetGenericRep (value, CVAR_Float);
S_Sound (CHAN_VOICE, "menu/change", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/change", 1, ATTN_NONE);
break;
case screenres:
@ -2583,7 +2583,7 @@ void M_OptResponder (event_t *ev)
item->a.selmode = col;
}
}
S_Sound (CHAN_VOICE, "menu/cursor", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/cursor", 1, ATTN_NONE);
break;
default:
@ -2641,7 +2641,7 @@ void M_OptResponder (event_t *ev)
setmodeneeded = true;
NewBits = BitTranslate[DummyDepthCvar];
}
S_Sound (CHAN_VOICE, "menu/choose", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/choose", 1, ATTN_NONE);
SetModesMenu (NewWidth, NewHeight, NewBits);
}
else if ((item->type == more ||
@ -2652,7 +2652,7 @@ void M_OptResponder (event_t *ev)
&& item->e.mfunc)
{
CurrentMenu->lastOn = CurrentItem;
S_Sound (CHAN_VOICE, "menu/choose", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/choose", 1, ATTN_NONE);
if (item->type == safemore || item->type == rsafemore)
{
ActivateConfirm (item->label, item->e.mfunc);
@ -2687,7 +2687,7 @@ void M_OptResponder (event_t *ev)
if (item->e.values == Depths)
BuildModesList (SCREENWIDTH, SCREENHEIGHT, DisplayBits);
S_Sound (CHAN_VOICE, "menu/change", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/change", 1, ATTN_NONE);
}
else if (item->type == control)
{
@ -2700,7 +2700,7 @@ void M_OptResponder (event_t *ev)
else if (item->type == listelement)
{
CurrentMenu->lastOn = CurrentItem;
S_Sound (CHAN_VOICE, "menu/choose", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/choose", 1, ATTN_NONE);
item->e.lfunc (CurrentItem);
}
else if (item->type == inverter)
@ -2708,7 +2708,7 @@ void M_OptResponder (event_t *ev)
value = item->a.cvar->GetGenericRep (CVAR_Float);
value.Float = -value.Float;
item->a.cvar->SetGenericRep (value, CVAR_Float);
S_Sound (CHAN_VOICE, "menu/change", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/change", 1, ATTN_NONE);
}
else if (item->type == screenres)
{
@ -2716,7 +2716,7 @@ void M_OptResponder (event_t *ev)
else if (item->type == colorpicker)
{
CurrentMenu->lastOn = CurrentItem;
S_Sound (CHAN_VOICE, "menu/choose", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/choose", 1, ATTN_NONE);
StartColorPickerMenu (item->label, item->a.colorcvar);
}
else if (item->type == palettegrid)
@ -2752,7 +2752,7 @@ void M_OptResponder (event_t *ev)
NewBits = BitTranslate[DummyDepthCvar];
setmodeneeded = true;
testingmode = I_GetTime(false) + 5 * TICRATE;
S_Sound (CHAN_VOICE, "menu/choose", 1, ATTN_NONE);
S_Sound (CHAN_VOICE | CHAN_UI, "menu/choose", 1, ATTN_NONE);
SetModesMenu (NewWidth, NewHeight, NewBits);
}
}
@ -3205,7 +3205,7 @@ static void BuildModesList (int hiwidth, int hiheight, int hi_bits)
if (/* hi_bits == showbits && */ width == hiwidth && height == hiheight)
ModesItems[i].e.highlight = ModesItems[i].a.selmode = c;
sprintf (strtemp, "%dx%d%s", width, height, letterbox?TEXTCOLOR_BROWN" LB":"");
mysnprintf (strtemp, countof(strtemp), "%dx%d%s", width, height, letterbox?TEXTCOLOR_BROWN" LB":"");
ReplaceString (str, strtemp);
}
else
@ -3302,7 +3302,7 @@ static void SetModesMenu (int w, int h, int bits)
{
char strtemp[64];
sprintf (strtemp, "TESTING %dx%dx%d", w, h, bits);
mysnprintf (strtemp, countof(strtemp), "TESTING %dx%dx%d", w, h, bits);
ModesItems[VM_ENTERLINE].label = copystring (strtemp);
ModesItems[VM_TESTLINE].label = "Please wait 5 seconds...";
}
@ -3357,7 +3357,7 @@ void M_LoadKeys (const char *modname, bool dbl)
if (GameNames[gameinfo.gametype] == NULL)
return;
sprintf (section, "%s.%s%sBindings", GameNames[gameinfo.gametype], modname,
mysnprintf (section, countof(section), "%s.%s%sBindings", GameNames[gameinfo.gametype], modname,
dbl ? ".Double" : ".");
if (GameConfig->SetSection (section))
{
@ -3388,7 +3388,7 @@ int M_DoSaveKeys (FConfigFile *config, char *section, int i, bool dbl)
return i;
}
void M_SaveCustomKeys (FConfigFile *config, char *section, char *subsection)
void M_SaveCustomKeys (FConfigFile *config, char *section, char *subsection, size_t sublen)
{
if (ControlsMenu.items == ControlsItems)
return;
@ -3404,9 +3404,9 @@ void M_SaveCustomKeys (FConfigFile *config, char *section, char *subsection)
if (item->type == whitetext)
{
assert (item->e.command != NULL);
sprintf (subsection, "%s.Bindings", item->e.command);
mysnprintf (subsection, sublen, "%s.Bindings", item->e.command);
M_DoSaveKeys (config, section, (int)i, false);
sprintf (subsection, "%s.DoubleBindings", item->e.command);
mysnprintf (subsection, sublen, "%s.DoubleBindings", item->e.command);
i = M_DoSaveKeys (config, section, (int)i, true);
}
else

View file

@ -45,9 +45,9 @@
// MACROS ------------------------------------------------------------------
#if defined(_DEBUG) && defined(_WIN32)
#if defined(_DEBUG) && defined(_WIN32) && defined(_MSC_VER)
#define DEBUGOUT(m,c,s,t) \
{ char foo[128]; sprintf(foo, m, c, s, t); OutputDebugString(foo); }
{ char foo[128]; mysnprintf(foo, countof(foo), m, c, s, t); OutputDebugString(foo); }
#else
#define DEBUGOUT(m,c,s,t)
#endif

View file

@ -373,7 +373,7 @@ static void LoadSectors (sectortype *bsec)
sec->floorplane.d = -sec->floortexz;
sec->floorplane.c = FRACUNIT;
sec->floorplane.ic = FRACUNIT;
sprintf (tnam, "BTIL%04d", LittleShort(bsec->floorpicnum));
mysnprintf (tnam, countof(tnam), "BTIL%04d", LittleShort(bsec->floorpicnum));
sec->floorpic = TexMan.GetTexture (tnam, FTexture::TEX_Build);
sec->SetXScale(sector_t::floor, (bsec->floorstat & 8) ? FRACUNIT*2 : FRACUNIT);
sec->SetYScale(sector_t::floor, (bsec->floorstat & 8) ? FRACUNIT*2 : FRACUNIT);
@ -386,7 +386,7 @@ static void LoadSectors (sectortype *bsec)
sec->ceilingplane.d = sec->ceilingtexz;
sec->ceilingplane.c = -FRACUNIT;
sec->ceilingplane.ic = -FRACUNIT;
sprintf (tnam, "BTIL%04d", LittleShort(bsec->ceilingpicnum));
mysnprintf (tnam, countof(tnam), "BTIL%04d", LittleShort(bsec->ceilingpicnum));
sec->ceilingpic = TexMan.GetTexture (tnam, FTexture::TEX_Build);
if (bsec->ceilingstat & 1)
{
@ -480,9 +480,9 @@ static void LoadWalls (walltype *walls, int numwalls, sectortype *bsec)
char tnam[9];
FTextureID overpic, pic;
sprintf (tnam, "BTIL%04d", LittleShort(walls[i].picnum));
mysnprintf (tnam, countof(tnam), "BTIL%04d", LittleShort(walls[i].picnum));
pic = TexMan.GetTexture (tnam, FTexture::TEX_Build);
sprintf (tnam, "BTIL%04d", LittleShort(walls[i].overpicnum));
mysnprintf (tnam, countof(tnam), "BTIL%04d", LittleShort(walls[i].overpicnum));
overpic = TexMan.GetTexture (tnam, FTexture::TEX_Build);
walls[i].x = LittleLong(walls[i].x);
@ -807,7 +807,7 @@ void ACustomSprite::BeginPlay ()
char name[9];
Super::BeginPlay ();
sprintf (name, "BTIL%04d", (args[0] + args[1]*256) & 0xffff);
mysnprintf (name, countof(name), "BTIL%04d", (args[0] + args[1]*256) & 0xffff);
picnum = TexMan.GetTexture (name, FTexture::TEX_Build);
scaleX = args[2] * (FRACUNIT/64);

View file

@ -328,7 +328,7 @@ static FStrifeDialogueNode *ReadRetailNode (FileReader *lump, DWORD &prevSpeaker
// The speaker's voice for this node, if any.
speech.Backdrop[0] = 0; //speech.Sound[8] = 0;
sprintf (fullsound, "svox/%s", speech.Sound);
mysnprintf (fullsound, countof(fullsound), "svox/%s", speech.Sound);
node->SpeakerVoice = fullsound;
// The speaker's name, if any.
@ -397,7 +397,7 @@ static FStrifeDialogueNode *ReadTeaserNode (FileReader *lump, DWORD &prevSpeaker
// The speaker's voice for this node, if any.
if (speech.VoiceNumber != 0)
{
sprintf (fullsound, "svox/voc%u", speech.VoiceNumber);
mysnprintf (fullsound, countof(fullsound), "svox/voc%u", speech.VoiceNumber);
node->SpeakerVoice = fullsound;
}
else
@ -491,7 +491,7 @@ static void ParseReplies (FStrifeDialogueReply **replyptr, Response *responses)
{
char moneystr[128];
sprintf (moneystr, "%s for %u", rsp->Reply, rsp->Count[0]);
mysnprintf (moneystr, countof(moneystr), "%s for %u", rsp->Reply, rsp->Count[0]);
reply->Reply = copystring (moneystr);
reply->NeedsGold = true;
}
@ -759,7 +759,7 @@ void P_StartConversation (AActor *npc, AActor *pc, bool facetalker, bool saveang
++i;
}
char goodbye[25];
sprintf(goodbye, "TXT_RANDOMGOODBYE_%d", 1+(pr_randomspeech() % NUM_RANDOM_GOODBYES));
mysnprintf(goodbye, countof(goodbye), "TXT_RANDOMGOODBYE_%d", 1+(pr_randomspeech() % NUM_RANDOM_GOODBYES));
item.label = (char*)GStrings[goodbye];
if (item.label == NULL) item.label = "Bye.";
item.b.position = i;
@ -907,7 +907,7 @@ static void DrawConversationMenu ()
AInventory *coin = cp->ConversationPC->FindInventory (RUNTIME_CLASS(ACoin));
char goldstr[32];
sprintf (goldstr, "%d", coin != NULL ? coin->Amount : 0);
mysnprintf (goldstr, countof(goldstr), "%d", coin != NULL ? coin->Amount : 0);
screen->DrawText (CR_GRAY, 21, 191, goldstr, DTA_320x200, true,
DTA_FillColor, 0, DTA_Alpha, HR_SHADOW, TAG_DONE);
screen->DrawTexture (TexMan(((AInventory *)GetDefaultByType (RUNTIME_CLASS(ACoin)))->Icon),

View file

@ -265,7 +265,7 @@ void ClientObituary (AActor *self, AActor *inflictor, AActor *attacker)
attacker->player->frags[attacker->player - players]++;
self = attacker;
gender = self->player->userinfo.gender;
sprintf (gendermessage, "OB_FRIENDLY%c", '1' + (pr_obituary() & 3));
mysnprintf (gendermessage, countof(gendermessage), "OB_FRIENDLY%c", '1' + (pr_obituary() & 3));
message = GStrings(gendermessage);
}
else

View file

@ -2718,7 +2718,7 @@ FUNC(LS_SendToCommunicator)
if (it != NULL && it->player != NULL && it->FindInventory(NAME_Communicator))
{
char name[32];
sprintf (name, "svox/voc%d", arg0);
mysnprintf (name, countof(name), "svox/voc%d", arg0);
if (!arg3)
{

View file

@ -362,7 +362,7 @@ void player_t::SetLogNumber (int num)
char lumpname[16];
int lumpnum;
sprintf (lumpname, "LOG%d", num);
mysnprintf (lumpname, countof(lumpname), "LOG%d", num);
lumpnum = Wads.CheckNumForName (lumpname);
if (lumpnum == -1)
{

View file

@ -656,7 +656,7 @@ void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight)
UCVarValue value;
char temp[16];
sprintf (temp, "%d x %d", viewwidth, viewheight);
mysnprintf (temp, countof(temp), "%d x %d", viewwidth, viewheight);
value.String = temp;
r_viewsize.ForceSet (value, CVAR_String);
}

View file

@ -701,6 +701,7 @@ visplane_t *R_CheckPlane (visplane_t *pl, int start, int stop)
new_pl->viewy = pl->viewy;
new_pl->viewz = pl->viewz;
new_pl->viewangle = pl->viewangle;
new_pl->sky = pl->sky;
pl = new_pl;
pl->minx = start;
pl->maxx = stop;

View file

@ -665,7 +665,7 @@ void drawquad(float x0, float y0, float x1, float y1, float x2, float y2, float
void printnum(int x, int y, int num)
{
char foo[16]; sprintf (foo, "%d", num);
char foo[16]; mysnprintf (foo, countof(foo), "%d", num);
RenderTarget->DrawText (CR_WHITE, x, y, foo);
}

View file

@ -476,7 +476,7 @@ void R_InitSkins (void)
{
if (stricmp (skins[i].name, skins[j].name) == 0)
{
sprintf (skins[i].name, "skin%d", (int)i);
mysnprintf (skins[i].name, countof(skins[i].name), "skin%d", (int)i);
Printf (PRINT_BOLD, "Skin %s duplicated as %s\n",
skins[j].name, skins[i].name);
break;
@ -657,7 +657,7 @@ void R_InitSkins (void)
if (!remove)
{
if (skins[i].name[0] == 0)
sprintf (skins[i].name, "skin%d", (int)i);
mysnprintf (skins[i].name, countof(skins[i].name), "skin%d", (int)i);
// Now collect the sprite frames for this skin. If the sprite name was not
// specified, use whatever immediately follows the specifier lump.

View file

@ -1017,7 +1017,7 @@ static void S_AddSNDINFO (int lump)
char temp[16];
sc.MustGetNumber ();
sprintf (temp, "MAP%02d", sc.Number);
mysnprintf (temp, countof(temp), "MAP%02d", sc.Number);
info = FindLevelInfo (temp);
sc.MustGetString ();
if (info->mapname[0] && (!(info->flags & LEVEL_MUSICDEFINED)))

View file

@ -201,21 +201,21 @@ void S_NoiseDebug (void)
else
{
// X coordinate
sprintf (temp, "%.0f", origin.X);
mysnprintf (temp, countof(temp), "%.0f", origin.X);
screen->DrawText (color, 70, y, temp, TAG_DONE);
// Y coordinate
sprintf (temp, "%.0f", origin.Z);
mysnprintf (temp, countof(temp), "%.0f", origin.Z);
screen->DrawText (color, 120, y, temp, TAG_DONE);
// Z coordinate
sprintf (temp, "%.0f", origin.Y);
mysnprintf (temp, countof(temp), "%.0f", origin.Y);
screen->DrawText (color, 170, y, temp, TAG_DONE);
// Distance
if (chan->DistanceScale > 0)
{
sprintf (temp, "%.0f", (origin - listener).Length());
mysnprintf (temp, countof(temp), "%.0f", (origin - listener).Length());
screen->DrawText (color, 260, y, temp, TAG_DONE);
}
else
@ -225,15 +225,15 @@ void S_NoiseDebug (void)
}
// Volume
sprintf (temp, "%.2g", chan->Volume);
mysnprintf (temp, countof(temp), "%.2g", chan->Volume);
screen->DrawText (color, 220, y, temp, TAG_DONE);
// Channel
sprintf (temp, "%d", chan->EntChannel);
mysnprintf (temp, countof(temp), "%d", chan->EntChannel);
screen->DrawText (color, 300, y, temp, TAG_DONE);
// Flags
sprintf (temp, "%s3%sZ%sU%sM%sN%sA%sL%sE",
mysnprintf (temp, countof(temp), "%s3%sZ%sU%sM%sN%sA%sL%sE",
(chan->ChanFlags & CHAN_IS3D) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
(chan->ChanFlags & CHAN_LISTENERZ) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
(chan->ChanFlags & CHAN_UI) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
@ -1770,13 +1770,13 @@ bool S_ChangeCDMusic (int track, unsigned int id, bool looping)
{
char temp[32];
if (id)
if (id != 0)
{
sprintf (temp, ",CD,%d,%x", track, id);
mysnprintf (temp, countof(temp), ",CD,%d,%x", track, id);
}
else
{
sprintf (temp, ",CD,%d", track);
mysnprintf (temp, countof(temp), ",CD,%d", track);
}
return S_ChangeMusic (temp, 0, looping);
}
@ -2054,7 +2054,7 @@ CCMD (playsound)
CCMD (idmus)
{
level_info_t *info;
char *map;
FString map;
int l;
if (argv.argc() > 1)
@ -2063,7 +2063,9 @@ CCMD (idmus)
{
l = atoi (argv[1]);
if (l <= 99)
{
map = CalcMapName (0, l);
}
else
{
Printf ("%s\n", GStrings("STSTR_NOMUS"));
@ -2137,9 +2139,13 @@ CCMD (cd_play)
char musname[16];
if (argv.argc() == 1)
{
strcpy (musname, ",CD,");
}
else
sprintf (musname, ",CD,%d", atoi(argv[1]));
{
mysnprintf (musname, countof(musname), ",CD,%d", atoi(argv[1]));
}
S_ChangeMusic (musname, 0, true);
}

View file

@ -474,7 +474,7 @@ bool TimiditySong::LaunchTimidity ()
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, err, 0, (LPTSTR)&msgBuf, 0, NULL))
{
sprintf (hres, "%08lx", err);
mysnprintf (hres, countof(hres), "%08lx", err);
msgBuf = hres;
}

View file

@ -468,10 +468,10 @@ int TimidityMIDIDevice::PlayTick()
};
#ifdef _WIN32
char buffer[128];
sprintf(buffer, "C%02d: %11s %3d %3d\n", (status & 15) + 1, commands[(status >> 4) & 7], parm1, parm2);
mysnprintf(buffer, countof(buffer), "C%02d: %11s %3d %3d\n", (status & 15) + 1, commands[(status >> 4) & 7], parm1, parm2);
OutputDebugString(buffer);
#else
fprintf(stderr, "C%02d: %11s %3d %3d\n", (status & 15) + 1, commands[(status >> 4) & 7], parm1, parm2);
//fprintf(stderr, "C%02d: %11s %3d %3d\n", (status & 15) + 1, commands[(status >> 4) & 7], parm1, parm2);
#endif
}
}

View file

@ -383,8 +383,8 @@ static bool Cht_ChangeLevel (cheatseq_t *cheat)
static bool Cht_ChangeStartSpot (cheatseq_t *cheat)
{
char cmd[64];
sprintf (cmd, "changemap %s %c", level.mapname, cheat->Args[0]);
mysnprintf (cmd, countof(cmd), "changemap %s %c", level.mapname, cheat->Args[0]);
C_DoCommand (cmd);
return true;
}

View file

@ -43,9 +43,13 @@ extern "C" double CyclesPerSecond;
#define _interlockedbittestandset64 hackfixfor
#define _interlockedbittestandreset64 x64compilation
#define _interlockedbittestandset wtfnmake
#define _interlockedbittestandreset doesittoo
#include <intrin.h>
#undef _interlockedbittestandset64
#undef _interlockedbittestandreset64
#undef _interlockedbittestandset
#undef _interlockedbittestandreset
typedef QWORD cycle_t;

View file

@ -3,5 +3,5 @@
// This file was automatically generated by the
// updaterevision tool. Do not edit by hand.
#define ZD_SVN_REVISION_STRING "1076"
#define ZD_SVN_REVISION_NUMBER 1076
#define ZD_SVN_REVISION_STRING "1082"
#define ZD_SVN_REVISION_NUMBER 1082

View file

@ -79,7 +79,7 @@ FBuildTexture::FBuildTexture (int tilenum, const BYTE *pixels, int width, int he
LeftOffset = left;
TopOffset = top;
CalcBitSize ();
sprintf (Name, "BTIL%04d", tilenum);
mysnprintf (Name, countof(Name), "BTIL%04d", tilenum);
UseType = TEX_Build;
}

View file

@ -287,6 +287,10 @@ static void ParseActionDef (FScanner &sc, PClass *cls)
static FActorInfo *CreateNewActor(FScanner &sc, FActorInfo **parentc, Baggage *bag)
{
FName typeName;
const PClass *replacee = NULL;
int DoomEdNum = -1;
PClass *ti = NULL;
FActorInfo *info = NULL;
// Get actor name
sc.MustGetString();
@ -339,10 +343,14 @@ static FActorInfo *CreateNewActor(FScanner &sc, FActorInfo **parentc, Baggage *b
{
sc.ScriptError ("Parent type '%s' not found", colon);
}
else if (parent->ActorInfo == NULL)
else if (!parent->IsDescendantOf(RUNTIME_CLASS(AActor)))
{
sc.ScriptError ("Parent type '%s' is not an actor", colon);
}
else if (parent->ActorInfo == NULL)
{
sc.ScriptError ("uninitialized parent type '%s'", colon);
}
else
{
*parentc = parent->ActorInfo;
@ -351,8 +359,57 @@ static FActorInfo *CreateNewActor(FScanner &sc, FActorInfo **parentc, Baggage *b
else sc.UnGet();
}
PClass *ti = parent->CreateDerivedClass (typeName, parent->Size);
FActorInfo *info = ti->ActorInfo;
// Check for "replaces"
if (sc.CheckString ("replaces"))
{
// Get actor name
sc.MustGetString ();
replacee = PClass::FindClass (sc.String);
if (replacee == NULL)
{
sc.ScriptError ("Replaced type '%s' not found", sc.String);
}
else if (replacee->ActorInfo == NULL)
{
sc.ScriptError ("Replaced type '%s' is not an actor", sc.String);
}
}
// Now, after the actor names have been parsed, it is time to switch to C-mode
// for the rest of the actor definition.
sc.SetCMode (true);
if (sc.CheckNumber())
{
if (sc.Number>=-1 && sc.Number<32768) DoomEdNum = sc.Number;
else sc.ScriptError ("DoomEdNum must be in the range [-1,32767]");
}
if (sc.CheckString("native"))
{
ti = (PClass*)PClass::FindClass(typeName);
if (ti == NULL)
{
sc.ScriptError("Unknown native class '%s'", typeName.GetChars());
}
else if (ti->ParentClass != parent)
{
sc.ScriptError("Native class '%s' does not inherit from '%s'",
typeName.GetChars(),parent->TypeName.GetChars());
}
else if (ti->ActorInfo != NULL)
{
sc.ScriptMessage("Redefinition of internal class '%s'", typeName.GetChars());
}
ti->InitializeActorInfo();
info = ti->ActorInfo;
}
else
{
ti = parent->CreateDerivedClass (typeName, parent->Size);
info = ti->ActorInfo;
}
MakeStateDefines(parent->ActorInfo->StateList);
@ -373,40 +430,14 @@ static FActorInfo *CreateNewActor(FScanner &sc, FActorInfo **parentc, Baggage *b
*info->PainChances = *parent->ActorInfo->PainChances;
}
// Check for "replaces"
sc.MustGetString ();
if (sc.Compare ("replaces"))
if (replacee != NULL)
{
const PClass *replacee;
// Get actor name
sc.MustGetString ();
replacee = PClass::FindClass (sc.String);
if (replacee == NULL)
{
sc.ScriptError ("Replaced type '%s' not found", sc.String);
}
else if (replacee->ActorInfo == NULL)
{
sc.ScriptError ("Replaced type '%s' is not an actor", sc.String);
}
replacee->ActorInfo->Replacement = ti->ActorInfo;
ti->ActorInfo->Replacee = replacee->ActorInfo;
}
else
{
sc.UnGet();
}
// Now, after the actor names have been parsed, it is time to switch to C-mode
// for the rest of the actor definition.
sc.SetCMode (true);
if (sc.CheckNumber())
{
if (sc.Number>=-1 && sc.Number<32768) info->DoomEdNum = sc.Number;
else sc.ScriptError ("DoomEdNum must be in the range [-1,32767]");
}
info->DoomEdNum = DoomEdNum;
if (parent == RUNTIME_CLASS(AWeapon))
{
// preinitialize kickback to the default for the game
@ -707,8 +738,8 @@ void FinishThingdef()
for(int i=0;i<31;i++)
{
char fmt[20];
sprintf(fmt, "QuestItem%d", i+1);
QuestItemClasses[i]=PClass::FindClass(fmt);
mysnprintf(fmt, countof(fmt), "QuestItem%d", i+1);
QuestItemClasses[i] = PClass::FindClass(fmt);
}
}

View file

@ -172,6 +172,7 @@ static flagdef ActorFlags[]=
DEFINE_FLAG(MF3, DONTOVERLAP, AActor, flags3),
DEFINE_FLAG(MF3, DONTMORPH, AActor, flags3),
DEFINE_FLAG(MF3, DONTSQUASH, AActor, flags3),
DEFINE_FLAG(MF3, EXPLOCOUNT, AActor, flags3),
DEFINE_FLAG(MF3, FULLVOLACTIVE, AActor, flags3),
DEFINE_FLAG(MF3, ISMONSTER, AActor, flags3),
DEFINE_FLAG(MF3, SKYEXPLODE, AActor, flags3),

View file

@ -784,7 +784,7 @@ static const char *SourceToString(USHORT usSource)
case CONN_SRC_CC93:
return "CC93";
default:
sprintf(unknown, "UNKNOWN (0x%04x)", usSource);
mysnprintf(unknown, countof(unknown), "UNKNOWN (0x%04x)", usSource);
return unknown;
}
}
@ -802,7 +802,7 @@ static const char *TransformToString(USHORT usTransform)
case CONN_TRN_SWITCH:
return "SWITCH";
default:
sprintf(unknown, "UNKNOWN (0x%04x)", usTransform);
mysnprintf(unknown, countof(unknown), "UNKNOWN (0x%04x)", usTransform);
return unknown;
}
}
@ -876,7 +876,7 @@ static const char *DestinationToString(USHORT usDestination)
case CONN_DST_FILTER_Q:
return "FILTER_Q";
default:
sprintf(unknown, "UNKNOWN (0x%04x)", usDestination);
mysnprintf(unknown, countof(unknown), "UNKNOWN (0x%04x)", usDestination);
return unknown;
}
}

View file

@ -33,7 +33,7 @@
BITS 32
%include "src/valgrind.inc"
%include "valgrind.inc"
; Segment/section definition macros.

View file

@ -37,7 +37,7 @@
BITS 32
%include "src/valgrind.inc"
%include "valgrind.inc"
%define SPACEFILLER4 (0x44444444)

View file

@ -1,4 +1,4 @@
%include "src/valgrind.inc"
%include "valgrind.inc"
%ifdef M_TARGET_WATCOM
SEGMENT DATA PUBLIC ALIGN=16 CLASS=DATA USE32

View file

@ -306,7 +306,7 @@ FFont::FFont (const char *name, const char *nametemplate, int first, int count,
for (i = 0; i < count; i++)
{
charlumps[i] = -1;
sprintf (buffer, nametemplate, i + start);
mysnprintf (buffer, countof(buffer), nametemplate, i + start);
lump = Wads.CheckNumForName (buffer, ns_graphics);
if (doomtemplate && lump >= 0 && i + start == 121)
{ // HACKHACK: Don't load STCFN121 in doom(2), because

View file

@ -819,7 +819,7 @@ void DFrameBuffer::DrawRateStuff ()
int chars;
int rate_x;
chars = sprintf (fpsbuff, "%2u ms (%3u fps)", howlong, LastCount);
chars = mysnprintf (fpsbuff, countof(fpsbuff), "%2u ms (%3u fps)", howlong, LastCount);
rate_x = Width - chars * 8;
Clear (rate_x, 0, Width, 8, 0, 0);
SetFont (ConFont);

View file

@ -465,13 +465,10 @@ void FWadCollection::AddFile (const char *filename, const char * data, int lengt
// Rearrange the name and extension in a part of the lump record
// that I don't have any use for in order to cnstruct the fullname.
rff_p->Name[8] = '\0';
sprintf ((char *)rff_p->IDontKnow, "%s.", rff_p->Name);
rff_p->Name[0] = '\0';
strcpy ((char *)rff_p->IDontKnow, rff_p->Name);
strcat ((char *)rff_p->IDontKnow, ".");
strcat ((char *)rff_p->IDontKnow, rff_p->Extension);
lump_p->fullname = copystring ((char *)rff_p->IDontKnow);
if (strstr ((char *)rff_p->IDontKnow, "TILE"))
rff_p = rff_p;
lump_p++;
}
Printf (" (%u files)", header.rff.NumLumps);
@ -715,7 +712,7 @@ void FWadCollection::AddFile (const char *filename, const char * data, int lengt
{
char path[256];
sprintf(path, "%s:", filename);
mysnprintf(path, countof(path), "%s:", filename);
char * wadstr = path+strlen(path);
for(unsigned int i = 0; i < EmbeddedWADs.Size(); i++)

View file

@ -317,10 +317,10 @@ void WI_LoadBackground(bool isenterpic)
case GAME_Doom:
if (gamemode != commercial)
{
char * level = isenterpic? wbs->next : wbs->current;
const char *level = isenterpic ? wbs->next : wbs->current;
if (IsExMy(level))
{
sprintf(buffer, "$IN_EPI%c", level[1]);
mysnprintf(buffer, countof(buffer), "$IN_EPI%c", level[1]);
lumpname = buffer;
}
}
@ -353,7 +353,7 @@ void WI_LoadBackground(bool isenterpic)
{
if (IsExMy(wbs->next))
{
sprintf(buffer, "$IN_HTC%c", wbs->next[1]);
mysnprintf(buffer, countof(buffer), "$IN_HTC%c", wbs->next[1]);
lumpname = buffer;
}
}
@ -842,7 +842,7 @@ void WI_drawEL ()
//
//====================================================================
int WI_MapToIndex (char *map)
int WI_MapToIndex (const char *map)
{
unsigned int i;
@ -904,11 +904,11 @@ int WI_drawNum (int x, int y, int n, int digits, bool leadingzeros = true)
if (leadingzeros)
{
sprintf (text, "%07d", n);
mysnprintf (text, countof(text), "%07d", n);
}
else
{
sprintf (text, "%7d", n);
mysnprintf (text, countof(text), "%7d", n);
if (digits < 0)
{
text_p = strrchr (text, ' ');
@ -1980,7 +1980,7 @@ void WI_loadData(void)
for (i = 0; i < 10; i++)
{ // numbers 0-9
sprintf (name, "WINUM%d", i);
mysnprintf (name, countof(name), "WINUM%d", i);
num[i] = TexMan[name];
}
}
@ -2004,7 +2004,7 @@ void WI_loadData(void)
for (i = 0; i < 10; i++)
{
sprintf (name, "FONTB%d", 16 + i);
mysnprintf (name, countof(name), "FONTB%d", 16 + i);
num[i] = TexMan[name];
}
}

View file

@ -47,11 +47,11 @@ typedef struct wbstartstruct_s
int finished_ep;
int next_ep;
char current[9]; // [RH] Name of map just finished
char next[9]; // next level, [RH] actual map name
FString current; // [RH] Name of map just finished
FString next; // next level, [RH] actual map name
char lname0[9];
char lname1[9];
FString lname0;
FString lname1;
int maxkills;
int maxitems;

View file

@ -196,7 +196,7 @@ LRESULT AddEnvToDropDown (HWND hCtl, bool showID, const ReverbContainer *env)
if (showID)
{
sprintf (buff, "(%3d,%3d) %s", HIBYTE(env->ID), LOBYTE(env->ID), env->Name);
mysnprintf (buff, countof(buff), "(%3d,%3d) %s", HIBYTE(env->ID), LOBYTE(env->ID), env->Name);
i = SendMessage (hCtl, CB_ADDSTRING, 0, (LPARAM)buff);
}
else
@ -255,9 +255,9 @@ void SetIDEdits (HWND hDlg, WORD id)
{
char text[4];
sprintf (text, "%d", HIBYTE(id));
mysnprintf (text, countof(text), "%d", HIBYTE(id));
SendMessage (GetDlgItem (hDlg, IDC_EDITID1), WM_SETTEXT, 0, (LPARAM)text);
sprintf (text, "%d", LOBYTE(id));
mysnprintf (text, countof(text), "%d", LOBYTE(id));
SendMessage (GetDlgItem (hDlg, IDC_EDITID2), WM_SETTEXT, 0, (LPARAM)text);
}
@ -406,11 +406,11 @@ LRESULT CALLBACK EditControlProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
int vali = SendMessage (env->SliderHWND, TBM_GETPOS, 0, 0);
if (env->Float)
{
sprintf (buff, "%d.%03d", vali/1000, abs(vali%1000));
mysnprintf (buff, countof(buff), "%d.%03d", vali/1000, abs(vali%1000));
}
else
{
sprintf (buff, "%d", vali);
mysnprintf (buff, countof(buff), "%d", vali);
}
CallWindowProc (StdEditProc, hWnd, WM_SETTEXT, 0, (LPARAM)buff);
CallWindowProc (StdEditProc, hWnd, EM_SETSEL, 0, -1);
@ -487,7 +487,7 @@ void UpdateControl (const EnvControl *control, int value, bool slider)
}
if (control->Float)
{
sprintf (buff, "%d.%03d", value/1000, abs(value%1000));
mysnprintf (buff, countof(buff), "%d.%03d", value/1000, abs(value%1000));
if (CurrentEnv != NULL)
{
CurrentEnv->Properties.*control->Float = float(value) / 1000.0;
@ -495,7 +495,7 @@ void UpdateControl (const EnvControl *control, int value, bool slider)
}
else
{
sprintf (buff, "%d", value);
mysnprintf (buff, countof(buff), "%d", value);
if (CurrentEnv != NULL)
{
CurrentEnv->Properties.*control->Int = value;
@ -542,10 +542,10 @@ void UpdateControls (ReverbContainer *env, HWND hDlg)
}
EnableWindow (GetDlgItem (hDlg, IDC_REVERT), !env->Builtin);
sprintf (buff, "%d", HIBYTE(env->ID));
mysnprintf (buff, countof(buff), "%d", HIBYTE(env->ID));
SendMessage (GetDlgItem (hDlg, IDC_ID1), WM_SETTEXT, 0, (LPARAM)buff);
sprintf (buff, "%d", LOBYTE(env->ID));
mysnprintf (buff, countof(buff), "%d", LOBYTE(env->ID));
SendMessage (GetDlgItem (hDlg, IDC_ID2), WM_SETTEXT, 0, (LPARAM)buff);
SavedProperties = env->Properties;
@ -690,7 +690,7 @@ void SuggestNewName (const ReverbContainer *env, HWND hEdit)
{
len = 31 - numdigits;
}
sprintf (text + len, "%d", number);
mysnprintf (text + len, countof(text) - len, "%d", number);
probe = Environments;
while (probe != NULL)
@ -829,7 +829,7 @@ INT_PTR CALLBACK NewEAXProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
static char foo[80];
ti.uId = 2;
ti.hwnd = GetDlgItem (hDlg, IDC_EDITID2);
sprintf (foo, "This ID is already used by \"%s\".", rev->Name);
mysnprintf (foo, countof(foo), "This ID is already used by \"%s\".", rev->Name);
ti.lpszText = foo;
ShowErrorTip (ToolTip, ti, hDlg, "Bad ID");
}

View file

@ -1164,7 +1164,7 @@ void DDrawFB::Update ()
}
unclock (BlitCycles);
LOG1 ("cycles = %d\n", BlitCycles);
LOG1 ("cycles = %llu\n", BlitCycles);
Buffer = NULL;
LockCount = 0;

View file

@ -53,6 +53,9 @@
#include <shellapi.h>
#include <uxtheme.h>
#include <stddef.h>
#define USE_WINDOWS_DWORD
#include "doomtype.h"
#include "resource.h"
#include "version.h"
#include "m_swap.h"
@ -637,23 +640,24 @@ HANDLE WriteTextReport ()
break;
}
}
j = sprintf (CrashSummary, "Code: %08lX", CrashPointers.ExceptionRecord->ExceptionCode);
j = mysnprintf (CrashSummary, countof(CrashSummary), "Code: %08lX", CrashPointers.ExceptionRecord->ExceptionCode);
if ((size_t)i < sizeof(exceptions)/sizeof(exceptions[0]))
{
j += sprintf (CrashSummary + j, " (%s", exceptions[i].Text);
j += mysnprintf (CrashSummary + j, countof(CrashSummary) - j, " (%s", exceptions[i].Text);
if (CrashPointers.ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION)
{
// Pre-NT kernels do not seem to provide this information.
if (verinfo.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS)
{
j += sprintf (CrashSummary + j, " - tried to %s address %08lX",
j += mysnprintf (CrashSummary + j, countof(CrashSummary) - j,
" - tried to %s address %08lX",
CrashPointers.ExceptionRecord->ExceptionInformation[0] ? "write" : "read",
CrashPointers.ExceptionRecord->ExceptionInformation[1]);
}
}
CrashSummary[j++] = ')';
}
j += sprintf (CrashSummary + j, "\r\nAddress: %p", CrashPointers.ExceptionRecord->ExceptionAddress);
j += mysnprintf (CrashSummary + j, countof(CrashSummary) - j, "\r\nAddress: %p", CrashPointers.ExceptionRecord->ExceptionAddress);
Writef (file, "%s\r\nFlags: %08X\r\n\r\n", CrashSummary, CrashPointers.ExceptionRecord->ExceptionFlags);
Writef (file, "Windows %s %d.%d Build %d %s\r\n\r\n",
@ -1125,15 +1129,15 @@ static void DumpBytes (HANDLE file, BYTE *address)
{
if ((i & 15) == 0)
{
line_p += sprintf (line_p, "\r\n%p:", address);
line_p += mysnprintf (line_p, countof(line) - (line_p - line), "\r\n%p:", address);
}
if (SafeReadMemory (address, &peek, 1))
{
line_p += sprintf (line_p, " %02x", *address);
line_p += mysnprintf (line_p, countof(line) - (line_p - line), " %02x", *address);
}
else
{
line_p += sprintf (line_p, " --");
line_p += mysnprintf (line_p, countof(line) - (line_p - line), " --");
}
address++;
}
@ -1918,12 +1922,13 @@ static DWORD CALLBACK StreamEditBinary (DWORD_PTR cookie, LPBYTE buffer, LONG cb
BYTE buf16[16];
DWORD read, i;
char *buff_p = (char *)buffer;
char *buff_end = (char *)buffer + cb;
repeat:
switch (info->Stage)
{
case 0: // Write prologue
buff_p += sprintf (buff_p, "{\\rtf1\\ansi\\deff0"
buff_p += mysnprintf (buff_p, buff_end - buff_p, "{\\rtf1\\ansi\\deff0"
"{\\colortbl ;\\red0\\green0\\blue80;\\red0\\green0\\blue0;\\red80\\green0\\blue80;}"
"\\viewkind4\\pard");
info->Stage++;
@ -1939,19 +1944,19 @@ repeat:
goto repeat;
}
char *linestart = buff_p;
buff_p += sprintf (buff_p, "\\cf1 %08lx:\\cf2 ", info->Pointer);
buff_p += mysnprintf (buff_p, buff_end - buff_p, "\\cf1 %08lx:\\cf2 ", info->Pointer);
info->Pointer += read;
for (i = 0; i < read;)
{
if (i <= read - 4)
{
buff_p += sprintf (buff_p, " %08lx", *(DWORD *)&buf16[i]);
buff_p += mysnprintf (buff_p, buff_end - buff_p, " %08lx", *(DWORD *)&buf16[i]);
i += 4;
}
else
{
buff_p += sprintf (buff_p, " %02x", buf16[i]);
buff_p += mysnprintf (buff_p, buff_end - buff_p, " %02x", buf16[i]);
i += 1;
}
}
@ -1959,7 +1964,7 @@ repeat:
{
*buff_p++ = ' ';
}
buff_p += sprintf (buff_p, "\\cf3 ");
buff_p += mysnprintf (buff_p, buff_end - buff_p, "\\cf3 ");
for (i = 0; i < read; ++i)
{
BYTE code = buf16[i];
@ -1967,17 +1972,17 @@ repeat:
if (code == '\\' || code == '{' || code == '}') *buff_p++ = '\\';
*buff_p++ = code;
}
buff_p += sprintf (buff_p, "\\par\r\n");
buff_p += mysnprintf (buff_p, buff_end - buff_p, "\\par\r\n");
}
break;
case 2: // Write epilogue
buff_p += sprintf (buff_p, "\\cf0 }");
buff_p += mysnprintf (buff_p, buff_end - buff_p, "\\cf0 }");
info->Stage = 4;
break;
case 3: // Write epilogue for truncated file
buff_p += sprintf (buff_p, "--- Rest of file truncated ---\\cf0 }");
buff_p += mysnprintf (buff_p, buff_end - buff_p, "--- Rest of file truncated ---\\cf0 }");
info->Stage = 4;
break;
@ -2015,11 +2020,11 @@ static void SetEditControl (HWND edit, HWND sizedisplay, int filenum)
size = GetFileSize (TarFiles[filenum].File, NULL);
if (size < 1024)
{
sprintf (sizebuf, "(%lu bytes)", size);
mysnprintf (sizebuf, countof(sizebuf), "(%lu bytes)", size);
}
else
{
sprintf (sizebuf, "(%lu KB)", size/1024);
mysnprintf (sizebuf, countof(sizebuf), "(%lu KB)", size/1024);
}
SetWindowText (sizedisplay, sizebuf);
@ -2125,7 +2130,7 @@ static void UploadFail (HWND hDlg, const char *message, int reason)
{
char buff[512];
sprintf (buff, "%s: %d", message, reason);
mysnprintf (buff, countof(buff), "%s: %d", message, reason);
SetWindowText (GetDlgItem (hDlg, IDC_BOINGSTATUS), buff);
if (reason >= 10000 && reason <= 11999)
@ -2681,7 +2686,7 @@ static DWORD WINAPI UploadProc (LPVOID lpParam)
sizeof(MultipartBinaryHeader)-1 +
sizeof(MultipartHeaderGZip)-1 + fileLen +
sizeof(MultipartFooter)-1;
headerLen = sprintf (xferbuf, PostHeader, contentLength);
headerLen = mysnprintf (xferbuf, countof(xferbuf), PostHeader, contentLength);
bytesSent = send (sock, xferbuf, headerLen, 0);
if (bytesSent != headerLen)
{
@ -2710,7 +2715,7 @@ static DWORD WINAPI UploadProc (LPVOID lpParam)
UploadFail (parm->hDlg, "Could not upload report", WSAGetLastError());
throw 1;
}
headerLen = sprintf (xferbuf, "Windows %08lX %p %X %08lX %08lX %08lX %08lX %08lX %s",
headerLen = mysnprintf (xferbuf, countof(xferbuf), "Windows %08lX %p %X %08lX %08lX %08lX %08lX %08lX %s",
CrashPointers.ExceptionRecord->ExceptionCode,
CrashPointers.ExceptionRecord->ExceptionAddress,
!!CrashPointers.ExceptionRecord->ExceptionInformation[0],
@ -2746,7 +2751,7 @@ static DWORD WINAPI UploadProc (LPVOID lpParam)
}
// Send the report file.
headerLen = sprintf (xferbuf, "%s%s", MultipartBinaryHeader, MultipartHeaderZip);
headerLen = mysnprintf (xferbuf, countof(xferbuf), "%s%s", MultipartBinaryHeader, MultipartHeaderZip);
bytesSent = send (sock, xferbuf, headerLen, 0);
if (bytesSent == SOCKET_ERROR)
@ -3059,7 +3064,7 @@ void DisplayCrashLog ()
GAMENAME" crashed but was unable to produce\n"
"detailed information about the crash.\n"
"\nThis is all that is available:\n\nCode=XXXXXXXX\nAddr=XXXXXXXX";
sprintf (ohPoo + sizeof(ohPoo) - 23, "%08lX\nAddr=%p", CrashCode, CrashAddress);
mysnprintf (ohPoo + countof(ohPoo) - 23, 23, "%08lX\nAddr=%p", CrashCode, CrashAddress);
MessageBox (NULL, ohPoo, GAMENAME" Very Fatal Error", MB_OK|MB_ICONSTOP);
if (WinHlp32 != NULL)
{

View file

@ -827,7 +827,7 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
}
#ifdef _DEBUG
char foo[256];
sprintf (foo, "Session Change: %ld %d\n", lParam, wParam);
mysnprintf (foo, countof(foo), "Session Change: %ld %d\n", lParam, wParam);
OutputDebugString (foo);
#endif
}
@ -1064,7 +1064,7 @@ bool SetJoystickSection (bool create)
if (g_pJoy != NULL && SUCCEEDED(g_pJoy->GetDeviceInfo (&inst)))
{
FormatGUID (section + 9, inst.guidInstance);
FormatGUID (section + 9, countof(section) - 9, inst.guidInstance);
strcpy (section + 9 + 38, ".Axes");
return GameConfig->SetSection (section, create);
}

View file

@ -964,22 +964,23 @@ void DoMain (HINSTANCE hInstance)
//
//==========================================================================
void DoomSpecificInfo (char *buffer)
void DoomSpecificInfo (char *buffer, size_t bufflen)
{
const char *arg;
char *const buffend = buffer + bufflen - 2; // -2 for CRLF at end
int i;
buffer += wsprintf (buffer, "ZDoom version " DOTVERSIONSTR " (" __DATE__ ")\r\n");
buffer += wsprintf (buffer, "\r\nCommand line: %s\r\n", GetCommandLine());
buffer += mysnprintf (buffer, buffend - buffer, "ZDoom version " DOTVERSIONSTR " (" __DATE__ ")\r\n");
buffer += mysnprintf (buffer, buffend - buffer, "\r\nCommand line: %s\r\n", GetCommandLine());
for (i = 0; (arg = Wads.GetWadName (i)) != NULL; ++i)
{
buffer += wsprintf (buffer, "\r\nWad %d: %s", i, arg);
buffer += mysnprintf (buffer, buffend - buffer, "\r\nWad %d: %s", i, arg);
}
if (gamestate != GS_LEVEL && gamestate != GS_TITLELEVEL)
{
buffer += wsprintf (buffer, "\r\n\r\nNot in a level.");
buffer += mysnprintf (buffer, buffend - buffer, "\r\n\r\nNot in a level.");
}
else
{
@ -987,18 +988,18 @@ void DoomSpecificInfo (char *buffer)
strncpy (name, level.mapname, 8);
name[8] = 0;
buffer += wsprintf (buffer, "\r\n\r\nCurrent map: %s", name);
buffer += mysnprintf (buffer, buffend - buffer, "\r\n\r\nCurrent map: %s", name);
if (!viewactive)
{
buffer += wsprintf (buffer, "\r\n\r\nView not active.");
buffer += mysnprintf (buffer, buffend - buffer, "\r\n\r\nView not active.");
}
else
{
buffer += wsprintf (buffer, "\r\n\r\nviewx = %d", viewx);
buffer += wsprintf (buffer, "\r\nviewy = %d", viewy);
buffer += wsprintf (buffer, "\r\nviewz = %d", viewz);
buffer += wsprintf (buffer, "\r\nviewangle = %x", viewangle);
buffer += mysnprintf (buffer, buffend - buffer, "\r\n\r\nviewx = %d", viewx);
buffer += mysnprintf (buffer, buffend - buffer, "\r\nviewy = %d", viewy);
buffer += mysnprintf (buffer, buffend - buffer, "\r\nviewz = %d", viewz);
buffer += mysnprintf (buffer, buffend - buffer, "\r\nviewangle = %x", viewangle);
}
}
*buffer++ = '\r';
@ -1093,7 +1094,7 @@ LONG WINAPI CatchAllExceptions (LPEXCEPTION_POINTERS info)
char *custominfo = (char *)HeapAlloc (GetProcessHeap(), 0, 16384);
CrashPointers = *info;
DoomSpecificInfo (custominfo);
DoomSpecificInfo (custominfo, 16384);
CreateCrashLog (custominfo, (DWORD)strlen(custominfo));
// If the main thread crashed, then make it clean up after itself.

View file

@ -515,74 +515,6 @@ void I_Quit (void)
extern FILE *Logfile;
bool gameisdead;
// We should use ZDoom's internal formatting routine here so that the extended
// format specifiers work here as well.
struct snprintf_state
{
char *buffer;
size_t maxlen;
size_t curlen;
int ideallen;
};
static int myvsnprintf_helper(void *data, const char *cstr, int cstr_len)
{
snprintf_state *state = (snprintf_state *)data;
if (INT_MAX - state->ideallen > cstr_len)
{
state->ideallen = INT_MAX;
}
else
{
state->ideallen += cstr_len;
}
if (state->curlen + cstr_len > state->maxlen)
{
cstr_len = (int)(state->maxlen - state->curlen);
}
if (cstr_len > 0)
{
memcpy(state->buffer + state->curlen, cstr, cstr_len);
state->curlen += cstr_len;
}
return cstr_len;
}
// Unlike the MS CRT function snprintf, this one always writes a terminating
// null character to the buffer. It also returns the full length of the string
// that would have been output if the buffer had been large enough. In other
// words, it follows BSD/Linux rules and not MS rules.
int myvsnprintf(char *buffer, size_t count, const char *format, va_list argptr)
{
size_t originalcount = count;
if (count != 0)
{
count--;
}
if (count > INT_MAX)
{
count = INT_MAX;
}
snprintf_state state = { buffer, count, 0, 0 };
StringFormat::VWorker(myvsnprintf_helper, &state, format, argptr);
if (originalcount > 0)
{
buffer[state.curlen] = '\0';
}
return state.ideallen;
}
int mysnprintf(char *buffer, size_t count, const char *format, ...)
{
va_list argptr;
va_start(argptr, format);
int len = myvsnprintf(buffer, count, format, argptr);
va_end(argptr);
return len;
}
void STACK_ARGS I_FatalError (const char *error, ...)
{
static BOOL alreadyThrown = false;

View file

@ -548,7 +548,7 @@ void FBasicStartupScreen :: NetProgress(int count)
{
char buf[16];
sprintf (buf, "%d/%d", NetCurPos, NetMaxPos);
mysnprintf (buf, countof(buf), "%d/%d", NetCurPos, NetMaxPos);
SetDlgItemText (NetStartPane, IDC_NETSTARTCOUNT, buf);
SendDlgItemMessage (NetStartPane, IDC_NETSTARTPROGRESS, PBM_SETPOS, MIN(NetCurPos, NetMaxPos), 0);
}

View file

@ -425,11 +425,11 @@ FILE *dbg;
#define STARTLOG
#define STOPLOG
#define LOG(x) { OutputDebugString(x); }
#define LOG1(x,y) { char poo[1024]; sprintf(poo, x, y); OutputDebugString(poo); }
#define LOG2(x,y,z) { char poo[1024]; sprintf(poo, x, y, z); OutputDebugString(poo); }
#define LOG3(x,y,z,zz) { char poo[1024]; sprintf(poo, x, y, z, zz); OutputDebugString(poo); }
#define LOG4(x,y,z,a,b) { char poo[1024]; sprintf(poo, x, y, z, a, b); OutputDebugString(poo); }
#define LOG5(x,y,z,a,b,c) { char poo[1024]; sprintf(poo, x, y, z, a, b, c); OutputDebugString(poo); }
#define LOG1(x,y) { char poo[1024]; mysnprintf(poo, countof(poo), x, y); OutputDebugString(poo); }
#define LOG2(x,y,z) { char poo[1024]; mysnprintf(poo, countof(poo), x, y, z); OutputDebugString(poo); }
#define LOG3(x,y,z,zz) { char poo[1024]; mysnprintf(poo, countof(poo), x, y, z, zz); OutputDebugString(poo); }
#define LOG4(x,y,z,a,b) { char poo[1024]; mysnprintf(poo, countof(poo), x, y, z, a, b); OutputDebugString(poo); }
#define LOG5(x,y,z,a,b,c) { char poo[1024]; mysnprintf(poo, countof(poo), x, y, z, a, b, c); OutputDebugString(poo); }
#else
#define STARTLOG
#define STOPLOG

View file

@ -1,11 +1,96 @@
/*
** zstrformat.cpp
** Routines for generic printf-style formatting.
**
**---------------------------------------------------------------------------
** Copyright 2005-2008 Randy Heit
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
** Portions of this file relating to printing floating point numbers
** are covered by the following copyright:
**
**---------------------------------------------------------------------------
** Copyright (c) 1990, 1993
** The Regents of the University of California. All rights reserved.
**
** This code is derived from software contributed to Berkeley by
** Chris Torek.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 4. Neither the name of the University nor the names of its contributors
** may be used to endorse or promote products derived from this software
** without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
** ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
**---------------------------------------------------------------------------
**
** Even though the standard C library has a function to do printf-style
** formatting in a generic way, there is no standard interface to this
** function. So if you want to do some printf formatting that doesn't fit in
** the context of the provided functions, you need to roll your own. Why is
** that?
**
** Maybe Microsoft wants you to write a better one yourself? When used as
** part of a sprintf replacement, this function is significantly faster than
** Microsoft's offering. When used as part of a fprintf replacement, this
** function turns out to be slower, but that's probably because the CRT's
** fprintf can interact with the FILE object on a low level for better
** perfomance. If you sprintf into a buffer and then fwrite that buffer, this
** routine wins again, though the difference isn't great.
*/
#include <limits.h>
#include <string.h>
#include <stddef.h>
#include <stdlib.h>
#include <math.h>
#include <malloc.h>
#include <locale.h>
#include "zstring.h"
#include "gdtoa.h"
#ifndef _MSC_VER
#include <stdint.h>
@ -14,21 +99,32 @@ typedef unsigned __int64 uint64_t;
typedef signed __int64 int64_t;
#endif
// Even though the standard C library has a function to do printf-style formatting in a
// generic way, there is no standard interface to this function. So if you want to do
// some printf formatting that doesn't fit in the context of the provided functions,
// you need to roll your own. Why is that?
//
// Maybe Microsoft wants you to write a better one yourself? When used as part of a
// sprintf replacement, this function is significantly faster than Microsoft's
// offering. When used as part of a fprintf replacement, this function turns out to
// be slower, but that's probably because the CRT's fprintf can interact with the
// FILE object on a low level for better perfomance. If you sprintf into a buffer
// and then fwrite that buffer, this routine wins again, though the difference isn't
// great.
/*
* MAXEXPDIG is the maximum number of decimal digits needed to store a
* floating point exponent in the largest supported format. It should
* be ceil(log10(LDBL_MAX_10_EXP)) or, if hexadecimal floating point
* conversions are supported, ceil(log10(LDBL_MAX_EXP)). But since it
* is presently never greater than 5 in practice, we fudge it.
*/
#define MAXEXPDIG 6
#if LDBL_MAX_EXP > 999999
#error "floating point buffers too small"
#endif
#define DEFPREC 6
static const char hexits[16] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
static const char HEXits[16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
static const char spaces[16] = {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '};
static const char zeroes[17] = {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','.'};
static const char dotchar = '.';
namespace StringFormat
{
static int writepad (OutputFunc output, void *outputData, const char *pad, int padsize, int spaceToFill);
static int printandpad (OutputFunc output, void *outputData, const char *p, const char *ep, int len, const char *with, int padsize);
static int exponent (char *p0, int exp, int fmtch);
int Worker (OutputFunc output, void *outputData, const char *fmt, ...)
{
va_list arglist;
@ -40,43 +136,6 @@ namespace StringFormat
return len;
}
static inline int writepad (OutputFunc output, void *outputData, const char *pad, int padsize, int spaceToFill)
{
int outlen = 0;
while (spaceToFill > 0)
{
int count = spaceToFill > padsize ? padsize : spaceToFill;
outlen += output (outputData, pad, count);
spaceToFill -= count;
}
return outlen;
}
// Gasp! This is supposed to be a replacement for sprintf formatting, but
// I used sprintf for doubles anyway! Oh no!
static int fmt_fp (OutputFunc output, void *outputData, int flags, int precision, int width, double number, char type)
{
char *buff;
char format[16];
int i;
format[0] = '%';
i = 1;
if (flags & F_MINUS) format[i++] = '-';
if (flags & F_PLUS) format[i++] = '+';
if (flags & F_ZERO) format[i++] = '0';
if (flags & F_BLANK) format[i++] = ' ';
if (flags & F_HASH) format[i++] = '#';
format[i++] = '*';
format[i++] = '.';
format[i++] = '*';
format[i++] = type;
format[i++] = '\0';
buff = (char *)alloca (1000 + precision);
i = sprintf (buff, format, width, precision, number);
return output (outputData, buff, i);
}
int VWorker (OutputFunc output, void *outputData, const char *fmt, va_list arglist)
{
const char *c;
@ -233,18 +292,13 @@ namespace StringFormat
// Now that that's all out of the way, we should be pointing at the type specifier
{
static const char hexits[18] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','0','x'};
static const char HEXits[18] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','0','X'};
static const char spaces[16] = {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '};
static const char zeroes[17] = {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','.'};
static const char plusprefix = '+';
static const char minusprefix = '-';
static const char dotchar = '.';
const char *prefix = NULL;
int prefixlen = 0;
char prefix[3];
int prefixlen;
char hexprefix = '\0';
char sign = '\0';
int postprefixzeros = 0;
int size = flags & 0xF000;
char buffer[32], *ibuff;
char buffer[80], *ibuff;
const char *obuff = 0;
char type = *c++;
int bufflen = 0;
@ -253,8 +307,32 @@ namespace StringFormat
uint64_t int64arg = 0;
const void *voidparg;
const char *charparg;
double dblarg;
const char *xits = hexits;
int inlen = len;
/*
* We can decompose the printed representation of floating
* point numbers into several parts, some of which may be empty:
*
* [+|-| ] [0x|0X] MMM . NNN [e|E|p|P] [+|-] ZZ
* A B ---C--- D E F
*
* A: 'sign' holds this value if present; '\0' otherwise
* B: hexprefix holds the 'x' or 'X'; '\0' if not hexadecimal
* C: obuff points to the string MMMNNN. Leading and trailing
* zeros are not in the string and must be added.
* D: expchar holds this character; '\0' if no exponent, e.g. %f
* F: at least two digits for decimal, at least one digit for hex
*/
const char *decimal_point = ".";/* locale specific decimal point */
int signflag; /* true if float is negative */
int expt; /* integer value of exponent */
char expchar = 'e'; /* exponent character: [eEpP\0] */
char *dtoaend; /* pointer to end of converted digits */
int expsize = 0; /* character count for expstr */
int ndig = 0; /* actual number of digits returned by dtoa */
char expstr[MAXEXPDIG+2]; /* buffer for exponent string: e+ZZZ */
char *dtoaresult = NULL; /* buffer allocated by dtoa */
// Using a bunch of if/else if statements is faster than a switch, because a switch generates
// a jump table. A jump table means a possible data cache miss and a hefty penalty while the
@ -263,7 +341,8 @@ namespace StringFormat
if (type == 'x' || type == 'X' ||
type == 'p' ||
type == 'd' || type == 'u' || type == 'i' ||
type == 'o')
type == 'o' ||
type == 'B')
{
if (type == 'X' || type == 'p')
{
@ -360,6 +439,14 @@ namespace StringFormat
}
intarg = int(int64arg);
}
else if (type == 'B')
{ // Binary: Dump digits until it fits in an unsigned int
while (int64arg > UINT_MAX)
{
*--ibuff = char(int64arg & 1) + '0'; int64arg >>= 1;
}
intarg = int(int64arg);
}
else
{
if (type != 'u')
@ -413,10 +500,19 @@ namespace StringFormat
}
else if (type == 'u')
{ // Decimal
while (intarg != 0)
int i;
// Unsigned division is typically slower than signed division.
// Do it at most once.
if (intarg > INT_MAX)
{
*--ibuff = char(intarg % 10) + '0'; intarg /= 10;
}
i = (int)intarg;
while (i != 0)
{
*--ibuff = char(i % 10) + '0'; i /= 10;
}
}
else if (type == 'o')
{ // Octal
@ -425,6 +521,13 @@ namespace StringFormat
*--ibuff = char(intarg & 7) + '0'; intarg >>= 3;
}
}
else if (type == 'B')
{ // Binary
while (intarg != 0)
{
*--ibuff = char(intarg & 1) + '0'; intarg >>= 1;
}
}
else
{ // Hexadecimal
while (intarg != 0)
@ -439,14 +542,16 @@ namespace StringFormat
{
if (bufflen >= precision)
{
prefix = zeroes;
prefixlen = 1;
sign = '0';
}
}
else if (type == 'x' || type == 'X')
{
prefix = xits + 16;
prefixlen = 2;
hexprefix = type;
}
else if (type == 'B')
{
hexprefix = '!';
}
}
bufflen = (int)(ptrdiff_t)(&buffer[sizeof(buffer)] - ibuff);
@ -519,59 +624,149 @@ namespace StringFormat
*va_arg (arglist, int *) = inlen;
}
}
else if (type == 'e' || type == 'E' ||
type == 'f' || type == 'F' ||
type == 'g' || type == 'G')
else if (type == 'f' || type == 'F')
{
// IEEE 754 floating point numbers
#ifdef _MSC_VER
#define FP_SIGN_MASK (1ui64<<63)
#define FP_EXPONENT_MASK (2047ui64<<52)
#define FP_FRACTION_MASK ((1ui64<<52)-1)
#else
#define FP_SIGN_MASK (1llu<<63)
#define FP_EXPONENT_MASK (2047llu<<52)
#define FP_FRACTION_MASK ((1llu<<52)-1)
#endif
union
expchar = '\0';
goto fp_begin;
}
else if (type == 'g' || type == 'G')
{
expchar = type - ('g' - 'e');
if (precision == 0)
{
double d;
uint64_t i64;
} number;
number.d = va_arg (arglist, double);
if (precision < 0) precision = 6;
flags |= F_SIGNED;
if ((number.i64 & FP_EXPONENT_MASK) == FP_EXPONENT_MASK)
precision = 1;
}
goto fp_begin;
}
#if 0
// The hdtoa function provided with FreeBSD uses a hexadecimal FP constant.
// Microsoft's compiler does not support these, so I would need to hack it
// together with ints instead. It's very do-able, but until I actually have
// some reason to print hex FP numbers, I won't bother.
else if (type == 'a' || type == 'A')
{
if (type == 'A')
{
if (number.i64 & FP_SIGN_MASK)
{
flags |= F_NEGATIVE;
}
if ((number.i64 & FP_FRACTION_MASK) == 0)
{
obuff = "Infinity";
bufflen = 8;
}
else if ((number.i64 & ((FP_FRACTION_MASK+1)>>1)) == 0)
{
obuff = "NaN";
bufflen = 3;
}
else
{
obuff = "Ind";
}
xits = HEXits;
hexprefix = 'X';
expchar = 'P';
}
else
{
// Converting a binary floating point number to an ASCII decimal
// representation is non-trivial, so I'm not going to do it myself.
// (At least for now.)
len += fmt_fp (output, outputData, flags, precision, width, number.d, type);
continue;
hexprefix = 'x';
expchar = 'p';
}
if (precision >= 0)
{
precision++;
}
dblarg = va_arg(arglist, double);
dtoaresult = obuff = hdtoa(dblarg, xits, precision, &expt, &signflag, &dtoaend);
if (precision < 0)
{
precision = (int)(dtoaend - obuff);
}
if (expt == INT_MAX)
{
hexprefix = '\0';
}
goto fp_common;
}
#endif
else if (type == 'e' || type == 'E')
{
expchar = type;
if (precision < 0) // account for digit before decpt
{
precision = DEFPREC + 1;
}
else
{
precision++;
}
fp_begin:
if (precision < 0)
{
precision = DEFPREC;
}
dblarg = va_arg(arglist, double);
obuff = dtoaresult = dtoa(dblarg, expchar ? 2 : 3, precision, &expt, &signflag, &dtoaend);
//fp_common:
decimal_point = localeconv()->decimal_point;
flags |= F_SIGNED;
if (signflag)
{
flags |= F_NEGATIVE;
}
if (expt == INT_MAX) // inf or nan
{
if (*obuff == 'N')
{
obuff = (type >= 'a') ? "nan" : "NAN";
flags &= ~F_SIGNED;
}
else
{
obuff = (type >= 'a') ? "inf" : "INF";
}
bufflen = 3;
flags &= ~F_ZERO;
}
else
{
flags |= F_FPT;
ndig = (int)(dtoaend - obuff);
if (type == 'g' || type == 'G')
{
if (expt > -4 && expt <= precision)
{ // Make %[gG] smell like %[fF].
expchar = '\0';
if (flags & F_HASH)
{
precision -= expt;
}
else
{
precision = ndig - expt;
}
if (precision < 0)
{
precision = 0;
}
}
else
{ // Make %[gG] smell like %[eE], but trim trailing zeroes if no # flag.
if (!(flags & F_HASH))
{
precision = ndig;
}
}
}
if (expchar)
{
expsize = exponent(expstr, expt - 1, expchar);
bufflen = expsize + precision;
if (precision > 1 || (flags & F_HASH))
{
++bufflen;
}
}
else
{ // space for digits before decimal point
if (expt > 0)
{
bufflen = expt;
}
else // "0"
{
bufflen = 1;
}
// space for decimal pt and following digits
if (precision != 0 || (flags & F_HASH))
{
bufflen += precision + 1;
}
}
}
}
@ -580,21 +775,32 @@ namespace StringFormat
{
if (flags & F_NEGATIVE)
{
prefix = &minusprefix;
prefixlen = 1;
sign = '-';
}
else if (flags & F_PLUS)
{
prefix = &plusprefix;
prefixlen = 1;
sign = '+';
}
else if (flags & F_BLANK)
{
prefix = spaces;
prefixlen = 1;
sign = ' ';
}
}
// Construct complete prefix from sign and hex prefix character
prefixlen = 0;
if (sign != '\0')
{
prefix[0] = sign;
prefixlen = 1;
}
if (hexprefix != '\0')
{
prefix[prefixlen] = '0';
prefix[prefixlen + 1] = hexprefix;
prefixlen += 2;
}
// Pad the output to the field width, if needed
int fieldlen = prefixlen + postprefixzeros + bufflen;
const char *pad = (flags & F_ZERO) ? zeroes : spaces;
@ -617,9 +823,55 @@ namespace StringFormat
outlen += output (outputData, prefix, prefixlen);
}
outlen += writepad (output, outputData, zeroes, sizeof(spaces), postprefixzeros);
if (bufflen > 0)
if (!(flags & F_FPT))
{
outlen += output (outputData, obuff, bufflen);
if (bufflen > 0)
{
outlen += output (outputData, obuff, bufflen);
}
}
else
{
if (expchar == '\0') // %[fF] or sufficiently short %[gG]
{
if (expt <= 0)
{
outlen += output (outputData, zeroes, 1);
if (precision != 0 || (flags & F_HASH))
{
outlen += output (outputData, decimal_point, 1);
}
outlen += writepad (output, outputData, zeroes, sizeof(zeroes), -expt);
// already handled initial 0's
precision += expt;
}
else
{
outlen += printandpad (output, outputData, obuff, dtoaend, expt, zeroes, sizeof(zeroes));
obuff += expt;
if (precision || (flags & F_HASH))
{
outlen += output (outputData, decimal_point, 1);
}
}
outlen += printandpad (output, outputData, obuff, dtoaend, precision, zeroes, sizeof(zeroes));
}
else // %[eE] or sufficiently long %[gG]
{
if (precision > 1 || (flags & F_HASH))
{
buffer[0] = *obuff++;
buffer[1] = *decimal_point;
outlen += output (outputData, buffer, 2);
outlen += output (outputData, obuff, ndig - 1);
outlen += writepad (output, outputData, zeroes, sizeof(zeroes), precision - ndig);
}
else // XeYY
{
outlen += output (outputData, obuff, 1);
}
outlen += output (outputData, expstr, expsize);
}
}
if ((flags & F_MINUS) && fieldlen < width)
@ -627,7 +879,166 @@ namespace StringFormat
outlen += writepad (output, outputData, pad, sizeof(spaces), width - fieldlen);
}
len += outlen;
if (dtoaresult != NULL)
{
freedtoa(dtoaresult);
dtoaresult = NULL;
}
}
}
}
static int writepad (OutputFunc output, void *outputData, const char *pad, int padsize, int spaceToFill)
{
int outlen = 0;
while (spaceToFill > 0)
{
int count = spaceToFill > padsize ? padsize : spaceToFill;
outlen += output (outputData, pad, count);
spaceToFill -= count;
}
return outlen;
}
static int printandpad (OutputFunc output, void *outputData, const char *p, const char *ep, int len, const char *with, int padsize)
{
int outlen = 0;
int n2 = (int)(ep - p);
if (n2 > len)
{
n2 = len;
}
if (n2 > 0)
{
outlen = output (outputData, p, n2);
}
return outlen + writepad (output, outputData, with, padsize, len - (n2 > 0 ? n2 : 0));
}
static int exponent (char *p0, int exp, int fmtch)
{
char *p, *t;
char expbuf[MAXEXPDIG];
p = p0;
*p++ = fmtch;
if (exp < 0)
{
exp = -exp;
*p++ = '-';
}
else
{
*p++ = '+';
}
t = expbuf + MAXEXPDIG;
if (exp > 9)
{
do
{
*--t = '0' + (exp % 10);
}
while ((exp /= 10) > 9);
*--t = '0' + exp;
for(; t < expbuf + MAXEXPDIG; *p++ = *t++)
{ }
}
else
{
// Exponents for decimal floating point conversions
// (%[eEgG]) must be at least two characters long,
// whereas exponents for hexadecimal conversions can
// be only one character long.
if (fmtch == 'e' || fmtch == 'E')
{
*p++ = '0';
}
*p++ = '0' + exp;
}
return (int)(p - p0);
}
};
//========================================================================//
// snprintf / vsnprintf imitations
#ifdef __GNUC__
#define GCCPRINTF(stri,firstargi) __attribute__((format(printf,stri,firstargi)))
#define GCCFORMAT(stri) __attribute__((format(printf,stri,0)))
#define GCCNOWARN __attribute__((unused))
#else
#define GCCPRINTF(a,b)
#define GCCFORMAT(a)
#define GCCNOWARN
#endif
struct snprintf_state
{
char *buffer;
size_t maxlen;
size_t curlen;
int ideallen;
};
static int myvsnprintf_helper(void *data, const char *cstr, int cstr_len)
{
snprintf_state *state = (snprintf_state *)data;
if (INT_MAX - cstr_len < state->ideallen)
{
state->ideallen = INT_MAX;
}
else
{
state->ideallen += cstr_len;
}
if (state->curlen + cstr_len > state->maxlen)
{
cstr_len = (int)(state->maxlen - state->curlen);
}
if (cstr_len > 0)
{
memcpy(state->buffer + state->curlen, cstr, cstr_len);
state->curlen += cstr_len;
}
return cstr_len;
}
extern "C"
{
// Unlike the MS CRT function snprintf, this one always writes a terminating
// null character to the buffer. It also returns the full length of the string
// that would have been output if the buffer had been large enough. In other
// words, it follows BSD/Linux rules and not MS rules.
int myvsnprintf(char *buffer, size_t count, const char *format, va_list argptr)
{
size_t originalcount = count;
if (count != 0)
{
count--;
}
if (count > INT_MAX)
{ // This is probably an error. Output nothing.
originalcount = 0;
count = 0;
}
snprintf_state state = { buffer, count, 0, 0 };
StringFormat::VWorker(myvsnprintf_helper, &state, format, argptr);
if (originalcount > 0)
{
buffer[state.curlen] = '\0';
}
return state.ideallen;
}
int mysnprintf(char *buffer, size_t count, const char *format, ...)
{
va_list argptr;
va_start(argptr, format);
int len = myvsnprintf(buffer, count, format, argptr);
va_end(argptr);
return len;
}
}

View file

@ -3,7 +3,7 @@
** A dynamically-allocated string class.
**
**---------------------------------------------------------------------------
** Copyright 2005-2007 Randy Heit
** Copyright 2005-2008 Randy Heit
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without

View file

@ -281,6 +281,7 @@ namespace StringFormat
F_SIGNED = 32,
F_NEGATIVE = 64,
F_ZEROVALUE = 128,
F_FPT = 256,
// Format specification size prefixes
F_HALFHALF = 0x1000, // hh

Some files were not shown because too many files have changed in this diff Show more