Jump to content

ReFresh

Active Member
  • Posts

    1797
  • Joined

  • Last visited

  • Days Won

    4
  • Feedback

    0%

Posts posted by ReFresh

  1. Along with this problem, there're some little visual problems too, probably not only visual.

    When the party leader (or someone else from the group) goes offline the EXP bonus icon should dissapear from their UI. (I don't really know, if the EXP bonus value is still counting to the group, but looks like it's counting).

    I'm talking about this little icon:
    spacer.png

    Also, if the party leader goes offline and the player have assigned a party role, the little icon showing the bonus of the party role should dissapear too (here is the bonus value removed, so it looks like, it's only visual problem):

    spacer.png

  2. So all I need to do is what Asikoo said in the topic, which he mentioned?

    1. You must compile your "db" and your "game" with the MySQL 8.0 includes.

    - That means I need to replace some MySQL includes in server source and then compile game and db again? And surely I'll need to edit makefile too right? And where I'll find the includes for example for 64 bit machine? Or can I compile it on 32 bit and then run the server on 64 bit?

    2. Change the password encryption method or imitate the PASSWORD() function (it has been removed)

    3. Some columns must be wrapped (in the cpp file) ("window", "rank" for example...)

    - window, rank are all columns, which I need to edit or there're more?

    And that's all? It's that simple?

  3. Thanks guys, but your answers aren't clear. It won't help me with anything. There are tons of things, which I need to know to do the "simple" database version change and that's a big problem for me.

    Firstly, I'll need to know this:

    1. How to export databases with data to make it much compatible as possible? Is possible to export databases from MySQL 5.6.51 and then import them to MySQL 8.0 without errors?

    What I tried:

    1. I downloaded some last .vdi file with preinstalled MySQL 5.6.51 to successfully run the queries to the database without errors.

    2. What now? I tried to export account, common, hotbackup, log, player databases to .sql files one by one containing data + structure. Then I went to server where I had MySQL 8.0 installed and tried to import those .sql files. What happened? Tons of errors appeared and tons of tables were empty.

    3. I tried to use Navicat function named Reverse Database to Model, then I clicked on File --> Convert Model to --> Model type -->Physical --> Target Database --> Database --> MySQL --> Version 8.0 --> Export SQL or synchronize to database (I tried both). Again what happened? Only structure of the database without data was exported.

    Second thing, which as I can see, it'll be needed to change some things in server source code. But I'll ask later for that. As first I need to successfully import the tables to MySQL 8.0 without errors and with all the data.

    Hm... Just managed to fix the error with mob proto: 1265 - Data truncated for column 'size' at row 1 by replacing INSERT INTO to INSERT IGNORE INTO in mob_proto query. Is that simple to solve these errors or should I take a care of them?

  4. Hey guys,

    I want to ask, if it's possible to upgrade MySQL database from 5.6.51 to MySQL 8.0 or to MariaDB, depends on what would be easier, if possible. I want to keep all my data + structure. I saw some tutorials here on the forum, but I'm confused from them. They're not clear for me. I was trying to manage the upgrade whole day, but I wasn't successful and that's really heart breaking for me, because now it's not possible to download an old packages from FreeBSD trees, they're all removed and forever gone 😞  So I cannot do my hobby in my free time.

    I would be really glad, if someone can help me with that.

    Thanks for possible answers!

    Sincerely,

    ReFresh

  5. 4 hours ago, [TiTAN] said:

    And initialize m_dwBestMinFilter and m_dwBestMagFilter directly with D3DTEXF_ANISOTROPIC like:

    CStateManager::CStateManager(LPDIRECT3DDEVICE9 lpDevice) : m_lpD3DDev(NULL)
    {
    	m_bScene = false;
    	m_dwBestMinFilter = D3DTEXF_ANISOTROPIC;
    	m_dwBestMagFilter = D3DTEXF_ANISOTROPIC;
    	SetDevice(lpDevice);
    }

    So that function will look like this?

    Spoiler
    void CStateManager::SetDevice(LPDIRECT3DDEVICE8 lpDevice)
    {
    	StateManager_Assert(lpDevice);
    	lpDevice->AddRef();
    
    	if (m_lpD3DDev)
    	{
    		m_lpD3DDev->Release();
    		m_lpD3DDev = NULL;
    	}
    
    	m_lpD3DDev = lpDevice;
    
    	D3DCAPS8 d3dCaps;
    	m_lpD3DDev->GetDeviceCaps(&d3dCaps);
    
    	m_bScene = false;
    	m_dwBestMinFilter = D3DTEXF_ANISOTROPIC;
    	m_dwBestMagFilter = D3DTEXF_ANISOTROPIC;
    	SetDevice(lpDevice);
    
    	DWORD dwMax = d3dCaps.MaxAnisotropy;
    	dwMax = dwMax < 4 ? dwMax : 4;
    
    	for (int i = 0; i < 8; ++i)
    		m_lpD3DDev->SetTextureStageState(i, D3DTSS_MAXANISOTROPY, dwMax);
    
    	SetDefaultState();
    }

    And CStateManager::SetDefaultState function will be set to default? So that means I won't do changes, which @Trial did?

    Correct me please, if I'm mistaken somewhere. Thanks

  6. 20 hours ago, Owsap said:

    Try to rename the event to another thing for example, "minning".

    I tried to rename to minning. It had no effect.

    20 hours ago, Owsap said:

    Also, try to see if you have any npc called "mine" in npclist.txt

    No mines were found in npclist.txt

    Exist some way how to debug it, to find why it's not working?

    • Good 1
  7. 21 minutes ago, WeedHex said:

    You changed the macro's name, be sure on visual studio with CTRL+SHIFT+F.

    Check the spoiler, it's directly copied from the files, which I edited.

    21 minutes ago, WeedHex said:

    Try to change on lua notice() to chat()

    Already tried and still 0 output when the mine event starts.

  8. On 1/16/2023 at 6:18 PM, Owsap said:

    It's working for me.

    I followed the github tutorial again to check for possible mistakes and no mistakes were found. The mine event still doesn't work. I can't see any reason why it doesn't work. No errors, syssers, syslogs... Everything is added correctly and I still can't get the notice output when I start the mine event. It's only the mine event, so it's really weird. Looks like I'm the only one who added and completely tested these events.

    Here I can prove that everything is added correctly:

    Spoiler
    //cmd_emotion.cpp
    #ifdef ENABLE_NEW_QUEST_EVENTS
    #include "questmanager.h"
    #endif
      
    #ifdef ENABLE_NEW_QUEST_EVENTS
    	ch->SetQuestNPCID(victim ? victim->GetVID() : 0);
    	quest::CQuestManager::instance().Emotion(ch->GetPlayerID(), victim ? victim->GetRaceNum() : quest::QUEST_NO_NPC);
    #endif
      
    //cube.cpp
    #ifdef ENABLE_NEW_QUEST_EVENTS
    #include "questmanager.h"
    #endif
      
    #ifdef ENABLE_NEW_QUEST_EVENTS
    		ch->SetQuestNPCID(npc->GetVID());
    		quest::CQuestManager::instance().CraftItem(ch->GetPlayerID(), npc->GetRaceNum(), new_item);
    #endif
      
    //char.cpp
    #ifdef ENABLE_NEW_QUEST_EVENTS
    	quest::CQuestManager::instance().Mine(GetPlayerID());
    #endif
      
    #ifdef ENABLE_NEW_QUEST_EVENTS
    	quest::CQuestManager::instance().Fish(GetPlayerID());
    #endif
      
    //quest.h
    #ifdef ENABLE_NEW_QUEST_EVENTS
    		QUEST_FISH_EVENT,
    		QUEST_MINE_EVENT,
    		QUEST_ITEM_BUY_EVENT,
    		QUEST_ITEM_SELL_EVENT,
    		QUEST_ITEM_CRAFT_EVENT,
    		QUEST_EMOTION_EVENT,
    #endif
      
    //questmanager.cpp
    #ifdef ENABLE_NEW_QUEST_EVENTS
    		m_mapEventName.insert(TEventNameMap::value_type("fish", QUEST_FISH_EVENT));
    		m_mapEventName.insert(TEventNameMap::value_type("mine", QUEST_MINE_EVENT));
    		m_mapEventName.insert(TEventNameMap::value_type("buy", QUEST_ITEM_BUY_EVENT));
    		m_mapEventName.insert(TEventNameMap::value_type("sell", QUEST_ITEM_SELL_EVENT));
    		m_mapEventName.insert(TEventNameMap::value_type("craft", QUEST_ITEM_CRAFT_EVENT));
    		m_mapEventName.insert(TEventNameMap::value_type("emotion", QUEST_EMOTION_EVENT));
    #endif
      
    #ifdef ENABLE_NEW_QUEST_EVENTS
    	void CQuestManager::Fish(unsigned int pc)
    	{
    		PC* pPC;
    		if ((pPC = GetPC(pc)))
    		{
    			if (!CheckQuestLoaded(pPC))
    				return;
    
    			m_mapNPC[QUEST_NO_NPC].OnFish(*pPC);
    		}
    		else
    		{
    			sys_err("QUEST FISH_EVENT no such pc id : %d", pc);
    		}
    	}
    
    	void CQuestManager::Mine(unsigned int pc)
    	{
    		PC* pPC;
    		if ((pPC = GetPC(pc)))
    		{
    			if (!CheckQuestLoaded(pPC))
    				return;
    
    			m_mapNPC[QUEST_NO_NPC].OnMine(*pPC);
    		}
    		else
    		{
    			sys_err("QUEST MINE_EVENT no such pc id : %d", pc);
    		}
    	}
    
    	void CQuestManager::BuyItem(unsigned int pc, unsigned int npc, LPITEM item)
    	{
    		PC* pPC;
    		if ((pPC = GetPC(pc)))
    		{
    			if (!CheckQuestLoaded(pPC))
    			{
    				LPCHARACTER ch = CHARACTER_MANAGER::instance().FindByPID(pc);
    				if (ch)
    				{
    					ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Quests aren't loaded."));
    				}
    				return;
    			}
    
    			SetCurrentItem(item);
    
    			if (npc != QUEST_NO_NPC)
    				m_mapNPC[npc].OnBuyItem(*pPC);
    
    			m_mapNPC[QUEST_NO_NPC].OnBuyItem(*pPC);
    		}
    		else
    		{
    			sys_err("QUEST ITEM_BUY_EVENT no such pc id : %d", pc);
    		}
    	}
    
    	void CQuestManager::SellItem(unsigned int pc, unsigned int npc, LPITEM item)
    	{
    		PC* pPC;
    		if ((pPC = GetPC(pc)))
    		{
    			if (!CheckQuestLoaded(pPC))
    			{
    				LPCHARACTER ch = CHARACTER_MANAGER::instance().FindByPID(pc);
    				if (ch)
    				{
    					ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Quests aren't loaded."));
    				}
    				return;
    			}
    
    			SetCurrentItem(item);
    
    			if (npc != QUEST_NO_NPC)
    				m_mapNPC[npc].OnSellItem(*pPC);
    
    			m_mapNPC[QUEST_NO_NPC].OnSellItem(*pPC);
    		}
    		else
    		{
    			sys_err("QUEST ITEM_SELL_EVENT no such pc id : %d", pc);
    		}
    	}
    
    	void CQuestManager::CraftItem(unsigned int pc, unsigned int npc, LPITEM item)
    	{
    		PC* pPC;
    		if ((pPC = GetPC(pc)))
    		{
    			if (!CheckQuestLoaded(pPC))
    			{
    				LPCHARACTER ch = CHARACTER_MANAGER::instance().FindByPID(pc);
    				if (ch)
    				{
    					ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Quests aren't loaded."));
    				}
    				return;
    			}
    
    			SetCurrentItem(item);
    
    			if (npc != QUEST_NO_NPC)
    				m_mapNPC[npc].OnCraftItem(*pPC);
    
    			m_mapNPC[QUEST_NO_NPC].OnCraftItem(*pPC);
    		}
    		else
    		{
    			sys_err("QUEST ITEM_CRAFT_EVENT no such pc id : %d", pc);
    		}
    	}
    
    	void CQuestManager::Emotion(unsigned int pc, unsigned int target)
    	{
    		PC* pPC;
    		if ((pPC = GetPC(pc)))
    		{
    			if (!CheckQuestLoaded(pPC))
    				return;
    
    			if (target != QUEST_NO_NPC)
    				m_mapNPC[target].OnEmotion(*pPC);
    
    			m_mapNPC[QUEST_NO_NPC].OnEmotion(*pPC);
    		}
    		else
    		{
    			sys_err("QUEST EMOTION_EVENT no such pc id : %d", pc);
    		}
    	}
    #endif
      
    //questmanager.h
    #ifdef ENABLE_NEW_QUEST_EVENTS
    			void		Fish(unsigned int pc);
    			void		Mine(unsigned int pc);
    			void		BuyItem(unsigned int pc, unsigned int npc, LPITEM item);
    			void		SellItem(unsigned int pc, unsigned int npc, LPITEM item);
    			void		CraftItem(unsigned int pc, unsigned int npc, LPITEM item);
    			void		Emotion(unsigned int pc, unsigned int target);
    #endif
    
    //questnpc.cpp
    #ifdef ENABLE_NEW_QUEST_EVENTS
    	bool NPC::OnFish(PC& pc)
    	{
    		return HandleReceiveAllEvent(pc, QUEST_FISH_EVENT);
    	}
    
    	bool NPC::OnMine(PC& pc)
    	{
    		return HandleReceiveAllEvent(pc, QUEST_MINE_EVENT);
    	}
    
    	bool NPC::OnBuyItem(PC& pc)
    	{
    		if (m_vnum == 0)
    			return HandleReceiveAllEvent(pc, QUEST_ITEM_BUY_EVENT);
    		else
    			return HandleEvent(pc, QUEST_ITEM_BUY_EVENT);
    	}
    
    	bool NPC::OnSellItem(PC& pc)
    	{
    		if (m_vnum == 0)
    			return HandleReceiveAllEvent(pc, QUEST_ITEM_SELL_EVENT);
    		else
    			return HandleEvent(pc, QUEST_ITEM_SELL_EVENT);
    	}
    
    	bool NPC::OnCraftItem(PC& pc)
    	{
    		if (m_vnum == 0)
    			return HandleReceiveAllEvent(pc, QUEST_ITEM_CRAFT_EVENT);
    		else
    			return HandleEvent(pc, QUEST_ITEM_CRAFT_EVENT);
    	}
    
    	bool NPC::OnEmotion(PC& pc)
    	{
    		if (m_vnum == 0)
    			return HandleReceiveAllEvent(pc, QUEST_EMOTION_EVENT);
    		else
    			return HandleEvent(pc, QUEST_EMOTION_EVENT);
    	}
    #endif
      
    //questnpc.h
    #ifdef ENABLE_NEW_QUEST_EVENTS
    			bool	OnFish(PC& pc);
    			bool	OnMine(PC& pc);
    			bool	OnBuyItem(PC& pc);
    			bool	OnSellItem(PC& pc);
    			bool	OnCraftItem(PC& pc);
    			bool	OnEmotion(PC& pc);
    #endif
      
    //shop.cpp
    #ifdef ENABLE_NEW_QUEST_EVENTS
    	ch->SetQuestNPCID(ch->GetShopOwner() ? ch->GetShopOwner()->GetVID() : 0);
    	quest::CQuestManager::instance().BuyItem(ch->GetPlayerID(), GetNPCVnum(), item);
    #endif
      
    //shop_manager.cpp
    #ifdef ENABLE_NEW_QUEST_EVENTS
    	if (pkChr->GetShop())
    		return false;
    #endif
    
    #ifdef ENABLE_NEW_QUEST_EVENTS
    	CShop* pkShop = ch->GetShop();
    
    	if (pkShop)
    	{
    		ch->SetQuestNPCID(ch->GetShopOwner() ? ch->GetShopOwner()->GetVID() : 0);
    		quest::CQuestManager::instance().SellItem(ch->GetPlayerID(), pkShop->GetNPCVnum(), item);
    	}
    #endif
      
    //service.h
    #define ENABLE_NEW_QUEST_EVENTS
      
    
    //quest
    quest new_event_test begin
    	state start begin
    		when mine begin
    			notice("You are mining.")
    		end
    
    		when fish begin
    			notice("You are fishing.")
    		end
    
    		when 20018.craft begin -- Baek-Go NPC
    			notice(string.format("You have crafted something from NPC %d", npc.get_race()))
    			notice(string.format("You crafted item %d", item.get_vnum()))
    		end
    
    		when 9003.buy begin
    			notice(string.format("You have bought something from NPC %d", npc.get_race()))
    			notice(string.format("You bought item %d", item.get_vnum()))
    		end
    
    		when 9003.sell begin
    			notice(string.format("You have sold something to NPC %d", npc.get_race()))
    			notice(string.format("You sold item %d", item.get_vnum()))
    		end
    
    		when emotion begin
    			notice("HandleReceiveAllEvent")
    			if npc.is_pc() then
    				notice(string.format("You are emoting / acting with %s", pc.get_name()))
    			else
    				notice("You are emoting / acting alone.")
    			end
    		end
    	end
    end

    Do you have some ideas why it doesn't work? Is there another person who tested the notice output when you start the mine event?

    Thanks for possible suggestions, corrections.

  9. First of all, thank you for this release!

    There are few details, which I have to say:

    1. You can get error when compiling:

    File: questmanager.cpp:

    LC_STRING("Äù½ºÆ®¸¦ ·ÎµåÇÏ´Â ÁßÀÔ´Ï´Ù. Àá½Ã¸¸ ±â´Ù·Á ÁֽʽÿÀ.")

    Should be like this by default:

    LC_TEXT("Äù½ºÆ®¸¦ ·ÎµåÇÏ´Â ÁßÀÔ´Ï´Ù. Àá½Ã¸¸ ±â´Ù·Á ÁֽʽÿÀ.")

    And what does it mean? I couldn't find any translation in my locale_string.txt. It's something like: Quests aren't loaded?

    2. You probably won't find this line:

    File: shop_manager.cpp:

    // search
    DBManager::instance().SendMoneyLog(MONEY_LOG_SHOP, item->GetVnum(), iPrice);

    Should be like this by default:

    // search
    DBManager::instance().SendMoneyLog(MONEY_LOG_SHOP, item->GetVnum(), dwPrice);

    Because iPrice is by default dwPrice, if I'm not mistaken.

    • Good 1
  10. 14 hours ago, Trial said:
    	D3DCAPS8 d3dCaps;
    	m_lpD3DDev->GetDeviceCaps(&d3dCaps);
    
    	if (d3dCaps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC)
    		m_dwBestMagFilter = D3DTEXF_ANISOTROPIC;
    	else
    		m_dwBestMagFilter = D3DTEXF_LINEAR;
    
    	if (d3dCaps.TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC)
    		m_dwBestMinFilter = D3DTEXF_ANISOTROPIC;
    	else
    		m_dwBestMinFilter = D3DTEXF_LINEAR;
    
    	DWORD dwMax = d3dCaps.MaxAnisotropy;
    	dwMax = dwMax < 4 ? dwMax : 4;
    
    	for (int i = 0; i < 8; ++i)
    		m_lpD3DDev->SetTextureStageState(i, D3DTSS_MAXANISOTROPY, dwMax);

    So could it be placed at the end of the 'CStateManager::SetDefaultState' function? Or it should be placed somewhere else in 'CStateManager::SetDefaultState' function?

    So it will look like this?

    Spoiler
    void CStateManager::SetDefaultState()
    {
    	m_CurrentState.ResetState();
    	m_CopyState.ResetState();
    	m_ChipState.ResetState();
    
    	m_bScene = false;
    	m_bForce = true;
    
    	D3DXMATRIX Identity;
    	D3DXMatrixIdentity(&Identity);
    
    	SetTransform(D3DTS_WORLD, &Identity);
    	SetTransform(D3DTS_VIEW, &Identity);
    	SetTransform(D3DTS_PROJECTION, &Identity);
    
    	D3DMATERIAL8 DefaultMat;
    	ZeroMemory(&DefaultMat, sizeof(D3DMATERIAL8));
    
    	DefaultMat.Diffuse.r = 1.0f;
    	DefaultMat.Diffuse.g = 1.0f;
    	DefaultMat.Diffuse.b = 1.0f;
    	DefaultMat.Diffuse.a = 1.0f;
    	DefaultMat.Ambient.r = 1.0f;
    	DefaultMat.Ambient.g = 1.0f;
    	DefaultMat.Ambient.b = 1.0f;
    	DefaultMat.Ambient.a = 1.0f;
    	DefaultMat.Emissive.r = 0.0f;
    	DefaultMat.Emissive.g = 0.0f;
    	DefaultMat.Emissive.b = 0.0f;
    	DefaultMat.Emissive.a = 0.0f;
    	DefaultMat.Specular.r = 0.0f;
    	DefaultMat.Specular.g = 0.0f;
    	DefaultMat.Specular.b = 0.0f;
    	DefaultMat.Specular.a = 0.0f;
    	DefaultMat.Power = 0.0f;
    
    	SetMaterial(&DefaultMat);
    
    	SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL);
    	SetRenderState(D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL);
    	SetRenderState(D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL);
    	SetRenderState(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_MATERIAL);
    
    	SetRenderState(D3DRS_LINEPATTERN, 0xFFFFFFFF);
    	SetRenderState(D3DRS_LASTPIXEL, FALSE);
    	SetRenderState(D3DRS_ALPHAREF, 1);
    	SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
    	SetRenderState(D3DRS_ZVISIBLE, FALSE);
    	SetRenderState(D3DRS_FOGSTART, 0);
    	SetRenderState(D3DRS_FOGEND, 0);
    	SetRenderState(D3DRS_FOGDENSITY, 0);
    	SetRenderState(D3DRS_EDGEANTIALIAS, FALSE);
    	SetRenderState(D3DRS_ZBIAS, 0);
    	SetRenderState(D3DRS_STENCILWRITEMASK, 0xFFFFFFFF);
    	SetRenderState(D3DRS_AMBIENT, 0x00000000);
    	SetRenderState(D3DRS_LOCALVIEWER, FALSE);
    	SetRenderState(D3DRS_NORMALIZENORMALS, FALSE);
    	SetRenderState(D3DRS_VERTEXBLEND, D3DVBF_DISABLE);
    	SetRenderState(D3DRS_CLIPPLANEENABLE, 0);
    	SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING, FALSE);
    	SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, FALSE);
    	SetRenderState(D3DRS_MULTISAMPLEMASK, 0xFFFFFFFF);
    	SetRenderState(D3DRS_INDEXEDVERTEXBLENDENABLE, FALSE);
    	SetRenderState(D3DRS_COLORWRITEENABLE, 0xFFFFFFFF);
    	SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
    	SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD);
    	SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);
    	SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
    	SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
    	SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
    	SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
    	SetRenderState(D3DRS_FOGENABLE, FALSE);
    	SetRenderState(D3DRS_FOGCOLOR, 0xFF000000);
    	SetRenderState(D3DRS_FOGTABLEMODE, D3DFOG_NONE);
    	SetRenderState(D3DRS_FOGVERTEXMODE, D3DFOG_LINEAR);
    	SetRenderState(D3DRS_RANGEFOGENABLE, FALSE);
    	SetRenderState(D3DRS_ZENABLE, TRUE);
    	SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
    	SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
    	SetRenderState(D3DRS_DITHERENABLE, TRUE);
    	SetRenderState(D3DRS_STENCILENABLE, FALSE);
    	SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
    	SetRenderState(D3DRS_CLIPPING, TRUE);
    	SetRenderState(D3DRS_LIGHTING, FALSE);
    	SetRenderState(D3DRS_SPECULARENABLE, FALSE);
    	SetRenderState(D3DRS_COLORVERTEX, FALSE);
    	SetRenderState(D3DRS_WRAP0, 0);
    	SetRenderState(D3DRS_WRAP1, 0);
    	SetRenderState(D3DRS_WRAP2, 0);
    	SetRenderState(D3DRS_WRAP3, 0);
    	SetRenderState(D3DRS_WRAP4, 0);
    	SetRenderState(D3DRS_WRAP5, 0);
    	SetRenderState(D3DRS_WRAP6, 0);
    	SetRenderState(D3DRS_WRAP7, 0);
    
    	SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
    	SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
    	SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_CURRENT);
    	SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
    	SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
    	SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
    
    	SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
    	SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
    	SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
    	SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
    	SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
    	SetTextureStageState(1, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
    
    	SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE);
    	SetTextureStageState(2, D3DTSS_COLORARG1, D3DTA_TEXTURE);
    	SetTextureStageState(2, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
    	SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
    	SetTextureStageState(2, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
    	SetTextureStageState(2, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
    
    	SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_DISABLE);
    	SetTextureStageState(3, D3DTSS_COLORARG1, D3DTA_TEXTURE);
    	SetTextureStageState(3, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
    	SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
    	SetTextureStageState(3, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
    	SetTextureStageState(3, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
    
    	SetTextureStageState(4, D3DTSS_COLOROP, D3DTOP_DISABLE);
    	SetTextureStageState(4, D3DTSS_COLORARG1, D3DTA_TEXTURE);
    	SetTextureStageState(4, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
    	SetTextureStageState(4, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
    	SetTextureStageState(4, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
    	SetTextureStageState(4, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
    
    	SetTextureStageState(5, D3DTSS_COLOROP, D3DTOP_DISABLE);
    	SetTextureStageState(5, D3DTSS_COLORARG1, D3DTA_TEXTURE);
    	SetTextureStageState(5, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
    	SetTextureStageState(5, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
    	SetTextureStageState(5, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
    	SetTextureStageState(5, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
    
    	SetTextureStageState(6, D3DTSS_COLOROP, D3DTOP_DISABLE);
    	SetTextureStageState(6, D3DTSS_COLORARG1, D3DTA_TEXTURE);
    	SetTextureStageState(6, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
    	SetTextureStageState(6, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
    	SetTextureStageState(6, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
    	SetTextureStageState(6, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
    
    	SetTextureStageState(7, D3DTSS_COLOROP, D3DTOP_DISABLE);
    	SetTextureStageState(7, D3DTSS_COLORARG1, D3DTA_TEXTURE);
    	SetTextureStageState(7, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
    	SetTextureStageState(7, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
    	SetTextureStageState(7, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
    	SetTextureStageState(7, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
    
    	SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);
    	SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1);
    	SetTextureStageState(2, D3DTSS_TEXCOORDINDEX, 2);
    	SetTextureStageState(3, D3DTSS_TEXCOORDINDEX, 3);
    	SetTextureStageState(4, D3DTSS_TEXCOORDINDEX, 4);
    	SetTextureStageState(5, D3DTSS_TEXCOORDINDEX, 5);
    	SetTextureStageState(6, D3DTSS_TEXCOORDINDEX, 6);
    	SetTextureStageState(7, D3DTSS_TEXCOORDINDEX, 7);
    
    	SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
    	SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
    	SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
    
    	SetTextureStageState(1, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
    	SetTextureStageState(1, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
    	SetTextureStageState(1, D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
    
    	SetTextureStageState(2, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
    	SetTextureStageState(2, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
    	SetTextureStageState(2, D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
    
    	SetTextureStageState(3, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
    	SetTextureStageState(3, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
    	SetTextureStageState(3, D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
    
    	SetTextureStageState(4, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
    	SetTextureStageState(4, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
    	SetTextureStageState(4, D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
    
    	SetTextureStageState(5, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
    	SetTextureStageState(5, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
    	SetTextureStageState(5, D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
    
    	SetTextureStageState(6, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
    	SetTextureStageState(6, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
    	SetTextureStageState(6, D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
    
    	SetTextureStageState(7, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
    	SetTextureStageState(7, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
    	SetTextureStageState(7, D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
    
    	SetTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
    	SetTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
    	SetTextureStageState(1, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
    	SetTextureStageState(1, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
    	SetTextureStageState(2, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
    	SetTextureStageState(2, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
    	SetTextureStageState(3, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
    	SetTextureStageState(3, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
    	SetTextureStageState(4, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
    	SetTextureStageState(4, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
    	SetTextureStageState(5, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
    	SetTextureStageState(5, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
    	SetTextureStageState(6, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
    	SetTextureStageState(6, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
    	SetTextureStageState(7, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
    	SetTextureStageState(7, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
    
    	SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, 0);
    	SetTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS, 0);
    	SetTextureStageState(2, D3DTSS_TEXTURETRANSFORMFLAGS, 0);
    	SetTextureStageState(3, D3DTSS_TEXTURETRANSFORMFLAGS, 0);
    	SetTextureStageState(4, D3DTSS_TEXTURETRANSFORMFLAGS, 0);
    	SetTextureStageState(5, D3DTSS_TEXTURETRANSFORMFLAGS, 0);
    	SetTextureStageState(6, D3DTSS_TEXTURETRANSFORMFLAGS, 0);
    	SetTextureStageState(7, D3DTSS_TEXTURETRANSFORMFLAGS, 0);
    
    	SetTexture(0, NULL);
    	SetTexture(1, NULL);
    	SetTexture(2, NULL);
    	SetTexture(3, NULL);
    	SetTexture(4, NULL);
    	SetTexture(5, NULL);
    	SetTexture(6, NULL);
    	SetTexture(7, NULL);
    
    	SetPixelShader(0);
    	SetVertexShader(D3DFVF_XYZ);
    
    	D3DXVECTOR4 av4Null[STATEMANAGER_MAX_VCONSTANTS];
    	memset(av4Null, 0, sizeof(av4Null));
    	SetVertexShaderConstant(0, av4Null, STATEMANAGER_MAX_VCONSTANTS);
    	SetPixelShaderConstant(0, av4Null, STATEMANAGER_MAX_PCONSTANTS);
    
    	m_bForce = false;
    
    #ifdef _DEBUG
    	int i, j;
    	for (i = 0; i < STATEMANAGER_MAX_RENDERSTATES; i++)
    		m_bRenderStateSavingFlag[i] = FALSE;
    
    	for (j = 0; j < STATEMANAGER_MAX_TRANSFORMSTATES; j++)
    		m_bTransformSavingFlag[j] = FALSE;
    
    	for (j = 0; j < STATEMANAGER_MAX_STAGES; ++j)
    		for (i = 0; i < STATEMANAGER_MAX_TEXTURESTATES; ++i)
    			m_bTextureStageStateSavingFlag[j][i] = FALSE;
    #endif _DEBUG
    	D3DCAPS8 d3dCaps;
    	m_lpD3DDev->GetDeviceCaps(&d3dCaps);
    
    	if (d3dCaps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC)
    		m_dwBestMagFilter = D3DTEXF_ANISOTROPIC;
    	else
    		m_dwBestMagFilter = D3DTEXF_LINEAR;
    
    	if (d3dCaps.TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC)
    		m_dwBestMinFilter = D3DTEXF_ANISOTROPIC;
    	else
    		m_dwBestMinFilter = D3DTEXF_LINEAR;
    
    	DWORD dwMax = d3dCaps.MaxAnisotropy;
    	dwMax = dwMax < 4 ? dwMax : 4;
    
    	for (int i = 0; i < 8; ++i)
    		m_lpD3DDev->SetTextureStageState(i, D3DTSS_MAXANISOTROPY, dwMax);
    }
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.