MCServer Development Discussion
#41
- Moved this thread to a more suitable forum -
Reply
Thanks given by:
#42
(10-24-2011, 09:29 AM)FakeTruth Wrote: - Moved this thread to a more suitable forum -

nice










Watching these kids talk on the server thinking it's a bukkit server is hilarious.

The health message is definitely causing crashes. I can't see what's causing it though.

The the message "Entity was not in chunk..." comes up there's also a bit of lag the the server stops responding.





I found this in cClientHandle.cpp

Code:
        case E_BLOCK_DIG:
            {
                cPacket_BlockDig* PacketData = reinterpret_cast<cPacket_BlockDig*>(a_Packet);
                //LOG("OnBlockDig: %i %i %i Dir: %i Stat: %i", PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ, PacketData->m_Direction, PacketData->m_Status );
                if( PacketData->m_Status == 0x04 )    // Drop block
                {
                    m_Player->TossItem( false );
                }
                else
                {
                    cWorld* World = cRoot::Get()->GetWorld();
                    char OldBlock = World->GetBlock(PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ);
                    char MetaData = World->GetBlockMeta(PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ);
                    bool bBroken = (PacketData->m_Status == 0x02) || g_BlockOneHitDig[(int)OldBlock];

                    cItem PickupItem;
                    if( bBroken ) // broken
                    {
                        ENUM_ITEM_ID PickupID = cBlockToPickup::ToPickup( (ENUM_BLOCK_ID)OldBlock, m_Player->GetInventory().GetEquippedItem().m_ItemID );
                        PickupItem.m_ItemID = PickupID;
                        PickupItem.m_ItemHealth = MetaData;
                        PickupItem.m_ItemCount = 1;
                    }
                    if(!cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_BLOCK_DIG, 2, PacketData, m_Player, &PickupItem ) )
                    {
                        if( bBroken ) // Block broken
                        {
                            if( cRoot::Get()->GetWorld()->DigBlock( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ, PickupItem ) )
                            {
                                m_Player->GetInventory().GetEquippedItem().m_ItemHealth ++;
                                LOG("Health: %i", m_Player->GetInventory().GetEquippedItem().m_ItemHealth);
                            }
                        }
                    }
                    else
                    {
                        cRoot::Get()->GetWorld()->SendBlockTo( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ, m_Player );
                    }
                }
            }
            break;



I *think* that's cause by using a client nuke with a tool in hand.
Reply
Thanks given by:
#43
Yes, as you can see there's no security, once the server receives the block dig packet, it will simply destroy the block (even if it's bedrock/adminium).

The security is relatively easy to implement.
According to this digging has a couple of stages.
Once the packet has been received for "start digging", store the XYZ coordinates and the current time.
Once the packet for "finished digging" is received, check coordinates and make sure enough time has elapsed before breaking the block.
???
profit
Reply
Thanks given by:
#44
That sounds easy enough. If someone sends finished digging too quickly the packet can be ignored. If it happens too many times it should probably kick or temp ban them.
Reply
Thanks given by:
#45
Be aware that some blocks only send finished digging, and no start digging because they break in one hit, for example flowers and tnt.
Another trick you can use is to check if the block the player is digging is within range of the player
Reply
Thanks given by:
#46
Hi! I tried to compile the server with Visual C++ 2010 Express. First of all, it thrown an error about missing 'afxres.h' but when I replaced it with 'windows.h' then the compilation went fine.
After I tried to run the server, it crashed during terrain generation (in noise.cpp, cNoise::SSE_IntNoise2D, Illegal instruction). I ran it with generated map, it runs fine but whenever a new chunk is generated it crashes, did you encounter similar problems before?
Reply
Thanks given by:
#47
This seems to be a problem with any AMD processor right now. To fix it find and replace all instance of "SSE_" with "" without the quotes in source/cChunk.cpp

In other words, just delete every instance of "SSE_" without the quotes, but keep the rest of the function name in there, the old noise generation functions are still in the code.
Reply
Thanks given by:
#48
Thanks, it worked.

I noticed cWorld::GetBlock and cWorld::GetBlockMeta both return char, wouldn't unsigned char be more suitable?
Reply
Thanks given by:
#49
(11-06-2011, 06:45 AM)Sebi Wrote: Thanks, it worked.

I noticed cWorld::GetBlock and cWorld::GetBlockMeta both return char, wouldn't unsigned char be more suitable?
AFAIK Java does not have unsigned chars so there's no benefit in making it an unsigned char in C++. Also if you know Notch, he might do something funky with it later which might require it to be a signed char
Reply
Thanks given by:
#50
Notch's thoughts: *I'm running out of block ids!* *Idea! Let's use negative ids!* :V

Also, in cPlayer.cpp (and also somewhere in monster file) at line 265 you have
Code:
char block = GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y, (int)m_Pos->z );
And there are some rounding issues with negative coords (you are set on fire one block off lava block)
Something like this shall do:
Code:
#define float2int(x) ((x)<0 ? ((int)(x))-1 : (int)(x))
char block = GetWorld()->GetBlock( float2int(m_Pos->x), float2int(m_Pos->y), float2int(m_Pos->z) );
Reply
Thanks given by:




Users browsing this thread: 2 Guest(s)