source-client
This commit is contained in:
parent
f47eed4544
commit
a00b9a88eb
22
source-client/.gitattributes
vendored
Normal file
22
source-client/.gitattributes
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
### default behavior
|
||||
* text=auto eol=lf
|
||||
## note: eol in text auto is fixed since git 2.10 (31 aug 2016)
|
||||
|
||||
### windows (always crlf)
|
||||
*.bat eol=crlf
|
||||
*.sln eol=crlf
|
||||
*.filters eol=crlf
|
||||
*.users eol=crlf
|
||||
*.vcxproj eol=crlf
|
||||
*.vssscc eol=crlf
|
||||
|
||||
### unix (always lf)
|
||||
*.sh eol=lf
|
||||
*.bash eol=lf
|
||||
*.py eol=lf
|
||||
|
||||
### binaries
|
||||
*.suo binary
|
||||
|
||||
### others
|
||||
*.txt eol=crlf
|
||||
70
source-client/.gitignore
vendored
Normal file
70
source-client/.gitignore
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
Extern
|
||||
__test
|
||||
__trash
|
||||
|
||||
.vs
|
||||
|
||||
*.ncb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
#+easy with .suo
|
||||
#*.suo
|
||||
|
||||
*.bsc
|
||||
*.exe
|
||||
*.ilk
|
||||
*.map
|
||||
*.pdb
|
||||
*.idb
|
||||
*.aps
|
||||
|
||||
obj
|
||||
ipch
|
||||
Debug
|
||||
Release
|
||||
MfcRelease
|
||||
*___Win32_MfcRelease
|
||||
MfcDebug
|
||||
*___Win32_MfcDebug
|
||||
Distribute
|
||||
|
||||
bin
|
||||
|
||||
OBJDIR
|
||||
.obj
|
||||
|
||||
Depend
|
||||
Depend.bak
|
||||
|
||||
*.a
|
||||
*.dll
|
||||
*.lib
|
||||
*.o
|
||||
*.so
|
||||
*.iobj
|
||||
*.ipdb
|
||||
|
||||
db_r*
|
||||
game_r*
|
||||
|
||||
db_symlink
|
||||
game_symlink
|
||||
|
||||
pre_qc
|
||||
*.pyc
|
||||
|
||||
*.bak
|
||||
/.project
|
||||
|
||||
### archives
|
||||
*.rar
|
||||
!client-Extern.rar
|
||||
*.7z
|
||||
*.zip
|
||||
*.gz
|
||||
*.bz
|
||||
*.xz
|
||||
*.tar
|
||||
*.tgz
|
||||
*.tbz
|
||||
*.txz
|
||||
245
source-client/README-CLIENT.txt
Normal file
245
source-client/README-CLIENT.txt
Normal file
@ -0,0 +1,245 @@
|
||||
# README #
|
||||
|
||||
This README would normally document whatever steps are necessary to get your application up and running.
|
||||
|
||||
### What is this repository for? ###
|
||||
|
||||
* Quick summary
|
||||
* Version
|
||||
* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
|
||||
|
||||
### How do I get set up? ###
|
||||
|
||||
* Summary of set up
|
||||
-Extract Extern.rar in ".\Srcs\"
|
||||
-Open ".\Srcs\Extern\cryptopp\cryptlib.sln" and compile it
|
||||
-Open ".\Srcs\Client\Metin2Client.sln" and compile it
|
||||
|
||||
@\Srcs\Extern\cryptopp is compiler-version based and should recompile with MT target option
|
||||
>maybe without /GL and /LTCG should be fine too
|
||||
|
||||
* Configuration
|
||||
@#PYTHON2 2.7
|
||||
>in ".\Srcs\Extern\include\Python27"
|
||||
|
||||
@#GRANNY2 (granny2.11 by default)
|
||||
>easy switch in ".\Srcs\Extern\include\granny.h" amongst granny2.4, 2.7, 2.8, 2.9, 2.11
|
||||
|
||||
@#GENERAL MACROS
|
||||
#define __OBSOLETE__ //useless and pointless code removed
|
||||
#define __UNIMPLEMENTED__ //drafts of new things to be implemented
|
||||
|
||||
@\Srcs\Client\UserInterface\Locale_inc.h for ymir system implementations
|
||||
>>default
|
||||
#define LOCALE_SERVICE_EUROPE //locale you want for locale.cpp
|
||||
#define ENABLE_COSTUME_SYSTEM //costume system [@warme666]
|
||||
#define ENABLE_ENERGY_SYSTEM //energy system [@warme666]
|
||||
#define ENABLE_DRAGON_SOUL_SYSTEM //dss system [@warme666]
|
||||
#define ENABLE_NEW_EQUIPMENT_SYSTEM //belt system [@warme666]
|
||||
>>new macros
|
||||
#define ENABLE_PACK_GET_CHECK //enable py|pyc|txt check on pack.Get
|
||||
#define ENABLE_CANSEEHIDDENTHING_FOR_GM //enable gm to see invisible characters (both normal semi-transparent and gm invisibility)
|
||||
#define ENABLE_PROTOSTRUCT_AUTODETECT // if enabled, all the item_proto/mob_proto official structures (2007~2016) are automatically detected and supported without recompiling
|
||||
#define ENABLE_PLAYER_PER_ACCOUNT5 //enable 5 characters per account [@warme666]
|
||||
#define ENABLE_LEVEL_IN_TRADE //for localeInfo.EXCHANGE_TITLE with level
|
||||
#define ENABLE_TEXT_LEVEL_REFRESH //enable text tail level refresh when levelup
|
||||
#define ENABLE_DICE_SYSTEM //enable dice system: if the mob is king or boss and you're in party, the dropped item is randomly rolled [@warme666]
|
||||
#define ENABLE_EXTEND_INVEN_SYSTEM //enable 4 inventory pages [@warme666]
|
||||
#define ENABLE_LVL115_ARMOR_EFFECT //enable sparkle effect for 115 armors
|
||||
#define ENABLE_USE_COSTUME_ATTR //enable the items reset costume and enchant costume
|
||||
#define ENABLE_SLOT_WINDOW_EX //it will fix the refresh of the activated and cooltimed slots in the skill page (V) (except when switching to the equitation tab and vice versa)
|
||||
#define WJ_SHOW_MOB_INFO //enable mob info update for showing the mob lvl and the asterisk in name if aggro (ENABLE_SHOW_MOBAIFLAG and ENABLE_SHOW_MOBLEVEL)
|
||||
#define ENABLE_WOLFMAN_CHARACTER //enable wolfman features [@warme666]
|
||||
#define DISABLE_WOLFMAN_ON_CREATE //disable wolfman on create phase [@warme666]
|
||||
#define ENABLE_SEQUENCE_SYSTEM // enable sequence system [@warme666]
|
||||
#define ENABLE_MAGIC_REDUCTION_SYSTEM // enable resist magic reduction bonus [@warme666]
|
||||
#define ENABLE_MOUNT_COSTUME_SYSTEM // enable mount costume slot [@warme666]
|
||||
#define ENABLE_WEAPON_COSTUME_SYSTEM // enable weapon costume system [@warme666]
|
||||
#define ENABLE_PET_SYSTEM_EX // enable item pet without quest [@warme666]
|
||||
#define ENABLE_LOCALE_COMMON // it loads shared locale data from locale/common/
|
||||
#define ENABLE_NO_DSS_QUALIFICATION //disable dragon soul qualification [@warme666]
|
||||
#define ENABLE_NO_SELL_PRICE_DIVIDED_BY_5 // disable dividing the sell price by 5 [@warme666]
|
||||
#define ENABLE_PENDANT_SYSTEM // pendant equip implementation [@warme666]
|
||||
#define ENABLE_GLOVE_SYSTEM // glove equip implementation [@warme666]
|
||||
#define ENABLE_MOVE_CHANNEL // enable channel switch [@warme666]
|
||||
#define ENABLE_QUIVER_SYSTEM // enable quiver system [@warme666]
|
||||
#define ENABLE_RACE_HEIGHT // enable race_height.txt load
|
||||
#define ENABLE_ELEMENTAL_TARGET // enable elemental target
|
||||
#define ENABLE_INGAME_CONSOLE // enable the debug console back again by pressing "," if gm
|
||||
#define ENABLE_4TH_AFF_SKILL_DESC // enable the 4th affect skill desc
|
||||
|
||||
@\Srcs\Client\GameLib\ActorInstanceAttach.cpp
|
||||
#define AUTODETECT_LYCAN_RODNPICK_BONE // adjust fishrod/pickaxe attached bone for lycan to equip_right instead of equip_right_weapon
|
||||
|
||||
@\Srcs\Client\GameLib\ActorInstanceCollisionDetection.cpp
|
||||
#define ENABLE_NPC_WITHOUT_COLLISIONS // disable collisions for all npc (except doors)
|
||||
#define ENABLE_PETS_WITHOUT_COLLISIONS // disable collisions for pets
|
||||
#define ENABLE_SHOPS_WITHOUT_COLLISIONS // disable collisions for shops
|
||||
#define ENABLE_MOUNTS_WITHOUT_COLLISIONS // disable collisions for mounts
|
||||
|
||||
@\Srcs\Client\GameLib\MapOutdoor.cpp
|
||||
#define ENABLE_FOG_LOAD // enable fog.tga load
|
||||
|
||||
@\Srcs\Client\EterLib\error.cpp
|
||||
#define ENABLE_CRASH_MINIDUMP // it will generate a debuggable client\logs\metin2client_{version}_{date}.dmp file instead of "??????"
|
||||
|
||||
@\Srcs\Client\EterPack\EterPack.cpp
|
||||
#define ENABLE_CRC32_CHECK //mine: enable/disable crc32 check for type2
|
||||
|
||||
@\Srcs\Client\UserInterface\PythonApplication.cpp
|
||||
#define ENABLE_LOAD_ITEM_LIST_FROM_ROOT //load item_list.txt from root
|
||||
#define ENABLE_LOAD_ITEM_SCALE_FROM_ROOT //load item_scale.txt from root
|
||||
#define ENABLE_LOAD_SKILL_TABLE_FROM_ROOT //load SkillTable.txt from root
|
||||
|
||||
@\Srcs\Client\UserInterface\PythonMiniMap.cpp
|
||||
#define ENABLE_NEW_ATLAS_MARK_INFO //read the new locale/<lan>/map/<mapname>_point.txt structure (files used for offline minimap npc rendering)
|
||||
|
||||
@\Srcs\Client\UserInterface\PythonPlayer.cpp
|
||||
#define ENABLE_NO_PICKUP_LIMIT //if enabled, there will be no 0.5s of delay when picking up items with keyboard (\\z)
|
||||
|
||||
@\Srcs\Client\UserInterface\UserInterface.cpp
|
||||
#define ENABLE_PYLIB_CHECK //check python lib files to prevent exploit before load them
|
||||
#define ENABLE_MILES_CHECK //check miles files to prevent mss32.dll exploit before load them
|
||||
|
||||
@\Srcs\Client\UserInterface\InstanceBase.cpp
|
||||
#define ENABLE_SIMPLE_REFINED_EFFECT_CHECK // enable simple refine effect check (+7 blue, +8 green, +9 red) for any weapon/armor
|
||||
#define USE_WEAPON_COSTUME_WITH_EFFECT // enable refine effect for weapon costume
|
||||
#define USE_BODY_COSTUME_WITH_EFFECT // enable refine effect for body costume
|
||||
|
||||
@\Srcs\Client\UserInterface\PythonBackground.cpp
|
||||
#define ENABLE_ATLASINFO_FROM_ROOT //read atlasinfo.txt from root instead of locale
|
||||
|
||||
@\Srcs\Client\GameLib\GameLibDefines.h
|
||||
>moved all to Locale_inc.h
|
||||
|
||||
@\Srcs\Client\GameLib\RaceDataFile.cpp
|
||||
#define ENABLE_SKIN_EXTENDED //extended source/targetskin[2-9] inside .msm
|
||||
|
||||
@\Srcs\Client\GameLib\ItemData.cpp
|
||||
#define ENABLE_LOAD_ALTER_ITEMICON //load a default item icon if the one inside the item_list.txt is missing
|
||||
|
||||
@\Srcs\Client\GameLib\ActorInstanceMotion.cpp
|
||||
#define ENABLE_WALK_RUN_ANI_ALTERNATIVE //load run animation instead of walk if missing
|
||||
|
||||
@\Srcs\Client\UserInterface\InstanceBase.cpp
|
||||
#define ENABLE_NO_MOUNT_CHECK //enable attack and skill from all horses/mounts
|
||||
|
||||
@\Srcs\Tools\DumpProto\dump_proto\dump_proto.cpp
|
||||
#define ENABLE_ADDONTYPE_AUTODETECT //it autodetects the addontype field from already known vnums (compatibility 100%)
|
||||
|
||||
@\Srcs\Tools\DumpProto\dump_proto\ItemCSVReader.cpp
|
||||
#define ENABLE_NUMERIC_FIELD //txt protos now can read numbers instead of tags as well
|
||||
|
||||
* Dependencies
|
||||
@\Srcs\Extern.rar
|
||||
>it contains all is needed
|
||||
|
||||
* Database configuration
|
||||
* How to run tests
|
||||
* Deployment instructions
|
||||
-Debug and Release are for UserInterface.sln
|
||||
-MfcDebug and MfcRelease are for WorldEditor.sln
|
||||
|
||||
### Contribution guidelines ###
|
||||
|
||||
* Writing tests
|
||||
* Code review
|
||||
#@@Globally
|
||||
@warme601: use release as advanced distribute with syserr.txt and so on
|
||||
@warme666: those features requires the same feature server-sidely otherwise you'll get random issues. (packets not correctly handled)
|
||||
@warme667: on ScriptLib/StdAfx.h; AT has been unset before loading python include
|
||||
@warme668: trivial errors will be treated as mere warnings (sys_err -> sys_log) (TraceError -> Tracenf)
|
||||
@warme669: on UserInterface/PythonNetworkStreamPhaseGame.cpp; the packet receive will be increased from 4 to 8 (totally removing the limit will cause packet instability)
|
||||
@warme670: on PythonApplication.cpp; the text in the error message was wrong
|
||||
@warme671: on ActorInstanceMotion.cpp; commented out the useless debug code that occludes the view
|
||||
|
||||
|
||||
#@@Client
|
||||
@warme001: AIL_startup responsible to load *.asi *.flt *.m3d *.mix
|
||||
@warme002: comments to be cleaned if necessary
|
||||
@warme003: messages now contain more useful information
|
||||
|
||||
|
||||
@fixme001: on UserInterface/Packet.h; for do_view_equip (WEAR_MAX_NUM: server 32, client 11) now equal (32 both sides)
|
||||
@fixme002: on EterLib/GrpImageTexture.cpp, GrpImage.cpp; to show the name of the failed mapped .dds load
|
||||
@fixme003: on PRTerrainLib/TextureSet.cpp; a new texture was added where the last was put
|
||||
@fixme004: on PRTerrainLib/TextureSet.cpp; a new textureset index was -1 instead of 0
|
||||
@fixme005: on EterLib/SkyBox.cpp; the bottom pic was not shown
|
||||
@fixme006: on UserInterface/PythonNetworkStreamModule.cpp, PythonNetworkStreamPhaseGame.cpp; "SEQUENCE mismatch 0xaf != 0x64 header 254" fix
|
||||
This happens due to a bug on the TODO_RECV_SYMBOL phase when calling the __SendSymbolCRCList.
|
||||
That function will connect via MarkServer_Login and iterate m_kVec_dwGuildID to send sub-"HEADER_CG_SYMBOL_CRC" packets.
|
||||
If m_kVec_dwGuildID is 0, the server will never receive packets after logged in the MarkServer, and the connection won't be closed.
|
||||
When a connection is established, a ping_event will be triggered every 60 seconds.
|
||||
When the time will come, a ping packet will be send to the client, and the client will reply back with a pong one.
|
||||
In this case, the secondary marklogin connection would be asynchronous, and the packet sequence for the pong mismatched too.
|
||||
After the sequence error occurs, the marklogin connection will be finally closed.
|
||||
|
||||
In few words, everytime someone logs in the server (after character selection),
|
||||
the syserr will get once the mismatch error after 60 seconds.
|
||||
The fix is to not establish a marklogin connection for TODO_RECV_SYMBOL if the m_kVec_dwGuildID is 0.
|
||||
@fixme008: on EterLib/IME.cpp; Ctrl+V crash when pasting images&co (no checks whether the handle was NULL or not)
|
||||
@fixme009: on UserInterface/PythonPlayerModule.cpp; player.GetItemLink wasn't considering 6-7 bonuses enough
|
||||
they could have been seen as 1-5 bonuses if the item didn't have 1-5 bonuses
|
||||
@fixme010: on UserInterface/PythonCharacterManager.cpp; ymir forgot .m_dwVID in the format argument (c_rkCreateData -> c_rkCreateData.m_dwVID)
|
||||
@fixme011: on EterLib/IME.cpp; non-printing/control characters were printed in the (chat) input (the ones you get when you press Ctrl+<key> in game)
|
||||
@fixme012: on EterLib/TextTag.cpp; on arabic locales, the [HyperText code] (alias Prism code) could be edited pressing <Backspace>
|
||||
@fixme013: on UserInterface/PythonPlayerModule.cpp; player.IsValuableItem was selecting a wrong item.cell
|
||||
@fixme014: on UserInterface/PythonPlayerInput.cpp; if you (mouse) click a monster without having arrows, the automatic attack will go in loop (clicking on ground again will fix, but moving with WASD will be bad)
|
||||
@fixme015: on GameLib/MapOutdoorLoad.cpp; regen.txt was loaded from launcher even though it's used only by the WorldEditor
|
||||
@fixme016: on UserInterface/PythonShop.cpp; ShopEx data weren't cleared if normal shops were open
|
||||
@fixme018: on EterLib/GrpDevice.cpp; on computers where 800x600 resolution has been removed, it would trigger "CREATE_NO_APPROPRIATE_DEVICE"
|
||||
@fixme020: on ScriptLib/Resource.cpp; .png textures weren't listed
|
||||
@fixme021: on GameLib/RaceManager.cpp; new npclist.txt autodetects season shape.msm automatically
|
||||
@fixme022: on UserInterface/PythonItem.cpp; GetCloseItem distance calculation failed during float conversion (faraway items got distance 2 making them unpickable)
|
||||
@fixme024: on UserInterface/Packet.h; TChannelStatus will always return the status offline any channel with ports higher than 32767.
|
||||
@fixme025: on UserInterface/InstanceBase.h, InstanceBaseEffect.cpp; if you were to receive many damage packets, the damage queue will keep showing damange texts even after a while
|
||||
@fixme026: on GameLib/RaceMotionDataEvent.h; backslashes were giving a wrong crc32 for the registered effects
|
||||
@fixme027: on EffectLib/EffectMesh.cpp, EffectMeshInstance.cpp; custom mde files with no index vertex would trigger a crash
|
||||
@fixme028: on EterPythonLib/PythonWindowManagerModule.cpp; wnd.TextSetFontColor had a signed/unsigned limit issue
|
||||
@fixme029: on UserInterface/PythonApplication.cpp, EterGrnLib/ModelInstanceUpdate.cpp; black screen fix - effectmanager wasn't delecting expired effects, and granny wasn't updating the models
|
||||
@fixme030: on EffectLib/EffectManager.cpp, GameLib/ActorInstance.cpp, GameLib/ActorInstanceAttach.cpp, GameLib/Area.cpp; the calculated crc32 will mismatch in case of uppercase letters
|
||||
@fixme031: on UserInterface/PythonApplication.cpp; the dropshadow style in win10 and the bigger taskbar were causing boring issues
|
||||
@fixme032: on UserInterface/PythonApplicationProcedure.cpp; ALT+key was triggering a windows system sound
|
||||
@fixme033: on GameLib/ActorInstanceSync.cpp; there was a desync when a mental strong body was being attacked without moving (server-side respawn still glitched)
|
||||
@fixme034: on UserInterface/NetworkActorManager.cpp; stones weren't properly cleared as actors
|
||||
@fixme035: on EterPack.cpp; memory leak in eterpack::get for panama and hybrid type
|
||||
@fixme036: on PythonTextTail.cpp; level position wrongly positioned
|
||||
@fixme037: on PythonPlayerInputMouse.cpp; little glitch when picking items with the horse (infinite rotation)
|
||||
@fixme038: on mileslib/SoundManager.cpp; stopped sounds were later played back unsuccessfully
|
||||
@fixme039: on EterLib/StateManager.cpp; the anisotropic texture filtering was applied only once at startup, but not after lostdevice/recoverydevice
|
||||
|
||||
|
||||
#@@Tools
|
||||
#@/DumpProto
|
||||
@fixme201: on ItemCSVReader.cpp; race splitted with | instead of ,
|
||||
|
||||
|
||||
#@/Metin2PackMaker
|
||||
@fixme301: on Main.cpp; The path ignored is always "d:/ymir work/sound/" instead of the chosen one
|
||||
@fixme302: on Main.cpp; The directory ignored is always "CVS" instead of the chosen one
|
||||
|
||||
|
||||
#@/Metin2MsaMaker
|
||||
@fixme401: on Metin2MSAMaker.cpp; the accumulation wasn't calculated at all on model versions above 2.4
|
||||
|
||||
|
||||
#@/General
|
||||
@fixme501: on UserInterface/Packet.h; mob race word to dword
|
||||
@fixme502: on UserInterface/Packet.h; character part word to dword
|
||||
|
||||
|
||||
* Other guidelines
|
||||
@\Srcs\Client\EterBase\Filename.h pseudo-fix to "successfully" compile
|
||||
>needs rewriting (or simply fixing)
|
||||
|
||||
@\Srcs\Client\ScriptLib\PythonUtils.cpp with pseudo-long fix
|
||||
#define PyLong_AsLong PyLong_AsLongLong
|
||||
#define PyLong_AsUnsignedLong PyLong_AsUnsignedLongLong
|
||||
>just this so it'll be 8 bytes instead of 4 for tuples
|
||||
>an another way is just to change every color function with Py_xUnsigned instead of its Signed
|
||||
|
||||
|
||||
### Who do I talk to? ###
|
||||
|
||||
* Repo owner or admin
|
||||
martysama0134
|
||||
1718
source-client/Srcs/Client/CWebBrowser/CWebBrowser.c
Normal file
1718
source-client/Srcs/Client/CWebBrowser/CWebBrowser.c
Normal file
File diff suppressed because it is too large
Load Diff
18
source-client/Srcs/Client/CWebBrowser/CWebBrowser.h
Normal file
18
source-client/Srcs/Client/CWebBrowser/CWebBrowser.h
Normal file
@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
extern "C" {
|
||||
int WebBrowser_Startup(HINSTANCE hInstance);
|
||||
void WebBrowser_Cleanup();
|
||||
void WebBrowser_Destroy();
|
||||
int WebBrowser_Show(HWND parent, const char* addr, const RECT* rcWebBrowser);
|
||||
void WebBrowser_Hide();
|
||||
void WebBrowser_Move(const RECT* rcWebBrowser);
|
||||
|
||||
int WebBrowser_IsVisible();
|
||||
const RECT& WebBrowser_GetRect();
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
193
source-client/Srcs/Client/CWebBrowser/CWebBrowser.vcxproj
Normal file
193
source-client/Srcs/Client/CWebBrowser/CWebBrowser.vcxproj
Normal file
@ -0,0 +1,193 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Distribute|Win32">
|
||||
<Configuration>Distribute</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectName>CWebBrowser</ProjectName>
|
||||
<ProjectGuid>{D64AE35F-F982-46D4-8E38-09E5C9752955}</ProjectGuid>
|
||||
<RootNamespace>CWebBrowser</RootNamespace>
|
||||
<SccProjectName>
|
||||
</SccProjectName>
|
||||
<SccAuxPath>
|
||||
</SccAuxPath>
|
||||
<SccLocalPath>
|
||||
</SccLocalPath>
|
||||
<SccProvider>
|
||||
</SccProvider>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">$(ProjectDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">$(Configuration)\</IntDir>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS;_SILENCE_ALL_CXX20_DEPRECATION_WARNINGS;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderOutputFile>$(IntDir)$(ProjectName).pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
|
||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
||||
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<PrecompiledHeaderFile>CWebBrowser.h</PrecompiledHeaderFile>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<SDLCheck>
|
||||
</SDLCheck>
|
||||
<AdditionalIncludeDirectories>../../Extern/include</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS;_SILENCE_ALL_CXX20_DEPRECATION_WARNINGS;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderOutputFile>$(IntDir)$(ProjectName).pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
|
||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
||||
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<PrecompiledHeaderFile>CWebBrowser.h</PrecompiledHeaderFile>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<SDLCheck>
|
||||
</SDLCheck>
|
||||
<AdditionalIncludeDirectories>../../Extern/include</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderOutputFile>$(IntDir)$(ProjectName).pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
|
||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
||||
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<PrecompiledHeaderFile>CWebBrowser.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="CWebBrowser.c">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="CWebBrowser.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
</Project>
|
||||
222
source-client/Srcs/Client/EffectLib/EffectData.cpp
Normal file
222
source-client/Srcs/Client/EffectLib/EffectData.cpp
Normal file
@ -0,0 +1,222 @@
|
||||
#include "StdAfx.h"
|
||||
#include "EffectData.h"
|
||||
|
||||
CDynamicPool<CEffectData> CEffectData::ms_kPool;
|
||||
|
||||
CEffectData* CEffectData::New()
|
||||
{
|
||||
return ms_kPool.Alloc();
|
||||
}
|
||||
|
||||
void CEffectData::Delete(CEffectData* pkData)
|
||||
{
|
||||
pkData->Clear();
|
||||
ms_kPool.Free(pkData);
|
||||
}
|
||||
|
||||
void CEffectData::DestroySystem()
|
||||
{
|
||||
ms_kPool.Destroy();
|
||||
|
||||
CParticleSystemData::DestroySystem();
|
||||
CEffectMeshScript::DestroySystem();
|
||||
CLightData::DestroySystem();
|
||||
}
|
||||
|
||||
bool CEffectData::LoadScript(const char * c_szFileName)
|
||||
{
|
||||
m_strFileName = c_szFileName;
|
||||
CFileNameHelper::StringPath(m_strFileName);
|
||||
|
||||
CTextFileLoader TextFileLoader;
|
||||
if (!TextFileLoader.Load(c_szFileName))
|
||||
return false;
|
||||
|
||||
TextFileLoader.SetTop();
|
||||
|
||||
if (!TextFileLoader.GetTokenFloat("boundingsphereradius", &m_fBoundingSphereRadius))
|
||||
{
|
||||
m_fBoundingSphereRadius = 0.0f;
|
||||
}
|
||||
|
||||
if (!TextFileLoader.GetTokenVector3("boundingsphereposition", &m_v3BoundingSpherePosition))
|
||||
{
|
||||
m_v3BoundingSpherePosition.x = m_v3BoundingSpherePosition.y = m_v3BoundingSpherePosition.z = 0.0f;
|
||||
}
|
||||
|
||||
for (DWORD i = 0; i < TextFileLoader.GetChildNodeCount(); ++i)
|
||||
{
|
||||
if (!TextFileLoader.SetChildNode(i))
|
||||
continue;
|
||||
|
||||
std::string strName;
|
||||
|
||||
if (!TextFileLoader.GetCurrentNodeName(&strName))
|
||||
continue;
|
||||
|
||||
if (0 == strName.compare("mesh"))
|
||||
{
|
||||
CEffectMeshScript * pMesh = AllocMesh();
|
||||
pMesh->Clear();
|
||||
pMesh->LoadScript(TextFileLoader);
|
||||
}
|
||||
else if (0 == strName.compare("particle"))
|
||||
{
|
||||
CParticleSystemData * pParticleSystemData = AllocParticle();
|
||||
pParticleSystemData->Clear();
|
||||
pParticleSystemData->LoadScript(TextFileLoader);
|
||||
}
|
||||
else if (0 == strName.compare("light"))
|
||||
{
|
||||
CLightData * pLightData = AllocLight();
|
||||
pLightData->Clear();
|
||||
pLightData->LoadScript(TextFileLoader);
|
||||
}
|
||||
|
||||
TextFileLoader.SetParentNode();
|
||||
}
|
||||
|
||||
// Load Sound
|
||||
std::string strPathHeader = "d:/ymir work/";
|
||||
std::string strNoExtensionName = CFileNameHelper::NoExtension(m_strFileName);
|
||||
int iPos = strNoExtensionName.find(strPathHeader.c_str());
|
||||
if (iPos >= 0)
|
||||
if (strNoExtensionName.size() > strPathHeader.size())
|
||||
{
|
||||
std::string strSoundFileName;
|
||||
strSoundFileName = "sound/";
|
||||
strSoundFileName += &strNoExtensionName[strPathHeader.size()];
|
||||
strSoundFileName += ".mss";
|
||||
|
||||
LoadSoundScriptData(strSoundFileName.c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CEffectData::LoadSoundScriptData(const char * c_szFileName)
|
||||
{
|
||||
NSound::TSoundDataVector SoundDataVector;
|
||||
|
||||
if (NSound::LoadSoundInformationPiece(c_szFileName, SoundDataVector))
|
||||
{
|
||||
NSound::DataToInstance(SoundDataVector, &m_SoundInstanceVector);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CParticleSystemData * CEffectData::AllocParticle()
|
||||
{
|
||||
CParticleSystemData * pParticle = CParticleSystemData::New();
|
||||
m_ParticleVector.push_back(pParticle);
|
||||
return pParticle;
|
||||
}
|
||||
|
||||
CEffectMeshScript * CEffectData::AllocMesh()
|
||||
{
|
||||
CEffectMeshScript * pMesh = CEffectMeshScript::New();
|
||||
m_MeshVector.push_back(pMesh);
|
||||
return pMesh;
|
||||
}
|
||||
|
||||
CLightData * CEffectData::AllocLight()
|
||||
{
|
||||
CLightData * pLight = CLightData::New();
|
||||
m_LightVector.push_back(pLight);
|
||||
return pLight;
|
||||
}
|
||||
|
||||
DWORD CEffectData::GetLightCount()
|
||||
{
|
||||
return m_LightVector.size();
|
||||
}
|
||||
|
||||
CLightData * CEffectData::GetLightPointer(DWORD dwPosition)
|
||||
{
|
||||
assert(dwPosition < m_LightVector.size());
|
||||
return m_LightVector[dwPosition];
|
||||
}
|
||||
|
||||
DWORD CEffectData::GetParticleCount()
|
||||
{
|
||||
return m_ParticleVector.size();
|
||||
}
|
||||
CParticleSystemData * CEffectData::GetParticlePointer(DWORD dwPosition)
|
||||
{
|
||||
if(dwPosition < m_ParticleVector.size())
|
||||
return m_ParticleVector[dwPosition];
|
||||
else
|
||||
{
|
||||
assert(false);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
DWORD CEffectData::GetMeshCount()
|
||||
{
|
||||
return m_MeshVector.size();
|
||||
}
|
||||
CEffectMeshScript * CEffectData::GetMeshPointer(DWORD dwPosition)
|
||||
{
|
||||
assert(dwPosition < m_MeshVector.size());
|
||||
return m_MeshVector[dwPosition];
|
||||
}
|
||||
|
||||
NSound::TSoundInstanceVector * CEffectData::GetSoundInstanceVector()
|
||||
{
|
||||
return &m_SoundInstanceVector;
|
||||
}
|
||||
|
||||
float CEffectData::GetBoundingSphereRadius()
|
||||
{
|
||||
return m_fBoundingSphereRadius;
|
||||
}
|
||||
|
||||
D3DXVECTOR3 CEffectData::GetBoundingSpherePosition()
|
||||
{
|
||||
return m_v3BoundingSpherePosition;
|
||||
}
|
||||
|
||||
const char * CEffectData::GetFileName() const
|
||||
{
|
||||
return m_strFileName.c_str();
|
||||
}
|
||||
|
||||
void CEffectData::__ClearParticleDataVector()
|
||||
{
|
||||
std::for_each(m_ParticleVector.begin(), m_ParticleVector.end(), CParticleSystemData::Delete);
|
||||
m_ParticleVector.clear();
|
||||
}
|
||||
|
||||
void CEffectData::__ClearLightDataVector()
|
||||
{
|
||||
std::for_each(m_LightVector.begin(), m_LightVector.end(), CLightData::Delete);
|
||||
m_LightVector.clear();
|
||||
}
|
||||
|
||||
void CEffectData::__ClearMeshDataVector()
|
||||
{
|
||||
std::for_each(m_MeshVector.begin(), m_MeshVector.end(), CEffectMeshScript::Delete);
|
||||
m_MeshVector.clear();
|
||||
}
|
||||
|
||||
void CEffectData::Clear()
|
||||
{
|
||||
m_fBoundingSphereRadius = 0.0f;
|
||||
m_v3BoundingSpherePosition.x = m_v3BoundingSpherePosition.y = m_v3BoundingSpherePosition.z = 0.0f;
|
||||
__ClearParticleDataVector();
|
||||
__ClearLightDataVector();
|
||||
__ClearMeshDataVector();
|
||||
}
|
||||
|
||||
CEffectData::CEffectData()
|
||||
{
|
||||
m_fBoundingSphereRadius = 0.0f;
|
||||
m_v3BoundingSpherePosition.x = m_v3BoundingSpherePosition.y = m_v3BoundingSpherePosition.z = 0.0f;
|
||||
}
|
||||
CEffectData::~CEffectData()
|
||||
{
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
68
source-client/Srcs/Client/EffectLib/EffectData.h
Normal file
68
source-client/Srcs/Client/EffectLib/EffectData.h
Normal file
@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
#include "../milesLib/Type.h"
|
||||
|
||||
#include "ParticleSystemData.h"
|
||||
#include "EffectMesh.h"
|
||||
#include "SimpleLightData.h"
|
||||
|
||||
class CEffectData
|
||||
{
|
||||
public:
|
||||
typedef std::vector<CParticleSystemData*> TParticleVector;
|
||||
typedef std::vector<CEffectMeshScript*> TMeshVector;
|
||||
typedef std::vector<CLightData*> TLightVector;
|
||||
|
||||
public:
|
||||
CEffectData();
|
||||
virtual ~CEffectData();
|
||||
|
||||
void Clear();
|
||||
bool LoadScript(const char * c_szFileName);
|
||||
bool LoadSoundScriptData(const char * c_szFileName);
|
||||
|
||||
DWORD GetParticleCount();
|
||||
CParticleSystemData * GetParticlePointer(DWORD dwPosition);
|
||||
|
||||
DWORD GetMeshCount();
|
||||
CEffectMeshScript * GetMeshPointer(DWORD dwPosition);
|
||||
|
||||
DWORD GetLightCount();
|
||||
CLightData * GetLightPointer(DWORD dwPosition);
|
||||
|
||||
NSound::TSoundInstanceVector * GetSoundInstanceVector();
|
||||
|
||||
float GetBoundingSphereRadius();
|
||||
D3DXVECTOR3 GetBoundingSpherePosition();
|
||||
|
||||
const char * GetFileName() const;
|
||||
|
||||
protected:
|
||||
void __ClearParticleDataVector();
|
||||
void __ClearLightDataVector();
|
||||
void __ClearMeshDataVector();
|
||||
|
||||
virtual CParticleSystemData * AllocParticle();
|
||||
virtual CEffectMeshScript * AllocMesh();
|
||||
virtual CLightData * AllocLight();
|
||||
|
||||
protected:
|
||||
TParticleVector m_ParticleVector;
|
||||
TMeshVector m_MeshVector;
|
||||
TLightVector m_LightVector;
|
||||
NSound::TSoundInstanceVector m_SoundInstanceVector;
|
||||
|
||||
float m_fBoundingSphereRadius;
|
||||
D3DXVECTOR3 m_v3BoundingSpherePosition;
|
||||
|
||||
std::string m_strFileName;
|
||||
|
||||
public:
|
||||
static void DestroySystem();
|
||||
|
||||
static CEffectData* New();
|
||||
static void Delete(CEffectData* pkData);
|
||||
|
||||
static CDynamicPool<CEffectData> ms_kPool;
|
||||
};
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
168
source-client/Srcs/Client/EffectLib/EffectElementBase.cpp
Normal file
168
source-client/Srcs/Client/EffectLib/EffectElementBase.cpp
Normal file
@ -0,0 +1,168 @@
|
||||
#include "StdAfx.h"
|
||||
#include "EffectElementBase.h"
|
||||
|
||||
void CEffectElementBase::GetPosition(float fTime, D3DXVECTOR3 & rPosition)
|
||||
{
|
||||
if (m_TimeEventTablePosition.empty())
|
||||
{
|
||||
rPosition = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
|
||||
return;
|
||||
}
|
||||
if (m_TimeEventTablePosition.size()==1)
|
||||
{
|
||||
rPosition = m_TimeEventTablePosition[0].m_vecPosition;
|
||||
return;
|
||||
}
|
||||
if (m_TimeEventTablePosition.front().m_fTime > fTime)
|
||||
{
|
||||
rPosition = m_TimeEventTablePosition.front().m_vecPosition;
|
||||
return;
|
||||
}
|
||||
if (m_TimeEventTablePosition.back().m_fTime < fTime)
|
||||
{
|
||||
rPosition = m_TimeEventTablePosition.back().m_vecPosition;
|
||||
return;
|
||||
}
|
||||
|
||||
typedef TTimeEventTablePosition::iterator iterator;
|
||||
iterator result = std::lower_bound( m_TimeEventTablePosition.begin(), m_TimeEventTablePosition.end(), fTime );
|
||||
|
||||
TEffectPosition & rEffectPosition = *result;
|
||||
iterator rPrev = result;
|
||||
if (m_TimeEventTablePosition.begin() != result)
|
||||
{
|
||||
rPrev = result-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
rPosition = result->m_vecPosition;
|
||||
return;
|
||||
}
|
||||
TEffectPosition & rPrevEffectPosition = *rPrev;
|
||||
int iMovingType = rPrevEffectPosition.m_iMovingType;
|
||||
|
||||
if (MOVING_TYPE_DIRECT == iMovingType)
|
||||
{
|
||||
float Head = fabs(rEffectPosition.m_fTime - fTime) / fabs(rEffectPosition.m_fTime - rPrevEffectPosition.m_fTime);
|
||||
float Tail = 1.0f - fabs(rEffectPosition.m_fTime - fTime) / fabs(rEffectPosition.m_fTime - rPrevEffectPosition.m_fTime);
|
||||
rPosition = (rPrevEffectPosition.m_vecPosition*Head) + (rEffectPosition.m_vecPosition*Tail);
|
||||
}
|
||||
else if (MOVING_TYPE_BEZIER_CURVE == iMovingType)
|
||||
{
|
||||
float ft = (fTime - rPrevEffectPosition.m_fTime) / (rEffectPosition.m_fTime - rPrevEffectPosition.m_fTime);
|
||||
|
||||
rPosition = rPrevEffectPosition.m_vecPosition * (1.0f - ft) * (1.0f - ft) +
|
||||
(rPrevEffectPosition.m_vecPosition + rPrevEffectPosition.m_vecControlPoint) * (1.0f - ft) * ft * 2 +
|
||||
rEffectPosition.m_vecPosition * ft * ft;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
bool CEffectElementBase::isVisible(float fTime)
|
||||
{
|
||||
for (DWORD i = 0; i < m_TimeEventTableVisible.size(); ++i)
|
||||
{
|
||||
float fPointTime = m_TimeEventTableVisible[i];
|
||||
|
||||
if (fTime < fPointTime)
|
||||
{
|
||||
if (1 == i % 2)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return 1 == (m_TimeEventTableVisible.size() % 2);
|
||||
}
|
||||
|
||||
void CEffectElementBase::GetAlpha(float fTime, float * pAlpha)
|
||||
{
|
||||
GetTimeEventBlendValue<TTimeEventTableFloat, float>(fTime, m_TimeEventAlpha, pAlpha);
|
||||
}
|
||||
|
||||
void CEffectElementBase::GetScale(float fTime, float * pScale)
|
||||
{
|
||||
GetTimeEventBlendValue<TTimeEventTableFloat, float>(fTime, m_TimeEventScale, pScale);
|
||||
}
|
||||
*/
|
||||
|
||||
bool CEffectElementBase::isData()
|
||||
{
|
||||
return OnIsData();
|
||||
}
|
||||
|
||||
void CEffectElementBase::Clear()
|
||||
{
|
||||
m_fStartTime = 0.0f;
|
||||
|
||||
OnClear();
|
||||
}
|
||||
|
||||
BOOL CEffectElementBase::LoadScript(CTextFileLoader & rTextFileLoader)
|
||||
{
|
||||
CTokenVector * pTokenVector;
|
||||
if (!rTextFileLoader.GetTokenFloat("starttime",&m_fStartTime))
|
||||
{
|
||||
m_fStartTime = 0.0f;
|
||||
}
|
||||
if (rTextFileLoader.GetTokenVector("timeeventposition", &pTokenVector))
|
||||
{
|
||||
m_TimeEventTablePosition.clear();
|
||||
|
||||
DWORD dwIndex = 0;
|
||||
for (DWORD i = 0; i < pTokenVector->size(); ++dwIndex)
|
||||
{
|
||||
TEffectPosition EffectPosition;
|
||||
EffectPosition.m_fTime = atof(pTokenVector->at(i++).c_str());
|
||||
if (pTokenVector->at(i)=="MOVING_TYPE_BEZIER_CURVE")
|
||||
{
|
||||
i++;
|
||||
|
||||
EffectPosition.m_iMovingType = MOVING_TYPE_BEZIER_CURVE;
|
||||
|
||||
EffectPosition.m_vecPosition.x = atof(pTokenVector->at(i++).c_str());
|
||||
EffectPosition.m_vecPosition.y = atof(pTokenVector->at(i++).c_str());
|
||||
EffectPosition.m_vecPosition.z = atof(pTokenVector->at(i++).c_str());
|
||||
|
||||
EffectPosition.m_vecControlPoint.x = atof(pTokenVector->at(i++).c_str());
|
||||
EffectPosition.m_vecControlPoint.y = atof(pTokenVector->at(i++).c_str());
|
||||
EffectPosition.m_vecControlPoint.z = atof(pTokenVector->at(i++).c_str());
|
||||
}
|
||||
else if (pTokenVector->at(i) == "MOVING_TYPE_DIRECT")
|
||||
{
|
||||
i++;
|
||||
|
||||
EffectPosition.m_iMovingType = MOVING_TYPE_DIRECT;
|
||||
|
||||
EffectPosition.m_vecPosition.x = atof(pTokenVector->at(i++).c_str());
|
||||
EffectPosition.m_vecPosition.y = atof(pTokenVector->at(i++).c_str());
|
||||
EffectPosition.m_vecPosition.z = atof(pTokenVector->at(i++).c_str());
|
||||
|
||||
EffectPosition.m_vecControlPoint = D3DXVECTOR3(0.0f,0.0f,0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_TimeEventTablePosition.push_back(EffectPosition);
|
||||
}
|
||||
}
|
||||
|
||||
return OnLoadScript(rTextFileLoader);
|
||||
}
|
||||
|
||||
float CEffectElementBase::GetStartTime()
|
||||
{
|
||||
return m_fStartTime;
|
||||
}
|
||||
|
||||
CEffectElementBase::CEffectElementBase()
|
||||
{
|
||||
m_fStartTime = 0.0f;
|
||||
}
|
||||
CEffectElementBase::~CEffectElementBase()
|
||||
{
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
38
source-client/Srcs/Client/EffectLib/EffectElementBase.h
Normal file
38
source-client/Srcs/Client/EffectLib/EffectElementBase.h
Normal file
@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
#include "Type.h"
|
||||
|
||||
class CEffectElementBase
|
||||
{
|
||||
public:
|
||||
CEffectElementBase();
|
||||
virtual ~CEffectElementBase();
|
||||
|
||||
void Clear();
|
||||
bool isData();
|
||||
|
||||
BOOL LoadScript(CTextFileLoader & rTextFileLoader);
|
||||
|
||||
void GetPosition(float fTime, D3DXVECTOR3 & rPosition);
|
||||
float GetStartTime();
|
||||
/*
|
||||
bool isVisible(float fTime);
|
||||
void GetAlpha(float fTime, float * pAlpha);
|
||||
void GetScale(float fTime, float * pScale);
|
||||
*/
|
||||
|
||||
protected:
|
||||
virtual void OnClear() = 0;
|
||||
virtual bool OnIsData() = 0;
|
||||
virtual BOOL OnLoadScript(CTextFileLoader & rTextFileLoader) = 0;
|
||||
|
||||
protected:
|
||||
float m_fStartTime;
|
||||
TTimeEventTablePosition m_TimeEventTablePosition;
|
||||
/*
|
||||
TTimeEventTable m_TimeEventTableVisible;
|
||||
TTimeEventTableFloat m_TimeEventAlpha;
|
||||
TTimeEventTableFloat m_TimeEventScale;
|
||||
*/
|
||||
};
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
@ -0,0 +1,98 @@
|
||||
#include "StdAfx.h"
|
||||
#include "EffectElementBaseInstance.h"
|
||||
|
||||
bool CEffectElementBaseInstance::Update(float fElapsedTime)
|
||||
{
|
||||
if (m_bStart)
|
||||
{
|
||||
m_fElapsedTime = fElapsedTime;
|
||||
m_fLocalTime += fElapsedTime;
|
||||
|
||||
return OnUpdate(fElapsedTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fRemainingTime -= fElapsedTime;
|
||||
if (m_fRemainingTime<=0.0f)
|
||||
m_bStart = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void CEffectElementBaseInstance::Render()
|
||||
{
|
||||
if (!m_bStart)
|
||||
return;
|
||||
|
||||
assert(mc_pmatLocal);
|
||||
|
||||
OnRender();
|
||||
}
|
||||
|
||||
void CEffectElementBaseInstance::SetLocalMatrixPointer(const D3DXMATRIX * c_pMatrix)
|
||||
{
|
||||
mc_pmatLocal = c_pMatrix;
|
||||
}
|
||||
|
||||
void CEffectElementBaseInstance::SetDataPointer(CEffectElementBase * pElement)
|
||||
{
|
||||
m_pBase = pElement;
|
||||
|
||||
m_dwStartTime = CTimer::Instance().GetCurrentMillisecond();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//add by ipkn, start time management
|
||||
|
||||
m_fRemainingTime = pElement->GetStartTime();
|
||||
if (m_fRemainingTime<=0.0f)
|
||||
m_bStart = true;
|
||||
else
|
||||
m_bStart = false;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
OnSetDataPointer(pElement);
|
||||
}
|
||||
|
||||
bool CEffectElementBaseInstance::isActive()
|
||||
{
|
||||
return m_isActive;
|
||||
}
|
||||
void CEffectElementBaseInstance::SetActive()
|
||||
{
|
||||
m_isActive = true;
|
||||
}
|
||||
void CEffectElementBaseInstance::SetDeactive()
|
||||
{
|
||||
m_isActive = false;
|
||||
}
|
||||
|
||||
void CEffectElementBaseInstance::Initialize()
|
||||
{
|
||||
mc_pmatLocal = NULL;
|
||||
|
||||
m_isActive = true;
|
||||
|
||||
m_fLocalTime = 0.0f;
|
||||
m_dwStartTime = 0;
|
||||
m_fElapsedTime = 0.0f;
|
||||
|
||||
m_bStart = false;
|
||||
m_fRemainingTime = 0.0f;
|
||||
|
||||
OnInitialize();
|
||||
}
|
||||
|
||||
void CEffectElementBaseInstance::Destroy()
|
||||
{
|
||||
OnDestroy();
|
||||
Initialize();
|
||||
}
|
||||
|
||||
CEffectElementBaseInstance::CEffectElementBaseInstance()
|
||||
{
|
||||
}
|
||||
CEffectElementBaseInstance::~CEffectElementBaseInstance()
|
||||
{
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
@ -0,0 +1,47 @@
|
||||
#pragma once
|
||||
|
||||
#include "EffectElementBase.h"
|
||||
|
||||
class CEffectElementBaseInstance
|
||||
{
|
||||
public:
|
||||
CEffectElementBaseInstance();
|
||||
virtual ~CEffectElementBaseInstance();
|
||||
|
||||
void SetDataPointer(CEffectElementBase * pElement);
|
||||
|
||||
void Initialize();
|
||||
void Destroy();
|
||||
|
||||
void SetLocalMatrixPointer(const D3DXMATRIX * c_pMatrix);
|
||||
bool Update(float fElapsedTime);
|
||||
void Render();
|
||||
|
||||
bool isActive();
|
||||
void SetActive();
|
||||
void SetDeactive();
|
||||
|
||||
protected:
|
||||
virtual void OnSetDataPointer(CEffectElementBase * pElement) = 0;
|
||||
|
||||
virtual void OnInitialize() = 0;
|
||||
virtual void OnDestroy() = 0;
|
||||
|
||||
virtual bool OnUpdate(float fElapsedTime) = 0;
|
||||
virtual void OnRender() = 0;
|
||||
|
||||
protected:
|
||||
const D3DXMATRIX * mc_pmatLocal;
|
||||
|
||||
bool m_isActive;
|
||||
|
||||
float m_fLocalTime;
|
||||
DWORD m_dwStartTime;
|
||||
float m_fElapsedTime;
|
||||
float m_fRemainingTime;
|
||||
bool m_bStart;
|
||||
|
||||
private:
|
||||
CEffectElementBase * m_pBase;
|
||||
};
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
290
source-client/Srcs/Client/EffectLib/EffectInstance.cpp
Normal file
290
source-client/Srcs/Client/EffectLib/EffectInstance.cpp
Normal file
@ -0,0 +1,290 @@
|
||||
#include "StdAfx.h"
|
||||
#include "EffectInstance.h"
|
||||
#include "ParticleSystemInstance.h"
|
||||
#include "SimpleLightInstance.h"
|
||||
|
||||
#include "../eterBase/Stl.h"
|
||||
#include "../eterLib/StateManager.h"
|
||||
#include "../MilesLib/SoundManager.h"
|
||||
|
||||
CDynamicPool<CEffectInstance> CEffectInstance::ms_kPool;
|
||||
int CEffectInstance::ms_iRenderingEffectCount = 0;
|
||||
|
||||
bool CEffectInstance::LessRenderOrder(CEffectInstance* pkEftInst)
|
||||
{
|
||||
return (m_pkEftData<pkEftInst->m_pkEftData);
|
||||
}
|
||||
|
||||
void CEffectInstance::ResetRenderingEffectCount()
|
||||
{
|
||||
ms_iRenderingEffectCount = 0;
|
||||
}
|
||||
|
||||
int CEffectInstance::GetRenderingEffectCount()
|
||||
{
|
||||
return ms_iRenderingEffectCount;
|
||||
}
|
||||
|
||||
CEffectInstance* CEffectInstance::New()
|
||||
{
|
||||
CEffectInstance* pkEftInst=ms_kPool.Alloc();
|
||||
return pkEftInst;
|
||||
}
|
||||
|
||||
void CEffectInstance::Delete(CEffectInstance* pkEftInst)
|
||||
{
|
||||
pkEftInst->Clear();
|
||||
ms_kPool.Free(pkEftInst);
|
||||
}
|
||||
|
||||
void CEffectInstance::DestroySystem()
|
||||
{
|
||||
ms_kPool.Destroy();
|
||||
|
||||
CParticleSystemInstance::DestroySystem();
|
||||
CEffectMeshInstance::DestroySystem();
|
||||
CLightInstance::DestroySystem();
|
||||
}
|
||||
|
||||
void CEffectInstance::UpdateSound()
|
||||
{
|
||||
if (m_pSoundInstanceVector)
|
||||
{
|
||||
CSoundManager& rkSndMgr=CSoundManager::Instance();
|
||||
rkSndMgr.UpdateSoundInstance(m_matGlobal._41, m_matGlobal._42, m_matGlobal._43, m_dwFrame, m_pSoundInstanceVector);
|
||||
}
|
||||
++m_dwFrame;
|
||||
}
|
||||
|
||||
struct FEffectUpdator
|
||||
{
|
||||
BOOL isAlive;
|
||||
float fElapsedTime;
|
||||
FEffectUpdator(float fElapsedTime)
|
||||
: isAlive(FALSE), fElapsedTime(fElapsedTime)
|
||||
{
|
||||
}
|
||||
void operator () (CEffectElementBaseInstance * pInstance)
|
||||
{
|
||||
if (pInstance->Update(fElapsedTime))
|
||||
isAlive = TRUE;
|
||||
}
|
||||
};
|
||||
|
||||
void CEffectInstance::OnUpdate()
|
||||
{
|
||||
Transform();
|
||||
|
||||
#ifdef WORLD_EDITOR
|
||||
FEffectUpdator f(CTimer::Instance().GetElapsedSecond());
|
||||
#else
|
||||
FEffectUpdator f(CTimer::Instance().GetCurrentSecond()-m_fLastTime);
|
||||
#endif
|
||||
f = std::for_each(m_ParticleInstanceVector.begin(), m_ParticleInstanceVector.end(),f);
|
||||
f = std::for_each(m_MeshInstanceVector.begin(), m_MeshInstanceVector.end(),f);
|
||||
f = std::for_each(m_LightInstanceVector.begin(), m_LightInstanceVector.end(),f);
|
||||
m_isAlive = f.isAlive;
|
||||
|
||||
m_fLastTime = CTimer::Instance().GetCurrentSecond();
|
||||
}
|
||||
|
||||
void CEffectInstance::OnRender()
|
||||
{
|
||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_NONE);
|
||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_NONE);
|
||||
STATEMANAGER.SaveRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
||||
STATEMANAGER.SaveRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
STATEMANAGER.SaveRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
||||
STATEMANAGER.SaveRenderState(D3DRS_ALPHATESTENABLE, FALSE);
|
||||
STATEMANAGER.SaveRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
STATEMANAGER.SaveRenderState(D3DRS_ZWRITEENABLE, FALSE);
|
||||
/////
|
||||
|
||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
|
||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
|
||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR);
|
||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);
|
||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ|D3DFVF_TEX1);
|
||||
std::for_each(m_ParticleInstanceVector.begin(),m_ParticleInstanceVector.end(),std::void_mem_fun(&CEffectElementBaseInstance::Render));
|
||||
std::for_each(m_MeshInstanceVector.begin(),m_MeshInstanceVector.end(),std::void_mem_fun(&CEffectElementBaseInstance::Render));
|
||||
|
||||
/////
|
||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_MINFILTER);
|
||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_MAGFILTER);
|
||||
STATEMANAGER.RestoreRenderState(D3DRS_ALPHABLENDENABLE);
|
||||
STATEMANAGER.RestoreRenderState(D3DRS_SRCBLEND);
|
||||
STATEMANAGER.RestoreRenderState(D3DRS_DESTBLEND);
|
||||
STATEMANAGER.RestoreRenderState(D3DRS_ALPHATESTENABLE);
|
||||
STATEMANAGER.RestoreRenderState(D3DRS_CULLMODE);
|
||||
STATEMANAGER.RestoreRenderState(D3DRS_ZWRITEENABLE);
|
||||
|
||||
++ms_iRenderingEffectCount;
|
||||
}
|
||||
|
||||
void CEffectInstance::SetGlobalMatrix(const D3DXMATRIX & c_rmatGlobal)
|
||||
{
|
||||
m_matGlobal = c_rmatGlobal;
|
||||
}
|
||||
|
||||
BOOL CEffectInstance::isAlive()
|
||||
{
|
||||
return m_isAlive;
|
||||
}
|
||||
|
||||
void CEffectInstance::SetActive()
|
||||
{
|
||||
std::for_each(
|
||||
m_ParticleInstanceVector.begin(),
|
||||
m_ParticleInstanceVector.end(),
|
||||
std::void_mem_fun(&CEffectElementBaseInstance::SetActive));
|
||||
std::for_each(
|
||||
m_MeshInstanceVector.begin(),
|
||||
m_MeshInstanceVector.end(),
|
||||
std::void_mem_fun(&CEffectElementBaseInstance::SetActive));
|
||||
std::for_each(
|
||||
m_LightInstanceVector.begin(),
|
||||
m_LightInstanceVector.end(),
|
||||
std::void_mem_fun(&CEffectElementBaseInstance::SetActive));
|
||||
}
|
||||
|
||||
void CEffectInstance::SetDeactive()
|
||||
{
|
||||
std::for_each(
|
||||
m_ParticleInstanceVector.begin(),
|
||||
m_ParticleInstanceVector.end(),
|
||||
std::void_mem_fun(&CEffectElementBaseInstance::SetDeactive));
|
||||
std::for_each(
|
||||
m_MeshInstanceVector.begin(),
|
||||
m_MeshInstanceVector.end(),
|
||||
std::void_mem_fun(&CEffectElementBaseInstance::SetDeactive));
|
||||
std::for_each(
|
||||
m_LightInstanceVector.begin(),
|
||||
m_LightInstanceVector.end(),
|
||||
std::void_mem_fun(&CEffectElementBaseInstance::SetDeactive));
|
||||
}
|
||||
|
||||
void CEffectInstance::__SetParticleData(CParticleSystemData * pData)
|
||||
{
|
||||
CParticleSystemInstance * pInstance = CParticleSystemInstance::New();
|
||||
pInstance->SetDataPointer(pData);
|
||||
pInstance->SetLocalMatrixPointer(&m_matGlobal);
|
||||
|
||||
m_ParticleInstanceVector.push_back(pInstance);
|
||||
}
|
||||
void CEffectInstance::__SetMeshData(CEffectMeshScript * pMesh)
|
||||
{
|
||||
CEffectMeshInstance * pMeshInstance = CEffectMeshInstance::New();
|
||||
pMeshInstance->SetDataPointer(pMesh);
|
||||
pMeshInstance->SetLocalMatrixPointer(&m_matGlobal);
|
||||
|
||||
m_MeshInstanceVector.push_back(pMeshInstance);
|
||||
}
|
||||
|
||||
void CEffectInstance::__SetLightData(CLightData* pData)
|
||||
{
|
||||
CLightInstance * pInstance = CLightInstance::New();
|
||||
pInstance->SetDataPointer(pData);
|
||||
pInstance->SetLocalMatrixPointer(&m_matGlobal);
|
||||
|
||||
m_LightInstanceVector.push_back(pInstance);
|
||||
}
|
||||
|
||||
void CEffectInstance::SetEffectDataPointer(CEffectData * pEffectData)
|
||||
{
|
||||
m_isAlive=true;
|
||||
|
||||
m_pkEftData=pEffectData;
|
||||
|
||||
m_fLastTime = CTimer::Instance().GetCurrentSecond();
|
||||
m_fBoundingSphereRadius = pEffectData->GetBoundingSphereRadius();
|
||||
m_v3BoundingSpherePosition = pEffectData->GetBoundingSpherePosition();
|
||||
|
||||
if (m_fBoundingSphereRadius > 0.0f)
|
||||
CGraphicObjectInstance::RegisterBoundingSphere();
|
||||
|
||||
DWORD i;
|
||||
|
||||
for (i = 0; i < pEffectData->GetParticleCount(); ++i)
|
||||
{
|
||||
CParticleSystemData * pParticle = pEffectData->GetParticlePointer(i);
|
||||
|
||||
__SetParticleData(pParticle);
|
||||
}
|
||||
|
||||
for (i = 0; i < pEffectData->GetMeshCount(); ++i)
|
||||
{
|
||||
CEffectMeshScript * pMesh = pEffectData->GetMeshPointer(i);
|
||||
|
||||
__SetMeshData(pMesh);
|
||||
}
|
||||
|
||||
for (i = 0; i < pEffectData->GetLightCount(); ++i)
|
||||
{
|
||||
CLightData * pLight = pEffectData->GetLightPointer(i);
|
||||
|
||||
__SetLightData(pLight);
|
||||
}
|
||||
|
||||
m_pSoundInstanceVector = pEffectData->GetSoundInstanceVector();
|
||||
}
|
||||
|
||||
bool CEffectInstance::GetBoundingSphere(D3DXVECTOR3 & v3Center, float & fRadius)
|
||||
{
|
||||
v3Center.x = m_matGlobal._41 + m_v3BoundingSpherePosition.x;
|
||||
v3Center.y = m_matGlobal._42 + m_v3BoundingSpherePosition.y;
|
||||
v3Center.z = m_matGlobal._43 + m_v3BoundingSpherePosition.z;
|
||||
fRadius = m_fBoundingSphereRadius;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CEffectInstance::Clear()
|
||||
{
|
||||
if (!m_ParticleInstanceVector.empty())
|
||||
{
|
||||
std::for_each(m_ParticleInstanceVector.begin(), m_ParticleInstanceVector.end(), CParticleSystemInstance::Delete);
|
||||
m_ParticleInstanceVector.clear();
|
||||
}
|
||||
|
||||
if (!m_MeshInstanceVector.empty())
|
||||
{
|
||||
std::for_each(m_MeshInstanceVector.begin(), m_MeshInstanceVector.end(), CEffectMeshInstance::Delete);
|
||||
m_MeshInstanceVector.clear();
|
||||
}
|
||||
|
||||
if (!m_LightInstanceVector.empty())
|
||||
{
|
||||
std::for_each(m_LightInstanceVector.begin(), m_LightInstanceVector.end(), CLightInstance::Delete);
|
||||
m_LightInstanceVector.clear();
|
||||
}
|
||||
|
||||
__Initialize();
|
||||
}
|
||||
|
||||
void CEffectInstance::__Initialize()
|
||||
{
|
||||
m_isAlive = FALSE;
|
||||
m_dwFrame = 0;
|
||||
m_pSoundInstanceVector = NULL;
|
||||
m_fBoundingSphereRadius = 0.0f;
|
||||
m_v3BoundingSpherePosition.x = m_v3BoundingSpherePosition.y = m_v3BoundingSpherePosition.z = 0.0f;
|
||||
|
||||
m_pkEftData=NULL;
|
||||
#ifdef __ENABLE_STEALTH_FIX__
|
||||
ReleaseAlwaysHidden();
|
||||
#endif
|
||||
D3DXMatrixIdentity(&m_matGlobal);
|
||||
}
|
||||
|
||||
CEffectInstance::CEffectInstance()
|
||||
{
|
||||
__Initialize();
|
||||
}
|
||||
CEffectInstance::~CEffectInstance()
|
||||
{
|
||||
assert(m_ParticleInstanceVector.empty());
|
||||
assert(m_MeshInstanceVector.empty());
|
||||
assert(m_LightInstanceVector.empty());
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
91
source-client/Srcs/Client/EffectLib/EffectInstance.h
Normal file
91
source-client/Srcs/Client/EffectLib/EffectInstance.h
Normal file
@ -0,0 +1,91 @@
|
||||
#pragma once
|
||||
|
||||
#include "../eterlib/GrpObjectInstance.h"
|
||||
#include "../eterlib/Pool.h"
|
||||
#include "../mileslib/Type.h"
|
||||
|
||||
#include "EffectElementBaseInstance.h"
|
||||
#include "EffectData.h"
|
||||
#include "EffectMeshInstance.h"
|
||||
#include "ParticleSystemInstance.h"
|
||||
#include "SimpleLightInstance.h"
|
||||
|
||||
class CEffectInstance : public CGraphicObjectInstance
|
||||
{
|
||||
public:
|
||||
typedef std::vector<CEffectElementBaseInstance*> TEffectElementInstanceVector;
|
||||
|
||||
enum
|
||||
{
|
||||
ID = EFFECT_OBJECT
|
||||
};
|
||||
int GetType() const
|
||||
{
|
||||
return CEffectInstance::ID;
|
||||
}
|
||||
|
||||
bool GetBoundingSphere(D3DXVECTOR3 & v3Center, float & fRadius);
|
||||
|
||||
static void DestroySystem();
|
||||
|
||||
static CEffectInstance* New();
|
||||
static void Delete(CEffectInstance* pkEftInst);
|
||||
|
||||
static void ResetRenderingEffectCount();
|
||||
static int GetRenderingEffectCount();
|
||||
|
||||
public:
|
||||
CEffectInstance();
|
||||
virtual ~CEffectInstance();
|
||||
|
||||
bool LessRenderOrder(CEffectInstance* pkEftInst);
|
||||
|
||||
void SetEffectDataPointer(CEffectData * pEffectData);
|
||||
|
||||
void Clear();
|
||||
BOOL isAlive();
|
||||
void SetActive();
|
||||
void SetDeactive();
|
||||
void SetGlobalMatrix(const D3DXMATRIX & c_rmatGlobal);
|
||||
void UpdateSound();
|
||||
void OnUpdate();
|
||||
void OnRender();
|
||||
void OnBlendRender() {} // Not used
|
||||
void OnRenderToShadowMap() {} // Not used
|
||||
void OnRenderShadow() {} // Not used
|
||||
void OnRenderPCBlocker() {} // Not used
|
||||
|
||||
protected:
|
||||
void __Initialize();
|
||||
|
||||
void __SetParticleData(CParticleSystemData * pData);
|
||||
void __SetMeshData(CEffectMeshScript * pMesh);
|
||||
void __SetLightData(CLightData * pData);
|
||||
|
||||
virtual void OnUpdateCollisionData(const CStaticCollisionDataVector * pscdVector) {} // Not used
|
||||
virtual void OnUpdateHeighInstance(CAttributeInstance * pAttributeInstance) {}
|
||||
virtual bool OnGetObjectHeight(float fX, float fY, float * pfHeight) { return false; }
|
||||
|
||||
protected:
|
||||
BOOL m_isAlive;
|
||||
DWORD m_dwFrame;
|
||||
D3DXMATRIX m_matGlobal;
|
||||
|
||||
CEffectData * m_pkEftData;
|
||||
|
||||
std::vector<CParticleSystemInstance*> m_ParticleInstanceVector;
|
||||
std::vector<CEffectMeshInstance*> m_MeshInstanceVector;
|
||||
std::vector<CLightInstance*> m_LightInstanceVector;
|
||||
|
||||
NSound::TSoundInstanceVector * m_pSoundInstanceVector;
|
||||
|
||||
float m_fBoundingSphereRadius;
|
||||
D3DXVECTOR3 m_v3BoundingSpherePosition;
|
||||
|
||||
float m_fLastTime;
|
||||
|
||||
public:
|
||||
static CDynamicPool<CEffectInstance> ms_kPool;
|
||||
static int ms_iRenderingEffectCount;
|
||||
};
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
447
source-client/Srcs/Client/EffectLib/EffectLib.vcxproj
Normal file
447
source-client/Srcs/Client/EffectLib/EffectLib.vcxproj
Normal file
@ -0,0 +1,447 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Distribute|Win32">
|
||||
<Configuration>Distribute</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectName>EffectLib</ProjectName>
|
||||
<ProjectGuid>{790B152D-6582-467F-B767-8603C5A9E613}</ProjectGuid>
|
||||
<RootNamespace>EffectLib</RootNamespace>
|
||||
<SccProjectName>
|
||||
</SccProjectName>
|
||||
<SccAuxPath>
|
||||
</SccAuxPath>
|
||||
<SccLocalPath>
|
||||
</SccLocalPath>
|
||||
<SccProvider>
|
||||
</SccProvider>
|
||||
<Keyword>MFCProj</Keyword>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">$(ProjectDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">$(Configuration)\</IntDir>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<AdditionalIncludeDirectories>../../Extern/include</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS;_SILENCE_ALL_CXX20_DEPRECATION_WARNINGS;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderOutputFile>$(IntDir)$(ProjectName).pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
|
||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
||||
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
|
||||
<BrowseInformation>
|
||||
</BrowseInformation>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<SDLCheck>
|
||||
</SDLCheck>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>../../Extern/include</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS;_SILENCE_ALL_CXX20_DEPRECATION_WARNINGS;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderOutputFile>$(IntDir)$(ProjectName).pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
|
||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
||||
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
|
||||
<BrowseInformation>
|
||||
</BrowseInformation>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<SDLCheck>
|
||||
</SDLCheck>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<AdditionalIncludeDirectories>.;../../extern/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderOutputFile>$(IntDir)$(ProjectName).pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerOutput>All</AssemblerOutput>
|
||||
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
|
||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
||||
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
|
||||
<BrowseInformation>
|
||||
</BrowseInformation>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="EffectData.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EffectElementBase.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EffectElementBaseInstance.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EffectInstance.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EffectManager.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EffectMesh.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EffectMeshInstance.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EffectUpdateDecorator.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EmitterProperty.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="FrameController.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ParticleInstance.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ParticleProperty.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ParticleSystemData.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ParticleSystemInstance.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SimpleLightData.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SimpleLightInstance.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="StdAfx.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">Create</PrecompiledHeader>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Type.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="EffectData.h" />
|
||||
<ClInclude Include="EffectElementBase.h" />
|
||||
<ClInclude Include="EffectElementBaseInstance.h" />
|
||||
<ClInclude Include="EffectInstance.h" />
|
||||
<ClInclude Include="EffectManager.h" />
|
||||
<ClInclude Include="EffectMesh.h" />
|
||||
<ClInclude Include="EffectMeshInstance.h" />
|
||||
<ClInclude Include="EffectUpdateDecorator.h" />
|
||||
<ClInclude Include="EmitterProperty.h" />
|
||||
<ClInclude Include="FrameController.h" />
|
||||
<ClInclude Include="ParticleInstance.h" />
|
||||
<ClInclude Include="ParticleProperty.h" />
|
||||
<ClInclude Include="ParticleSystemData.h" />
|
||||
<ClInclude Include="ParticleSystemInstance.h" />
|
||||
<ClInclude Include="SimpleLightData.h" />
|
||||
<ClInclude Include="SimpleLightInstance.h" />
|
||||
<ClInclude Include="StdAfx.h" />
|
||||
<ClInclude Include="Type.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
</Project>
|
||||
465
source-client/Srcs/Client/EffectLib/EffectManager.cpp
Normal file
465
source-client/Srcs/Client/EffectLib/EffectManager.cpp
Normal file
@ -0,0 +1,465 @@
|
||||
#include "StdAfx.h"
|
||||
#include "../eterBase/Random.h"
|
||||
#include "../eterlib/StateManager.h"
|
||||
#include "EffectManager.h"
|
||||
|
||||
void CEffectManager::GetInfo(std::string* pstInfo)
|
||||
{
|
||||
char szInfo[256];
|
||||
|
||||
sprintf(szInfo, "Effect: Inst - ED %d, EI %d Pool - PSI %d, MI %d, LI %d, PI %d, EI %d, ED %d, PSD %d, EM %d, LD %d",
|
||||
m_kEftDataMap.size(),
|
||||
m_kEftInstMap.size(),
|
||||
CParticleSystemInstance::ms_kPool.GetCapacity(),
|
||||
CEffectMeshInstance::ms_kPool.GetCapacity(),
|
||||
CLightInstance::ms_kPool.GetCapacity(),
|
||||
CParticleInstance::ms_kPool.GetCapacity(),
|
||||
//CRayParticleInstance::ms_kPool.GetCapacity(),
|
||||
CEffectInstance::ms_kPool.GetCapacity(),
|
||||
CEffectData::ms_kPool.GetCapacity(),
|
||||
CParticleSystemData::ms_kPool.GetCapacity(),
|
||||
CEffectMeshScript::ms_kPool.GetCapacity(),
|
||||
CLightData::ms_kPool.GetCapacity()
|
||||
);
|
||||
pstInfo->append(szInfo);
|
||||
}
|
||||
|
||||
void CEffectManager::UpdateSound()
|
||||
{
|
||||
for (TEffectInstanceMap::iterator itor = m_kEftInstMap.begin(); itor != m_kEftInstMap.end(); ++itor)
|
||||
{
|
||||
CEffectInstance * pEffectInstance = itor->second;
|
||||
|
||||
pEffectInstance->UpdateSound();
|
||||
}
|
||||
}
|
||||
|
||||
bool CEffectManager::IsAliveEffect(DWORD dwInstanceIndex)
|
||||
{
|
||||
TEffectInstanceMap::iterator f = m_kEftInstMap.find(dwInstanceIndex);
|
||||
if (m_kEftInstMap.end()==f)
|
||||
return false;
|
||||
|
||||
return f->second->isAlive() ? true : false;
|
||||
}
|
||||
|
||||
void CEffectManager::Update()
|
||||
{
|
||||
for (TEffectInstanceMap::iterator itor = m_kEftInstMap.begin(); itor != m_kEftInstMap.end();)
|
||||
{
|
||||
CEffectInstance * pEffectInstance = itor->second;
|
||||
|
||||
pEffectInstance->Update(/*fElapsedTime*/);
|
||||
|
||||
if (!pEffectInstance->isAlive())
|
||||
{
|
||||
itor = m_kEftInstMap.erase(itor);
|
||||
|
||||
CEffectInstance::Delete(pEffectInstance);
|
||||
}
|
||||
else
|
||||
{
|
||||
++itor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct CEffectManager_LessEffectInstancePtrRenderOrder
|
||||
{
|
||||
bool operator() (CEffectInstance* pkLeft, CEffectInstance* pkRight)
|
||||
{
|
||||
return pkLeft->LessRenderOrder(pkRight);
|
||||
}
|
||||
};
|
||||
|
||||
struct CEffectManager_FEffectInstanceRender
|
||||
{
|
||||
inline void operator () (CEffectInstance * pkEftInst)
|
||||
{
|
||||
pkEftInst->Render();
|
||||
}
|
||||
};
|
||||
|
||||
void CEffectManager::Render()
|
||||
{
|
||||
STATEMANAGER.SetTexture(0, NULL);
|
||||
STATEMANAGER.SetTexture(1, NULL);
|
||||
|
||||
if (m_isDisableSortRendering)
|
||||
{
|
||||
for (TEffectInstanceMap::iterator itor = m_kEftInstMap.begin(); itor != m_kEftInstMap.end();)
|
||||
{
|
||||
CEffectInstance * pEffectInstance = itor->second;
|
||||
pEffectInstance->Render();
|
||||
++itor;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
static std::vector<CEffectInstance*> s_kVct_pkEftInstSort;
|
||||
s_kVct_pkEftInstSort.clear();
|
||||
|
||||
TEffectInstanceMap& rkMap_pkEftInstSrc=m_kEftInstMap;
|
||||
TEffectInstanceMap::iterator i;
|
||||
for (i=rkMap_pkEftInstSrc.begin(); i!=rkMap_pkEftInstSrc.end(); ++i)
|
||||
s_kVct_pkEftInstSort.emplace_back(i->second);
|
||||
|
||||
std::sort(s_kVct_pkEftInstSort.begin(), s_kVct_pkEftInstSort.end(), CEffectManager_LessEffectInstancePtrRenderOrder());
|
||||
std::for_each(s_kVct_pkEftInstSort.begin(), s_kVct_pkEftInstSort.end(), CEffectManager_FEffectInstanceRender());
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CEffectManager::RegisterEffect(const char * c_szFileName,bool isExistDelete,bool isNeedCache)
|
||||
{
|
||||
std::string strFileName;
|
||||
StringPath(c_szFileName, strFileName);
|
||||
DWORD dwCRC = GetCaseCRC32(strFileName.c_str(), strFileName.length());
|
||||
|
||||
TEffectDataMap::iterator itor = m_kEftDataMap.find(dwCRC);
|
||||
if (m_kEftDataMap.end() != itor)
|
||||
{
|
||||
if (isExistDelete)
|
||||
{
|
||||
CEffectData* pkEftData=itor->second;
|
||||
CEffectData::Delete(pkEftData);
|
||||
m_kEftDataMap.erase(itor);
|
||||
}
|
||||
else
|
||||
{
|
||||
//TraceError("CEffectManager::RegisterEffect - m_kEftDataMap.find [%s] Already Exist", c_szFileName);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
CEffectData * pkEftData = CEffectData::New();
|
||||
|
||||
if (!pkEftData->LoadScript(c_szFileName))
|
||||
{
|
||||
TraceError("CEffectManager::RegisterEffect - LoadScript(%s) Error", c_szFileName);
|
||||
CEffectData::Delete(pkEftData);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_kEftDataMap.emplace(dwCRC, pkEftData);
|
||||
|
||||
if (isNeedCache)
|
||||
{
|
||||
if (m_kEftCacheMap.find(dwCRC)==m_kEftCacheMap.end())
|
||||
{
|
||||
CEffectInstance* pkNewEftInst=CEffectInstance::New();
|
||||
pkNewEftInst->SetEffectDataPointer(pkEftData);
|
||||
m_kEftCacheMap.emplace(dwCRC, pkNewEftInst);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
BOOL CEffectManager::RegisterEffect2(const char * c_szFileName, DWORD* pdwRetCRC, bool isNeedCache)
|
||||
{
|
||||
std::string strFileName;
|
||||
StringPath(c_szFileName, strFileName);
|
||||
DWORD dwCRC = GetCaseCRC32(strFileName.c_str(), strFileName.length());
|
||||
*pdwRetCRC=dwCRC;
|
||||
|
||||
return RegisterEffect(c_szFileName,false,isNeedCache);
|
||||
}
|
||||
|
||||
int CEffectManager::CreateEffect(const char * c_szFileName, const D3DXVECTOR3 & c_rv3Position, const D3DXVECTOR3 & c_rv3Rotation)
|
||||
{
|
||||
std::string strFileName;
|
||||
StringPath(c_szFileName, strFileName); //@fixme030
|
||||
DWORD dwID = GetCaseCRC32(strFileName.c_str(), strFileName.size());
|
||||
return CreateEffect(dwID, c_rv3Position, c_rv3Rotation);
|
||||
}
|
||||
|
||||
int CEffectManager::CreateEffect(DWORD dwID, const D3DXVECTOR3 & c_rv3Position, const D3DXVECTOR3 & c_rv3Rotation)
|
||||
{
|
||||
int iInstanceIndex = GetEmptyIndex();
|
||||
|
||||
CreateEffectInstance(iInstanceIndex, dwID);
|
||||
SelectEffectInstance(iInstanceIndex);
|
||||
D3DXMATRIX mat;
|
||||
D3DXMatrixRotationYawPitchRoll(&mat,D3DXToRadian(c_rv3Rotation.x),D3DXToRadian(c_rv3Rotation.y),D3DXToRadian(c_rv3Rotation.z));
|
||||
mat._41 = c_rv3Position.x;
|
||||
mat._42 = c_rv3Position.y;
|
||||
mat._43 = c_rv3Position.z;
|
||||
SetEffectInstanceGlobalMatrix(mat);
|
||||
|
||||
return iInstanceIndex;
|
||||
}
|
||||
|
||||
void CEffectManager::CreateEffectInstance(DWORD dwInstanceIndex, DWORD dwID)
|
||||
{
|
||||
if (!dwID)
|
||||
return;
|
||||
|
||||
CEffectData * pEffect;
|
||||
if (!GetEffectData(dwID, &pEffect))
|
||||
{
|
||||
Tracef("CEffectManager::CreateEffectInstance - NO DATA :%d\n", dwID);
|
||||
return;
|
||||
}
|
||||
|
||||
CEffectInstance * pEffectInstance = CEffectInstance::New();
|
||||
pEffectInstance->SetEffectDataPointer(pEffect);
|
||||
|
||||
m_kEftInstMap.emplace(dwInstanceIndex, pEffectInstance);
|
||||
}
|
||||
|
||||
bool CEffectManager::DestroyEffectInstance(DWORD dwInstanceIndex)
|
||||
{
|
||||
TEffectInstanceMap::iterator itor = m_kEftInstMap.find(dwInstanceIndex);
|
||||
|
||||
if (itor == m_kEftInstMap.end())
|
||||
return false;
|
||||
|
||||
CEffectInstance * pEffectInstance = itor->second;
|
||||
|
||||
m_kEftInstMap.erase(itor);
|
||||
|
||||
CEffectInstance::Delete(pEffectInstance);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CEffectManager::DeactiveEffectInstance(DWORD dwInstanceIndex)
|
||||
{
|
||||
TEffectInstanceMap::iterator itor = m_kEftInstMap.find(dwInstanceIndex);
|
||||
|
||||
if (itor == m_kEftInstMap.end())
|
||||
return;
|
||||
|
||||
CEffectInstance * pEffectInstance = itor->second;
|
||||
pEffectInstance->SetDeactive();
|
||||
}
|
||||
|
||||
void CEffectManager::CreateUnsafeEffectInstance(DWORD dwEffectDataID, CEffectInstance ** ppEffectInstance)
|
||||
{
|
||||
CEffectData * pEffect{nullptr}; //@fixme030
|
||||
if (!GetEffectData(dwEffectDataID, &pEffect))
|
||||
{
|
||||
Tracef("CEffectManager::CreateUnsafeEffectInstance - NO DATA :%d\n", dwEffectDataID);
|
||||
return;
|
||||
}
|
||||
|
||||
CEffectInstance* pkEftInstNew=CEffectInstance::New();
|
||||
pkEftInstNew->SetEffectDataPointer(pEffect);
|
||||
|
||||
*ppEffectInstance = pkEftInstNew;
|
||||
}
|
||||
|
||||
bool CEffectManager::DestroyUnsafeEffectInstance(CEffectInstance * pEffectInstance)
|
||||
{
|
||||
if (!pEffectInstance)
|
||||
return false;
|
||||
|
||||
CEffectInstance::Delete(pEffectInstance);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL CEffectManager::SelectEffectInstance(DWORD dwInstanceIndex)
|
||||
{
|
||||
TEffectInstanceMap::iterator itor = m_kEftInstMap.find(dwInstanceIndex);
|
||||
|
||||
m_pSelectedEffectInstance = NULL;
|
||||
|
||||
if (m_kEftInstMap.end() == itor)
|
||||
return FALSE;
|
||||
|
||||
m_pSelectedEffectInstance = itor->second;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CEffectManager::SetEffectTextures(DWORD dwID,std::vector<string> textures)
|
||||
{
|
||||
CEffectData * pEffectData;
|
||||
if (!GetEffectData(dwID, &pEffectData))
|
||||
{
|
||||
Tracef("CEffectManager::SetEffectTextures - NO DATA :%d\n", dwID);
|
||||
return;
|
||||
}
|
||||
|
||||
for(DWORD i = 0; i < textures.size(); i++)
|
||||
{
|
||||
CParticleSystemData * pParticle = pEffectData->GetParticlePointer(i);
|
||||
pParticle->ChangeTexture(textures.at(i).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void CEffectManager::SetEffectInstancePosition(const D3DXVECTOR3 & c_rv3Position)
|
||||
{
|
||||
if (!m_pSelectedEffectInstance)
|
||||
{
|
||||
// assert(!"Instance to use is not yet set!");
|
||||
return;
|
||||
}
|
||||
|
||||
m_pSelectedEffectInstance->SetPosition(c_rv3Position);
|
||||
}
|
||||
|
||||
void CEffectManager::SetEffectInstanceRotation(const D3DXVECTOR3 & c_rv3Rotation)
|
||||
{
|
||||
if (!m_pSelectedEffectInstance)
|
||||
{
|
||||
// assert(!"Instance to use is not yet set!");
|
||||
return;
|
||||
}
|
||||
|
||||
m_pSelectedEffectInstance->SetRotation(c_rv3Rotation.x,c_rv3Rotation.y,c_rv3Rotation.z);
|
||||
}
|
||||
|
||||
void CEffectManager::SetEffectInstanceGlobalMatrix(const D3DXMATRIX & c_rmatGlobal)
|
||||
{
|
||||
if (!m_pSelectedEffectInstance)
|
||||
return;
|
||||
|
||||
m_pSelectedEffectInstance->SetGlobalMatrix(c_rmatGlobal);
|
||||
}
|
||||
|
||||
void CEffectManager::ShowEffect()
|
||||
{
|
||||
if (!m_pSelectedEffectInstance)
|
||||
return;
|
||||
|
||||
m_pSelectedEffectInstance->Show();
|
||||
}
|
||||
|
||||
void CEffectManager::HideEffect()
|
||||
{
|
||||
if (!m_pSelectedEffectInstance)
|
||||
return;
|
||||
|
||||
m_pSelectedEffectInstance->Hide();
|
||||
}
|
||||
|
||||
#ifdef __ENABLE_STEALTH_FIX__
|
||||
void CEffectManager::ApplyAlwaysHidden()
|
||||
{
|
||||
if (!m_pSelectedEffectInstance)
|
||||
return;
|
||||
m_pSelectedEffectInstance->ApplyAlwaysHidden();
|
||||
}
|
||||
|
||||
void CEffectManager::ReleaseAlwaysHidden()
|
||||
{
|
||||
if (!m_pSelectedEffectInstance)
|
||||
return;
|
||||
m_pSelectedEffectInstance->ReleaseAlwaysHidden();
|
||||
}
|
||||
#endif
|
||||
|
||||
bool CEffectManager::GetEffectData(DWORD dwID, CEffectData ** ppEffect)
|
||||
{
|
||||
TEffectDataMap::iterator itor = m_kEftDataMap.find(dwID);
|
||||
|
||||
if (itor == m_kEftDataMap.end())
|
||||
return false;
|
||||
|
||||
*ppEffect = itor->second;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CEffectManager::GetEffectData(DWORD dwID, const CEffectData ** c_ppEffect)
|
||||
{
|
||||
TEffectDataMap::iterator itor = m_kEftDataMap.find(dwID);
|
||||
|
||||
if (itor == m_kEftDataMap.end())
|
||||
return false;
|
||||
|
||||
*c_ppEffect = itor->second;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DWORD CEffectManager::GetRandomEffect()
|
||||
{
|
||||
int iIndex = random() % m_kEftDataMap.size();
|
||||
|
||||
TEffectDataMap::iterator itor = m_kEftDataMap.begin();
|
||||
for (int i = 0; i < iIndex; ++i, ++itor);
|
||||
|
||||
return itor->first;
|
||||
}
|
||||
|
||||
int CEffectManager::GetEmptyIndex()
|
||||
{
|
||||
static int iMaxIndex=1;
|
||||
|
||||
if (iMaxIndex>2100000000)
|
||||
iMaxIndex = 1;
|
||||
|
||||
int iNextIndex = iMaxIndex++;
|
||||
while(m_kEftInstMap.find(iNextIndex) != m_kEftInstMap.end())
|
||||
iNextIndex++;
|
||||
|
||||
return iNextIndex;
|
||||
}
|
||||
|
||||
void CEffectManager::DeleteAllInstances()
|
||||
{
|
||||
__DestroyEffectInstanceMap();
|
||||
}
|
||||
|
||||
void CEffectManager::__DestroyEffectInstanceMap()
|
||||
{
|
||||
for (TEffectInstanceMap::iterator i = m_kEftInstMap.begin(); i != m_kEftInstMap.end(); ++i)
|
||||
{
|
||||
CEffectInstance * pkEftInst = i->second;
|
||||
CEffectInstance::Delete(pkEftInst);
|
||||
}
|
||||
|
||||
m_kEftInstMap.clear();
|
||||
}
|
||||
|
||||
void CEffectManager::__DestroyEffectCacheMap()
|
||||
{
|
||||
for (TEffectInstanceMap::iterator i = m_kEftCacheMap.begin(); i != m_kEftCacheMap.end(); ++i)
|
||||
{
|
||||
CEffectInstance * pkEftInst = i->second;
|
||||
CEffectInstance::Delete(pkEftInst);
|
||||
}
|
||||
|
||||
m_kEftCacheMap.clear();
|
||||
}
|
||||
|
||||
void CEffectManager::__DestroyEffectDataMap()
|
||||
{
|
||||
for (TEffectDataMap::iterator i = m_kEftDataMap.begin(); i != m_kEftDataMap.end(); ++i)
|
||||
{
|
||||
CEffectData * pData = i->second;
|
||||
CEffectData::Delete(pData);
|
||||
}
|
||||
|
||||
m_kEftDataMap.clear();
|
||||
}
|
||||
|
||||
void CEffectManager::Destroy()
|
||||
{
|
||||
__DestroyEffectInstanceMap();
|
||||
__DestroyEffectCacheMap();
|
||||
__DestroyEffectDataMap();
|
||||
|
||||
__Initialize();
|
||||
}
|
||||
|
||||
void CEffectManager::__Initialize()
|
||||
{
|
||||
m_pSelectedEffectInstance = NULL;
|
||||
m_isDisableSortRendering = false;
|
||||
}
|
||||
|
||||
CEffectManager::CEffectManager()
|
||||
{
|
||||
__Initialize();
|
||||
}
|
||||
|
||||
CEffectManager::~CEffectManager()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
// just for map effect
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
90
source-client/Srcs/Client/EffectLib/EffectManager.h
Normal file
90
source-client/Srcs/Client/EffectLib/EffectManager.h
Normal file
@ -0,0 +1,90 @@
|
||||
#pragma once
|
||||
|
||||
#include "EffectInstance.h"
|
||||
|
||||
class CEffectManager : public CScreen, public CSingleton<CEffectManager>
|
||||
{
|
||||
public:
|
||||
enum EEffectType
|
||||
{
|
||||
EFFECT_TYPE_NONE = 0,
|
||||
EFFECT_TYPE_PARTICLE = 1,
|
||||
EFFECT_TYPE_ANIMATION_TEXTURE = 2,
|
||||
EFFECT_TYPE_MESH = 3,
|
||||
EFFECT_TYPE_SIMPLE_LIGHT = 4,
|
||||
|
||||
EFFECT_TYPE_MAX_NUM = 4,
|
||||
};
|
||||
|
||||
typedef std::map<DWORD, CEffectData*> TEffectDataMap;
|
||||
typedef std::map<DWORD, CEffectInstance*> TEffectInstanceMap;
|
||||
|
||||
public:
|
||||
CEffectManager();
|
||||
virtual ~CEffectManager();
|
||||
|
||||
void Destroy();
|
||||
|
||||
void UpdateSound();
|
||||
void Update();
|
||||
void Render();
|
||||
|
||||
void GetInfo(std::string* pstInfo);
|
||||
|
||||
bool IsAliveEffect(DWORD dwInstanceIndex);
|
||||
|
||||
// Register
|
||||
BOOL RegisterEffect(const char * c_szFileName,bool isExistDelete=false,bool isNeedCache=false);
|
||||
BOOL RegisterEffect2(const char * c_szFileName, DWORD* pdwRetCRC, bool isNeedCache=false);
|
||||
|
||||
void DeleteAllInstances();
|
||||
|
||||
// Usage
|
||||
int CreateEffect(DWORD dwID, const D3DXVECTOR3 & c_rv3Position, const D3DXVECTOR3 & c_rv3Rotation);
|
||||
int CreateEffect(const char * c_szFileName, const D3DXVECTOR3 & c_rv3Position, const D3DXVECTOR3 & c_rv3Rotation);
|
||||
|
||||
void CreateEffectInstance(DWORD dwInstanceIndex, DWORD dwID);
|
||||
BOOL SelectEffectInstance(DWORD dwInstanceIndex);
|
||||
bool DestroyEffectInstance(DWORD dwInstanceIndex);
|
||||
void DeactiveEffectInstance(DWORD dwInstanceIndex);
|
||||
|
||||
void SetEffectTextures(DWORD dwID,std::vector<string> textures);
|
||||
void SetEffectInstancePosition(const D3DXVECTOR3 & c_rv3Position);
|
||||
void SetEffectInstanceRotation(const D3DXVECTOR3 & c_rv3Rotation);
|
||||
void SetEffectInstanceGlobalMatrix(const D3DXMATRIX & c_rmatGlobal);
|
||||
|
||||
void ShowEffect();
|
||||
void HideEffect();
|
||||
|
||||
#ifdef __ENABLE_STEALTH_FIX__
|
||||
void ApplyAlwaysHidden();
|
||||
void ReleaseAlwaysHidden();
|
||||
#endif
|
||||
|
||||
// Temporary function
|
||||
DWORD GetRandomEffect();
|
||||
int GetEmptyIndex();
|
||||
bool GetEffectData(DWORD dwID, CEffectData ** ppEffect);
|
||||
bool GetEffectData(DWORD dwID, const CEffectData ** c_ppEffect);
|
||||
|
||||
void CreateUnsafeEffectInstance(DWORD dwEffectDataID, CEffectInstance ** ppEffectInstance);
|
||||
bool DestroyUnsafeEffectInstance(CEffectInstance * pEffectInstance);
|
||||
|
||||
int GetRenderingEffectCount();
|
||||
|
||||
protected:
|
||||
void __Initialize();
|
||||
|
||||
void __DestroyEffectInstanceMap();
|
||||
void __DestroyEffectCacheMap();
|
||||
void __DestroyEffectDataMap();
|
||||
|
||||
protected:
|
||||
bool m_isDisableSortRendering;
|
||||
TEffectDataMap m_kEftDataMap;
|
||||
TEffectInstanceMap m_kEftInstMap;
|
||||
TEffectInstanceMap m_kEftCacheMap;
|
||||
|
||||
CEffectInstance * m_pSelectedEffectInstance;
|
||||
};
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
700
source-client/Srcs/Client/EffectLib/EffectMesh.cpp
Normal file
700
source-client/Srcs/Client/EffectLib/EffectMesh.cpp
Normal file
@ -0,0 +1,700 @@
|
||||
#include "StdAfx.h"
|
||||
#include "../eterlib/StateManager.h"
|
||||
#include "../eterlib/ResourceManager.h"
|
||||
#include "../eterpack/EterPackManager.h"
|
||||
#include "EffectMesh.h"
|
||||
|
||||
CDynamicPool<CEffectMesh::SEffectMeshData> CEffectMesh::SEffectMeshData::ms_kPool;
|
||||
|
||||
CEffectMesh::SEffectMeshData* CEffectMesh::SEffectMeshData::New()
|
||||
{
|
||||
return ms_kPool.Alloc();
|
||||
}
|
||||
|
||||
void CEffectMesh::SEffectMeshData::Delete(SEffectMeshData* pkData)
|
||||
{
|
||||
pkData->EffectFrameDataVector.clear();
|
||||
pkData->pImageVector.clear();
|
||||
|
||||
ms_kPool.Free(pkData);
|
||||
}
|
||||
|
||||
void CEffectMesh::SEffectMeshData::DestroySystem()
|
||||
{
|
||||
ms_kPool.Destroy();
|
||||
}
|
||||
|
||||
DWORD CEffectMesh::GetFrameCount()
|
||||
{
|
||||
return m_iFrameCount;
|
||||
}
|
||||
|
||||
DWORD CEffectMesh::GetMeshCount()
|
||||
{
|
||||
return m_pEffectMeshDataVector.size();
|
||||
}
|
||||
|
||||
CEffectMesh::TEffectMeshData * CEffectMesh::GetMeshDataPointer(DWORD dwMeshIndex)
|
||||
{
|
||||
assert(dwMeshIndex < m_pEffectMeshDataVector.size());
|
||||
return m_pEffectMeshDataVector[dwMeshIndex];
|
||||
}
|
||||
|
||||
std::vector<CGraphicImage*>* CEffectMesh::GetTextureVectorPointer(DWORD dwMeshIndex)
|
||||
{
|
||||
if (dwMeshIndex>=m_pEffectMeshDataVector.size())
|
||||
return NULL;
|
||||
|
||||
return &m_pEffectMeshDataVector[dwMeshIndex]->pImageVector;
|
||||
}
|
||||
|
||||
std::vector<CGraphicImage*> & CEffectMesh::GetTextureVectorReference(DWORD dwMeshIndex)
|
||||
{
|
||||
return m_pEffectMeshDataVector[dwMeshIndex]->pImageVector;
|
||||
}
|
||||
|
||||
CEffectMesh::TType CEffectMesh::Type()
|
||||
{
|
||||
static TType s_type = StringToType("CEffectMesh");
|
||||
return s_type;
|
||||
}
|
||||
|
||||
bool CEffectMesh::OnIsType(TType type)
|
||||
{
|
||||
if (CEffectMesh::Type() == type)
|
||||
return true;
|
||||
|
||||
return CResource::OnIsType(type);
|
||||
}
|
||||
|
||||
bool CEffectMesh::OnLoad(int iSize, const void * c_pvBuf)
|
||||
{
|
||||
if (!c_pvBuf)
|
||||
return false;
|
||||
|
||||
const BYTE * c_pbBuf = static_cast<const BYTE *> (c_pvBuf);
|
||||
|
||||
char szHeader[10+1];
|
||||
memcpy(szHeader, c_pbBuf, 10+1);
|
||||
c_pbBuf += 10+1;
|
||||
|
||||
if (0 == strcmp("EffectData", szHeader))
|
||||
{
|
||||
if (!__LoadData_Ver001(iSize, c_pbBuf))
|
||||
return false;
|
||||
}
|
||||
else if (0 == strcmp("MDEData002", szHeader))
|
||||
{
|
||||
if (!__LoadData_Ver002(iSize, c_pbBuf))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_isData = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL CEffectMesh::__LoadData_Ver002(int iSize, const BYTE * c_pbBuf)
|
||||
{
|
||||
std::vector<D3DXVECTOR3> v3VertexVector;
|
||||
std::vector<int> iIndexVector;
|
||||
std::vector<D3DXVECTOR2> v3TextureVertexVector;
|
||||
std::vector<int> iTextureIndexVector;
|
||||
|
||||
m_iGeomCount = *(int *)c_pbBuf;
|
||||
c_pbBuf += 4;
|
||||
m_iFrameCount = *(int *)c_pbBuf;
|
||||
c_pbBuf += 4;
|
||||
|
||||
m_pEffectMeshDataVector.clear();
|
||||
m_pEffectMeshDataVector.resize(m_iGeomCount);
|
||||
|
||||
for (short n = 0; n < m_iGeomCount; ++n)
|
||||
{
|
||||
SEffectMeshData * pMeshData = SEffectMeshData::New();
|
||||
|
||||
memcpy(pMeshData->szObjectName, c_pbBuf, 32);
|
||||
c_pbBuf += 32;
|
||||
memcpy(pMeshData->szDiffuseMapFileName, c_pbBuf, 128);
|
||||
c_pbBuf += 128;
|
||||
|
||||
pMeshData->EffectFrameDataVector.clear();
|
||||
pMeshData->EffectFrameDataVector.resize(m_iFrameCount);
|
||||
|
||||
for(int i = 0; i < m_iFrameCount; ++i)
|
||||
{
|
||||
TEffectFrameData & rFrameData = pMeshData->EffectFrameDataVector[i];
|
||||
|
||||
memcpy(&rFrameData.byChangedFrame, c_pbBuf, sizeof(BYTE));
|
||||
c_pbBuf += sizeof(BYTE);
|
||||
|
||||
memcpy(&rFrameData.fVisibility, c_pbBuf, sizeof(float));
|
||||
c_pbBuf += sizeof(float);
|
||||
|
||||
memcpy(&rFrameData.dwVertexCount, c_pbBuf, sizeof(DWORD));
|
||||
c_pbBuf += sizeof(DWORD);
|
||||
|
||||
memcpy(&rFrameData.dwIndexCount, c_pbBuf, sizeof(DWORD));
|
||||
c_pbBuf += sizeof(DWORD);
|
||||
|
||||
memcpy(&rFrameData.dwTextureVertexCount, c_pbBuf, sizeof(DWORD));
|
||||
c_pbBuf += sizeof(DWORD);
|
||||
|
||||
v3VertexVector.clear();
|
||||
v3VertexVector.resize(rFrameData.dwVertexCount);
|
||||
iIndexVector.clear();
|
||||
iIndexVector.resize(rFrameData.dwIndexCount);
|
||||
v3TextureVertexVector.clear();
|
||||
v3TextureVertexVector.resize(rFrameData.dwTextureVertexCount);
|
||||
iTextureIndexVector.clear();
|
||||
iTextureIndexVector.resize(rFrameData.dwIndexCount);
|
||||
|
||||
memcpy(&v3VertexVector[0], c_pbBuf, rFrameData.dwVertexCount*sizeof(D3DXVECTOR3));
|
||||
c_pbBuf += rFrameData.dwVertexCount*sizeof(D3DXVECTOR3);
|
||||
if (rFrameData.dwIndexCount) // @fixme027
|
||||
memcpy(&iIndexVector[0], c_pbBuf, rFrameData.dwIndexCount*sizeof(int));
|
||||
c_pbBuf += rFrameData.dwIndexCount*sizeof(int);
|
||||
memcpy(&v3TextureVertexVector[0], c_pbBuf, rFrameData.dwTextureVertexCount*sizeof(D3DXVECTOR2));
|
||||
c_pbBuf += rFrameData.dwTextureVertexCount*sizeof(D3DXVECTOR2);
|
||||
if (rFrameData.dwIndexCount) // @fixme027
|
||||
memcpy(&iTextureIndexVector[0], c_pbBuf, rFrameData.dwIndexCount*sizeof(int));
|
||||
c_pbBuf += rFrameData.dwIndexCount*sizeof(int);
|
||||
|
||||
///////////////////////////////
|
||||
|
||||
rFrameData.PDTVertexVector.clear();
|
||||
rFrameData.PDTVertexVector.resize(rFrameData.dwIndexCount);
|
||||
for (DWORD j = 0; j < rFrameData.dwIndexCount; ++j)
|
||||
{
|
||||
TPTVertex & rVertex = rFrameData.PDTVertexVector[j];
|
||||
|
||||
DWORD dwIndex = iIndexVector[j];
|
||||
DWORD dwTextureIndex = iTextureIndexVector[j];
|
||||
|
||||
assert(dwIndex < v3VertexVector.size());
|
||||
assert(dwTextureIndex < v3TextureVertexVector.size());
|
||||
|
||||
rVertex.position = v3VertexVector[dwIndex];
|
||||
rVertex.texCoord = v3TextureVertexVector[dwTextureIndex];
|
||||
rVertex.texCoord.y *= -1;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
|
||||
pMeshData->pImageVector.clear();
|
||||
|
||||
std::string strExtension;
|
||||
GetFileExtension(pMeshData->szDiffuseMapFileName, strlen(pMeshData->szDiffuseMapFileName), &strExtension);
|
||||
stl_lowers(strExtension);
|
||||
|
||||
if (0 == strExtension.compare("ifl"))
|
||||
{
|
||||
LPCVOID pMotionData;
|
||||
CMappedFile File;
|
||||
|
||||
if (CEterPackManager::Instance().Get(File, pMeshData->szDiffuseMapFileName, &pMotionData))
|
||||
{
|
||||
CMemoryTextFileLoader textFileLoader;
|
||||
std::vector<std::string> stTokenVector;
|
||||
|
||||
textFileLoader.Bind(File.Size(), pMotionData);
|
||||
|
||||
std::string strPathName;
|
||||
GetOnlyPathName(pMeshData->szDiffuseMapFileName, strPathName);
|
||||
|
||||
std::string strTextureFileName;
|
||||
for (DWORD i = 0; i < textFileLoader.GetLineCount(); ++i)
|
||||
{
|
||||
const std::string & c_rstrFileName = textFileLoader.GetLineString(i);
|
||||
|
||||
if (c_rstrFileName.empty())
|
||||
continue;
|
||||
|
||||
strTextureFileName = strPathName;
|
||||
strTextureFileName += c_rstrFileName;
|
||||
|
||||
CGraphicImage * pImage = (CGraphicImage *)CResourceManager::Instance().GetResourcePointer(strTextureFileName.c_str());
|
||||
|
||||
pMeshData->pImageVector.push_back(pImage);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CGraphicImage * pImage = (CGraphicImage *)CResourceManager::Instance().GetResourcePointer(pMeshData->szDiffuseMapFileName);
|
||||
|
||||
pMeshData->pImageVector.push_back(pImage);
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
|
||||
m_pEffectMeshDataVector[n] = pMeshData;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CEffectMesh::__LoadData_Ver001(int iSize, const BYTE * c_pbBuf)
|
||||
{
|
||||
std::vector<D3DXVECTOR3> v3VertexVector;
|
||||
std::vector<int> iIndexVector;
|
||||
std::vector<D3DXVECTOR2> v3TextureVertexVector;
|
||||
std::vector<int> iTextureIndexVector;
|
||||
|
||||
m_iGeomCount = *(int *)c_pbBuf;
|
||||
c_pbBuf += 4;
|
||||
m_iFrameCount = *(int *)c_pbBuf;
|
||||
c_pbBuf += 4;
|
||||
|
||||
m_pEffectMeshDataVector.clear();
|
||||
m_pEffectMeshDataVector.resize(m_iGeomCount);
|
||||
|
||||
for (short n = 0; n < m_iGeomCount; ++n)
|
||||
{
|
||||
SEffectMeshData * pMeshData = SEffectMeshData::New();
|
||||
|
||||
memcpy(pMeshData->szObjectName, c_pbBuf, 32);
|
||||
c_pbBuf += 32;
|
||||
memcpy(pMeshData->szDiffuseMapFileName, c_pbBuf, 128);
|
||||
c_pbBuf += 128;
|
||||
|
||||
DWORD dwVertexCount;
|
||||
DWORD dwIndexCount;
|
||||
DWORD dwTextureVertexCount;
|
||||
|
||||
memcpy(&dwVertexCount, c_pbBuf, sizeof(DWORD));
|
||||
c_pbBuf += sizeof(DWORD);
|
||||
|
||||
memcpy(&dwIndexCount, c_pbBuf, sizeof(DWORD));
|
||||
c_pbBuf += sizeof(DWORD);
|
||||
|
||||
memcpy(&dwTextureVertexCount, c_pbBuf, sizeof(DWORD));
|
||||
c_pbBuf += sizeof(DWORD);
|
||||
|
||||
pMeshData->EffectFrameDataVector.clear();
|
||||
pMeshData->EffectFrameDataVector.resize(m_iFrameCount);
|
||||
|
||||
for(int i = 0; i < m_iFrameCount; ++i)
|
||||
{
|
||||
TEffectFrameData & rFrameData = pMeshData->EffectFrameDataVector[i];
|
||||
|
||||
rFrameData.dwVertexCount = dwVertexCount;
|
||||
rFrameData.dwIndexCount = dwIndexCount;
|
||||
rFrameData.dwTextureVertexCount = dwTextureVertexCount;
|
||||
|
||||
v3VertexVector.clear();
|
||||
v3VertexVector.resize(rFrameData.dwVertexCount);
|
||||
iIndexVector.clear();
|
||||
iIndexVector.resize(rFrameData.dwIndexCount);
|
||||
v3TextureVertexVector.clear();
|
||||
v3TextureVertexVector.resize(rFrameData.dwTextureVertexCount);
|
||||
iTextureIndexVector.clear();
|
||||
iTextureIndexVector.resize(rFrameData.dwIndexCount);
|
||||
|
||||
memcpy(&rFrameData.fVisibility, c_pbBuf, sizeof(float));
|
||||
c_pbBuf += sizeof(float);
|
||||
memcpy(&v3VertexVector[0], c_pbBuf, rFrameData.dwVertexCount*sizeof(D3DXVECTOR3));
|
||||
c_pbBuf += rFrameData.dwVertexCount*sizeof(D3DXVECTOR3);
|
||||
if (rFrameData.dwIndexCount) // @fixme027
|
||||
memcpy(&iIndexVector[0], c_pbBuf, rFrameData.dwIndexCount*sizeof(int));
|
||||
c_pbBuf += rFrameData.dwIndexCount*sizeof(int);
|
||||
memcpy(&v3TextureVertexVector[0], c_pbBuf, rFrameData.dwTextureVertexCount*sizeof(D3DXVECTOR2));
|
||||
c_pbBuf += rFrameData.dwTextureVertexCount*sizeof(D3DXVECTOR2);
|
||||
if (rFrameData.dwIndexCount) // @fixme027
|
||||
memcpy(&iTextureIndexVector[0], c_pbBuf, rFrameData.dwIndexCount*sizeof(int));
|
||||
c_pbBuf += rFrameData.dwIndexCount*sizeof(int);
|
||||
|
||||
///////////////////////////////
|
||||
|
||||
rFrameData.PDTVertexVector.clear();
|
||||
rFrameData.PDTVertexVector.resize(rFrameData.dwIndexCount);
|
||||
for (DWORD j = 0; j < rFrameData.dwIndexCount; ++j)
|
||||
{
|
||||
TPTVertex & rVertex = rFrameData.PDTVertexVector[j];
|
||||
|
||||
DWORD dwIndex = iIndexVector[j];
|
||||
DWORD dwTextureIndex = iTextureIndexVector[j];
|
||||
|
||||
assert(dwIndex < v3VertexVector.size());
|
||||
assert(dwTextureIndex < v3TextureVertexVector.size());
|
||||
|
||||
rVertex.position = v3VertexVector[dwIndex];
|
||||
rVertex.texCoord = v3TextureVertexVector[dwTextureIndex];
|
||||
rVertex.texCoord.y *= -1;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
|
||||
pMeshData->pImageVector.clear();
|
||||
|
||||
std::string strExtension;
|
||||
GetFileExtension(pMeshData->szDiffuseMapFileName, strlen(pMeshData->szDiffuseMapFileName), &strExtension);
|
||||
stl_lowers(strExtension);
|
||||
|
||||
if (0 == strExtension.compare("ifl"))
|
||||
{
|
||||
LPCVOID pMotionData;
|
||||
CMappedFile File;
|
||||
|
||||
if (CEterPackManager::Instance().Get(File, pMeshData->szDiffuseMapFileName, &pMotionData))
|
||||
{
|
||||
CMemoryTextFileLoader textFileLoader;
|
||||
std::vector<std::string> stTokenVector;
|
||||
|
||||
textFileLoader.Bind(File.Size(), pMotionData);
|
||||
|
||||
std::string strPathName;
|
||||
GetOnlyPathName(pMeshData->szDiffuseMapFileName, strPathName);
|
||||
|
||||
std::string strTextureFileName;
|
||||
for (DWORD i = 0; i < textFileLoader.GetLineCount(); ++i)
|
||||
{
|
||||
const std::string & c_rstrFileName = textFileLoader.GetLineString(i);
|
||||
|
||||
if (c_rstrFileName.empty())
|
||||
continue;
|
||||
|
||||
strTextureFileName = strPathName;
|
||||
strTextureFileName += c_rstrFileName;
|
||||
|
||||
CGraphicImage * pImage = (CGraphicImage *)CResourceManager::Instance().GetResourcePointer(strTextureFileName.c_str());
|
||||
|
||||
pMeshData->pImageVector.push_back(pImage);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CGraphicImage * pImage = (CGraphicImage *)CResourceManager::Instance().GetResourcePointer(pMeshData->szDiffuseMapFileName);
|
||||
|
||||
pMeshData->pImageVector.push_back(pImage);
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
|
||||
m_pEffectMeshDataVector[n] = pMeshData;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CEffectMesh::GetMeshElementPointer(DWORD dwMeshIndex, TEffectMeshData ** ppMeshData)
|
||||
{
|
||||
if (dwMeshIndex >= m_pEffectMeshDataVector.size())
|
||||
return FALSE;
|
||||
|
||||
*ppMeshData = m_pEffectMeshDataVector[dwMeshIndex];
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CEffectMesh::OnClear()
|
||||
{
|
||||
if (!m_isData)
|
||||
return;
|
||||
|
||||
for (DWORD i = 0; i < m_pEffectMeshDataVector.size(); ++i)
|
||||
{
|
||||
m_pEffectMeshDataVector[i]->pImageVector.clear();
|
||||
m_pEffectMeshDataVector[i]->EffectFrameDataVector.clear();
|
||||
|
||||
SEffectMeshData::Delete(m_pEffectMeshDataVector[i]);
|
||||
}
|
||||
m_pEffectMeshDataVector.clear();
|
||||
|
||||
m_isData = false;
|
||||
}
|
||||
|
||||
bool CEffectMesh::OnIsEmpty() const
|
||||
{
|
||||
return !m_isData;
|
||||
}
|
||||
|
||||
CEffectMesh::CEffectMesh(const char * c_szFileName) : CResource(c_szFileName)
|
||||
{
|
||||
m_iGeomCount = 0;
|
||||
m_iFrameCount = 0;
|
||||
m_isData = false;
|
||||
}
|
||||
|
||||
CEffectMesh::~CEffectMesh()
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CDynamicPool<CEffectMeshScript> CEffectMeshScript::ms_kPool;
|
||||
|
||||
void CEffectMeshScript::DestroySystem()
|
||||
{
|
||||
ms_kPool.Destroy();
|
||||
}
|
||||
|
||||
CEffectMeshScript* CEffectMeshScript::New()
|
||||
{
|
||||
return ms_kPool.Alloc();
|
||||
}
|
||||
|
||||
void CEffectMeshScript::Delete(CEffectMeshScript* pkData)
|
||||
{
|
||||
pkData->Clear();
|
||||
ms_kPool.Free(pkData);
|
||||
}
|
||||
|
||||
void CEffectMeshScript::ReserveMeshData(DWORD dwMeshCount)
|
||||
{
|
||||
if (m_MeshDataVector.size() == dwMeshCount)
|
||||
return;
|
||||
|
||||
m_MeshDataVector.clear();
|
||||
m_MeshDataVector.resize(dwMeshCount);
|
||||
|
||||
for (DWORD i = 0; i < m_MeshDataVector.size(); ++i)
|
||||
{
|
||||
TMeshData & rMeshData = m_MeshDataVector[i];
|
||||
|
||||
rMeshData.byBillboardType = MESH_BILLBOARD_TYPE_NONE;
|
||||
rMeshData.bBlendingEnable = TRUE;
|
||||
rMeshData.byBlendingSrcType = D3DBLEND_SRCCOLOR;
|
||||
rMeshData.byBlendingDestType = D3DBLEND_ONE;
|
||||
rMeshData.bTextureAlphaEnable = FALSE;
|
||||
|
||||
rMeshData.byColorOperationType = D3DTOP_MODULATE;
|
||||
rMeshData.ColorFactor = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
rMeshData.bTextureAnimationLoopEnable = true;
|
||||
rMeshData.fTextureAnimationFrameDelay = 0.02f;
|
||||
rMeshData.dwTextureAnimationStartFrame = 0;
|
||||
}
|
||||
}
|
||||
|
||||
const char * CEffectMeshScript::GetMeshFileName()
|
||||
{
|
||||
return m_strMeshFileName.c_str();
|
||||
}
|
||||
|
||||
bool CEffectMeshScript::CheckMeshIndex(DWORD dwMeshIndex)
|
||||
{
|
||||
if (dwMeshIndex >= m_MeshDataVector.size())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CEffectMeshScript::GetMeshDataPointer(DWORD dwMeshIndex, TMeshData ** ppMeshData)
|
||||
{
|
||||
if (!CheckMeshIndex(dwMeshIndex))
|
||||
return false;
|
||||
|
||||
*ppMeshData = &m_MeshDataVector[dwMeshIndex];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int CEffectMeshScript::GetMeshDataCount()
|
||||
{
|
||||
return m_MeshDataVector.size();
|
||||
}
|
||||
|
||||
int CEffectMeshScript::GetBillboardType(DWORD dwMeshIndex)
|
||||
{
|
||||
if (!CheckMeshIndex(dwMeshIndex))
|
||||
return 0;
|
||||
|
||||
return m_MeshDataVector[dwMeshIndex].byBillboardType;
|
||||
}
|
||||
BOOL CEffectMeshScript::isBlendingEnable(DWORD dwMeshIndex)
|
||||
{
|
||||
if (!CheckMeshIndex(dwMeshIndex))
|
||||
return FALSE;
|
||||
|
||||
return m_MeshDataVector[dwMeshIndex].bBlendingEnable;
|
||||
}
|
||||
BYTE CEffectMeshScript::GetBlendingSrcType(DWORD dwMeshIndex)
|
||||
{
|
||||
if (!CheckMeshIndex(dwMeshIndex))
|
||||
return false;
|
||||
|
||||
return m_MeshDataVector[dwMeshIndex].byBlendingSrcType;
|
||||
}
|
||||
BYTE CEffectMeshScript::GetBlendingDestType(DWORD dwMeshIndex)
|
||||
{
|
||||
if (!CheckMeshIndex(dwMeshIndex))
|
||||
return false;
|
||||
|
||||
return m_MeshDataVector[dwMeshIndex].byBlendingDestType;
|
||||
}
|
||||
BOOL CEffectMeshScript::isTextureAlphaEnable(DWORD dwMeshIndex)
|
||||
{
|
||||
if (!CheckMeshIndex(dwMeshIndex))
|
||||
return false;
|
||||
|
||||
return m_MeshDataVector[dwMeshIndex].bTextureAlphaEnable;
|
||||
}
|
||||
|
||||
BOOL CEffectMeshScript::GetColorOperationType(DWORD dwMeshIndex, BYTE * pbyType)
|
||||
{
|
||||
if (!CheckMeshIndex(dwMeshIndex))
|
||||
return FALSE;
|
||||
|
||||
*pbyType = m_MeshDataVector[dwMeshIndex].byColorOperationType;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
BOOL CEffectMeshScript::GetColorFactor(DWORD dwMeshIndex, D3DXCOLOR * pColor)
|
||||
{
|
||||
if (!CheckMeshIndex(dwMeshIndex))
|
||||
return FALSE;
|
||||
|
||||
*pColor = m_MeshDataVector[dwMeshIndex].ColorFactor;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CEffectMeshScript::GetTimeTableAlphaPointer(DWORD dwMeshIndex, TTimeEventTableFloat ** pTimeEventAlpha)
|
||||
{
|
||||
if (!CheckMeshIndex(dwMeshIndex))
|
||||
return FALSE;
|
||||
|
||||
*pTimeEventAlpha = &m_MeshDataVector[dwMeshIndex].TimeEventAlpha;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CEffectMeshScript::isMeshAnimationLoop()
|
||||
{
|
||||
return m_isMeshAnimationLoop;
|
||||
}
|
||||
int CEffectMeshScript::GetMeshAnimationLoopCount()
|
||||
{
|
||||
return m_iMeshAnimationLoopCount;
|
||||
}
|
||||
float CEffectMeshScript::GetMeshAnimationFrameDelay()
|
||||
{
|
||||
return m_fMeshAnimationFrameDelay;
|
||||
}
|
||||
|
||||
BOOL CEffectMeshScript::isTextureAnimationLoop(DWORD dwMeshIndex)
|
||||
{
|
||||
if (!CheckMeshIndex(dwMeshIndex))
|
||||
return 0.0f;
|
||||
|
||||
return m_MeshDataVector[dwMeshIndex].bTextureAnimationLoopEnable;
|
||||
}
|
||||
float CEffectMeshScript::GetTextureAnimationFrameDelay(DWORD dwMeshIndex)
|
||||
{
|
||||
if (!CheckMeshIndex(dwMeshIndex))
|
||||
return 0.0f;
|
||||
|
||||
return m_MeshDataVector[dwMeshIndex].fTextureAnimationFrameDelay;
|
||||
}
|
||||
|
||||
DWORD CEffectMeshScript::GetTextureAnimationStartFrame(DWORD dwMeshIndex)
|
||||
{
|
||||
if (!CheckMeshIndex(dwMeshIndex))
|
||||
return 0;
|
||||
|
||||
return m_MeshDataVector[dwMeshIndex].dwTextureAnimationStartFrame;
|
||||
}
|
||||
|
||||
BOOL CEffectMeshScript::OnLoadScript(CTextFileLoader & rTextFileLoader)
|
||||
{
|
||||
if (rTextFileLoader.GetTokenString("meshfilename", &m_strMeshFileName))
|
||||
{
|
||||
if (!IsGlobalFileName(m_strMeshFileName.c_str()))
|
||||
{
|
||||
m_strMeshFileName = GetOnlyPathName(rTextFileLoader.GetFileName()) + m_strMeshFileName;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!rTextFileLoader.GetTokenInteger("meshanimationloopenable", &m_isMeshAnimationLoop))
|
||||
return FALSE;
|
||||
if (!rTextFileLoader.GetTokenInteger("meshanimationloopcount", &m_iMeshAnimationLoopCount))
|
||||
{
|
||||
m_iMeshAnimationLoopCount = 0;
|
||||
}
|
||||
if (!rTextFileLoader.GetTokenFloat("meshanimationframedelay", &m_fMeshAnimationFrameDelay))
|
||||
return FALSE;
|
||||
|
||||
DWORD dwMeshElementCount;
|
||||
if (!rTextFileLoader.GetTokenDoubleWord("meshelementcount", &dwMeshElementCount))
|
||||
return FALSE;
|
||||
|
||||
m_MeshDataVector.clear();
|
||||
m_MeshDataVector.resize(dwMeshElementCount);
|
||||
for (DWORD i = 0; i < m_MeshDataVector.size(); ++i)
|
||||
{
|
||||
CTextFileLoader::CGotoChild GotoChild(&rTextFileLoader, i);
|
||||
|
||||
TMeshData & rMeshData = m_MeshDataVector[i];
|
||||
|
||||
if (!rTextFileLoader.GetTokenByte("billboardtype", &rMeshData.byBillboardType))
|
||||
return FALSE;
|
||||
if (!rTextFileLoader.GetTokenBoolean("blendingenable", &rMeshData.bBlendingEnable))
|
||||
return FALSE;
|
||||
if (!rTextFileLoader.GetTokenByte("blendingsrctype", &rMeshData.byBlendingSrcType))
|
||||
return FALSE;
|
||||
if (!rTextFileLoader.GetTokenByte("blendingdesttype", &rMeshData.byBlendingDestType))
|
||||
return FALSE;
|
||||
|
||||
if (!rTextFileLoader.GetTokenBoolean("textureanimationloopenable", &rMeshData.bTextureAnimationLoopEnable))
|
||||
return FALSE;
|
||||
if (!rTextFileLoader.GetTokenFloat("textureanimationframedelay", &rMeshData.fTextureAnimationFrameDelay))
|
||||
return FALSE;
|
||||
if (!rTextFileLoader.GetTokenDoubleWord("textureanimationstartframe", &rMeshData.dwTextureAnimationStartFrame))
|
||||
{
|
||||
rMeshData.dwTextureAnimationStartFrame = 0;
|
||||
}
|
||||
|
||||
if (!rTextFileLoader.GetTokenByte("coloroperationtype", &rMeshData.byColorOperationType))
|
||||
{
|
||||
rMeshData.byColorOperationType = D3DTOP_MODULATE;
|
||||
}
|
||||
if (!rTextFileLoader.GetTokenColor("colorfactor", &rMeshData.ColorFactor))
|
||||
{
|
||||
rMeshData.ColorFactor = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventalpha", &rMeshData.TimeEventAlpha))
|
||||
{
|
||||
rMeshData.TimeEventAlpha.clear();
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool CEffectMeshScript::OnIsData()
|
||||
{
|
||||
if (0 == m_strMeshFileName.length())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CEffectMeshScript::OnClear()
|
||||
{
|
||||
m_isMeshAnimationLoop = false;
|
||||
m_iMeshAnimationLoopCount = 0;
|
||||
m_fMeshAnimationFrameDelay = 0.02f;
|
||||
|
||||
m_MeshDataVector.clear();
|
||||
m_strMeshFileName = "";
|
||||
}
|
||||
|
||||
CEffectMeshScript::CEffectMeshScript()
|
||||
{
|
||||
}
|
||||
CEffectMeshScript::~CEffectMeshScript()
|
||||
{
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
158
source-client/Srcs/Client/EffectLib/EffectMesh.h
Normal file
158
source-client/Srcs/Client/EffectLib/EffectMesh.h
Normal file
@ -0,0 +1,158 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3dx8.h>
|
||||
|
||||
#include "../eterlib/GrpScreen.h"
|
||||
#include "../eterlib/Resource.h"
|
||||
#include "../eterlib/GrpImageInstance.h"
|
||||
#include "../eterLib/TextFileLoader.h"
|
||||
|
||||
#include "Type.h"
|
||||
#include "EffectElementBase.h"
|
||||
|
||||
class CEffectMesh : public CResource
|
||||
{
|
||||
public:
|
||||
typedef struct SEffectFrameData
|
||||
{
|
||||
BYTE byChangedFrame;
|
||||
float fVisibility;
|
||||
DWORD dwVertexCount;
|
||||
DWORD dwTextureVertexCount;
|
||||
DWORD dwIndexCount;
|
||||
std::vector<TPTVertex> PDTVertexVector;
|
||||
} TEffectFrameData;
|
||||
|
||||
typedef struct SEffectMeshData
|
||||
{
|
||||
char szObjectName[32];
|
||||
char szDiffuseMapFileName[128];
|
||||
|
||||
std::vector<TEffectFrameData> EffectFrameDataVector;
|
||||
std::vector<CGraphicImage*> pImageVector;
|
||||
|
||||
static SEffectMeshData* New();
|
||||
static void Delete(SEffectMeshData* pkData);
|
||||
|
||||
static void DestroySystem();
|
||||
|
||||
static CDynamicPool<SEffectMeshData> ms_kPool;
|
||||
} TEffectMeshData;
|
||||
|
||||
// About Resource Code
|
||||
public:
|
||||
typedef CRef<CEffectMesh> TRef;
|
||||
|
||||
public:
|
||||
static TType Type();
|
||||
|
||||
public:
|
||||
CEffectMesh(const char * c_szFileName);
|
||||
virtual ~CEffectMesh();
|
||||
|
||||
DWORD GetFrameCount();
|
||||
DWORD GetMeshCount();
|
||||
TEffectMeshData * GetMeshDataPointer(DWORD dwMeshIndex);
|
||||
|
||||
std::vector<CGraphicImage*>* GetTextureVectorPointer(DWORD dwMeshIndex);
|
||||
std::vector<CGraphicImage*>& GetTextureVectorReference(DWORD dwMeshIndex);
|
||||
|
||||
// Exceptional function for tool
|
||||
BOOL GetMeshElementPointer(DWORD dwMeshIndex, TEffectMeshData ** ppMeshData);
|
||||
|
||||
protected:
|
||||
bool OnLoad(int iSize, const void * c_pvBuf);
|
||||
|
||||
void OnClear();
|
||||
bool OnIsEmpty() const;
|
||||
bool OnIsType(TType type);
|
||||
|
||||
BOOL __LoadData_Ver001(int iSize, const BYTE * c_pbBuf);
|
||||
BOOL __LoadData_Ver002(int iSize, const BYTE * c_pbBuf);
|
||||
|
||||
protected:
|
||||
int m_iGeomCount;
|
||||
int m_iFrameCount;
|
||||
std::vector<TEffectMeshData *> m_pEffectMeshDataVector;
|
||||
|
||||
bool m_isData;
|
||||
};
|
||||
|
||||
class CEffectMeshScript : public CEffectElementBase
|
||||
{
|
||||
public:
|
||||
typedef struct SMeshData
|
||||
{
|
||||
BYTE byBillboardType;
|
||||
|
||||
BOOL bBlendingEnable;
|
||||
BYTE byBlendingSrcType;
|
||||
BYTE byBlendingDestType;
|
||||
BOOL bTextureAlphaEnable;
|
||||
|
||||
BYTE byColorOperationType;
|
||||
D3DXCOLOR ColorFactor;
|
||||
|
||||
BOOL bTextureAnimationLoopEnable;
|
||||
float fTextureAnimationFrameDelay;
|
||||
|
||||
DWORD dwTextureAnimationStartFrame;
|
||||
|
||||
TTimeEventTableFloat TimeEventAlpha;
|
||||
|
||||
SMeshData()
|
||||
{
|
||||
TimeEventAlpha.clear();
|
||||
}
|
||||
} TMeshData;
|
||||
typedef std::vector<TMeshData> TMeshDataVector;
|
||||
|
||||
public:
|
||||
CEffectMeshScript();
|
||||
virtual ~CEffectMeshScript();
|
||||
|
||||
const char * GetMeshFileName();
|
||||
|
||||
void ReserveMeshData(DWORD dwMeshCount);
|
||||
bool CheckMeshIndex(DWORD dwMeshIndex);
|
||||
bool GetMeshDataPointer(DWORD dwMeshIndex, TMeshData ** ppMeshData);
|
||||
int GetMeshDataCount();
|
||||
|
||||
int GetBillboardType(DWORD dwMeshIndex);
|
||||
BOOL isBlendingEnable(DWORD dwMeshIndex);
|
||||
BYTE GetBlendingSrcType(DWORD dwMeshIndex);
|
||||
BYTE GetBlendingDestType(DWORD dwMeshIndex);
|
||||
BOOL isTextureAlphaEnable(DWORD dwMeshIndex);
|
||||
BOOL GetColorOperationType(DWORD dwMeshIndex, BYTE * pbyType);
|
||||
BOOL GetColorFactor(DWORD dwMeshIndex, D3DXCOLOR * pColor);
|
||||
BOOL GetTimeTableAlphaPointer(DWORD dwMeshIndex, TTimeEventTableFloat ** pTimeEventAlpha);
|
||||
|
||||
BOOL isMeshAnimationLoop();
|
||||
BOOL GetMeshAnimationLoopCount();
|
||||
float GetMeshAnimationFrameDelay();
|
||||
BOOL isTextureAnimationLoop(DWORD dwMeshIndex);
|
||||
float GetTextureAnimationFrameDelay(DWORD dwMeshIndex);
|
||||
DWORD GetTextureAnimationStartFrame(DWORD dwMeshIndex);
|
||||
|
||||
protected:
|
||||
void OnClear();
|
||||
bool OnIsData();
|
||||
BOOL OnLoadScript(CTextFileLoader & rTextFileLoader);
|
||||
|
||||
protected:
|
||||
BOOL m_isMeshAnimationLoop;
|
||||
int m_iMeshAnimationLoopCount;
|
||||
float m_fMeshAnimationFrameDelay;
|
||||
TMeshDataVector m_MeshDataVector;
|
||||
|
||||
std::string m_strMeshFileName;
|
||||
|
||||
public:
|
||||
static void DestroySystem();
|
||||
|
||||
static CEffectMeshScript* New();
|
||||
static void Delete(CEffectMeshScript* pkData);
|
||||
|
||||
static CDynamicPool<CEffectMeshScript> ms_kPool;
|
||||
};
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
273
source-client/Srcs/Client/EffectLib/EffectMeshInstance.cpp
Normal file
273
source-client/Srcs/Client/EffectLib/EffectMeshInstance.cpp
Normal file
@ -0,0 +1,273 @@
|
||||
#include "StdAfx.h"
|
||||
#include "../eterLib/StateManager.h"
|
||||
#include "../eterLib/ResourceManager.h"
|
||||
#include "EffectMeshInstance.h"
|
||||
#include "../eterlib/GrpMath.h"
|
||||
|
||||
CDynamicPool<CEffectMeshInstance> CEffectMeshInstance::ms_kPool;
|
||||
|
||||
void CEffectMeshInstance::DestroySystem()
|
||||
{
|
||||
ms_kPool.Destroy();
|
||||
}
|
||||
|
||||
CEffectMeshInstance* CEffectMeshInstance::New()
|
||||
{
|
||||
return ms_kPool.Alloc();
|
||||
}
|
||||
|
||||
void CEffectMeshInstance::Delete(CEffectMeshInstance* pkMeshInstance)
|
||||
{
|
||||
pkMeshInstance->Destroy();
|
||||
ms_kPool.Free(pkMeshInstance);
|
||||
}
|
||||
|
||||
BOOL CEffectMeshInstance::isActive()
|
||||
{
|
||||
if (!CEffectElementBaseInstance::isActive())
|
||||
return FALSE;
|
||||
|
||||
if (!m_MeshFrameController.isActive())
|
||||
return FALSE;
|
||||
|
||||
for (DWORD j = 0; j < m_TextureInstanceVector.size(); ++j)
|
||||
{
|
||||
int iCurrentFrame = m_MeshFrameController.GetCurrentFrame();
|
||||
if (m_TextureInstanceVector[j].TextureFrameController.isActive(iCurrentFrame))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool CEffectMeshInstance::OnUpdate(float fElapsedTime)
|
||||
{
|
||||
if (!isActive())
|
||||
return false;
|
||||
|
||||
if (m_MeshFrameController.isActive())
|
||||
m_MeshFrameController.Update(fElapsedTime);
|
||||
|
||||
for (DWORD j = 0; j < m_TextureInstanceVector.size(); ++j)
|
||||
{
|
||||
int iCurrentFrame = m_MeshFrameController.GetCurrentFrame();
|
||||
if (m_TextureInstanceVector[j].TextureFrameController.isActive(iCurrentFrame))
|
||||
m_TextureInstanceVector[j].TextureFrameController.Update(fElapsedTime);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CEffectMeshInstance::OnRender()
|
||||
{
|
||||
if (!isActive())
|
||||
return;
|
||||
|
||||
CEffectMesh * pEffectMesh = m_roMesh.GetPointer();
|
||||
|
||||
for (DWORD i = 0; i < pEffectMesh->GetMeshCount(); ++i)
|
||||
{
|
||||
assert(i < m_TextureInstanceVector.size());
|
||||
|
||||
CFrameController & rTextureFrameController = m_TextureInstanceVector[i].TextureFrameController;
|
||||
if (!rTextureFrameController.isActive(m_MeshFrameController.GetCurrentFrame()))
|
||||
continue;
|
||||
|
||||
int iBillboardType = m_pMeshScript->GetBillboardType(i);
|
||||
|
||||
D3DXMATRIX m_matWorld;
|
||||
D3DXMatrixIdentity(&m_matWorld);
|
||||
|
||||
switch(iBillboardType)
|
||||
{
|
||||
case MESH_BILLBOARD_TYPE_ALL:
|
||||
{
|
||||
D3DXMATRIX matTemp;
|
||||
D3DXMatrixRotationX(&matTemp, 90.0f);
|
||||
D3DXMatrixInverse(&m_matWorld, NULL, &CScreen::GetViewMatrix());
|
||||
|
||||
m_matWorld = matTemp * m_matWorld;
|
||||
}
|
||||
break;
|
||||
|
||||
case MESH_BILLBOARD_TYPE_Y:
|
||||
{
|
||||
D3DXMATRIX matTemp;
|
||||
D3DXMatrixIdentity(&matTemp);
|
||||
|
||||
D3DXMatrixInverse(&matTemp, NULL, &CScreen::GetViewMatrix());
|
||||
m_matWorld._11 = matTemp._11;
|
||||
m_matWorld._12 = matTemp._12;
|
||||
m_matWorld._21 = matTemp._21;
|
||||
m_matWorld._22 = matTemp._22;
|
||||
}
|
||||
break;
|
||||
|
||||
case MESH_BILLBOARD_TYPE_MOVE:
|
||||
{
|
||||
D3DXVECTOR3 Position;
|
||||
m_pMeshScript->GetPosition(m_fLocalTime, Position);
|
||||
D3DXVECTOR3 LastPosition;
|
||||
m_pMeshScript->GetPosition(m_fLocalTime-CTimer::Instance().GetElapsedSecond(), LastPosition);
|
||||
Position -= LastPosition;
|
||||
if (D3DXVec3LengthSq(&Position)>0.001f)
|
||||
{
|
||||
D3DXVec3Normalize(&Position,&Position);
|
||||
D3DXQUATERNION q = SafeRotationNormalizedArc(D3DXVECTOR3(0.0f,-1.0f,0.0f),Position);
|
||||
D3DXMatrixRotationQuaternion(&m_matWorld,&q);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!m_pMeshScript->isBlendingEnable(i))
|
||||
{
|
||||
STATEMANAGER.SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
int iBlendingSrcType = m_pMeshScript->GetBlendingSrcType(i);
|
||||
int iBlendingDestType = m_pMeshScript->GetBlendingDestType(i);
|
||||
STATEMANAGER.SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
||||
STATEMANAGER.SetRenderState(D3DRS_SRCBLEND, iBlendingSrcType);
|
||||
STATEMANAGER.SetRenderState(D3DRS_DESTBLEND, iBlendingDestType);
|
||||
}
|
||||
|
||||
D3DXVECTOR3 Position;
|
||||
m_pMeshScript->GetPosition(m_fLocalTime, Position);
|
||||
m_matWorld._41 = Position.x;
|
||||
m_matWorld._42 = Position.y;
|
||||
m_matWorld._43 = Position.z;
|
||||
m_matWorld = m_matWorld * *mc_pmatLocal;
|
||||
STATEMANAGER.SetTransform(D3DTS_WORLD, &m_matWorld);
|
||||
|
||||
BYTE byType;
|
||||
D3DXCOLOR Color(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
if (m_pMeshScript->GetColorOperationType(i, &byType))
|
||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, byType);
|
||||
m_pMeshScript->GetColorFactor(i, &Color);
|
||||
|
||||
TTimeEventTableFloat * TableAlpha;
|
||||
|
||||
float fAlpha = 1.0f;
|
||||
if (m_pMeshScript->GetTimeTableAlphaPointer(i, &TableAlpha) && !TableAlpha->empty())
|
||||
GetTimeEventBlendValue(m_fLocalTime,*TableAlpha, &fAlpha);
|
||||
|
||||
// Render
|
||||
CEffectMesh::TEffectMeshData * pMeshData = pEffectMesh->GetMeshDataPointer(i);
|
||||
|
||||
assert(m_MeshFrameController.GetCurrentFrame() < pMeshData->EffectFrameDataVector.size());
|
||||
CEffectMesh::TEffectFrameData & rFrameData = pMeshData->EffectFrameDataVector[m_MeshFrameController.GetCurrentFrame()];
|
||||
|
||||
DWORD dwcurTextureFrame = rTextureFrameController.GetCurrentFrame();
|
||||
if (dwcurTextureFrame < m_TextureInstanceVector[i].TextureInstanceVector.size())
|
||||
{
|
||||
CGraphicImageInstance * pImageInstance = m_TextureInstanceVector[i].TextureInstanceVector[dwcurTextureFrame];
|
||||
STATEMANAGER.SetTexture(0, pImageInstance->GetTexturePointer()->GetD3DTexture());
|
||||
}
|
||||
|
||||
Color.a = fAlpha * rFrameData.fVisibility;
|
||||
STATEMANAGER.SetRenderState(D3DRS_TEXTUREFACTOR, DWORD(Color));
|
||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ | D3DFVF_TEX1);
|
||||
if (rFrameData.dwIndexCount) // @fixme027
|
||||
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLELIST,
|
||||
rFrameData.dwIndexCount/3,
|
||||
&rFrameData.PDTVertexVector[0],
|
||||
sizeof(TPTVertex));
|
||||
// Render
|
||||
}
|
||||
}
|
||||
|
||||
void CEffectMeshInstance::OnSetDataPointer(CEffectElementBase * pElement)
|
||||
{
|
||||
CEffectMeshScript * pMesh = (CEffectMeshScript *)pElement;
|
||||
m_pMeshScript = pMesh;
|
||||
|
||||
const char * c_szMeshFileName = pMesh->GetMeshFileName();
|
||||
|
||||
m_pEffectMesh = (CEffectMesh *) CResourceManager::Instance().GetResourcePointer(c_szMeshFileName);
|
||||
|
||||
if (!m_pEffectMesh)
|
||||
return;
|
||||
|
||||
m_roMesh.SetPointer(m_pEffectMesh);
|
||||
|
||||
m_MeshFrameController.Clear();
|
||||
m_MeshFrameController.SetMaxFrame(m_roMesh.GetPointer()->GetFrameCount());
|
||||
m_MeshFrameController.SetFrameTime(pMesh->GetMeshAnimationFrameDelay());
|
||||
m_MeshFrameController.SetLoopFlag(pMesh->isMeshAnimationLoop());
|
||||
m_MeshFrameController.SetLoopCount(pMesh->GetMeshAnimationLoopCount());
|
||||
m_MeshFrameController.SetStartFrame(0);
|
||||
|
||||
m_TextureInstanceVector.clear();
|
||||
m_TextureInstanceVector.resize(m_pEffectMesh->GetMeshCount());
|
||||
for (DWORD j = 0; j < m_TextureInstanceVector.size(); ++j)
|
||||
{
|
||||
CEffectMeshScript::TMeshData * pMeshData;
|
||||
if (!m_pMeshScript->GetMeshDataPointer(j, &pMeshData))
|
||||
continue;
|
||||
|
||||
CEffectMesh* pkEftMesh=m_roMesh.GetPointer();
|
||||
|
||||
if (!pkEftMesh)
|
||||
continue;
|
||||
|
||||
std::vector<CGraphicImage*>* pTextureVector = pkEftMesh->GetTextureVectorPointer(j);
|
||||
if (!pTextureVector)
|
||||
continue;
|
||||
|
||||
std::vector<CGraphicImage*>& rTextureVector = *pTextureVector;
|
||||
|
||||
CFrameController & rFrameController = m_TextureInstanceVector[j].TextureFrameController;
|
||||
rFrameController.Clear();
|
||||
rFrameController.SetMaxFrame(rTextureVector.size());
|
||||
rFrameController.SetFrameTime(pMeshData->fTextureAnimationFrameDelay);
|
||||
rFrameController.SetLoopFlag(pMeshData->bTextureAnimationLoopEnable);
|
||||
rFrameController.SetStartFrame(pMeshData->dwTextureAnimationStartFrame);
|
||||
|
||||
std::vector<CGraphicImageInstance*> & rImageInstanceVector = m_TextureInstanceVector[j].TextureInstanceVector;
|
||||
rImageInstanceVector.clear();
|
||||
rImageInstanceVector.reserve(rTextureVector.size());
|
||||
for (std::vector<CGraphicImage*>::iterator itor = rTextureVector.begin(); itor != rTextureVector.end(); ++itor)
|
||||
{
|
||||
CGraphicImage * pImage = *itor;
|
||||
CGraphicImageInstance * pImageInstance = CGraphicImageInstance::ms_kPool.Alloc();
|
||||
pImageInstance->SetImagePointer(pImage);
|
||||
rImageInstanceVector.push_back(pImageInstance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CEffectMeshInstance_DeleteImageInstance(CGraphicImageInstance * pkInstance)
|
||||
{
|
||||
CGraphicImageInstance::ms_kPool.Free(pkInstance);
|
||||
}
|
||||
|
||||
void CEffectMeshInstance_DeleteTextureInstance(CEffectMeshInstance::TTextureInstance & rkInstance)
|
||||
{
|
||||
std::vector<CGraphicImageInstance*> & rVector = rkInstance.TextureInstanceVector;
|
||||
for_each(rVector.begin(), rVector.end(), CEffectMeshInstance_DeleteImageInstance);
|
||||
rVector.clear();
|
||||
}
|
||||
|
||||
void CEffectMeshInstance::OnInitialize()
|
||||
{
|
||||
}
|
||||
|
||||
void CEffectMeshInstance::OnDestroy()
|
||||
{
|
||||
for_each(m_TextureInstanceVector.begin(), m_TextureInstanceVector.end(), CEffectMeshInstance_DeleteTextureInstance);
|
||||
m_TextureInstanceVector.clear();
|
||||
m_roMesh.SetPointer(NULL);
|
||||
}
|
||||
|
||||
CEffectMeshInstance::CEffectMeshInstance()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
CEffectMeshInstance::~CEffectMeshInstance()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
50
source-client/Srcs/Client/EffectLib/EffectMeshInstance.h
Normal file
50
source-client/Srcs/Client/EffectLib/EffectMeshInstance.h
Normal file
@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
|
||||
#include "../eterlib/GrpScreen.h"
|
||||
#include "../eterlib/GrpImageInstance.h"
|
||||
#include "EffectElementBaseInstance.h"
|
||||
#include "FrameController.h"
|
||||
#include "EffectMesh.h"
|
||||
|
||||
class CEffectMeshInstance : public CEffectElementBaseInstance
|
||||
{
|
||||
public:
|
||||
typedef struct STextureInstance
|
||||
{
|
||||
CFrameController TextureFrameController;
|
||||
std::vector<CGraphicImageInstance*> TextureInstanceVector;
|
||||
} TTextureInstance;
|
||||
|
||||
public:
|
||||
CEffectMeshInstance();
|
||||
virtual ~CEffectMeshInstance();
|
||||
|
||||
public:
|
||||
static void DestroySystem();
|
||||
|
||||
static CEffectMeshInstance* New();
|
||||
static void Delete(CEffectMeshInstance* pkMeshInstance);
|
||||
|
||||
static CDynamicPool<CEffectMeshInstance> ms_kPool;
|
||||
|
||||
protected:
|
||||
void OnSetDataPointer(CEffectElementBase * pElement);
|
||||
|
||||
void OnInitialize();
|
||||
void OnDestroy();
|
||||
|
||||
bool OnUpdate(float fElapsedTime);
|
||||
void OnRender();
|
||||
|
||||
BOOL isActive();
|
||||
|
||||
protected:
|
||||
CEffectMeshScript * m_pMeshScript;
|
||||
CEffectMesh * m_pEffectMesh;
|
||||
|
||||
CFrameController m_MeshFrameController;
|
||||
std::vector<TTextureInstance> m_TextureInstanceVector;
|
||||
|
||||
CEffectMesh::TRef m_roMesh;
|
||||
};
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
@ -0,0 +1,38 @@
|
||||
#include "stdafx.h"
|
||||
#include "EffectUpdateDecorator.h"
|
||||
#include "ParticleInstance.h"
|
||||
namespace NEffectUpdateDecorator
|
||||
{
|
||||
CBaseDecorator* CAirResistanceDecorator::__Clone(CParticleInstance* pfi, CParticleInstance* pi)
|
||||
{
|
||||
pi->m_fAirResistance = pfi->m_fAirResistance;
|
||||
return new CAirResistanceDecorator;
|
||||
}
|
||||
|
||||
void CAirResistanceDecorator::__Excute(const CDecoratorData & d)
|
||||
{
|
||||
d.pInstance->m_v3Velocity *= 1.0f-d.pInstance->m_fAirResistance;
|
||||
}
|
||||
CBaseDecorator* CGravityDecorator::__Clone(CParticleInstance* pfi, CParticleInstance* pi)
|
||||
{
|
||||
pi->m_fGravity = pfi->m_fGravity;
|
||||
return new CGravityDecorator;
|
||||
}
|
||||
|
||||
void CGravityDecorator::__Excute(const CDecoratorData& d)
|
||||
{
|
||||
d.pInstance->m_v3Velocity.z -= d.pInstance->m_fGravity * d.fElapsedTime;
|
||||
}
|
||||
|
||||
CBaseDecorator* CRotationDecorator::__Clone(CParticleInstance* pfi, CParticleInstance* pi)
|
||||
{
|
||||
pi->m_fRotationSpeed = pfi->m_fRotationSpeed;
|
||||
return new CRotationDecorator;
|
||||
}
|
||||
|
||||
void CRotationDecorator::__Excute(const CDecoratorData& d)
|
||||
{
|
||||
d.pInstance->m_fRotation += d.pInstance->m_fRotationSpeed * d.fElapsedTime;
|
||||
}
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
282
source-client/Srcs/Client/EffectLib/EffectUpdateDecorator.h
Normal file
282
source-client/Srcs/Client/EffectLib/EffectUpdateDecorator.h
Normal file
@ -0,0 +1,282 @@
|
||||
#pragma once
|
||||
|
||||
#include "Type.h"
|
||||
#include "../eterbase/Random.h"
|
||||
#include "../eterlib/Pool.h"
|
||||
class CParticleInstance;
|
||||
|
||||
namespace NEffectUpdateDecorator
|
||||
{
|
||||
class CDecoratorData
|
||||
{
|
||||
public:
|
||||
float fTime;
|
||||
float fElapsedTime;
|
||||
CParticleInstance * pInstance;
|
||||
CDecoratorData(float fTime, float fElapsedTime, CParticleInstance * pInstance)
|
||||
: fTime(fTime), fElapsedTime(fElapsedTime), pInstance(pInstance)
|
||||
{}
|
||||
};
|
||||
class CBaseDecorator
|
||||
{
|
||||
friend class CParticleSystemData;
|
||||
public:
|
||||
CBaseDecorator() :m_NextDecorator(0), m_PrevDecorator(0) {}
|
||||
virtual ~CBaseDecorator(){}
|
||||
|
||||
void Excute(const CDecoratorData & d)
|
||||
{
|
||||
CBaseDecorator* pd = this;
|
||||
while(pd)
|
||||
{
|
||||
CBaseDecorator* pNextDecorator = pd->m_NextDecorator;
|
||||
pd->__Excute(d);
|
||||
pd = pNextDecorator;
|
||||
}
|
||||
}
|
||||
CBaseDecorator * AddChainFront(CBaseDecorator * pd)
|
||||
{
|
||||
pd->m_NextDecorator = this;
|
||||
m_PrevDecorator = pd;
|
||||
return pd;
|
||||
}
|
||||
void DeleteThis()
|
||||
{
|
||||
//return;
|
||||
if (m_NextDecorator)
|
||||
m_NextDecorator->DeleteThis();
|
||||
delete this;
|
||||
}
|
||||
CBaseDecorator * Clone(CParticleInstance* pFirstInstance, CParticleInstance* pInstance)
|
||||
{
|
||||
CBaseDecorator * pNewDecorator = __Clone(pFirstInstance, pInstance);
|
||||
CBaseDecorator * pSrc = this;
|
||||
CBaseDecorator * pDest = pNewDecorator;
|
||||
while (pSrc->m_NextDecorator)
|
||||
{
|
||||
pDest->m_NextDecorator = pSrc->m_NextDecorator->__Clone(pFirstInstance, pInstance);
|
||||
pDest->m_NextDecorator->m_PrevDecorator = pDest;
|
||||
|
||||
pSrc = pSrc->m_NextDecorator;
|
||||
pDest = pDest->m_NextDecorator;
|
||||
}
|
||||
return pNewDecorator;
|
||||
}
|
||||
protected:
|
||||
virtual void __Excute(const CDecoratorData & d) = 0;
|
||||
virtual CBaseDecorator* __Clone(CParticleInstance* pFirstInstance, CParticleInstance* pInstance) = 0;
|
||||
void RemoveMe()
|
||||
{
|
||||
m_PrevDecorator->m_NextDecorator = m_NextDecorator;
|
||||
m_NextDecorator->m_PrevDecorator=m_PrevDecorator;
|
||||
delete this;
|
||||
}
|
||||
CBaseDecorator * m_NextDecorator;
|
||||
CBaseDecorator * m_PrevDecorator;
|
||||
};
|
||||
|
||||
class CHeaderDecorator : public CBaseDecorator, public CPooledObject<CHeaderDecorator>
|
||||
{
|
||||
public:
|
||||
CHeaderDecorator() {}
|
||||
virtual ~CHeaderDecorator() {}
|
||||
protected:
|
||||
virtual void __Excute(const CDecoratorData&) {}
|
||||
virtual CBaseDecorator* __Clone(CParticleInstance*, CParticleInstance*) { return new CHeaderDecorator; }
|
||||
};
|
||||
|
||||
class CNullDecorator : public CBaseDecorator, public CPooledObject<CNullDecorator>
|
||||
{
|
||||
public:
|
||||
CNullDecorator(){}
|
||||
virtual ~CNullDecorator(){}
|
||||
|
||||
protected:
|
||||
virtual void __Excute(const CDecoratorData & d) {}
|
||||
virtual CBaseDecorator* __Clone(CParticleInstance*, CParticleInstance* ) { return new CNullDecorator; }
|
||||
};
|
||||
|
||||
template <class T> class CTimeEventDecorator : public CBaseDecorator, public CPooledObject<CTimeEventDecorator<T> >
|
||||
{
|
||||
public:
|
||||
typedef CTimeEvent<T> TTimeEventType;
|
||||
typedef std::vector<TTimeEventType> TTimeEventContainerType;
|
||||
CTimeEventDecorator(const TTimeEventContainerType& TimeEventContainer, T * pValue = 0)
|
||||
: it_start(TimeEventContainer.begin()),
|
||||
it_cur(TimeEventContainer.begin()),
|
||||
it_next(TimeEventContainer.begin()),
|
||||
it_end(TimeEventContainer.end()),
|
||||
pData(pValue)
|
||||
{
|
||||
if (it_start == it_end)
|
||||
*pValue = T();
|
||||
else
|
||||
++it_next;
|
||||
}
|
||||
virtual ~CTimeEventDecorator() {}
|
||||
|
||||
void SetData( T * pValue ) { pData = pValue; }
|
||||
|
||||
protected:
|
||||
//CTimeEventDecorator(CTimeEventDecorator<T>& ted, CParticleInstance * pFirstInstance, CParticleInstance * pInstance);
|
||||
CTimeEventDecorator(CTimeEventDecorator<T>& ted, CParticleInstance* pFirstInstance, CParticleInstance* pInstance)
|
||||
: it_start(ted.it_start),
|
||||
it_end(ted.it_end),
|
||||
it_cur(ted.it_cur),
|
||||
it_next(ted.it_next),
|
||||
pData((T*)( (unsigned char*)ted.pData - (DWORD)pFirstInstance + (DWORD)pInstance))
|
||||
{
|
||||
if (it_start == it_end)
|
||||
*pData = T();
|
||||
}
|
||||
virtual CBaseDecorator* __Clone(CParticleInstance* pFirstInstance, CParticleInstance* pInstance) { return new CTimeEventDecorator(*this, pFirstInstance, pInstance); }
|
||||
virtual void __Excute(const CDecoratorData & d)
|
||||
{
|
||||
if (it_start==it_end)
|
||||
{
|
||||
RemoveMe();
|
||||
}
|
||||
else if (it_cur->m_fTime>d.fTime)
|
||||
{
|
||||
*pData = it_cur->m_Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (it_next!=it_end && it_next->m_fTime<=d.fTime)
|
||||
++it_cur, ++it_next;
|
||||
if (it_next == it_end)
|
||||
{
|
||||
// setting value
|
||||
*pData = it_cur->m_Value;
|
||||
|
||||
RemoveMe();
|
||||
}
|
||||
else
|
||||
{
|
||||
float length = it_next->m_fTime - it_cur->m_fTime;
|
||||
//*pData = it_cur->m_Value + (it_next->m_Value - it_cur->m_Value)*(d.fTime-it_cur->m_fTime)/length;
|
||||
*pData = it_cur->m_Value*(1-(d.fTime-it_cur->m_fTime)/length) ;
|
||||
*pData += it_next->m_Value * ((d.fTime-it_cur->m_fTime)/length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typename TTimeEventContainerType::const_iterator it_start;
|
||||
typename TTimeEventContainerType::const_iterator it_end;
|
||||
typename TTimeEventContainerType::const_iterator it_cur;
|
||||
typename TTimeEventContainerType::const_iterator it_next;
|
||||
T * pData;
|
||||
};
|
||||
|
||||
typedef CTimeEventDecorator<float> CScaleValueDecorator;
|
||||
typedef CTimeEventDecorator<float> CColorValueDecorator;
|
||||
typedef CTimeEventDecorator<DWORDCOLOR> CColorAllDecorator;
|
||||
typedef CTimeEventDecorator<float> CAirResistanceValueDecorator;
|
||||
typedef CTimeEventDecorator<float> CGravityValueDecorator;
|
||||
typedef CTimeEventDecorator<float> CRotationSpeedValueDecorator;
|
||||
|
||||
class CTextureAnimationCWDecorator : public CBaseDecorator, public CPooledObject<CTextureAnimationCWDecorator>
|
||||
{
|
||||
public:
|
||||
CTextureAnimationCWDecorator(float fFrameTime, DWORD n, BYTE * pIdx) :n(n),pIdx(pIdx),fFrameTime(fFrameTime),fLastFrameTime(fFrameTime){}
|
||||
virtual ~CTextureAnimationCWDecorator(){}
|
||||
protected:
|
||||
virtual CBaseDecorator* __Clone(CParticleInstance* pfi, CParticleInstance* pi) { return new CTextureAnimationCWDecorator(fFrameTime,n,(BYTE*)((unsigned char*)pi+((BYTE*)pIdx-(BYTE*)pfi))); }
|
||||
virtual void __Excute(const CDecoratorData & d)
|
||||
{
|
||||
fLastFrameTime -= d.fElapsedTime;
|
||||
while (fLastFrameTime<0.0f)
|
||||
{
|
||||
fLastFrameTime += fFrameTime;
|
||||
if (++(*pIdx) >= n)
|
||||
*pIdx = 0;
|
||||
}
|
||||
}
|
||||
DWORD n;
|
||||
float fLastFrameTime;
|
||||
float fFrameTime;
|
||||
BYTE* pIdx;
|
||||
|
||||
};
|
||||
class CTextureAnimationCCWDecorator : public CBaseDecorator, public CPooledObject<CTextureAnimationCCWDecorator>
|
||||
{
|
||||
public:
|
||||
CTextureAnimationCCWDecorator(float fFrameTime, BYTE n, BYTE * pIdx) :n(n),pIdx(pIdx),fFrameTime(fFrameTime),fLastFrameTime(fFrameTime){}
|
||||
virtual ~CTextureAnimationCCWDecorator(){}
|
||||
protected:
|
||||
virtual CBaseDecorator* __Clone(CParticleInstance* pfi, CParticleInstance* pi) { return new CTextureAnimationCCWDecorator(fFrameTime,n,(BYTE*)((unsigned char*)pi+((BYTE*)pIdx-(BYTE*)pfi))); }
|
||||
virtual void __Excute(const CDecoratorData & d)
|
||||
{
|
||||
fLastFrameTime -= d.fElapsedTime;
|
||||
while (fLastFrameTime<0.0f)
|
||||
{
|
||||
fLastFrameTime += fFrameTime;
|
||||
|
||||
if (--(*pIdx) >= n && n != 0) // Because variable is unsigned..
|
||||
*pIdx = BYTE(n - 1);
|
||||
}
|
||||
}
|
||||
BYTE n;
|
||||
float fLastFrameTime;
|
||||
float fFrameTime;
|
||||
BYTE* pIdx;
|
||||
|
||||
};
|
||||
class CTextureAnimationRandomDecorator : public CBaseDecorator, public CPooledObject<CTextureAnimationRandomDecorator>
|
||||
{
|
||||
public:
|
||||
CTextureAnimationRandomDecorator(float fFrameTime, BYTE n, BYTE * pIdx) :n(n),pIdx(pIdx),fFrameTime(fFrameTime),fLastFrameTime(fFrameTime){}
|
||||
virtual ~CTextureAnimationRandomDecorator(){}
|
||||
protected:
|
||||
virtual CBaseDecorator* __Clone(CParticleInstance* pfi, CParticleInstance* pi) { return new CTextureAnimationRandomDecorator(fFrameTime,n,(BYTE*)((unsigned char*)pi+((BYTE*)pIdx-(BYTE*)pfi))); }
|
||||
virtual void __Excute(const CDecoratorData & d)
|
||||
{
|
||||
fLastFrameTime -= d.fElapsedTime;
|
||||
if (fLastFrameTime<0.0f && n!=0)
|
||||
{
|
||||
*pIdx = (BYTE)random_range(0,n-1);
|
||||
}
|
||||
while (fLastFrameTime<0.0f)
|
||||
fLastFrameTime += fFrameTime;
|
||||
}
|
||||
BYTE n;
|
||||
float fLastFrameTime;
|
||||
float fFrameTime;
|
||||
BYTE* pIdx;
|
||||
|
||||
};
|
||||
|
||||
class CAirResistanceDecorator : public CBaseDecorator, public CPooledObject<CAirResistanceDecorator>
|
||||
{
|
||||
public:
|
||||
CAirResistanceDecorator(){}
|
||||
virtual ~CAirResistanceDecorator(){}
|
||||
|
||||
protected:
|
||||
virtual void __Excute(const CDecoratorData & d);
|
||||
virtual CBaseDecorator* __Clone(CParticleInstance* pfi, CParticleInstance* pi);
|
||||
};
|
||||
|
||||
class CGravityDecorator : public CBaseDecorator, public CPooledObject<CGravityDecorator>
|
||||
{
|
||||
public:
|
||||
CGravityDecorator(){}
|
||||
virtual ~CGravityDecorator(){}
|
||||
protected:
|
||||
virtual void __Excute(const CDecoratorData& d);
|
||||
virtual CBaseDecorator* __Clone(CParticleInstance* pfi, CParticleInstance* pi);
|
||||
};
|
||||
|
||||
class CRotationDecorator : public CBaseDecorator, public CPooledObject<CRotationDecorator>
|
||||
{
|
||||
public:
|
||||
CRotationDecorator(){}
|
||||
virtual ~CRotationDecorator()
|
||||
{
|
||||
}
|
||||
protected:
|
||||
virtual void __Excute(const CDecoratorData& d);
|
||||
virtual CBaseDecorator* __Clone(CParticleInstance* pfi, CParticleInstance* pi) ;
|
||||
};
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
103
source-client/Srcs/Client/EffectLib/EmitterProperty.cpp
Normal file
103
source-client/Srcs/Client/EffectLib/EmitterProperty.cpp
Normal file
@ -0,0 +1,103 @@
|
||||
#include "StdAfx.h"
|
||||
#include "EmitterProperty.h"
|
||||
|
||||
BYTE CEmitterProperty::GetEmitterShape()
|
||||
{
|
||||
return m_byEmitterShape;
|
||||
}
|
||||
BYTE CEmitterProperty::GetEmitterAdvancedType()
|
||||
{
|
||||
return m_byEmitterAdvancedType;
|
||||
}
|
||||
BOOL CEmitterProperty::isEmitFromEdge()
|
||||
{
|
||||
return m_bEmitFromEdgeFlag;
|
||||
}
|
||||
|
||||
void CEmitterProperty::GetEmittingSize(float fTime, float * pfValue)
|
||||
{
|
||||
//GetTimeEventBlendValue<TTimeEventTableFloat, float>(fTime, m_TimeEventEmittingSize, pfValue);
|
||||
GetTimeEventBlendValue(fTime, m_TimeEventEmittingSize, pfValue);
|
||||
}
|
||||
void CEmitterProperty::GetEmittingAngularVelocity(float fTime, float * pfValue)
|
||||
{
|
||||
//GetTimeEventBlendValue<TTimeEventTableFloat, float>(fTime, m_TimeEventEmittingAngularVelocity, pfValue);
|
||||
GetTimeEventBlendValue(fTime, m_TimeEventEmittingAngularVelocity, pfValue);
|
||||
}
|
||||
void CEmitterProperty::GetEmittingDirectionX(float fTime, float * pfValue)
|
||||
{
|
||||
//GetTimeEventBlendValue<TTimeEventTableFloat, float>(fTime, m_TimeEventEmittingDirectionX, pfValue);
|
||||
GetTimeEventBlendValue(fTime, m_TimeEventEmittingDirectionX, pfValue);
|
||||
}
|
||||
void CEmitterProperty::GetEmittingDirectionY(float fTime, float * pfValue)
|
||||
{
|
||||
//GetTimeEventBlendValue<TTimeEventTableFloat, float>(fTime, m_TimeEventEmittingDirectionY, pfValue);
|
||||
GetTimeEventBlendValue(fTime, m_TimeEventEmittingDirectionY, pfValue);
|
||||
}
|
||||
void CEmitterProperty::GetEmittingDirectionZ(float fTime, float * pfValue)
|
||||
{
|
||||
//GetTimeEventBlendValue<TTimeEventTableFloat, float>(fTime, m_TimeEventEmittingDirectionZ, pfValue);
|
||||
GetTimeEventBlendValue(fTime, m_TimeEventEmittingDirectionZ, pfValue);
|
||||
}
|
||||
void CEmitterProperty::GetEmittingVelocity(float fTime, float * pfValue)
|
||||
{
|
||||
//GetTimeEventBlendValue<TTimeEventTableFloat, float>(fTime, m_TimeEventEmittingVelocity, pfValue);
|
||||
GetTimeEventBlendValue(fTime, m_TimeEventEmittingVelocity, pfValue);
|
||||
}
|
||||
void CEmitterProperty::GetEmissionCountPerSecond(float fTime, float * pfValue)
|
||||
{
|
||||
//GetTimeEventBlendValue<TTimeEventTableFloat, float>(fTime, m_TimeEventEmissionCountPerSecond, pfValue);
|
||||
GetTimeEventBlendValue(fTime, m_TimeEventEmissionCountPerSecond, pfValue);
|
||||
}
|
||||
void CEmitterProperty::GetParticleLifeTime(float fTime, float * pfValue)
|
||||
{
|
||||
//GetTimeEventBlendValue<TTimeEventTableFloat, float>(fTime, m_TimeEventLifeTime, pfValue);
|
||||
GetTimeEventBlendValue(fTime, m_TimeEventLifeTime, pfValue);
|
||||
}
|
||||
void CEmitterProperty::GetParticleSizeX(float fTime, float * pfValue)
|
||||
{
|
||||
//GetTimeEventBlendValue<TTimeEventTableFloat, float>(fTime, m_TimeEventSizeX, pfValue);
|
||||
GetTimeEventBlendValue(fTime, m_TimeEventSizeX, pfValue);
|
||||
}
|
||||
void CEmitterProperty::GetParticleSizeY(float fTime, float * pfValue)
|
||||
{
|
||||
//GetTimeEventBlendValue<TTimeEventTableFloat, float>(fTime, m_TimeEventSizeY, pfValue);
|
||||
GetTimeEventBlendValue(fTime, m_TimeEventSizeY, pfValue);
|
||||
}
|
||||
|
||||
void CEmitterProperty::Clear()
|
||||
{
|
||||
m_dwMaxEmissionCount = 0;
|
||||
|
||||
m_fCycleLength = 0.0f;
|
||||
m_bCycleLoopFlag = FALSE;
|
||||
m_iLoopCount = 0;
|
||||
|
||||
m_byEmitterShape = EMITTER_SHAPE_POINT;
|
||||
m_byEmitterAdvancedType = EMITTER_ADVANCED_TYPE_FREE;
|
||||
m_bEmitFromEdgeFlag = FALSE;
|
||||
m_v3EmittingSize = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
|
||||
m_fEmittingRadius = 0.0f;
|
||||
|
||||
m_v3EmittingDirection = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
m_TimeEventEmittingSize.clear();
|
||||
m_TimeEventEmittingDirectionX.clear();
|
||||
m_TimeEventEmittingDirectionY.clear();
|
||||
m_TimeEventEmittingDirectionZ.clear();
|
||||
m_TimeEventEmittingVelocity.clear();
|
||||
m_TimeEventEmissionCountPerSecond.clear();
|
||||
m_TimeEventLifeTime.clear();
|
||||
m_TimeEventSizeX.clear();
|
||||
m_TimeEventSizeY.clear();
|
||||
m_TimeEventEmittingAngularVelocity.clear();
|
||||
}
|
||||
|
||||
CEmitterProperty::CEmitterProperty()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
CEmitterProperty::~CEmitterProperty()
|
||||
{
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
95
source-client/Srcs/Client/EffectLib/EmitterProperty.h
Normal file
95
source-client/Srcs/Client/EffectLib/EmitterProperty.h
Normal file
@ -0,0 +1,95 @@
|
||||
#pragma once
|
||||
|
||||
#include "Type.h"
|
||||
|
||||
class CEmitterProperty
|
||||
{
|
||||
friend class CParticleSystemData;
|
||||
friend class CParticleSystemInstance;
|
||||
public:
|
||||
enum
|
||||
{
|
||||
EMITTER_SHAPE_POINT,
|
||||
EMITTER_SHAPE_ELLIPSE,
|
||||
EMITTER_SHAPE_SQUARE,
|
||||
EMITTER_SHAPE_SPHERE,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
EMITTER_ADVANCED_TYPE_FREE,
|
||||
EMITTER_ADVANCED_TYPE_OUTER,
|
||||
EMITTER_ADVANCED_TYPE_INNER,
|
||||
};
|
||||
|
||||
public:
|
||||
CEmitterProperty();
|
||||
virtual ~CEmitterProperty();
|
||||
|
||||
void Clear();
|
||||
|
||||
DWORD GetMaxEmissionCount()
|
||||
{
|
||||
return m_dwMaxEmissionCount;
|
||||
}
|
||||
|
||||
float GetCycleLength()
|
||||
{
|
||||
return m_fCycleLength;
|
||||
}
|
||||
|
||||
BOOL isCycleLoop()
|
||||
{
|
||||
return m_bCycleLoopFlag;
|
||||
}
|
||||
|
||||
int GetLoopCount()
|
||||
{
|
||||
return m_iLoopCount;
|
||||
}
|
||||
|
||||
BYTE GetEmitterShape();
|
||||
BYTE GetEmitterAdvancedType();
|
||||
BOOL isEmitFromEdge();
|
||||
|
||||
void GetEmittingSize(float fTime, float * pfValue);
|
||||
void GetEmittingAngularVelocity(float fTime, float * pfValue);
|
||||
|
||||
void GetEmittingDirectionX(float fTime, float * pfValue);
|
||||
void GetEmittingDirectionY(float fTime, float * pfValue);
|
||||
void GetEmittingDirectionZ(float fTime, float * pfValue);
|
||||
void GetEmittingVelocity(float fTime, float * pfValue);
|
||||
void GetEmissionCountPerSecond(float fTime, float * pfValue);
|
||||
void GetParticleLifeTime(float fTime, float * pfValue);
|
||||
void GetParticleSizeX(float fTime, float * pfValue);
|
||||
void GetParticleSizeY(float fTime, float * pfValue);
|
||||
|
||||
/////
|
||||
|
||||
DWORD m_dwMaxEmissionCount;
|
||||
|
||||
float m_fCycleLength;
|
||||
BOOL m_bCycleLoopFlag;
|
||||
int m_iLoopCount;
|
||||
|
||||
BYTE m_byEmitterShape;
|
||||
BYTE m_byEmitterAdvancedType;
|
||||
BOOL m_bEmitFromEdgeFlag;
|
||||
D3DXVECTOR3 m_v3EmittingSize;
|
||||
float m_fEmittingRadius;
|
||||
|
||||
D3DXVECTOR3 m_v3EmittingDirection;
|
||||
|
||||
//TTimeEventTableFloat m_TimeEventEmittingRadius;
|
||||
TTimeEventTableFloat m_TimeEventEmittingSize;
|
||||
TTimeEventTableFloat m_TimeEventEmittingAngularVelocity;
|
||||
TTimeEventTableFloat m_TimeEventEmittingDirectionX;
|
||||
TTimeEventTableFloat m_TimeEventEmittingDirectionY;
|
||||
TTimeEventTableFloat m_TimeEventEmittingDirectionZ;
|
||||
TTimeEventTableFloat m_TimeEventEmittingVelocity;
|
||||
TTimeEventTableFloat m_TimeEventEmissionCountPerSecond;
|
||||
TTimeEventTableFloat m_TimeEventLifeTime;
|
||||
TTimeEventTableFloat m_TimeEventSizeX;
|
||||
TTimeEventTableFloat m_TimeEventSizeY;
|
||||
};
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
107
source-client/Srcs/Client/EffectLib/FrameController.cpp
Normal file
107
source-client/Srcs/Client/EffectLib/FrameController.cpp
Normal file
@ -0,0 +1,107 @@
|
||||
#include "StdAfx.h"
|
||||
#include "FrameController.h"
|
||||
|
||||
void CFrameController::Update(float fElapsedTime)
|
||||
{
|
||||
m_fLastFrameTime -= fElapsedTime;
|
||||
|
||||
for (int i = 0; i < 20; ++i)
|
||||
{
|
||||
if (m_fLastFrameTime < 0.0f)
|
||||
{
|
||||
m_fLastFrameTime += m_fFrameTime;
|
||||
++m_dwcurFrame;
|
||||
|
||||
if (m_dwcurFrame >= m_dwMaxFrame)
|
||||
{
|
||||
if (m_isLoop && --m_iLoopCount!=0)
|
||||
{
|
||||
if (m_iLoopCount<0)
|
||||
m_iLoopCount = 0;
|
||||
m_dwcurFrame = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_iLoopCount = 1;
|
||||
m_dwcurFrame = 0;
|
||||
m_isActive = FALSE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CFrameController::SetCurrentFrame(DWORD dwFrame)
|
||||
{
|
||||
m_dwcurFrame = dwFrame;
|
||||
}
|
||||
|
||||
BYTE CFrameController::GetCurrentFrame()
|
||||
{
|
||||
return m_dwcurFrame;
|
||||
}
|
||||
|
||||
void CFrameController::SetMaxFrame(DWORD dwMaxFrame)
|
||||
{
|
||||
m_dwMaxFrame = dwMaxFrame;
|
||||
}
|
||||
void CFrameController::SetFrameTime(float fTime)
|
||||
{
|
||||
m_fFrameTime = fTime;
|
||||
m_fLastFrameTime = fTime;
|
||||
}
|
||||
void CFrameController::SetStartFrame(DWORD dwStartFrame)
|
||||
{
|
||||
m_dwStartFrame = dwStartFrame;
|
||||
}
|
||||
|
||||
void CFrameController::SetLoopFlag(BOOL bFlag)
|
||||
{
|
||||
m_isLoop = bFlag;
|
||||
}
|
||||
|
||||
void CFrameController::SetLoopCount(int iLoopCount)
|
||||
{
|
||||
m_iLoopCount = iLoopCount;
|
||||
}
|
||||
|
||||
void CFrameController::SetActive(BOOL bFlag)
|
||||
{
|
||||
m_isActive = bFlag;
|
||||
}
|
||||
|
||||
BOOL CFrameController::isActive(DWORD dwMainFrame)
|
||||
{
|
||||
if (dwMainFrame < m_dwStartFrame)
|
||||
return FALSE;
|
||||
|
||||
return m_isActive;
|
||||
}
|
||||
|
||||
void CFrameController::Clear()
|
||||
{
|
||||
m_isActive = TRUE;
|
||||
m_dwcurFrame = 0;
|
||||
m_fLastFrameTime = 0.0f;
|
||||
}
|
||||
|
||||
CFrameController::CFrameController()
|
||||
{
|
||||
m_isActive = TRUE;
|
||||
m_dwcurFrame = 0;
|
||||
m_fLastFrameTime = 0.0f;
|
||||
|
||||
m_isLoop = FALSE;
|
||||
m_dwMaxFrame = 0;
|
||||
m_fFrameTime = 0.0f;
|
||||
m_dwStartFrame = 0;
|
||||
}
|
||||
CFrameController::~CFrameController()
|
||||
{
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
39
source-client/Srcs/Client/EffectLib/FrameController.h
Normal file
39
source-client/Srcs/Client/EffectLib/FrameController.h
Normal file
@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
class CFrameController
|
||||
{
|
||||
public:
|
||||
CFrameController();
|
||||
virtual ~CFrameController();
|
||||
|
||||
void Clear();
|
||||
|
||||
void Update(float fElapsedTime);
|
||||
|
||||
void SetCurrentFrame(DWORD dwFrame);
|
||||
BYTE GetCurrentFrame();
|
||||
|
||||
void SetMaxFrame(DWORD dwMaxFrame);
|
||||
void SetFrameTime(float fTime);
|
||||
void SetStartFrame(DWORD dwStartFrame);
|
||||
void SetLoopFlag(BOOL bFlag);
|
||||
void SetLoopCount(int iLoopCount);
|
||||
|
||||
void SetActive(BOOL bFlag);
|
||||
BOOL isActive(DWORD dwMainFrame = 0);
|
||||
|
||||
protected:
|
||||
// Dynamic
|
||||
BOOL m_isActive;
|
||||
DWORD m_dwcurFrame;
|
||||
float m_fLastFrameTime;
|
||||
|
||||
int m_iLoopCount;
|
||||
|
||||
// Static
|
||||
BOOL m_isLoop;
|
||||
DWORD m_dwMaxFrame;
|
||||
float m_fFrameTime;
|
||||
DWORD m_dwStartFrame;
|
||||
};
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
505
source-client/Srcs/Client/EffectLib/ParticleInstance.cpp
Normal file
505
source-client/Srcs/Client/EffectLib/ParticleInstance.cpp
Normal file
@ -0,0 +1,505 @@
|
||||
#include "StdAfx.h"
|
||||
#include "ParticleInstance.h"
|
||||
#include "ParticleProperty.h"
|
||||
|
||||
#include "../eterBase/Random.h"
|
||||
#include "../eterLib/Camera.h"
|
||||
#include "../eterLib/StateManager.h"
|
||||
|
||||
CDynamicPool<CParticleInstance> CParticleInstance::ms_kPool;
|
||||
|
||||
using namespace NEffectUpdateDecorator;
|
||||
|
||||
void CParticleInstance::DestroySystem()
|
||||
{
|
||||
ms_kPool.Destroy();
|
||||
}
|
||||
|
||||
CParticleInstance* CParticleInstance::New()
|
||||
{
|
||||
return ms_kPool.Alloc();
|
||||
}
|
||||
|
||||
void CParticleInstance::DeleteThis()
|
||||
{
|
||||
Destroy();
|
||||
|
||||
ms_kPool.Free(this);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//CDynamicPool<CRayParticleInstance> CRayParticleInstance::ms_kPool;
|
||||
|
||||
/*void CRayParticleInstance::DestroySystem()
|
||||
{
|
||||
ms_kPool.Destroy();
|
||||
}
|
||||
|
||||
CRayParticleInstance* CRayParticleInstance::New()
|
||||
{
|
||||
return ms_kPool.Alloc();
|
||||
}
|
||||
|
||||
void CRayParticleInstance::DeleteThis()
|
||||
{
|
||||
#ifdef RAY_TO_AFTERIMAGE
|
||||
m_PositionList.clear();
|
||||
#else
|
||||
m_bStart = false;
|
||||
#endif
|
||||
ms_kPool.Free(this);
|
||||
}
|
||||
*/
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
float CParticleInstance::GetRadiusApproximation()
|
||||
{
|
||||
return m_v2HalfSize.y*m_v2Scale.y + m_v2HalfSize.x*m_v2Scale.x;
|
||||
}
|
||||
/*
|
||||
D3DXVECTOR3 CBaseParticleInstance::GetCenterApproximation()
|
||||
{
|
||||
return D3DXVECTOR3(
|
||||
m_v3Position.x + mc_pmatLocal._41,
|
||||
m_v3Position.y + mc_pmatLocal._42,
|
||||
m_v3Position.z + mc_pmatLocal._43
|
||||
);
|
||||
}*/
|
||||
|
||||
BOOL CParticleInstance::Update(float fElapsedTime, float fAngle)
|
||||
{
|
||||
m_fLastLifeTime -= fElapsedTime;
|
||||
if (m_fLastLifeTime < 0.0f)
|
||||
return FALSE;
|
||||
|
||||
float fLifePercentage = (m_fLifeTime - m_fLastLifeTime) / m_fLifeTime;
|
||||
|
||||
m_pDecorator->Excute(CDecoratorData(fLifePercentage,fElapsedTime,this));
|
||||
|
||||
m_v3LastPosition = m_v3Position;
|
||||
m_v3Position += m_v3Velocity * fElapsedTime;
|
||||
|
||||
if (fAngle)
|
||||
{
|
||||
if (m_pParticleProperty->m_bAttachFlag)
|
||||
{
|
||||
float fCos, fSin;
|
||||
fAngle = D3DXToRadian(fAngle);
|
||||
fCos = cos(fAngle);
|
||||
fSin = sin(fAngle);
|
||||
|
||||
float rx = m_v3Position.x - m_v3StartPosition.x;
|
||||
float ry = m_v3Position.y - m_v3StartPosition.y;
|
||||
|
||||
m_v3Position.x = fCos * rx + fSin * ry + m_v3StartPosition.x;
|
||||
m_v3Position.y = - fSin * rx + fCos * ry + m_v3StartPosition.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
D3DXQUATERNION q,qc;
|
||||
D3DXQuaternionRotationAxis(&q,&m_pParticleProperty->m_v3ZAxis,D3DXToRadian(fAngle));
|
||||
D3DXQuaternionConjugate(&qc,&q);
|
||||
|
||||
D3DXQUATERNION qr(
|
||||
m_v3Position.x-m_v3StartPosition.x,
|
||||
m_v3Position.y-m_v3StartPosition.y,
|
||||
m_v3Position.z-m_v3StartPosition.z,
|
||||
0.0f);
|
||||
D3DXQuaternionMultiply(&qr,&q,&qr);
|
||||
D3DXQuaternionMultiply(&qr,&qr,&qc);
|
||||
|
||||
m_v3Position.x = qr.x;
|
||||
m_v3Position.y = qr.y;
|
||||
m_v3Position.z = qr.z;
|
||||
|
||||
m_v3Position += m_v3StartPosition;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CParticleInstance::Transform(const D3DXMATRIX * c_matLocal)
|
||||
{
|
||||
#ifdef WORLD_EDITOR
|
||||
STATEMANAGER.SetRenderState(D3DRS_TEXTUREFACTOR, m_Color);
|
||||
#else
|
||||
STATEMANAGER.SetRenderState(D3DRS_TEXTUREFACTOR, m_dcColor);
|
||||
#endif
|
||||
|
||||
/////
|
||||
|
||||
D3DXVECTOR3 v3Up;
|
||||
D3DXVECTOR3 v3Cross;
|
||||
|
||||
if (!m_pParticleProperty->m_bStretchFlag)
|
||||
{
|
||||
CCamera * pCurrentCamera = CCameraManager::Instance().GetCurrentCamera();
|
||||
const D3DXVECTOR3 & c_rv3Up = pCurrentCamera->GetUp();
|
||||
const D3DXVECTOR3 & c_rv3Cross = pCurrentCamera->GetCross();
|
||||
|
||||
D3DXVECTOR3 v3Rotation;
|
||||
|
||||
switch(m_pParticleProperty->m_byBillboardType) {
|
||||
case BILLBOARD_TYPE_LIE:
|
||||
{
|
||||
float fCos = cosf(D3DXToRadian(m_fRotation)), fSin = sinf(D3DXToRadian(m_fRotation));
|
||||
v3Up.x = fCos;
|
||||
v3Up.y = -fSin;
|
||||
v3Up.z = 0;
|
||||
v3Cross.x = fSin;
|
||||
v3Cross.y = fCos;
|
||||
v3Cross.z = 0;
|
||||
}
|
||||
break;
|
||||
case BILLBOARD_TYPE_2FACE:
|
||||
case BILLBOARD_TYPE_3FACE:
|
||||
// using setting with y, and local rotation at render
|
||||
case BILLBOARD_TYPE_Y:
|
||||
{
|
||||
v3Up = D3DXVECTOR3(0.0f,0.0f,1.0f);
|
||||
//v3Up = D3DXVECTOR3(cosf(D3DXToRadian(m_fRotation)),0.0f,-sinf(D3DXToRadian(m_fRotation)));
|
||||
const D3DXVECTOR3 & c_rv3View = pCurrentCamera->GetView();
|
||||
if (v3Up.x * c_rv3View.y - v3Up.y * c_rv3View.x<0)
|
||||
v3Up*=-1;
|
||||
auto val = D3DXVECTOR3(c_rv3View.x,c_rv3View.y,0);
|
||||
D3DXVec3Cross(&v3Cross, &v3Up, &val);
|
||||
D3DXVec3Normalize(&v3Cross, &v3Cross);
|
||||
|
||||
if (m_fRotation)
|
||||
{
|
||||
float fCos = -sinf(D3DXToRadian(m_fRotation)); // + 90
|
||||
float fSin = cosf(D3DXToRadian(m_fRotation));
|
||||
|
||||
D3DXVECTOR3 v3Temp = v3Up * fCos - v3Cross * fSin;
|
||||
v3Cross = v3Cross * fCos + v3Up * fSin;
|
||||
v3Up = v3Temp;
|
||||
}
|
||||
|
||||
//D3DXVECTOR3 v3Rotation;
|
||||
//D3DXVec3Cross(&v3Rotation, &v3Up, &v3Cross);
|
||||
|
||||
}
|
||||
break;
|
||||
case BILLBOARD_TYPE_ALL:
|
||||
default:
|
||||
{
|
||||
if (m_fRotation==0.0f)
|
||||
{
|
||||
v3Up = -c_rv3Cross;
|
||||
v3Cross = c_rv3Up;
|
||||
}
|
||||
else
|
||||
{
|
||||
const D3DXVECTOR3 & c_rv3View = pCurrentCamera->GetView();
|
||||
D3DXQUATERNION q,qc;
|
||||
D3DXQuaternionRotationAxis(&q, &c_rv3View, D3DXToRadian(m_fRotation));
|
||||
D3DXQuaternionConjugate(&qc, &q);
|
||||
|
||||
{
|
||||
D3DXQUATERNION qr(-c_rv3Cross.x, -c_rv3Cross.y, -c_rv3Cross.z, 0);
|
||||
D3DXQuaternionMultiply(&qr,&qc,&qr);
|
||||
D3DXQuaternionMultiply(&qr,&qr,&q);
|
||||
v3Up.x = qr.x;
|
||||
v3Up.y = qr.y;
|
||||
v3Up.z = qr.z;
|
||||
}
|
||||
{
|
||||
D3DXQUATERNION qr(c_rv3Up.x, c_rv3Up.y, c_rv3Up.z, 0);
|
||||
D3DXQuaternionMultiply(&qr,&qc,&qr);
|
||||
D3DXQuaternionMultiply(&qr,&qr,&q);
|
||||
v3Cross.x = qr.x;
|
||||
v3Cross.y = qr.y;
|
||||
v3Cross.z = qr.z;
|
||||
}
|
||||
|
||||
}
|
||||
//D3DXMATRIX matRotation;
|
||||
|
||||
//D3DXMatrixRotationAxis(&matRotation, &c_rv3View, D3DXToRadian(m_fRotation));
|
||||
|
||||
//D3DXVec3TransformCoord(&v3Up, &(-c_rv3Cross), &matRotation);
|
||||
//D3DXVec3TransformCoord(&v3Cross, &c_rv3Up, &matRotation);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
v3Up = m_v3Position - m_v3LastPosition;
|
||||
|
||||
if (c_matLocal)
|
||||
{
|
||||
//if (!m_pParticleProperty->m_bAttachFlag)
|
||||
D3DXVec3TransformNormal(&v3Up, &v3Up, c_matLocal);
|
||||
}
|
||||
|
||||
float length = D3DXVec3Length(&v3Up);
|
||||
if (length == 0.0f)
|
||||
{
|
||||
v3Up = D3DXVECTOR3(0.0f,0.0f,1.0f);
|
||||
}
|
||||
else
|
||||
v3Up *=(1+log(1+length))/length;
|
||||
|
||||
CCamera * pCurrentCamera = CCameraManager::Instance().GetCurrentCamera();
|
||||
const D3DXVECTOR3 & c_rv3View = pCurrentCamera->GetView();
|
||||
D3DXVec3Cross(&v3Cross, &v3Up, &c_rv3View);
|
||||
D3DXVec3Normalize(&v3Cross, &v3Cross);
|
||||
|
||||
}
|
||||
|
||||
v3Cross = -(m_v2HalfSize.x*m_v2Scale.x) * v3Cross;
|
||||
v3Up = (m_v2HalfSize.y*m_v2Scale.y) * v3Up;
|
||||
|
||||
if (c_matLocal && m_pParticleProperty->m_bAttachFlag)
|
||||
{
|
||||
D3DXVECTOR3 v3Position;
|
||||
D3DXVec3TransformCoord(&v3Position, &m_v3Position, c_matLocal);
|
||||
m_ParticleMesh[0].position = v3Position - v3Up + v3Cross;
|
||||
m_ParticleMesh[1].position = v3Position - v3Up - v3Cross;
|
||||
m_ParticleMesh[2].position = v3Position + v3Up + v3Cross;
|
||||
m_ParticleMesh[3].position = v3Position + v3Up - v3Cross;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ParticleMesh[0].position = m_v3Position - v3Up + v3Cross;
|
||||
m_ParticleMesh[1].position = m_v3Position - v3Up - v3Cross;
|
||||
m_ParticleMesh[2].position = m_v3Position + v3Up + v3Cross;
|
||||
m_ParticleMesh[3].position = m_v3Position + v3Up - v3Cross;
|
||||
}
|
||||
}
|
||||
|
||||
void CParticleInstance::Transform(const D3DXMATRIX * c_matLocal, const float c_fZRotation)
|
||||
{
|
||||
#ifdef WORLD_EDITOR
|
||||
STATEMANAGER.SetRenderState(D3DRS_TEXTUREFACTOR, m_Color);
|
||||
#else
|
||||
STATEMANAGER.SetRenderState(D3DRS_TEXTUREFACTOR, (DWORD)m_dcColor);
|
||||
#endif
|
||||
|
||||
/////
|
||||
|
||||
D3DXVECTOR3 v3Up;
|
||||
D3DXVECTOR3 v3Cross;
|
||||
|
||||
if (!m_pParticleProperty->m_bStretchFlag)
|
||||
{
|
||||
CCamera * pCurrentCamera = CCameraManager::Instance().GetCurrentCamera();
|
||||
const D3DXVECTOR3 & c_rv3Up = pCurrentCamera->GetUp();
|
||||
const D3DXVECTOR3 & c_rv3Cross = pCurrentCamera->GetCross();
|
||||
|
||||
D3DXVECTOR3 v3Rotation;
|
||||
|
||||
switch(m_pParticleProperty->m_byBillboardType) {
|
||||
case BILLBOARD_TYPE_LIE:
|
||||
{
|
||||
float fCos = cosf(D3DXToRadian(m_fRotation)), fSin = sinf(D3DXToRadian(m_fRotation));
|
||||
v3Up.x = fCos;
|
||||
v3Up.y = -fSin;
|
||||
v3Up.z = 0;
|
||||
|
||||
v3Cross.x = fSin;
|
||||
v3Cross.y = fCos;
|
||||
v3Cross.z = 0;
|
||||
}
|
||||
break;
|
||||
case BILLBOARD_TYPE_2FACE:
|
||||
case BILLBOARD_TYPE_3FACE:
|
||||
// using setting with y, and local rotation at render
|
||||
case BILLBOARD_TYPE_Y:
|
||||
{
|
||||
v3Up = D3DXVECTOR3(0.0f,0.0f,1.0f);
|
||||
//v3Up = D3DXVECTOR3(cosf(D3DXToRadian(m_fRotation)),0.0f,-sinf(D3DXToRadian(m_fRotation)));
|
||||
const D3DXVECTOR3 & c_rv3View = pCurrentCamera->GetView();
|
||||
if (v3Up.x * c_rv3View.y - v3Up.y * c_rv3View.x<0)
|
||||
v3Up*=-1;
|
||||
auto val = D3DXVECTOR3(c_rv3View.x,c_rv3View.y,0);
|
||||
D3DXVec3Cross(&v3Cross, &v3Up, &val);
|
||||
D3DXVec3Normalize(&v3Cross, &v3Cross);
|
||||
|
||||
if (m_fRotation)
|
||||
{
|
||||
float fCos = -sinf(D3DXToRadian(m_fRotation)); // + 90
|
||||
float fSin = cosf(D3DXToRadian(m_fRotation));
|
||||
|
||||
D3DXVECTOR3 v3Temp = v3Up * fCos - v3Cross * fSin;
|
||||
v3Cross = v3Cross * fCos + v3Up * fSin;
|
||||
v3Up = v3Temp;
|
||||
}
|
||||
|
||||
//D3DXVECTOR3 v3Rotation;
|
||||
//D3DXVec3Cross(&v3Rotation, &v3Up, &v3Cross);
|
||||
|
||||
}
|
||||
break;
|
||||
case BILLBOARD_TYPE_ALL:
|
||||
default:
|
||||
{
|
||||
if (m_fRotation==0.0f)
|
||||
{
|
||||
v3Up = -c_rv3Cross;
|
||||
v3Cross = c_rv3Up;
|
||||
}
|
||||
else
|
||||
{
|
||||
const D3DXVECTOR3 & c_rv3View = pCurrentCamera->GetView();
|
||||
D3DXMATRIX matRotation;
|
||||
|
||||
D3DXMatrixRotationAxis(&matRotation, &c_rv3View, D3DXToRadian(m_fRotation));
|
||||
auto val = (-c_rv3Cross);
|
||||
D3DXVec3TransformCoord(&v3Up, &val, &matRotation);
|
||||
D3DXVec3TransformCoord(&v3Cross, &c_rv3Up, &matRotation);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
v3Up = m_v3Position - m_v3LastPosition;
|
||||
|
||||
if (c_matLocal)
|
||||
{
|
||||
//if (!m_pParticleProperty->m_bAttachFlag)
|
||||
D3DXVec3TransformNormal(&v3Up, &v3Up, c_matLocal);
|
||||
}
|
||||
|
||||
float length = D3DXVec3Length(&v3Up);
|
||||
if (length == 0.0f)
|
||||
{
|
||||
v3Up = D3DXVECTOR3(0.0f,0.0f,1.0f);
|
||||
}
|
||||
else
|
||||
v3Up *=(1+log(1+length))/length;
|
||||
//D3DXVec3Normalize(&v3Up,&v3Up);
|
||||
//v3Up *= 1+log(1+length);
|
||||
|
||||
CCamera * pCurrentCamera = CCameraManager::Instance().GetCurrentCamera();
|
||||
const D3DXVECTOR3 & c_rv3View = pCurrentCamera->GetView();
|
||||
D3DXVec3Cross(&v3Cross, &v3Up, &c_rv3View);
|
||||
D3DXVec3Normalize(&v3Cross, &v3Cross);
|
||||
|
||||
}
|
||||
|
||||
if (c_fZRotation)
|
||||
{
|
||||
float x, y;
|
||||
float fCos = cosf(c_fZRotation);
|
||||
float fSin = sinf(c_fZRotation);
|
||||
|
||||
x = v3Up.x;
|
||||
y = v3Up.y;
|
||||
v3Up.x = x * fCos - y * fSin;
|
||||
v3Up.y = y * fCos + x * fSin;
|
||||
|
||||
x = v3Cross.x;
|
||||
y = v3Cross.y;
|
||||
v3Cross.x = x * fCos - y * fSin;
|
||||
v3Cross.y = y * fCos + x * fSin;
|
||||
}
|
||||
|
||||
v3Cross = -(m_v2HalfSize.x*m_v2Scale.x) * v3Cross;
|
||||
v3Up = (m_v2HalfSize.y*m_v2Scale.y) * v3Up;
|
||||
|
||||
if (c_matLocal && m_pParticleProperty->m_bAttachFlag)
|
||||
{
|
||||
D3DXVECTOR3 v3Position;
|
||||
D3DXVec3TransformCoord(&v3Position, &m_v3Position, c_matLocal);
|
||||
m_ParticleMesh[0].position = v3Position - v3Up + v3Cross;
|
||||
m_ParticleMesh[1].position = v3Position - v3Up - v3Cross;
|
||||
m_ParticleMesh[2].position = v3Position + v3Up + v3Cross;
|
||||
m_ParticleMesh[3].position = v3Position + v3Up - v3Cross;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ParticleMesh[0].position = m_v3Position - v3Up + v3Cross;
|
||||
m_ParticleMesh[1].position = m_v3Position - v3Up - v3Cross;
|
||||
m_ParticleMesh[2].position = m_v3Position + v3Up + v3Cross;
|
||||
m_ParticleMesh[3].position = m_v3Position + v3Up - v3Cross;
|
||||
}
|
||||
}
|
||||
|
||||
void CParticleInstance::Destroy()
|
||||
{
|
||||
if (m_pDecorator)
|
||||
m_pDecorator->DeleteThis();
|
||||
|
||||
__Initialize();
|
||||
}
|
||||
|
||||
void CParticleInstance::__Initialize()
|
||||
{
|
||||
//*
|
||||
m_pDecorator=NULL;
|
||||
|
||||
m_v3Position = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
|
||||
m_v3LastPosition = m_v3Position;
|
||||
m_v3Velocity = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
m_v2Scale = D3DXVECTOR2(1.0f, 1.0f);
|
||||
#ifdef WORLD_EDITOR
|
||||
m_Color = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
#else
|
||||
m_dcColor.m_dwColor = 0xffffffff;
|
||||
#endif
|
||||
|
||||
m_byFrameIndex = 0;
|
||||
m_ParticleMesh[0].texCoord = D3DXVECTOR2(0.0f, 1.0f);
|
||||
m_ParticleMesh[1].texCoord = D3DXVECTOR2(0.0f, 0.0f);
|
||||
m_ParticleMesh[2].texCoord = D3DXVECTOR2(1.0f, 1.0f);
|
||||
m_ParticleMesh[3].texCoord = D3DXVECTOR2(1.0f, 0.0f);
|
||||
}
|
||||
|
||||
CParticleInstance::CParticleInstance()
|
||||
{
|
||||
__Initialize();
|
||||
}
|
||||
|
||||
CParticleInstance::~CParticleInstance()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
/*CRayParticleInstance::CRayParticleInstance()
|
||||
{
|
||||
#ifdef RAY_TO_AFTERIMAGE
|
||||
int i;
|
||||
for(i=0;i<RAY_VERTEX_COUNT*2;i+=2)
|
||||
{
|
||||
m_ParticleMesh[i].texCoord = D3DXVECTOR2(i+0.0f, 1.0f);
|
||||
m_ParticleMesh[i+1].texCoord = D3DXVECTOR2(i+1.0f, 0.0f);
|
||||
}
|
||||
#else
|
||||
m_ParticleMesh[0].texCoord = D3DXVECTOR2(0.0f, 1.0f);
|
||||
m_ParticleMesh[1].texCoord = D3DXVECTOR2(0.0f, 0.0f);
|
||||
m_ParticleMesh[2].texCoord = D3DXVECTOR2(0.5f, 1.0f);
|
||||
m_ParticleMesh[3].texCoord = D3DXVECTOR2(0.5f, 0.0f);
|
||||
m_ParticleMesh[4].texCoord = D3DXVECTOR2(1.0f, 1.0f);
|
||||
m_ParticleMesh[5].texCoord = D3DXVECTOR2(1.0f, 0.0f);
|
||||
|
||||
m_bStart = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
CRayParticleInstance::~CRayParticleInstance()
|
||||
{
|
||||
}*/
|
||||
|
||||
TPTVertex * CParticleInstance::GetParticleMeshPointer()
|
||||
{
|
||||
return m_ParticleMesh;
|
||||
}
|
||||
|
||||
/*TPTVertex * CRayParticleInstance::GetParticleMeshPointer()
|
||||
{
|
||||
return m_ParticleMesh;
|
||||
}
|
||||
|
||||
void CRayParticleInstance::Transform(const D3DXMATRIX * c_matLocal, const float c_fZRotation)
|
||||
{
|
||||
assert(false && "NOT_REACHED");
|
||||
}*/
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
91
source-client/Srcs/Client/EffectLib/ParticleInstance.h
Normal file
91
source-client/Srcs/Client/EffectLib/ParticleInstance.h
Normal file
@ -0,0 +1,91 @@
|
||||
#pragma once
|
||||
|
||||
#include "../eterlib/GrpBase.h"
|
||||
#include "../eterLib/Pool.h"
|
||||
#include "EffectUpdateDecorator.h"
|
||||
class CParticleProperty;
|
||||
class CEmitterProperty;
|
||||
|
||||
class CParticleInstance
|
||||
{
|
||||
friend class CParticleSystemData;
|
||||
friend class CParticleSystemInstance;
|
||||
|
||||
friend class NEffectUpdateDecorator::CBaseDecorator;
|
||||
friend class NEffectUpdateDecorator::CAirResistanceDecorator;
|
||||
friend class NEffectUpdateDecorator::CGravityDecorator;
|
||||
friend class NEffectUpdateDecorator::CRotationDecorator;
|
||||
|
||||
public:
|
||||
CParticleInstance();
|
||||
~CParticleInstance();
|
||||
|
||||
float GetRadiusApproximation();
|
||||
|
||||
BOOL Update(float fElapsedTime, float fAngle);
|
||||
//virtual void Transform(const D3DXMATRIX * c_matLocal, const float c_fZRotation)=0;
|
||||
//virtual void Transform(const D3DXMATRIX * c_matLocal = NULL)=0;
|
||||
|
||||
//virtual TPTVertex * GetParticleMeshPointer() = 0;
|
||||
|
||||
//__forceinline float GetLifePercentage()
|
||||
//{
|
||||
// return m_fLifePercentage;
|
||||
//return (m_fLifeTime - m_fLastLifeTime) / m_fLifeTime;
|
||||
//}
|
||||
|
||||
//virtual void DeleteThis() = 0;
|
||||
|
||||
protected:
|
||||
//float m_fLifePercentage;
|
||||
D3DXVECTOR3 m_v3StartPosition;
|
||||
|
||||
D3DXVECTOR3 m_v3Position;
|
||||
D3DXVECTOR3 m_v3LastPosition;
|
||||
D3DXVECTOR3 m_v3Velocity;
|
||||
|
||||
D3DXVECTOR2 m_v2HalfSize;
|
||||
D3DXVECTOR2 m_v2Scale;
|
||||
|
||||
float m_fRotation;
|
||||
#ifdef WORLD_EDITOR
|
||||
D3DXCOLOR m_Color;
|
||||
#else
|
||||
DWORDCOLOR m_dcColor;
|
||||
#endif
|
||||
|
||||
BYTE m_byTextureAnimationType;
|
||||
float m_fLastFrameTime;
|
||||
BYTE m_byFrameIndex;
|
||||
|
||||
float m_fLifeTime;
|
||||
float m_fLastLifeTime;
|
||||
|
||||
CParticleProperty * m_pParticleProperty;
|
||||
CEmitterProperty * m_pEmitterProperty;
|
||||
|
||||
float m_fAirResistance;
|
||||
float m_fRotationSpeed;
|
||||
float m_fGravity;
|
||||
|
||||
NEffectUpdateDecorator::CBaseDecorator * m_pDecorator;
|
||||
public:
|
||||
static CParticleInstance* New();
|
||||
static void DestroySystem();
|
||||
|
||||
void Transform(const D3DXMATRIX * c_matLocal=NULL);
|
||||
void Transform(const D3DXMATRIX * c_matLocal, const float c_fZRotation);
|
||||
|
||||
TPTVertex * GetParticleMeshPointer();
|
||||
|
||||
void DeleteThis();
|
||||
|
||||
void Destroy();
|
||||
|
||||
protected:
|
||||
void __Initialize();
|
||||
TPTVertex m_ParticleMesh[4];
|
||||
public:
|
||||
static CDynamicPool<CParticleInstance> ms_kPool;
|
||||
};
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
122
source-client/Srcs/Client/EffectLib/ParticleProperty.cpp
Normal file
122
source-client/Srcs/Client/EffectLib/ParticleProperty.cpp
Normal file
@ -0,0 +1,122 @@
|
||||
#include "StdAfx.h"
|
||||
#include "ParticleProperty.h"
|
||||
#include "../eterlib/ResourceManager.h"
|
||||
|
||||
void CParticleProperty::InsertTexture(const char * c_szFileName)
|
||||
{
|
||||
CGraphicImage * pImage = (CGraphicImage *)CResourceManager::Instance().GetResourcePointer(c_szFileName);
|
||||
|
||||
m_ImageVector.push_back(pImage);
|
||||
#ifdef WORLD_EDITOR
|
||||
m_TextureNameVector.push_back(c_szFileName);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CParticleProperty::SetTexture(const char * c_szFileName)
|
||||
{
|
||||
if (m_ImageVector.size() > 1)
|
||||
{
|
||||
assert(false);
|
||||
return false;
|
||||
}
|
||||
m_ImageVector.clear();
|
||||
#ifdef WORLD_EDITOR
|
||||
m_TextureNameVector.clear();
|
||||
#endif
|
||||
InsertTexture(c_szFileName);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CParticleProperty::Clear()
|
||||
{
|
||||
m_byRotationType = 0;
|
||||
m_fRotationSpeed = 0.0f;
|
||||
m_wRotationRandomStartingBegin = 0;
|
||||
m_wRotationRandomStartingEnd = 0;
|
||||
|
||||
m_bAttachFlag = FALSE;
|
||||
m_bStretchFlag = FALSE;
|
||||
|
||||
m_bySrcBlendType = D3DBLEND_SRCALPHA;
|
||||
m_byDestBlendType = D3DBLEND_ONE;
|
||||
m_byColorOperationType = D3DTOP_MODULATE;
|
||||
|
||||
m_byBillboardType = BILLBOARD_TYPE_NONE;
|
||||
|
||||
m_byTexAniType = TEXTURE_ANIMATION_TYPE_NONE;
|
||||
m_fTexAniDelay = 0.05f;
|
||||
m_bTexAniRandomStartFrameFlag = FALSE;
|
||||
|
||||
//m_fGravity = 0.0f;
|
||||
//m_fAirResistance = 0.0f;
|
||||
|
||||
m_TimeEventGravity.clear();
|
||||
m_TimeEventAirResistance.clear();
|
||||
|
||||
m_TimeEventScaleX.clear();
|
||||
m_TimeEventScaleY.clear();
|
||||
//m_TimeEventScaleXY.clear();
|
||||
#ifdef WORLD_EDITOR
|
||||
m_TimeEventColorRed.clear();
|
||||
m_TimeEventColorGreen.clear();
|
||||
m_TimeEventColorBlue.clear();
|
||||
m_TimeEventAlpha.clear();
|
||||
m_TextureNameVector.clear();
|
||||
#else
|
||||
m_TimeEventColor.clear();
|
||||
#endif
|
||||
m_TimeEventRotation.clear();
|
||||
|
||||
m_ImageVector.clear();
|
||||
}
|
||||
|
||||
CParticleProperty::CParticleProperty()
|
||||
{
|
||||
}
|
||||
CParticleProperty::~CParticleProperty()
|
||||
{
|
||||
}
|
||||
|
||||
CParticleProperty & CParticleProperty::operator = ( const CParticleProperty& c_ParticleProperty )
|
||||
{
|
||||
m_byTexAniType = c_ParticleProperty.m_byTexAniType;
|
||||
m_fTexAniDelay = c_ParticleProperty.m_fTexAniDelay;
|
||||
m_bTexAniRandomStartFrameFlag = c_ParticleProperty.m_bTexAniRandomStartFrameFlag;
|
||||
|
||||
m_bySrcBlendType = c_ParticleProperty.m_bySrcBlendType;
|
||||
m_byDestBlendType = c_ParticleProperty.m_byDestBlendType;
|
||||
m_byColorOperationType = c_ParticleProperty.m_byColorOperationType;
|
||||
|
||||
m_byBillboardType = c_ParticleProperty.m_byBillboardType;
|
||||
|
||||
m_byRotationType = c_ParticleProperty.m_byRotationType;
|
||||
m_fRotationSpeed = c_ParticleProperty.m_fRotationSpeed;
|
||||
m_wRotationRandomStartingBegin = c_ParticleProperty.m_wRotationRandomStartingBegin;
|
||||
m_wRotationRandomStartingEnd = c_ParticleProperty.m_wRotationRandomStartingEnd;
|
||||
|
||||
m_bAttachFlag = c_ParticleProperty.m_bAttachFlag;
|
||||
m_bStretchFlag = c_ParticleProperty.m_bStretchFlag;
|
||||
|
||||
m_TimeEventGravity = c_ParticleProperty.m_TimeEventGravity;
|
||||
m_TimeEventAirResistance = c_ParticleProperty.m_TimeEventAirResistance;
|
||||
|
||||
m_TimeEventScaleX = c_ParticleProperty.m_TimeEventScaleX;
|
||||
m_TimeEventScaleY = c_ParticleProperty.m_TimeEventScaleY;
|
||||
|
||||
#ifdef WORLD_EDITOR
|
||||
m_TimeEventColorRed = c_ParticleProperty.m_TimeEventColorRed;
|
||||
m_TimeEventColorGreen = c_ParticleProperty.m_TimeEventColorGreen;
|
||||
m_TimeEventColorBlue = c_ParticleProperty.m_TimeEventColorBlue;
|
||||
m_TimeEventAlpha = c_ParticleProperty.m_TimeEventAlpha;
|
||||
|
||||
m_TextureNameVector = c_ParticleProperty.m_TextureNameVector;
|
||||
#else
|
||||
m_TimeEventColor = c_ParticleProperty.m_TimeEventColor;
|
||||
#endif
|
||||
m_TimeEventRotation = c_ParticleProperty.m_TimeEventRotation;
|
||||
|
||||
m_ImageVector = c_ParticleProperty.m_ImageVector;
|
||||
|
||||
return *this;
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
96
source-client/Srcs/Client/EffectLib/ParticleProperty.h
Normal file
96
source-client/Srcs/Client/EffectLib/ParticleProperty.h
Normal file
@ -0,0 +1,96 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "../eterlib/GrpImageInstance.h"
|
||||
|
||||
#include "Type.h"
|
||||
|
||||
class CParticleProperty
|
||||
{
|
||||
friend class CParticleSystemData;
|
||||
friend class CParticleSystemInstance;
|
||||
public:
|
||||
enum
|
||||
{
|
||||
ROTATION_TYPE_NONE,
|
||||
ROTATION_TYPE_TIME_EVENT,
|
||||
ROTATION_TYPE_CW,
|
||||
ROTATION_TYPE_CCW,
|
||||
ROTATION_TYPE_RANDOM_DIRECTION,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TEXTURE_ANIMATION_TYPE_NONE,
|
||||
TEXTURE_ANIMATION_TYPE_CW,
|
||||
TEXTURE_ANIMATION_TYPE_CCW,
|
||||
TEXTURE_ANIMATION_TYPE_RANDOM_FRAME,
|
||||
TEXTURE_ANIMATION_TYPE_RANDOM_DIRECTION,
|
||||
};
|
||||
|
||||
public:
|
||||
CParticleProperty();
|
||||
virtual ~CParticleProperty();
|
||||
|
||||
void Clear();
|
||||
|
||||
void InsertTexture(const char * c_szFileName);
|
||||
bool SetTexture(const char * c_szFileName);
|
||||
|
||||
__forceinline BYTE GetTextureAnimationType()
|
||||
{
|
||||
return m_byTexAniType;
|
||||
}
|
||||
|
||||
__forceinline DWORD GetTextureAnimationFrameCount()
|
||||
{
|
||||
return m_ImageVector.size();
|
||||
}
|
||||
|
||||
__forceinline float GetTextureAnimationFrameDelay()
|
||||
{
|
||||
return m_fTexAniDelay;
|
||||
}
|
||||
|
||||
BYTE m_byTexAniType;
|
||||
float m_fTexAniDelay;
|
||||
BOOL m_bTexAniRandomStartFrameFlag;
|
||||
|
||||
BYTE m_bySrcBlendType;
|
||||
BYTE m_byDestBlendType;
|
||||
BYTE m_byColorOperationType;
|
||||
BYTE m_byBillboardType;
|
||||
|
||||
BYTE m_byRotationType;
|
||||
float m_fRotationSpeed;
|
||||
WORD m_wRotationRandomStartingBegin;
|
||||
WORD m_wRotationRandomStartingEnd;
|
||||
|
||||
BOOL m_bAttachFlag;
|
||||
BOOL m_bStretchFlag;
|
||||
|
||||
TTimeEventTableFloat m_TimeEventGravity;
|
||||
TTimeEventTableFloat m_TimeEventAirResistance;
|
||||
|
||||
TTimeEventTableFloat m_TimeEventScaleX;
|
||||
TTimeEventTableFloat m_TimeEventScaleY;
|
||||
#ifdef WORLD_EDITOR
|
||||
TTimeEventTableFloat m_TimeEventColorRed;
|
||||
TTimeEventTableFloat m_TimeEventColorGreen;
|
||||
TTimeEventTableFloat m_TimeEventColorBlue;
|
||||
TTimeEventTableFloat m_TimeEventAlpha;
|
||||
|
||||
std::vector<std::string> m_TextureNameVector;
|
||||
#else
|
||||
TTimeEventTableColor m_TimeEventColor;
|
||||
#endif
|
||||
TTimeEventTableFloat m_TimeEventRotation;
|
||||
|
||||
std::vector<CGraphicImage*> m_ImageVector;
|
||||
|
||||
CParticleProperty & operator = ( const CParticleProperty& c_ParticleProperty );
|
||||
|
||||
// pre-transformed variables
|
||||
D3DXVECTOR3 m_v3ZAxis;
|
||||
};
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
425
source-client/Srcs/Client/EffectLib/ParticleSystemData.cpp
Normal file
425
source-client/Srcs/Client/EffectLib/ParticleSystemData.cpp
Normal file
@ -0,0 +1,425 @@
|
||||
#include "StdAfx.h"
|
||||
#include "ParticleSystemData.h"
|
||||
#include "EffectUpdateDecorator.h"
|
||||
#include "ParticleInstance.h"
|
||||
|
||||
CDynamicPool<CParticleSystemData> CParticleSystemData::ms_kPool;
|
||||
|
||||
void CParticleSystemData::DestroySystem()
|
||||
{
|
||||
ms_kPool.Destroy();
|
||||
}
|
||||
|
||||
CParticleSystemData* CParticleSystemData::New()
|
||||
{
|
||||
return ms_kPool.Alloc();
|
||||
}
|
||||
|
||||
void CParticleSystemData::Delete(CParticleSystemData* pkData)
|
||||
{
|
||||
pkData->Clear();
|
||||
ms_kPool.Free(pkData);
|
||||
}
|
||||
|
||||
CEmitterProperty * CParticleSystemData::GetEmitterPropertyPointer()
|
||||
{
|
||||
return &m_EmitterProperty;
|
||||
}
|
||||
CParticleProperty * CParticleSystemData::GetParticlePropertyPointer()
|
||||
{
|
||||
return &m_ParticleProperty;
|
||||
}
|
||||
|
||||
BOOL CParticleSystemData::OnLoadScript(CTextFileLoader & rTextFileLoader)
|
||||
{
|
||||
{
|
||||
CTextFileLoader::CGotoChild GotoChild(&rTextFileLoader, "emitterproperty");
|
||||
|
||||
if (!rTextFileLoader.GetTokenDoubleWord("maxemissioncount", &m_EmitterProperty.m_dwMaxEmissionCount))
|
||||
return FALSE;
|
||||
|
||||
if (!rTextFileLoader.GetTokenFloat("cyclelength", &m_EmitterProperty.m_fCycleLength))
|
||||
{
|
||||
m_EmitterProperty.m_fCycleLength = 0.05f;
|
||||
}
|
||||
if (!rTextFileLoader.GetTokenBoolean("cycleloopenable", &m_EmitterProperty.m_bCycleLoopFlag))
|
||||
{
|
||||
m_EmitterProperty.m_bCycleLoopFlag = FALSE;
|
||||
}
|
||||
if (!rTextFileLoader.GetTokenInteger("loopcount",&m_EmitterProperty.m_iLoopCount))
|
||||
{
|
||||
m_EmitterProperty.m_iLoopCount = 0;
|
||||
}
|
||||
|
||||
if (!rTextFileLoader.GetTokenByte("emittershape", &m_EmitterProperty.m_byEmitterShape))
|
||||
return FALSE;
|
||||
|
||||
if (!rTextFileLoader.GetTokenByte("emitteradvancedtype", &m_EmitterProperty.m_byEmitterAdvancedType))
|
||||
{
|
||||
m_EmitterProperty.m_byEmitterShape = CEmitterProperty::EMITTER_ADVANCED_TYPE_FREE;
|
||||
}
|
||||
if (!rTextFileLoader.GetTokenPosition("emittingsize", &m_EmitterProperty.m_v3EmittingSize))
|
||||
{
|
||||
m_EmitterProperty.m_v3EmittingSize = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
if (!rTextFileLoader.GetTokenFloat("emittingradius", &m_EmitterProperty.m_fEmittingRadius))
|
||||
{
|
||||
m_EmitterProperty.m_fEmittingRadius = 0.0f;
|
||||
}
|
||||
|
||||
if (!rTextFileLoader.GetTokenBoolean("emitteremitfromedgeflag", &m_EmitterProperty.m_bEmitFromEdgeFlag))
|
||||
{
|
||||
m_EmitterProperty.m_bEmitFromEdgeFlag = FALSE;
|
||||
}
|
||||
|
||||
if (!rTextFileLoader.GetTokenPosition("emittingdirection", &m_EmitterProperty.m_v3EmittingDirection))
|
||||
{
|
||||
m_EmitterProperty.m_v3EmittingDirection = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventemittingsize", &m_EmitterProperty.m_TimeEventEmittingSize))
|
||||
{
|
||||
m_EmitterProperty.m_TimeEventEmittingSize.clear();
|
||||
TTimeEventTypeFloat TimeEventFloat;
|
||||
TimeEventFloat.m_fTime = 0.0f;
|
||||
TimeEventFloat.m_Value = 0.0f;
|
||||
m_EmitterProperty.m_TimeEventEmittingSize.push_back(TimeEventFloat);
|
||||
}
|
||||
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventemittingangularvelocity", &m_EmitterProperty.m_TimeEventEmittingAngularVelocity))
|
||||
{
|
||||
m_EmitterProperty.m_TimeEventEmittingAngularVelocity.clear();
|
||||
TTimeEventTypeFloat TimeEventFloat;
|
||||
TimeEventFloat.m_fTime = 0.0f;
|
||||
TimeEventFloat.m_Value = 0.0f;
|
||||
m_EmitterProperty.m_TimeEventEmittingAngularVelocity.push_back(TimeEventFloat);
|
||||
}
|
||||
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventemittingdirectionx", &m_EmitterProperty.m_TimeEventEmittingDirectionX))
|
||||
{
|
||||
m_EmitterProperty.m_TimeEventEmittingDirectionX.clear();
|
||||
TTimeEventTypeFloat TimeEventFloat;
|
||||
TimeEventFloat.m_fTime = 0.0f;
|
||||
TimeEventFloat.m_Value = 0.0f;
|
||||
m_EmitterProperty.m_TimeEventEmittingDirectionX.push_back(TimeEventFloat);
|
||||
}
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventemittingdirectiony", &m_EmitterProperty.m_TimeEventEmittingDirectionY))
|
||||
{
|
||||
m_EmitterProperty.m_TimeEventEmittingDirectionY.clear();
|
||||
TTimeEventTypeFloat TimeEventFloat;
|
||||
TimeEventFloat.m_fTime = 0.0f;
|
||||
TimeEventFloat.m_Value = 0.0f;
|
||||
m_EmitterProperty.m_TimeEventEmittingDirectionY.push_back(TimeEventFloat);
|
||||
}
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventemittingdirectionz", &m_EmitterProperty.m_TimeEventEmittingDirectionZ))
|
||||
{
|
||||
m_EmitterProperty.m_TimeEventEmittingDirectionZ.clear();
|
||||
TTimeEventTypeFloat TimeEventFloat;
|
||||
TimeEventFloat.m_fTime = 0.0f;
|
||||
TimeEventFloat.m_Value = 0.0f;
|
||||
m_EmitterProperty.m_TimeEventEmittingDirectionZ.push_back(TimeEventFloat);
|
||||
}
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventemittingvelocity", &m_EmitterProperty.m_TimeEventEmittingVelocity))
|
||||
{
|
||||
m_EmitterProperty.m_TimeEventEmittingVelocity.clear();
|
||||
TTimeEventTypeFloat TimeEventFloat;
|
||||
TimeEventFloat.m_fTime = 0.0f;
|
||||
TimeEventFloat.m_Value = 0.0f;
|
||||
m_EmitterProperty.m_TimeEventEmittingVelocity.push_back(TimeEventFloat);
|
||||
}
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventemissioncountpersecond", &m_EmitterProperty.m_TimeEventEmissionCountPerSecond))
|
||||
return FALSE;
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventlifetime", &m_EmitterProperty.m_TimeEventLifeTime))
|
||||
return FALSE;
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventsizex", &m_EmitterProperty.m_TimeEventSizeX))
|
||||
return FALSE;
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventsizey", &m_EmitterProperty.m_TimeEventSizeY))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
{
|
||||
CTextFileLoader::CGotoChild GotoChild(&rTextFileLoader, "particleproperty");
|
||||
|
||||
if (!rTextFileLoader.GetTokenByte("srcblendtype", &m_ParticleProperty.m_bySrcBlendType))
|
||||
{
|
||||
m_ParticleProperty.m_bySrcBlendType = D3DBLEND_SRCALPHA;
|
||||
}
|
||||
if (!rTextFileLoader.GetTokenByte("destblendtype", &m_ParticleProperty.m_byDestBlendType))
|
||||
{
|
||||
m_ParticleProperty.m_byDestBlendType = D3DBLEND_ONE;
|
||||
}
|
||||
if (!rTextFileLoader.GetTokenByte("coloroperationtype", &m_ParticleProperty.m_byColorOperationType))
|
||||
{
|
||||
m_ParticleProperty.m_byColorOperationType = D3DTOP_MODULATE;
|
||||
}
|
||||
|
||||
if (!rTextFileLoader.GetTokenByte("billboardtype", &m_ParticleProperty.m_byBillboardType))
|
||||
return FALSE;
|
||||
|
||||
if (!rTextFileLoader.GetTokenByte("rotationtype", &m_ParticleProperty.m_byRotationType))
|
||||
return FALSE;
|
||||
if (!rTextFileLoader.GetTokenFloat("rotationspeed", &m_ParticleProperty.m_fRotationSpeed))
|
||||
return FALSE;
|
||||
if (!rTextFileLoader.GetTokenWord("rotationrandomstartingbegin", &m_ParticleProperty.m_wRotationRandomStartingBegin))
|
||||
return FALSE;
|
||||
if (!rTextFileLoader.GetTokenWord("rotationrandomstartingend", &m_ParticleProperty.m_wRotationRandomStartingEnd))
|
||||
return FALSE;
|
||||
|
||||
if (!rTextFileLoader.GetTokenBoolean("attachenable", &m_ParticleProperty.m_bAttachFlag))
|
||||
{
|
||||
m_ParticleProperty.m_bAttachFlag = FALSE;
|
||||
}
|
||||
if (!rTextFileLoader.GetTokenBoolean("stretchenable", &m_ParticleProperty.m_bStretchFlag))
|
||||
return FALSE;
|
||||
|
||||
if (!rTextFileLoader.GetTokenByte("texanitype", &m_ParticleProperty.m_byTexAniType))
|
||||
return FALSE;
|
||||
if (!rTextFileLoader.GetTokenFloat("texanidelay", &m_ParticleProperty.m_fTexAniDelay))
|
||||
return FALSE;
|
||||
if (!rTextFileLoader.GetTokenBoolean("texanirandomstartframeenable", &m_ParticleProperty.m_bTexAniRandomStartFrameFlag))
|
||||
return FALSE;
|
||||
|
||||
float fGravity;
|
||||
|
||||
if (rTextFileLoader.GetTokenFloat("gravity", &fGravity))
|
||||
{
|
||||
TTimeEventTypeFloat f;
|
||||
f.m_fTime = 0.0f;
|
||||
f.m_Value = fGravity;
|
||||
m_ParticleProperty.m_TimeEventGravity.push_back(f);
|
||||
}
|
||||
else if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventgravity", &m_ParticleProperty.m_TimeEventGravity))
|
||||
{
|
||||
m_ParticleProperty.m_TimeEventGravity.clear();
|
||||
}
|
||||
|
||||
float fAirResistance;
|
||||
if (rTextFileLoader.GetTokenFloat("airresistance", &fAirResistance))
|
||||
{
|
||||
TTimeEventTypeFloat f;
|
||||
f.m_fTime = 0.0f;
|
||||
f.m_Value = fAirResistance;
|
||||
m_ParticleProperty.m_TimeEventAirResistance.push_back(f);
|
||||
}
|
||||
else if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventairresistance", &m_ParticleProperty.m_TimeEventAirResistance))
|
||||
{
|
||||
m_ParticleProperty.m_TimeEventAirResistance.clear();
|
||||
}
|
||||
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventscalex", &m_ParticleProperty.m_TimeEventScaleX))
|
||||
return FALSE;
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventscaley", &m_ParticleProperty.m_TimeEventScaleY))
|
||||
return FALSE;
|
||||
|
||||
#ifdef WORLD_EDITOR
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventcolorred", &m_ParticleProperty.m_TimeEventColorRed))
|
||||
return FALSE;
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventcolorgreen", &m_ParticleProperty.m_TimeEventColorGreen))
|
||||
return FALSE;
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventcolorblue", &m_ParticleProperty.m_TimeEventColorBlue))
|
||||
return FALSE;
|
||||
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventalpha", &m_ParticleProperty.m_TimeEventAlpha))
|
||||
return FALSE;
|
||||
#else
|
||||
TTimeEventTableFloat TimeEventR;
|
||||
TTimeEventTableFloat TimeEventB;
|
||||
TTimeEventTableFloat TimeEventG;
|
||||
TTimeEventTableFloat TimeEventA;
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventcolorred", &TimeEventR))
|
||||
return FALSE;
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventcolorgreen", &TimeEventG))
|
||||
return FALSE;
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventcolorblue", &TimeEventB))
|
||||
return FALSE;
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventalpha", &TimeEventA))
|
||||
return FALSE;
|
||||
|
||||
m_ParticleProperty.m_TimeEventColor.clear();
|
||||
{
|
||||
std::set<float> times;
|
||||
int i;
|
||||
for(i=0;i<TimeEventR.size();i++)
|
||||
times.insert(TimeEventR[i].m_fTime);
|
||||
for(i=0;i<TimeEventG.size();i++)
|
||||
times.insert(TimeEventG[i].m_fTime);
|
||||
for(i=0;i<TimeEventB.size();i++)
|
||||
times.insert(TimeEventB[i].m_fTime);
|
||||
for(i=0;i<TimeEventA.size();i++)
|
||||
times.insert(TimeEventA[i].m_fTime);
|
||||
std::set<float>::iterator it;
|
||||
for(it = times.begin(); it != times.end(); ++it)
|
||||
{
|
||||
float fTime = *it;
|
||||
float fR, fG, fB, fA;
|
||||
GetTimeEventBlendValue<float>(fTime, TimeEventR, &fR);
|
||||
GetTimeEventBlendValue<float>(fTime, TimeEventG, &fG);
|
||||
GetTimeEventBlendValue<float>(fTime, TimeEventB, &fB);
|
||||
GetTimeEventBlendValue<float>(fTime, TimeEventA, &fA);
|
||||
TTimeEventTypeColor t;
|
||||
t.m_fTime = fTime;
|
||||
D3DXCOLOR c;
|
||||
c.r = fR;
|
||||
c.g = fG;
|
||||
c.b = fB;
|
||||
c.a = fA;
|
||||
t.m_Value.m_dwColor = /*(DWORD)*/ (DWORD)c;
|
||||
m_ParticleProperty.m_TimeEventColor.push_back(t);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventrotation", &m_ParticleProperty.m_TimeEventRotation))
|
||||
return FALSE;
|
||||
|
||||
CTokenVector * pTextureVector;
|
||||
|
||||
if (!rTextFileLoader.GetTokenVector("texturefiles", &pTextureVector))
|
||||
return FALSE;
|
||||
|
||||
for (DWORD i = 0; i < pTextureVector->size(); ++i)
|
||||
{
|
||||
std::string strTextureFileName = pTextureVector->at(i).c_str();
|
||||
|
||||
if (!IsGlobalFileName(strTextureFileName.c_str()))
|
||||
strTextureFileName = GetOnlyPathName(rTextFileLoader.GetFileName()) + strTextureFileName;
|
||||
|
||||
m_ParticleProperty.InsertTexture(strTextureFileName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CParticleSystemData::ChangeTexture(const char * c_szFileName)
|
||||
{
|
||||
m_ParticleProperty.SetTexture(c_szFileName);
|
||||
}
|
||||
|
||||
void CParticleSystemData::OnClear()
|
||||
{
|
||||
m_EmitterProperty.Clear();
|
||||
m_ParticleProperty.Clear();
|
||||
}
|
||||
|
||||
bool CParticleSystemData::OnIsData()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void CParticleSystemData::BuildDecorator(CParticleInstance * pInstance)
|
||||
{
|
||||
using namespace NEffectUpdateDecorator;
|
||||
|
||||
pInstance->m_pDecorator = new CNullDecorator;
|
||||
|
||||
//////
|
||||
|
||||
if (m_ParticleProperty.m_TimeEventAirResistance.size()>1)
|
||||
{
|
||||
pInstance->m_pDecorator=pInstance->m_pDecorator->AddChainFront(new CAirResistanceDecorator);
|
||||
pInstance->m_pDecorator=pInstance->m_pDecorator->AddChainFront(
|
||||
new CAirResistanceValueDecorator(m_ParticleProperty.m_TimeEventAirResistance, &pInstance->m_fAirResistance)
|
||||
);
|
||||
}
|
||||
else if (m_ParticleProperty.m_TimeEventAirResistance.size()==1)
|
||||
{
|
||||
pInstance->m_fAirResistance = m_ParticleProperty.m_TimeEventAirResistance[0].m_Value;
|
||||
pInstance->m_pDecorator=pInstance->m_pDecorator->AddChainFront(new CAirResistanceDecorator);
|
||||
}
|
||||
|
||||
if (m_ParticleProperty.m_TimeEventGravity.size() > 1)
|
||||
{
|
||||
pInstance->m_pDecorator = pInstance->m_pDecorator->AddChainFront(new CGravityDecorator);
|
||||
pInstance->m_pDecorator = pInstance->m_pDecorator->AddChainFront(
|
||||
new CGravityValueDecorator(m_ParticleProperty.m_TimeEventGravity, &pInstance->m_fGravity)
|
||||
);
|
||||
}
|
||||
else if (m_ParticleProperty.m_TimeEventGravity.size() == 1)
|
||||
{
|
||||
pInstance->m_fGravity = m_ParticleProperty.m_TimeEventGravity[0].m_Value;
|
||||
pInstance->m_pDecorator = pInstance->m_pDecorator->AddChainFront(new CGravityDecorator);
|
||||
}
|
||||
#ifdef WORLD_EDITOR
|
||||
pInstance->m_pDecorator = pInstance->m_pDecorator->AddChainFront(
|
||||
new CColorValueDecorator(m_ParticleProperty.m_TimeEventColorRed, &pInstance->m_Color.r));
|
||||
pInstance->m_pDecorator = pInstance->m_pDecorator->AddChainFront(
|
||||
new CColorValueDecorator(m_ParticleProperty.m_TimeEventColorGreen, &pInstance->m_Color.g));
|
||||
pInstance->m_pDecorator = pInstance->m_pDecorator->AddChainFront(
|
||||
new CColorValueDecorator(m_ParticleProperty.m_TimeEventColorBlue, &pInstance->m_Color.b));
|
||||
pInstance->m_pDecorator = pInstance->m_pDecorator->AddChainFront(
|
||||
new CColorValueDecorator(m_ParticleProperty.m_TimeEventAlpha, &pInstance->m_Color.a));
|
||||
#else
|
||||
pInstance->m_pDecorator = pInstance->m_pDecorator->AddChainFront(
|
||||
new CColorAllDecorator(m_ParticleProperty.m_TimeEventColor, &pInstance->m_dcColor));
|
||||
#endif
|
||||
|
||||
pInstance->m_pDecorator = pInstance->m_pDecorator->AddChainFront(
|
||||
new CScaleValueDecorator(m_ParticleProperty.m_TimeEventScaleX, &pInstance->m_v2Scale.x));
|
||||
pInstance->m_pDecorator = pInstance->m_pDecorator->AddChainFront(
|
||||
new CScaleValueDecorator(m_ParticleProperty.m_TimeEventScaleY, &pInstance->m_v2Scale.y));
|
||||
|
||||
if (m_ParticleProperty.GetTextureAnimationFrameCount()>1 &&m_ParticleProperty.GetTextureAnimationFrameDelay()>1e-6)
|
||||
{
|
||||
switch (pInstance->m_byTextureAnimationType)
|
||||
{
|
||||
case CParticleProperty::TEXTURE_ANIMATION_TYPE_CW:
|
||||
pInstance->m_pDecorator=pInstance->m_pDecorator->AddChainFront(
|
||||
new CTextureAnimationCWDecorator(m_ParticleProperty.GetTextureAnimationFrameDelay(), m_ParticleProperty.GetTextureAnimationFrameCount(), &pInstance->m_byFrameIndex));
|
||||
break;
|
||||
case CParticleProperty::TEXTURE_ANIMATION_TYPE_CCW:
|
||||
pInstance->m_pDecorator=pInstance->m_pDecorator->AddChainFront(
|
||||
new CTextureAnimationCCWDecorator(m_ParticleProperty.GetTextureAnimationFrameDelay(), m_ParticleProperty.GetTextureAnimationFrameCount(), &pInstance->m_byFrameIndex));
|
||||
break;
|
||||
case CParticleProperty::TEXTURE_ANIMATION_TYPE_RANDOM_FRAME:
|
||||
pInstance->m_pDecorator=pInstance->m_pDecorator->AddChainFront(
|
||||
new CTextureAnimationRandomDecorator(m_ParticleProperty.GetTextureAnimationFrameDelay(), m_ParticleProperty.GetTextureAnimationFrameCount(), &pInstance->m_byFrameIndex));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BYTE byRotationType = m_ParticleProperty.m_byRotationType;
|
||||
|
||||
if (m_ParticleProperty.m_fRotationSpeed==0.0f && byRotationType!=CParticleProperty::ROTATION_TYPE_TIME_EVENT)
|
||||
{
|
||||
byRotationType = CParticleProperty::ROTATION_TYPE_NONE;
|
||||
}
|
||||
else if (byRotationType==CParticleProperty::ROTATION_TYPE_RANDOM_DIRECTION)
|
||||
{
|
||||
byRotationType = (random()&1)?CParticleProperty::ROTATION_TYPE_CW:CParticleProperty::ROTATION_TYPE_CCW;
|
||||
}
|
||||
|
||||
switch(byRotationType)
|
||||
{
|
||||
case CParticleProperty::ROTATION_TYPE_TIME_EVENT:
|
||||
pInstance->m_pDecorator=pInstance->m_pDecorator->AddChainFront(
|
||||
new CRotationDecorator());
|
||||
pInstance->m_pDecorator=pInstance->m_pDecorator->AddChainFront(
|
||||
new CRotationSpeedValueDecorator(m_ParticleProperty.m_TimeEventRotation,&pInstance->m_fRotationSpeed));
|
||||
break;
|
||||
|
||||
case CParticleProperty::ROTATION_TYPE_CW:
|
||||
pInstance->m_fRotationSpeed = m_ParticleProperty.m_fRotationSpeed;
|
||||
pInstance->m_pDecorator=pInstance->m_pDecorator->AddChainFront(
|
||||
new CRotationDecorator());
|
||||
break;
|
||||
|
||||
case CParticleProperty::ROTATION_TYPE_CCW:
|
||||
pInstance->m_fRotationSpeed = - m_ParticleProperty.m_fRotationSpeed;
|
||||
pInstance->m_pDecorator=pInstance->m_pDecorator->AddChainFront(
|
||||
new CRotationDecorator());
|
||||
break;
|
||||
}
|
||||
|
||||
/////
|
||||
|
||||
pInstance->m_pDecorator=pInstance->m_pDecorator->AddChainFront(new CHeaderDecorator);
|
||||
}
|
||||
|
||||
CParticleSystemData::CParticleSystemData()
|
||||
{
|
||||
}
|
||||
CParticleSystemData::~CParticleSystemData()
|
||||
{
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
41
source-client/Srcs/Client/EffectLib/ParticleSystemData.h
Normal file
41
source-client/Srcs/Client/EffectLib/ParticleSystemData.h
Normal file
@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include "../eterLib/TextFileLoader.h"
|
||||
|
||||
#include "EffectElementBase.h"
|
||||
#include "EmitterProperty.h"
|
||||
#include "ParticleProperty.h"
|
||||
//#include "ParticleInstance.h"
|
||||
|
||||
class CParticleInstance;
|
||||
|
||||
class CParticleSystemData : public CEffectElementBase
|
||||
{
|
||||
public:
|
||||
virtual ~CParticleSystemData();
|
||||
CParticleSystemData();
|
||||
|
||||
CEmitterProperty * GetEmitterPropertyPointer();
|
||||
CParticleProperty * GetParticlePropertyPointer();
|
||||
|
||||
void ChangeTexture(const char * c_szFileName);
|
||||
|
||||
void BuildDecorator(CParticleInstance * pInstance);
|
||||
protected:
|
||||
BOOL OnLoadScript(CTextFileLoader & rTextFileLoader);
|
||||
|
||||
void OnClear();
|
||||
bool OnIsData();
|
||||
|
||||
CEmitterProperty m_EmitterProperty;
|
||||
CParticleProperty m_ParticleProperty;
|
||||
|
||||
public:
|
||||
static void DestroySystem();
|
||||
|
||||
static CParticleSystemData* New();
|
||||
static void Delete(CParticleSystemData* pkData);
|
||||
|
||||
static CDynamicPool<CParticleSystemData> ms_kPool;
|
||||
};
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
516
source-client/Srcs/Client/EffectLib/ParticleSystemInstance.cpp
Normal file
516
source-client/Srcs/Client/EffectLib/ParticleSystemInstance.cpp
Normal file
@ -0,0 +1,516 @@
|
||||
#include "StdAfx.h"
|
||||
#include "../eterBase/Random.h"
|
||||
#include "../eterLib/StateManager.h"
|
||||
#include "ParticleSystemData.h"
|
||||
#include "ParticleSystemInstance.h"
|
||||
#include "ParticleInstance.h"
|
||||
|
||||
CDynamicPool<CParticleSystemInstance> CParticleSystemInstance::ms_kPool;
|
||||
|
||||
using namespace NEffectUpdateDecorator;
|
||||
|
||||
void CParticleSystemInstance::DestroySystem()
|
||||
{
|
||||
ms_kPool.Destroy();
|
||||
|
||||
CParticleInstance::DestroySystem();
|
||||
//CRayParticleInstance::DestroySystem();
|
||||
}
|
||||
|
||||
CParticleSystemInstance* CParticleSystemInstance::New()
|
||||
{
|
||||
return ms_kPool.Alloc();
|
||||
}
|
||||
|
||||
void CParticleSystemInstance::Delete(CParticleSystemInstance* pkPSInst)
|
||||
{
|
||||
pkPSInst->Destroy();
|
||||
ms_kPool.Free(pkPSInst);
|
||||
}
|
||||
|
||||
DWORD CParticleSystemInstance::GetEmissionCount()
|
||||
{
|
||||
return m_dwCurrentEmissionCount;
|
||||
}
|
||||
|
||||
void CParticleSystemInstance::CreateParticles(float fElapsedTime)
|
||||
{
|
||||
float fEmissionCount;
|
||||
m_pEmitterProperty->GetEmissionCountPerSecond(m_fLocalTime, &fEmissionCount);
|
||||
|
||||
float fCreatingValue = fEmissionCount * (fElapsedTime / 1.0f) + m_fEmissionResidue;
|
||||
int iCreatingCount = int(fCreatingValue);
|
||||
m_fEmissionResidue = fCreatingValue - iCreatingCount;
|
||||
|
||||
int icurEmissionCount = GetEmissionCount();
|
||||
int iMaxEmissionCount = int(m_pEmitterProperty->GetMaxEmissionCount());
|
||||
int iNextEmissionCount = int(icurEmissionCount + iCreatingCount);
|
||||
iCreatingCount -= max(0, iNextEmissionCount - iMaxEmissionCount);
|
||||
|
||||
float fLifeTime = 0.0f;
|
||||
float fEmittingSize = 0.0f;
|
||||
D3DXVECTOR3 _v3TimePosition;
|
||||
D3DXVECTOR3 _v3Velocity;
|
||||
float fVelocity = 0.0f;
|
||||
D3DXVECTOR2 v2HalfSize;
|
||||
float fLieRotation = 0;
|
||||
if (iCreatingCount)
|
||||
{
|
||||
m_pEmitterProperty->GetParticleLifeTime(m_fLocalTime, &fLifeTime);
|
||||
if (fLifeTime==0.0f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_pEmitterProperty->GetEmittingSize(m_fLocalTime, &fEmittingSize);
|
||||
|
||||
m_pData->GetPosition(m_fLocalTime, _v3TimePosition);
|
||||
|
||||
m_pEmitterProperty->GetEmittingDirectionX(m_fLocalTime, &_v3Velocity.x);
|
||||
m_pEmitterProperty->GetEmittingDirectionY(m_fLocalTime, &_v3Velocity.y);
|
||||
m_pEmitterProperty->GetEmittingDirectionZ(m_fLocalTime, &_v3Velocity.z);
|
||||
|
||||
m_pEmitterProperty->GetEmittingVelocity(m_fLocalTime, &fVelocity);
|
||||
|
||||
m_pEmitterProperty->GetParticleSizeX(m_fLocalTime, &v2HalfSize.x);
|
||||
m_pEmitterProperty->GetParticleSizeY(m_fLocalTime, &v2HalfSize.y);
|
||||
|
||||
if (BILLBOARD_TYPE_LIE == m_pParticleProperty->m_byBillboardType && mc_pmatLocal)
|
||||
{
|
||||
float fsx = mc_pmatLocal->_32;
|
||||
float fcx = sqrtf(1.0f - fsx * fsx);
|
||||
|
||||
if (fcx >= 0.00001f)
|
||||
fLieRotation = D3DXToDegree(atan2f(-mc_pmatLocal->_12, mc_pmatLocal->_22));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
CParticleInstance * pFirstInstance = 0;
|
||||
|
||||
for (int i = 0; i < iCreatingCount; ++i)
|
||||
{
|
||||
CParticleInstance * pInstance;
|
||||
|
||||
pInstance = CParticleInstance::New();
|
||||
pInstance->m_pParticleProperty = m_pParticleProperty;
|
||||
pInstance->m_pEmitterProperty = m_pEmitterProperty;
|
||||
|
||||
// LifeTime
|
||||
pInstance->m_fLifeTime = fLifeTime;
|
||||
pInstance->m_fLastLifeTime = fLifeTime;
|
||||
|
||||
// Position
|
||||
switch (m_pEmitterProperty->GetEmitterShape())
|
||||
{
|
||||
case CEmitterProperty::EMITTER_SHAPE_POINT:
|
||||
pInstance->m_v3Position.x = 0.0f;
|
||||
pInstance->m_v3Position.y = 0.0f;
|
||||
pInstance->m_v3Position.z = 0.0f;
|
||||
break;
|
||||
|
||||
case CEmitterProperty::EMITTER_SHAPE_ELLIPSE:
|
||||
pInstance->m_v3Position.x = frandom(-500.0f, 500.0f);
|
||||
pInstance->m_v3Position.y = frandom(-500.0f, 500.0f);
|
||||
pInstance->m_v3Position.z = 0.0f;
|
||||
D3DXVec3Normalize(&pInstance->m_v3Position, &pInstance->m_v3Position);
|
||||
|
||||
if (m_pEmitterProperty->isEmitFromEdge())
|
||||
{
|
||||
pInstance->m_v3Position *= (m_pEmitterProperty->m_fEmittingRadius + fEmittingSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
pInstance->m_v3Position *= (frandom(0.0f, m_pEmitterProperty->m_fEmittingRadius) + fEmittingSize);
|
||||
}
|
||||
break;
|
||||
|
||||
case CEmitterProperty::EMITTER_SHAPE_SQUARE:
|
||||
pInstance->m_v3Position.x = (frandom(-m_pEmitterProperty->m_v3EmittingSize.x/2.0f, m_pEmitterProperty->m_v3EmittingSize.x/2.0f) + fEmittingSize);
|
||||
pInstance->m_v3Position.y = (frandom(-m_pEmitterProperty->m_v3EmittingSize.y/2.0f, m_pEmitterProperty->m_v3EmittingSize.y/2.0f) + fEmittingSize);
|
||||
pInstance->m_v3Position.z = (frandom(-m_pEmitterProperty->m_v3EmittingSize.z/2.0f, m_pEmitterProperty->m_v3EmittingSize.z/2.0f) + fEmittingSize);
|
||||
break;
|
||||
|
||||
case CEmitterProperty::EMITTER_SHAPE_SPHERE:
|
||||
pInstance->m_v3Position.x = frandom(-500.0f, 500.0f);
|
||||
pInstance->m_v3Position.y = frandom(-500.0f, 500.0f);
|
||||
pInstance->m_v3Position.z = frandom(-500.0f, 500.0f);
|
||||
D3DXVec3Normalize(&pInstance->m_v3Position, &pInstance->m_v3Position);
|
||||
|
||||
if (m_pEmitterProperty->isEmitFromEdge())
|
||||
{
|
||||
pInstance->m_v3Position *= (m_pEmitterProperty->m_fEmittingRadius + fEmittingSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
pInstance->m_v3Position *= (frandom(0.0f, m_pEmitterProperty->m_fEmittingRadius) + fEmittingSize);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Position
|
||||
D3DXVECTOR3 v3TimePosition=_v3TimePosition;
|
||||
|
||||
pInstance->m_v3Position += v3TimePosition;
|
||||
|
||||
if (mc_pmatLocal && !m_pParticleProperty->m_bAttachFlag)
|
||||
{
|
||||
D3DXVec3TransformCoord(&pInstance->m_v3Position,&pInstance->m_v3Position,mc_pmatLocal);
|
||||
D3DXVec3TransformCoord(&v3TimePosition, &v3TimePosition, mc_pmatLocal);
|
||||
}
|
||||
pInstance->m_v3StartPosition = v3TimePosition;
|
||||
//pInstance->m_v3LastPosition = pInstance->m_v3Position;
|
||||
|
||||
// Direction & Velocity
|
||||
pInstance->m_v3Velocity.x = 0.0f;
|
||||
pInstance->m_v3Velocity.y = 0.0f;
|
||||
pInstance->m_v3Velocity.z = 0.0f;
|
||||
|
||||
if (CEmitterProperty::EMITTER_ADVANCED_TYPE_INNER == m_pEmitterProperty->GetEmitterAdvancedType())
|
||||
{
|
||||
auto val = (pInstance->m_v3Position-v3TimePosition);
|
||||
D3DXVec3Normalize(&pInstance->m_v3Velocity, &val);
|
||||
pInstance->m_v3Velocity *= -100.0f;
|
||||
}
|
||||
else if (CEmitterProperty::EMITTER_ADVANCED_TYPE_OUTER == m_pEmitterProperty->GetEmitterAdvancedType())
|
||||
{
|
||||
if (m_pEmitterProperty->GetEmitterShape() == CEmitterProperty::EMITTER_SHAPE_POINT)
|
||||
{
|
||||
pInstance->m_v3Velocity.x = frandom(-100.0f, 100.0f);
|
||||
pInstance->m_v3Velocity.y = frandom(-100.0f, 100.0f);
|
||||
pInstance->m_v3Velocity.z = frandom(-100.0f, 100.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto val = (pInstance->m_v3Position-v3TimePosition);
|
||||
D3DXVec3Normalize(&pInstance->m_v3Velocity, &val);
|
||||
pInstance->m_v3Velocity *= 100.0f;
|
||||
}
|
||||
}
|
||||
|
||||
D3DXVECTOR3 v3Velocity = _v3Velocity;
|
||||
if (mc_pmatLocal && !m_pParticleProperty->m_bAttachFlag)
|
||||
{
|
||||
D3DXVec3TransformNormal(&v3Velocity, &v3Velocity, mc_pmatLocal);
|
||||
}
|
||||
|
||||
pInstance->m_v3Velocity += v3Velocity;
|
||||
if (m_pEmitterProperty->m_v3EmittingDirection.x > 0.0f)
|
||||
pInstance->m_v3Velocity.x += frandom(-m_pEmitterProperty->m_v3EmittingDirection.x/2.0f, m_pEmitterProperty->m_v3EmittingDirection.x/2.0f) * 1000.0f;
|
||||
if (m_pEmitterProperty->m_v3EmittingDirection.y > 0.0f)
|
||||
pInstance->m_v3Velocity.y += frandom(-m_pEmitterProperty->m_v3EmittingDirection.y/2.0f, m_pEmitterProperty->m_v3EmittingDirection.y/2.0f) * 1000.0f;
|
||||
if (m_pEmitterProperty->m_v3EmittingDirection.z > 0.0f)
|
||||
pInstance->m_v3Velocity.z += frandom(-m_pEmitterProperty->m_v3EmittingDirection.z/2.0f, m_pEmitterProperty->m_v3EmittingDirection.z/2.0f) * 1000.0f;
|
||||
|
||||
pInstance->m_v3Velocity *= fVelocity;
|
||||
|
||||
// Size
|
||||
pInstance->m_v2HalfSize = v2HalfSize;
|
||||
|
||||
// Rotation
|
||||
pInstance->m_fRotation = m_pParticleProperty->m_wRotationRandomStartingBegin;
|
||||
pInstance->m_fRotation = frandom(m_pParticleProperty->m_wRotationRandomStartingBegin,m_pParticleProperty->m_wRotationRandomStartingEnd);
|
||||
if (BILLBOARD_TYPE_LIE == m_pParticleProperty->m_byBillboardType && mc_pmatLocal)
|
||||
{
|
||||
pInstance->m_fRotation += fLieRotation;
|
||||
}
|
||||
|
||||
// Texture Animation
|
||||
pInstance->m_byFrameIndex = 0;
|
||||
pInstance->m_byTextureAnimationType = m_pParticleProperty->GetTextureAnimationType();
|
||||
|
||||
if (m_pParticleProperty->GetTextureAnimationFrameCount() > 1)
|
||||
{
|
||||
if (CParticleProperty::TEXTURE_ANIMATION_TYPE_RANDOM_DIRECTION == m_pParticleProperty->GetTextureAnimationType())
|
||||
{
|
||||
if (random() & 1)
|
||||
{
|
||||
pInstance->m_byFrameIndex = 0;
|
||||
pInstance->m_byTextureAnimationType = CParticleProperty::TEXTURE_ANIMATION_TYPE_CW;
|
||||
}
|
||||
else
|
||||
{
|
||||
pInstance->m_byFrameIndex = m_pParticleProperty->GetTextureAnimationFrameCount() - 1;
|
||||
pInstance->m_byTextureAnimationType = CParticleProperty::TEXTURE_ANIMATION_TYPE_CCW;
|
||||
}
|
||||
}
|
||||
if (m_pParticleProperty->m_bTexAniRandomStartFrameFlag)
|
||||
{
|
||||
pInstance->m_byFrameIndex = random_range(0,m_pParticleProperty->GetTextureAnimationFrameCount()-1);
|
||||
}
|
||||
}
|
||||
|
||||
// Simple Update
|
||||
{
|
||||
pInstance->m_v3LastPosition = pInstance->m_v3Position - (pInstance->m_v3Velocity * fElapsedTime);
|
||||
pInstance->m_v2Scale.x = m_pParticleProperty->m_TimeEventScaleX.front().m_Value;
|
||||
pInstance->m_v2Scale.y= m_pParticleProperty->m_TimeEventScaleY.front().m_Value;
|
||||
//pInstance->m_v2Scale = m_pParticleProperty->m_TimeEventScaleXY.front().m_Value;
|
||||
#ifdef WORLD_EDITOR
|
||||
pInstance->m_Color.r = m_pParticleProperty->m_TimeEventColorRed.front().m_Value;
|
||||
pInstance->m_Color.g = m_pParticleProperty->m_TimeEventColorGreen.front().m_Value;
|
||||
pInstance->m_Color.b = m_pParticleProperty->m_TimeEventColorBlue.front().m_Value;
|
||||
pInstance->m_Color.a = m_pParticleProperty->m_TimeEventAlpha.front().m_Value;
|
||||
#else
|
||||
pInstance->m_dcColor = m_pParticleProperty->m_TimeEventColor.front().m_Value;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!pFirstInstance)
|
||||
{
|
||||
m_pData->BuildDecorator(pInstance);
|
||||
pFirstInstance = pInstance;
|
||||
}
|
||||
else
|
||||
{
|
||||
pInstance->m_pDecorator = pFirstInstance->m_pDecorator->Clone(pFirstInstance,pInstance);
|
||||
}
|
||||
|
||||
m_ParticleInstanceListVector[pInstance->m_byFrameIndex].push_back(pInstance);
|
||||
m_dwCurrentEmissionCount++;
|
||||
}
|
||||
}
|
||||
|
||||
bool CParticleSystemInstance::OnUpdate(float fElapsedTime)
|
||||
{
|
||||
bool bMakeParticle = true;
|
||||
|
||||
/////
|
||||
|
||||
if (m_fLocalTime >= m_pEmitterProperty->GetCycleLength())
|
||||
{
|
||||
if (m_pEmitterProperty->isCycleLoop() && --m_iLoopCount!=0)
|
||||
{
|
||||
if (m_iLoopCount<0)
|
||||
m_iLoopCount = 0;
|
||||
m_fLocalTime = m_fLocalTime - m_pEmitterProperty->GetCycleLength();
|
||||
}
|
||||
else
|
||||
{
|
||||
bMakeParticle = false;
|
||||
m_iLoopCount=1;
|
||||
if (GetEmissionCount()==0)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/////
|
||||
|
||||
int dwFrameIndex;
|
||||
int dwFrameCount = m_pParticleProperty->GetTextureAnimationFrameCount();
|
||||
|
||||
float fAngularVelocity;
|
||||
m_pEmitterProperty->GetEmittingAngularVelocity(m_fLocalTime,&fAngularVelocity);
|
||||
|
||||
if (fAngularVelocity && !m_pParticleProperty->m_bAttachFlag)
|
||||
{
|
||||
auto val = D3DXVECTOR3(0.0f,0.0f,1.0f);
|
||||
D3DXVec3TransformNormal(&m_pParticleProperty->m_v3ZAxis,&val,mc_pmatLocal);
|
||||
}
|
||||
|
||||
for (dwFrameIndex = 0; dwFrameIndex < dwFrameCount; dwFrameIndex++)
|
||||
{
|
||||
TParticleInstanceList::iterator itor = m_ParticleInstanceListVector[dwFrameIndex].begin();
|
||||
for (; itor != m_ParticleInstanceListVector[dwFrameIndex].end();)
|
||||
{
|
||||
CParticleInstance * pInstance = *itor;
|
||||
|
||||
if (!pInstance->Update(fElapsedTime,fAngularVelocity))
|
||||
{
|
||||
pInstance->DeleteThis();
|
||||
|
||||
itor = m_ParticleInstanceListVector[dwFrameIndex].erase(itor);
|
||||
m_dwCurrentEmissionCount--;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pInstance->m_byFrameIndex != dwFrameIndex)
|
||||
{
|
||||
m_ParticleInstanceListVector[dwFrameCount+pInstance->m_byFrameIndex].push_back(*itor);
|
||||
itor = m_ParticleInstanceListVector[dwFrameIndex].erase(itor);
|
||||
}
|
||||
else
|
||||
++itor;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isActive() && bMakeParticle)
|
||||
CreateParticles(fElapsedTime);
|
||||
|
||||
for (dwFrameIndex = 0; dwFrameIndex < dwFrameCount; ++dwFrameIndex)
|
||||
{
|
||||
m_ParticleInstanceListVector[dwFrameIndex].splice(m_ParticleInstanceListVector[dwFrameIndex].end(),m_ParticleInstanceListVector[dwFrameIndex+dwFrameCount]);
|
||||
m_ParticleInstanceListVector[dwFrameIndex+dwFrameCount].clear();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace NParticleRenderer
|
||||
{
|
||||
struct TwoSideRenderer
|
||||
{
|
||||
const D3DXMATRIX * pmat;
|
||||
TwoSideRenderer(const D3DXMATRIX * pmat=NULL)
|
||||
: pmat(pmat)
|
||||
{
|
||||
}
|
||||
|
||||
inline void operator () (CParticleInstance * pInstance)
|
||||
{
|
||||
pInstance->Transform(pmat,D3DXToRadian(-30.0f));
|
||||
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pInstance->GetParticleMeshPointer(), sizeof(TPTVertex));
|
||||
|
||||
pInstance->Transform(pmat,D3DXToRadian(+30.0f));
|
||||
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pInstance->GetParticleMeshPointer(), sizeof(TPTVertex));
|
||||
}
|
||||
};
|
||||
|
||||
struct ThreeSideRenderer
|
||||
{
|
||||
const D3DXMATRIX * pmat;
|
||||
ThreeSideRenderer(const D3DXMATRIX * pmat=NULL)
|
||||
: pmat(pmat)
|
||||
{
|
||||
}
|
||||
|
||||
inline void operator () (CParticleInstance * pInstance)
|
||||
{
|
||||
pInstance->Transform(pmat);
|
||||
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pInstance->GetParticleMeshPointer(), sizeof(TPTVertex));
|
||||
pInstance->Transform(pmat,D3DXToRadian(-60.0f));
|
||||
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pInstance->GetParticleMeshPointer(), sizeof(TPTVertex));
|
||||
pInstance->Transform(pmat,D3DXToRadian(+60.0f));
|
||||
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pInstance->GetParticleMeshPointer(), sizeof(TPTVertex));
|
||||
}
|
||||
};
|
||||
|
||||
struct NormalRenderer
|
||||
{
|
||||
inline void operator () (CParticleInstance * pInstance)
|
||||
{
|
||||
pInstance->Transform();
|
||||
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pInstance->GetParticleMeshPointer(), sizeof(TPTVertex));
|
||||
}
|
||||
};
|
||||
struct AttachRenderer
|
||||
{
|
||||
const D3DXMATRIX* pmat;
|
||||
AttachRenderer(const D3DXMATRIX * pmat)
|
||||
: pmat(pmat)
|
||||
{
|
||||
}
|
||||
|
||||
inline void operator () (CParticleInstance * pInstance)
|
||||
{
|
||||
pInstance->Transform(pmat);
|
||||
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pInstance->GetParticleMeshPointer(), sizeof(TPTVertex));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void CParticleSystemInstance::OnRender()
|
||||
{
|
||||
CScreen::Identity();
|
||||
STATEMANAGER.SetRenderState(D3DRS_SRCBLEND, m_pParticleProperty->m_bySrcBlendType);
|
||||
STATEMANAGER.SetRenderState(D3DRS_DESTBLEND, m_pParticleProperty->m_byDestBlendType);
|
||||
STATEMANAGER.SetTextureStageState(0,D3DTSS_COLOROP,m_pParticleProperty->m_byColorOperationType);
|
||||
if (m_pParticleProperty->m_byBillboardType < BILLBOARD_TYPE_2FACE)
|
||||
{
|
||||
if (!m_pParticleProperty->m_bAttachFlag)
|
||||
{
|
||||
ForEachParticleRendering(NParticleRenderer::NormalRenderer());
|
||||
}
|
||||
else
|
||||
{
|
||||
ForEachParticleRendering(NParticleRenderer::AttachRenderer(mc_pmatLocal));
|
||||
}
|
||||
}
|
||||
else if (m_pParticleProperty->m_byBillboardType == BILLBOARD_TYPE_2FACE)
|
||||
{
|
||||
if (!m_pParticleProperty->m_bAttachFlag)
|
||||
{
|
||||
ForEachParticleRendering(NParticleRenderer::TwoSideRenderer());
|
||||
}
|
||||
else
|
||||
{
|
||||
ForEachParticleRendering(NParticleRenderer::TwoSideRenderer(mc_pmatLocal));
|
||||
}
|
||||
}
|
||||
else if (m_pParticleProperty->m_byBillboardType == BILLBOARD_TYPE_3FACE)
|
||||
{
|
||||
if (!m_pParticleProperty->m_bAttachFlag)
|
||||
{
|
||||
ForEachParticleRendering(NParticleRenderer::ThreeSideRenderer());
|
||||
}
|
||||
else
|
||||
{
|
||||
ForEachParticleRendering(NParticleRenderer::ThreeSideRenderer(mc_pmatLocal));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CParticleSystemInstance::OnSetDataPointer(CEffectElementBase * pElement)
|
||||
{
|
||||
m_pData = (CParticleSystemData *)pElement;
|
||||
|
||||
m_dwCurrentEmissionCount = 0;
|
||||
m_pParticleProperty = m_pData->GetParticlePropertyPointer();
|
||||
m_pEmitterProperty = m_pData->GetEmitterPropertyPointer();
|
||||
m_iLoopCount = m_pEmitterProperty->GetLoopCount();
|
||||
m_ParticleInstanceListVector.resize(m_pParticleProperty->GetTextureAnimationFrameCount()*2+2);
|
||||
|
||||
/////
|
||||
|
||||
assert(m_kVct_pkImgInst.empty());
|
||||
m_kVct_pkImgInst.reserve(m_pParticleProperty->m_ImageVector.size());
|
||||
for (DWORD i = 0; i < m_pParticleProperty->m_ImageVector.size(); ++i)
|
||||
{
|
||||
CGraphicImage * pImage = m_pParticleProperty->m_ImageVector[i];
|
||||
|
||||
CGraphicImageInstance* pkImgInstNew = CGraphicImageInstance::New();
|
||||
pkImgInstNew->SetImagePointer(pImage);
|
||||
m_kVct_pkImgInst.push_back(pkImgInstNew);
|
||||
}
|
||||
}
|
||||
|
||||
void CParticleSystemInstance::OnInitialize()
|
||||
{
|
||||
m_dwCurrentEmissionCount = 0;
|
||||
m_iLoopCount = 0;
|
||||
m_fEmissionResidue = 0.0f;
|
||||
}
|
||||
|
||||
void CParticleSystemInstance::OnDestroy()
|
||||
{
|
||||
TParticleInstanceListVector::iterator i;
|
||||
for(i = m_ParticleInstanceListVector.begin(); i!=m_ParticleInstanceListVector.end(); ++i)
|
||||
{
|
||||
TParticleInstanceList& rkLst_kParticleInst=*i;
|
||||
|
||||
TParticleInstanceList::iterator j;
|
||||
for(j = rkLst_kParticleInst.begin(); j!=rkLst_kParticleInst.end(); ++j)
|
||||
{
|
||||
CParticleInstance* pkParticleInst=*j;
|
||||
pkParticleInst->DeleteThis();
|
||||
}
|
||||
|
||||
rkLst_kParticleInst.clear();
|
||||
}
|
||||
m_ParticleInstanceListVector.clear();
|
||||
|
||||
std::for_each(m_kVct_pkImgInst.begin(), m_kVct_pkImgInst.end(), CGraphicImageInstance::Delete);
|
||||
m_kVct_pkImgInst.clear();
|
||||
}
|
||||
|
||||
CParticleSystemInstance::CParticleSystemInstance()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
CParticleSystemInstance::~CParticleSystemInstance()
|
||||
{
|
||||
assert(m_ParticleInstanceListVector.empty());
|
||||
assert(m_kVct_pkImgInst.empty());
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
86
source-client/Srcs/Client/EffectLib/ParticleSystemInstance.h
Normal file
86
source-client/Srcs/Client/EffectLib/ParticleSystemInstance.h
Normal file
@ -0,0 +1,86 @@
|
||||
#pragma once
|
||||
|
||||
#include "EffectElementBaseInstance.h"
|
||||
#include "ParticleInstance.h"
|
||||
#include "ParticleProperty.h"
|
||||
|
||||
#include "../eterlib/GrpScreen.h"
|
||||
#include "../eterlib/StateManager.h"
|
||||
#include "../eterLib/GrpImageInstance.h"
|
||||
#include "EmitterProperty.h"
|
||||
|
||||
class CParticleSystemInstance : public CEffectElementBaseInstance
|
||||
{
|
||||
public:
|
||||
static void DestroySystem();
|
||||
|
||||
static CParticleSystemInstance* New();
|
||||
static void Delete(CParticleSystemInstance* pkData);
|
||||
|
||||
static CDynamicPool<CParticleSystemInstance> ms_kPool;
|
||||
|
||||
public:
|
||||
template <typename T>
|
||||
inline void ForEachParticleRendering(T && FunObj)
|
||||
{
|
||||
DWORD dwFrameIndex;
|
||||
for(dwFrameIndex=0; dwFrameIndex<m_kVct_pkImgInst.size(); dwFrameIndex++)
|
||||
{
|
||||
STATEMANAGER.SetTexture(0, m_kVct_pkImgInst[dwFrameIndex]->GetTextureReference().GetD3DTexture());
|
||||
TParticleInstanceList::iterator itor = m_ParticleInstanceListVector[dwFrameIndex].begin();
|
||||
for (; itor != m_ParticleInstanceListVector[dwFrameIndex].end(); ++itor)
|
||||
{
|
||||
if (!InFrustum(*itor))
|
||||
return;
|
||||
FunObj(*itor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CParticleSystemInstance();
|
||||
virtual ~CParticleSystemInstance();
|
||||
|
||||
void OnSetDataPointer(CEffectElementBase * pElement);
|
||||
|
||||
void CreateParticles(float fElapsedTime);
|
||||
|
||||
inline bool InFrustum(CParticleInstance * pInstance)
|
||||
{
|
||||
if (m_pParticleProperty->m_bAttachFlag)
|
||||
return CScreen::GetFrustum().ViewVolumeTest(Vector3d(
|
||||
pInstance->m_v3Position.x + mc_pmatLocal->_41,
|
||||
pInstance->m_v3Position.y + mc_pmatLocal->_42,
|
||||
pInstance->m_v3Position.z + mc_pmatLocal->_43
|
||||
),pInstance->GetRadiusApproximation())!=VS_OUTSIDE;
|
||||
else
|
||||
return CScreen::GetFrustum().ViewVolumeTest(Vector3d(pInstance->m_v3Position.x,pInstance->m_v3Position.y,pInstance->m_v3Position.z),pInstance->GetRadiusApproximation())!=VS_OUTSIDE;
|
||||
}
|
||||
|
||||
DWORD GetEmissionCount();
|
||||
|
||||
protected:
|
||||
void OnInitialize();
|
||||
void OnDestroy();
|
||||
|
||||
bool OnUpdate(float fElapsedTime);
|
||||
void OnRender();
|
||||
|
||||
protected:
|
||||
float m_fEmissionResidue;
|
||||
|
||||
DWORD m_dwCurrentEmissionCount;
|
||||
int m_iLoopCount;
|
||||
|
||||
typedef std::list<CParticleInstance*> TParticleInstanceList;
|
||||
typedef std::vector<TParticleInstanceList> TParticleInstanceListVector;
|
||||
TParticleInstanceListVector m_ParticleInstanceListVector;
|
||||
|
||||
typedef std::vector<CGraphicImageInstance*> TImageInstanceVector;
|
||||
TImageInstanceVector m_kVct_pkImgInst;
|
||||
|
||||
CParticleSystemData * m_pData;
|
||||
|
||||
CParticleProperty * m_pParticleProperty;
|
||||
CEmitterProperty * m_pEmitterProperty;
|
||||
};
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
162
source-client/Srcs/Client/EffectLib/SimpleLightData.cpp
Normal file
162
source-client/Srcs/Client/EffectLib/SimpleLightData.cpp
Normal file
@ -0,0 +1,162 @@
|
||||
#include "StdAfx.h"
|
||||
#include "SimpleLightData.h"
|
||||
|
||||
CDynamicPool<CLightData> CLightData::ms_kPool;
|
||||
|
||||
void CLightData::DestroySystem()
|
||||
{
|
||||
ms_kPool.Destroy();
|
||||
}
|
||||
|
||||
CLightData* CLightData::New()
|
||||
{
|
||||
return ms_kPool.Alloc();
|
||||
}
|
||||
|
||||
void CLightData::Delete(CLightData* pkData)
|
||||
{
|
||||
pkData->Clear();
|
||||
ms_kPool.Free(pkData);
|
||||
}
|
||||
|
||||
void CLightData::OnClear()
|
||||
{
|
||||
m_fMaxRange = 300.0f;
|
||||
|
||||
m_TimeEventTableRange.clear();
|
||||
|
||||
m_cAmbient.r = 0.5f;
|
||||
m_cAmbient.g = 0.5f;
|
||||
m_cAmbient.b = 0.5f;
|
||||
m_cAmbient.a = 1.0f;
|
||||
m_cDiffuse.r = 0.0f;
|
||||
m_cDiffuse.g = 0.0f;
|
||||
m_cDiffuse.b = 0.0f;
|
||||
m_cDiffuse.a = 1.0f;
|
||||
|
||||
m_fDuration = 1.0f;
|
||||
|
||||
m_fAttenuation0 = 0.0f;
|
||||
m_fAttenuation1 = 0.1f;
|
||||
m_fAttenuation2 = 0.0f;
|
||||
|
||||
m_bLoopFlag = false;
|
||||
m_iLoopCount = 0;
|
||||
}
|
||||
void CLightData::GetRange(float fTime, float& rRange)
|
||||
{
|
||||
if (m_TimeEventTableRange.empty())
|
||||
{
|
||||
rRange = 1.0f * m_fMaxRange;
|
||||
if (rRange<0.0f)
|
||||
rRange = 0.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
GetTimeEventBlendValue(fTime, m_TimeEventTableRange, &rRange);
|
||||
rRange *= m_fMaxRange;
|
||||
if (rRange<0.0f)
|
||||
rRange = 0.0f;
|
||||
return;
|
||||
/*
|
||||
float vecLastRange = m_TimeEventTableRange[0].m_Value;
|
||||
|
||||
for (DWORD dwIndex = 0; dwIndex < m_TimeEventTableRange.size(); ++dwIndex)
|
||||
{
|
||||
if(fTime < m_TimeEventTableRange[dwIndex].m_fTime)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (dwIndex >= m_TimeEventTableRange.size())
|
||||
{
|
||||
rRange = m_TimeEventTableRange[m_TimeEventTableRange.size()-1].m_Value * m_fMaxRange;
|
||||
if (rRange<0.0f)
|
||||
rRange = 0.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
TTimeEventTypeFloat & rEffectRange = m_TimeEventTableRange[dwIndex];
|
||||
TTimeEventTypeFloat & rPrevEffectRange = m_TimeEventTableRange[dwIndex-1];
|
||||
|
||||
float Head = fabs(rEffectRange.m_fTime - fTime) / fabs(rEffectRange.m_fTime - rPrevEffectRange.m_fTime);
|
||||
float Tail = 1.0f - fabs(rEffectRange.m_fTime - fTime) / fabs(rEffectRange.m_fTime - rPrevEffectRange.m_fTime);
|
||||
rRange = ((rPrevEffectRange.m_Value*Head) + (rEffectRange.m_Value*Tail) )*m_fMaxRange;
|
||||
if (rRange<0.0f)
|
||||
rRange = 0.0f;
|
||||
*/
|
||||
}
|
||||
|
||||
bool CLightData::OnIsData()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL CLightData::OnLoadScript(CTextFileLoader & rTextFileLoader)
|
||||
{
|
||||
if (!rTextFileLoader.GetTokenFloat("duration",&m_fDuration))
|
||||
m_fDuration = 1.0f;
|
||||
|
||||
if (!rTextFileLoader.GetTokenBoolean("loopflag",&m_bLoopFlag))
|
||||
m_bLoopFlag = false;
|
||||
|
||||
if (!rTextFileLoader.GetTokenInteger("loopcount",&m_iLoopCount))
|
||||
m_iLoopCount = 0;
|
||||
|
||||
if (!rTextFileLoader.GetTokenColor("ambientcolor",&m_cAmbient))
|
||||
return FALSE;
|
||||
|
||||
if (!rTextFileLoader.GetTokenColor("diffusecolor",&m_cDiffuse))
|
||||
return FALSE;
|
||||
|
||||
if (!rTextFileLoader.GetTokenFloat("maxrange",&m_fMaxRange))
|
||||
return FALSE;
|
||||
|
||||
if (!rTextFileLoader.GetTokenFloat("attenuation0",&m_fAttenuation0))
|
||||
return FALSE;
|
||||
|
||||
if (!rTextFileLoader.GetTokenFloat("attenuation1",&m_fAttenuation1))
|
||||
return FALSE;
|
||||
|
||||
if (!rTextFileLoader.GetTokenFloat("attenuation2",&m_fAttenuation2))
|
||||
return FALSE;
|
||||
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader,"timeeventrange",&m_TimeEventTableRange))
|
||||
{
|
||||
m_TimeEventTableRange.clear();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CLightData::CLightData()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
CLightData::~CLightData()
|
||||
{
|
||||
}
|
||||
|
||||
float CLightData::GetDuration()
|
||||
{
|
||||
return m_fDuration;
|
||||
}
|
||||
void CLightData::InitializeLight(D3DLIGHT8& light)
|
||||
{
|
||||
light.Type = D3DLIGHT_POINT;
|
||||
|
||||
light.Ambient = m_cAmbient;
|
||||
light.Diffuse = m_cDiffuse;
|
||||
light.Attenuation0 = m_fAttenuation0;
|
||||
light.Attenuation1 = m_fAttenuation1;
|
||||
light.Attenuation2 = m_fAttenuation2;
|
||||
|
||||
D3DXVECTOR3 position;
|
||||
GetPosition( 0.0f, position);
|
||||
light.Position = position;
|
||||
|
||||
GetRange(0.0f, light.Range);
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
58
source-client/Srcs/Client/EffectLib/SimpleLightData.h
Normal file
58
source-client/Srcs/Client/EffectLib/SimpleLightData.h
Normal file
@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3dx8.h>
|
||||
|
||||
#include "../eterLib/TextFileLoader.h"
|
||||
|
||||
#include "Type.h"
|
||||
#include "EffectElementBase.h"
|
||||
|
||||
class CLightData : public CEffectElementBase
|
||||
{
|
||||
friend class CLightInstance;
|
||||
public:
|
||||
CLightData();
|
||||
virtual ~CLightData();
|
||||
|
||||
void GetRange(float fTime, float& rRange);
|
||||
float GetDuration();
|
||||
BOOL isLoop()
|
||||
{
|
||||
return m_bLoopFlag;
|
||||
}
|
||||
int GetLoopCount()
|
||||
{
|
||||
return m_iLoopCount;
|
||||
}
|
||||
void InitializeLight(D3DLIGHT8& light);
|
||||
|
||||
protected:
|
||||
void OnClear();
|
||||
bool OnIsData();
|
||||
|
||||
BOOL OnLoadScript(CTextFileLoader & rTextFileLoader);
|
||||
|
||||
protected:
|
||||
float m_fMaxRange;
|
||||
float m_fDuration;
|
||||
TTimeEventTableFloat m_TimeEventTableRange;
|
||||
|
||||
D3DXCOLOR m_cAmbient;
|
||||
D3DXCOLOR m_cDiffuse;
|
||||
|
||||
BOOL m_bLoopFlag;
|
||||
int m_iLoopCount;
|
||||
|
||||
float m_fAttenuation0;
|
||||
float m_fAttenuation1;
|
||||
float m_fAttenuation2;
|
||||
|
||||
public:
|
||||
static void DestroySystem();
|
||||
|
||||
static CLightData* New();
|
||||
static void Delete(CLightData* pkData);
|
||||
|
||||
static CDynamicPool<CLightData> ms_kPool;
|
||||
};
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
139
source-client/Srcs/Client/EffectLib/SimpleLightInstance.cpp
Normal file
139
source-client/Srcs/Client/EffectLib/SimpleLightInstance.cpp
Normal file
@ -0,0 +1,139 @@
|
||||
#include "Stdafx.h"
|
||||
#include "../eterLib/GrpLightManager.h"
|
||||
|
||||
#include "SimpleLightInstance.h"
|
||||
|
||||
CDynamicPool<CLightInstance> CLightInstance::ms_kPool;
|
||||
|
||||
void CLightInstance::DestroySystem()
|
||||
{
|
||||
ms_kPool.Destroy();
|
||||
}
|
||||
|
||||
CLightInstance* CLightInstance::New()
|
||||
{
|
||||
return ms_kPool.Alloc();
|
||||
}
|
||||
|
||||
void CLightInstance::Delete(CLightInstance* pkData)
|
||||
{
|
||||
pkData->Destroy();
|
||||
ms_kPool.Free(pkData);
|
||||
}
|
||||
|
||||
void CLightInstance::OnSetDataPointer(CEffectElementBase * pElement)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
m_pData = ((CLightData*)pElement);
|
||||
|
||||
m_iLoopCount = m_pData->GetLoopCount();
|
||||
|
||||
D3DLIGHT8 Light;
|
||||
m_pData->InitializeLight(Light);
|
||||
CLightManager::Instance().RegisterLight(LIGHT_TYPE_DYNAMIC, &m_LightID, Light);
|
||||
}
|
||||
|
||||
bool CLightInstance::OnUpdate(float fElapsedTime)
|
||||
{
|
||||
if (!isActive())
|
||||
{
|
||||
Destroy();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_fLocalTime >= m_pData->GetDuration())
|
||||
{
|
||||
if (m_pData->isLoop() && --m_iLoopCount!=0)
|
||||
{
|
||||
if (m_iLoopCount<0)
|
||||
m_iLoopCount = 0;
|
||||
m_fLocalTime -= m_pData->GetDuration();
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy();
|
||||
m_iLoopCount = 1;
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
if (!m_pData->isLoop())
|
||||
{
|
||||
OnClear();
|
||||
return false;
|
||||
}
|
||||
m_fLocalTime -= m_pData->GetDuration();
|
||||
*/
|
||||
}
|
||||
|
||||
CLight * pLight = CLightManager::Instance().GetLight(m_LightID);
|
||||
|
||||
if (pLight)
|
||||
{
|
||||
pLight->SetAmbientColor(m_pData->m_cAmbient.r, m_pData->m_cAmbient.g, m_pData->m_cAmbient.b, m_pData->m_cAmbient.a);
|
||||
pLight->SetDiffuseColor(m_pData->m_cDiffuse.r, m_pData->m_cDiffuse.g, m_pData->m_cDiffuse.b, m_pData->m_cDiffuse.a);
|
||||
|
||||
/*if (m_pData->m_TimeEventTableRange.size()
|
||||
&& m_fLocalTime>=m_pData->GetDuration()*m_pData->m_TimeEventTableRange[m_dwRangeIndex].m_fTime)
|
||||
{
|
||||
while(m_dwRangeIndex<m_pData->m_TimeEventTableRange.size()
|
||||
&& m_fLocalTime>=m_pData->GetDuration()*m_pData->m_TimeEventTableRange[m_dwRangeIndex].m_fTime)
|
||||
m_dwRangeIndex++;
|
||||
float fLastTime;
|
||||
float fLastRange=m_pData->m_TimeEventTableRange[m_pData->m_TimeEventTableRange.size()-1].m_Value;
|
||||
if (m_dwRangeIndex == m_pData->m_TimeEventTableRange.size())
|
||||
fLastTime = 1.0f;
|
||||
else
|
||||
{
|
||||
fLastTime = m_pData->m_TimeEventTableRange[m_dwRangeIndex].m_fTime;
|
||||
fLastRange = m_pData->m_TimeEventTableRange[m_dwRangeIndex].m_Value;
|
||||
}
|
||||
m_dwRangeIndex--;
|
||||
pLight->BlendRange(fLastRange*m_pData->m_fMaxRange,
|
||||
(fLastTime-m_pData->m_TimeEventTableRange[m_dwRangeIndex].m_fTime)*m_pData->GetDuration());
|
||||
m_dwRangeIndex++;
|
||||
}*/
|
||||
|
||||
float fRange;
|
||||
m_pData->GetRange(m_fLocalTime, fRange);
|
||||
pLight->SetRange(fRange);
|
||||
|
||||
D3DXVECTOR3 pos;
|
||||
m_pData->GetPosition(m_fLocalTime,pos);
|
||||
D3DXVec3TransformCoord(&pos,&pos,mc_pmatLocal);
|
||||
pLight->SetPosition(pos.x,pos.y,pos.z);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CLightInstance::OnRender()
|
||||
{
|
||||
//OnUpdate(0);
|
||||
}
|
||||
|
||||
void CLightInstance::OnInitialize()
|
||||
{
|
||||
m_LightID = 0;
|
||||
m_dwRangeIndex = 0;
|
||||
}
|
||||
|
||||
void CLightInstance::OnDestroy()
|
||||
{
|
||||
if (m_LightID)
|
||||
{
|
||||
CLightManager::Instance().DeleteLight(m_LightID);
|
||||
}
|
||||
}
|
||||
|
||||
CLightInstance::CLightInstance()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
CLightInstance::~CLightInstance()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
40
source-client/Srcs/Client/EffectLib/SimpleLightInstance.h
Normal file
40
source-client/Srcs/Client/EffectLib/SimpleLightInstance.h
Normal file
@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include "../eterLib/GrpScreen.h"
|
||||
|
||||
#include "EffectElementBaseInstance.h"
|
||||
#include "SimpleLightData.h"
|
||||
|
||||
class CLightInstance : public CEffectElementBaseInstance
|
||||
{
|
||||
public:
|
||||
friend class CLightData;
|
||||
|
||||
CLightInstance();
|
||||
virtual ~CLightInstance();
|
||||
|
||||
protected:
|
||||
|
||||
void OnSetDataPointer(CEffectElementBase * pElement);
|
||||
|
||||
void OnInitialize();
|
||||
void OnDestroy();
|
||||
|
||||
bool OnUpdate(float fElapsedTime);
|
||||
void OnRender();
|
||||
|
||||
DWORD m_LightID;
|
||||
CLightData * m_pData;
|
||||
DWORD m_dwRangeIndex;
|
||||
|
||||
DWORD m_iLoopCount;
|
||||
|
||||
public:
|
||||
static void DestroySystem();
|
||||
|
||||
static CLightInstance* New();
|
||||
static void Delete(CLightInstance* pkData);
|
||||
|
||||
static CDynamicPool<CLightInstance> ms_kPool;
|
||||
};
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
2
source-client/Srcs/Client/EffectLib/StdAfx.cpp
Normal file
2
source-client/Srcs/Client/EffectLib/StdAfx.cpp
Normal file
@ -0,0 +1,2 @@
|
||||
#include "StdAfx.h"
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
41
source-client/Srcs/Client/EffectLib/StdAfx.h
Normal file
41
source-client/Srcs/Client/EffectLib/StdAfx.h
Normal file
@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
//#include <crtdbg.h>
|
||||
|
||||
#include "../eterBase/StdAfx.h"
|
||||
|
||||
#include "../eterBase/Utils.h"
|
||||
#include "../eterBase/Timer.h"
|
||||
#include "../eterBase/CRC32.h"
|
||||
#include "../eterBase/Debug.h"
|
||||
|
||||
#include "../eterLib/StdAfx.h"
|
||||
#include "../eterLib/TextFileLoader.h"
|
||||
|
||||
#include "../milesLib/StdAfx.h"
|
||||
|
||||
/*
|
||||
#include "FrameController.h"
|
||||
|
||||
#include "EffectElementBase.h"
|
||||
#include "EffectElementBaseInstance.h"
|
||||
|
||||
#include "ParticleProperty.h"
|
||||
#include "ParticleInstance.h"
|
||||
#include "EmitterProperty.h"
|
||||
|
||||
#include "ParticleSystemData.h"
|
||||
#include "ParticleSystemInstance.h"
|
||||
|
||||
#include "EffectMesh.h"
|
||||
#include "EffectMeshInstance.h"
|
||||
|
||||
#include "SimpleLightData.h"
|
||||
#include "SimpleLightInstance.h"
|
||||
|
||||
#include "EffectData.h"
|
||||
#include "EffectInstance.h"
|
||||
|
||||
#include "EffectManager.h"
|
||||
*/
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
39
source-client/Srcs/Client/EffectLib/Type.cpp
Normal file
39
source-client/Srcs/Client/EffectLib/Type.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
#include "StdAfx.h"
|
||||
#include "Type.h"
|
||||
|
||||
BOOL GetTokenTimeEventFloat(CTextFileLoader & rTextFileLoader, const char * c_szKey, TTimeEventTableFloat * pTimeEventTableFloat)
|
||||
{
|
||||
CTokenVector * pTokenVector;
|
||||
if (!rTextFileLoader.GetTokenVector(c_szKey, &pTokenVector))
|
||||
return FALSE;
|
||||
|
||||
pTimeEventTableFloat->clear();
|
||||
pTimeEventTableFloat->resize(pTokenVector->size() / 2);
|
||||
|
||||
DWORD dwIndex = 0;
|
||||
for (DWORD i = 0; i < pTokenVector->size(); i+=2, ++dwIndex)
|
||||
{
|
||||
pTimeEventTableFloat->at(dwIndex).m_fTime = atof(pTokenVector->at(i).c_str());
|
||||
pTimeEventTableFloat->at(dwIndex).m_Value = atof(pTokenVector->at(i+1).c_str());
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void InsertItemTimeEventFloat(TTimeEventTableFloat * pTable, float fTime, float fValue)
|
||||
{
|
||||
TTimeEventTableFloat::iterator itor = pTable->begin();
|
||||
for (; itor != pTable->end(); ++itor)
|
||||
{
|
||||
TTimeEventTypeFloat & rTimeEvent = *itor;
|
||||
if (rTimeEvent.m_fTime > fTime)
|
||||
break;
|
||||
}
|
||||
|
||||
TTimeEventTypeFloat TimeEvent;
|
||||
TimeEvent.m_fTime = fTime;
|
||||
TimeEvent.m_Value = fValue;
|
||||
|
||||
pTable->insert(itor, TimeEvent);
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
272
source-client/Srcs/Client/EffectLib/Type.h
Normal file
272
source-client/Srcs/Client/EffectLib/Type.h
Normal file
@ -0,0 +1,272 @@
|
||||
#pragma once
|
||||
|
||||
#define Clamp(x, min, max) x = (x<min ? min : x<max ? x : max);
|
||||
#define GRAVITY D3DXVECTOR3(0.0f, 0.0f, -9.8f)
|
||||
|
||||
#define MAX_FRAME 20
|
||||
#define MAX_TEXTURE 20
|
||||
|
||||
typedef struct _FVF_POINT
|
||||
{
|
||||
float x, y, z;
|
||||
} FVF_POINT;
|
||||
|
||||
#ifndef D3DFVF_POINT
|
||||
#define D3DFVF_POINT (D3DFVF_XYZ)
|
||||
#endif
|
||||
|
||||
typedef struct _FVF_PT
|
||||
{
|
||||
float x, y, z;
|
||||
float tu, tv;
|
||||
} FVF_PT;
|
||||
|
||||
#ifndef D3DFVF_PT
|
||||
#define D3DFVF_PT (D3DFVF_XYZ|D3DFVF_TEX1)
|
||||
#endif
|
||||
|
||||
typedef struct _FVF_PDT
|
||||
{
|
||||
float x, y, z;
|
||||
DWORD color;
|
||||
float tu, tv;
|
||||
} FVF_PDT;
|
||||
|
||||
#ifndef D3DFVF_PDT
|
||||
#define D3DFVF_PDT (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1)
|
||||
#endif
|
||||
|
||||
inline FVF_PDT _FVF_PDT(float x, float y, float z, DWORD dif, float u, float v)
|
||||
{
|
||||
FVF_PDT result;
|
||||
result.x = x; result.y = y; result.z = z; result.color = dif; result.tu = u; result.tv = v;
|
||||
return result;
|
||||
}
|
||||
|
||||
enum EEffectType
|
||||
{
|
||||
EFFECT_TYPE_PARTICLE = 1,
|
||||
EFFECT_TYPE_ANIMATION_TEXTURE = 2,
|
||||
EFFECT_TYPE_MESH = 3,
|
||||
EFFECT_TYPE_SIMPLE_LIGHT = 4,
|
||||
};
|
||||
|
||||
enum EMeshBillBoardType
|
||||
{
|
||||
MESH_BILLBOARD_TYPE_NONE,
|
||||
|
||||
MESH_BILLBOARD_TYPE_ALL,
|
||||
MESH_BILLBOARD_TYPE_Y,
|
||||
|
||||
MESH_BILLBOARD_TYPE_MOVE
|
||||
};
|
||||
|
||||
enum EBillBoardType
|
||||
{
|
||||
BILLBOARD_TYPE_NONE,
|
||||
|
||||
BILLBOARD_TYPE_ALL,
|
||||
BILLBOARD_TYPE_Y,
|
||||
|
||||
BILLBOARD_TYPE_LIE,
|
||||
|
||||
BILLBOARD_TYPE_2FACE, // / and \.
|
||||
BILLBOARD_TYPE_3FACE, // / and \ and -
|
||||
};
|
||||
|
||||
enum EMovingType
|
||||
{
|
||||
MOVING_TYPE_DIRECT,
|
||||
MOVING_TYPE_BEZIER_CURVE,
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct SEffectPosition
|
||||
{
|
||||
float m_fTime;
|
||||
|
||||
D3DXVECTOR3 m_vecPosition;
|
||||
|
||||
// For Bezier Curve
|
||||
int m_iMovingType;
|
||||
D3DXVECTOR3 m_vecControlPoint;
|
||||
} TEffectPosition;
|
||||
|
||||
inline bool operator < (const SEffectPosition & lhs, const SEffectPosition & rhs)
|
||||
{
|
||||
return lhs.m_fTime < rhs.m_fTime;
|
||||
}
|
||||
inline bool operator < (const float & lhs, const SEffectPosition & rhs)
|
||||
{
|
||||
return lhs < rhs.m_fTime;
|
||||
}
|
||||
inline bool operator < (const SEffectPosition & lhs, const float & rhs)
|
||||
{
|
||||
return lhs.m_fTime < rhs;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
class CTimeEvent
|
||||
{
|
||||
public:
|
||||
CTimeEvent(){}
|
||||
~CTimeEvent(){}
|
||||
|
||||
float m_fTime;
|
||||
T m_Value;
|
||||
};
|
||||
#define AG_MASK 0xff00ff00
|
||||
#define RB_MASK 0x00ff00ff
|
||||
|
||||
struct DWORDCOLOR
|
||||
{
|
||||
DWORD m_dwColor;
|
||||
|
||||
DWORDCOLOR()
|
||||
{
|
||||
}
|
||||
DWORDCOLOR(const DWORDCOLOR& r)
|
||||
: m_dwColor(r.m_dwColor)
|
||||
{}
|
||||
|
||||
DWORDCOLOR& operator = (const DWORDCOLOR& r)
|
||||
{
|
||||
m_dwColor = r.m_dwColor;
|
||||
return *this;
|
||||
}
|
||||
|
||||
DWORDCOLOR& operator *= (float f)
|
||||
{
|
||||
DWORD idx = DWORD(f * 256);
|
||||
m_dwColor =
|
||||
(((DWORD)(((m_dwColor & AG_MASK)>>8) * idx)) & AG_MASK)
|
||||
+((DWORD)(((m_dwColor & RB_MASK) * idx)>>8) & RB_MASK);
|
||||
//m_dwColor =
|
||||
// ((DWORD)((m_dwColor & AG_MASK) * f) & AG_MASK)
|
||||
// +((DWORD)((m_dwColor & RB_MASK) * f) & RB_MASK);
|
||||
return *this;
|
||||
}
|
||||
DWORDCOLOR& operator += (const DWORDCOLOR& r)
|
||||
{
|
||||
m_dwColor += r.m_dwColor;
|
||||
return *this;
|
||||
}
|
||||
operator DWORD()
|
||||
{
|
||||
return m_dwColor;
|
||||
}
|
||||
};
|
||||
#undef AG_MASK
|
||||
#undef RB_MASK
|
||||
|
||||
inline DWORDCOLOR operator * (DWORDCOLOR dc, float f)
|
||||
{
|
||||
DWORDCOLOR tmp(dc);
|
||||
tmp *= f;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
inline DWORDCOLOR operator * (float f, DWORDCOLOR dc)
|
||||
{
|
||||
DWORDCOLOR tmp(dc);
|
||||
tmp *= f;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
__forceinline bool operator < (const CTimeEvent<T> & lhs, const CTimeEvent<T> & rhs)
|
||||
{
|
||||
return lhs.m_fTime < rhs.m_fTime;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
__forceinline bool operator < (const CTimeEvent<T> & lhs, const float & rhs)
|
||||
{
|
||||
return lhs.m_fTime < rhs;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
__forceinline bool operator < (const float & lhs, const CTimeEvent<T> & rhs)
|
||||
{
|
||||
return lhs < rhs.m_fTime;
|
||||
}
|
||||
|
||||
typedef CTimeEvent<char> TTimeEventTypeCharacter;
|
||||
typedef CTimeEvent<short> TTimeEventTypeShort;
|
||||
typedef CTimeEvent<float> TTimeEventTypeFloat;
|
||||
typedef CTimeEvent<WORD> TTimeEventTypeWord;
|
||||
typedef CTimeEvent<DWORD> TTimeEventTypeDoubleWord;
|
||||
typedef CTimeEvent<DWORDCOLOR> TTimeEventTypeColor;
|
||||
typedef CTimeEvent<D3DXVECTOR2> TTimeEventTypeVector2;
|
||||
typedef CTimeEvent<D3DXVECTOR3> TTimeEventTypeVector3;
|
||||
|
||||
typedef std::vector<float> TTimeEventTable;
|
||||
typedef std::vector<TEffectPosition> TTimeEventTablePosition;
|
||||
typedef std::vector<TTimeEventTypeCharacter> TTimeEventTableCharacter;
|
||||
typedef std::vector<TTimeEventTypeShort> TTimeEventTableShort;
|
||||
typedef std::vector<TTimeEventTypeFloat> TTimeEventTableFloat;
|
||||
typedef std::vector<TTimeEventTypeWord> TTimeEventTableWord;
|
||||
typedef std::vector<TTimeEventTypeDoubleWord> TTimeEventTableDoubleWord;
|
||||
typedef std::vector<TTimeEventTypeColor> TTimeEventTableColor;
|
||||
typedef std::vector<TTimeEventTypeVector2> TTimeEventTableVector2;
|
||||
typedef std::vector<TTimeEventTypeVector3> TTimeEventTableVector3;
|
||||
|
||||
template <typename T>
|
||||
__forceinline void GetTimeEventBlendValue(float fElapsedTime, std::vector<CTimeEvent<T> >& rVector, T * pReturnValue)
|
||||
{
|
||||
if (rVector.empty())
|
||||
{
|
||||
*pReturnValue = T();
|
||||
return;
|
||||
}
|
||||
|
||||
if(rVector.begin()+1==rVector.end())
|
||||
{
|
||||
*pReturnValue = rVector.front().m_Value;
|
||||
return;
|
||||
}
|
||||
|
||||
if (fElapsedTime < rVector.front().m_fTime)
|
||||
{
|
||||
*pReturnValue = rVector.front().m_Value;
|
||||
return;
|
||||
}
|
||||
|
||||
if (fElapsedTime > rVector.back().m_fTime)
|
||||
{
|
||||
*pReturnValue = rVector.back().m_Value;
|
||||
return;
|
||||
}
|
||||
|
||||
typedef typename std::vector<CTimeEvent<T> >::iterator iterator;
|
||||
|
||||
std::pair<iterator, iterator> result = std::equal_range(rVector.begin(), rVector.end(), fElapsedTime);
|
||||
|
||||
if (result.first != result.second)
|
||||
*pReturnValue = result.first->m_Value;
|
||||
else
|
||||
{
|
||||
--result.first;
|
||||
float Head = (result.second->m_fTime - fElapsedTime) / (result.second->m_fTime - result.first->m_fTime);
|
||||
*pReturnValue = T((result.first->m_Value-result.second->m_Value)*Head+(result.second->m_Value));
|
||||
}
|
||||
}
|
||||
|
||||
extern BOOL GetTokenTimeEventFloat(CTextFileLoader & rTextFileLoader, const char * c_szKey, TTimeEventTableFloat * pTimeEventTableFloat);
|
||||
//extern void InsertItemTimeEventFloat(TTimeEventTableFloat * pTable, float fTime, float fValue);
|
||||
|
||||
template <typename T>
|
||||
void InsertItemTimeEvent(std::vector<CTimeEvent<T> > * pTable, float fTime, T fValue)
|
||||
{
|
||||
typedef std::vector<CTimeEvent<T> >::iterator iterator;
|
||||
|
||||
iterator itor = std::lower_bound(pTable->begin(), pTable->end(), fTime);
|
||||
|
||||
CTimeEvent<T> TimeEvent;
|
||||
TimeEvent.m_fTime = fTime;
|
||||
TimeEvent.m_Value = fValue;
|
||||
|
||||
pTable->insert(itor, TimeEvent);
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
300
source-client/Srcs/Client/EterBase/CPostIt.cpp
Normal file
300
source-client/Srcs/Client/EterBase/CPostIt.cpp
Normal file
@ -0,0 +1,300 @@
|
||||
#include "StdAfx.h"
|
||||
#include "CPostIt.h"
|
||||
#include "../eterBase/utils.h"
|
||||
|
||||
class _CPostItMemoryBlock
|
||||
{
|
||||
public:
|
||||
_CPostItMemoryBlock( void );
|
||||
~_CPostItMemoryBlock( void );
|
||||
|
||||
BOOL Assign( HANDLE hBlock );
|
||||
HANDLE CreateHandle( void );
|
||||
BOOL DestroyHandle( void );
|
||||
|
||||
LPSTR Find( LPCSTR lpszKeyName );
|
||||
BOOL Put( LPCSTR lpBuffer );
|
||||
BOOL Put( LPCSTR lpszKeyName, LPCSTR lpBuffer );
|
||||
BOOL Get( LPCSTR lpszKeyName, LPSTR lpBuffer, DWORD nSize );
|
||||
|
||||
protected:
|
||||
typedef std::list<CHAR *> StrList;
|
||||
typedef StrList::iterator StrListItr;
|
||||
|
||||
HANDLE m_hHandle;
|
||||
StrList m_StrList;
|
||||
};
|
||||
|
||||
CPostIt::CPostIt( LPCSTR szAppName ) : m_pMemoryBlock(NULL), m_bModified(FALSE)
|
||||
{
|
||||
Init( szAppName );
|
||||
}
|
||||
|
||||
CPostIt::~CPostIt( void )
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
BOOL CPostIt::Init( LPCSTR szAppName )
|
||||
{
|
||||
if( szAppName == NULL || !*szAppName ) {
|
||||
strcpy( m_szClipFormatName, "YMCF" );
|
||||
} else {
|
||||
strcpy( m_szClipFormatName, "YMCF_" );
|
||||
strcat( m_szClipFormatName, szAppName );
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CPostIt::CopyTo( CPostIt *pPostIt, LPCSTR lpszKeyName )
|
||||
{
|
||||
if( m_pMemoryBlock == NULL )
|
||||
return FALSE;
|
||||
LPSTR szText = m_pMemoryBlock->Find( lpszKeyName );
|
||||
if( szText == NULL )
|
||||
return FALSE;
|
||||
return pPostIt->Set( szText );
|
||||
}
|
||||
|
||||
BOOL CPostIt::Flush( void )
|
||||
{
|
||||
if( m_bModified == FALSE )
|
||||
return FALSE;
|
||||
if( m_pMemoryBlock == NULL )
|
||||
return FALSE;
|
||||
UINT uDGPFormat;
|
||||
|
||||
uDGPFormat = ::RegisterClipboardFormatA( m_szClipFormatName );
|
||||
if( ::OpenClipboard( NULL ) == FALSE )
|
||||
return FALSE;
|
||||
if( ::SetClipboardData( uDGPFormat, m_pMemoryBlock->CreateHandle() ) == NULL ) {
|
||||
// DWORD dwLastError = ::GetLastError();
|
||||
m_pMemoryBlock->DestroyHandle();
|
||||
::CloseClipboard();
|
||||
m_bModified = FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
::CloseClipboard();
|
||||
m_bModified = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CPostIt::Empty( void )
|
||||
{
|
||||
SAFE_DELETE( m_pMemoryBlock );
|
||||
|
||||
UINT uDGPFormat;
|
||||
|
||||
uDGPFormat = ::RegisterClipboardFormatA( m_szClipFormatName );
|
||||
if( ::OpenClipboard( NULL ) == FALSE )
|
||||
return;
|
||||
HANDLE hClipboardMemory = ::GetClipboardData( uDGPFormat );
|
||||
if( hClipboardMemory ) {
|
||||
// ::GlobalFree( hClipboardMemory );
|
||||
::SetClipboardData( uDGPFormat, NULL );
|
||||
}
|
||||
::CloseClipboard();
|
||||
|
||||
m_bModified = FALSE;
|
||||
}
|
||||
|
||||
void CPostIt::Destroy( void )
|
||||
{
|
||||
Flush();
|
||||
SAFE_DELETE( m_pMemoryBlock );
|
||||
}
|
||||
|
||||
BOOL CPostIt::Set( LPCSTR lpszKeyName, LPCSTR lpBuffer )
|
||||
{
|
||||
if( m_pMemoryBlock == NULL )
|
||||
m_pMemoryBlock = new _CPostItMemoryBlock;
|
||||
m_pMemoryBlock->Put( lpszKeyName, lpBuffer );
|
||||
m_bModified = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CPostIt::Set( LPCSTR lpszKeyName, DWORD dwValue )
|
||||
{
|
||||
CHAR szValue[12];
|
||||
|
||||
_snprintf( szValue, 12, "%d", dwValue );
|
||||
return Set( lpszKeyName, szValue );
|
||||
}
|
||||
|
||||
BOOL CPostIt::Set( LPCSTR lpBuffer )
|
||||
{
|
||||
if( lpBuffer == NULL )
|
||||
return FALSE;
|
||||
if( m_pMemoryBlock == NULL )
|
||||
m_pMemoryBlock = new _CPostItMemoryBlock;
|
||||
m_pMemoryBlock->Put( lpBuffer );
|
||||
m_bModified = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CPostIt::Get( LPCSTR lpszKeyName, LPSTR lpBuffer, DWORD nSize )
|
||||
{
|
||||
if( m_pMemoryBlock == NULL ) {
|
||||
UINT uDGPFormat;
|
||||
|
||||
uDGPFormat = ::RegisterClipboardFormatA( m_szClipFormatName );
|
||||
if( ::OpenClipboard( NULL ) == FALSE )
|
||||
return FALSE;
|
||||
|
||||
HANDLE hClipboardMemory = ::GetClipboardData( uDGPFormat );
|
||||
|
||||
if( hClipboardMemory == NULL ) {
|
||||
::CloseClipboard();
|
||||
return FALSE;
|
||||
}
|
||||
m_pMemoryBlock = new _CPostItMemoryBlock;
|
||||
m_pMemoryBlock->Assign( hClipboardMemory );
|
||||
|
||||
::CloseClipboard();
|
||||
}
|
||||
|
||||
return m_pMemoryBlock->Get( lpszKeyName, lpBuffer, nSize );
|
||||
}
|
||||
|
||||
_CPostItMemoryBlock::_CPostItMemoryBlock( void ) : m_hHandle( NULL )
|
||||
{
|
||||
}
|
||||
|
||||
_CPostItMemoryBlock::~_CPostItMemoryBlock( void )
|
||||
{
|
||||
for( StrListItr itr = m_StrList.begin(); itr != m_StrList.end(); ) {
|
||||
LPSTR lpszText = *itr;
|
||||
SAFE_DELETE_ARRAY( lpszText );
|
||||
itr = m_StrList.erase( itr );
|
||||
}
|
||||
}
|
||||
|
||||
BOOL _CPostItMemoryBlock::Assign( HANDLE hBlock )
|
||||
{
|
||||
if( hBlock == NULL || hBlock == INVALID_HANDLE_VALUE )
|
||||
return FALSE;
|
||||
LPBYTE lpBuffer = (LPBYTE) ::GlobalLock( hBlock );
|
||||
|
||||
if( lpBuffer == NULL )
|
||||
return FALSE;
|
||||
DWORD dwCount = *((LPDWORD) lpBuffer); lpBuffer += sizeof( DWORD );
|
||||
for( DWORD dwI=0; dwI < dwCount; dwI++ ) {
|
||||
WORD wLen = *((LPWORD) lpBuffer); lpBuffer += sizeof( WORD );
|
||||
|
||||
LPSTR lpszText = new CHAR[ wLen + 1 ];
|
||||
::CopyMemory( lpszText, lpBuffer, wLen );
|
||||
lpszText[ wLen ] = '\0';
|
||||
|
||||
lpBuffer += wLen;
|
||||
|
||||
Put( lpszText );
|
||||
}
|
||||
::GlobalUnlock( hBlock );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
HANDLE _CPostItMemoryBlock::CreateHandle( void )
|
||||
{
|
||||
if( m_StrList.size() == 0 )
|
||||
return INVALID_HANDLE_VALUE;
|
||||
DWORD dwBlockSize = sizeof( DWORD );
|
||||
StrListItr itr;
|
||||
|
||||
// Calculation for Memory Block Size
|
||||
for( itr = m_StrList.begin(); itr != m_StrList.end(); ++itr ) {
|
||||
dwBlockSize += sizeof( WORD );
|
||||
dwBlockSize += (DWORD) strlen( *itr );
|
||||
}
|
||||
|
||||
HANDLE hBlock = ::GlobalAlloc( GMEM_ZEROINIT | GMEM_MOVEABLE, dwBlockSize );
|
||||
if( hBlock == NULL )
|
||||
return INVALID_HANDLE_VALUE;
|
||||
LPBYTE lpBuffer = (LPBYTE) ::GlobalLock( hBlock );
|
||||
if( lpBuffer == NULL ) {
|
||||
::GlobalFree( hBlock );
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
*((LPDWORD) lpBuffer) = (DWORD) m_StrList.size(); lpBuffer += sizeof( DWORD );
|
||||
for( itr = m_StrList.begin(); itr != m_StrList.end(); ++itr ) {
|
||||
*((LPWORD) lpBuffer) = (WORD) strlen( *itr ); lpBuffer += sizeof( WORD );
|
||||
::CopyMemory( lpBuffer, *itr, strlen( *itr ) ); lpBuffer += strlen( *itr );
|
||||
}
|
||||
::GlobalUnlock( hBlock );
|
||||
|
||||
m_hHandle = hBlock;
|
||||
return hBlock;
|
||||
}
|
||||
|
||||
BOOL _CPostItMemoryBlock::DestroyHandle( void )
|
||||
{
|
||||
::GlobalFree( m_hHandle );
|
||||
m_hHandle = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
LPSTR _CPostItMemoryBlock::Find( LPCSTR lpszKeyName )
|
||||
{
|
||||
for( StrListItr itr = m_StrList.begin(); itr != m_StrList.end(); ++itr ) {
|
||||
LPSTR lpszText = *itr;
|
||||
|
||||
if( _strnicmp( lpszText, lpszKeyName, strlen( lpszKeyName ) ) != 0 )
|
||||
continue;
|
||||
if( *(lpszText + strlen( lpszKeyName )) != '=' )
|
||||
continue;
|
||||
return lpszText;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BOOL _CPostItMemoryBlock::Put( LPCSTR lpszKeyName, LPCSTR lpBuffer )
|
||||
{
|
||||
LPSTR lpszText;
|
||||
|
||||
if( (lpszText = Find( lpszKeyName )) != NULL ) {
|
||||
for( StrListItr itr = m_StrList.begin(); itr != m_StrList.end(); ++itr ) {
|
||||
if( lpszText == *itr ) {
|
||||
SAFE_DELETE_ARRAY( lpszText );
|
||||
m_StrList.erase( itr );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( lpBuffer == NULL || !*lpBuffer )
|
||||
return TRUE;
|
||||
size_t nStrLen = strlen( lpszKeyName ) + 1 /* '=' */ + strlen( lpBuffer );
|
||||
lpszText = new CHAR[ nStrLen + 1 ];
|
||||
::CopyMemory( lpszText, lpszKeyName, strlen( lpszKeyName ) );
|
||||
*(lpszText + strlen( lpszKeyName )) = '=';
|
||||
::CopyMemory( lpszText + strlen( lpszKeyName ) + 1, lpBuffer, strlen( lpBuffer ) );
|
||||
*(lpszText + nStrLen) = '\0';
|
||||
|
||||
m_StrList.push_back( lpszText );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL _CPostItMemoryBlock::Put( LPCSTR lpBuffer )
|
||||
{
|
||||
LPSTR lpszText;
|
||||
|
||||
if( lpBuffer == NULL || !*lpBuffer )
|
||||
return TRUE;
|
||||
size_t nStrLen = strlen( lpBuffer );
|
||||
lpszText = new CHAR[ nStrLen + 1 ];
|
||||
::CopyMemory( lpszText, lpBuffer, nStrLen );
|
||||
*(lpszText + nStrLen) = '\0';
|
||||
|
||||
m_StrList.push_back( lpszText );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL _CPostItMemoryBlock::Get( LPCSTR lpszKeyName, LPSTR lpBuffer, DWORD nSize )
|
||||
{
|
||||
LPSTR lpszText = Find( lpszKeyName );
|
||||
if( lpszText == NULL )
|
||||
return FALSE;
|
||||
lpszText += (strlen( lpszKeyName ) + 1);
|
||||
::ZeroMemory( lpBuffer, nSize );
|
||||
strncpy( lpBuffer, lpszText, (nSize < strlen( lpszText )) ? nSize : strlen( lpszText ) );
|
||||
return TRUE;
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
43
source-client/Srcs/Client/EterBase/CPostIt.h
Normal file
43
source-client/Srcs/Client/EterBase/CPostIt.h
Normal file
@ -0,0 +1,43 @@
|
||||
#ifndef _EL_CPOSTIT_H_
|
||||
#define _EL_CPOSTIT_H_
|
||||
|
||||
// _CPostItMemoryBlock is defined in CPostIt.cpp
|
||||
class _CPostItMemoryBlock;
|
||||
|
||||
class CPostIt
|
||||
{
|
||||
public:
|
||||
|
||||
explicit CPostIt( LPCSTR szAppName );
|
||||
|
||||
/**
|
||||
* @brief CPostIt destructor
|
||||
*/
|
||||
~CPostIt( void );
|
||||
|
||||
BOOL Flush( void );
|
||||
|
||||
void Empty( void );
|
||||
|
||||
BOOL Get( LPCSTR lpszKeyName, LPSTR lpszData, DWORD nSize );
|
||||
|
||||
BOOL Set( LPCSTR lpszData );
|
||||
|
||||
BOOL Set( LPCSTR lpszKeyName, LPCSTR lpszData );
|
||||
|
||||
BOOL Set( LPCSTR lpszKeyName, DWORD dwValue );
|
||||
|
||||
BOOL CopyTo( CPostIt *pPostIt, LPCSTR lpszKeyName );
|
||||
|
||||
protected:
|
||||
BOOL Init( LPCSTR szAppName );
|
||||
void Destroy( void );
|
||||
|
||||
protected:
|
||||
BOOL m_bModified;
|
||||
CHAR m_szClipFormatName[_MAX_PATH];
|
||||
_CPostItMemoryBlock* m_pMemoryBlock;
|
||||
};
|
||||
|
||||
#endif /* _EL_CPOSTIT_H_ */
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
209
source-client/Srcs/Client/EterBase/CRC32.cpp
Normal file
209
source-client/Srcs/Client/EterBase/CRC32.cpp
Normal file
@ -0,0 +1,209 @@
|
||||
#include "StdAfx.h"
|
||||
#include "CRC32.h"
|
||||
|
||||
static unsigned long CRCTable[256] =
|
||||
{
|
||||
0x00000000,0x77073096,0xEE0E612C,0x990951BA,0x076DC419,0x706AF48F,
|
||||
0xE963A535,0x9E6495A3,0x0EDB8832,0x79DCB8A4,0xE0D5E91E,0x97D2D988,
|
||||
0x09B64C2B,0x7EB17CBD,0xE7B82D07,0x90BF1D91,0x1DB71064,0x6AB020F2,
|
||||
0xF3B97148,0x84BE41DE,0x1ADAD47D,0x6DDDE4EB,0xF4D4B551,0x83D385C7,
|
||||
0x136C9856,0x646BA8C0,0xFD62F97A,0x8A65C9EC,0x14015C4F,0x63066CD9,
|
||||
0xFA0F3D63,0x8D080DF5,0x3B6E20C8,0x4C69105E,0xD56041E4,0xA2677172,
|
||||
0x3C03E4D1,0x4B04D447,0xD20D85FD,0xA50AB56B,0x35B5A8FA,0x42B2986C,
|
||||
0xDBBBC9D6,0xACBCF940,0x32D86CE3,0x45DF5C75,0xDCD60DCF,0xABD13D59,
|
||||
0x26D930AC,0x51DE003A,0xC8D75180,0xBFD06116,0x21B4F4B5,0x56B3C423,
|
||||
0xCFBA9599,0xB8BDA50F,0x2802B89E,0x5F058808,0xC60CD9B2,0xB10BE924,
|
||||
0x2F6F7C87,0x58684C11,0xC1611DAB,0xB6662D3D,0x76DC4190,0x01DB7106,
|
||||
0x98D220BC,0xEFD5102A,0x71B18589,0x06B6B51F,0x9FBFE4A5,0xE8B8D433,
|
||||
0x7807C9A2,0x0F00F934,0x9609A88E,0xE10E9818,0x7F6A0DBB,0x086D3D2D,
|
||||
0x91646C97,0xE6635C01,0x6B6B51F4,0x1C6C6162,0x856530D8,0xF262004E,
|
||||
0x6C0695ED,0x1B01A57B,0x8208F4C1,0xF50FC457,0x65B0D9C6,0x12B7E950,
|
||||
0x8BBEB8EA,0xFCB9887C,0x62DD1DDF,0x15DA2D49,0x8CD37CF3,0xFBD44C65,
|
||||
0x4DB26158,0x3AB551CE,0xA3BC0074,0xD4BB30E2,0x4ADFA541,0x3DD895D7,
|
||||
0xA4D1C46D,0xD3D6F4FB,0x4369E96A,0x346ED9FC,0xAD678846,0xDA60B8D0,
|
||||
0x44042D73,0x33031DE5,0xAA0A4C5F,0xDD0D7CC9,0x5005713C,0x270241AA,
|
||||
0xBE0B1010,0xC90C2086,0x5768B525,0x206F85B3,0xB966D409,0xCE61E49F,
|
||||
0x5EDEF90E,0x29D9C998,0xB0D09822,0xC7D7A8B4,0x59B33D17,0x2EB40D81,
|
||||
0xB7BD5C3B,0xC0BA6CAD,0xEDB88320,0x9ABFB3B6,0x03B6E20C,0x74B1D29A,
|
||||
0xEAD54739,0x9DD277AF,0x04DB2615,0x73DC1683,0xE3630B12,0x94643B84,
|
||||
0x0D6D6A3E,0x7A6A5AA8,0xE40ECF0B,0x9309FF9D,0x0A00AE27,0x7D079EB1,
|
||||
0xF00F9344,0x8708A3D2,0x1E01F268,0x6906C2FE,0xF762575D,0x806567CB,
|
||||
0x196C3671,0x6E6B06E7,0xFED41B76,0x89D32BE0,0x10DA7A5A,0x67DD4ACC,
|
||||
0xF9B9DF6F,0x8EBEEFF9,0x17B7BE43,0x60B08ED5,0xD6D6A3E8,0xA1D1937E,
|
||||
0x38D8C2C4,0x4FDFF252,0xD1BB67F1,0xA6BC5767,0x3FB506DD,0x48B2364B,
|
||||
0xD80D2BDA,0xAF0A1B4C,0x36034AF6,0x41047A60,0xDF60EFC3,0xA867DF55,
|
||||
0x316E8EEF,0x4669BE79,0xCB61B38C,0xBC66831A,0x256FD2A0,0x5268E236,
|
||||
0xCC0C7795,0xBB0B4703,0x220216B9,0x5505262F,0xC5BA3BBE,0xB2BD0B28,
|
||||
0x2BB45A92,0x5CB36A04,0xC2D7FFA7,0xB5D0CF31,0x2CD99E8B,0x5BDEAE1D,
|
||||
0x9B64C2B0,0xEC63F226,0x756AA39C,0x026D930A,0x9C0906A9,0xEB0E363F,
|
||||
0x72076785,0x05005713,0x95BF4A82,0xE2B87A14,0x7BB12BAE,0x0CB61B38,
|
||||
0x92D28E9B,0xE5D5BE0D,0x7CDCEFB7,0x0BDBDF21,0x86D3D2D4,0xF1D4E242,
|
||||
0x68DDB3F8,0x1FDA836E,0x81BE16CD,0xF6B9265B,0x6FB077E1,0x18B74777,
|
||||
0x88085AE6,0xFF0F6A70,0x66063BCA,0x11010B5C,0x8F659EFF,0xF862AE69,
|
||||
0x616BFFD3,0x166CCF45,0xA00AE278,0xD70DD2EE,0x4E048354,0x3903B3C2,
|
||||
0xA7672661,0xD06016F7,0x4969474D,0x3E6E77DB,0xAED16A4A,0xD9D65ADC,
|
||||
0x40DF0B66,0x37D83BF0,0xA9BCAE53,0xDEBB9EC5,0x47B2CF7F,0x30B5FFE9,
|
||||
0xBDBDF21C,0xCABAC28A,0x53B39330,0x24B4A3A6,0xBAD03605,0xCDD70693,
|
||||
0x54DE5729,0x23D967BF,0xB3667A2E,0xC4614AB8,0x5D681B02,0x2A6F2B94,
|
||||
0xB40BBE37,0xC30C8EA1,0x5A05DF1B,0x2D02EF8D
|
||||
};
|
||||
|
||||
#define DO1(buf, i) crc = CRCTable[(crc ^ buf[i]) & 0xff] ^ (crc >> 8)
|
||||
#define DO2(buf, i) DO1(buf, i); DO1(buf, i + 1);
|
||||
#define DO4(buf, i) DO2(buf, i); DO2(buf, i + 2);
|
||||
#define DO8(buf, i) DO4(buf, i); DO4(buf, i + 4);
|
||||
#define DO16(buf, i) DO8(buf, i); DO8(buf, i + 8);
|
||||
|
||||
DWORD GetCRC32(const char * buf, size_t len)
|
||||
{
|
||||
DWORD crc = 0xffffffff;
|
||||
|
||||
if (len >= 16)
|
||||
{
|
||||
do
|
||||
{
|
||||
DO16(buf, 0);
|
||||
|
||||
buf += 16;
|
||||
len -= 16;
|
||||
} while (len >= 16);
|
||||
}
|
||||
|
||||
if (len != 0)
|
||||
{
|
||||
do
|
||||
{
|
||||
DO1(buf, 0);
|
||||
++buf;
|
||||
--len;
|
||||
} while (len > 0);
|
||||
}
|
||||
|
||||
crc ^= 0xffffffff;
|
||||
return crc;
|
||||
}
|
||||
|
||||
#ifndef UPPER
|
||||
#define UPPER(c) (((c)>='a' && (c) <= 'z') ? ((c)+('A'-'a')) : (c))
|
||||
#endif
|
||||
|
||||
#define DO1CI(buf, i) crc = CRCTable[(crc ^ UPPER(buf[i])) & 0xff] ^ (crc >> 8)
|
||||
#define DO2CI(buf, i) DO1CI(buf, i); DO1CI(buf, i + 1);
|
||||
#define DO4CI(buf, i) DO2CI(buf, i); DO2CI(buf, i + 2);
|
||||
#define DO8CI(buf, i) DO4CI(buf, i); DO4CI(buf, i + 4);
|
||||
#define DO16CI(buf, i) DO8CI(buf, i); DO8CI(buf, i + 8);
|
||||
|
||||
DWORD GetCaseCRC32(const char * buf, size_t len)
|
||||
{
|
||||
DWORD crc = 0xffffffff;
|
||||
|
||||
if (16 <= len)
|
||||
{
|
||||
do
|
||||
{
|
||||
DO16CI(buf, 0);
|
||||
|
||||
buf += 16;
|
||||
len -= 16;
|
||||
} while (len >= 16);
|
||||
}
|
||||
|
||||
if (0 != len)
|
||||
{
|
||||
do
|
||||
{
|
||||
DO1CI(buf, 0);
|
||||
|
||||
++buf;
|
||||
--len;
|
||||
} while (len > 0);
|
||||
}
|
||||
|
||||
crc ^= 0xffffffff;
|
||||
return crc;
|
||||
}
|
||||
|
||||
DWORD GetHFILECRC32(HANDLE hFile)
|
||||
{
|
||||
DWORD dwRetCRC32=0;
|
||||
|
||||
DWORD dwFileSize = GetFileSize(hFile, NULL);
|
||||
|
||||
DWORD dataOffset=0;
|
||||
DWORD mapSize=dwFileSize;
|
||||
|
||||
SYSTEM_INFO SysInfo;
|
||||
GetSystemInfo(&SysInfo);
|
||||
|
||||
DWORD dwSysGran = SysInfo.dwAllocationGranularity;
|
||||
DWORD dwFileMapStart = (dataOffset / dwSysGran) * dwSysGran;
|
||||
DWORD dwMapViewSize = (dataOffset % dwSysGran) + mapSize;
|
||||
//INT iViewDelta = dataOffset - dwFileMapStart;
|
||||
|
||||
HANDLE hFM = CreateFileMapping(hFile, // handle
|
||||
NULL, // security
|
||||
PAGE_READONLY, // flProtect
|
||||
0, // high
|
||||
dataOffset + mapSize, // low
|
||||
NULL); // name
|
||||
if (hFM)
|
||||
{
|
||||
LPVOID lpMapData = MapViewOfFile(hFM,
|
||||
FILE_MAP_READ,
|
||||
0,
|
||||
dwFileMapStart,
|
||||
dwMapViewSize);
|
||||
|
||||
dwRetCRC32=GetCRC32((const char*)lpMapData, dwFileSize);
|
||||
|
||||
if (lpMapData)
|
||||
{
|
||||
UnmapViewOfFile(lpMapData);
|
||||
}
|
||||
|
||||
CloseHandle(hFM);
|
||||
}
|
||||
|
||||
return dwRetCRC32;
|
||||
}
|
||||
|
||||
DWORD GetFileCRC32(const char* c_szFileName)
|
||||
{
|
||||
HANDLE hFile = CreateFile(c_szFileName, // name of the file
|
||||
GENERIC_READ, // desired access
|
||||
FILE_SHARE_READ, // share mode
|
||||
NULL, // security attributes
|
||||
OPEN_EXISTING, // creation disposition
|
||||
FILE_ATTRIBUTE_NORMAL, // flags and attr
|
||||
NULL); // template file
|
||||
|
||||
if (INVALID_HANDLE_VALUE == hFile)
|
||||
return 0;
|
||||
|
||||
DWORD dwRetCRC32=GetHFILECRC32(hFile);
|
||||
|
||||
CloseHandle(hFile);
|
||||
|
||||
return dwRetCRC32;
|
||||
}
|
||||
|
||||
DWORD GetFileSize(const char* c_szFileName)
|
||||
{
|
||||
HANDLE hFile = CreateFile(c_szFileName, // name of the file
|
||||
GENERIC_READ, // desired access
|
||||
FILE_SHARE_READ, // share mode
|
||||
NULL, // security attributes
|
||||
OPEN_EXISTING, // creation disposition
|
||||
FILE_ATTRIBUTE_NORMAL, // flags and attr
|
||||
NULL); // template file
|
||||
|
||||
if (INVALID_HANDLE_VALUE == hFile)
|
||||
return 0;
|
||||
|
||||
DWORD dwSize = GetFileSize(hFile, NULL);
|
||||
|
||||
CloseHandle(hFile);
|
||||
|
||||
return dwSize;
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
13
source-client/Srcs/Client/EterBase/CRC32.h
Normal file
13
source-client/Srcs/Client/EterBase/CRC32.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef __INC_CRC32_H__
|
||||
#define __INC_CRC32_H__
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
DWORD GetCRC32(const char* buffer, size_t count);
|
||||
DWORD GetCaseCRC32(const char * buf, size_t len);
|
||||
DWORD GetHFILECRC32(HANDLE hFile);
|
||||
DWORD GetFileCRC32(const char* c_szFileName);
|
||||
DWORD GetFileSize(const char* c_szFileName);
|
||||
|
||||
#endif
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
326
source-client/Srcs/Client/EterBase/Debug.cpp
Normal file
326
source-client/Srcs/Client/EterBase/Debug.cpp
Normal file
@ -0,0 +1,326 @@
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include "Debug.h"
|
||||
#include "Singleton.h"
|
||||
#include "Timer.h"
|
||||
|
||||
const DWORD DEBUG_STRING_MAX_LEN = 1024;
|
||||
|
||||
static int isLogFile = false;
|
||||
HWND g_PopupHwnd = NULL;
|
||||
|
||||
class CLogFile : public CSingleton<CLogFile>
|
||||
{
|
||||
public:
|
||||
CLogFile() : m_fp(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~CLogFile()
|
||||
{
|
||||
if (m_fp)
|
||||
fclose(m_fp);
|
||||
|
||||
m_fp = NULL;
|
||||
}
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
m_fp = fopen("log.txt", "w");
|
||||
}
|
||||
|
||||
void Write(const char * c_pszMsg)
|
||||
{
|
||||
if (!m_fp)
|
||||
return;
|
||||
|
||||
time_t ct = time(0);
|
||||
struct tm ctm = *localtime(&ct);
|
||||
|
||||
fprintf(m_fp, "%02d%02d %02d:%02d:%05d :: %s",
|
||||
ctm.tm_mon + 1,
|
||||
ctm.tm_mday,
|
||||
ctm.tm_hour,
|
||||
ctm.tm_min,
|
||||
ELTimer_GetMSec() % 60000,
|
||||
c_pszMsg);
|
||||
|
||||
fflush(m_fp);
|
||||
}
|
||||
|
||||
protected:
|
||||
FILE * m_fp;
|
||||
};
|
||||
|
||||
static CLogFile gs_logfile;
|
||||
|
||||
static UINT gs_uLevel=0;
|
||||
|
||||
void SetLogLevel(UINT uLevel)
|
||||
{
|
||||
gs_uLevel=uLevel;
|
||||
}
|
||||
|
||||
void Log(UINT uLevel, const char* c_szMsg)
|
||||
{
|
||||
if (uLevel>=gs_uLevel)
|
||||
Trace(c_szMsg);
|
||||
}
|
||||
|
||||
void Logn(UINT uLevel, const char* c_szMsg)
|
||||
{
|
||||
if (uLevel>=gs_uLevel)
|
||||
Tracen(c_szMsg);
|
||||
}
|
||||
|
||||
void Logf(UINT uLevel, const char* c_szFormat, ...)
|
||||
{
|
||||
if (uLevel<gs_uLevel)
|
||||
return;
|
||||
|
||||
char szBuf[DEBUG_STRING_MAX_LEN+1];
|
||||
|
||||
va_list args;
|
||||
va_start(args, c_szFormat);
|
||||
_vsnprintf(szBuf, sizeof(szBuf), c_szFormat, args);
|
||||
va_end(args);
|
||||
#ifdef _DEBUG
|
||||
OutputDebugString(szBuf);
|
||||
fputs(szBuf, stdout);
|
||||
#endif
|
||||
|
||||
if (isLogFile)
|
||||
LogFile(szBuf);
|
||||
}
|
||||
|
||||
void Lognf(UINT uLevel, const char* c_szFormat, ...)
|
||||
{
|
||||
if (uLevel<gs_uLevel)
|
||||
return;
|
||||
|
||||
va_list args;
|
||||
va_start(args, c_szFormat);
|
||||
|
||||
char szBuf[DEBUG_STRING_MAX_LEN+2];
|
||||
int len = _vsnprintf(szBuf, sizeof(szBuf)-1, c_szFormat, args);
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
szBuf[len] = '\n';
|
||||
szBuf[len + 1] = '\0';
|
||||
}
|
||||
va_end(args);
|
||||
#ifdef _DEBUG
|
||||
OutputDebugString(szBuf);
|
||||
puts(szBuf);
|
||||
#endif
|
||||
|
||||
if (isLogFile)
|
||||
LogFile(szBuf);
|
||||
}
|
||||
|
||||
void Trace(const char * c_szMsg)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
OutputDebugString(c_szMsg);
|
||||
printf("%s", c_szMsg);
|
||||
#endif
|
||||
|
||||
if (isLogFile)
|
||||
LogFile(c_szMsg);
|
||||
}
|
||||
|
||||
void Tracen(const char* c_szMsg)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
char szBuf[DEBUG_STRING_MAX_LEN+1];
|
||||
_snprintf(szBuf, sizeof(szBuf), "%s\n", c_szMsg);
|
||||
OutputDebugString(szBuf);
|
||||
puts(c_szMsg);
|
||||
|
||||
if (isLogFile)
|
||||
LogFile(szBuf);
|
||||
|
||||
puts(c_szMsg);
|
||||
putc('\n', stdout);
|
||||
#else
|
||||
if (isLogFile)
|
||||
{
|
||||
LogFile(c_szMsg);
|
||||
LogFile("\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Tracenf(const char* c_szFormat, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, c_szFormat);
|
||||
|
||||
char szBuf[DEBUG_STRING_MAX_LEN+2];
|
||||
int len = _vsnprintf(szBuf, sizeof(szBuf)-1, c_szFormat, args);
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
szBuf[len] = '\n';
|
||||
szBuf[len + 1] = '\0';
|
||||
}
|
||||
va_end(args);
|
||||
#ifdef _DEBUG
|
||||
OutputDebugString(szBuf);
|
||||
printf("%s", szBuf);
|
||||
#endif
|
||||
|
||||
if (isLogFile)
|
||||
LogFile(szBuf);
|
||||
}
|
||||
|
||||
void Tracef(const char* c_szFormat, ...)
|
||||
{
|
||||
char szBuf[DEBUG_STRING_MAX_LEN+1];
|
||||
|
||||
va_list args;
|
||||
va_start(args, c_szFormat);
|
||||
_vsnprintf(szBuf, sizeof(szBuf), c_szFormat, args);
|
||||
va_end(args);
|
||||
|
||||
#ifdef _DEBUG
|
||||
OutputDebugString(szBuf);
|
||||
fputs(szBuf, stdout);
|
||||
#endif
|
||||
|
||||
if (isLogFile)
|
||||
LogFile(szBuf);
|
||||
}
|
||||
|
||||
void TraceError(const char* c_szFormat, ...)
|
||||
{
|
||||
#ifndef _DISTRIBUTE
|
||||
|
||||
char szBuf[DEBUG_STRING_MAX_LEN+2];
|
||||
|
||||
strncpy(szBuf, "SYSERR: ", DEBUG_STRING_MAX_LEN);
|
||||
int len = strlen(szBuf);
|
||||
|
||||
va_list args;
|
||||
va_start(args, c_szFormat);
|
||||
len = _vsnprintf(szBuf + len, sizeof(szBuf) - (len + 1), c_szFormat, args) + len;
|
||||
va_end(args);
|
||||
|
||||
szBuf[len] = '\n';
|
||||
szBuf[len + 1] = '\0';
|
||||
|
||||
time_t ct = time(0);
|
||||
struct tm ctm = *localtime(&ct);
|
||||
|
||||
fprintf(stderr, "%02d%02d %02d:%02d:%05d :: %s",
|
||||
ctm.tm_mon + 1,
|
||||
ctm.tm_mday,
|
||||
ctm.tm_hour,
|
||||
ctm.tm_min,
|
||||
ELTimer_GetMSec() % 60000,
|
||||
szBuf + 8);
|
||||
fflush(stderr);
|
||||
|
||||
#ifdef _DEBUG
|
||||
OutputDebugString(szBuf);
|
||||
fputs(szBuf, stdout);
|
||||
#endif
|
||||
|
||||
if (isLogFile)
|
||||
LogFile(szBuf);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void TraceErrorWithoutEnter(const char* c_szFormat, ...)
|
||||
{
|
||||
#ifndef _DISTRIBUTE
|
||||
|
||||
char szBuf[DEBUG_STRING_MAX_LEN];
|
||||
|
||||
va_list args;
|
||||
va_start(args, c_szFormat);
|
||||
_vsnprintf(szBuf, sizeof(szBuf), c_szFormat, args);
|
||||
va_end(args);
|
||||
|
||||
time_t ct = time(0);
|
||||
struct tm ctm = *localtime(&ct);
|
||||
|
||||
fprintf(stderr, "%02d%02d %02d:%02d:%05d :: %s",
|
||||
ctm.tm_mon + 1,
|
||||
ctm.tm_mday,
|
||||
ctm.tm_hour,
|
||||
ctm.tm_min,
|
||||
ELTimer_GetMSec() % 60000,
|
||||
szBuf + 8);
|
||||
fflush(stderr);
|
||||
|
||||
#ifdef _DEBUG
|
||||
OutputDebugString(szBuf);
|
||||
fputs(szBuf, stdout);
|
||||
#endif
|
||||
|
||||
if (isLogFile)
|
||||
LogFile(szBuf);
|
||||
#endif
|
||||
}
|
||||
|
||||
void LogBoxf(const char* c_szFormat, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, c_szFormat);
|
||||
|
||||
char szBuf[2048];
|
||||
_vsnprintf(szBuf, sizeof(szBuf), c_szFormat, args);
|
||||
|
||||
LogBox(szBuf);
|
||||
}
|
||||
|
||||
void LogBox(const char* c_szMsg, const char * c_szCaption, HWND hWnd)
|
||||
{
|
||||
if (!hWnd)
|
||||
hWnd = g_PopupHwnd;
|
||||
|
||||
MessageBox(hWnd, c_szMsg, c_szCaption ? c_szCaption : "LOG", MB_OK);
|
||||
Tracen(c_szMsg);
|
||||
}
|
||||
|
||||
void LogFile(const char * c_szMsg)
|
||||
{
|
||||
CLogFile::Instance().Write(c_szMsg);
|
||||
}
|
||||
|
||||
void LogFilef(const char * c_szMessage, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, c_szMessage);
|
||||
char szBuf[DEBUG_STRING_MAX_LEN+1];
|
||||
_vsnprintf(szBuf, sizeof(szBuf), c_szMessage, args);
|
||||
|
||||
CLogFile::Instance().Write(szBuf);
|
||||
}
|
||||
|
||||
void OpenLogFile(bool bUseLogFIle)
|
||||
{
|
||||
#ifndef _DISTRIBUTE
|
||||
freopen("syserr.txt", "w", stderr);
|
||||
|
||||
if (bUseLogFIle)
|
||||
{
|
||||
isLogFile = true;
|
||||
CLogFile::Instance().Initialize();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void OpenConsoleWindow()
|
||||
{
|
||||
AllocConsole();
|
||||
|
||||
freopen("CONOUT$", "a", stdout);
|
||||
freopen("CONIN$", "r", stdin);
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
41
source-client/Srcs/Client/EterBase/Debug.h
Normal file
41
source-client/Srcs/Client/EterBase/Debug.h
Normal file
@ -0,0 +1,41 @@
|
||||
#ifndef __INC_ETERLIB_DEBUG_H__
|
||||
#define __INC_ETERLIB_DEBUG_H__
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
extern void SetLogLevel(UINT uLevel);
|
||||
extern void Log(UINT uLevel, const char* c_szMsg);
|
||||
extern void Logn(UINT uLevel, const char* c_szMsg);
|
||||
extern void Logf(UINT uLevel, const char* c_szFormat, ...);
|
||||
extern void Lognf(UINT uLevel, const char* c_szFormat, ...);
|
||||
|
||||
extern void Trace(const char* c_szMsg);
|
||||
extern void Tracen(const char* c_szMsg);
|
||||
extern void Tracenf(const char* c_szFormat, ...);
|
||||
extern void Tracef(const char* c_szFormat, ...);
|
||||
extern void TraceError(const char* c_szFormat, ...);
|
||||
extern void TraceErrorWithoutEnter(const char* c_szFormat, ...);
|
||||
|
||||
extern void LogBox(const char* c_szMsg, const char * c_szCaption = NULL, HWND hWnd = NULL);
|
||||
extern void LogBoxf(const char* c_szMsg, ...);
|
||||
|
||||
extern void LogFile(const char* c_szMsg);
|
||||
extern void LogFilef(const char * c_szMessage, ...);
|
||||
extern void OpenConsoleWindow(void);
|
||||
extern void CloseConsoleWindow();
|
||||
extern void SetupLog(void);
|
||||
|
||||
extern void OpenLogFile(bool bUseLogFile = true);
|
||||
extern void CloseLogFile();
|
||||
|
||||
extern HWND g_PopupHwnd;
|
||||
|
||||
#define CHECK_RETURN(flag, string) \
|
||||
if (flag) \
|
||||
{ \
|
||||
LogBox(string); \
|
||||
return; \
|
||||
} \
|
||||
|
||||
#endif
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
116
source-client/Srcs/Client/EterBase/FileBase.cpp
Normal file
116
source-client/Srcs/Client/EterBase/FileBase.cpp
Normal file
@ -0,0 +1,116 @@
|
||||
#include "StdAfx.h"
|
||||
#include "FileBase.h"
|
||||
|
||||
CFileBase::CFileBase() : m_hFile(NULL), m_dwSize(0)
|
||||
{
|
||||
}
|
||||
|
||||
CFileBase::~CFileBase()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
char * CFileBase::GetFileName()
|
||||
{
|
||||
return m_filename;
|
||||
}
|
||||
|
||||
void CFileBase::Destroy()
|
||||
{
|
||||
Close();
|
||||
m_dwSize = 0;
|
||||
}
|
||||
|
||||
void CFileBase::Close()
|
||||
{
|
||||
if (m_hFile)
|
||||
{
|
||||
CloseHandle(m_hFile);
|
||||
m_hFile = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CFileBase::Create(const char* filename, EFileMode mode)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
strncpy(m_filename, filename, MAX_PATH);
|
||||
|
||||
DWORD dwMode, dwShareMode = FILE_SHARE_READ;
|
||||
|
||||
if (mode == FILEMODE_WRITE)
|
||||
{
|
||||
dwMode = GENERIC_READ | GENERIC_WRITE;
|
||||
dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
|
||||
}
|
||||
else
|
||||
dwMode = GENERIC_READ;
|
||||
|
||||
m_hFile = CreateFile(filename, // name of the file
|
||||
dwMode, // desired access
|
||||
dwShareMode, // share mode
|
||||
NULL, // security attributes
|
||||
mode == FILEMODE_READ ? OPEN_EXISTING : OPEN_ALWAYS, // creation disposition
|
||||
FILE_ATTRIBUTE_NORMAL, // flags and attr
|
||||
NULL); // template file
|
||||
|
||||
if (m_hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
m_dwSize = GetFileSize(m_hFile, NULL);
|
||||
m_mode = mode;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* char buf[256];
|
||||
GetCurrentDirectory(256, buf);
|
||||
DWORD dwErr = GetLastError();*/
|
||||
m_hFile = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
DWORD CFileBase::Size()
|
||||
{
|
||||
return (m_dwSize);
|
||||
}
|
||||
|
||||
void CFileBase::SeekCur(DWORD size)
|
||||
{
|
||||
SetFilePointer(m_hFile, size, NULL, FILE_CURRENT);
|
||||
}
|
||||
|
||||
void CFileBase::Seek(DWORD offset)
|
||||
{
|
||||
if (offset > m_dwSize)
|
||||
offset = m_dwSize;
|
||||
|
||||
SetFilePointer(m_hFile, offset, NULL, FILE_BEGIN);
|
||||
}
|
||||
|
||||
DWORD CFileBase::GetPosition()
|
||||
{
|
||||
return SetFilePointer(m_hFile, 0, NULL, FILE_CURRENT);
|
||||
}
|
||||
|
||||
BOOL CFileBase::Write(const void* src, int bytes)
|
||||
{
|
||||
DWORD dwUseless;
|
||||
BOOL ret = WriteFile(m_hFile, src, bytes, &dwUseless, NULL);
|
||||
|
||||
if (!ret)
|
||||
return false;
|
||||
|
||||
m_dwSize = GetFileSize(m_hFile, NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL CFileBase::Read(void* dest, int bytes)
|
||||
{
|
||||
DWORD dwUseless;
|
||||
return ReadFile(m_hFile, dest, bytes, &dwUseless, NULL);
|
||||
}
|
||||
|
||||
BOOL CFileBase::IsNull()
|
||||
{
|
||||
return !m_hFile ? true : false;
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
41
source-client/Srcs/Client/EterBase/FileBase.h
Normal file
41
source-client/Srcs/Client/EterBase/FileBase.h
Normal file
@ -0,0 +1,41 @@
|
||||
#ifndef __INC_ETERBASE_FILEBASE_H__
|
||||
#define __INC_ETERBASE_FILEBASE_H__
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
class CFileBase
|
||||
{
|
||||
public:
|
||||
enum EFileMode
|
||||
{
|
||||
FILEMODE_READ = (1 << 0),
|
||||
FILEMODE_WRITE = (1 << 1)
|
||||
};
|
||||
|
||||
CFileBase();
|
||||
virtual ~CFileBase();
|
||||
|
||||
void Destroy();
|
||||
void Close();
|
||||
|
||||
BOOL Create(const char* filename, EFileMode mode);
|
||||
DWORD Size();
|
||||
void SeekCur(DWORD size);
|
||||
void Seek(DWORD offset);
|
||||
DWORD GetPosition();
|
||||
|
||||
virtual BOOL Write(const void* src, int bytes);
|
||||
BOOL Read(void* dest, int bytes);
|
||||
|
||||
char* GetFileName();
|
||||
BOOL IsNull();
|
||||
|
||||
protected:
|
||||
int m_mode;
|
||||
char m_filename[MAX_PATH+1];
|
||||
HANDLE m_hFile;
|
||||
DWORD m_dwSize;
|
||||
};
|
||||
|
||||
#endif
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
103
source-client/Srcs/Client/EterBase/FileDir.cpp
Normal file
103
source-client/Srcs/Client/EterBase/FileDir.cpp
Normal file
@ -0,0 +1,103 @@
|
||||
#include "StdAfx.h"
|
||||
#include "FileDir.h"
|
||||
#include <string>
|
||||
|
||||
CDir::CDir()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
CDir::~CDir()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void CDir::Destroy()
|
||||
{
|
||||
if (m_hFind)
|
||||
FindClose(m_hFind);
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
bool CDir::Create(const char * c_szFilter, const char* c_szPath, BOOL bCheckedExtension)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
std::string stPath = c_szPath;
|
||||
|
||||
if (stPath.length())
|
||||
{
|
||||
char end = stPath[stPath.length() - 1];
|
||||
|
||||
if (end != '\\')
|
||||
stPath+='\\';
|
||||
}
|
||||
|
||||
std::string stQuery;
|
||||
stQuery += stPath;
|
||||
stQuery += "*.*";
|
||||
|
||||
m_wfd.dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
|
||||
m_hFind = FindFirstFile(stQuery.c_str(), &m_wfd);
|
||||
|
||||
if (m_hFind == INVALID_HANDLE_VALUE)
|
||||
return true;
|
||||
|
||||
do
|
||||
{
|
||||
if (*m_wfd.cFileName == '.')
|
||||
continue;
|
||||
|
||||
if (IsFolder())
|
||||
{
|
||||
if (!OnFolder(c_szFilter, stPath.c_str(), m_wfd.cFileName))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
const char * c_szExtension = strchr(m_wfd.cFileName, '.');
|
||||
if (!c_szExtension)
|
||||
continue;
|
||||
|
||||
if (bCheckedExtension)
|
||||
{
|
||||
std::string strFilter = c_szFilter;
|
||||
int iPos = strFilter.find_first_of(';', 0);
|
||||
if (iPos > 0)
|
||||
{
|
||||
std::string strFirstFilter = std::string(c_szFilter).substr(0, iPos);
|
||||
std::string strSecondFilter = std::string(c_szFilter).substr(iPos+1, strlen(c_szFilter));
|
||||
if (0 != strFirstFilter.compare(c_szExtension+1) && 0 != strSecondFilter.compare(c_szExtension+1))
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0 != stricmp(c_szExtension+1, c_szFilter))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!OnFile(stPath.c_str(), m_wfd.cFileName))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
while (FindNextFile(m_hFind, &m_wfd));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDir::IsFolder()
|
||||
{
|
||||
if (m_wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CDir::Initialize()
|
||||
{
|
||||
memset(&m_wfd, 0, sizeof(m_wfd));
|
||||
m_hFind = NULL;
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
30
source-client/Srcs/Client/EterBase/FileDir.h
Normal file
30
source-client/Srcs/Client/EterBase/FileDir.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef __ETER_FILE_DIR__
|
||||
#define __ETER_FILE_DIR__
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
class CDir
|
||||
{
|
||||
public:
|
||||
CDir();
|
||||
virtual ~CDir();
|
||||
|
||||
void Destroy();
|
||||
bool Create(const char* c_szFilter, const char* c_szPath="", BOOL bCheckedExtension = FALSE);
|
||||
|
||||
protected:
|
||||
virtual bool OnFolder(const char* c_szFilter, const char* c_szPath, const char* c_szName) = 0;
|
||||
virtual bool OnFile(const char* c_szPath, const char* c_szName) = 0;
|
||||
|
||||
protected:
|
||||
bool IsFolder();
|
||||
|
||||
void Initialize();
|
||||
|
||||
protected:
|
||||
WIN32_FIND_DATA m_wfd;
|
||||
HANDLE m_hFind;
|
||||
};
|
||||
|
||||
#endif
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
287
source-client/Srcs/Client/EterBase/FileLoader.cpp
Normal file
287
source-client/Srcs/Client/EterBase/FileLoader.cpp
Normal file
@ -0,0 +1,287 @@
|
||||
#include "StdAfx.h"
|
||||
#include "FileLoader.h"
|
||||
#include <assert.h>
|
||||
|
||||
CMemoryTextFileLoader::CMemoryTextFileLoader()
|
||||
{
|
||||
}
|
||||
|
||||
CMemoryTextFileLoader::~CMemoryTextFileLoader()
|
||||
{
|
||||
}
|
||||
|
||||
bool CMemoryTextFileLoader::SplitLineByTab(DWORD dwLine, CTokenVector* pstTokenVector)
|
||||
{
|
||||
pstTokenVector->reserve(10);
|
||||
pstTokenVector->clear();
|
||||
|
||||
const std::string & c_rstLine = GetLineString(dwLine);
|
||||
const int c_iLineLength = c_rstLine.length();
|
||||
|
||||
if (0 == c_iLineLength)
|
||||
return false;
|
||||
|
||||
int basePos = 0;
|
||||
|
||||
do
|
||||
{
|
||||
int beginPos = c_rstLine.find_first_of("\t", basePos);
|
||||
|
||||
pstTokenVector->push_back(c_rstLine.substr(basePos, beginPos-basePos));
|
||||
|
||||
basePos = beginPos+1;
|
||||
} while (basePos < c_iLineLength && basePos > 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int CMemoryTextFileLoader::SplitLine2(DWORD dwLine, CTokenVector* pstTokenVector, const char * c_szDelimeter)
|
||||
{
|
||||
pstTokenVector->reserve(10);
|
||||
pstTokenVector->clear();
|
||||
|
||||
std::string stToken;
|
||||
const std::string & c_rstLine = GetLineString(dwLine);
|
||||
|
||||
DWORD basePos = 0;
|
||||
|
||||
do
|
||||
{
|
||||
int beginPos = c_rstLine.find_first_not_of(c_szDelimeter, basePos);
|
||||
|
||||
if (beginPos < 0)
|
||||
return -1;
|
||||
|
||||
int endPos;
|
||||
|
||||
if (c_rstLine[beginPos] == '"')
|
||||
{
|
||||
++beginPos;
|
||||
endPos = c_rstLine.find_first_of("\"", beginPos);
|
||||
|
||||
if (endPos < 0)
|
||||
return -2;
|
||||
|
||||
basePos = endPos + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
endPos = c_rstLine.find_first_of(c_szDelimeter, beginPos);
|
||||
basePos = endPos;
|
||||
}
|
||||
|
||||
pstTokenVector->push_back(c_rstLine.substr(beginPos, endPos - beginPos));
|
||||
|
||||
if (int(c_rstLine.find_first_not_of(c_szDelimeter, basePos)) < 0)
|
||||
break;
|
||||
} while (basePos < c_rstLine.length());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CMemoryTextFileLoader::SplitLine(DWORD dwLine, CTokenVector* pstTokenVector, const char * c_szDelimeter)
|
||||
{
|
||||
pstTokenVector->reserve(10);
|
||||
pstTokenVector->clear();
|
||||
|
||||
std::string stToken;
|
||||
const std::string & c_rstLine = GetLineString(dwLine);
|
||||
|
||||
DWORD basePos = 0;
|
||||
|
||||
do
|
||||
{
|
||||
int beginPos = c_rstLine.find_first_not_of(c_szDelimeter, basePos);
|
||||
if (beginPos < 0)
|
||||
return false;
|
||||
|
||||
int endPos;
|
||||
|
||||
if (c_rstLine[beginPos] == '"')
|
||||
{
|
||||
++beginPos;
|
||||
endPos = c_rstLine.find_first_of("\"", beginPos);
|
||||
|
||||
if (endPos < 0)
|
||||
return false;
|
||||
|
||||
basePos = endPos + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
endPos = c_rstLine.find_first_of(c_szDelimeter, beginPos);
|
||||
basePos = endPos;
|
||||
}
|
||||
|
||||
pstTokenVector->push_back(c_rstLine.substr(beginPos, endPos - beginPos));
|
||||
|
||||
if (int(c_rstLine.find_first_not_of(c_szDelimeter, basePos)) < 0)
|
||||
break;
|
||||
} while (basePos < c_rstLine.length());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DWORD CMemoryTextFileLoader::GetLineCount()
|
||||
{
|
||||
return m_stLineVector.size();
|
||||
}
|
||||
|
||||
bool CMemoryTextFileLoader::CheckLineIndex(DWORD dwLine)
|
||||
{
|
||||
if (dwLine >= m_stLineVector.size())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const std::string & CMemoryTextFileLoader::GetLineString(DWORD dwLine)
|
||||
{
|
||||
assert(CheckLineIndex(dwLine));
|
||||
return m_stLineVector[dwLine];
|
||||
}
|
||||
|
||||
void CMemoryTextFileLoader::Bind(int bufSize, const void* c_pvBuf)
|
||||
{
|
||||
m_stLineVector.reserve(128);
|
||||
m_stLineVector.clear();
|
||||
|
||||
const char * c_pcBuf = (const char *)c_pvBuf;
|
||||
std::string stLine;
|
||||
int pos = 0;
|
||||
|
||||
while (pos < bufSize)
|
||||
{
|
||||
const char c = c_pcBuf[pos++];
|
||||
|
||||
if ('\n' == c || '\r' == c)
|
||||
{
|
||||
if (pos < bufSize)
|
||||
if ('\n' == c_pcBuf[pos] || '\r' == c_pcBuf[pos])
|
||||
++pos;
|
||||
|
||||
m_stLineVector.push_back(stLine);
|
||||
stLine = "";
|
||||
}
|
||||
else if (c < 0)
|
||||
{
|
||||
stLine.append(c_pcBuf + (pos-1), 2);
|
||||
++pos;
|
||||
}
|
||||
else
|
||||
{
|
||||
stLine += c;
|
||||
}
|
||||
}
|
||||
|
||||
m_stLineVector.push_back(stLine);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
int CMemoryFileLoader::GetSize()
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
int CMemoryFileLoader::GetPosition()
|
||||
{
|
||||
return m_pos;
|
||||
}
|
||||
|
||||
bool CMemoryFileLoader::IsReadableSize(int size)
|
||||
{
|
||||
if (m_pos + size > m_size)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CMemoryFileLoader::Read(int size, void* pvDst)
|
||||
{
|
||||
if (!IsReadableSize(size))
|
||||
return false;
|
||||
|
||||
memcpy(pvDst, GetCurrentPositionPointer(), size);
|
||||
m_pos += size;
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* CMemoryFileLoader::GetCurrentPositionPointer()
|
||||
{
|
||||
assert(m_pcBase != NULL);
|
||||
return (m_pcBase + m_pos);
|
||||
}
|
||||
|
||||
CMemoryFileLoader::CMemoryFileLoader(int size, const void* c_pvMemoryFile)
|
||||
{
|
||||
assert(c_pvMemoryFile != NULL);
|
||||
|
||||
m_pos = 0;
|
||||
m_size = size;
|
||||
m_pcBase = (const char *) c_pvMemoryFile;
|
||||
}
|
||||
|
||||
CMemoryFileLoader::~CMemoryFileLoader()
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
int CDiskFileLoader::GetSize()
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
bool CDiskFileLoader::Read(int size, void* pvDst)
|
||||
{
|
||||
assert(m_fp != NULL);
|
||||
|
||||
int ret = fread(pvDst, size, 1, m_fp);
|
||||
|
||||
if (ret <= 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDiskFileLoader::Open(const char* c_szFileName)
|
||||
{
|
||||
Close();
|
||||
|
||||
if (!c_szFileName[0])
|
||||
return false;
|
||||
|
||||
m_fp = fopen(c_szFileName, "rb");
|
||||
|
||||
if (!m_fp)
|
||||
return false;
|
||||
|
||||
fseek(m_fp, 0, SEEK_END);
|
||||
m_size = ftell(m_fp);
|
||||
fseek(m_fp, 0, SEEK_SET);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDiskFileLoader::Close()
|
||||
{
|
||||
if (m_fp)
|
||||
fclose(m_fp);
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
void CDiskFileLoader::Initialize()
|
||||
{
|
||||
m_fp = NULL;
|
||||
m_size = 0;
|
||||
}
|
||||
|
||||
CDiskFileLoader::CDiskFileLoader()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
CDiskFileLoader::~CDiskFileLoader()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
72
source-client/Srcs/Client/EterBase/FileLoader.h
Normal file
72
source-client/Srcs/Client/EterBase/FileLoader.h
Normal file
@ -0,0 +1,72 @@
|
||||
#pragma once
|
||||
|
||||
#pragma warning(disable:4786)
|
||||
|
||||
#include <windows.h>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include "Stl.h"
|
||||
|
||||
class CMemoryTextFileLoader
|
||||
{
|
||||
public:
|
||||
CMemoryTextFileLoader();
|
||||
virtual ~CMemoryTextFileLoader();
|
||||
|
||||
void Bind(int bufSize, const void* c_pvBuf);
|
||||
DWORD GetLineCount();
|
||||
bool CheckLineIndex(DWORD dwLine);
|
||||
bool SplitLine(DWORD dwLine, CTokenVector * pstTokenVector, const char * c_szDelimeter = " \t");
|
||||
int SplitLine2(DWORD dwLine, CTokenVector * pstTokenVector, const char * c_szDelimeter = " \t");
|
||||
bool SplitLineByTab(DWORD dwLine, CTokenVector* pstTokenVector);
|
||||
const std::string & GetLineString(DWORD dwLine);
|
||||
|
||||
protected:
|
||||
std::vector<std::string> m_stLineVector;
|
||||
};
|
||||
|
||||
class CMemoryFileLoader
|
||||
{
|
||||
public:
|
||||
CMemoryFileLoader(int size, const void * c_pvMemoryFile);
|
||||
virtual ~CMemoryFileLoader();
|
||||
|
||||
bool Read(int size, void* pvDst);
|
||||
|
||||
int GetPosition();
|
||||
int GetSize();
|
||||
|
||||
protected:
|
||||
bool IsReadableSize(int size);
|
||||
const char * GetCurrentPositionPointer();
|
||||
|
||||
protected:
|
||||
const char * m_pcBase;
|
||||
int m_size;
|
||||
int m_pos;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
class CDiskFileLoader
|
||||
{
|
||||
public:
|
||||
CDiskFileLoader();
|
||||
virtual ~CDiskFileLoader();
|
||||
|
||||
void Close();
|
||||
bool Open(const char * c_szFileName);
|
||||
bool Read(int size, void * pvDst);
|
||||
|
||||
int GetSize();
|
||||
|
||||
protected:
|
||||
void Initialize();
|
||||
|
||||
protected:
|
||||
FILE * m_fp;
|
||||
int m_size;
|
||||
};
|
||||
|
||||
typedef std::map<std::string, std::string> TStringMap;
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
370
source-client/Srcs/Client/EterBase/Filename.h
Normal file
370
source-client/Srcs/Client/EterBase/Filename.h
Normal file
@ -0,0 +1,370 @@
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CFilename Class
|
||||
//
|
||||
// (c) 2003 IDV, Inc. (half-fixed by martysama0134)
|
||||
//
|
||||
// *** INTERACTIVE DATA VISUALIZATION (IDV) PROPRIETARY INFORMATION ***
|
||||
//
|
||||
// This software is supplied under the terms of a license agreement or
|
||||
// nondisclosure agreement with Interactive Data Visualization and may
|
||||
// not be copied or disclosed except in accordance with the terms of
|
||||
// that agreement.
|
||||
//
|
||||
// Copyright (c) 2001-2003 IDV, Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// IDV, Inc.
|
||||
// 1233 Washington St. Suite 610
|
||||
// Columbia, SC 29201
|
||||
// Voice: (803) 799-1699
|
||||
// Fax: (803) 931-0320
|
||||
// Web: http://www.idvinc.com
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
using std::string;
|
||||
using namespace std::string_literals;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CFilename Class
|
||||
|
||||
/*
|
||||
#define CFilename CFileNameHelper
|
||||
*/
|
||||
|
||||
class CFilename
|
||||
{
|
||||
public:
|
||||
CFilename() { }
|
||||
CFilename(const char* pFilename) { m_sRaw = pFilename; }
|
||||
CFilename(std::string strFilename) { m_sRaw = strFilename; }
|
||||
|
||||
virtual ~CFilename() {}
|
||||
|
||||
operator const string() const { return m_sRaw; }
|
||||
operator string&() { return m_sRaw; }
|
||||
CFilename& operator =(const CFilename& r) { m_sRaw = r.m_sRaw; return *this; }
|
||||
bool operator ==(const CFilename& r) const { return m_sRaw == r.m_sRaw; }
|
||||
CFilename operator +(const CFilename& r) const { return CFilename(m_sRaw + r.m_sRaw); }
|
||||
CFilename& operator +=(const CFilename& r) { m_sRaw += r.m_sRaw; return *this; }
|
||||
const char& operator[](size_t nIdx) const { return m_sRaw[nIdx]; }
|
||||
const char* c_str() const { return m_sRaw.c_str(); }
|
||||
size_t find(const char* pcszSrc) const { return m_sRaw.find(pcszSrc); }
|
||||
bool empty() const { return m_sRaw.empty(); }
|
||||
size_t size() const { return m_sRaw.size(); }
|
||||
size_t length() const { return m_sRaw.length(); }
|
||||
|
||||
string& GetString() { return m_sRaw; }
|
||||
|
||||
void ChangeDosPath()
|
||||
{
|
||||
size_t nLength = m_sRaw.length();
|
||||
|
||||
for (size_t i = 0; i < nLength; ++i)
|
||||
{
|
||||
if (m_sRaw.at(i) == '/')
|
||||
m_sRaw.at(i) = '\\';
|
||||
}
|
||||
}
|
||||
|
||||
void StringPath()
|
||||
{
|
||||
size_t nLength = m_sRaw.length();
|
||||
|
||||
for (size_t i = 0; i<nLength; ++i)
|
||||
{
|
||||
if (m_sRaw.at(i) == '\\')
|
||||
m_sRaw.at(i) = '/';
|
||||
else
|
||||
m_sRaw.at(i) = (char)tolower(m_sRaw.at(i));
|
||||
}
|
||||
}
|
||||
|
||||
string GetName(void); // if filename is "/idv/code/file.cpp", it returns "file"
|
||||
string GetExtension(void); // if filename is "/idv/code/file.cpp", it returns "cpp"
|
||||
string GetPath(void); // if filename is "/idv/code/file.cpp", it returns "/idv/code"
|
||||
string NoExtension(void); // if filename is "/idv/code/file.cpp", it returns "/idv/code/file"
|
||||
string NoPath(void); // if filename is "/idv/code/file.cpp", it returns "file.cpp"
|
||||
|
||||
int compare (const char* s) const { return m_sRaw.compare(s); }
|
||||
friend CFilename operator +(const string alfa, const CFilename& beta);
|
||||
|
||||
string m_sRaw;
|
||||
};
|
||||
|
||||
inline CFilename operator +(const string alfa, const CFilename& beta) { return beta + alfa; }
|
||||
|
||||
inline string CFilename::GetName(void) // if filename is "/idv/code/file.cpp", it returns "file"
|
||||
{
|
||||
string strName;
|
||||
|
||||
size_t nLength = m_sRaw.length();
|
||||
|
||||
if (nLength > 0)
|
||||
{
|
||||
size_t iExtensionStartPos = nLength - 1;
|
||||
|
||||
for (size_t i = nLength - 1; i > 0; i--)
|
||||
{
|
||||
if (m_sRaw[i] == '.')
|
||||
{
|
||||
iExtensionStartPos = i;
|
||||
}
|
||||
|
||||
if (m_sRaw[i] == '/')
|
||||
{
|
||||
strName = string(m_sRaw.c_str() + i + 1);
|
||||
strName.resize(iExtensionStartPos - i - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return strName;
|
||||
}
|
||||
inline string CFilename::GetExtension(void) // if filename is "/idv/code/file.cpp", it returns "cpp"
|
||||
{
|
||||
string strExtension;
|
||||
|
||||
size_t nLength = m_sRaw.length();
|
||||
|
||||
if (nLength > 0)
|
||||
{
|
||||
for (size_t i = nLength - 1; i > 0 && m_sRaw[i] != '/'; i--)
|
||||
if (m_sRaw[i] == '.')
|
||||
{
|
||||
strExtension = string(m_sRaw.c_str( ) + i + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return strExtension;
|
||||
}
|
||||
inline string CFilename::GetPath(void) // if filename is "/idv/code/file.cpp", it returns "/idv/code"
|
||||
{
|
||||
char szPath[1024];
|
||||
szPath[0] = '\0';
|
||||
|
||||
size_t nLength = m_sRaw.length();
|
||||
|
||||
if (nLength > 0)
|
||||
{
|
||||
for (size_t i = nLength - 1; i > 0; i--)
|
||||
{
|
||||
if (m_sRaw[i] == '/' || m_sRaw[i] == '\\')
|
||||
{
|
||||
for (size_t j = 0; j < i + 1; j++)
|
||||
szPath[j] = m_sRaw[j];
|
||||
szPath[i+1] = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
if (0 == i)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return szPath;
|
||||
}
|
||||
inline string CFilename::NoExtension(void) // if filename is "/idv/code/file.cpp", it returns "/idv/code/file"
|
||||
{
|
||||
std::size_t npos = m_sRaw.find_last_of('.');
|
||||
|
||||
if (string::npos != npos)
|
||||
return std::string(m_sRaw, 0, npos);
|
||||
|
||||
return m_sRaw;
|
||||
}
|
||||
inline string CFilename::NoPath(void) // if filename is "/idv/code/file.cpp", it returns "file.cpp"
|
||||
{
|
||||
char szPath[1024];
|
||||
szPath[0] = '\0';
|
||||
|
||||
size_t nLength = m_sRaw.length();
|
||||
|
||||
if (nLength > 0)
|
||||
{
|
||||
strcpy(szPath, m_sRaw.c_str());
|
||||
|
||||
for (size_t i = nLength - 1; i > 0; i--)
|
||||
{
|
||||
if (m_sRaw[i] == '/' || m_sRaw[i] == '\\')
|
||||
{
|
||||
int k = 0;
|
||||
for (size_t j = i + 1; j < nLength; j++, k++)
|
||||
szPath[k] = m_sRaw[j];
|
||||
szPath[k] = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
if (0 == i)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return szPath;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CFileNameHelper Class
|
||||
|
||||
class CFileNameHelper
|
||||
{
|
||||
public:
|
||||
static void ChangeDosPath(string& str) {
|
||||
size_t nLength = str.length();
|
||||
|
||||
for (size_t i = 0; i < nLength; ++i)
|
||||
{
|
||||
if (str.at(i) == '/')
|
||||
str.at(i) = '\\';
|
||||
}
|
||||
}
|
||||
|
||||
static void StringPath(string& str) {
|
||||
size_t nLength = str.length();
|
||||
|
||||
for (size_t i = 0; i<nLength; ++i)
|
||||
{
|
||||
if (str.at(i) == '\\')
|
||||
str.at(i) = '/';
|
||||
else
|
||||
str.at(i) = (char)tolower(str.at(i));
|
||||
}
|
||||
}
|
||||
|
||||
static string GetName(const string& str); // if filename is "/idv/code/file.cpp", it returns "file"
|
||||
static string GetExtension(const string& str); // if filename is "/idv/code/file.cpp", it returns "cpp"
|
||||
static string GetPath(const string& str); // if filename is "/idv/code/file.cpp", it returns "/idv/code"
|
||||
static string NoExtension(const string& str); // if filename is "/idv/code/file.cpp", it returns "/idv/code/file"
|
||||
static string NoPath(const string& str); // if filename is "/idv/code/file.cpp", it returns "file.cpp"
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CFileNameHelper::GetExtension
|
||||
|
||||
inline string CFileNameHelper::GetName(const string& str)
|
||||
{
|
||||
string strName;
|
||||
|
||||
size_t nLength = str.length();
|
||||
|
||||
if (nLength > 0)
|
||||
{
|
||||
size_t iExtensionStartPos = nLength - 1;
|
||||
|
||||
for (size_t i = nLength - 1; i > 0; i--)
|
||||
{
|
||||
if (str[i] == '.')
|
||||
{
|
||||
iExtensionStartPos = i;
|
||||
}
|
||||
|
||||
if (str[i] == '/')
|
||||
{
|
||||
strName = string(str.c_str() + i + 1);
|
||||
strName.resize(iExtensionStartPos - i - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return strName;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CFilenameHelper::GetExtension
|
||||
|
||||
inline string CFileNameHelper::GetExtension(const string& str)
|
||||
{
|
||||
string strExtension;
|
||||
|
||||
size_t nLength = str.length();
|
||||
|
||||
if (nLength > 0)
|
||||
{
|
||||
for (size_t i = nLength - 1; i > 0 && str[i] != '/'; i--)
|
||||
if (str[i] == '.')
|
||||
{
|
||||
strExtension = string(str.c_str( ) + i + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return strExtension;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CFilenameHelper::GetPath
|
||||
|
||||
inline string CFileNameHelper::GetPath(const string& str)
|
||||
{
|
||||
char szPath[1024];
|
||||
szPath[0] = '\0';
|
||||
|
||||
size_t nLength = str.length();
|
||||
|
||||
if (nLength > 0)
|
||||
{
|
||||
for (size_t i = nLength - 1; i > 0; i--)
|
||||
{
|
||||
if (str[i] == '/' || str[i] == '\\')
|
||||
{
|
||||
for (size_t j = 0; j < i + 1; j++)
|
||||
szPath[j] = str[j];
|
||||
szPath[i+1] = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
if (0 == i)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return szPath;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CFilenameHelper::NoExtension
|
||||
|
||||
inline string CFileNameHelper::NoExtension(const string& str)
|
||||
{
|
||||
std::size_t npos = str.find_last_of('.');
|
||||
|
||||
if (string::npos != npos)
|
||||
return std::string(str, 0, npos);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CFilenameHelper::NoPath
|
||||
|
||||
inline string CFileNameHelper::NoPath(const string& str)
|
||||
{
|
||||
char szPath[1024];
|
||||
szPath[0] = '\0';
|
||||
|
||||
size_t nLength = str.length();
|
||||
|
||||
if (nLength > 0)
|
||||
{
|
||||
strcpy(szPath, str.c_str());
|
||||
|
||||
for (size_t i = nLength - 1; i > 0; i--)
|
||||
{
|
||||
if (str[i] == '/' || str[i] == '\\')
|
||||
{
|
||||
int k = 0;
|
||||
for (size_t j = i + 1; j < nLength; j++, k++)
|
||||
szPath[k] = str[j];
|
||||
szPath[k] = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
if (0 == i)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return szPath;
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
255
source-client/Srcs/Client/EterBase/MappedFile.cpp
Normal file
255
source-client/Srcs/Client/EterBase/MappedFile.cpp
Normal file
@ -0,0 +1,255 @@
|
||||
#include "StdAfx.h"
|
||||
#include "MappedFile.h"
|
||||
#include "Debug.h"
|
||||
|
||||
CMappedFile::CMappedFile() :
|
||||
m_hFM(NULL),
|
||||
m_lpMapData(NULL),
|
||||
m_dataOffset(0),
|
||||
m_mapSize(0),
|
||||
m_seekPosition(0),
|
||||
m_pLZObj(NULL),
|
||||
m_pbBufLinkData(NULL),
|
||||
m_dwBufLinkSize(0),
|
||||
m_pbAppendResultDataBlock(NULL),
|
||||
m_dwAppendResultDataSize(0)
|
||||
{
|
||||
}
|
||||
|
||||
CMappedFile::~CMappedFile()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
BOOL CMappedFile::Create(const char * filename)
|
||||
{
|
||||
Destroy();
|
||||
return CFileBase::Create(filename, FILEMODE_READ);
|
||||
}
|
||||
|
||||
BOOL CMappedFile::Create(const char * filename, const void** dest, int offset, int size)
|
||||
{
|
||||
if (!CMappedFile::Create(filename))
|
||||
return NULL;
|
||||
|
||||
int ret = Map(dest, offset, size);
|
||||
return (ret) > 0;
|
||||
}
|
||||
|
||||
LPCVOID CMappedFile::Get()
|
||||
{
|
||||
return m_lpData;
|
||||
}
|
||||
|
||||
void CMappedFile::Link(DWORD dwBufSize, const void* c_pvBufData)
|
||||
{
|
||||
m_dwBufLinkSize=dwBufSize;
|
||||
m_pbBufLinkData=(BYTE*)c_pvBufData;
|
||||
}
|
||||
|
||||
void CMappedFile::BindLZObject(CLZObject * pLZObj)
|
||||
{
|
||||
assert(m_pLZObj == NULL);
|
||||
m_pLZObj = pLZObj;
|
||||
|
||||
Link(m_pLZObj->GetSize(), m_pLZObj->GetBuffer());
|
||||
}
|
||||
|
||||
void CMappedFile::BindLZObjectWithBufferedSize(CLZObject * pLZObj)
|
||||
{
|
||||
assert(m_pLZObj == NULL);
|
||||
m_pLZObj = pLZObj;
|
||||
|
||||
Link(m_pLZObj->GetBufferSize(), m_pLZObj->GetBuffer());
|
||||
}
|
||||
|
||||
BYTE* CMappedFile::AppendDataBlock( const void* pBlock, DWORD dwBlockSize )
|
||||
{
|
||||
if( m_pbAppendResultDataBlock )
|
||||
{
|
||||
delete []m_pbAppendResultDataBlock;
|
||||
}
|
||||
|
||||
//realloc
|
||||
m_dwAppendResultDataSize = m_dwBufLinkSize+dwBlockSize;
|
||||
m_pbAppendResultDataBlock = new BYTE[m_dwAppendResultDataSize];
|
||||
|
||||
memcpy(m_pbAppendResultDataBlock, m_pbBufLinkData, m_dwBufLinkSize );
|
||||
memcpy(m_pbAppendResultDataBlock + m_dwBufLinkSize, pBlock, dwBlockSize );
|
||||
|
||||
//redirect
|
||||
Link(m_dwAppendResultDataSize, m_pbAppendResultDataBlock);
|
||||
|
||||
return m_pbAppendResultDataBlock;
|
||||
}
|
||||
|
||||
void CMappedFile::Destroy()
|
||||
{
|
||||
if (m_pLZObj)
|
||||
{
|
||||
delete m_pLZObj;
|
||||
m_pLZObj = NULL;
|
||||
}
|
||||
|
||||
if (NULL != m_lpMapData)
|
||||
{
|
||||
Unmap(m_lpMapData);
|
||||
m_lpMapData = NULL;
|
||||
}
|
||||
|
||||
if (NULL != m_hFM)
|
||||
{
|
||||
CloseHandle(m_hFM);
|
||||
m_hFM = NULL;
|
||||
}
|
||||
|
||||
if( m_pbAppendResultDataBlock )
|
||||
{
|
||||
delete []m_pbAppendResultDataBlock;
|
||||
m_pbAppendResultDataBlock = NULL;
|
||||
}
|
||||
|
||||
m_dwAppendResultDataSize = 0;
|
||||
|
||||
m_pbBufLinkData = NULL;
|
||||
m_dwBufLinkSize = 0;
|
||||
|
||||
m_seekPosition = 0;
|
||||
m_dataOffset = 0;
|
||||
m_mapSize = 0;
|
||||
|
||||
CFileBase::Destroy();
|
||||
}
|
||||
|
||||
int CMappedFile::Seek(DWORD offset, int iSeekType)
|
||||
{
|
||||
switch (iSeekType)
|
||||
{
|
||||
case SEEK_TYPE_BEGIN:
|
||||
if (offset > m_dwSize)
|
||||
offset = m_dwSize;
|
||||
|
||||
m_seekPosition = offset;
|
||||
break;
|
||||
|
||||
case SEEK_TYPE_CURRENT:
|
||||
m_seekPosition = min(m_seekPosition + offset, Size());
|
||||
break;
|
||||
|
||||
case SEEK_TYPE_END:
|
||||
m_seekPosition = max(0, Size() - offset);
|
||||
break;
|
||||
}
|
||||
|
||||
return m_seekPosition;
|
||||
}
|
||||
|
||||
//DWORD g_dwCount=0;
|
||||
|
||||
int CMappedFile::Map(const void **dest, int offset, int size)
|
||||
{
|
||||
m_dataOffset = offset;
|
||||
|
||||
if (size == 0)
|
||||
m_mapSize = m_dwSize;
|
||||
else
|
||||
m_mapSize = size;
|
||||
|
||||
if (m_dataOffset + m_mapSize > m_dwSize)
|
||||
return NULL;
|
||||
|
||||
SYSTEM_INFO SysInfo;
|
||||
GetSystemInfo(&SysInfo);
|
||||
DWORD dwSysGran = SysInfo.dwAllocationGranularity;
|
||||
DWORD dwFileMapStart = (m_dataOffset / dwSysGran) * dwSysGran;
|
||||
DWORD dwMapViewSize = (m_dataOffset % dwSysGran) + m_mapSize;
|
||||
INT iViewDelta = m_dataOffset - dwFileMapStart;
|
||||
|
||||
m_hFM = CreateFileMapping(m_hFile, // handle
|
||||
NULL, // security
|
||||
PAGE_READONLY, // flProtect
|
||||
0, // high
|
||||
m_dataOffset + m_mapSize, // low
|
||||
NULL); // name
|
||||
|
||||
if (!m_hFM)
|
||||
{
|
||||
OutputDebugString("CMappedFile::Map !m_hFM\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
m_lpMapData = MapViewOfFile(m_hFM,
|
||||
FILE_MAP_READ,
|
||||
0,
|
||||
dwFileMapStart,
|
||||
dwMapViewSize);
|
||||
|
||||
if (!m_lpMapData) // Success
|
||||
{
|
||||
TraceError("CMappedFile::Map !m_lpMapData %lu", GetLastError());
|
||||
return 0;
|
||||
}
|
||||
|
||||
//g_dwCount++;
|
||||
//Tracenf("MAPFILE %d", g_dwCount);
|
||||
|
||||
m_lpData = (char*) m_lpMapData + iViewDelta;
|
||||
*dest = (char*) m_lpData;
|
||||
m_seekPosition = 0;
|
||||
|
||||
Link(m_mapSize, m_lpData);
|
||||
|
||||
return (m_mapSize);
|
||||
}
|
||||
|
||||
BYTE * CMappedFile::GetCurrentSeekPoint()
|
||||
{
|
||||
return m_pbBufLinkData+m_seekPosition;
|
||||
//return m_pLZObj ? m_pLZObj->GetBuffer() + m_seekPosition : (BYTE *) m_lpData + m_seekPosition;
|
||||
}
|
||||
|
||||
DWORD CMappedFile::Size()
|
||||
{
|
||||
return m_dwBufLinkSize;
|
||||
/*
|
||||
if (m_pLZObj)
|
||||
return m_pLZObj->GetSize();
|
||||
|
||||
return (m_mapSize);
|
||||
*/
|
||||
}
|
||||
|
||||
DWORD CMappedFile::GetPosition()
|
||||
{
|
||||
return m_dataOffset;
|
||||
}
|
||||
|
||||
BOOL CMappedFile::Read(void * dest, int bytes)
|
||||
{
|
||||
if (m_seekPosition + bytes > Size())
|
||||
return FALSE;
|
||||
|
||||
memcpy(dest, GetCurrentSeekPoint(), bytes);
|
||||
m_seekPosition += bytes;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
DWORD CMappedFile::GetSeekPosition(void)
|
||||
{
|
||||
return m_seekPosition;
|
||||
}
|
||||
|
||||
void CMappedFile::Unmap(LPCVOID data)
|
||||
{
|
||||
if (UnmapViewOfFile(data))
|
||||
{
|
||||
//g_dwCount--;
|
||||
//Tracenf("UNMAPFILE %d", g_dwCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
TraceError("CMappedFile::Unmap - Error");
|
||||
}
|
||||
m_lpData = NULL;
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
60
source-client/Srcs/Client/EterBase/MappedFile.h
Normal file
60
source-client/Srcs/Client/EterBase/MappedFile.h
Normal file
@ -0,0 +1,60 @@
|
||||
#ifndef __INC_MAPPEDFILE_H__
|
||||
#define __INC_MAPPEDFILE_H__
|
||||
|
||||
#include "lzo.h"
|
||||
#include "FileBase.h"
|
||||
|
||||
class CMappedFile : public CFileBase
|
||||
{
|
||||
public:
|
||||
enum ESeekType
|
||||
{
|
||||
SEEK_TYPE_BEGIN,
|
||||
SEEK_TYPE_CURRENT,
|
||||
SEEK_TYPE_END
|
||||
};
|
||||
|
||||
public:
|
||||
CMappedFile();
|
||||
virtual ~CMappedFile();
|
||||
|
||||
void Link(DWORD dwBufSize, const void* c_pvBufData);
|
||||
|
||||
BOOL Create(const char* filename);
|
||||
BOOL Create(const char* filename, const void** dest, int offset, int size);
|
||||
LPCVOID Get();
|
||||
void Destroy();
|
||||
int Seek(DWORD offset, int iSeekType = SEEK_TYPE_BEGIN);
|
||||
int Map(const void **dest, int offset=0, int size=0);
|
||||
DWORD Size();
|
||||
DWORD GetPosition();
|
||||
BOOL Read(void* dest, int bytes);
|
||||
DWORD GetSeekPosition();
|
||||
void BindLZObject(CLZObject * pLZObj);
|
||||
void BindLZObjectWithBufferedSize(CLZObject * pLZObj);
|
||||
BYTE* AppendDataBlock( const void* pBlock, DWORD dwBlockSize );
|
||||
|
||||
BYTE * GetCurrentSeekPoint();
|
||||
|
||||
private:
|
||||
void Unmap(LPCVOID data);
|
||||
|
||||
private:
|
||||
BYTE* m_pbBufLinkData;
|
||||
DWORD m_dwBufLinkSize;
|
||||
|
||||
BYTE* m_pbAppendResultDataBlock;
|
||||
DWORD m_dwAppendResultDataSize;
|
||||
|
||||
DWORD m_seekPosition;
|
||||
HANDLE m_hFM;
|
||||
DWORD m_dataOffset;
|
||||
DWORD m_mapSize;
|
||||
LPVOID m_lpMapData;
|
||||
LPVOID m_lpData;
|
||||
|
||||
CLZObject * m_pLZObj;
|
||||
};
|
||||
|
||||
#endif
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
27
source-client/Srcs/Client/EterBase/Poly/Base.cpp
Normal file
27
source-client/Srcs/Client/EterBase/Poly/Base.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include "StdAfx.h"
|
||||
#include "Base.h"
|
||||
|
||||
CBase::CBase()
|
||||
{
|
||||
id = 0;
|
||||
}
|
||||
|
||||
CBase::~CBase()
|
||||
{
|
||||
}
|
||||
|
||||
bool CBase::isNumber()
|
||||
{
|
||||
return (id & MID_NUMBER) != 0 ? true : false;
|
||||
}
|
||||
|
||||
bool CBase::isVar()
|
||||
{
|
||||
return (id & MID_VARIABLE) != 0 ? true : false;
|
||||
}
|
||||
|
||||
bool CBase::isSymbol()
|
||||
{
|
||||
return (id & MID_SYMBOL) != 0 ? true : false;
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
25
source-client/Srcs/Client/EterBase/Poly/Base.h
Normal file
25
source-client/Srcs/Client/EterBase/Poly/Base.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef __POLY_BASE_H__
|
||||
#define __POLY_BASE_H__
|
||||
|
||||
#define MID_UNKNOWN 0
|
||||
#define MID_NUMBER 256
|
||||
#define MID_VARIABLE 512
|
||||
#define MID_SYMBOL 1024
|
||||
|
||||
#define MID_LONG MID_NUMBER + 1
|
||||
#define MID_SQRT MID_NUMBER + 2
|
||||
#define MID_FRACTION MID_NUMBER + 3
|
||||
|
||||
class CBase
|
||||
{
|
||||
public:
|
||||
bool isSymbol();
|
||||
bool isVar();
|
||||
bool isNumber();
|
||||
int id;
|
||||
CBase();
|
||||
virtual ~CBase();
|
||||
};
|
||||
|
||||
#endif
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
621
source-client/Srcs/Client/EterBase/Poly/Poly.cpp
Normal file
621
source-client/Srcs/Client/EterBase/Poly/Poly.cpp
Normal file
@ -0,0 +1,621 @@
|
||||
#include "StdAfx.h"
|
||||
#include <string>
|
||||
#include <assert.h>
|
||||
|
||||
#include "Poly.h"
|
||||
#include <cmath>
|
||||
#include <cctype>
|
||||
#include <cstdlib>
|
||||
|
||||
using namespace std;
|
||||
|
||||
double _random()
|
||||
{
|
||||
return rand() / (RAND_MAX + 1.0);
|
||||
}
|
||||
|
||||
void CPoly::SetRandom(int iRandomType)
|
||||
{
|
||||
m_iRandomType = iRandomType;
|
||||
}
|
||||
|
||||
int CPoly::my_irandom(double start, double end)
|
||||
{
|
||||
switch (m_iRandomType)
|
||||
{
|
||||
case RANDOM_TYPE_FORCE_MIN:
|
||||
return int(start);
|
||||
break;
|
||||
case RANDOM_TYPE_FORCE_MAX:
|
||||
return int(end);
|
||||
break;
|
||||
}
|
||||
|
||||
// Make range as inclusive-exclusive
|
||||
int is = int(start + 0.5);
|
||||
int ie = int(end - start + 0.5) + 1;
|
||||
|
||||
return int(_random() * ie + is);
|
||||
}
|
||||
|
||||
double CPoly::my_frandom(double start, double end)
|
||||
{
|
||||
return _random() * (end - start) + start;
|
||||
}
|
||||
|
||||
CPoly::CPoly()
|
||||
{
|
||||
m_iRandomType = RANDOM_TYPE_FREELY;
|
||||
uiLookPos = 0;
|
||||
ErrorOccur = true;
|
||||
lSymbol.clear();
|
||||
STSize = 0;
|
||||
MathSymbolCount = 0;
|
||||
lSymbol.reserve(50);
|
||||
init();
|
||||
}
|
||||
|
||||
CPoly::~CPoly()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void CPoly::SetStr(const string & str)
|
||||
{
|
||||
strData = str;
|
||||
}
|
||||
|
||||
float CPoly::Eval()
|
||||
{
|
||||
int stNow;
|
||||
double save[POLY_MAXSTACK],t;
|
||||
int iSp=0;
|
||||
if (ErrorOccur)
|
||||
{
|
||||
/*THROW(new CEvalException("Evaluate Error"));*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
//TEST
|
||||
//list<int>::iterator pos = tokenBase.begin();
|
||||
//list<double>::iterator posn = numBase.begin();
|
||||
vector<int>::iterator pos = tokenBase.begin();
|
||||
vector<double>::iterator posn = numBase.begin();
|
||||
while (pos != tokenBase.end())
|
||||
{
|
||||
stNow=*pos;
|
||||
++pos;
|
||||
switch (stNow)
|
||||
{
|
||||
case POLY_NUM:
|
||||
save[iSp++]=*posn++; break;
|
||||
case POLY_ID:
|
||||
save[iSp++]=
|
||||
lSymbol[ *pos ]->dVal;
|
||||
pos++;
|
||||
break;
|
||||
//case '+':
|
||||
case POLY_PLU:
|
||||
iSp--;
|
||||
save[iSp-1]+=save[iSp]; break;
|
||||
//case '-':
|
||||
case POLY_MIN:
|
||||
iSp--;
|
||||
save[iSp-1]-=save[iSp]; break;
|
||||
//case '*':
|
||||
case POLY_MUL:
|
||||
iSp--;
|
||||
save[iSp-1]*=save[iSp]; break;
|
||||
//case '%':
|
||||
case POLY_MOD:
|
||||
iSp--;
|
||||
if (save[iSp]==0)
|
||||
{
|
||||
//THROW(new CEvalException("Divide by 0"));
|
||||
return 0;
|
||||
}
|
||||
save[iSp-1]=fmod(save[iSp-1],save[iSp]); break;
|
||||
//case '/':
|
||||
case POLY_DIV:
|
||||
iSp--;
|
||||
if (save[iSp]==0)
|
||||
{
|
||||
//THROW(new CEvalException("Divide by 0"));
|
||||
return 0;
|
||||
}
|
||||
save[iSp-1]/=save[iSp]; break;
|
||||
//case '^':
|
||||
case POLY_POW:
|
||||
iSp--;
|
||||
save[iSp-1]=pow(save[iSp-1],save[iSp]); break;
|
||||
case POLY_ROOT:
|
||||
if (save[iSp-1]<0)
|
||||
{
|
||||
//THROW(new CEvalException("Negative in root"));
|
||||
return 0;
|
||||
}
|
||||
save[iSp-1]=sqrt(save[iSp-1]); break;
|
||||
case POLY_COS:
|
||||
save[iSp-1]=cos(save[iSp-1]); break;
|
||||
case POLY_SIN:
|
||||
save[iSp-1]=sin(save[iSp-1]); break;
|
||||
case POLY_TAN:
|
||||
if (!(t=cos(save[iSp-1])))
|
||||
{
|
||||
//THROW (new CEvalException("Divide by 0"));
|
||||
return 0;
|
||||
}
|
||||
save[iSp-1]=tan(save[iSp-1]); break;
|
||||
case POLY_CSC:
|
||||
if (!(t=sin(save[iSp-1])))
|
||||
{
|
||||
//THROW(new CEvalException("Divide by 0"));
|
||||
return 0;
|
||||
}
|
||||
save[iSp-1]=1/t; break;
|
||||
case POLY_SEC:
|
||||
if (!(t=cos(save[iSp-1])))
|
||||
{
|
||||
//THROW(new CEvalException("Divide by 0"));
|
||||
return 0;
|
||||
}
|
||||
save[iSp-1]=1/t; break;
|
||||
case POLY_COT:
|
||||
if (!(t=sin(save[iSp-1])))
|
||||
{
|
||||
//THROW(new CEvalException("Divide by 0"));
|
||||
return 0;
|
||||
}
|
||||
save[iSp-1]=cos(save[iSp-1])/t; break;
|
||||
case POLY_LN:
|
||||
if (save[iSp-1]<=0)
|
||||
{
|
||||
//THROW( new CEvalException("Call Log with minus number"));
|
||||
return 0;
|
||||
}
|
||||
save[iSp-1]=log(save[iSp-1]); break;
|
||||
case POLY_LOG10:
|
||||
if (save[iSp-1]<=0)
|
||||
{
|
||||
//THROW( new CEvalException("Call Log with minus number"));
|
||||
return 0;
|
||||
}
|
||||
save[iSp-1]=log10(save[iSp-1]); break;
|
||||
case POLY_LOG:
|
||||
if (save[iSp-1]<=0)
|
||||
{
|
||||
//THROW( new CEvalException("Call Log with minus number"));
|
||||
return 0;
|
||||
}
|
||||
if (save[iSp-2]<=0 || save[iSp-2]==1)
|
||||
{
|
||||
//THROW( new CEvalException("Call Log with minus number"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
save[iSp-2]=log(save[iSp-1])/log(save[iSp-2]);
|
||||
iSp--;
|
||||
break;
|
||||
case POLY_ABS:
|
||||
save[iSp-1]=fabs(save[iSp-1]);
|
||||
break;
|
||||
case POLY_FLOOR:
|
||||
save[iSp-1]=floor(save[iSp-1]);
|
||||
break;
|
||||
case POLY_IRAND:
|
||||
save[iSp-2]=my_irandom(save[iSp-2],save[iSp-1]);
|
||||
iSp--;
|
||||
break;
|
||||
case POLY_FRAND:
|
||||
save[iSp-2]=my_frandom(save[iSp-2],save[iSp-1]);
|
||||
iSp--;
|
||||
break;
|
||||
case POLY_MINF:
|
||||
save[iSp-2]=(save[iSp-2]<save[iSp-1])?save[iSp-2]:save[iSp-1];
|
||||
iSp--;
|
||||
break;
|
||||
case POLY_MAXF:
|
||||
save[iSp-2]=(save[iSp-2]>save[iSp-1])?save[iSp-2]:save[iSp-1];
|
||||
iSp--;
|
||||
break;
|
||||
/*case POLY_MOD:
|
||||
save[iSp-2]=fmod(save[iSp-2],save[iSp-1]);
|
||||
iSp--;
|
||||
break;*/
|
||||
default:
|
||||
return 0;
|
||||
//THROW(new CEvalException("Token Error"));
|
||||
}
|
||||
}
|
||||
return float(save[iSp-1]);
|
||||
}
|
||||
|
||||
int CPoly::Analyze(const char * pszStr)
|
||||
{
|
||||
if (pszStr)
|
||||
SetStr(pszStr);
|
||||
|
||||
if (0 == strData.length())
|
||||
return true;
|
||||
|
||||
//DisposeList();
|
||||
ErrorOccur = false;
|
||||
uiLookPos = 0;
|
||||
iLookAhead = lexan();
|
||||
|
||||
expr();
|
||||
|
||||
if (tokenBase.empty())
|
||||
{
|
||||
//THROW(new CParseException("No Data"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return !ErrorOccur;
|
||||
}
|
||||
|
||||
void CPoly::Clear()
|
||||
{
|
||||
int i;
|
||||
//while (!tokenBase.IsEmpty()) listBase.RemoveTail();
|
||||
//while (!numBase.IsEmpty()) numBase.RemoveTail();
|
||||
tokenBase.clear();
|
||||
numBase.clear();
|
||||
|
||||
for (i = 0;i < STSize; ++i)
|
||||
{
|
||||
if (lSymbol[i]) delete lSymbol[i];
|
||||
lSymbol[i]=NULL;
|
||||
}
|
||||
//lSymbol.FreeExtra();
|
||||
lSymbol.clear();
|
||||
SymbolIndex.clear();
|
||||
STSize=0;
|
||||
MathSymbolCount=0;
|
||||
}
|
||||
|
||||
void CPoly::expr()
|
||||
{
|
||||
int t;
|
||||
|
||||
switch (iLookAhead)
|
||||
{
|
||||
case '+':
|
||||
case '-':
|
||||
uiLookPos--;
|
||||
iLookAhead = POLY_NUM;
|
||||
iNumToken = iToken = 0;
|
||||
|
||||
}
|
||||
|
||||
term();
|
||||
|
||||
while (!ErrorOccur)
|
||||
{
|
||||
switch (iLookAhead)
|
||||
{
|
||||
case '+':
|
||||
case '-':
|
||||
t=iLookAhead;
|
||||
match(t);
|
||||
term();
|
||||
emit(t,POLY_NONE);
|
||||
continue;
|
||||
case POLY_EOS: case ')': case ',': return;
|
||||
default:
|
||||
error();
|
||||
//THROW( new CParseException("Error Parsing"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPoly::error()
|
||||
{
|
||||
iErrorPos=uiLookPos;
|
||||
ErrorOccur=true;
|
||||
}
|
||||
|
||||
int CPoly::lexan()
|
||||
{
|
||||
int t;
|
||||
double tt;
|
||||
|
||||
while (uiLookPos < strData.size())
|
||||
{
|
||||
if (strData[uiLookPos] == ' ' || strData[uiLookPos] == '\t')
|
||||
;
|
||||
else if (isdigit(strData[uiLookPos]))
|
||||
{
|
||||
t = 0;
|
||||
for (;uiLookPos<strData.size();uiLookPos++)
|
||||
{
|
||||
if (isdigit(strData[uiLookPos]))
|
||||
t = t * 10 + strData[uiLookPos] - '0';
|
||||
else
|
||||
break;
|
||||
}
|
||||
iToken=t;
|
||||
tt=0.1;
|
||||
iNumToken=0;
|
||||
if (uiLookPos<strData.size() && strData[uiLookPos]=='.')
|
||||
{
|
||||
uiLookPos++;
|
||||
for (;uiLookPos<strData.size();uiLookPos++,tt*=0.1)
|
||||
{
|
||||
if (isdigit(strData[uiLookPos]))
|
||||
iNumToken+=tt*(strData[uiLookPos]-'0');
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
iNumToken+=iToken;
|
||||
return POLY_NUM;
|
||||
}
|
||||
else if (isalpha(strData[uiLookPos]))
|
||||
{
|
||||
string localSymbol("");
|
||||
while (uiLookPos<strData.size() && isalpha(strData[uiLookPos]))
|
||||
{
|
||||
localSymbol+=strData[uiLookPos];
|
||||
uiLookPos++;
|
||||
}
|
||||
iToken= find(localSymbol);
|
||||
if (iToken==-1)
|
||||
{
|
||||
iToken=insert(localSymbol,POLY_ID);
|
||||
}
|
||||
return lSymbol[(/*FindIndex*/(iToken))]->token;
|
||||
}
|
||||
else
|
||||
{
|
||||
iToken=0;
|
||||
return strData[uiLookPos++];
|
||||
}
|
||||
uiLookPos++;
|
||||
}
|
||||
return POLY_EOS;
|
||||
}
|
||||
|
||||
void CPoly::term()
|
||||
{
|
||||
int t;
|
||||
factor();
|
||||
while (!ErrorOccur)
|
||||
{
|
||||
switch (iLookAhead)
|
||||
{
|
||||
case '*':
|
||||
case '/':
|
||||
case '%':
|
||||
t=iLookAhead;
|
||||
match(t);
|
||||
factor();
|
||||
emit(t,POLY_NONE);
|
||||
continue;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPoly::factor()
|
||||
{
|
||||
int t;
|
||||
expo();
|
||||
while (!ErrorOccur)
|
||||
{
|
||||
switch (iLookAhead)
|
||||
{
|
||||
case '^':
|
||||
t=iLookAhead;
|
||||
match(t);
|
||||
expo();
|
||||
emit(t,POLY_NONE);
|
||||
continue;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPoly::expo()
|
||||
{
|
||||
int t;
|
||||
switch (iLookAhead)
|
||||
{
|
||||
case '(':
|
||||
match('('); expr(); match(')'); break;
|
||||
case POLY_NUM:
|
||||
emit(POLY_NUM, iToken); match(POLY_NUM); break;
|
||||
case POLY_ID:
|
||||
emit(POLY_ID,(int)/*FindIndex*/(iToken)); match(POLY_ID); break;
|
||||
case POLY_ROOT:
|
||||
case POLY_SIN:
|
||||
case POLY_COT:
|
||||
case POLY_TAN:
|
||||
case POLY_CSC:
|
||||
case POLY_SEC:
|
||||
case POLY_LN:
|
||||
case POLY_LOG10:
|
||||
case POLY_COS:
|
||||
case POLY_ABS:
|
||||
case POLY_FLOOR:
|
||||
t=iLookAhead;
|
||||
match(iLookAhead); match('('); expr(); match(')'); emit(t,iToken);
|
||||
break;
|
||||
case POLY_LOG:
|
||||
case POLY_MINF:
|
||||
case POLY_MAXF:
|
||||
case POLY_IRAND:
|
||||
case POLY_FRAND:
|
||||
case POLY_MOD:
|
||||
t=iLookAhead;
|
||||
match(iLookAhead); match('('); expr(); match(','); expr(); match(')'); emit(t,iToken);
|
||||
break;
|
||||
case POLY_EOS:
|
||||
break;
|
||||
default:
|
||||
error();
|
||||
//THROW( new CParseException("Error Parsing"));
|
||||
}
|
||||
}
|
||||
|
||||
void CPoly::match(int t)
|
||||
{
|
||||
if (iLookAhead==t) iLookAhead=lexan(); else error();
|
||||
}
|
||||
|
||||
void CPoly::emit(int t, int tval)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
case '+':
|
||||
tokenBase.push_back(POLY_PLU);
|
||||
break;
|
||||
case '-':
|
||||
tokenBase.push_back(POLY_MIN);
|
||||
break;
|
||||
case '*':
|
||||
tokenBase.push_back(POLY_MUL);
|
||||
break;
|
||||
case '/':
|
||||
tokenBase.push_back(POLY_DIV);
|
||||
break;
|
||||
case '%':
|
||||
tokenBase.push_back(POLY_MOD);
|
||||
break;
|
||||
case '^':
|
||||
tokenBase.push_back(POLY_POW);
|
||||
break;
|
||||
case POLY_ROOT:
|
||||
case POLY_SIN:
|
||||
case POLY_TAN:
|
||||
case POLY_COT:
|
||||
case POLY_COS:
|
||||
case POLY_CSC:
|
||||
case POLY_SEC:
|
||||
case POLY_LOG:
|
||||
case POLY_LN:
|
||||
case POLY_LOG10:
|
||||
case POLY_ABS:
|
||||
case POLY_MINF:
|
||||
case POLY_MAXF:
|
||||
case POLY_IRAND:
|
||||
case POLY_FRAND:
|
||||
case POLY_MOD:
|
||||
case POLY_FLOOR:
|
||||
tokenBase.push_back(t);
|
||||
break;
|
||||
case POLY_NUM:
|
||||
tokenBase.push_back(t);
|
||||
numBase.push_back(iNumToken);
|
||||
break;
|
||||
case POLY_ID:
|
||||
tokenBase.push_back(t);
|
||||
tokenBase.push_back(tval); break;
|
||||
default:
|
||||
error();
|
||||
Clear();
|
||||
//THROW( new CParseException("Error Parsing"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int CPoly::find(const string & s)
|
||||
{
|
||||
int l, m, r;
|
||||
|
||||
l = 0;
|
||||
r = STSize - 1;
|
||||
|
||||
while (l <= r)
|
||||
{
|
||||
m = (l + r) >> 1;
|
||||
|
||||
if (lSymbol[SymbolIndex[m]]->strlex == s)
|
||||
return SymbolIndex[m];
|
||||
else if (lSymbol[SymbolIndex[m]]->strlex < s)
|
||||
l = m + 1;
|
||||
else
|
||||
r = m - 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int CPoly::insert(const string & s, int tok)
|
||||
{
|
||||
int i;
|
||||
bool bAdded=false;
|
||||
|
||||
lSymbol.push_back(new CSymTable(tok,s));
|
||||
for (i=0;i<STSize;i++)
|
||||
{
|
||||
if (s<lSymbol[SymbolIndex[i]]->strlex)
|
||||
{
|
||||
SymbolIndex.insert(SymbolIndex.begin()+i,STSize);
|
||||
bAdded=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!bAdded)
|
||||
{
|
||||
//SymbolIndex.SetAtGrow(STSize,STSize);
|
||||
SymbolIndex.push_back(STSize);
|
||||
}
|
||||
STSize++;
|
||||
return STSize-1;
|
||||
}
|
||||
|
||||
int CPoly::SetVar(const string & strName, double dVar)
|
||||
{
|
||||
if (ErrorOccur) return false;
|
||||
int index=find(strName);
|
||||
if (index==-1) return false;
|
||||
CSymTable* stVar = lSymbol[(/*FindIndex*/(index))];
|
||||
stVar->dVal=dVar;
|
||||
return true;
|
||||
}
|
||||
|
||||
int CPoly::GetVarCount()
|
||||
{
|
||||
return lSymbol.size() - MathSymbolCount;
|
||||
}
|
||||
|
||||
const char * CPoly::GetVarName(unsigned int dwIndex)
|
||||
{
|
||||
assert(dwIndex + MathSymbolCount < lSymbol.size());
|
||||
return lSymbol[dwIndex + MathSymbolCount]->strlex.c_str();
|
||||
}
|
||||
|
||||
void CPoly::init()
|
||||
{
|
||||
insert("min",POLY_MINF);
|
||||
insert("max",POLY_MAXF);
|
||||
insert("number", POLY_IRAND);
|
||||
insert("irandom", POLY_IRAND);
|
||||
insert("irand", POLY_IRAND);
|
||||
insert("frandom",POLY_FRAND);
|
||||
insert("frand",POLY_FRAND);
|
||||
insert("rt",POLY_ROOT);
|
||||
insert("sqrt",POLY_ROOT);
|
||||
insert("cos",POLY_COS);
|
||||
insert("sin",POLY_SIN);
|
||||
insert("tan",POLY_TAN);
|
||||
insert("cot",POLY_COT);
|
||||
insert("csc",POLY_CSC);
|
||||
insert("cosec",POLY_COSEC);
|
||||
insert("sec",POLY_SEC);
|
||||
insert("pi",POLY_PI);
|
||||
SetVar("pi",3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068);
|
||||
insert("e",POLY_EXP);
|
||||
SetVar("e",2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427);
|
||||
insert("log",POLY_LOG);
|
||||
insert("ln",POLY_LN);
|
||||
insert("log10",POLY_LOG10);
|
||||
insert("abs",POLY_ABS);
|
||||
insert("mod",POLY_MOD);
|
||||
insert("floor",POLY_FLOOR);
|
||||
MathSymbolCount = STSize;
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
107
source-client/Srcs/Client/EterBase/Poly/Poly.h
Normal file
107
source-client/Srcs/Client/EterBase/Poly/Poly.h
Normal file
@ -0,0 +1,107 @@
|
||||
#ifndef __POLY_POLY_H__
|
||||
#define __POLY_POLY_H__
|
||||
|
||||
#include "SymTable.h"
|
||||
|
||||
#pragma warning ( push, 3 )
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
|
||||
#pragma warning ( pop )
|
||||
|
||||
#define POLY_MAXVALUE 0
|
||||
#define POLY_NONE POLY_MAXVALUE
|
||||
#define POLY_ROOT POLY_MAXVALUE + 1
|
||||
#define POLY_MUL POLY_MAXVALUE + 2
|
||||
#define POLY_PLU POLY_MAXVALUE + 3
|
||||
#define POLY_POW POLY_MAXVALUE + 4
|
||||
#define POLY_MIN POLY_MAXVALUE + 5
|
||||
#define POLY_DIV POLY_MAXVALUE + 6
|
||||
#define POLY_OPEN POLY_MAXVALUE + 7
|
||||
#define POLY_CLOSE POLY_MAXVALUE + 8
|
||||
#define POLY_NUM POLY_MAXVALUE + 9
|
||||
#define POLY_ID POLY_MAXVALUE + 10
|
||||
#define POLY_EOS POLY_MAXVALUE + 11
|
||||
#define POLY_COS POLY_MAXVALUE + 12
|
||||
#define POLY_SIN POLY_MAXVALUE + 13
|
||||
#define POLY_TAN POLY_MAXVALUE + 14
|
||||
#define POLY_COSEC POLY_MAXVALUE + 15
|
||||
#define POLY_CSC POLY_COSEC
|
||||
#define POLY_SEC POLY_MAXVALUE + 16
|
||||
#define POLY_COT POLY_MAXVALUE + 17
|
||||
#define POLY_PI POLY_ID
|
||||
#define POLY_EXP POLY_ID
|
||||
#define POLY_LOG POLY_MAXVALUE + 18
|
||||
#define POLY_LN POLY_MAXVALUE + 19
|
||||
#define POLY_LOG10 POLY_MAXVALUE + 20
|
||||
|
||||
#define POLY_ABS POLY_MAXVALUE + 21
|
||||
#define POLY_MINF POLY_MAXVALUE + 22
|
||||
#define POLY_MAXF POLY_MAXVALUE + 23
|
||||
#define POLY_IRAND POLY_MAXVALUE + 24
|
||||
#define POLY_FRAND POLY_MAXVALUE + 25
|
||||
#define POLY_MOD POLY_MAXVALUE + 26
|
||||
#define POLY_FLOOR POLY_MAXVALUE + 27
|
||||
|
||||
#define POLY_MAXSTACK 100
|
||||
|
||||
class CPoly
|
||||
{
|
||||
public:
|
||||
enum ERandomType
|
||||
{
|
||||
RANDOM_TYPE_FREELY,
|
||||
RANDOM_TYPE_FORCE_MIN,
|
||||
RANDOM_TYPE_FORCE_MAX,
|
||||
};
|
||||
|
||||
public:
|
||||
CPoly();
|
||||
virtual ~CPoly();
|
||||
|
||||
int Analyze(const char * pszStr = NULL);
|
||||
float Eval();
|
||||
void SetRandom(int iRandomType);
|
||||
void SetStr(const std::string & str);
|
||||
int SetVar(const std::string & strName, double dVar);
|
||||
int GetVarCount();
|
||||
const char * GetVarName(unsigned int dwIndex);
|
||||
void Clear();
|
||||
|
||||
protected:
|
||||
int my_irandom(double start, double end);
|
||||
double my_frandom(double start, double end);
|
||||
|
||||
void init();
|
||||
int insert(const std::string & s, int tok);
|
||||
int find(const std::string & s);
|
||||
void emit(int t,int tval);
|
||||
void match(int t);
|
||||
void expo();
|
||||
void factor();
|
||||
void term();
|
||||
int iToken;
|
||||
double iNumToken;
|
||||
int iLookAhead;
|
||||
int lexan();
|
||||
int iErrorPos;
|
||||
void error();
|
||||
void expr();
|
||||
bool ErrorOccur;
|
||||
unsigned int uiLookPos;
|
||||
|
||||
// NOTE: list is slight faster than vector, why?!
|
||||
std::vector<int> tokenBase;
|
||||
std::vector<double> numBase;
|
||||
std::vector<CSymTable *> lSymbol;
|
||||
std::vector<int> SymbolIndex;
|
||||
int STSize;
|
||||
int MathSymbolCount;
|
||||
std::string strData;
|
||||
int m_iRandomType;
|
||||
};
|
||||
|
||||
#endif
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
13
source-client/Srcs/Client/EterBase/Poly/SymTable.cpp
Normal file
13
source-client/Srcs/Client/EterBase/Poly/SymTable.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "StdAfx.h"
|
||||
#include "SymTable.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
CSymTable::CSymTable(int aTok, string aStr) : dVal(0), token(aTok), strlex(aStr)
|
||||
{
|
||||
}
|
||||
|
||||
CSymTable::~CSymTable()
|
||||
{
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
18
source-client/Srcs/Client/EterBase/Poly/SymTable.h
Normal file
18
source-client/Srcs/Client/EterBase/Poly/SymTable.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef __POLY_SYMTABLE_H__
|
||||
#define __POLY_SYMTABLE_H__
|
||||
|
||||
#include <string>
|
||||
|
||||
class CSymTable
|
||||
{
|
||||
public:
|
||||
CSymTable(int aTok, std::string aStr);
|
||||
virtual ~CSymTable();
|
||||
|
||||
double dVal;
|
||||
int token;
|
||||
std::string strlex;
|
||||
};
|
||||
|
||||
#endif
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
50
source-client/Srcs/Client/EterBase/Poly/Symbol.cpp
Normal file
50
source-client/Srcs/Client/EterBase/Poly/Symbol.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
#include "StdAfx.h"
|
||||
#include "Symbol.h"
|
||||
|
||||
CSymbol::CSymbol()
|
||||
{
|
||||
id = MID_SYMBOL;
|
||||
iType = ST_UNKNOWN;
|
||||
}
|
||||
|
||||
CSymbol::~CSymbol()
|
||||
{
|
||||
}
|
||||
|
||||
bool CSymbol::Equal(CSymbol dif)
|
||||
{
|
||||
if (dif.iType/10 == iType/10) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CSymbol::Less(CSymbol dif)
|
||||
{
|
||||
if (dif.iType/10 > iType/10) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
int CSymbol::GetType()
|
||||
{
|
||||
return iType;
|
||||
}
|
||||
|
||||
void CSymbol::SetType(int Type)
|
||||
{
|
||||
iType=Type;
|
||||
}
|
||||
|
||||
int CSymbol::issymbol(int ch)
|
||||
{
|
||||
switch(ch)
|
||||
{
|
||||
case SY_PLUS : return ST_PLUS;
|
||||
case SY_MINUS : return ST_MINUS;
|
||||
case SY_MULTIPLY: return ST_MULTIPLY;
|
||||
case SY_DIVIDE : return SY_DIVIDE;
|
||||
case SY_CARET : return SY_CARET;
|
||||
case SY_OPEN : return SY_OPEN;
|
||||
case SY_CLOSE : return ST_CLOSE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
40
source-client/Srcs/Client/EterBase/Poly/Symbol.h
Normal file
40
source-client/Srcs/Client/EterBase/Poly/Symbol.h
Normal file
@ -0,0 +1,40 @@
|
||||
#ifndef __POLY_SYMBOL_H__
|
||||
#define __POLY_SYMBOL_H__
|
||||
|
||||
#include "Base.h"
|
||||
|
||||
#define ST_UNKNOWN 0
|
||||
#define ST_PLUS 11
|
||||
#define ST_MINUS 12
|
||||
#define ST_MULTIPLY 23
|
||||
#define ST_DIVIDE 24
|
||||
#define ST_CARET 35
|
||||
#define ST_OPEN 06
|
||||
#define ST_CLOSE 07
|
||||
|
||||
#define SY_PLUS '+'
|
||||
#define SY_MINUS '-'
|
||||
#define SY_MULTIPLY '*'
|
||||
#define SY_DIVIDE '/'
|
||||
#define SY_CARET '^'
|
||||
#define SY_OPEN '('
|
||||
#define SY_CLOSE ')'
|
||||
|
||||
class CSymbol : public CBase
|
||||
{
|
||||
private:
|
||||
int iType;
|
||||
|
||||
public:
|
||||
CSymbol();
|
||||
virtual ~CSymbol();
|
||||
|
||||
static int issymbol(int ch);
|
||||
void SetType(int Type);
|
||||
int GetType();
|
||||
bool Equal(CSymbol dif);
|
||||
bool Less(CSymbol dif);
|
||||
};
|
||||
|
||||
#endif
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
3
source-client/Srcs/Client/EterBase/Poly/stdafx.h
Normal file
3
source-client/Srcs/Client/EterBase/Poly/stdafx.h
Normal file
@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
#include "..\StdAfx.h"
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
48
source-client/Srcs/Client/EterBase/Random.cpp
Normal file
48
source-client/Srcs/Client/EterBase/Random.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
static unsigned long randseed = 1;
|
||||
|
||||
void srandom(unsigned long seed)
|
||||
{
|
||||
randseed = seed;
|
||||
}
|
||||
|
||||
/*
|
||||
* Pseudo-random number generator for randomizing the profiling clock,
|
||||
* and whatever else we might use it for. The result is uniform on
|
||||
* [0, 2^31 - 1].
|
||||
*/
|
||||
unsigned long random()
|
||||
{
|
||||
register long x, hi, lo, t;
|
||||
|
||||
/*
|
||||
* Compute x[n + 1] = (7^5 * x[n]) mod (2^31 - 1).
|
||||
* From "Random number generators: good ones are hard to find",
|
||||
* Park and Miller, Communications of the ACM, vol. 31, no. 10,
|
||||
* October 1988, p. 1195.
|
||||
*/
|
||||
x = randseed;
|
||||
hi = x / 127773;
|
||||
lo = x % 127773;
|
||||
t = 16807 * lo - 2836 * hi;
|
||||
if (t <= 0)
|
||||
t += 0x7fffffff;
|
||||
randseed = t;
|
||||
return (t);
|
||||
}
|
||||
|
||||
float frandom(float flLow, float flHigh)
|
||||
{
|
||||
float fl = float(random()) / float(2147483648.0f); // float in [0,1)
|
||||
return (fl * (flHigh - flLow)) + flLow; // float in [low,high)
|
||||
}
|
||||
|
||||
long random_range(long from, long to)
|
||||
{
|
||||
assert(from <= to);
|
||||
return ((random() % (to - from + 1)) + from);
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
10
source-client/Srcs/Client/EterBase/Random.h
Normal file
10
source-client/Srcs/Client/EterBase/Random.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef __INC_ETERBASE_RANDOM_H__
|
||||
#define __INC_ETERBASE_RANDOM_H__
|
||||
|
||||
extern void srandom(unsigned long seed);
|
||||
extern unsigned long random();
|
||||
extern float frandom(float flLow, float flHigh);
|
||||
extern long random_range(long from, long to);
|
||||
|
||||
#endif
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
8
source-client/Srcs/Client/EterBase/ServiceDefs.h
Normal file
8
source-client/Srcs/Client/EterBase/ServiceDefs.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef _EL_SERVICEDEFS_H_
|
||||
#define _EL_SERVICEDEFS_H_
|
||||
|
||||
#define _IMPROVED_PACKET_ENCRYPTION_
|
||||
//#define __PERFORMANCE_CHECK__
|
||||
|
||||
#endif //_EL_SERVICEDEFS_H_
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
86
source-client/Srcs/Client/EterBase/Singleton.h
Normal file
86
source-client/Srcs/Client/EterBase/Singleton.h
Normal file
@ -0,0 +1,86 @@
|
||||
#ifndef __INC_ETERLIB_SINGLETON_H__
|
||||
#define __INC_ETERLIB_SINGLETON_H__
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
template <typename T> class CSingleton
|
||||
{
|
||||
static T * ms_singleton;
|
||||
|
||||
public:
|
||||
CSingleton()
|
||||
{
|
||||
assert(!ms_singleton);
|
||||
int offset = (int) (T*) 1 - (int) (CSingleton <T>*) (T*) 1;
|
||||
ms_singleton = (T*) ((int) this + offset);
|
||||
}
|
||||
|
||||
virtual ~CSingleton()
|
||||
{
|
||||
assert(ms_singleton);
|
||||
ms_singleton = 0;
|
||||
}
|
||||
|
||||
__forceinline static T & Instance()
|
||||
{
|
||||
assert(ms_singleton);
|
||||
return (*ms_singleton);
|
||||
}
|
||||
|
||||
__forceinline static T * InstancePtr()
|
||||
{
|
||||
return (ms_singleton);
|
||||
}
|
||||
|
||||
__forceinline static T & instance()
|
||||
{
|
||||
assert(ms_singleton);
|
||||
return (*ms_singleton);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T> T * CSingleton <T>::ms_singleton = 0;
|
||||
|
||||
//
|
||||
// singleton for non-hungarian
|
||||
//
|
||||
template <typename T> class singleton
|
||||
{
|
||||
static T * ms_singleton;
|
||||
|
||||
public:
|
||||
singleton()
|
||||
{
|
||||
assert(!ms_singleton);
|
||||
int offset = (int) (T*) 1 - (int) (singleton <T>*) (T*) 1;
|
||||
ms_singleton = (T*) ((int) this + offset);
|
||||
}
|
||||
|
||||
virtual ~singleton()
|
||||
{
|
||||
assert(ms_singleton);
|
||||
ms_singleton = 0;
|
||||
}
|
||||
|
||||
__forceinline static T & Instance()
|
||||
{
|
||||
assert(ms_singleton);
|
||||
return (*ms_singleton);
|
||||
}
|
||||
|
||||
__forceinline static T * InstancePtr()
|
||||
{
|
||||
return (ms_singleton);
|
||||
}
|
||||
|
||||
__forceinline static T & instance()
|
||||
{
|
||||
assert(ms_singleton);
|
||||
return (*ms_singleton);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T> T * singleton <T>::ms_singleton = 0;
|
||||
|
||||
#endif
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
7
source-client/Srcs/Client/EterBase/StdAfx.cpp
Normal file
7
source-client/Srcs/Client/EterBase/StdAfx.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// eterBase.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
namespace { char dummy; }; // solve warning lnk4221
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
51
source-client/Srcs/Client/EterBase/StdAfx.h
Normal file
51
source-client/Srcs/Client/EterBase/StdAfx.h
Normal file
@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#pragma warning(disable: 4100 4127 4189 4231 4505 4512 4706) // cryptopp
|
||||
#pragma warning(disable:4995) // pragma deprecated
|
||||
#pragma warning(disable:4710) // not inlined
|
||||
#pragma warning(disable:4786)
|
||||
#pragma warning(disable:4244) // type conversion possible lose of data
|
||||
#pragma warning(disable:5033) // cpp17 deprecated warnings
|
||||
|
||||
#include "../UserInterface/Locale_inc.h"
|
||||
#include <windows.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#pragma warning ( disable : 4201 )
|
||||
#include <mmsystem.h>
|
||||
#pragma warning ( default : 4201 )
|
||||
#include <imagehlp.h>
|
||||
#include <time.h>
|
||||
|
||||
#pragma warning ( push, 3 )
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
#pragma warning ( pop )
|
||||
|
||||
#if _MSC_VER >= 1400
|
||||
#define stricmp _stricmp
|
||||
#define strnicmp _strnicmp
|
||||
#define strupt _strupr
|
||||
#define strcmpi _strcmpi
|
||||
#define fileno _fileno
|
||||
//#define access _access_s
|
||||
//#define _access _access_s
|
||||
#define atoi _atoi64
|
||||
#endif
|
||||
|
||||
#include "vk.h"
|
||||
#include "filename.h"
|
||||
#include "Stl.h"
|
||||
#include "ServiceDefs.h"
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
93
source-client/Srcs/Client/EterBase/Stl.cpp
Normal file
93
source-client/Srcs/Client/EterBase/Stl.cpp
Normal file
@ -0,0 +1,93 @@
|
||||
#include "StdAfx.h"
|
||||
#include "stl.h"
|
||||
|
||||
static std::list<std::string> s_stList;
|
||||
|
||||
char korean_tolower(const char c)
|
||||
{
|
||||
char ret = c;
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
ret = c - 'A' + 'a';
|
||||
|
||||
assert(ret == tolower(c));
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string& stl_static_string(const char * c_sz)
|
||||
{
|
||||
std::string str;
|
||||
str.assign(c_sz);
|
||||
|
||||
s_stList.push_back(str);
|
||||
return s_stList.back();
|
||||
}
|
||||
|
||||
void stl_lowers(std::string& rstRet)
|
||||
{
|
||||
for (size_t i = 0; i < rstRet.length(); ++i)
|
||||
rstRet[i] = korean_tolower(rstRet[i]);
|
||||
}
|
||||
|
||||
int split_string(const string& input, const string& delimiter, std::vector<string>& results, bool includeEmpties)
|
||||
{
|
||||
int iPos = 0;
|
||||
int newPos = -1;
|
||||
UINT sizeS2 = delimiter.size();
|
||||
UINT isize = input.size();
|
||||
|
||||
if ((isize == 0) || (sizeS2 == 0))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::vector<int> positions;
|
||||
|
||||
newPos = input.find(delimiter, 0);
|
||||
|
||||
if (newPos < 0)
|
||||
return 0;
|
||||
|
||||
int numFound = 0;
|
||||
|
||||
while (newPos >= iPos)
|
||||
{
|
||||
numFound++;
|
||||
positions.push_back(newPos);
|
||||
iPos = newPos;
|
||||
newPos = input.find(delimiter, iPos+sizeS2);
|
||||
}
|
||||
|
||||
if (numFound == 0)
|
||||
return 0;
|
||||
|
||||
for (UINT i = 0; i <= positions.size(); ++i)
|
||||
{
|
||||
string s("");
|
||||
if (i == 0)
|
||||
{
|
||||
s = input.substr(i, positions[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
UINT offset = positions[i-1] + sizeS2;
|
||||
|
||||
if (offset < isize)
|
||||
{
|
||||
if (i == positions.size())
|
||||
{
|
||||
s = input.substr(offset);
|
||||
}
|
||||
else if (i > 0)
|
||||
{
|
||||
s = input.substr(positions[i-1] + sizeS2, positions[i] - positions[i-1] - sizeS2);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (includeEmpties || (s.size() > 0))
|
||||
{
|
||||
results.push_back(s);
|
||||
}
|
||||
}
|
||||
return numFound;
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
470
source-client/Srcs/Client/EterBase/Stl.h
Normal file
470
source-client/Srcs/Client/EterBase/Stl.h
Normal file
@ -0,0 +1,470 @@
|
||||
#ifndef __INC_ETERBASE_STL_H__
|
||||
#define __INC_ETERBASE_STL_H__
|
||||
|
||||
#pragma warning(disable:4786) // identifier was truncated to '255' characters in the browser information
|
||||
#pragma warning(disable:4018) // signed <-> unsigned mismatch
|
||||
#pragma warning(disable:4503) // decorated name length exceeded, name was truncated
|
||||
#pragma warning(disable:4018) // '<' : signed/unsigned mismatch
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#pragma warning ( push, 3 )
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stack>
|
||||
#include <deque>
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <queue>
|
||||
#include <functional>
|
||||
#include <SSTREAM>
|
||||
|
||||
#pragma warning ( pop )
|
||||
|
||||
extern char korean_tolower(const char c);
|
||||
extern std::string& stl_static_string(const char* c_sz);
|
||||
extern void stl_lowers(std::string& rstRet);
|
||||
extern int split_string(const std::string & input, const std::string & delimiter, std::vector<std::string>& results, bool includeEmpties);
|
||||
|
||||
namespace utils
|
||||
{
|
||||
template <typename T> struct IsContiguous {
|
||||
static bool constexpr value = false;
|
||||
};
|
||||
|
||||
template <typename... Args>
|
||||
struct IsContiguous<std::vector<Args...>> {
|
||||
static bool constexpr value = true;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct IsContiguous<std::string> {
|
||||
static bool constexpr value = true;
|
||||
};
|
||||
|
||||
template <typename... Args>
|
||||
struct IsContiguous<std::array<Args...>> {
|
||||
static bool constexpr value = true;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
constexpr bool IsContiguousV = IsContiguous<T>::value;
|
||||
|
||||
/////////////////////
|
||||
template<typename T>
|
||||
constexpr bool IsRawV = !std::is_pointer_v<T> && std::is_trivially_copyable_v<T> && !IsContiguousV<T>;
|
||||
};
|
||||
|
||||
namespace std
|
||||
{
|
||||
#if _HAS_CXX17
|
||||
// FUNCTIONAL STUFF (from <functional>)
|
||||
// STRUCT TEMPLATE unary_function
|
||||
template <class _Arg, class _Result> struct unary_function
|
||||
{ // base class for unary functions
|
||||
typedef _Arg argument_type;
|
||||
typedef _Result result_type;
|
||||
};
|
||||
|
||||
// STRUCT TEMPLATE binary_function
|
||||
template <class _Arg1, class _Arg2, class _Result> struct binary_function
|
||||
{ // base class for binary functions
|
||||
typedef _Arg1 first_argument_type;
|
||||
typedef _Arg2 second_argument_type;
|
||||
typedef _Result result_type;
|
||||
};
|
||||
#endif /* _HAS_AUTO_PTR_ETC */
|
||||
|
||||
template <class _Ty>
|
||||
class void_mem_fun_t
|
||||
: public unary_function<_Ty *, void> {
|
||||
public:
|
||||
explicit void_mem_fun_t(void (_Ty::*_Pm)())
|
||||
: _Ptr(_Pm) {}
|
||||
void operator()(_Ty *_P) const
|
||||
{((_P->*_Ptr)()); }
|
||||
private:
|
||||
void (_Ty::*_Ptr)();
|
||||
};
|
||||
template<class _Ty> inline
|
||||
void_mem_fun_t<_Ty> void_mem_fun(void (_Ty::*_Pm)())
|
||||
{return (void_mem_fun_t<_Ty>(_Pm)); }
|
||||
|
||||
template<class _Ty>
|
||||
class void_mem_fun_ref_t : public unary_function<_Ty, void> {
|
||||
public:
|
||||
explicit void_mem_fun_ref_t(void (_Ty::*_Pm)())
|
||||
: _Ptr(_Pm) {}
|
||||
void operator()(_Ty& _X) const
|
||||
{return ((_X.*_Ptr)()); }
|
||||
private:
|
||||
void (_Ty::*_Ptr)();
|
||||
};
|
||||
|
||||
template<class _Ty> inline
|
||||
void_mem_fun_ref_t<_Ty> void_mem_fun_ref(void (_Ty::*_Pm)())
|
||||
{return (void_mem_fun_ref_t< _Ty>(_Pm)); }
|
||||
|
||||
// TEMPLATE CLASS mem_fun1_t
|
||||
template<class _R, class _Ty, class _A>
|
||||
class void_mem_fun1_t : public binary_function<_Ty *, _A, _R> {
|
||||
public:
|
||||
explicit void_mem_fun1_t(_R (_Ty::*_Pm)(_A))
|
||||
: _Ptr(_Pm) {}
|
||||
_R operator()(_Ty *_P, _A _Arg) const
|
||||
{return ((_P->*_Ptr)(_Arg)); }
|
||||
private:
|
||||
_R (_Ty::*_Ptr)(_A);
|
||||
};
|
||||
// TEMPLATE FUNCTION mem_fun1
|
||||
template<class _R, class _Ty, class _A> inline
|
||||
void_mem_fun1_t<_R, _Ty, _A> void_mem_fun1(_R (_Ty::*_Pm)(_A))
|
||||
{return (void_mem_fun1_t<_R, _Ty, _A>(_Pm)); }
|
||||
}
|
||||
|
||||
struct stl_sz_less
|
||||
{
|
||||
bool operator() (char * const & left, char * const & right) const
|
||||
{
|
||||
return (strcmp(left, right) < 0);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename TContainer>
|
||||
inline void stl_wipe(TContainer& container)
|
||||
{
|
||||
for (auto i = container.begin(); i != container.end(); ++i)
|
||||
{
|
||||
delete *i;
|
||||
*i = NULL;
|
||||
}
|
||||
|
||||
container.clear();
|
||||
}
|
||||
|
||||
template<typename TString>
|
||||
inline int hex2dec(TString szhex)
|
||||
{
|
||||
int hex0 = toupper(szhex[0]);
|
||||
int hex1 = toupper(szhex[1]);
|
||||
|
||||
return (hex1 >= 'A' ? hex1 - 'A' + 10 : hex1 - '0') +
|
||||
(hex0 >= 'A' ? hex0 - 'A' + 10 : hex0 - '0') * 16;
|
||||
}
|
||||
|
||||
template<typename TString>
|
||||
inline unsigned long htmlColorStringToARGB(TString str)
|
||||
{
|
||||
unsigned long alp = hex2dec(str);
|
||||
unsigned long red = hex2dec(str + 2);
|
||||
unsigned long green = hex2dec(str + 4);
|
||||
unsigned long blue = hex2dec(str + 6);
|
||||
return (alp << 24 | red << 16 | green << 8 | blue);
|
||||
}
|
||||
|
||||
template<typename TContainer>
|
||||
inline void stl_wipe_second(TContainer& container)
|
||||
{
|
||||
for (auto i = container.begin(); i != container.end(); ++i)
|
||||
{
|
||||
delete i->second;
|
||||
}
|
||||
|
||||
container.clear();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void safe_release(T& rpObject)
|
||||
{
|
||||
if (!rpObject)
|
||||
return;
|
||||
|
||||
rpObject->Release();
|
||||
rpObject = NULL;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void DeleteVectorItem(std::vector<T> * pVector, unsigned long dwIndex)
|
||||
{
|
||||
if (dwIndex >= pVector->size())
|
||||
{
|
||||
assert(!"Wrong index to delete!");
|
||||
return;
|
||||
}
|
||||
if (1 == pVector->size())
|
||||
{
|
||||
pVector->clear();
|
||||
return;
|
||||
}
|
||||
|
||||
auto itor = pVector->begin();
|
||||
for (unsigned long i = 0; i < dwIndex; ++i)
|
||||
++itor;
|
||||
|
||||
pVector->erase(itor);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void DeleteVectorItem(T * pVector, unsigned long dwStartIndex, unsigned long dwEndIndex)
|
||||
{
|
||||
if (dwStartIndex >= pVector->size())
|
||||
{
|
||||
assert(!"Wrong start index to delete!");
|
||||
return;
|
||||
}
|
||||
if (dwEndIndex >= pVector->size())
|
||||
{
|
||||
assert(!"Wrong end index to delete!");
|
||||
return;
|
||||
}
|
||||
|
||||
auto itorStart = pVector->begin();
|
||||
for (unsigned long i = 0; i < dwStartIndex; ++i)
|
||||
++itorStart;
|
||||
auto itorEnd = pVector->begin();
|
||||
for (unsigned long j = 0; j < dwEndIndex; ++j)
|
||||
++itorEnd;
|
||||
|
||||
pVector->erase(itorStart, itorEnd);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void DeleteVectorItem(std::vector<T> * pVector, T pItem)
|
||||
{
|
||||
auto itor = pVector->begin();
|
||||
for (; itor != pVector->end(); ++itor)
|
||||
{
|
||||
if (pItem == *itor)
|
||||
{
|
||||
if (1 == pVector->size())
|
||||
{
|
||||
pVector->clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
pVector->erase(itor);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void DeleteListItem(std::list<T> * pList, T pItem)
|
||||
{
|
||||
auto itor = pList->begin();
|
||||
for (; itor != pList->end(); ++itor)
|
||||
{
|
||||
if (pItem == *itor)
|
||||
{
|
||||
if (1 == pList->size())
|
||||
{
|
||||
pList->clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
pList->erase(itor);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T, typename F>
|
||||
void stl_vector_qsort(std::vector<T>& rdataVector, F comp)
|
||||
{
|
||||
if (rdataVector.empty()) return;
|
||||
qsort(&rdataVector[0], rdataVector.size(), sizeof(T), comp);
|
||||
}
|
||||
|
||||
template<typename TData>
|
||||
class stl_stack_pool
|
||||
{
|
||||
public:
|
||||
stl_stack_pool()
|
||||
{
|
||||
m_pos = 0;
|
||||
}
|
||||
|
||||
stl_stack_pool(int capacity)
|
||||
{
|
||||
m_pos = 0;
|
||||
initialize(capacity);
|
||||
}
|
||||
|
||||
virtual ~stl_stack_pool()
|
||||
{
|
||||
}
|
||||
|
||||
void initialize(int capacity)
|
||||
{
|
||||
m_dataVector.clear();
|
||||
m_dataVector.resize(capacity);
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
m_pos = 0;
|
||||
}
|
||||
|
||||
TData * alloc()
|
||||
{
|
||||
assert(!m_dataVector.empty() && "stl_stack_pool::alloc you MUST run stl_stack_pool::initialize");
|
||||
|
||||
int max = m_dataVector.size();
|
||||
|
||||
if (m_pos >= max)
|
||||
{
|
||||
assert(!"stl_stack_pool::alloc OUT of memory");
|
||||
m_pos = 0;
|
||||
}
|
||||
|
||||
return &m_dataVector[m_pos++];
|
||||
}
|
||||
|
||||
TData* base()
|
||||
{
|
||||
return &m_dataVector[0];
|
||||
}
|
||||
|
||||
int size()
|
||||
{
|
||||
return m_pos;
|
||||
}
|
||||
|
||||
private:
|
||||
int m_pos;
|
||||
|
||||
std::vector<TData> m_dataVector;
|
||||
};
|
||||
|
||||
template<typename TData, typename THandle=int>
|
||||
class stl_circle_pool
|
||||
{
|
||||
public:
|
||||
typedef bool TFlag;
|
||||
|
||||
public:
|
||||
stl_circle_pool()
|
||||
{
|
||||
initialize();
|
||||
}
|
||||
virtual ~stl_circle_pool()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
void destroy()
|
||||
{
|
||||
if (m_datas)
|
||||
{
|
||||
delete [] m_datas;
|
||||
m_datas=NULL;
|
||||
}
|
||||
if (m_flags)
|
||||
{
|
||||
delete [] m_flags;
|
||||
m_flags=NULL;
|
||||
}
|
||||
}
|
||||
void create(int size)
|
||||
{
|
||||
destroy();
|
||||
|
||||
initialize();
|
||||
|
||||
m_size=size;
|
||||
m_datas=new TData[m_size];
|
||||
m_flags=new TFlag[m_size];
|
||||
|
||||
for (int i=0; i<m_size; ++i)
|
||||
m_flags[i]=false;
|
||||
}
|
||||
THandle alloc()
|
||||
{
|
||||
THandle max=m_size;
|
||||
|
||||
THandle loop=max;
|
||||
while (loop--)
|
||||
{
|
||||
int cur=m_pos%max;++m_pos;
|
||||
if (!m_flags[cur])
|
||||
{
|
||||
m_flags[cur]=true;
|
||||
return cur;
|
||||
}
|
||||
}
|
||||
|
||||
assert(!"Out of Memory");
|
||||
|
||||
return 0;
|
||||
}
|
||||
void free(THandle handle)
|
||||
{
|
||||
assert(check(handle) && "Out of RANGE");
|
||||
m_flags[handle]=false;
|
||||
}
|
||||
inline bool check(THandle handle)
|
||||
{
|
||||
if (handle>=m_size) return false;
|
||||
return true;
|
||||
}
|
||||
inline int size()
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
inline TData& refer(THandle handle)
|
||||
{
|
||||
assert(check(handle) && "Out of RANGE");
|
||||
return m_datas[handle];
|
||||
}
|
||||
|
||||
protected:
|
||||
void initialize()
|
||||
{
|
||||
m_datas=NULL;
|
||||
m_flags=NULL;
|
||||
m_pos=0;
|
||||
m_size=0;
|
||||
}
|
||||
|
||||
protected:
|
||||
TData* m_datas;
|
||||
TFlag* m_flags;
|
||||
|
||||
THandle m_size;
|
||||
|
||||
THandle m_pos;
|
||||
};
|
||||
|
||||
typedef std::vector<std::string> CTokenVector;
|
||||
typedef std::map<std::string, std::string> CTokenMap;
|
||||
typedef std::map<std::string, CTokenVector> CTokenVectorMap;
|
||||
|
||||
struct stringhash
|
||||
{
|
||||
size_t GetHash(const std::string & str) const
|
||||
{
|
||||
const unsigned char * s = (const unsigned char*) str.c_str();
|
||||
const unsigned char * end = s + str.size();
|
||||
size_t h = 0;
|
||||
|
||||
while (s < end)
|
||||
{
|
||||
h *= 16777619;
|
||||
h ^= (unsigned char) *(unsigned char *) (s++);
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
size_t operator () (const std::string & str) const
|
||||
{
|
||||
return GetHash(str);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
22
source-client/Srcs/Client/EterBase/TempFile.cpp
Normal file
22
source-client/Srcs/Client/EterBase/TempFile.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include "StdAfx.h"
|
||||
#include "TempFile.h"
|
||||
#include "Utils.h"
|
||||
#include "Debug.h"
|
||||
|
||||
CTempFile::~CTempFile()
|
||||
{
|
||||
Destroy();
|
||||
DeleteFile(m_szFileName);
|
||||
}
|
||||
|
||||
CTempFile::CTempFile(const char * c_pszPrefix)
|
||||
{
|
||||
strncpy(m_szFileName, CreateTempFileName(c_pszPrefix), MAX_PATH);
|
||||
|
||||
if (!Create(m_szFileName, CFileBase::FILEMODE_WRITE))
|
||||
{
|
||||
TraceError("CTempFile::CTempFile cannot create temporary file. (filename: %s)", m_szFileName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
17
source-client/Srcs/Client/EterBase/TempFile.h
Normal file
17
source-client/Srcs/Client/EterBase/TempFile.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef __INC_ETERBASE_TEMPFILE_H__
|
||||
#define __INC_ETERBASE_TEMPFILE_H__
|
||||
|
||||
#include "FileBase.h"
|
||||
|
||||
class CTempFile : public CFileBase
|
||||
{
|
||||
public:
|
||||
CTempFile(const char * c_pszPrefix = NULL);
|
||||
virtual ~CTempFile();
|
||||
|
||||
protected:
|
||||
char m_szFileName[MAX_PATH+1];
|
||||
};
|
||||
|
||||
#endif
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
139
source-client/Srcs/Client/EterBase/Timer.cpp
Normal file
139
source-client/Srcs/Client/EterBase/Timer.cpp
Normal file
@ -0,0 +1,139 @@
|
||||
#include "StdAfx.h"
|
||||
#include "Timer.h"
|
||||
|
||||
static LARGE_INTEGER gs_liTickCountPerSec;
|
||||
static DWORD gs_dwBaseTime=0;
|
||||
static DWORD gs_dwServerTime=0;
|
||||
static DWORD gs_dwClientTime=0;
|
||||
static DWORD gs_dwFrameTime=0;
|
||||
|
||||
#pragma comment(lib, "winmm.lib")
|
||||
|
||||
BOOL ELTimer_Init()
|
||||
{
|
||||
gs_dwBaseTime = timeGetTime();
|
||||
return 1;
|
||||
}
|
||||
|
||||
DWORD ELTimer_GetMSec()
|
||||
{
|
||||
return timeGetTime() - gs_dwBaseTime;
|
||||
}
|
||||
|
||||
VOID ELTimer_SetServerMSec(DWORD dwServerTime)
|
||||
{
|
||||
if (0 != dwServerTime)
|
||||
{
|
||||
gs_dwServerTime = dwServerTime;
|
||||
gs_dwClientTime = CTimer::instance().GetCurrentMillisecond();
|
||||
}
|
||||
}
|
||||
|
||||
DWORD ELTimer_GetServerMSec()
|
||||
{
|
||||
return CTimer::instance().GetCurrentMillisecond() - gs_dwClientTime + gs_dwServerTime;
|
||||
}
|
||||
|
||||
DWORD ELTimer_GetFrameMSec()
|
||||
{
|
||||
return gs_dwFrameTime;
|
||||
}
|
||||
|
||||
DWORD ELTimer_GetServerFrameMSec()
|
||||
{
|
||||
return ELTimer_GetFrameMSec() - gs_dwClientTime + gs_dwServerTime;
|
||||
}
|
||||
|
||||
VOID ELTimer_SetFrameMSec()
|
||||
{
|
||||
gs_dwFrameTime = ELTimer_GetMSec();
|
||||
}
|
||||
|
||||
CTimer::CTimer()
|
||||
{
|
||||
ELTimer_Init();
|
||||
|
||||
if (this)
|
||||
{
|
||||
m_dwCurrentTime = 0;
|
||||
m_bUseRealTime = true;
|
||||
m_index = 0;
|
||||
|
||||
m_dwElapsedTime = 0;
|
||||
|
||||
m_fCurrentTime = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
CTimer::~CTimer()
|
||||
{
|
||||
}
|
||||
|
||||
void CTimer::SetBaseTime()
|
||||
{
|
||||
m_dwCurrentTime = 0;
|
||||
}
|
||||
|
||||
void CTimer::Advance()
|
||||
{
|
||||
if (!m_bUseRealTime)
|
||||
{
|
||||
++m_index;
|
||||
|
||||
if (m_index == 1)
|
||||
m_index = -1;
|
||||
|
||||
m_dwCurrentTime += 16 + (m_index & 1);
|
||||
m_fCurrentTime = m_dwCurrentTime / 1000.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD currentTime = ELTimer_GetMSec();
|
||||
|
||||
if (m_dwCurrentTime == 0)
|
||||
m_dwCurrentTime = currentTime;
|
||||
|
||||
m_dwElapsedTime = currentTime - m_dwCurrentTime;
|
||||
m_dwCurrentTime = currentTime;
|
||||
}
|
||||
}
|
||||
|
||||
void CTimer::Adjust(int iTimeGap)
|
||||
{
|
||||
m_dwCurrentTime += iTimeGap;
|
||||
}
|
||||
|
||||
float CTimer::GetCurrentSecond()
|
||||
{
|
||||
if (m_bUseRealTime)
|
||||
return ELTimer_GetMSec() / 1000.0f;
|
||||
|
||||
return m_fCurrentTime;
|
||||
}
|
||||
|
||||
DWORD CTimer::GetCurrentMillisecond()
|
||||
{
|
||||
if (m_bUseRealTime)
|
||||
return ELTimer_GetMSec();
|
||||
|
||||
return m_dwCurrentTime;
|
||||
}
|
||||
|
||||
float CTimer::GetElapsedSecond()
|
||||
{
|
||||
return GetElapsedMilliecond() / 1000.0f;
|
||||
}
|
||||
|
||||
DWORD CTimer::GetElapsedMilliecond()
|
||||
{
|
||||
if (!m_bUseRealTime)
|
||||
return 16 + (m_index & 1);
|
||||
|
||||
return m_dwElapsedTime;
|
||||
}
|
||||
|
||||
void CTimer::UseCustomTime()
|
||||
{
|
||||
m_bUseRealTime = false;
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
42
source-client/Srcs/Client/EterBase/Timer.h
Normal file
42
source-client/Srcs/Client/EterBase/Timer.h
Normal file
@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
#include "Singleton.h"
|
||||
|
||||
class CTimer : public CSingleton<CTimer>
|
||||
{
|
||||
public:
|
||||
CTimer();
|
||||
virtual ~CTimer();
|
||||
|
||||
void Advance();
|
||||
void Adjust(int iTimeGap);
|
||||
void SetBaseTime();
|
||||
|
||||
float GetCurrentSecond();
|
||||
DWORD GetCurrentMillisecond();
|
||||
|
||||
float GetElapsedSecond();
|
||||
DWORD GetElapsedMilliecond();
|
||||
|
||||
void UseCustomTime();
|
||||
|
||||
protected:
|
||||
bool m_bUseRealTime;
|
||||
DWORD m_dwBaseTime;
|
||||
DWORD m_dwCurrentTime;
|
||||
float m_fCurrentTime;
|
||||
DWORD m_dwElapsedTime;
|
||||
int m_index;
|
||||
};
|
||||
|
||||
BOOL ELTimer_Init();
|
||||
|
||||
DWORD ELTimer_GetMSec();
|
||||
|
||||
VOID ELTimer_SetServerMSec(DWORD dwServerTime);
|
||||
DWORD ELTimer_GetServerMSec();
|
||||
|
||||
VOID ELTimer_SetFrameMSec();
|
||||
DWORD ELTimer_GetFrameMSec();
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
677
source-client/Srcs/Client/EterBase/Utils.cpp
Normal file
677
source-client/Srcs/Client/EterBase/Utils.cpp
Normal file
@ -0,0 +1,677 @@
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <direct.h>
|
||||
#include <io.h>
|
||||
#include <assert.h>
|
||||
#include <sys/stat.h>
|
||||
#include "Utils.h"
|
||||
#include "filedir.h"
|
||||
|
||||
char korean_tolower(const char c);
|
||||
|
||||
const char * CreateTempFileName(const char * c_pszPrefix)
|
||||
{
|
||||
char szTempPath[MAX_PATH + 1];
|
||||
static char szTempName[MAX_PATH + 1];
|
||||
|
||||
GetTempPath(MAX_PATH, szTempPath);
|
||||
|
||||
GetTempFileName(szTempPath, // directory for temp files
|
||||
c_pszPrefix ? c_pszPrefix : "etb", // temp file name prefix
|
||||
c_pszPrefix ? true : false, // create unique name
|
||||
szTempName); // buffer for name
|
||||
|
||||
return (szTempName);
|
||||
}
|
||||
|
||||
void GetFilePathNameExtension(const char * c_szFile, int len, std::string * pstPath, std::string * pstName, std::string * pstExt)
|
||||
{
|
||||
assert(pstPath != NULL);
|
||||
assert(pstName != NULL);
|
||||
assert(pstExt != NULL);
|
||||
|
||||
int ext = len;
|
||||
int pos = len;
|
||||
|
||||
while (pos > 0)
|
||||
{
|
||||
--pos;
|
||||
char c = c_szFile[pos];
|
||||
|
||||
if (ext == len && c == '.')
|
||||
{
|
||||
ext = pos;
|
||||
break;
|
||||
}
|
||||
|
||||
if (c == '/' || c == '\\')
|
||||
break;
|
||||
}
|
||||
|
||||
while (pos > 0)
|
||||
{
|
||||
--pos;
|
||||
char c = c_szFile[pos];
|
||||
|
||||
if (c == '/' || c == '\\')
|
||||
break;
|
||||
}
|
||||
|
||||
if (pos)
|
||||
{
|
||||
++pos;
|
||||
pstPath->append(c_szFile, pos);
|
||||
}
|
||||
|
||||
if (ext > pos)
|
||||
pstName->append(c_szFile + pos, ext - pos);
|
||||
|
||||
++ext;
|
||||
|
||||
if (len > ext)
|
||||
pstExt->append(c_szFile + ext, len - ext);
|
||||
}
|
||||
|
||||
void GetFileExtension(const char* c_szFile, int len, std::string* pstExt)
|
||||
{
|
||||
int ext = len;
|
||||
int pos = len;
|
||||
while (pos > 0)
|
||||
{
|
||||
--pos;
|
||||
char c=c_szFile[pos];
|
||||
if (ext==len && c=='.')
|
||||
{
|
||||
ext=pos;
|
||||
break;
|
||||
}
|
||||
|
||||
if (c=='/') break;
|
||||
else if (c=='\\') break;
|
||||
}
|
||||
|
||||
++ext;
|
||||
if (len>ext)
|
||||
pstExt->append(c_szFile+ext, len-ext);
|
||||
}
|
||||
|
||||
void GetFileNameParts(const char* c_szFile, int len, char* pszPath, char* pszName, char* pszExt)
|
||||
{
|
||||
assert(pszPath!=NULL);
|
||||
assert(pszName!=NULL);
|
||||
assert(pszExt!=NULL);
|
||||
|
||||
int ext=len;
|
||||
int pos=len;
|
||||
while (pos>0)
|
||||
{
|
||||
--pos;
|
||||
char c=c_szFile[pos];
|
||||
if (ext==len && c=='.')
|
||||
{
|
||||
ext=pos;
|
||||
break;
|
||||
}
|
||||
|
||||
if (c=='/') break;
|
||||
else if (c=='\\') break;
|
||||
}
|
||||
|
||||
while (pos>0)
|
||||
{
|
||||
--pos;
|
||||
char c=c_szFile[pos];
|
||||
|
||||
if (c=='/') break;
|
||||
else if (c=='\\') break;
|
||||
}
|
||||
|
||||
if (pos)
|
||||
{
|
||||
++pos;
|
||||
for (int i = 0; i < pos; ++i)
|
||||
{
|
||||
pszPath[i] = c_szFile[i];
|
||||
}
|
||||
pszPath[pos] = '\0';
|
||||
}
|
||||
|
||||
if (ext>pos)
|
||||
{
|
||||
int count = 0;
|
||||
for (int i = pos; i < ext; ++i)
|
||||
{
|
||||
pszName[count++] = c_szFile[i];
|
||||
}
|
||||
pszName[count] = '\0';
|
||||
}
|
||||
|
||||
++ext;
|
||||
if (len > ext)
|
||||
{
|
||||
int count = 0;
|
||||
for (int i = ext; i < len; ++i)
|
||||
{
|
||||
pszExt[count++] = c_szFile[i];
|
||||
}
|
||||
pszExt[count] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
void GetOldIndexingName(char * szName, int Index)
|
||||
{
|
||||
int dec, sign;
|
||||
char Temp[512];
|
||||
|
||||
strcpy(Temp, _ecvt(Index, 256, &dec, &sign));
|
||||
Temp[dec] = '\0';
|
||||
|
||||
strcat(szName, Temp);
|
||||
}
|
||||
|
||||
void GetIndexingName(char * szName, DWORD Index)
|
||||
{
|
||||
sprintf(szName + strlen(szName), "%u", Index);
|
||||
}
|
||||
|
||||
void GetOnlyFileName(const char * sz_Name, std::string & strFileName)
|
||||
{
|
||||
strFileName = "";
|
||||
|
||||
int i;
|
||||
for (i=strlen(sz_Name)-1; i>=0; --i)
|
||||
{
|
||||
if ('\\' == sz_Name[i] || '/' == sz_Name[i])
|
||||
{
|
||||
++i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == -1)
|
||||
i = 0;
|
||||
|
||||
for (size_t j = i; j < strlen(sz_Name); ++j)
|
||||
{
|
||||
strFileName += sz_Name[j];
|
||||
}
|
||||
|
||||
strFileName += "\0";
|
||||
}
|
||||
|
||||
void GetExceptionPathName(const char * sz_Name, std::string & OnlyFileName)
|
||||
{
|
||||
GetOnlyFileName(sz_Name, OnlyFileName);
|
||||
}
|
||||
|
||||
void GetOnlyPathName(const char * sz_Name, std::string & OnlyPathName)
|
||||
{
|
||||
int i;
|
||||
for (i = strlen(sz_Name) - 1; i >= 0; --i)
|
||||
{
|
||||
if ('\\' == sz_Name[i] || '/' == sz_Name[i])
|
||||
{
|
||||
++i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == -1)
|
||||
i = 0;
|
||||
|
||||
OnlyPathName.reserve(strlen(sz_Name));
|
||||
OnlyPathName = "";
|
||||
|
||||
for (int j=0; j<i; ++j)
|
||||
{
|
||||
OnlyPathName += sz_Name[j];
|
||||
}
|
||||
OnlyPathName += "\0";
|
||||
}
|
||||
|
||||
const char * GetOnlyPathName(const char * c_szName)
|
||||
{
|
||||
static std::string strPathName;
|
||||
GetOnlyPathName(c_szName, strPathName);
|
||||
|
||||
return strPathName.c_str();
|
||||
}
|
||||
|
||||
bool GetLocalFileName(const char * c_szGlobalPath, const char * c_szFullPathFileName, std::string * pstrLocalFileName)
|
||||
{
|
||||
std::string strLocalFileName;
|
||||
|
||||
std::string strGlobalPath;
|
||||
std::string strFullPathFileName;
|
||||
StringPath(c_szGlobalPath, strGlobalPath);
|
||||
StringPath(c_szFullPathFileName, strFullPathFileName);
|
||||
|
||||
if (strGlobalPath.length() >= strFullPathFileName.length())
|
||||
return false;
|
||||
|
||||
DWORD length = min(strGlobalPath.length(), strFullPathFileName.length());
|
||||
for (DWORD dwPos = 0; dwPos < length; ++dwPos)
|
||||
{
|
||||
if (strGlobalPath[dwPos] != strFullPathFileName[dwPos])
|
||||
return false;
|
||||
}
|
||||
|
||||
*pstrLocalFileName = &c_szFullPathFileName[length];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GetWorkingFolder(std::string & strFileName)
|
||||
{
|
||||
char buf[128+1];
|
||||
_getcwd(buf, 128);
|
||||
strcat(buf, "/");
|
||||
strFileName = buf;
|
||||
}
|
||||
|
||||
void StringLowers(char * String)
|
||||
{
|
||||
for (DWORD i = 0; i < strlen(String); ++i)
|
||||
{
|
||||
String[i] = korean_tolower(String[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void StringPath(std::string & rString)
|
||||
{
|
||||
for (DWORD i = 0; i < rString.length(); ++i)
|
||||
{
|
||||
if (rString[i] == '\\')
|
||||
rString[i] = '/';
|
||||
else
|
||||
rString[i] = korean_tolower(rString[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void StringPath(char * pString)
|
||||
{
|
||||
for (DWORD i = 0; i < strlen(pString); ++i)
|
||||
{
|
||||
if (pString[i] == '\\')
|
||||
pString[i] = '/';
|
||||
else
|
||||
pString[i] = korean_tolower(pString[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void StringPath(const char * c_szSrc, char * szDest)
|
||||
{
|
||||
for (DWORD i = 0; i < strlen(c_szSrc); ++i)
|
||||
{
|
||||
if (c_szSrc[i] == '\\')
|
||||
szDest[i] = '/';
|
||||
else
|
||||
szDest[i] = korean_tolower(c_szSrc[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void StringPath(const char * c_szSrc, std::string & rString)
|
||||
{
|
||||
rString = "";
|
||||
rString.resize(strlen(c_szSrc));
|
||||
|
||||
for (DWORD i = 0; i < strlen(c_szSrc); ++i)
|
||||
{
|
||||
if (c_szSrc[i] == '\\')
|
||||
rString[i] = '/';
|
||||
else
|
||||
rString[i] = korean_tolower(c_szSrc[i]);
|
||||
}
|
||||
}
|
||||
|
||||
#define ishprint(x) ((((x) & 0xE0) > 0x90) || isprint(x))
|
||||
|
||||
void PrintAsciiData(const void* void_data, int bytes)
|
||||
{
|
||||
int i, j, k;
|
||||
const unsigned char* p;
|
||||
const unsigned char* data;
|
||||
|
||||
data = (const unsigned char*) void_data;
|
||||
|
||||
fprintf(stdout, "------------------------------------------------------------------\n");
|
||||
j = bytes;
|
||||
while (1)
|
||||
{
|
||||
k = j >= 16 ? 16 : j;
|
||||
|
||||
p = data;
|
||||
for (i = 0; i < 16; ++i)
|
||||
{
|
||||
if (i >= k)
|
||||
fprintf(stdout, " ");
|
||||
else
|
||||
fprintf(stdout, "%02x ", *p);
|
||||
p++;
|
||||
}
|
||||
|
||||
fprintf(stdout, "| ");
|
||||
|
||||
p = data;
|
||||
for (i = 0; i < k; ++i)
|
||||
{
|
||||
if (i >= k)
|
||||
fprintf(stdout, " ");
|
||||
else
|
||||
fprintf(stdout, "%c", ishprint(*p) ? *p : '.');
|
||||
p++;
|
||||
}
|
||||
|
||||
fprintf(stdout, "\n");
|
||||
|
||||
j -= 16;
|
||||
data += 16;
|
||||
|
||||
if (j <= 0)
|
||||
break;
|
||||
}
|
||||
|
||||
fprintf(stdout, "------------------------------------------------------------------\n");
|
||||
}
|
||||
|
||||
int MIN(int a, int b)
|
||||
{
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
int MAX(int a, int b)
|
||||
{
|
||||
return a > b ? a : b;
|
||||
}
|
||||
|
||||
int MINMAX(int min, int value, int max)
|
||||
{
|
||||
if (max < min)
|
||||
return MAX(min, value);
|
||||
|
||||
register int tv;
|
||||
tv = (min > value ? min : value);
|
||||
return (max < tv) ? max : tv;
|
||||
}
|
||||
|
||||
float fMIN(float a, float b)
|
||||
{
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
float fMAX(float a, float b)
|
||||
{
|
||||
return a > b ? a : b;
|
||||
}
|
||||
|
||||
float fMINMAX(float min, float value, float max)
|
||||
{
|
||||
register float tv;
|
||||
|
||||
tv = (min > value ? min : value);
|
||||
return (max < tv) ? max : tv;
|
||||
}
|
||||
|
||||
bool IsFile(const char* filename)
|
||||
{
|
||||
return _access(filename, 0) == 0 ? true : false;
|
||||
}
|
||||
|
||||
bool IsGlobalFileName(const char * c_szFileName)
|
||||
{
|
||||
return strchr(c_szFileName, ':') != NULL;
|
||||
}
|
||||
|
||||
void MyCreateDirectory(const char* path)
|
||||
{
|
||||
if (!path || !*path)
|
||||
return;
|
||||
|
||||
char * dir;
|
||||
const char * p;
|
||||
|
||||
if (strlen(path) >= 3)
|
||||
{
|
||||
if (*(path + 1) == ':')
|
||||
path += 3;
|
||||
}
|
||||
|
||||
p = path;
|
||||
|
||||
int len = strlen(path) + 1;
|
||||
dir = new char[len];
|
||||
|
||||
while (*p)
|
||||
{
|
||||
if (*p == '/' || *p == '\\')
|
||||
{
|
||||
memset(dir, 0, len);
|
||||
strncpy(dir, path, p - path);
|
||||
CreateDirectory(dir, NULL);
|
||||
}
|
||||
|
||||
++p;
|
||||
}
|
||||
|
||||
delete [] dir;
|
||||
}
|
||||
|
||||
class CDirRemover : public CDir
|
||||
{
|
||||
public:
|
||||
CDirRemover()
|
||||
{
|
||||
}
|
||||
virtual ~CDirRemover()
|
||||
{
|
||||
}
|
||||
|
||||
bool OnFolder(const char* c_szFilter, const char* c_szPathName, const char* c_szFileName)
|
||||
{
|
||||
std::string strFullPathName;
|
||||
strFullPathName = c_szPathName;
|
||||
strFullPathName += c_szFileName;
|
||||
|
||||
CDirRemover remover;
|
||||
remover.Create(c_szFilter, strFullPathName.c_str());
|
||||
|
||||
std::string strWorkingFolder;
|
||||
GetWorkingFolder(strWorkingFolder);
|
||||
strWorkingFolder += strFullPathName;
|
||||
strWorkingFolder += "/";
|
||||
StringPath(strWorkingFolder);
|
||||
ms_strDirectoryDeque.push_back(strWorkingFolder);
|
||||
return true;
|
||||
}
|
||||
bool OnFile(const char* c_szPathName, const char* c_szFileName)
|
||||
{
|
||||
std::string strFullPathName;
|
||||
strFullPathName = c_szPathName;
|
||||
strFullPathName += c_szFileName;
|
||||
_chmod(strFullPathName.c_str(), _S_IWRITE);
|
||||
DeleteFile(strFullPathName.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
static void RemoveAllDirectory()
|
||||
{
|
||||
for (std::deque<std::string>::iterator itor = ms_strDirectoryDeque.begin(); itor != ms_strDirectoryDeque.end(); ++itor)
|
||||
{
|
||||
const std::string & c_rstrDirectory = *itor;
|
||||
RemoveDirectory(c_rstrDirectory.c_str());
|
||||
}
|
||||
|
||||
ms_strDirectoryDeque.clear();
|
||||
}
|
||||
|
||||
protected:
|
||||
static std::deque<std::string> ms_strDirectoryDeque;
|
||||
};
|
||||
|
||||
std::deque<std::string> CDirRemover::ms_strDirectoryDeque;
|
||||
|
||||
void RemoveAllDirectory(const char * c_szDirectoryName)
|
||||
{
|
||||
{
|
||||
CDirRemover remover;
|
||||
remover.Create("*.*", c_szDirectoryName);
|
||||
CDirRemover::RemoveAllDirectory();
|
||||
}
|
||||
RemoveDirectory(c_szDirectoryName);
|
||||
}
|
||||
|
||||
void StringExceptCharacter(std::string * pstrString, const char * c_szCharacter)
|
||||
{
|
||||
int icurPos = 0;
|
||||
int iNextPos = 0;
|
||||
|
||||
while((iNextPos = pstrString->find_first_of(c_szCharacter, icurPos)) >= 0)
|
||||
{
|
||||
std::string strFront = pstrString->substr(icurPos, iNextPos - icurPos);
|
||||
std::string strBack = pstrString->substr(iNextPos+1, pstrString->length() - iNextPos - 1);
|
||||
*pstrString = strFront + strBack;
|
||||
}
|
||||
}
|
||||
|
||||
bool SplitLine(const char * c_szLine, const char * c_szDelimeter, std::vector<std::string> * pkVec_strToken)
|
||||
{
|
||||
pkVec_strToken->reserve(10);
|
||||
pkVec_strToken->clear();
|
||||
|
||||
std::string strLine = c_szLine;
|
||||
|
||||
DWORD basePos = 0;
|
||||
|
||||
do
|
||||
{
|
||||
int beginPos = strLine.find_first_not_of(c_szDelimeter, basePos);
|
||||
if (beginPos < 0)
|
||||
return false;
|
||||
|
||||
int endPos;
|
||||
|
||||
if (strLine[beginPos] == '"')
|
||||
{
|
||||
++beginPos;
|
||||
endPos = strLine.find_first_of("\"", beginPos);
|
||||
|
||||
if (endPos < 0)
|
||||
return false;
|
||||
|
||||
basePos = endPos + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
endPos = strLine.find_first_of(c_szDelimeter, beginPos);
|
||||
basePos = endPos;
|
||||
}
|
||||
|
||||
pkVec_strToken->push_back(strLine.substr(beginPos, endPos - beginPos));
|
||||
} while (basePos < strLine.length());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GetExcutedFileName(std::string & r_str)
|
||||
{
|
||||
char szPath[MAX_PATH+1];
|
||||
|
||||
GetModuleFileName(NULL, szPath, MAX_PATH);
|
||||
szPath[MAX_PATH] = '\0';
|
||||
|
||||
r_str = szPath;
|
||||
}
|
||||
|
||||
const char * _getf(const char* c_szFormat, ...)
|
||||
{
|
||||
static char szBuf[256];
|
||||
|
||||
va_list args;
|
||||
va_start(args, c_szFormat);
|
||||
_vsnprintf(szBuf, sizeof(szBuf), c_szFormat, args);
|
||||
va_end(args);
|
||||
|
||||
return szBuf;
|
||||
}
|
||||
|
||||
PCHAR* CommandLineToArgv( PCHAR CmdLine, int* _argc )
|
||||
{
|
||||
PCHAR* argv;
|
||||
PCHAR _argv;
|
||||
ULONG len;
|
||||
ULONG argc;
|
||||
CHAR a;
|
||||
ULONG i, j;
|
||||
|
||||
BOOLEAN in_QM;
|
||||
BOOLEAN in_TEXT;
|
||||
BOOLEAN in_SPACE;
|
||||
|
||||
len = strlen(CmdLine);
|
||||
i = ((len+2)/2)*sizeof(PVOID) + sizeof(PVOID);
|
||||
|
||||
argv = (PCHAR*)GlobalAlloc(GMEM_FIXED,
|
||||
i + (len+2)*sizeof(CHAR));
|
||||
|
||||
_argv = (PCHAR)(((PUCHAR)argv)+i);
|
||||
|
||||
argc = 0;
|
||||
argv[argc] = _argv;
|
||||
in_QM = FALSE;
|
||||
in_TEXT = FALSE;
|
||||
in_SPACE = TRUE;
|
||||
i = 0;
|
||||
j = 0;
|
||||
|
||||
while( (a = CmdLine[i]) != 0 ) {
|
||||
if(in_QM) {
|
||||
if(a == '\"') {
|
||||
in_QM = FALSE;
|
||||
} else {
|
||||
_argv[j] = a;
|
||||
j++;
|
||||
}
|
||||
} else {
|
||||
switch(a) {
|
||||
case '\"':
|
||||
in_QM = TRUE;
|
||||
in_TEXT = TRUE;
|
||||
if(in_SPACE) {
|
||||
argv[argc] = _argv+j;
|
||||
argc++;
|
||||
}
|
||||
in_SPACE = FALSE;
|
||||
break;
|
||||
case ' ':
|
||||
case '\t':
|
||||
case '\n':
|
||||
case '\r':
|
||||
if(in_TEXT) {
|
||||
_argv[j] = '\0';
|
||||
j++;
|
||||
}
|
||||
in_TEXT = FALSE;
|
||||
in_SPACE = TRUE;
|
||||
break;
|
||||
default:
|
||||
in_TEXT = TRUE;
|
||||
if(in_SPACE) {
|
||||
argv[argc] = _argv+j;
|
||||
argc++;
|
||||
}
|
||||
_argv[j] = a;
|
||||
j++;
|
||||
in_SPACE = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
_argv[j] = '\0';
|
||||
argv[argc] = NULL;
|
||||
|
||||
(*_argc) = argc;
|
||||
return argv;
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
219
source-client/Srcs/Client/EterBase/Utils.h
Normal file
219
source-client/Srcs/Client/EterBase/Utils.h
Normal file
@ -0,0 +1,219 @@
|
||||
#ifndef __INC_ETER2_ETERBASE_UTILS_H__
|
||||
#define __INC_ETER2_ETERBASE_UTILS_H__
|
||||
|
||||
#include <windows.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#ifndef SAFE_DELETE
|
||||
#define SAFE_DELETE(p) { if (p) { delete (p); (p) = NULL; } }
|
||||
#endif
|
||||
|
||||
#ifndef SAFE_DELETE_ARRAY
|
||||
#define SAFE_DELETE_ARRAY(p) { if (p) { delete[] (p); (p) = NULL; } }
|
||||
#endif
|
||||
|
||||
#ifndef SAFE_RELEASE
|
||||
#define SAFE_RELEASE(p) { if (p) { (p)->Release(); (p) = NULL; } }
|
||||
#endif
|
||||
|
||||
#ifndef SAFE_FREE_GLOBAL
|
||||
#define SAFE_FREE_GLOBAL(p) { if (p) { ::GlobalFree(p); (p) = NULL; } }
|
||||
#endif
|
||||
|
||||
#ifndef SAFE_FREE_LIBRARY
|
||||
#define SAFE_FREE_LIBRARY(p) { if (p) { ::FreeLibrary(p); (p) = NULL; } }
|
||||
#endif
|
||||
|
||||
#define AssertLog(str) TraceError(str); assert(!str)
|
||||
|
||||
#ifndef MAKEFOURCC
|
||||
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
|
||||
((DWORD)(BYTE) (ch0 ) | ((DWORD)(BYTE) (ch1) << 8) | \
|
||||
((DWORD)(BYTE) (ch2) << 16) | ((DWORD)(BYTE) (ch3) << 24))
|
||||
#endif // defined(MAKEFOURCC)
|
||||
|
||||
#ifndef IS_SET
|
||||
#define IS_SET(flag,bit) ((flag) & (bit))
|
||||
#endif
|
||||
|
||||
#ifndef SET_BIT
|
||||
#define SET_BIT(var,bit) ((var) |= (bit))
|
||||
#endif
|
||||
|
||||
#ifndef REMOVE_BIT
|
||||
#define REMOVE_BIT(var,bit) ((var) &= ~(bit))
|
||||
#endif
|
||||
|
||||
#ifndef TOGGLE_BIT
|
||||
#define TOGGLE_BIT(var,bit) ((var) = (var) ^ (bit))
|
||||
#endif
|
||||
|
||||
extern const char * CreateTempFileName(const char * c_pszPrefix = NULL);
|
||||
extern void GetFilePathNameExtension(const char* c_szFile, int len, std::string* pstPath, std::string* pstName, std::string* pstExt);
|
||||
extern void GetFileExtension(const char* c_szFile, int len, std::string* pstExt);
|
||||
extern void GetFileNameParts(const char* c_szFile, int len, char* pszPath, char* pszName, char* pszExt);
|
||||
extern void GetOldIndexingName(char * szName, int Index);
|
||||
extern void GetIndexingName(char * szName, DWORD Index);
|
||||
extern void stl_lowers(std::string& rstRet);
|
||||
extern void GetOnlyFileName(const char * sz_Name, std::string & strFileName);
|
||||
extern void GetOnlyPathName(const char * sz_Name, std::string & OnlyPathName);
|
||||
extern const char * GetOnlyPathName(const char * c_szName);
|
||||
bool GetLocalFileName(const char * c_szGlobalPath, const char * c_szFullPathFileName, std::string * pstrLocalFileName);
|
||||
extern void GetExceptionPathName(const char * sz_Name, std::string & OnlyFileName);
|
||||
extern void GetWorkingFolder(std::string & strFileName);
|
||||
extern void StringLowers(char * pString);
|
||||
extern void StringPath(std::string & rString);
|
||||
extern void StringPath(char * pString);
|
||||
extern void StringPath(const char * c_szSrc, char * szDest);
|
||||
extern void StringPath(const char * c_szSrc, std::string & rString);
|
||||
extern void PrintAsciiData(const void* data, int bytes);
|
||||
bool IsFile(const char* filename);
|
||||
bool IsGlobalFileName(const char * c_szFileName);
|
||||
int MIN(int a, int b);
|
||||
int MAX(int a, int b);
|
||||
int MINMAX(int min, int value, int max);
|
||||
float fMIN(float a, float b);
|
||||
float fMAX(float a, float b);
|
||||
float fMINMAX(float min, float value, float max);
|
||||
void MyCreateDirectory(const char* path);
|
||||
void RemoveAllDirectory(const char * c_szDirectoryName);
|
||||
bool SplitLine(const char * c_szLine, const char * c_szDelimeter, std::vector<std::string> * pkVec_strToken);
|
||||
const char * _getf(const char* c_szFormat, ...);
|
||||
PCHAR* CommandLineToArgv( PCHAR CmdLine, int* _argc );
|
||||
|
||||
template<typename T>
|
||||
T EL_DegreeToRadian(T degree)
|
||||
{
|
||||
const T PI = T(3.141592);
|
||||
return T(PI*degree/180.0f);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void ELPlainCoord_GetRotatedPixelPosition(T centerX, T centerY, T distance, T rotDegree, T* pdstX, T* pdstY)
|
||||
{
|
||||
T rotRadian=EL_DegreeToRadian(rotDegree);
|
||||
*pdstX=centerX+distance*T(sin((double)rotRadian));
|
||||
*pdstY=centerY+distance*T(cos((double)rotRadian));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T EL_SignedDegreeToUnsignedDegree(T fSrc)
|
||||
{
|
||||
if (fSrc<0.0f)
|
||||
return T(360.0+T(fmod(fSrc, 360.0)));
|
||||
|
||||
return T(fmod(fSrc, 360.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T ELRightCoord_ConvertToPlainCoordDegree(T srcDegree)
|
||||
{
|
||||
return T(fmod(450.0 - srcDegree, 360.0));
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
void string_join(const std::string& sep, const C& container, std::string* ret)
|
||||
{
|
||||
unsigned int capacity = sep.length() * container.size() - 1;
|
||||
|
||||
// calculate string sequence
|
||||
{
|
||||
for (auto i = container.begin(); i != container.end(); ++i)
|
||||
capacity += (*i).length();
|
||||
}
|
||||
|
||||
std::string buf;
|
||||
buf.reserve(capacity);
|
||||
|
||||
// join strings
|
||||
{
|
||||
auto cur = container.begin();
|
||||
auto end = container.end();
|
||||
--end;
|
||||
|
||||
while (cur != end)
|
||||
{
|
||||
buf.append(*cur++);
|
||||
buf.append(sep);
|
||||
}
|
||||
buf.append(*cur);
|
||||
}
|
||||
|
||||
swap(*ret, buf);
|
||||
}
|
||||
|
||||
__forceinline int htoi(const wchar_t *s, int size)
|
||||
{
|
||||
const wchar_t *t = s;
|
||||
int x = 0, y = 1;
|
||||
s += size;
|
||||
|
||||
while (t <= --s)
|
||||
{
|
||||
if (L'0' <= *s && *s <= L'9')
|
||||
x += y * (*s - L'0');
|
||||
else if (L'a' <= *s && *s <= L'f')
|
||||
x += y * (*s - L'a' + 10);
|
||||
else if (L'A' <= *s && *s <= L'F')
|
||||
x += y * (10 + *s - L'A');
|
||||
else
|
||||
return -1; /* invalid input! */
|
||||
y <<= 4;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
__forceinline int htoi(const char *s, int size)
|
||||
{
|
||||
const char *t = s;
|
||||
int x = 0, y = 1;
|
||||
s += size;
|
||||
|
||||
while (t <= --s)
|
||||
{
|
||||
if ('0' <= *s && *s <= '9')
|
||||
x += y * (*s - '0');
|
||||
else if ('a' <= *s && *s <= 'f')
|
||||
x += y * (*s - 'a' + 10);
|
||||
else if ('A' <= *s && *s <= 'F')
|
||||
x += y * (10 + *s - 'A');
|
||||
else
|
||||
return -1; /* invalid input! */
|
||||
y <<= 4;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
__forceinline int htoi(const char *s)
|
||||
{
|
||||
const char *t = s;
|
||||
int x = 0, y = 1;
|
||||
s += strlen(s);
|
||||
|
||||
while (t <= --s)
|
||||
{
|
||||
if ('0' <= *s && *s <= '9')
|
||||
x += y * (*s - '0');
|
||||
else if ('a' <= *s && *s <= 'f')
|
||||
x += y * (*s - 'a' + 10);
|
||||
else if ('A' <= *s && *s <= 'F')
|
||||
x += y * (10 + *s - 'A');
|
||||
else
|
||||
return -1; /* invalid input! */
|
||||
y <<= 4;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
typedef std::vector<std::string> TTokenVector;
|
||||
|
||||
void StringExceptCharacter(std::string * pstrString, const char * c_szCharacter);
|
||||
|
||||
extern void GetExcutedFileName(std::string & r_str);
|
||||
|
||||
#endif
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
450
source-client/Srcs/Client/EterBase/cipher.cpp
Normal file
450
source-client/Srcs/Client/EterBase/cipher.cpp
Normal file
@ -0,0 +1,450 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "cipher.h"
|
||||
|
||||
#ifdef _IMPROVED_PACKET_ENCRYPTION_
|
||||
|
||||
#pragma warning(push)
|
||||
//#pragma warning(disable: 4100 4127 4189 4231 4512 4706)
|
||||
|
||||
#include <cryptopp/modes.h>
|
||||
#include <cryptopp/nbtheory.h>
|
||||
#include <cryptopp/osrng.h>
|
||||
|
||||
// Diffie-Hellman key agreement
|
||||
#include <cryptopp/dh.h>
|
||||
#include <cryptopp/dh2.h>
|
||||
|
||||
// AES winner and candidates
|
||||
#include <cryptopp/aes.h>
|
||||
#include <cryptopp/cast.h>
|
||||
#include <cryptopp/rc6.h>
|
||||
#include <cryptopp/mars.h>
|
||||
#include <cryptopp/serpent.h>
|
||||
#include <cryptopp/twofish.h>
|
||||
// Other block ciphers
|
||||
#include <cryptopp/blowfish.h>
|
||||
#include <cryptopp/camellia.h>
|
||||
#include <cryptopp/des.h>
|
||||
#include <cryptopp/idea.h>
|
||||
#include <cryptopp/rc5.h>
|
||||
#include <cryptopp/seed.h>
|
||||
#include <cryptopp/shacal2.h>
|
||||
#include <cryptopp/skipjack.h>
|
||||
#include <cryptopp/tea.h>
|
||||
|
||||
#ifdef __THEMIDA__
|
||||
#include <ThemidaSDK.h>
|
||||
#endif
|
||||
|
||||
#include "Debug.h"
|
||||
|
||||
using namespace CryptoPP;
|
||||
|
||||
// Block cipher algorithm selector abstract base class.
|
||||
struct BlockCipherAlgorithm {
|
||||
enum {
|
||||
kDefault, // to give more chances to default algorithm
|
||||
// AES winner and candidates
|
||||
// kAES, // Rijndael
|
||||
kRC6,
|
||||
kMARS,
|
||||
kTwofish,
|
||||
kSerpent,
|
||||
kCAST256,
|
||||
// Other block ciphers
|
||||
kIDEA,
|
||||
k3DES, // DES-EDE2
|
||||
kCamellia,
|
||||
kSEED,
|
||||
kRC5,
|
||||
kBlowfish,
|
||||
kTEA,
|
||||
//kSKIPJACK,
|
||||
kSHACAL2,
|
||||
// End sentinel
|
||||
kMaxAlgorithms
|
||||
};
|
||||
|
||||
BlockCipherAlgorithm() {}
|
||||
virtual ~BlockCipherAlgorithm() {}
|
||||
|
||||
static BlockCipherAlgorithm* Pick(int hint);
|
||||
|
||||
virtual int GetBlockSize() const = 0;
|
||||
virtual int GetDefaultKeyLength() const = 0;
|
||||
virtual int GetIVLength() const = 0;
|
||||
|
||||
virtual SymmetricCipher* CreateEncoder(const byte* key, size_t keylen,
|
||||
const byte* iv) const = 0;
|
||||
virtual SymmetricCipher* CreateDecoder(const byte* key, size_t keylen,
|
||||
const byte* iv) const = 0;
|
||||
};
|
||||
|
||||
// Block cipher (with CTR mode) algorithm selector template class.
|
||||
template<class T>
|
||||
struct BlockCipherDetail : public BlockCipherAlgorithm {
|
||||
BlockCipherDetail() {}
|
||||
virtual ~BlockCipherDetail() {}
|
||||
|
||||
virtual int GetBlockSize() const { return T::BLOCKSIZE; }
|
||||
virtual int GetDefaultKeyLength() const { return T::DEFAULT_KEYLENGTH; }
|
||||
virtual int GetIVLength() const { return T::IV_LENGTH; }
|
||||
|
||||
virtual SymmetricCipher* CreateEncoder(const byte* key, size_t keylen,
|
||||
const byte* iv) const {
|
||||
return new CTR_Mode<T>::Encryption(key, keylen, iv);
|
||||
}
|
||||
virtual SymmetricCipher* CreateDecoder(const byte* key, size_t keylen,
|
||||
const byte* iv) const {
|
||||
return new CTR_Mode<T>::Decryption(key, keylen, iv);
|
||||
}
|
||||
};
|
||||
|
||||
// Key agreement scheme abstract class.
|
||||
class KeyAgreement {
|
||||
public:
|
||||
KeyAgreement() {}
|
||||
virtual ~KeyAgreement() {}
|
||||
|
||||
virtual size_t Prepare(void* buffer, size_t* length) = 0;
|
||||
virtual bool Agree(size_t agreed_length, const void* buffer, size_t length) = 0;
|
||||
|
||||
const SecByteBlock& shared() const { return shared_; }
|
||||
|
||||
protected:
|
||||
SecByteBlock shared_;
|
||||
};
|
||||
|
||||
// Crypto++ Unified Diffie-Hellman key agreement scheme implementation.
|
||||
class DH2KeyAgreement : public KeyAgreement {
|
||||
public:
|
||||
DH2KeyAgreement();
|
||||
virtual ~DH2KeyAgreement();
|
||||
|
||||
virtual size_t Prepare(void* buffer, size_t* length);
|
||||
virtual bool Agree(size_t agreed_length, const void* buffer, size_t length);
|
||||
|
||||
private:
|
||||
DH dh_;
|
||||
DH2 dh2_;
|
||||
SecByteBlock spriv_key_;
|
||||
SecByteBlock epriv_key_;
|
||||
};
|
||||
|
||||
Cipher::Cipher()
|
||||
: activated_(false), encoder_(NULL), decoder_(NULL), key_agreement_(NULL) {
|
||||
}
|
||||
|
||||
Cipher::~Cipher() {
|
||||
if (activated_) {
|
||||
CleanUp();
|
||||
}
|
||||
}
|
||||
|
||||
void Cipher::CleanUp() {
|
||||
if (encoder_ != NULL) {
|
||||
delete encoder_;
|
||||
encoder_ = NULL;
|
||||
}
|
||||
if (decoder_ != NULL) {
|
||||
delete decoder_;
|
||||
decoder_ = NULL;
|
||||
}
|
||||
if (key_agreement_ != NULL) {
|
||||
delete key_agreement_;
|
||||
key_agreement_ = NULL;
|
||||
}
|
||||
activated_ = false;
|
||||
}
|
||||
|
||||
size_t Cipher::Prepare(void* buffer, size_t* length) {
|
||||
#ifdef __THEMIDA__
|
||||
VM_START
|
||||
#endif
|
||||
|
||||
assert(key_agreement_ == NULL);
|
||||
key_agreement_ = new DH2KeyAgreement();
|
||||
assert(key_agreement_ != NULL);
|
||||
size_t agreed_length = key_agreement_->Prepare(buffer, length);
|
||||
if (agreed_length == 0) {
|
||||
delete key_agreement_;
|
||||
key_agreement_ = NULL;
|
||||
}
|
||||
#ifdef __THEMIDA__
|
||||
VM_END
|
||||
#endif
|
||||
|
||||
return agreed_length;
|
||||
}
|
||||
|
||||
bool Cipher::Activate(bool polarity, size_t agreed_length,
|
||||
const void* buffer, size_t length) {
|
||||
#ifdef __THEMIDA__
|
||||
VM_START
|
||||
#endif
|
||||
|
||||
assert(activated_ == false);
|
||||
assert(key_agreement_ != NULL);
|
||||
bool result = false;
|
||||
if (key_agreement_->Agree(agreed_length, buffer, length)) {
|
||||
result = SetUp(polarity);
|
||||
}
|
||||
delete key_agreement_;
|
||||
key_agreement_ = NULL;
|
||||
#ifdef __THEMIDA__
|
||||
VM_END
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Cipher::SetUp(bool polarity) {
|
||||
#ifdef __THEMIDA__
|
||||
VM_START
|
||||
#endif
|
||||
|
||||
assert(key_agreement_ != NULL);
|
||||
const SecByteBlock& shared = key_agreement_->shared();
|
||||
|
||||
// Pick a block cipher algorithm
|
||||
|
||||
if (shared.size() < 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int hint_0 = shared.BytePtr()[*(shared.BytePtr()) % shared.size()];
|
||||
int hint_1 = shared.BytePtr()[*(shared.BytePtr() + 1) % shared.size()];
|
||||
BlockCipherAlgorithm* detail_0 = BlockCipherAlgorithm::Pick(hint_0);
|
||||
BlockCipherAlgorithm* detail_1 = BlockCipherAlgorithm::Pick(hint_1);
|
||||
assert(detail_0 != NULL);
|
||||
assert(detail_1 != NULL);
|
||||
std::unique_ptr<BlockCipherAlgorithm> algorithm_0(detail_0);
|
||||
std::unique_ptr<BlockCipherAlgorithm> algorithm_1(detail_1);
|
||||
|
||||
const size_t key_length_0 = algorithm_0->GetDefaultKeyLength();
|
||||
const size_t iv_length_0 = algorithm_0->GetBlockSize();
|
||||
|
||||
if (shared.size() < key_length_0 || shared.size() < iv_length_0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const size_t key_length_1 = algorithm_1->GetDefaultKeyLength();
|
||||
const size_t iv_length_1 = algorithm_1->GetBlockSize();
|
||||
|
||||
if (shared.size() < key_length_1 || shared.size() < iv_length_1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Pick encryption keys and initial vectors
|
||||
|
||||
SecByteBlock key_0(key_length_0), iv_0(iv_length_0);
|
||||
SecByteBlock key_1(key_length_1), iv_1(iv_length_1);
|
||||
|
||||
size_t offset;
|
||||
|
||||
key_0.Assign(shared, key_length_0);
|
||||
offset = key_length_0;
|
||||
offset = min(key_length_0, shared.size() - key_length_1);
|
||||
key_1.Assign(shared.BytePtr() + offset, key_length_1);
|
||||
|
||||
offset = shared.size() - iv_length_0;
|
||||
iv_0.Assign(shared.BytePtr() + offset, iv_length_0);
|
||||
offset = (offset < iv_length_1 ? 0 : offset - iv_length_1);
|
||||
iv_1.Assign(shared.BytePtr() + offset, iv_length_1);
|
||||
|
||||
// Create encryption/decryption objects
|
||||
|
||||
if (polarity) {
|
||||
encoder_ = algorithm_1->CreateEncoder(key_1, key_1.size(), iv_1);
|
||||
decoder_ = algorithm_0->CreateDecoder(key_0, key_0.size(), iv_0);
|
||||
} else {
|
||||
encoder_ = algorithm_0->CreateEncoder(key_0, key_0.size(), iv_0);
|
||||
decoder_ = algorithm_1->CreateDecoder(key_1, key_1.size(), iv_1);
|
||||
}
|
||||
|
||||
assert(encoder_ != NULL);
|
||||
assert(decoder_ != NULL);
|
||||
#ifdef __THEMIDA__
|
||||
VM_END
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BlockCipherAlgorithm* BlockCipherAlgorithm::Pick(int hint) {
|
||||
BlockCipherAlgorithm* detail;
|
||||
int selector = hint % kMaxAlgorithms;
|
||||
switch (selector) {
|
||||
//case kAES:
|
||||
// detail = new BlockCipherDetail<AES>();
|
||||
break;
|
||||
case kRC6:
|
||||
detail = new BlockCipherDetail<RC6>();
|
||||
break;
|
||||
case kMARS:
|
||||
detail = new BlockCipherDetail<MARS>();
|
||||
break;
|
||||
case kTwofish:
|
||||
detail = new BlockCipherDetail<Twofish>();
|
||||
break;
|
||||
case kSerpent:
|
||||
detail = new BlockCipherDetail<Serpent>();
|
||||
break;
|
||||
case kCAST256:
|
||||
detail = new BlockCipherDetail<CAST256>();
|
||||
break;
|
||||
case kIDEA:
|
||||
detail = new BlockCipherDetail<IDEA>();
|
||||
break;
|
||||
case k3DES:
|
||||
detail = new BlockCipherDetail<DES_EDE2>();
|
||||
break;
|
||||
case kCamellia:
|
||||
detail = new BlockCipherDetail<Camellia>();
|
||||
break;
|
||||
case kSEED:
|
||||
detail = new BlockCipherDetail<SEED>();
|
||||
break;
|
||||
case kRC5:
|
||||
detail = new BlockCipherDetail<RC5>();
|
||||
break;
|
||||
case kBlowfish:
|
||||
detail = new BlockCipherDetail<Blowfish>();
|
||||
break;
|
||||
case kTEA:
|
||||
detail = new BlockCipherDetail<TEA>();
|
||||
break;
|
||||
// case kSKIPJACK:
|
||||
// detail = new BlockCipherDetail<SKIPJACK>();
|
||||
// break;
|
||||
case kSHACAL2:
|
||||
detail = new BlockCipherDetail<SHACAL2>();
|
||||
break;
|
||||
case kDefault:
|
||||
default:
|
||||
detail = new BlockCipherDetail<Twofish>(); // default algorithm
|
||||
break;
|
||||
}
|
||||
|
||||
return detail;
|
||||
}
|
||||
|
||||
DH2KeyAgreement::DH2KeyAgreement() : dh_(), dh2_(dh_) {
|
||||
}
|
||||
|
||||
DH2KeyAgreement::~DH2KeyAgreement() {
|
||||
}
|
||||
|
||||
size_t DH2KeyAgreement::Prepare(void* buffer, size_t* length) {
|
||||
#ifdef __THEMIDA__
|
||||
VM_START
|
||||
#endif
|
||||
|
||||
// RFC 5114, 1024-bit MODP Group with 160-bit Prime Order Subgroup
|
||||
// http://tools.ietf.org/html/rfc5114#section-2.1
|
||||
Integer p("0xB10B8F96A080E01DDE92DE5EAE5D54EC52C99FBCFB06A3C6"
|
||||
"9A6A9DCA52D23B616073E28675A23D189838EF1E2EE652C0"
|
||||
"13ECB4AEA906112324975C3CD49B83BFACCBDD7D90C4BD70"
|
||||
"98488E9C219A73724EFFD6FAE5644738FAA31A4FF55BCCC0"
|
||||
"A151AF5F0DC8B4BD45BF37DF365C1A65E68CFDA76D4DA708"
|
||||
"DF1FB2BC2E4A4371");
|
||||
|
||||
Integer g("0xA4D1CBD5C3FD34126765A442EFB99905F8104DD258AC507F"
|
||||
"D6406CFF14266D31266FEA1E5C41564B777E690F5504F213"
|
||||
"160217B4B01B886A5E91547F9E2749F4D7FBD7D3B9A92EE1"
|
||||
"909D0D2263F80A76A6A24C087A091F531DBF0A0169B6A28A"
|
||||
"D662A4D18E73AFA32D779D5918D08BC8858F4DCEF97C2A24"
|
||||
"855E6EEB22B3B2E5");
|
||||
|
||||
Integer q("0xF518AA8781A8DF278ABA4E7D64B7CB9D49462353");
|
||||
|
||||
// Schnorr Group primes are of the form p = rq + 1, p and q prime. They
|
||||
// provide a subgroup order. In the case of 1024-bit MODP Group, the
|
||||
// security level is 80 bits (based on the 160-bit prime order subgroup).
|
||||
|
||||
// For a compare/contrast of using the maximum security level, see
|
||||
// dh-unified.zip. Also see http://www.cryptopp.com/wiki/Diffie-Hellman
|
||||
// and http://www.cryptopp.com/wiki/Security_level .
|
||||
|
||||
AutoSeededRandomPool rnd;
|
||||
|
||||
dh_.AccessGroupParameters().Initialize(p, q, g);
|
||||
|
||||
if(!dh_.GetGroupParameters().ValidateGroup(rnd, 3)) {
|
||||
// Failed to validate prime and generator
|
||||
return 0;
|
||||
}
|
||||
|
||||
// size_t count = 0;
|
||||
|
||||
p = dh_.GetGroupParameters().GetModulus();
|
||||
q = dh_.GetGroupParameters().GetSubgroupOrder();
|
||||
g = dh_.GetGroupParameters().GetGenerator();
|
||||
|
||||
// http://groups.google.com/group/sci.crypt/browse_thread/thread/7dc7eeb04a09f0ce
|
||||
Integer v = ModularExponentiation(g, q, p);
|
||||
|
||||
if(v != Integer::One()) {
|
||||
// Failed to verify order of the subgroup
|
||||
return 0;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
spriv_key_.New(dh2_.StaticPrivateKeyLength());
|
||||
epriv_key_.New(dh2_.EphemeralPrivateKeyLength());
|
||||
SecByteBlock spub_key(dh2_.StaticPublicKeyLength());
|
||||
SecByteBlock epub_key(dh2_.EphemeralPublicKeyLength());
|
||||
|
||||
dh2_.GenerateStaticKeyPair(rnd, spriv_key_, spub_key);
|
||||
dh2_.GenerateEphemeralKeyPair(rnd, epriv_key_, epub_key);
|
||||
|
||||
// Prepare key agreement data
|
||||
const size_t spub_key_length = spub_key.size();
|
||||
const size_t epub_key_length = epub_key.size();
|
||||
const size_t data_length = spub_key_length + epub_key_length;
|
||||
|
||||
if (*length < data_length) {
|
||||
// Not enough data buffer length
|
||||
return 0;
|
||||
}
|
||||
|
||||
*length = data_length;
|
||||
byte* buf = (byte*)buffer;
|
||||
memcpy(buf, spub_key.BytePtr(), spub_key_length);
|
||||
memcpy(buf + spub_key_length, epub_key.BytePtr(), epub_key_length);
|
||||
|
||||
#ifdef __THEMIDA__
|
||||
VM_END
|
||||
#endif
|
||||
|
||||
return dh2_.AgreedValueLength();
|
||||
}
|
||||
|
||||
bool DH2KeyAgreement::Agree(size_t agreed_length, const void* buffer, size_t length) {
|
||||
if (agreed_length != dh2_.AgreedValueLength()) {
|
||||
// Shared secret size mismatch
|
||||
return false;
|
||||
}
|
||||
const size_t spub_key_length = dh2_.StaticPublicKeyLength();
|
||||
const size_t epub_key_length = dh2_.EphemeralPublicKeyLength();
|
||||
if (length != (spub_key_length + epub_key_length)) {
|
||||
// Wrong data length
|
||||
return false;
|
||||
}
|
||||
shared_.New(dh2_.AgreedValueLength());
|
||||
const byte* buf = (const byte*)buffer;
|
||||
if (!dh2_.Agree(shared_, spriv_key_, epriv_key_, buf, buf + spub_key_length)) {
|
||||
// Failed to reach shared secret
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#pragma warning(pop)
|
||||
|
||||
#endif // _IMPROVED_PACKET_ENCRYPTION_
|
||||
|
||||
// EOF cipher.cpp
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
64
source-client/Srcs/Client/EterBase/cipher.h
Normal file
64
source-client/Srcs/Client/EterBase/cipher.h
Normal file
@ -0,0 +1,64 @@
|
||||
#ifndef __CIPHER_H__
|
||||
#define __CIPHER_H__
|
||||
|
||||
#ifdef _IMPROVED_PACKET_ENCRYPTION_
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4100 4127 4189 4231 4512 4706)
|
||||
#include <cryptopp/cryptlib.h>
|
||||
#pragma warning(pop)
|
||||
|
||||
// Forward declaration
|
||||
class KeyAgreement;
|
||||
|
||||
//THEMIDA
|
||||
// Communication channel encryption handler.
|
||||
class Cipher {
|
||||
public:
|
||||
explicit Cipher();
|
||||
~Cipher();
|
||||
|
||||
void CleanUp();
|
||||
|
||||
// Returns agreed value length in bytes, or zero on failure.
|
||||
size_t Prepare(void* buffer, size_t* length);
|
||||
// Try to activate cipher algorithm with agreement data received from peer.
|
||||
bool Activate(bool polarity, size_t agreed_length,
|
||||
const void* buffer, size_t length);
|
||||
|
||||
// Encrypts the given block of data. (no padding required)
|
||||
void Encrypt(void* buffer, size_t length) {
|
||||
assert(activated_);
|
||||
if (!activated_) {
|
||||
return;
|
||||
}
|
||||
encoder_->ProcessData((CryptoPP::byte*)buffer, (const CryptoPP::byte*)buffer, length);
|
||||
}
|
||||
// Decrypts the given block of data. (no padding required)
|
||||
void Decrypt(void* buffer, size_t length) {
|
||||
assert(activated_);
|
||||
if (!activated_) {
|
||||
return;
|
||||
}
|
||||
decoder_->ProcessData((CryptoPP::byte*)buffer, (const CryptoPP::byte*)buffer, length);
|
||||
}
|
||||
|
||||
bool activated() const { return activated_; }
|
||||
|
||||
void set_activated(bool value) { activated_ = value; }
|
||||
|
||||
private:
|
||||
bool SetUp(bool polarity);
|
||||
|
||||
bool activated_;
|
||||
|
||||
CryptoPP::SymmetricCipher* encoder_;
|
||||
CryptoPP::SymmetricCipher* decoder_;
|
||||
|
||||
KeyAgreement* key_agreement_;
|
||||
};
|
||||
|
||||
#endif // _IMPROVED_PACKET_ENCRYPTION_
|
||||
|
||||
#endif // __CIPHER_H__
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
74
source-client/Srcs/Client/EterBase/error.cpp
Normal file
74
source-client/Srcs/Client/EterBase/error.cpp
Normal file
@ -0,0 +1,74 @@
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <winsock.h>
|
||||
#include <imagehlp.h>
|
||||
|
||||
FILE * fException;
|
||||
|
||||
#define ENABLE_CRASH_MINIDUMP
|
||||
#ifdef ENABLE_CRASH_MINIDUMP
|
||||
#include "../UserInterface/Version.h"
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
void make_minidump(EXCEPTION_POINTERS* e)
|
||||
{
|
||||
auto hDbgHelp = LoadLibraryA("dbghelp");
|
||||
if (hDbgHelp == nullptr)
|
||||
return;
|
||||
auto pMiniDumpWriteDump = (decltype(&MiniDumpWriteDump))GetProcAddress(hDbgHelp, "MiniDumpWriteDump");
|
||||
if (pMiniDumpWriteDump == nullptr)
|
||||
return;
|
||||
// folder name
|
||||
std::string folder = "logs";
|
||||
CreateDirectoryA(folder.c_str(), nullptr);
|
||||
// time format
|
||||
auto t = std::time(nullptr);
|
||||
std::ostringstream timefmt;
|
||||
timefmt << std::put_time(std::localtime(&t), "%Y%m%d_%H%M%S");
|
||||
// filename
|
||||
std::string filename = folder + "\\"s + "metin2client_"s + std::to_string(METIN2_GET_VERSION()) + "_"s + timefmt.str() + ".dmp";
|
||||
|
||||
auto hFile = CreateFileA(filename.c_str(), GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
return;
|
||||
|
||||
MINIDUMP_EXCEPTION_INFORMATION exceptionInfo;
|
||||
exceptionInfo.ThreadId = GetCurrentThreadId();
|
||||
exceptionInfo.ExceptionPointers = e;
|
||||
exceptionInfo.ClientPointers = FALSE;
|
||||
|
||||
auto dumped = pMiniDumpWriteDump(
|
||||
GetCurrentProcess(),
|
||||
GetCurrentProcessId(),
|
||||
hFile,
|
||||
MINIDUMP_TYPE(MiniDumpWithIndirectlyReferencedMemory | MiniDumpScanMemory),
|
||||
e ? &exceptionInfo : nullptr,
|
||||
nullptr,
|
||||
nullptr);
|
||||
|
||||
CloseHandle(hFile);
|
||||
|
||||
// std::string errMsg = "The application crashed. Send the generated file to the staff: "s + name;
|
||||
// MessageBox(nullptr, errMsg.c_str(), "Metin2Client", MB_ICONSTOP);
|
||||
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
LONG __stdcall EterExceptionFilter(_EXCEPTION_POINTERS * pExceptionInfo)
|
||||
{
|
||||
#ifdef ENABLE_CRASH_MINIDUMP
|
||||
make_minidump(pExceptionInfo);
|
||||
#else
|
||||
// eterlog trash
|
||||
#endif
|
||||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
}
|
||||
|
||||
void SetEterExceptionHandler()
|
||||
{
|
||||
SetUnhandledExceptionFilter(EterExceptionFilter);
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
3
source-client/Srcs/Client/EterBase/error.h
Normal file
3
source-client/Srcs/Client/EterBase/error.h
Normal file
@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
extern void SetEterExceptionHandler();
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
248
source-client/Srcs/Client/EterBase/eterBase.vcxproj
Normal file
248
source-client/Srcs/Client/EterBase/eterBase.vcxproj
Normal file
@ -0,0 +1,248 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Distribute|Win32">
|
||||
<Configuration>Distribute</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectName>eterBase</ProjectName>
|
||||
<ProjectGuid>{678C47DC-B3EF-460E-A932-56F3208FC65E}</ProjectGuid>
|
||||
<RootNamespace>eterBase</RootNamespace>
|
||||
<SccProjectName>
|
||||
</SccProjectName>
|
||||
<SccAuxPath>
|
||||
</SccAuxPath>
|
||||
<SccLocalPath>
|
||||
</SccLocalPath>
|
||||
<SccProvider>
|
||||
</SccProvider>
|
||||
<Keyword>MFCProj</Keyword>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">$(ProjectDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>../../Extern/include</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS;_SILENCE_ALL_CXX20_DEPRECATION_WARNINGS;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PrecompiledHeaderOutputFile>$(IntDir)$(ProjectName).pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
|
||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
||||
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
|
||||
<BrowseInformation>
|
||||
</BrowseInformation>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<SDLCheck>
|
||||
</SDLCheck>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
<IgnoreStandardIncludePath>true</IgnoreStandardIncludePath>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||
<AdditionalLibraryDirectories>../../../extern/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<AdditionalIncludeDirectories>../../extern/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;DISTRIBUTE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PrecompiledHeaderOutputFile>$(IntDir)$(ProjectName).pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerOutput>All</AssemblerOutput>
|
||||
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
|
||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
||||
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
|
||||
<BrowseInformation>
|
||||
</BrowseInformation>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||
<AdditionalLibraryDirectories>../../extern/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<AdditionalIncludeDirectories>../../Extern/include</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS;_SILENCE_ALL_CXX20_DEPRECATION_WARNINGS;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PrecompiledHeaderOutputFile>$(IntDir)$(ProjectName).pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
|
||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
||||
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
|
||||
<BrowseInformation>
|
||||
</BrowseInformation>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<SDLCheck>
|
||||
</SDLCheck>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||
<AdditionalLibraryDirectories>../../extern/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="poly\Base.cpp" />
|
||||
<ClCompile Include="poly\Poly.cpp" />
|
||||
<ClCompile Include="poly\Symbol.cpp" />
|
||||
<ClCompile Include="poly\SymTable.cpp" />
|
||||
<ClCompile Include="cipher.cpp" />
|
||||
<ClCompile Include="CPostIt.cpp" />
|
||||
<ClCompile Include="CRC32.cpp" />
|
||||
<ClCompile Include="Debug.cpp" />
|
||||
<ClCompile Include="error.cpp" />
|
||||
<ClCompile Include="FileBase.cpp" />
|
||||
<ClCompile Include="FileDir.cpp" />
|
||||
<ClCompile Include="FileLoader.cpp" />
|
||||
<ClCompile Include="lzo.cpp" />
|
||||
<ClCompile Include="MappedFile.cpp" />
|
||||
<ClCompile Include="Random.cpp" />
|
||||
<ClCompile Include="StdAfx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Stl.cpp" />
|
||||
<ClCompile Include="tea.cpp" />
|
||||
<ClCompile Include="TempFile.cpp" />
|
||||
<ClCompile Include="Timer.cpp" />
|
||||
<ClCompile Include="Utils.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="poly\Base.h" />
|
||||
<ClInclude Include="poly\Poly.h" />
|
||||
<ClInclude Include="poly\Symbol.h" />
|
||||
<ClInclude Include="poly\SymTable.h" />
|
||||
<ClInclude Include="cipher.h" />
|
||||
<ClInclude Include="CPostIt.h" />
|
||||
<ClInclude Include="CRC32.h" />
|
||||
<ClInclude Include="Debug.h" />
|
||||
<ClInclude Include="error.h" />
|
||||
<ClInclude Include="FileBase.h" />
|
||||
<ClInclude Include="FileDir.h" />
|
||||
<ClInclude Include="FileLoader.h" />
|
||||
<ClInclude Include="Filename.h" />
|
||||
<ClInclude Include="lzo.h" />
|
||||
<ClInclude Include="MappedFile.h" />
|
||||
<ClInclude Include="Random.h" />
|
||||
<ClInclude Include="ServiceDefs.h" />
|
||||
<ClInclude Include="Singleton.h" />
|
||||
<ClInclude Include="StdAfx.h" />
|
||||
<ClInclude Include="Stl.h" />
|
||||
<ClInclude Include="tea.h" />
|
||||
<ClInclude Include="TempFile.h" />
|
||||
<ClInclude Include="Timer.h" />
|
||||
<ClInclude Include="Utils.h" />
|
||||
<ClInclude Include="vk.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
3
source-client/Srcs/Client/EterBase/eterBase.vcxproj.user
Normal file
3
source-client/Srcs/Client/EterBase/eterBase.vcxproj.user
Normal file
@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
</Project>
|
||||
402
source-client/Srcs/Client/EterBase/lzo.cpp
Normal file
402
source-client/Srcs/Client/EterBase/lzo.cpp
Normal file
@ -0,0 +1,402 @@
|
||||
#include "StdAfx.h"
|
||||
#include <stdlib.h>
|
||||
#include <lzo/lzoLibLink.h>
|
||||
|
||||
#include "lzo.h"
|
||||
#include "tea.h"
|
||||
#include "debug.h"
|
||||
|
||||
#define dbg_printf
|
||||
|
||||
static class LZOFreeMemoryMgr
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
REUSING_CAPACITY = 64*1024,
|
||||
};
|
||||
public:
|
||||
~LZOFreeMemoryMgr()
|
||||
{
|
||||
std::vector<BYTE*>::iterator i;
|
||||
for (i = m_freeVector.begin(); i != m_freeVector.end(); ++i)
|
||||
delete *i;
|
||||
|
||||
m_freeVector.clear();
|
||||
}
|
||||
BYTE* Alloc(unsigned capacity)
|
||||
{
|
||||
assert(capacity > 0);
|
||||
if (capacity < REUSING_CAPACITY)
|
||||
{
|
||||
if (!m_freeVector.empty())
|
||||
{
|
||||
BYTE* freeMem = m_freeVector.back();
|
||||
m_freeVector.pop_back();
|
||||
|
||||
dbg_printf("lzo.reuse_alloc\t%p(%d) free\n", freeMem, capacity);
|
||||
return freeMem;
|
||||
}
|
||||
BYTE* newMem = new BYTE[REUSING_CAPACITY];
|
||||
dbg_printf("lzo.reuse_alloc\t%p(%d) real\n", newMem, capacity);
|
||||
return newMem;
|
||||
}
|
||||
BYTE* newMem = new BYTE[capacity];
|
||||
dbg_printf("lzo.real_alloc\t%p(%d)\n", newMem, capacity);
|
||||
return newMem;
|
||||
}
|
||||
void Free(BYTE* ptr, unsigned capacity)
|
||||
{
|
||||
assert(ptr != NULL);
|
||||
assert(capacity > 0);
|
||||
if (capacity < REUSING_CAPACITY)
|
||||
{
|
||||
dbg_printf("lzo.reuse_free\t%p(%d)\n", ptr, capacity);
|
||||
m_freeVector.push_back(ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
dbg_printf("lzo.real_free\t%p(%d)\n", ptr, capacity);
|
||||
delete [] ptr;
|
||||
}
|
||||
private:
|
||||
std::vector<BYTE*> m_freeVector;
|
||||
} gs_freeMemMgr;
|
||||
|
||||
DWORD CLZObject::ms_dwFourCC = MAKEFOURCC('M', 'C', 'O', 'Z');
|
||||
|
||||
CLZObject::CLZObject()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
void CLZObject::Initialize()
|
||||
{
|
||||
m_bInBuffer = false;
|
||||
m_pbBuffer = NULL;
|
||||
m_dwBufferSize = 0;
|
||||
|
||||
m_pHeader = NULL;
|
||||
m_pbIn = NULL;
|
||||
m_bCompressed = false;
|
||||
}
|
||||
|
||||
void CLZObject::Clear()
|
||||
{
|
||||
if (m_pbBuffer && !m_bInBuffer)
|
||||
gs_freeMemMgr.Free(m_pbBuffer, m_dwBufferSize);
|
||||
|
||||
if (m_dwBufferSize > 0)
|
||||
{
|
||||
dbg_printf("lzo.free %d\n", m_dwBufferSize);
|
||||
}
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
CLZObject::~CLZObject()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
DWORD CLZObject::GetSize()
|
||||
{
|
||||
assert(m_pHeader);
|
||||
|
||||
if (m_bCompressed)
|
||||
{
|
||||
if (m_pHeader->dwEncryptSize)
|
||||
return sizeof(THeader) + sizeof(DWORD) + m_pHeader->dwEncryptSize;
|
||||
else
|
||||
return sizeof(THeader) + sizeof(DWORD) + m_pHeader->dwCompressedSize;
|
||||
}
|
||||
else
|
||||
return m_pHeader->dwRealSize;
|
||||
}
|
||||
|
||||
void CLZObject::BeginCompress(const void * pvIn, UINT uiInLen)
|
||||
{
|
||||
m_pbIn = (const BYTE *) pvIn;
|
||||
|
||||
// sizeof(SHeader) +
|
||||
m_dwBufferSize = sizeof(THeader) + sizeof(DWORD) + (uiInLen + uiInLen / 64 + 16 + 3) + 8;
|
||||
|
||||
m_pbBuffer = gs_freeMemMgr.Alloc(m_dwBufferSize);
|
||||
memset(m_pbBuffer, 0, m_dwBufferSize);
|
||||
|
||||
m_pHeader = (THeader *) m_pbBuffer;
|
||||
m_pHeader->dwFourCC = ms_dwFourCC;
|
||||
m_pHeader->dwEncryptSize = m_pHeader->dwCompressedSize = m_pHeader->dwRealSize = 0;
|
||||
m_pHeader->dwRealSize = uiInLen;
|
||||
}
|
||||
|
||||
void CLZObject::BeginCompressInBuffer(const void * pvIn, UINT uiInLen, void * /*pvOut*/)
|
||||
{
|
||||
m_pbIn = (const BYTE *) pvIn;
|
||||
|
||||
// sizeof(SHeader) +
|
||||
m_dwBufferSize = sizeof(THeader) + sizeof(DWORD) + (uiInLen + uiInLen / 64 + 16 + 3) + 8;
|
||||
|
||||
m_pbBuffer = gs_freeMemMgr.Alloc(m_dwBufferSize);
|
||||
memset(m_pbBuffer, 0, m_dwBufferSize);
|
||||
|
||||
m_pHeader = (THeader *) m_pbBuffer;
|
||||
m_pHeader->dwFourCC = ms_dwFourCC;
|
||||
m_pHeader->dwEncryptSize = m_pHeader->dwCompressedSize = m_pHeader->dwRealSize = 0;
|
||||
m_pHeader->dwRealSize = uiInLen;
|
||||
m_bInBuffer = true;
|
||||
}
|
||||
|
||||
bool CLZObject::Compress()
|
||||
{
|
||||
UINT iOutLen;
|
||||
BYTE * pbBuffer;
|
||||
|
||||
pbBuffer = m_pbBuffer + sizeof(THeader);
|
||||
*(DWORD *) pbBuffer = ms_dwFourCC;
|
||||
pbBuffer += sizeof(DWORD);
|
||||
|
||||
#if defined( LZO1X_999_MEM_COMPRESS )
|
||||
int r = lzo1x_999_compress((BYTE *) m_pbIn, m_pHeader->dwRealSize, pbBuffer, (lzo_uint*) &iOutLen, CLZO::Instance().GetWorkMemory());
|
||||
#else
|
||||
int r = lzo1x_1_compress((BYTE *) m_pbIn, m_pHeader->dwRealSize, pbBuffer, (lzo_uint*) &iOutLen, CLZO::Instance().GetWorkMemory());
|
||||
#endif
|
||||
|
||||
if (LZO_E_OK != r)
|
||||
{
|
||||
TraceError("LZO: lzo1x_999_compress failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_pHeader->dwCompressedSize = iOutLen;
|
||||
m_bCompressed = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CLZObject::BeginDecompress(const void * pvIn)
|
||||
{
|
||||
THeader * pHeader = (THeader *) pvIn;
|
||||
|
||||
if (pHeader->dwFourCC != ms_dwFourCC)
|
||||
{
|
||||
TraceError("LZObject: not a valid data");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_pHeader = pHeader;
|
||||
m_pbIn = (const BYTE *) pvIn + (sizeof(THeader) + sizeof(DWORD));
|
||||
|
||||
/*
|
||||
static unsigned sum = 0;
|
||||
static unsigned count = 0;
|
||||
sum += pHeader->dwRealSize;
|
||||
count++;
|
||||
printf("decompress cur: %d, ave: %d\n", pHeader->dwRealSize, sum/count);
|
||||
*/
|
||||
m_dwBufferSize = pHeader->dwRealSize;
|
||||
m_pbBuffer = gs_freeMemMgr.Alloc(m_dwBufferSize);
|
||||
memset(m_pbBuffer, 0, pHeader->dwRealSize);
|
||||
return true;
|
||||
}
|
||||
|
||||
class DecryptBuffer
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
LOCAL_BUF_SIZE = 8 * 1024,
|
||||
};
|
||||
public:
|
||||
DecryptBuffer(unsigned size)
|
||||
{
|
||||
static unsigned count = 0;
|
||||
static unsigned sum = 0;
|
||||
static unsigned maxSize = 0;
|
||||
|
||||
sum += size;
|
||||
count++;
|
||||
|
||||
maxSize = max(size, maxSize);
|
||||
if (size >= LOCAL_BUF_SIZE)
|
||||
{
|
||||
m_buf = new char[size];
|
||||
dbg_printf("DecryptBuffer - AllocHeap %d max(%d) ave(%d)\n", size, maxSize/1024, sum/count);
|
||||
}
|
||||
else
|
||||
{
|
||||
dbg_printf("DecryptBuffer - AllocStack %d max(%d) ave(%d)\n", size, maxSize/1024, sum/count);
|
||||
m_buf = m_local_buf;
|
||||
}
|
||||
}
|
||||
~DecryptBuffer()
|
||||
{
|
||||
if (m_local_buf != m_buf)
|
||||
{
|
||||
dbg_printf("DecruptBuffer - FreeHeap\n");
|
||||
delete [] m_buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
dbg_printf("DecruptBuffer - FreeStack\n");
|
||||
}
|
||||
}
|
||||
void* GetBufferPtr()
|
||||
{
|
||||
return m_buf;
|
||||
}
|
||||
|
||||
private:
|
||||
char* m_buf;
|
||||
char m_local_buf[LOCAL_BUF_SIZE];
|
||||
};
|
||||
|
||||
bool CLZObject::Decompress(DWORD * pdwKey)
|
||||
{
|
||||
UINT uiSize;
|
||||
int r;
|
||||
|
||||
if (m_pHeader->dwEncryptSize)
|
||||
{
|
||||
DecryptBuffer buf(m_pHeader->dwEncryptSize);
|
||||
|
||||
BYTE* pbDecryptedBuffer = (BYTE*)buf.GetBufferPtr();
|
||||
|
||||
__Decrypt(pdwKey, pbDecryptedBuffer);
|
||||
|
||||
if (*(DWORD *) pbDecryptedBuffer != ms_dwFourCC)
|
||||
{
|
||||
TraceError("LZObject: key incorrect");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (LZO_E_OK != (r = lzo1x_decompress(pbDecryptedBuffer + sizeof(DWORD), m_pHeader->dwCompressedSize, m_pbBuffer, (lzo_uint*) &uiSize, NULL)))
|
||||
{
|
||||
TraceError("LZObject: Decompress failed(decrypt) ret %d\n", r);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
uiSize = m_pHeader->dwRealSize;
|
||||
|
||||
//if (LZO_E_OK != (r = lzo1x_decompress_safe(m_pbIn, m_pHeader->dwCompressedSize, m_pbBuffer, (lzo_uint*) &uiSize, NULL)))
|
||||
if (LZO_E_OK != (r = lzo1x_decompress(m_pbIn, m_pHeader->dwCompressedSize, m_pbBuffer, (lzo_uint*) &uiSize, NULL)))
|
||||
{
|
||||
TraceError("LZObject: Decompress failed : ret %d, CompressedSize %d\n", r, m_pHeader->dwCompressedSize);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (uiSize != m_pHeader->dwRealSize)
|
||||
{
|
||||
TraceError("LZObject: Size differs");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CLZObject::Encrypt(DWORD * pdwKey)
|
||||
{
|
||||
if (!m_bCompressed)
|
||||
{
|
||||
assert(!"not compressed yet");
|
||||
return false;
|
||||
}
|
||||
|
||||
BYTE * pbBuffer = m_pbBuffer + sizeof(THeader);
|
||||
m_pHeader->dwEncryptSize = tea_encrypt((DWORD *) pbBuffer, (const DWORD *) pbBuffer, pdwKey, m_pHeader->dwCompressedSize + 19);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CLZObject::__Decrypt(DWORD * key, BYTE* data)
|
||||
{
|
||||
assert(m_pbBuffer);
|
||||
|
||||
tea_decrypt((DWORD *) data, (const DWORD *) (m_pbIn - sizeof(DWORD)), key, m_pHeader->dwEncryptSize);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CLZObject::AllocBuffer(DWORD dwSrcSize)
|
||||
{
|
||||
if (m_pbBuffer && !m_bInBuffer)
|
||||
gs_freeMemMgr.Free(m_pbBuffer, m_dwBufferSize);
|
||||
|
||||
m_pbBuffer = gs_freeMemMgr.Alloc(dwSrcSize);
|
||||
m_dwBufferSize = dwSrcSize;
|
||||
}
|
||||
/*
|
||||
void CLZObject::CopyBuffer(const char* pbSrc, DWORD dwSrcSize)
|
||||
{
|
||||
AllocBuffer(dwSrcSize);
|
||||
memcpy(m_pbBuffer, pbSrc, dwSrcSize);
|
||||
}
|
||||
*/
|
||||
|
||||
CLZO::CLZO() : m_pWorkMem(NULL)
|
||||
{
|
||||
if (lzo_init() != LZO_E_OK)
|
||||
{
|
||||
TraceError("LZO: cannot initialize");
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined( LZO1X_999_MEM_COMPRESS )
|
||||
m_pWorkMem = (BYTE *) malloc(LZO1X_999_MEM_COMPRESS);
|
||||
#else
|
||||
m_pWorkMem = (BYTE *) malloc(LZO1X_1_MEM_COMPRESS);
|
||||
#endif
|
||||
|
||||
if (NULL == m_pWorkMem)
|
||||
{
|
||||
TraceError("LZO: cannot alloc memory");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
CLZO::~CLZO()
|
||||
{
|
||||
if (m_pWorkMem)
|
||||
{
|
||||
free(m_pWorkMem);
|
||||
m_pWorkMem = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool CLZO::CompressMemory(CLZObject & rObj, const void * pIn, UINT uiInLen)
|
||||
{
|
||||
rObj.BeginCompress(pIn, uiInLen);
|
||||
return rObj.Compress();
|
||||
}
|
||||
|
||||
bool CLZO::CompressEncryptedMemory(CLZObject & rObj, const void * pIn, UINT uiInLen, DWORD * pdwKey)
|
||||
{
|
||||
rObj.BeginCompress(pIn, uiInLen);
|
||||
|
||||
if (rObj.Compress())
|
||||
{
|
||||
if (rObj.Encrypt(pdwKey))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CLZO::Decompress(CLZObject & rObj, const BYTE * pbBuf, DWORD * pdwKey)
|
||||
{
|
||||
if (!rObj.BeginDecompress(pbBuf))
|
||||
return false;
|
||||
|
||||
if (!rObj.Decompress(pdwKey))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BYTE * CLZO::GetWorkMemory()
|
||||
{
|
||||
return m_pWorkMem;
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
75
source-client/Srcs/Client/EterBase/lzo.h
Normal file
75
source-client/Srcs/Client/EterBase/lzo.h
Normal file
@ -0,0 +1,75 @@
|
||||
#ifndef __INC_METIN_II_371GNFBQOCJ_LZO_H__
|
||||
#define __INC_METIN_II_371GNFBQOCJ_LZO_H__
|
||||
|
||||
#include <windows.h>
|
||||
#include <lzo/lzo1x.h>
|
||||
#include "Singleton.h"
|
||||
|
||||
class CLZObject
|
||||
{
|
||||
public:
|
||||
#pragma pack(4)
|
||||
typedef struct SHeader
|
||||
{
|
||||
DWORD dwFourCC;
|
||||
DWORD dwEncryptSize;
|
||||
DWORD dwCompressedSize;
|
||||
DWORD dwRealSize;
|
||||
} THeader;
|
||||
#pragma pack()
|
||||
|
||||
CLZObject();
|
||||
~CLZObject();
|
||||
|
||||
void Clear();
|
||||
|
||||
void BeginCompress(const void * pvIn, UINT uiInLen);
|
||||
void BeginCompressInBuffer(const void * pvIn, UINT uiInLen, void * pvOut);
|
||||
bool Compress();
|
||||
|
||||
bool BeginDecompress(const void * pvIn);
|
||||
bool Decompress(DWORD * pdwKey = NULL);
|
||||
|
||||
bool Encrypt(DWORD * pdwKey);
|
||||
bool __Decrypt(DWORD * key, BYTE* data);
|
||||
|
||||
const THeader & GetHeader() { return *m_pHeader; }
|
||||
BYTE * GetBuffer() { return m_pbBuffer; }
|
||||
DWORD GetSize();
|
||||
void AllocBuffer(DWORD dwSize);
|
||||
DWORD GetBufferSize() { return m_dwBufferSize; }
|
||||
//void CopyBuffer(const char* pbSrc, DWORD dwSrcSize);
|
||||
|
||||
private:
|
||||
void Initialize();
|
||||
|
||||
BYTE * m_pbBuffer;
|
||||
DWORD m_dwBufferSize;
|
||||
|
||||
THeader * m_pHeader;
|
||||
const BYTE * m_pbIn;
|
||||
bool m_bCompressed;
|
||||
|
||||
bool m_bInBuffer;
|
||||
|
||||
public:
|
||||
static DWORD ms_dwFourCC;
|
||||
};
|
||||
|
||||
class CLZO : public CSingleton<CLZO>
|
||||
{
|
||||
public:
|
||||
CLZO();
|
||||
virtual ~CLZO();
|
||||
|
||||
bool CompressMemory(CLZObject & rObj, const void * pIn, UINT uiInLen);
|
||||
bool CompressEncryptedMemory(CLZObject & rObj, const void * pIn, UINT uiInLen, DWORD * pdwKey);
|
||||
bool Decompress(CLZObject & rObj, const BYTE * pbBuf, DWORD * pdwKey = NULL);
|
||||
BYTE * GetWorkMemory();
|
||||
|
||||
private:
|
||||
BYTE * m_pWorkMem;
|
||||
};
|
||||
|
||||
#endif
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
77
source-client/Srcs/Client/EterBase/tea.cpp
Normal file
77
source-client/Srcs/Client/EterBase/tea.cpp
Normal file
@ -0,0 +1,77 @@
|
||||
#include "StdAfx.h"
|
||||
#include "tea.h"
|
||||
#include <memory.h>
|
||||
|
||||
#define TEA_ROUND 32
|
||||
#define DELTA 0x9E3779B9
|
||||
|
||||
void tea_code(const unsigned long sz, const unsigned long sy, const unsigned long *key, unsigned long *dest)
|
||||
{
|
||||
register unsigned long y = sy, z = sz, sum = 0;
|
||||
unsigned long n = TEA_ROUND;
|
||||
|
||||
while (n-- > 0)
|
||||
{
|
||||
y += ((z << 4 ^ z >> 5) + z) ^ (sum + key[sum & 3]);
|
||||
sum += DELTA;
|
||||
z += ((y << 4 ^ y >> 5) + y) ^ (sum + key[sum >> 11 & 3]);
|
||||
}
|
||||
|
||||
*(dest++) = y;
|
||||
*dest = z;
|
||||
}
|
||||
|
||||
void tea_decode(const unsigned long sz, const unsigned long sy, const unsigned long *key, unsigned long *dest)
|
||||
{
|
||||
#pragma warning(disable:4307)
|
||||
register unsigned long y = sy, z = sz, sum = DELTA * TEA_ROUND;
|
||||
#pragma warning(default:4307)
|
||||
|
||||
unsigned long n = TEA_ROUND;
|
||||
|
||||
while (n-- > 0)
|
||||
{
|
||||
z -= ((y << 4 ^ y >> 5) + y) ^ (sum + key[sum >> 11 & 3]);
|
||||
sum -= DELTA;
|
||||
y -= ((z << 4 ^ z >> 5) + z) ^ (sum + key[sum & 3]);
|
||||
}
|
||||
|
||||
*(dest++) = y;
|
||||
*dest = z;
|
||||
}
|
||||
|
||||
int tea_encrypt(unsigned long *dest, const unsigned long *src, const unsigned long * key, int size)
|
||||
{
|
||||
int i;
|
||||
int resize;
|
||||
|
||||
if (size % 8 != 0)
|
||||
{
|
||||
resize = size + 8 - (size % 8);
|
||||
memset((char *) src + size, 0, resize - size);
|
||||
}
|
||||
else
|
||||
resize = size;
|
||||
|
||||
for (i = 0; i < resize >> 3; i++, dest += 2, src += 2)
|
||||
tea_code(*(src + 1), *src, key, dest);
|
||||
|
||||
return (resize);
|
||||
}
|
||||
|
||||
int tea_decrypt(unsigned long *dest, const unsigned long *src, const unsigned long * key, int size)
|
||||
{
|
||||
int i;
|
||||
int resize;
|
||||
|
||||
if (size % 8 != 0)
|
||||
resize = size + 8 - (size % 8);
|
||||
else
|
||||
resize = size;
|
||||
|
||||
for (i = 0; i < resize >> 3; i++, dest += 2, src += 2)
|
||||
tea_decode(*(src + 1), *src, key, dest);
|
||||
|
||||
return (resize);
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
20
source-client/Srcs/Client/EterBase/tea.h
Normal file
20
source-client/Srcs/Client/EterBase/tea.h
Normal file
@ -0,0 +1,20 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* TEA is a 64-bit symmetric block cipher with a 128-bit key, developed
|
||||
by David J. Wheeler and Roger M. Needham, and described in their
|
||||
paper at <URL:http://www.cl.cam.ac.uk/ftp/users/djw3/tea.ps>.
|
||||
|
||||
This implementation is based on their code in
|
||||
<URL:http://www.cl.cam.ac.uk/ftp/users/djw3/xtea.ps> */
|
||||
|
||||
#define TEA_KEY_LENGTH 16
|
||||
|
||||
int tea_encrypt(unsigned long *dest, const unsigned long *src, const unsigned long *key, int size);
|
||||
int tea_decrypt(unsigned long *dest, const unsigned long *src, const unsigned long *key, int size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
46
source-client/Srcs/Client/EterBase/vk.h
Normal file
46
source-client/Srcs/Client/EterBase/vk.h
Normal file
@ -0,0 +1,46 @@
|
||||
#ifndef __VK_H__
|
||||
#define __VK_H__
|
||||
#ifndef VK_0
|
||||
#define VK_0 0x30
|
||||
#define VK_1 0x31
|
||||
#define VK_2 0x32
|
||||
#define VK_3 0x33
|
||||
#define VK_4 0x34
|
||||
#define VK_5 0x35
|
||||
#define VK_6 0x36
|
||||
#define VK_7 0x37
|
||||
#define VK_8 0x38
|
||||
#define VK_9 0x39
|
||||
#endif
|
||||
|
||||
#ifndef VK_A
|
||||
#define VK_A 0x41
|
||||
#define VK_B 0x42
|
||||
#define VK_C 0x43
|
||||
#define VK_D 0x44
|
||||
#define VK_E 0x45
|
||||
#define VK_F 0x46
|
||||
#define VK_G 0x47
|
||||
#define VK_H 0x48
|
||||
#define VK_I 0x49
|
||||
#define VK_J 0x4A
|
||||
#define VK_K 0x4B
|
||||
#define VK_L 0x4C
|
||||
#define VK_M 0x4D
|
||||
#define VK_N 0x4E
|
||||
#define VK_O 0x4F
|
||||
#define VK_P 0x50
|
||||
#define VK_Q 0x51
|
||||
#define VK_R 0x52
|
||||
#define VK_S 0x53
|
||||
#define VK_T 0x54
|
||||
#define VK_U 0x55
|
||||
#define VK_V 0x56
|
||||
#define VK_W 0x57
|
||||
#define VK_X 0x58
|
||||
#define VK_Y 0x59
|
||||
#define VK_Z 0x5A
|
||||
#endif
|
||||
|
||||
#endif
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
681
source-client/Srcs/Client/EterGrnLib/LODController.cpp
Normal file
681
source-client/Srcs/Client/EterGrnLib/LODController.cpp
Normal file
@ -0,0 +1,681 @@
|
||||
#include "StdAfx.h"
|
||||
#include "LODController.h"
|
||||
|
||||
static float LODHEIGHT_ACTOR = 500.0f;
|
||||
static float LODDISTANCE_ACTOR = 5000.0f;
|
||||
static float LODDISTANCE_BUILDING = 25000.0f;
|
||||
|
||||
static const float c_fNearLodScale = 3.0f;
|
||||
static const float c_fFarLodScale = 25.0f;
|
||||
static const float LOD_APPLY_MAX = 2000.0f;
|
||||
static const float LOD_APPLY_MIN = 500.0f;
|
||||
|
||||
bool ms_isMinLODModeEnable=false;
|
||||
|
||||
enum
|
||||
{
|
||||
SHARED_VB_500 = 0,
|
||||
SHARED_VB_1000 = 1,
|
||||
SHARED_VB_1500 = 2,
|
||||
SHARED_VB_2000 = 3,
|
||||
SHARED_VB_2500 = 4,
|
||||
SHARED_VB_3000 = 5,
|
||||
SHARED_VB_3500 = 6,
|
||||
SHARED_VB_4000 = 7,
|
||||
SHARED_VB_NUM = 9,
|
||||
};
|
||||
|
||||
static std::vector<CGraphicVertexBuffer*> gs_vbs[SHARED_VB_NUM];
|
||||
|
||||
static CGraphicVertexBuffer gs_emptyVB;
|
||||
|
||||
#include <time.h>
|
||||
|
||||
static CGraphicVertexBuffer* __AllocDeformVertexBuffer(unsigned deformableVertexCount)
|
||||
{
|
||||
if (deformableVertexCount == 0)
|
||||
return &gs_emptyVB;
|
||||
|
||||
unsigned capacity = (((deformableVertexCount-1) / 500) + 1) * 500;
|
||||
unsigned index = (deformableVertexCount-1) / 500;
|
||||
if (index < SHARED_VB_NUM)
|
||||
{
|
||||
std::vector<CGraphicVertexBuffer*>& vbs = gs_vbs[index];
|
||||
if (!vbs.empty())
|
||||
{
|
||||
//TraceError("REUSE %d(%d)", capacity, deformableVertexCount);
|
||||
|
||||
CGraphicVertexBuffer* pkRetVB = vbs.back();
|
||||
vbs.pop_back();
|
||||
return pkRetVB;
|
||||
}
|
||||
}
|
||||
|
||||
static time_t base = time(NULL);
|
||||
//TraceError("NEW %8d: %d(%d)", time(NULL) - base, capacity, deformableVertexCount);
|
||||
|
||||
CGraphicVertexBuffer* pkNewVB = new CGraphicVertexBuffer;
|
||||
|
||||
if (!pkNewVB->Create(
|
||||
capacity,
|
||||
D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1,
|
||||
D3DUSAGE_WRITEONLY,
|
||||
D3DPOOL_MANAGED))
|
||||
{
|
||||
TraceError("NEW_ERROR %8d: %d(%d)", time(NULL) - base, capacity, deformableVertexCount);
|
||||
}
|
||||
|
||||
return pkNewVB;
|
||||
}
|
||||
|
||||
void __FreeDeformVertexBuffer(CGraphicVertexBuffer* pkDelVB)
|
||||
{
|
||||
if (pkDelVB)
|
||||
{
|
||||
if (pkDelVB == &gs_emptyVB)
|
||||
return;
|
||||
|
||||
unsigned index = (pkDelVB->GetVertexCount() - 1) / 500;
|
||||
if (index < SHARED_VB_NUM)
|
||||
{
|
||||
gs_vbs[index].push_back(pkDelVB);
|
||||
}
|
||||
else
|
||||
{
|
||||
pkDelVB->Destroy();
|
||||
delete pkDelVB;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void __ReserveSharedVertexBuffers(unsigned index, unsigned count)
|
||||
{
|
||||
if (index >= SHARED_VB_NUM)
|
||||
return;
|
||||
|
||||
unsigned capacity = (index + 1) * 500;
|
||||
|
||||
for (unsigned i = 0; i != count; ++i)
|
||||
{
|
||||
CGraphicVertexBuffer* pkNewVB = new CGraphicVertexBuffer;
|
||||
pkNewVB->Create(
|
||||
capacity,
|
||||
D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1,
|
||||
D3DUSAGE_WRITEONLY,
|
||||
D3DPOOL_MANAGED);
|
||||
gs_vbs[index].push_back(pkNewVB);
|
||||
}
|
||||
}
|
||||
|
||||
void GrannyCreateSharedDeformBuffer()
|
||||
{
|
||||
__ReserveSharedVertexBuffers(SHARED_VB_500, 40);
|
||||
__ReserveSharedVertexBuffers(SHARED_VB_1000, 20);
|
||||
__ReserveSharedVertexBuffers(SHARED_VB_1500, 20);
|
||||
__ReserveSharedVertexBuffers(SHARED_VB_2000, 40);
|
||||
__ReserveSharedVertexBuffers(SHARED_VB_3000, 20);
|
||||
}
|
||||
|
||||
void GrannyDestroySharedDeformBuffer()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
TraceError("granny_shared_vbs:");
|
||||
#endif
|
||||
for (int i = 0; i != SHARED_VB_NUM; ++i)
|
||||
{
|
||||
std::vector<CGraphicVertexBuffer*>& vbs = gs_vbs[i];
|
||||
#ifdef _DEBUG
|
||||
TraceError("\t%d: %d", i, vbs.size());
|
||||
#endif
|
||||
|
||||
std::vector<CGraphicVertexBuffer*>::iterator v;
|
||||
for (v = vbs.begin(); v != vbs.end(); ++v)
|
||||
{
|
||||
CGraphicVertexBuffer* pkEachVB = (*v);
|
||||
pkEachVB->Destroy();
|
||||
delete pkEachVB;
|
||||
}
|
||||
vbs.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void CGrannyLODController::SetMinLODMode(bool isEnable)
|
||||
{
|
||||
ms_isMinLODModeEnable=isEnable;
|
||||
}
|
||||
|
||||
void CGrannyLODController::SetMaterialImagePointer(const char* c_szImageName, CGraphicImage* pImage)
|
||||
{
|
||||
std::deque<CGrannyModelInstance *>::iterator i;
|
||||
for (i=m_que_pkModelInst.begin(); i!=m_que_pkModelInst.end(); ++i)
|
||||
{
|
||||
CGrannyModelInstance* pkModelInst=(*i);
|
||||
pkModelInst->SetMaterialImagePointer(c_szImageName, pImage);
|
||||
}
|
||||
}
|
||||
|
||||
void CGrannyLODController::SetMaterialData(const char* c_szImageName, const SMaterialData& c_rkMaterialData)
|
||||
{
|
||||
std::deque<CGrannyModelInstance *>::iterator i;
|
||||
for (i=m_que_pkModelInst.begin(); i!=m_que_pkModelInst.end(); ++i)
|
||||
{
|
||||
CGrannyModelInstance* pkModelInst=(*i);
|
||||
pkModelInst->SetMaterialData(c_szImageName, c_rkMaterialData);
|
||||
}
|
||||
}
|
||||
|
||||
void CGrannyLODController::SetSpecularInfo(const char* c_szMtrlName, BOOL bEnable, float fPower)
|
||||
{
|
||||
std::deque<CGrannyModelInstance *>::iterator i;
|
||||
for (i=m_que_pkModelInst.begin(); i!=m_que_pkModelInst.end(); ++i)
|
||||
{
|
||||
CGrannyModelInstance* pkModelInst=(*i);
|
||||
pkModelInst->SetSpecularInfo(c_szMtrlName, bEnable, fPower);
|
||||
}
|
||||
}
|
||||
|
||||
CGrannyLODController::CGrannyLODController() :
|
||||
m_pCurrentModelInstance(NULL),
|
||||
m_bLODLevel(0),
|
||||
m_pAttachedParentModel(NULL),
|
||||
m_fLODDistance(0.0f),
|
||||
m_dwLODAniFPS(CGrannyModelInstance::ANIFPS_MAX),
|
||||
m_pkSharedDeformableVertexBuffer(NULL)
|
||||
/////////////////////////////////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
CGrannyLODController::~CGrannyLODController()
|
||||
{
|
||||
__FreeDeformVertexBuffer(m_pkSharedDeformableVertexBuffer);
|
||||
|
||||
Clear();
|
||||
}
|
||||
|
||||
void CGrannyLODController::Clear()
|
||||
{
|
||||
if (m_pAttachedParentModel)
|
||||
{
|
||||
m_pAttachedParentModel->DetachModelInstance(this);
|
||||
}
|
||||
|
||||
m_pCurrentModelInstance = NULL;
|
||||
m_pAttachedParentModel = NULL;
|
||||
|
||||
std::for_each(m_que_pkModelInst.begin(), m_que_pkModelInst.end(), CGrannyModelInstance::Delete);
|
||||
m_que_pkModelInst.clear();
|
||||
|
||||
std::vector<TAttachingModelData>::iterator itor = m_AttachedModelDataVector.begin();
|
||||
for (; m_AttachedModelDataVector.end() != itor; ++itor)
|
||||
{
|
||||
TAttachingModelData & rData = *itor;
|
||||
rData.pkLODController->m_pAttachedParentModel = NULL;
|
||||
}
|
||||
|
||||
m_AttachedModelDataVector.clear();
|
||||
}
|
||||
|
||||
void CGrannyLODController::AddModel(CGraphicThing * pThing, int iSrcModel, CGrannyLODController * pSkelLODController)
|
||||
{
|
||||
if (!pThing)
|
||||
return;
|
||||
|
||||
if (pSkelLODController && pSkelLODController->m_que_pkModelInst.empty())
|
||||
{
|
||||
assert(!"EMPTY SKELETON(CANNON LINK)");
|
||||
return;
|
||||
}
|
||||
|
||||
assert(pThing->GetReferenceCount()>=1);
|
||||
|
||||
pThing->AddReference();
|
||||
|
||||
if (pThing->GetModelCount() <= iSrcModel)
|
||||
{
|
||||
pThing->Release();
|
||||
return;
|
||||
}
|
||||
CGrannyModel * pModel = pThing->GetModelPointer(iSrcModel);
|
||||
if (!pModel)
|
||||
{
|
||||
pThing->Release();
|
||||
return;
|
||||
}
|
||||
|
||||
CGrannyModelInstance * pModelInstance = CGrannyModelInstance::New();
|
||||
|
||||
__ReserveSharedDeformableVertexBuffer(pModel->GetDeformVertexCount());
|
||||
|
||||
if (pSkelLODController)
|
||||
{
|
||||
pModelInstance->SetLinkedModelPointer(pModel, m_pkSharedDeformableVertexBuffer, &pSkelLODController->m_pCurrentModelInstance);
|
||||
}
|
||||
else
|
||||
{
|
||||
pModelInstance->SetLinkedModelPointer(pModel, m_pkSharedDeformableVertexBuffer, NULL);
|
||||
}
|
||||
|
||||
// END_OF_WORK
|
||||
|
||||
if (!m_pCurrentModelInstance)
|
||||
{
|
||||
m_pCurrentModelInstance = pModelInstance;
|
||||
pModelInstance->DeformNoSkin(&ms_matIdentity);
|
||||
|
||||
D3DXVECTOR3 vtMin, vtMax;
|
||||
pModelInstance->GetBoundBox(&vtMin, &vtMax);
|
||||
|
||||
float fSize = 0.0f;
|
||||
fSize = fMAX(fSize, fabs(vtMin.x - vtMax.x));
|
||||
fSize = fMAX(fSize, fabs(vtMin.y - vtMax.y));
|
||||
fSize = fMAX(fSize, fabs(vtMin.z - vtMax.z));
|
||||
|
||||
if (fSize<LODHEIGHT_ACTOR)
|
||||
SetLODLimits(0.0f, LODDISTANCE_ACTOR);
|
||||
else
|
||||
|
||||
SetLODLimits(0.0f, LODDISTANCE_BUILDING);
|
||||
}
|
||||
else
|
||||
{
|
||||
pModelInstance->DeformNoSkin(&ms_matIdentity);
|
||||
}
|
||||
|
||||
pThing->Release();
|
||||
|
||||
m_que_pkModelInst.push_front(pModelInstance);
|
||||
}
|
||||
|
||||
void CGrannyLODController::__ReserveSharedDeformableVertexBuffer(DWORD deformableVertexCount)
|
||||
{
|
||||
if (m_pkSharedDeformableVertexBuffer &&
|
||||
m_pkSharedDeformableVertexBuffer->GetVertexCount() >= deformableVertexCount)
|
||||
return;
|
||||
|
||||
__FreeDeformVertexBuffer(m_pkSharedDeformableVertexBuffer);
|
||||
|
||||
m_pkSharedDeformableVertexBuffer = __AllocDeformVertexBuffer(deformableVertexCount);
|
||||
}
|
||||
|
||||
void CGrannyLODController::AttachModelInstance(CGrannyLODController * pSrcLODController, const char * c_szBoneName)
|
||||
{
|
||||
CGrannyModelInstance * pSrcInstance = pSrcLODController->GetModelInstance();
|
||||
if (!pSrcInstance)
|
||||
return;
|
||||
|
||||
CGrannyModelInstance * pDestInstance = GetModelInstance();
|
||||
if (pDestInstance)
|
||||
{
|
||||
pSrcInstance->SetParentModelInstance(pDestInstance, c_szBoneName);
|
||||
}
|
||||
|
||||
if (!pSrcLODController->GetModelInstance())
|
||||
return;
|
||||
|
||||
// Link Parent Data
|
||||
pSrcLODController->m_pAttachedParentModel = this;
|
||||
|
||||
// Link Child Data
|
||||
std::vector<TAttachingModelData>::iterator itor = m_AttachedModelDataVector.begin();
|
||||
for (; m_AttachedModelDataVector.end() != itor;)
|
||||
{
|
||||
TAttachingModelData & rData = *itor;
|
||||
if (pSrcLODController == rData.pkLODController)
|
||||
{
|
||||
itor = m_AttachedModelDataVector.erase(itor);
|
||||
}
|
||||
else
|
||||
{
|
||||
++itor;
|
||||
}
|
||||
}
|
||||
|
||||
TAttachingModelData AttachingModelData;
|
||||
AttachingModelData.pkLODController = pSrcLODController;
|
||||
AttachingModelData.strBoneName = c_szBoneName;
|
||||
m_AttachedModelDataVector.push_back(AttachingModelData);
|
||||
}
|
||||
|
||||
void CGrannyLODController::DetachModelInstance(CGrannyLODController * pSrcLODController)
|
||||
{
|
||||
CGrannyModelInstance * pSrcInstance = pSrcLODController->GetModelInstance();
|
||||
if (!pSrcInstance)
|
||||
return;
|
||||
|
||||
CGrannyModelInstance * pDestInstance = GetModelInstance();
|
||||
if (pDestInstance)
|
||||
{
|
||||
pSrcInstance->SetParentModelInstance(NULL, 0);
|
||||
}
|
||||
|
||||
// Unlink Child Data
|
||||
std::vector<TAttachingModelData>::iterator itor = m_AttachedModelDataVector.begin();
|
||||
for (; m_AttachedModelDataVector.end() != itor;)
|
||||
{
|
||||
TAttachingModelData & rData = *itor;
|
||||
if (pSrcLODController == rData.pkLODController)
|
||||
{
|
||||
itor = m_AttachedModelDataVector.erase(itor);
|
||||
}
|
||||
else
|
||||
{
|
||||
++itor;
|
||||
}
|
||||
}
|
||||
|
||||
// Unlink Parent Data
|
||||
pSrcLODController->m_pAttachedParentModel = NULL;
|
||||
}
|
||||
|
||||
void CGrannyLODController::SetLODLimits(float /*fNearLOD*/, float fFarLOD)
|
||||
{
|
||||
m_fLODDistance = fFarLOD;
|
||||
}
|
||||
|
||||
void CGrannyLODController::SetLODLevel(BYTE bLodLevel)
|
||||
{
|
||||
assert(m_que_pkModelInst.size() > 0);
|
||||
|
||||
if (m_que_pkModelInst.size() > 0)
|
||||
m_bLODLevel = (BYTE) MIN(m_que_pkModelInst.size() - 1, bLodLevel);
|
||||
}
|
||||
|
||||
void CGrannyLODController::CreateDeviceObjects()
|
||||
{
|
||||
std::for_each(m_que_pkModelInst.begin(),
|
||||
m_que_pkModelInst.end(),
|
||||
CGrannyModelInstance::FCreateDeviceObjects());
|
||||
}
|
||||
|
||||
void CGrannyLODController::DestroyDeviceObjects()
|
||||
{
|
||||
std::for_each(m_que_pkModelInst.begin(),
|
||||
m_que_pkModelInst.end(),
|
||||
CGrannyModelInstance::FDestroyDeviceObjects());
|
||||
}
|
||||
|
||||
void CGrannyLODController::RenderWithOneTexture()
|
||||
{
|
||||
assert(m_pCurrentModelInstance != NULL);
|
||||
|
||||
//#define CHECK_LOD
|
||||
#ifdef CHECK_LOD
|
||||
if (m_que_pkModelInst.size() > 0 && m_pCurrentModelInstance == m_que_pkModelInst[0])
|
||||
m_pCurrentModelInstance->RenderWithoutTexture();
|
||||
|
||||
if (m_que_pkModelInst.size() > 1 && m_pCurrentModelInstance == m_que_pkModelInst[1])
|
||||
m_pCurrentModelInstance->RenderWithOneTexture();
|
||||
|
||||
if (m_que_pkModelInst.size() > 2 && m_pCurrentModelInstance == m_que_pkModelInst[2])
|
||||
m_pCurrentModelInstance->RenderWithOneTexture();
|
||||
|
||||
if (m_que_pkModelInst.size() > 3 && m_pCurrentModelInstance == m_que_pkModelInst[3])
|
||||
m_pCurrentModelInstance->RenderWithOneTexture();
|
||||
|
||||
#else
|
||||
m_pCurrentModelInstance->RenderWithOneTexture();
|
||||
#endif
|
||||
}
|
||||
|
||||
void CGrannyLODController::BlendRenderWithOneTexture()
|
||||
{
|
||||
assert(m_pCurrentModelInstance != NULL);
|
||||
m_pCurrentModelInstance->BlendRenderWithOneTexture();
|
||||
}
|
||||
|
||||
void CGrannyLODController::RenderWithTwoTexture()
|
||||
{
|
||||
assert(m_pCurrentModelInstance != NULL);
|
||||
m_pCurrentModelInstance->RenderWithTwoTexture();
|
||||
}
|
||||
|
||||
void CGrannyLODController::BlendRenderWithTwoTexture()
|
||||
{
|
||||
assert(m_pCurrentModelInstance != NULL);
|
||||
m_pCurrentModelInstance->BlendRenderWithTwoTexture();
|
||||
}
|
||||
|
||||
void CGrannyLODController::Update(float fElapsedTime, float fDistanceFromCenter, float fDistanceFromCamera)
|
||||
{
|
||||
UpdateLODLevel(fDistanceFromCenter, fDistanceFromCamera);
|
||||
UpdateTime(fElapsedTime);
|
||||
}
|
||||
|
||||
void CGrannyLODController::UpdateLODLevel(float fDistanceFromCenter, float fDistanceFromCamera)
|
||||
{
|
||||
if (m_que_pkModelInst.size()<=1)
|
||||
return;
|
||||
|
||||
assert(m_pCurrentModelInstance != NULL);
|
||||
|
||||
if (fDistanceFromCenter > LOD_APPLY_MIN)
|
||||
{
|
||||
// 100fps 50fps 33fps 25fps 20fps
|
||||
// 10ms 20ms 30ms 40ms 50ms
|
||||
float fLODFactor = fMINMAX(0.0f, (m_fLODDistance-fDistanceFromCamera), m_fLODDistance);
|
||||
|
||||
if (m_fLODDistance>0.0f)
|
||||
m_dwLODAniFPS = (DWORD) ((CGrannyModelInstance::ANIFPS_MAX - CGrannyModelInstance::ANIFPS_MIN) * fLODFactor / m_fLODDistance + CGrannyModelInstance::ANIFPS_MIN);
|
||||
else
|
||||
m_dwLODAniFPS = CGrannyModelInstance::ANIFPS_MIN;
|
||||
|
||||
assert(m_dwLODAniFPS > 0);
|
||||
m_dwLODAniFPS /= 10;
|
||||
m_dwLODAniFPS *= 10;
|
||||
|
||||
float fLODStep = m_fLODDistance / m_que_pkModelInst.size();
|
||||
BYTE bLODLevel = BYTE(fLODFactor / fLODStep);
|
||||
|
||||
if (m_fLODDistance <= 5000.0f)
|
||||
{
|
||||
if (fDistanceFromCamera < 500.0f)
|
||||
{
|
||||
bLODLevel = 0;
|
||||
}
|
||||
else if (fDistanceFromCamera < 1500.0f)
|
||||
{
|
||||
bLODLevel = 1;
|
||||
}
|
||||
else if (fDistanceFromCamera < 2500.0f)
|
||||
{
|
||||
bLODLevel = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
bLODLevel = 3;
|
||||
}
|
||||
|
||||
bLODLevel = (BYTE) (m_que_pkModelInst.size() - min(bLODLevel, m_que_pkModelInst.size()) - 1);
|
||||
}
|
||||
|
||||
if (ms_isMinLODModeEnable)
|
||||
bLODLevel=0;
|
||||
|
||||
SetLODLevel(bLODLevel);
|
||||
|
||||
if (m_pCurrentModelInstance != m_que_pkModelInst[m_bLODLevel])
|
||||
{
|
||||
SetCurrentModelInstance(m_que_pkModelInst[m_bLODLevel]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_dwLODAniFPS=CGrannyModelInstance::ANIFPS_MAX;
|
||||
|
||||
if (!m_que_pkModelInst.empty())
|
||||
{
|
||||
if (m_pCurrentModelInstance != m_que_pkModelInst.back())
|
||||
{
|
||||
SetCurrentModelInstance(m_que_pkModelInst.back());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGrannyLODController::UpdateTime(float fElapsedTime)
|
||||
{
|
||||
assert(m_pCurrentModelInstance != NULL);
|
||||
|
||||
m_pCurrentModelInstance->Update(m_dwLODAniFPS);
|
||||
|
||||
//DWORD t3=timeGetTime();
|
||||
m_pCurrentModelInstance->UpdateLocalTime(fElapsedTime);
|
||||
|
||||
//DWORD t4=timeGetTime();
|
||||
|
||||
#ifdef __PERFORMANCE_CHECKER__
|
||||
{
|
||||
static FILE* fp=fopen("perf_lod_update.txt", "w");
|
||||
|
||||
if (t4-t1>3)
|
||||
{
|
||||
fprintf(fp, "LOD.Total %d (Time %f)\n", t4-t1, timeGetTime()/1000.0f);
|
||||
fprintf(fp, "LOD.SMI %d\n", t2-t1);
|
||||
fprintf(fp, "LOD.UP %d\n", t3-t2);
|
||||
fprintf(fp, "LOD.UL %d\n", t4-t3);
|
||||
fprintf(fp, "-------------------------------- \n");
|
||||
fflush(fp);
|
||||
}
|
||||
fflush(fp);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void CGrannyLODController::SetCurrentModelInstance(CGrannyModelInstance * pgrnModelInstance)
|
||||
{
|
||||
// Copy Motion
|
||||
pgrnModelInstance->CopyMotion(m_pCurrentModelInstance, true);
|
||||
m_pCurrentModelInstance = pgrnModelInstance;
|
||||
|
||||
// Change children attaching link
|
||||
RefreshAttachedModelInstance();
|
||||
|
||||
// Change parent attaching link
|
||||
if (m_pAttachedParentModel)
|
||||
{
|
||||
m_pAttachedParentModel->RefreshAttachedModelInstance();
|
||||
}
|
||||
}
|
||||
|
||||
void CGrannyLODController::RefreshAttachedModelInstance()
|
||||
{
|
||||
if (!m_pCurrentModelInstance)
|
||||
return;
|
||||
|
||||
for (DWORD i = 0; i < m_AttachedModelDataVector.size(); ++i)
|
||||
{
|
||||
TAttachingModelData & rModelData = m_AttachedModelDataVector[i];
|
||||
|
||||
CGrannyModelInstance * pSrcInstance = rModelData.pkLODController->GetModelInstance();
|
||||
if (!pSrcInstance)
|
||||
{
|
||||
Tracenf("CGrannyLODController::RefreshAttachedModelInstance : m_AttachedModelDataVector[%d]->pkLODController->GetModelIntance()==NULL", i);
|
||||
continue;
|
||||
}
|
||||
|
||||
pSrcInstance->SetParentModelInstance(m_pCurrentModelInstance, rModelData.strBoneName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void CGrannyLODController::UpdateSkeleton(const D3DXMATRIX * c_pWorldMatrix, float fElapsedTime)
|
||||
{
|
||||
if (m_pCurrentModelInstance)
|
||||
m_pCurrentModelInstance->UpdateSkeleton(c_pWorldMatrix, fElapsedTime);
|
||||
}
|
||||
|
||||
void CGrannyLODController::DeformAll(const D3DXMATRIX * c_pWorldMatrix)
|
||||
{
|
||||
std::deque<CGrannyModelInstance *>::iterator i;
|
||||
for (i=m_que_pkModelInst.begin(); i!=m_que_pkModelInst.end(); ++i)
|
||||
{
|
||||
CGrannyModelInstance* pkModelInst=(*i);
|
||||
pkModelInst->Deform(c_pWorldMatrix);
|
||||
}
|
||||
}
|
||||
|
||||
void CGrannyLODController::DeformNoSkin(const D3DXMATRIX * c_pWorldMatrix)
|
||||
{
|
||||
if (m_pCurrentModelInstance)
|
||||
m_pCurrentModelInstance->DeformNoSkin(c_pWorldMatrix);
|
||||
}
|
||||
|
||||
void CGrannyLODController::Deform(const D3DXMATRIX * c_pWorldMatrix)
|
||||
{
|
||||
if (m_pCurrentModelInstance)
|
||||
m_pCurrentModelInstance->Deform(c_pWorldMatrix);
|
||||
}
|
||||
|
||||
void CGrannyLODController::RenderToShadowMap()
|
||||
{
|
||||
if (m_pCurrentModelInstance)
|
||||
m_pCurrentModelInstance->RenderWithoutTexture();
|
||||
}
|
||||
|
||||
void CGrannyLODController::RenderShadow()
|
||||
{
|
||||
if (m_pCurrentModelInstance)
|
||||
m_pCurrentModelInstance->RenderWithOneTexture();
|
||||
}
|
||||
|
||||
void CGrannyLODController::ReloadTexture()
|
||||
{
|
||||
if (m_pCurrentModelInstance)
|
||||
m_pCurrentModelInstance->ReloadTexture();
|
||||
}
|
||||
|
||||
void CGrannyLODController::GetBoundBox(D3DXVECTOR3 * vtMin, D3DXVECTOR3 * vtMax)
|
||||
{
|
||||
if (m_pCurrentModelInstance)
|
||||
m_pCurrentModelInstance->GetBoundBox(vtMin, vtMax);
|
||||
}
|
||||
|
||||
bool CGrannyLODController::Intersect(const D3DXMATRIX * c_pMatrix, float * u, float * v, float * t)
|
||||
{
|
||||
if (!m_pCurrentModelInstance)
|
||||
return false;
|
||||
return m_pCurrentModelInstance->Intersect(c_pMatrix, u, v, t);
|
||||
}
|
||||
|
||||
void CGrannyLODController::SetLocalTime(float fLocalTime)
|
||||
{
|
||||
if (m_pCurrentModelInstance)
|
||||
m_pCurrentModelInstance->SetLocalTime(fLocalTime);
|
||||
}
|
||||
|
||||
void CGrannyLODController::ResetLocalTime()
|
||||
{
|
||||
assert(m_pCurrentModelInstance != NULL);
|
||||
m_pCurrentModelInstance->ResetLocalTime();
|
||||
}
|
||||
|
||||
void CGrannyLODController::SetMotionPointer(const CGrannyMotion * c_pMotion, float fBlendTime, int iLoopCount, float speedRatio)
|
||||
{
|
||||
assert(m_pCurrentModelInstance != NULL);
|
||||
m_pCurrentModelInstance->SetMotionPointer(c_pMotion, fBlendTime, iLoopCount, speedRatio);
|
||||
}
|
||||
|
||||
void CGrannyLODController::ChangeMotionPointer(const CGrannyMotion * c_pMotion, int iLoopCount, float speedRatio)
|
||||
{
|
||||
assert(m_pCurrentModelInstance != NULL);
|
||||
m_pCurrentModelInstance->ChangeMotionPointer(c_pMotion, iLoopCount, speedRatio);
|
||||
}
|
||||
|
||||
void CGrannyLODController::SetMotionAtEnd()
|
||||
{
|
||||
if (m_pCurrentModelInstance)
|
||||
m_pCurrentModelInstance->SetMotionAtEnd();
|
||||
}
|
||||
|
||||
BOOL CGrannyLODController::isModelInstance()
|
||||
{
|
||||
if (!m_pCurrentModelInstance)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
CGrannyModelInstance * CGrannyLODController::GetModelInstance()
|
||||
{
|
||||
return m_pCurrentModelInstance;
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
305
source-client/Srcs/Client/EterGrnLib/LODController.h
Normal file
305
source-client/Srcs/Client/EterGrnLib/LODController.h
Normal file
@ -0,0 +1,305 @@
|
||||
#pragma once
|
||||
|
||||
#pragma warning(disable:4786)
|
||||
|
||||
#include <deque>
|
||||
#include "Thing.h"
|
||||
#include "ModelInstance.h"
|
||||
|
||||
class CGrannyLODController : public CGraphicBase
|
||||
{
|
||||
public:
|
||||
static void SetMinLODMode(bool isEnable);
|
||||
|
||||
public:
|
||||
struct FSetLocalTime
|
||||
{
|
||||
float fLocalTime;
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
pController->SetLocalTime(fLocalTime);
|
||||
}
|
||||
};
|
||||
|
||||
struct FUpdateTime
|
||||
{
|
||||
float fElapsedTime;
|
||||
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->UpdateTime(fElapsedTime);
|
||||
}
|
||||
};
|
||||
|
||||
struct FUpdateLODLevel
|
||||
{
|
||||
float fDistanceFromCenter;
|
||||
float fDistanceFromCamera;
|
||||
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->UpdateLODLevel(fDistanceFromCenter, fDistanceFromCamera);
|
||||
}
|
||||
};
|
||||
|
||||
struct FRenderWithOneTexture
|
||||
{
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->RenderWithOneTexture();
|
||||
}
|
||||
};
|
||||
|
||||
struct FBlendRenderWithOneTexture
|
||||
{
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->BlendRenderWithOneTexture();
|
||||
}
|
||||
};
|
||||
|
||||
struct FRenderWithTwoTexture
|
||||
{
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->RenderWithTwoTexture();
|
||||
}
|
||||
};
|
||||
|
||||
struct FBlendRenderWithTwoTexture
|
||||
{
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->BlendRenderWithTwoTexture();
|
||||
}
|
||||
};
|
||||
|
||||
struct FRenderToShadowMap
|
||||
{
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->RenderToShadowMap();
|
||||
}
|
||||
};
|
||||
|
||||
struct FRenderShadow
|
||||
{
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->RenderShadow();
|
||||
}
|
||||
};
|
||||
|
||||
struct FDeform
|
||||
{
|
||||
const D3DXMATRIX * mc_pWorldMatrix;
|
||||
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->Deform(mc_pWorldMatrix);
|
||||
}
|
||||
};
|
||||
struct FDeformNoSkin
|
||||
{
|
||||
const D3DXMATRIX * mc_pWorldMatrix;
|
||||
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->DeformNoSkin(mc_pWorldMatrix);
|
||||
}
|
||||
};
|
||||
struct FDeformAll
|
||||
{
|
||||
const D3DXMATRIX * mc_pWorldMatrix;
|
||||
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->DeformAll(mc_pWorldMatrix);
|
||||
}
|
||||
};
|
||||
|
||||
struct FCreateDeviceObjects
|
||||
{
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->CreateDeviceObjects();
|
||||
}
|
||||
};
|
||||
|
||||
struct FDestroyDeviceObjects
|
||||
{
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->DestroyDeviceObjects();
|
||||
}
|
||||
};
|
||||
|
||||
struct FBoundBox
|
||||
{
|
||||
D3DXVECTOR3* m_vtMin;
|
||||
D3DXVECTOR3* m_vtMax;
|
||||
|
||||
FBoundBox(D3DXVECTOR3 * vtMin, D3DXVECTOR3 * vtMax)
|
||||
{
|
||||
m_vtMin = vtMin;
|
||||
m_vtMax = vtMax;
|
||||
}
|
||||
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->GetBoundBox(m_vtMin, m_vtMax);
|
||||
}
|
||||
};
|
||||
|
||||
struct FResetLocalTime
|
||||
{
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->ResetLocalTime();
|
||||
}
|
||||
};
|
||||
|
||||
struct FReloadTexture
|
||||
{
|
||||
void operator () (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->ReloadTexture();
|
||||
}
|
||||
};
|
||||
|
||||
struct FSetMotionPointer
|
||||
{
|
||||
const CGrannyMotion * m_pMotion;
|
||||
float m_speedRatio;
|
||||
float m_blendTime;
|
||||
int m_loopCount;
|
||||
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->SetMotionPointer(m_pMotion, m_blendTime, m_loopCount, m_speedRatio);
|
||||
}
|
||||
};
|
||||
|
||||
struct FChangeMotionPointer
|
||||
{
|
||||
const CGrannyMotion * m_pMotion;
|
||||
float m_speedRatio;
|
||||
int m_loopCount;
|
||||
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->ChangeMotionPointer(m_pMotion, m_loopCount, m_speedRatio);
|
||||
}
|
||||
};
|
||||
|
||||
struct FEndStopMotionPointer
|
||||
{
|
||||
const CGrannyMotion * m_pMotion;
|
||||
|
||||
void operator () (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->SetMotionAtEnd();
|
||||
}
|
||||
};
|
||||
|
||||
CGrannyLODController();
|
||||
virtual ~CGrannyLODController();
|
||||
|
||||
void Clear();
|
||||
|
||||
void CreateDeviceObjects();
|
||||
void DestroyDeviceObjects();
|
||||
|
||||
void AddModel(CGraphicThing * pThing, int iSrcModel, CGrannyLODController * pSkelLODController=NULL);
|
||||
void AttachModelInstance(CGrannyLODController * pSrcLODController, const char * c_szBoneName);
|
||||
void DetachModelInstance(CGrannyLODController * pSrcLODController);
|
||||
void SetLODLimits(float fNearLOD, float fFarLOD);
|
||||
void SetLODLevel(BYTE bLODLevel);
|
||||
BYTE GetLODLevel() { return m_bLODLevel; }
|
||||
void SetMaterialImagePointer(const char* c_szImageName, CGraphicImage* pImage);
|
||||
void SetMaterialData(const char* c_szImageName, const SMaterialData& c_rkMaterialData);
|
||||
void SetSpecularInfo(const char* c_szMtrlName, BOOL bEnable, float fPower);
|
||||
|
||||
void RenderWithOneTexture();
|
||||
void RenderWithTwoTexture();
|
||||
void BlendRenderWithOneTexture();
|
||||
void BlendRenderWithTwoTexture();
|
||||
|
||||
void Update(float fElapsedTime, float fDistanceFromCenter, float fDistanceFromCamera);
|
||||
void UpdateLODLevel(float fDistanceFromCenter, float fDistanceFromCamera);
|
||||
void UpdateTime(float fElapsedTime);
|
||||
|
||||
void UpdateSkeleton(const D3DXMATRIX * c_pWorldMatrix, float fElapsedTime);
|
||||
void Deform(const D3DXMATRIX * c_pWorldMatrix);
|
||||
void DeformNoSkin(const D3DXMATRIX * c_pWorldMatrix);
|
||||
void DeformAll(const D3DXMATRIX * c_pWorldMatrix);
|
||||
|
||||
void RenderToShadowMap();
|
||||
void RenderShadow();
|
||||
void ReloadTexture();
|
||||
|
||||
void GetBoundBox(D3DXVECTOR3 * vtMin, D3DXVECTOR3 * vtMax);
|
||||
bool Intersect(const D3DXMATRIX * c_pMatrix, float * u, float * v, float * t);
|
||||
|
||||
void SetLocalTime(float fLocalTime);
|
||||
void ResetLocalTime();
|
||||
|
||||
void SetMotionPointer(const CGrannyMotion * c_pMotion, float fBlendTime, int iLoopCount, float speedRatio);
|
||||
void ChangeMotionPointer(const CGrannyMotion * c_pMotion, int iLoopCount, float speedRatio);
|
||||
void SetMotionAtEnd();
|
||||
|
||||
BOOL isModelInstance();
|
||||
CGrannyModelInstance* GetModelInstance();
|
||||
bool HaveBlendThing() { return 0 != GetModelInstance() ? GetModelInstance()->HaveBlendThing() : false; }
|
||||
|
||||
protected:
|
||||
void SetCurrentModelInstance(CGrannyModelInstance * pgrnModelInstance);
|
||||
void RefreshAttachedModelInstance();
|
||||
|
||||
void __ReserveSharedDeformableVertexBuffer(DWORD deformableVertexCount);
|
||||
|
||||
protected:
|
||||
float m_fLODDistance;
|
||||
DWORD m_dwLODAniFPS;
|
||||
|
||||
//// Attaching Link Data
|
||||
// Data of Parent Side
|
||||
typedef struct SAttachingModelData
|
||||
{
|
||||
CGrannyLODController * pkLODController;
|
||||
std::string strBoneName;
|
||||
} TAttachingModelData;
|
||||
|
||||
std::vector<TAttachingModelData> m_AttachedModelDataVector;
|
||||
// Data of Child Side
|
||||
CGrannyLODController * m_pAttachedParentModel;
|
||||
|
||||
BYTE m_bLODLevel;
|
||||
CGrannyModelInstance * m_pCurrentModelInstance;
|
||||
|
||||
// WORK
|
||||
std::deque<CGrannyModelInstance *> m_que_pkModelInst;
|
||||
|
||||
CGraphicVertexBuffer* m_pkSharedDeformableVertexBuffer;
|
||||
// END_OF_WORK
|
||||
};
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
518
source-client/Srcs/Client/EterGrnLib/Material.cpp
Normal file
518
source-client/Srcs/Client/EterGrnLib/Material.cpp
Normal file
@ -0,0 +1,518 @@
|
||||
#include "StdAfx.h"
|
||||
#include "Material.h"
|
||||
#include "Mesh.h"
|
||||
#include "../eterbase/Filename.h"
|
||||
#include "../eterlib/ResourceManager.h"
|
||||
#include "../eterlib/StateManager.h"
|
||||
#include "../eterlib/GrpScreen.h"
|
||||
|
||||
CGraphicImageInstance CGrannyMaterial::ms_akSphereMapInstance[SPHEREMAP_NUM];
|
||||
|
||||
D3DXVECTOR3 CGrannyMaterial::ms_v3SpecularTrans(0.0f, 0.0f, 0.0f);
|
||||
D3DXMATRIX CGrannyMaterial::ms_matSpecular;
|
||||
|
||||
D3DXCOLOR g_fSpecularColor = D3DXCOLOR(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
void CGrannyMaterial::TranslateSpecularMatrix(float fAddX, float fAddY, float fAddZ)
|
||||
{
|
||||
static float SPECULAR_TRANSLATE_MAX = 1000000.0f;
|
||||
|
||||
ms_v3SpecularTrans.x+=fAddX;
|
||||
ms_v3SpecularTrans.y+=fAddY;
|
||||
ms_v3SpecularTrans.z+=fAddZ;
|
||||
|
||||
if (ms_v3SpecularTrans.x>=SPECULAR_TRANSLATE_MAX)
|
||||
ms_v3SpecularTrans.x=0.0f;
|
||||
|
||||
if (ms_v3SpecularTrans.y>=SPECULAR_TRANSLATE_MAX)
|
||||
ms_v3SpecularTrans.y=0.0f;
|
||||
|
||||
if (ms_v3SpecularTrans.z>=SPECULAR_TRANSLATE_MAX)
|
||||
ms_v3SpecularTrans.z=0.0f;
|
||||
|
||||
D3DXMatrixTranslation(&ms_matSpecular,
|
||||
ms_v3SpecularTrans.x,
|
||||
ms_v3SpecularTrans.y,
|
||||
ms_v3SpecularTrans.z
|
||||
);
|
||||
}
|
||||
|
||||
void CGrannyMaterial::ApplyRenderState()
|
||||
{
|
||||
assert(m_pfnApplyRenderState!=NULL && "CGrannyMaterial::SaveRenderState");
|
||||
(this->*m_pfnApplyRenderState)();
|
||||
}
|
||||
|
||||
void CGrannyMaterial::RestoreRenderState()
|
||||
{
|
||||
assert(m_pfnRestoreRenderState!=NULL && "CGrannyMaterial::RestoreRenderState");
|
||||
(this->*m_pfnRestoreRenderState)();
|
||||
}
|
||||
|
||||
void CGrannyMaterial::Copy(CGrannyMaterial& rkMtrl)
|
||||
{
|
||||
m_pgrnMaterial = rkMtrl.m_pgrnMaterial;
|
||||
m_roImage[0] = rkMtrl.m_roImage[0];
|
||||
m_roImage[1] = rkMtrl.m_roImage[1];
|
||||
m_eType = rkMtrl.m_eType;
|
||||
}
|
||||
|
||||
CGrannyMaterial::CGrannyMaterial()
|
||||
{
|
||||
m_bTwoSideRender = false;
|
||||
m_dwLastCullRenderStateForTwoSideRendering = D3DCULL_CW;
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
CGrannyMaterial::~CGrannyMaterial()
|
||||
{
|
||||
}
|
||||
|
||||
CGrannyMaterial::EType CGrannyMaterial::GetType() const
|
||||
{
|
||||
return m_eType;
|
||||
}
|
||||
|
||||
void CGrannyMaterial::SetImagePointer(int iStage, CGraphicImage* pImage)
|
||||
{
|
||||
assert(iStage<2 && "CGrannyMaterial::SetImagePointer");
|
||||
m_roImage[iStage]=pImage;
|
||||
}
|
||||
|
||||
bool CGrannyMaterial::IsIn(const char* c_szImageName, int* piStage)
|
||||
{
|
||||
std::string strImageName = c_szImageName;
|
||||
CFileNameHelper::StringPath(strImageName);
|
||||
|
||||
granny_texture * pgrnDiffuseTexture = GrannyGetMaterialTextureByType(m_pgrnMaterial, GrannyDiffuseColorTexture);
|
||||
if (pgrnDiffuseTexture)
|
||||
{
|
||||
std::string strDiffuseFileName = pgrnDiffuseTexture->FromFileName;
|
||||
CFileNameHelper::StringPath(strDiffuseFileName);
|
||||
if (strDiffuseFileName == strImageName)
|
||||
{
|
||||
*piStage=0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
granny_texture * pgrnOpacityTexture = GrannyGetMaterialTextureByType(m_pgrnMaterial, GrannyOpacityTexture);
|
||||
if (pgrnOpacityTexture)
|
||||
{
|
||||
std::string strOpacityFileName = pgrnOpacityTexture->FromFileName;
|
||||
CFileNameHelper::StringPath(strOpacityFileName);
|
||||
if (strOpacityFileName == strImageName)
|
||||
{
|
||||
*piStage=1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CGrannyMaterial::SetSpecularInfo(BOOL bFlag, float fPower, BYTE uSphereMapIndex)
|
||||
{
|
||||
m_fSpecularPower = fPower;
|
||||
m_bSphereMapIndex = uSphereMapIndex;
|
||||
m_bSpecularEnable = bFlag;
|
||||
|
||||
if (bFlag)
|
||||
{
|
||||
m_pfnApplyRenderState = &CGrannyMaterial::__ApplySpecularRenderState;
|
||||
m_pfnRestoreRenderState = &CGrannyMaterial::__RestoreSpecularRenderState;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pfnApplyRenderState = &CGrannyMaterial::__ApplyDiffuseRenderState;
|
||||
m_pfnRestoreRenderState = &CGrannyMaterial::__RestoreDiffuseRenderState;
|
||||
}
|
||||
}
|
||||
|
||||
bool CGrannyMaterial::IsEqual(granny_material* pgrnMaterial) const
|
||||
{
|
||||
if (m_pgrnMaterial==pgrnMaterial)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
LPDIRECT3DTEXTURE8 CGrannyMaterial::GetD3DTexture(int iStage) const
|
||||
{
|
||||
const CGraphicImage::TRef & ratImage = m_roImage[iStage];
|
||||
|
||||
if (ratImage.IsNull())
|
||||
return NULL;
|
||||
|
||||
CGraphicImage * pImage = ratImage.GetPointer();
|
||||
const CGraphicTexture * pTexture = pImage->GetTexturePointer();
|
||||
return pTexture->GetD3DTexture();
|
||||
}
|
||||
|
||||
CGraphicImage * CGrannyMaterial::GetImagePointer(int iStage) const
|
||||
{
|
||||
const CGraphicImage::TRef & ratImage = m_roImage[iStage];
|
||||
|
||||
if (ratImage.IsNull())
|
||||
return NULL;
|
||||
|
||||
CGraphicImage * pImage = ratImage.GetPointer();
|
||||
return pImage;
|
||||
}
|
||||
|
||||
const CGraphicTexture* CGrannyMaterial::GetDiffuseTexture() const
|
||||
{
|
||||
if (m_roImage[0].IsNull())
|
||||
return NULL;
|
||||
|
||||
return m_roImage[0].GetPointer()->GetTexturePointer();
|
||||
}
|
||||
|
||||
const CGraphicTexture* CGrannyMaterial::GetOpacityTexture() const
|
||||
{
|
||||
if (m_roImage[1].IsNull())
|
||||
return NULL;
|
||||
|
||||
return m_roImage[1].GetPointer()->GetTexturePointer();
|
||||
}
|
||||
|
||||
BOOL CGrannyMaterial::__IsSpecularEnable() const
|
||||
{
|
||||
return m_bSpecularEnable;
|
||||
}
|
||||
|
||||
float CGrannyMaterial::__GetSpecularPower() const
|
||||
{
|
||||
return m_fSpecularPower;
|
||||
}
|
||||
|
||||
extern const std::string& GetModelLocalPath();
|
||||
|
||||
CGraphicImage* CGrannyMaterial::__GetImagePointer(const char* fileName)
|
||||
{
|
||||
assert(*fileName != '\0');
|
||||
|
||||
CResourceManager& rkResMgr = CResourceManager::Instance();
|
||||
|
||||
// SUPPORT_LOCAL_TEXTURE
|
||||
int fileName_len = strlen(fileName);
|
||||
if (fileName_len > 2 && fileName[1] != ':')
|
||||
{
|
||||
char localFileName[256];
|
||||
const std::string& modelLocalPath = GetModelLocalPath();
|
||||
|
||||
int localFileName_len = modelLocalPath.length() + 1 + fileName_len;
|
||||
if (localFileName_len < sizeof(localFileName) - 1)
|
||||
{
|
||||
_snprintf(localFileName, sizeof(localFileName), "%s%s", GetModelLocalPath().c_str(), fileName);
|
||||
CResource* pResource = rkResMgr.GetResourcePointer(localFileName);
|
||||
return static_cast<CGraphicImage*>(pResource);
|
||||
}
|
||||
}
|
||||
// END_OF_SUPPORT_LOCAL_TEXTURE
|
||||
|
||||
CResource* pResource = rkResMgr.GetResourcePointer(fileName);
|
||||
return static_cast<CGraphicImage*>(pResource);
|
||||
}
|
||||
|
||||
bool CGrannyMaterial::CreateFromGrannyMaterialPointer(granny_material * pgrnMaterial)
|
||||
{
|
||||
m_pgrnMaterial = pgrnMaterial;
|
||||
|
||||
granny_texture * pgrnDiffuseTexture = NULL;
|
||||
granny_texture * pgrnOpacityTexture = NULL;
|
||||
|
||||
if (pgrnMaterial)
|
||||
{
|
||||
if (pgrnMaterial->MapCount > 1 && !_strnicmp(pgrnMaterial->Name, "Blend", 5))
|
||||
{
|
||||
pgrnDiffuseTexture = GrannyGetMaterialTextureByType(pgrnMaterial->Maps[0].Material, GrannyDiffuseColorTexture);
|
||||
pgrnOpacityTexture = GrannyGetMaterialTextureByType(pgrnMaterial->Maps[1].Material, GrannyDiffuseColorTexture);
|
||||
}
|
||||
else
|
||||
{
|
||||
pgrnDiffuseTexture = GrannyGetMaterialTextureByType(m_pgrnMaterial, GrannyDiffuseColorTexture);
|
||||
pgrnOpacityTexture = GrannyGetMaterialTextureByType(m_pgrnMaterial, GrannyOpacityTexture);
|
||||
}
|
||||
|
||||
{
|
||||
granny_int32 twoSided = 0;
|
||||
granny_data_type_definition TwoSidedFieldType[] =
|
||||
{
|
||||
{GrannyInt32Member, "Two-sided"},
|
||||
{GrannyEndMember},
|
||||
};
|
||||
#if GrannyProductMinorVersion==4
|
||||
granny_variant twoSideResult = GrannyFindMatchingMember(pgrnMaterial->ExtendedData.Type, pgrnMaterial->ExtendedData.Object, "Two-sided");
|
||||
|
||||
if (NULL != twoSideResult.Type)
|
||||
GrannyConvertSingleObject(twoSideResult.Type, twoSideResult.Object, TwoSidedFieldType, &twoSided);
|
||||
#elif GrannyProductMinorVersion==7
|
||||
granny_variant twoSideResult;
|
||||
bool findMatchResult = GrannyFindMatchingMember(pgrnMaterial->ExtendedData.Type, pgrnMaterial->ExtendedData.Object, "Two-sided", &twoSideResult);
|
||||
if (NULL != twoSideResult.Type && findMatchResult)
|
||||
GrannyConvertSingleObject(twoSideResult.Type, twoSideResult.Object, TwoSidedFieldType, &twoSided);
|
||||
#elif GrannyProductMinorVersion==11 || GrannyProductMinorVersion==9 || GrannyProductMinorVersion==8
|
||||
granny_variant twoSideResult;
|
||||
bool gfmm_bool = GrannyFindMatchingMember(pgrnMaterial->ExtendedData.Type, pgrnMaterial->ExtendedData.Object, "Two-sided", &twoSideResult);
|
||||
if (NULL != twoSideResult.Type)
|
||||
GrannyConvertSingleObject(twoSideResult.Type, twoSideResult.Object, TwoSidedFieldType, &twoSided, 0);
|
||||
#else
|
||||
#error "unknown granny version"
|
||||
#endif
|
||||
|
||||
m_bTwoSideRender = 1 == twoSided;
|
||||
}
|
||||
}
|
||||
|
||||
if (pgrnDiffuseTexture)
|
||||
m_roImage[0].SetPointer(__GetImagePointer(pgrnDiffuseTexture->FromFileName));
|
||||
|
||||
if (pgrnOpacityTexture)
|
||||
m_roImage[1].SetPointer(__GetImagePointer(pgrnOpacityTexture->FromFileName));
|
||||
|
||||
if (!m_roImage[1].IsNull())
|
||||
m_eType = TYPE_BLEND_PNT;
|
||||
else
|
||||
m_eType = TYPE_DIFFUSE_PNT;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGrannyMaterial::Initialize()
|
||||
{
|
||||
m_roImage[0] = NULL;
|
||||
m_roImage[1] = NULL;
|
||||
|
||||
SetSpecularInfo(FALSE, 0.0f, 0);
|
||||
}
|
||||
|
||||
void CGrannyMaterial::__ApplyDiffuseRenderState()
|
||||
{
|
||||
STATEMANAGER.SetTexture(0, GetD3DTexture(0));
|
||||
|
||||
if (m_bTwoSideRender)
|
||||
{
|
||||
m_dwLastCullRenderStateForTwoSideRendering = STATEMANAGER.GetRenderState(D3DRS_CULLMODE);
|
||||
STATEMANAGER.SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
void CGrannyMaterial::__RestoreDiffuseRenderState()
|
||||
{
|
||||
if (m_bTwoSideRender)
|
||||
{
|
||||
STATEMANAGER.SetRenderState(D3DRS_CULLMODE, m_dwLastCullRenderStateForTwoSideRendering);
|
||||
}
|
||||
}
|
||||
|
||||
void CGrannyMaterial::__ApplySpecularRenderState()
|
||||
{
|
||||
if (TRUE == STATEMANAGER.GetRenderState(D3DRS_ALPHABLENDENABLE))
|
||||
{
|
||||
__ApplyDiffuseRenderState();
|
||||
return;
|
||||
}
|
||||
|
||||
CGraphicTexture* pkTexture=ms_akSphereMapInstance[m_bSphereMapIndex].GetTexturePointer();
|
||||
|
||||
STATEMANAGER.SetTexture(0, GetD3DTexture(0));
|
||||
|
||||
if (pkTexture)
|
||||
STATEMANAGER.SetTexture(1, pkTexture->GetD3DTexture());
|
||||
else
|
||||
STATEMANAGER.SetTexture(1, NULL);
|
||||
|
||||
STATEMANAGER.SetRenderState(D3DRS_TEXTUREFACTOR, D3DXCOLOR(g_fSpecularColor.r, g_fSpecularColor.g, g_fSpecularColor.b, __GetSpecularPower()));
|
||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR);
|
||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
|
||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TFACTOR);
|
||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||
|
||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_CURRENT);
|
||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_TEXTURE);
|
||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATEALPHA_ADDCOLOR);
|
||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_CURRENT);
|
||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||
|
||||
STATEMANAGER.SetTransform(D3DTS_TEXTURE1, &ms_matSpecular);
|
||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
|
||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
|
||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
|
||||
}
|
||||
|
||||
void CGrannyMaterial::__RestoreSpecularRenderState()
|
||||
{
|
||||
if (TRUE == STATEMANAGER.GetRenderState(D3DRS_ALPHABLENDENABLE))
|
||||
{
|
||||
__RestoreDiffuseRenderState();
|
||||
return;
|
||||
}
|
||||
|
||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS);
|
||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_ADDRESSU);
|
||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_ADDRESSV);
|
||||
|
||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_TEXCOORDINDEX);
|
||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||
|
||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_COLORARG1);
|
||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_COLORARG2);
|
||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_COLOROP);
|
||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ALPHAARG1);
|
||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ALPHAARG2);
|
||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ALPHAOP);
|
||||
}
|
||||
|
||||
void CGrannyMaterial::CreateSphereMap(UINT uMapIndex, const char* c_szSphereMapImageFileName)
|
||||
{
|
||||
CResourceManager& rkResMgr = CResourceManager::Instance();
|
||||
CGraphicImage * pImage = (CGraphicImage *)rkResMgr.GetResourcePointer(c_szSphereMapImageFileName);
|
||||
ms_akSphereMapInstance[uMapIndex].SetImagePointer(pImage);
|
||||
}
|
||||
|
||||
void CGrannyMaterial::DestroySphereMap()
|
||||
{
|
||||
for (UINT uMapIndex=0; uMapIndex<SPHEREMAP_NUM; ++uMapIndex)
|
||||
ms_akSphereMapInstance[uMapIndex].Destroy();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CGrannyMaterialPalette::CGrannyMaterialPalette()
|
||||
{
|
||||
}
|
||||
|
||||
CGrannyMaterialPalette::~CGrannyMaterialPalette()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void CGrannyMaterialPalette::Copy(const CGrannyMaterialPalette& rkMtrlPalSrc)
|
||||
{
|
||||
m_mtrlVector=rkMtrlPalSrc.m_mtrlVector;
|
||||
}
|
||||
|
||||
void CGrannyMaterialPalette::Clear()
|
||||
{
|
||||
m_mtrlVector.clear();
|
||||
}
|
||||
|
||||
CGrannyMaterial& CGrannyMaterialPalette::GetMaterialRef(DWORD mtrlIndex)
|
||||
{
|
||||
assert(mtrlIndex<m_mtrlVector.size());
|
||||
return *m_mtrlVector[mtrlIndex].GetPointer();
|
||||
}
|
||||
|
||||
void CGrannyMaterialPalette::SetMaterialImagePointer(const char* c_szImageName, CGraphicImage* pImage)
|
||||
{
|
||||
DWORD size=m_mtrlVector.size();
|
||||
DWORD i;
|
||||
for (i=0; i<size; ++i)
|
||||
{
|
||||
CGrannyMaterial::TRef& roMtrl=m_mtrlVector[i];
|
||||
|
||||
int iStage;
|
||||
if (roMtrl->IsIn(c_szImageName, &iStage))
|
||||
{
|
||||
CGrannyMaterial* pkNewMtrl=new CGrannyMaterial;
|
||||
pkNewMtrl->Copy(*roMtrl.GetPointer());
|
||||
pkNewMtrl->SetImagePointer(iStage, pImage);
|
||||
roMtrl=pkNewMtrl;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGrannyMaterialPalette::SetMaterialData(const char* c_szMtrlName, const SMaterialData& c_rkMaterialData)
|
||||
{
|
||||
if (c_szMtrlName)
|
||||
{
|
||||
std::vector<CGrannyMaterial::TRef>::iterator i;
|
||||
for (i=m_mtrlVector.begin(); i!=m_mtrlVector.end(); ++i)
|
||||
{
|
||||
CGrannyMaterial::TRef& roMtrl=*i;
|
||||
|
||||
int iStage;
|
||||
if (roMtrl->IsIn(c_szMtrlName, &iStage))
|
||||
{
|
||||
CGrannyMaterial* pkNewMtrl=new CGrannyMaterial;
|
||||
pkNewMtrl->Copy(*roMtrl.GetPointer());
|
||||
pkNewMtrl->SetImagePointer(iStage, c_rkMaterialData.pImage);
|
||||
pkNewMtrl->SetSpecularInfo(c_rkMaterialData.isSpecularEnable, c_rkMaterialData.fSpecularPower, c_rkMaterialData.bSphereMapIndex);
|
||||
roMtrl=pkNewMtrl;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<CGrannyMaterial::TRef>::iterator i;
|
||||
for (i=m_mtrlVector.begin(); i!=m_mtrlVector.end(); ++i)
|
||||
{
|
||||
CGrannyMaterial::TRef& roMtrl=*i;
|
||||
roMtrl->SetSpecularInfo(c_rkMaterialData.isSpecularEnable, c_rkMaterialData.fSpecularPower, c_rkMaterialData.bSphereMapIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGrannyMaterialPalette::SetSpecularInfo(const char* c_szMtrlName, BOOL bEnable, float fPower)
|
||||
{
|
||||
DWORD size=m_mtrlVector.size();
|
||||
DWORD i;
|
||||
if (c_szMtrlName)
|
||||
{
|
||||
for (i=0; i<size; ++i)
|
||||
{
|
||||
CGrannyMaterial::TRef& roMtrl=m_mtrlVector[i];
|
||||
|
||||
int iStage;
|
||||
if (roMtrl->IsIn(c_szMtrlName, &iStage))
|
||||
{
|
||||
roMtrl->SetSpecularInfo(bEnable, fPower, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i=0; i<size; ++i)
|
||||
{
|
||||
CGrannyMaterial::TRef& roMtrl=m_mtrlVector[i];
|
||||
roMtrl->SetSpecularInfo(bEnable, fPower, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DWORD CGrannyMaterialPalette::RegisterMaterial(granny_material* pgrnMaterial)
|
||||
{
|
||||
DWORD size=m_mtrlVector.size();
|
||||
DWORD i;
|
||||
for (i=0; i<size; ++i)
|
||||
{
|
||||
CGrannyMaterial::TRef& roMtrl=m_mtrlVector[i];
|
||||
if (roMtrl->IsEqual(pgrnMaterial))
|
||||
return i;
|
||||
}
|
||||
|
||||
CGrannyMaterial* pkNewMtrl=new CGrannyMaterial;
|
||||
pkNewMtrl->CreateFromGrannyMaterialPointer(pgrnMaterial);
|
||||
m_mtrlVector.push_back(pkNewMtrl);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
DWORD CGrannyMaterialPalette::GetMaterialCount() const
|
||||
{
|
||||
return m_mtrlVector.size();
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
119
source-client/Srcs/Client/EterGrnLib/Material.h
Normal file
119
source-client/Srcs/Client/EterGrnLib/Material.h
Normal file
@ -0,0 +1,119 @@
|
||||
#pragma once
|
||||
|
||||
#include <granny.h>
|
||||
#include <windows.h>
|
||||
#include <d3d8.h>
|
||||
|
||||
#include "../eterlib/ReferenceObject.h"
|
||||
#include "../eterlib/Ref.h"
|
||||
#include "../eterlib/GrpImageInstance.h"
|
||||
#include "Util.h"
|
||||
|
||||
class CGrannyMaterial : public CReferenceObject
|
||||
{
|
||||
public:
|
||||
typedef CRef<CGrannyMaterial> TRef;
|
||||
|
||||
static void CreateSphereMap(UINT uMapIndex, const char* c_szSphereMapImageFileName);
|
||||
static void DestroySphereMap();
|
||||
|
||||
public:
|
||||
enum EType
|
||||
{
|
||||
TYPE_DIFFUSE_PNT,
|
||||
TYPE_BLEND_PNT,
|
||||
TYPE_MAX_NUM
|
||||
};
|
||||
|
||||
public:
|
||||
static void TranslateSpecularMatrix(float fAddX, float fAddY, float fAddZ);
|
||||
|
||||
private:
|
||||
static D3DXMATRIX ms_matSpecular;
|
||||
static D3DXVECTOR3 ms_v3SpecularTrans;
|
||||
|
||||
public:
|
||||
CGrannyMaterial();
|
||||
virtual ~CGrannyMaterial();
|
||||
|
||||
void Destroy();
|
||||
void Copy(CGrannyMaterial& rkMtrl);
|
||||
bool IsEqual(granny_material * pgrnMaterial) const;
|
||||
bool IsIn(const char* c_szImageName, int* iStage);
|
||||
void SetSpecularInfo(BOOL bFlag, float fPower, BYTE uSphereMapIndex);
|
||||
|
||||
void ApplyRenderState();
|
||||
void RestoreRenderState();
|
||||
|
||||
protected:
|
||||
void Initialize();
|
||||
|
||||
public:
|
||||
bool CreateFromGrannyMaterialPointer(granny_material* pgrnMaterial);
|
||||
void SetImagePointer(int iStage, CGraphicImage* pImage);
|
||||
|
||||
CGrannyMaterial::EType GetType() const;
|
||||
CGraphicImage * GetImagePointer(int iStage) const;
|
||||
|
||||
const CGraphicTexture * GetDiffuseTexture() const;
|
||||
const CGraphicTexture * GetOpacityTexture() const;
|
||||
|
||||
LPDIRECT3DTEXTURE8 GetD3DTexture(int iStage) const;
|
||||
|
||||
bool IsTwoSided() const { return m_bTwoSideRender; }
|
||||
|
||||
protected:
|
||||
CGraphicImage * __GetImagePointer(const char * c_szFileName);
|
||||
|
||||
BOOL __IsSpecularEnable() const;
|
||||
float __GetSpecularPower() const;
|
||||
|
||||
void __ApplyDiffuseRenderState();
|
||||
void __RestoreDiffuseRenderState();
|
||||
void __ApplySpecularRenderState();
|
||||
void __RestoreSpecularRenderState();
|
||||
|
||||
protected:
|
||||
granny_material * m_pgrnMaterial;
|
||||
CGraphicImage::TRef m_roImage[2];
|
||||
EType m_eType;
|
||||
|
||||
float m_fSpecularPower;
|
||||
BOOL m_bSpecularEnable;
|
||||
bool m_bTwoSideRender;
|
||||
DWORD m_dwLastCullRenderStateForTwoSideRendering;
|
||||
BYTE m_bSphereMapIndex;
|
||||
|
||||
void (CGrannyMaterial::*m_pfnApplyRenderState)();
|
||||
void (CGrannyMaterial::*m_pfnRestoreRenderState)();
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
SPHEREMAP_NUM = 10,
|
||||
};
|
||||
static CGraphicImageInstance ms_akSphereMapInstance[SPHEREMAP_NUM];
|
||||
};
|
||||
|
||||
class CGrannyMaterialPalette
|
||||
{
|
||||
public:
|
||||
CGrannyMaterialPalette();
|
||||
virtual ~CGrannyMaterialPalette();
|
||||
|
||||
void Clear();
|
||||
void Copy(const CGrannyMaterialPalette& rkMtrlPalSrc);
|
||||
|
||||
DWORD RegisterMaterial(granny_material* pgrnMaterial);
|
||||
void SetMaterialImagePointer(const char* c_szMtrlName, CGraphicImage* pImage);
|
||||
void SetMaterialData(const char* c_szMtrlName, const SMaterialData& c_rkMaterialData);
|
||||
void SetSpecularInfo(const char* c_szMtrlName, BOOL bEnable, float fPower);
|
||||
|
||||
CGrannyMaterial& GetMaterialRef(DWORD mtrlIndex);
|
||||
|
||||
DWORD GetMaterialCount() const;
|
||||
|
||||
protected:
|
||||
std::vector<CGrannyMaterial::TRef> m_mtrlVector;
|
||||
};
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
331
source-client/Srcs/Client/EterGrnLib/Mesh.cpp
Normal file
331
source-client/Srcs/Client/EterGrnLib/Mesh.cpp
Normal file
@ -0,0 +1,331 @@
|
||||
#include "StdAfx.h"
|
||||
#include "Mesh.h"
|
||||
#include "Model.h"
|
||||
#include "Material.h"
|
||||
|
||||
granny_data_type_definition GrannyPNT3322VertexType[5] =
|
||||
{
|
||||
{GrannyReal32Member, GrannyVertexPositionName, 0, 3},
|
||||
{GrannyReal32Member, GrannyVertexNormalName, 0, 3},
|
||||
{GrannyReal32Member, GrannyVertexTextureCoordinatesName"0", 0, 2},
|
||||
{GrannyReal32Member, GrannyVertexTextureCoordinatesName"1", 0, 2},
|
||||
{GrannyEndMember}
|
||||
};
|
||||
|
||||
void CGrannyMesh::LoadIndices(void * dstBaseIndices)
|
||||
{
|
||||
const granny_mesh * pgrnMesh = GetGrannyMeshPointer();
|
||||
|
||||
TIndex * dstIndices = ((TIndex *)dstBaseIndices) + m_idxBasePos;
|
||||
GrannyCopyMeshIndices(pgrnMesh, sizeof(TIndex), dstIndices);
|
||||
}
|
||||
|
||||
void CGrannyMesh::LoadPNTVertices(void * dstBaseVertices)
|
||||
{
|
||||
const granny_mesh * pgrnMesh = GetGrannyMeshPointer();
|
||||
|
||||
if (!GrannyMeshIsRigid(pgrnMesh))
|
||||
return;
|
||||
|
||||
TPNTVertex * dstVertices = ((TPNTVertex *)dstBaseVertices) + m_vtxBasePos;
|
||||
GrannyCopyMeshVertices(pgrnMesh, m_pgrnMeshType, dstVertices);
|
||||
}
|
||||
|
||||
void CGrannyMesh::NEW_LoadVertices(void * dstBaseVertices)
|
||||
{
|
||||
const granny_mesh * pgrnMesh = GetGrannyMeshPointer();
|
||||
|
||||
if (!GrannyMeshIsRigid(pgrnMesh))
|
||||
return;
|
||||
|
||||
TPNTVertex * dstVertices = ((TPNTVertex *)dstBaseVertices) + m_vtxBasePos;
|
||||
GrannyCopyMeshVertices(pgrnMesh, m_pgrnMeshType, dstVertices);
|
||||
}
|
||||
|
||||
void CGrannyMesh::DeformPNTVertices(void * dstBaseVertices, D3DXMATRIX * boneMatrices, granny_mesh_binding* pgrnMeshBinding) const
|
||||
{
|
||||
assert(dstBaseVertices != NULL);
|
||||
assert(boneMatrices != NULL);
|
||||
assert(m_pgrnMeshDeformer != NULL);
|
||||
|
||||
const granny_mesh * pgrnMesh = GetGrannyMeshPointer();
|
||||
|
||||
TPNTVertex * srcVertices = (TPNTVertex *) GrannyGetMeshVertices(pgrnMesh);
|
||||
TPNTVertex * dstVertices = ((TPNTVertex *) dstBaseVertices) + m_vtxBasePos;
|
||||
|
||||
int vtxCount = GrannyGetMeshVertexCount(pgrnMesh);
|
||||
|
||||
// WORK
|
||||
#if GrannyProductMinorVersion==4
|
||||
int * boneIndices = GrannyGetMeshBindingToBoneIndices(pgrnMeshBinding);
|
||||
#elif GrannyProductMinorVersion==11 || GrannyProductMinorVersion==9 || GrannyProductMinorVersion==8 || GrannyProductMinorVersion==7
|
||||
const granny_int32x * boneIndices = GrannyGetMeshBindingToBoneIndices(pgrnMeshBinding);
|
||||
#else
|
||||
#error "unknown granny version"
|
||||
#endif
|
||||
// END_OF_WORK
|
||||
|
||||
GrannyDeformVertices(
|
||||
m_pgrnMeshDeformer,
|
||||
boneIndices,
|
||||
(float *)boneMatrices,
|
||||
vtxCount,
|
||||
srcVertices,
|
||||
dstVertices);
|
||||
}
|
||||
|
||||
bool CGrannyMesh::CanDeformPNTVertices() const
|
||||
{
|
||||
return m_canDeformPNTVertex;
|
||||
}
|
||||
|
||||
const granny_mesh * CGrannyMesh::GetGrannyMeshPointer() const
|
||||
{
|
||||
return m_pgrnMesh;
|
||||
}
|
||||
|
||||
const CGrannyMesh::TTriGroupNode * CGrannyMesh::GetTriGroupNodeList(CGrannyMaterial::EType eMtrlType) const
|
||||
{
|
||||
return m_triGroupNodeLists[eMtrlType];
|
||||
}
|
||||
|
||||
int CGrannyMesh::GetVertexCount() const
|
||||
{
|
||||
assert(m_pgrnMesh!=NULL);
|
||||
return GrannyGetMeshVertexCount(m_pgrnMesh);
|
||||
}
|
||||
|
||||
int CGrannyMesh::GetVertexBasePosition() const
|
||||
{
|
||||
return m_vtxBasePos;
|
||||
}
|
||||
|
||||
int CGrannyMesh::GetIndexBasePosition() const
|
||||
{
|
||||
return m_idxBasePos;
|
||||
}
|
||||
|
||||
// WORK
|
||||
#if GrannyProductMinorVersion==4
|
||||
int * CGrannyMesh::GetDefaultBoneIndices() const
|
||||
#elif GrannyProductMinorVersion==11 || GrannyProductMinorVersion==9 || GrannyProductMinorVersion==8 || GrannyProductMinorVersion==7
|
||||
const granny_int32x * CGrannyMesh::GetDefaultBoneIndices() const
|
||||
#else
|
||||
#error "unknown granny version"
|
||||
#endif
|
||||
{
|
||||
return GrannyGetMeshBindingToBoneIndices(m_pgrnMeshBindingTemp);
|
||||
}
|
||||
// END_OF_WORK
|
||||
|
||||
bool CGrannyMesh::IsEmpty() const
|
||||
{
|
||||
if (m_pgrnMesh)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGrannyMesh::CreateFromGrannyMeshPointer(granny_skeleton * pgrnSkeleton, granny_mesh * pgrnMesh, int vtxBasePos, int idxBasePos, CGrannyMaterialPalette& rkMtrlPal)
|
||||
{
|
||||
assert(IsEmpty());
|
||||
|
||||
m_pgrnMesh = pgrnMesh;
|
||||
m_vtxBasePos = vtxBasePos;
|
||||
m_idxBasePos = idxBasePos;
|
||||
|
||||
if (m_pgrnMesh->BoneBindingCount < 0)
|
||||
return true;
|
||||
|
||||
// WORK
|
||||
m_pgrnMeshBindingTemp = GrannyNewMeshBinding(m_pgrnMesh, pgrnSkeleton, pgrnSkeleton);
|
||||
// END_OF_WORK
|
||||
|
||||
if (!GrannyMeshIsRigid(m_pgrnMesh))
|
||||
{
|
||||
m_canDeformPNTVertex = true;
|
||||
|
||||
granny_data_type_definition * pgrnInputType = GrannyGetMeshVertexType(m_pgrnMesh);
|
||||
granny_data_type_definition * pgrnOutputType = m_pgrnMeshType;
|
||||
|
||||
#if GrannyProductMinorVersion==4
|
||||
m_pgrnMeshDeformer = GrannyNewMeshDeformer(pgrnInputType, pgrnOutputType, GrannyDeformPositionNormal);
|
||||
#elif GrannyProductMinorVersion==11 || GrannyProductMinorVersion==9 || GrannyProductMinorVersion==8 || GrannyProductMinorVersion==7
|
||||
m_pgrnMeshDeformer = GrannyNewMeshDeformer(pgrnInputType, pgrnOutputType, GrannyDeformPositionNormal, GrannyDontAllowUncopiedTail);
|
||||
// m_pgrnMeshDeformer = GrannyNewMeshDeformer(pgrnInputType, pgrnOutputType, GrannyDeformPositionNormal, GrannyAllowUncopiedTail);
|
||||
#else
|
||||
#error "unknown granny version"
|
||||
#endif
|
||||
assert(m_pgrnMeshDeformer != NULL && "Cannot create mesh deformer");
|
||||
}
|
||||
|
||||
// Two Side Mesh
|
||||
if (!strncmp(m_pgrnMesh->Name, "2x", 2))
|
||||
m_isTwoSide = true;
|
||||
|
||||
if (!LoadMaterials(rkMtrlPal))
|
||||
return false;
|
||||
|
||||
if (!LoadTriGroupNodeList(rkMtrlPal))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGrannyMesh::LoadTriGroupNodeList(CGrannyMaterialPalette& rkMtrlPal)
|
||||
{
|
||||
assert(m_pgrnMesh != NULL);
|
||||
assert(m_triGroupNodes == NULL);
|
||||
|
||||
int mtrlCount = m_pgrnMesh->MaterialBindingCount;
|
||||
if (mtrlCount <= 0)
|
||||
return true;
|
||||
|
||||
int GroupNodeCount = GrannyGetMeshTriangleGroupCount(m_pgrnMesh);
|
||||
if (GroupNodeCount <= 0)
|
||||
return true;
|
||||
|
||||
m_triGroupNodes = new TTriGroupNode[GroupNodeCount];
|
||||
|
||||
const granny_tri_material_group * c_pgrnTriGroups = GrannyGetMeshTriangleGroups(m_pgrnMesh);
|
||||
|
||||
for (int g = 0; g < GroupNodeCount; ++g)
|
||||
{
|
||||
const granny_tri_material_group & c_rgrnTriGroup = c_pgrnTriGroups[g];
|
||||
TTriGroupNode * pTriGroupNode = m_triGroupNodes + g;
|
||||
|
||||
pTriGroupNode->idxPos = m_idxBasePos + c_rgrnTriGroup.TriFirst * 3;
|
||||
pTriGroupNode->triCount = c_rgrnTriGroup.TriCount;
|
||||
|
||||
int iMtrl = c_rgrnTriGroup.MaterialIndex;
|
||||
if (iMtrl < 0 || iMtrl >= mtrlCount)
|
||||
{
|
||||
pTriGroupNode->mtrlIndex=0;//m_mtrlIndexVector[iMtrl];
|
||||
}
|
||||
else
|
||||
{
|
||||
pTriGroupNode->mtrlIndex=m_mtrlIndexVector[iMtrl];
|
||||
}
|
||||
|
||||
const CGrannyMaterial& rkMtrl=rkMtrlPal.GetMaterialRef(pTriGroupNode->mtrlIndex);
|
||||
pTriGroupNode->pNextTriGroupNode = m_triGroupNodeLists[rkMtrl.GetType()];
|
||||
m_triGroupNodeLists[rkMtrl.GetType()] = pTriGroupNode;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGrannyMesh::RebuildTriGroupNodeList()
|
||||
{
|
||||
assert(!"CGrannyMesh::RebuildTriGroupNodeList() - Why should you rebuild it -?");
|
||||
/*
|
||||
int mtrlCount = m_pgrnMesh->MaterialBindingCount;
|
||||
int GroupNodeCount = GrannyGetMeshTriangleGroupCount(m_pgrnMesh);
|
||||
|
||||
if (GroupNodeCount <= 0)
|
||||
return;
|
||||
|
||||
const granny_tri_material_group * c_pgrnTriGroups = GrannyGetMeshTriangleGroups(m_pgrnMesh);
|
||||
|
||||
for (int g = 0; g < GroupNodeCount; ++g)
|
||||
{
|
||||
const granny_tri_material_group& c_rgrnTriGroup = c_pgrnTriGroups[g];
|
||||
TTriGroupNode * pTriGroupNode = m_triGroupNodes + g;
|
||||
|
||||
int iMtrl = c_rgrnTriGroup.MaterialIndex;
|
||||
|
||||
if (iMtrl >= 0 && iMtrl < mtrlCount)
|
||||
{
|
||||
CGrannyMaterial & rMtrl = m_mtrls[iMtrl];
|
||||
|
||||
pTriGroupNode->lpd3dTextures[0] = rMtrl.GetD3DTexture(0);
|
||||
pTriGroupNode->lpd3dTextures[1] = rMtrl.GetD3DTexture(1);
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
bool CGrannyMesh::LoadMaterials(CGrannyMaterialPalette& rkMtrlPal)
|
||||
{
|
||||
assert(m_pgrnMesh != NULL);
|
||||
|
||||
if (m_pgrnMesh->MaterialBindingCount <= 0)
|
||||
return true;
|
||||
|
||||
int mtrlCount = m_pgrnMesh->MaterialBindingCount;
|
||||
bool bHaveBlendThing = false;
|
||||
|
||||
for (int m = 0; m < mtrlCount; ++m)
|
||||
{
|
||||
granny_material* pgrnMaterial = m_pgrnMesh->MaterialBindings[m].Material;
|
||||
DWORD mtrlIndex=rkMtrlPal.RegisterMaterial(pgrnMaterial);
|
||||
m_mtrlIndexVector.push_back(mtrlIndex);
|
||||
bHaveBlendThing |= rkMtrlPal.GetMaterialRef(mtrlIndex).GetType() == CGrannyMaterial::TYPE_BLEND_PNT;
|
||||
}
|
||||
m_bHaveBlendThing = bHaveBlendThing;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGrannyMesh::IsTwoSide() const
|
||||
{
|
||||
return m_isTwoSide;
|
||||
}
|
||||
|
||||
void CGrannyMesh::SetPNT2Mesh()
|
||||
{
|
||||
m_pgrnMeshType = GrannyPNT3322VertexType;
|
||||
}
|
||||
|
||||
void CGrannyMesh::Destroy()
|
||||
{
|
||||
if (m_triGroupNodes)
|
||||
delete [] m_triGroupNodes;
|
||||
|
||||
m_mtrlIndexVector.clear();
|
||||
|
||||
// WORK
|
||||
if (m_pgrnMeshBindingTemp)
|
||||
GrannyFreeMeshBinding(m_pgrnMeshBindingTemp);
|
||||
// END_OF_WORK
|
||||
|
||||
if (m_pgrnMeshDeformer)
|
||||
GrannyFreeMeshDeformer(m_pgrnMeshDeformer);
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
void CGrannyMesh::Initialize()
|
||||
{
|
||||
for (int r = 0; r < CGrannyMaterial::TYPE_MAX_NUM; ++r)
|
||||
m_triGroupNodeLists[r] = NULL;
|
||||
|
||||
m_pgrnMeshType = GrannyPNT332VertexType;
|
||||
m_pgrnMesh = NULL;
|
||||
// WORK
|
||||
m_pgrnMeshBindingTemp = NULL;
|
||||
// END_OF_WORK
|
||||
m_pgrnMeshDeformer = NULL;
|
||||
|
||||
m_triGroupNodes = NULL;
|
||||
|
||||
m_vtxBasePos = 0;
|
||||
m_idxBasePos = 0;
|
||||
|
||||
m_canDeformPNTVertex = false;
|
||||
m_isTwoSide = false;
|
||||
m_bHaveBlendThing = false;
|
||||
}
|
||||
|
||||
CGrannyMesh::CGrannyMesh()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
CGrannyMesh::~CGrannyMesh()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
105
source-client/Srcs/Client/EterGrnLib/Mesh.h
Normal file
105
source-client/Srcs/Client/EterGrnLib/Mesh.h
Normal file
@ -0,0 +1,105 @@
|
||||
#pragma once
|
||||
|
||||
#include "Material.h"
|
||||
|
||||
extern granny_data_type_definition GrannyPNT3322VertexType[5];
|
||||
|
||||
struct granny_pnt3322_vertex
|
||||
{
|
||||
granny_real32 Position[3];
|
||||
granny_real32 Normal[3];
|
||||
granny_real32 UV0[2];
|
||||
granny_real32 UV1[2];
|
||||
};
|
||||
|
||||
class CGrannyMesh
|
||||
{
|
||||
public:
|
||||
enum EType
|
||||
{
|
||||
TYPE_RIGID,
|
||||
TYPE_DEFORM,
|
||||
TYPE_MAX_NUM
|
||||
};
|
||||
|
||||
typedef struct STriGroupNode
|
||||
{
|
||||
STriGroupNode * pNextTriGroupNode;
|
||||
int idxPos;
|
||||
int triCount;
|
||||
DWORD mtrlIndex;
|
||||
} TTriGroupNode;
|
||||
|
||||
public:
|
||||
CGrannyMesh();
|
||||
virtual ~CGrannyMesh();
|
||||
|
||||
bool IsEmpty() const;
|
||||
bool CreateFromGrannyMeshPointer(granny_skeleton* pgrnSkeleton, granny_mesh* pgrnMesh, int vtxBasePos, int idxBasePos, CGrannyMaterialPalette& rkMtrlPal);
|
||||
void LoadIndices(void* dstBaseIndices);
|
||||
void LoadPNTVertices(void* dstBaseVertices);
|
||||
void NEW_LoadVertices(void* dstBaseVertices);
|
||||
void Destroy();
|
||||
|
||||
void SetPNT2Mesh();
|
||||
|
||||
void DeformPNTVertices(void* dstBaseVertices, D3DXMATRIX* boneMatrices, granny_mesh_binding* pgrnMeshBinding) const;
|
||||
bool CanDeformPNTVertices() const;
|
||||
bool IsTwoSide() const;
|
||||
|
||||
int GetVertexCount() const;
|
||||
|
||||
// WORK
|
||||
#if GrannyProductMinorVersion==4
|
||||
int * GetDefaultBoneIndices() const;
|
||||
#elif GrannyProductMinorVersion==11 || GrannyProductMinorVersion==9 || GrannyProductMinorVersion==8 || GrannyProductMinorVersion==7
|
||||
const granny_int32x * GetDefaultBoneIndices() const;
|
||||
#else
|
||||
#error "unknown granny version"
|
||||
#endif
|
||||
// END_OF_WORK
|
||||
|
||||
int GetVertexBasePosition() const;
|
||||
int GetIndexBasePosition() const;
|
||||
|
||||
const granny_mesh * GetGrannyMeshPointer() const;
|
||||
const CGrannyMesh::TTriGroupNode * GetTriGroupNodeList(CGrannyMaterial::EType eMtrlType) const;
|
||||
|
||||
void RebuildTriGroupNodeList();
|
||||
void ReloadMaterials();
|
||||
|
||||
protected:
|
||||
void Initialize();
|
||||
|
||||
bool LoadMaterials(CGrannyMaterialPalette& rkMtrlPal);
|
||||
bool LoadTriGroupNodeList(CGrannyMaterialPalette& rkMtrlPal);
|
||||
|
||||
protected:
|
||||
// Granny Mesh Data
|
||||
granny_data_type_definition * m_pgrnMeshType;
|
||||
granny_mesh * m_pgrnMesh;
|
||||
|
||||
// WORK
|
||||
granny_mesh_binding * m_pgrnMeshBindingTemp;
|
||||
// END_OF_WORK
|
||||
|
||||
granny_mesh_deformer * m_pgrnMeshDeformer;
|
||||
|
||||
// Granny Material Data
|
||||
std::vector<DWORD> m_mtrlIndexVector;
|
||||
|
||||
// TriGroups Data
|
||||
TTriGroupNode * m_triGroupNodes;
|
||||
TTriGroupNode * m_triGroupNodeLists[CGrannyMaterial::TYPE_MAX_NUM];
|
||||
|
||||
int m_vtxBasePos;
|
||||
int m_idxBasePos;
|
||||
|
||||
bool m_canDeformPNTVertex;
|
||||
bool m_isTwoSide;
|
||||
private:
|
||||
bool m_bHaveBlendThing;
|
||||
public:
|
||||
bool HaveBlendThing() { return m_bHaveBlendThing; }
|
||||
};
|
||||
//martysama0134's 2e58d0b8baeb072acdf3afc4a5d1999f
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user