[req] Auto Clearmap

Codes already submitted by people of the forums.
EvilHit
Loyal fan
Posts: 356
Joined: Sun Jan 16, 2005 3:20 am

Post by EvilHit »

hey im lookin for auto clear map like it clears the map every 10 mins or so
Aragorn
Regular
Posts: 81
Joined: Fri Mar 03, 2006 12:02 pm

Post by Aragorn »

EvilHit wrote: hey im lookin for auto clear map like it clears the map every 10 mins or so
go home
The fear of making permanent commitments can change the mutual love of husband and wife into two loves of self-two loves existing side by side, until they end in separation.
KLKS
Loyal fan
Posts: 218
Joined: Sun Feb 22, 2004 2:32 pm

Post by KLKS »

aight i'll work on that code, shouldnt be too hard, i have the concept just have to put it on code :)
Dax
<3 bd long time
Posts: 785
Joined: Mon Apr 18, 2005 3:19 pm

Post by Dax »

EvilHit wrote: hey im lookin for auto clear map like it clears the map every 10 mins or so
Great idea. Let me just drop my Devastator for a second to clear some space and WTF WHERE DID IT GO? Give the items 5minutes each on the ground before they clear like runescape did. Clearing entire maps at the same time will cause problems for players.
Reppin' 127.0.0.1!!!<br><br><img src='http://img502.imageshack.us/img502/1348/sig4daxbn2.jpg' border='0' alt='user posted image' /><br><br>I contend that we are both atheists. I just believe in one fewer god than you do. <br>When you understand why you dismiss all the other possible gods, you will <br>understand why I dismiss yours.<br>~ <b>Stephen Roberts</b>
KLKS
Loyal fan
Posts: 218
Joined: Sun Feb 22, 2004 2:32 pm

Post by KLKS »

and thats why smart people break down their maps into multiple HG's ;)

Code: Select all

in CGame::CGame(HWND hWnd) add

	dwItemCleanLastTime = GetTickCount();
	dwItemCleanDelay = 600000;	//600k ms = 10 mins
	dwItemDeleteDelay = 300000; //300k ms = 5 mins

Code: Select all

in "class CGame" add

	DWORD dwItemCleanLastTime;  //Last time a map was cleaned
	DWORD dwItemCleanDelay;  	//After how long before we should clean
	DWORD dwItemDeleteDelay;  //How long should an item be on floor before it gets deleted

Code: Select all

in "class CItem" add

DWORD m_dwItemTime;

Code: Select all

in "CItem::CItem()" add

m_dwItemTime = GetTickCount();

Code: Select all

in DropItemHandler add

  if ((m_pClientList[iClientH]->m_pItemList[sItemIndex]->m_sItemEffectType == DEF_ITEMEFFECTTYPE_ALTERITEMDROP) && 
  	(m_pClientList[iClientH]->m_pItemList[sItemIndex]->m_wCurLifeSpan == 0)) {
    delete m_pClientList[iClientH]->m_pItemList[sItemIndex];
    m_pClientList[iClientH]->m_pItemList[sItemIndex] = NULL;
  	}
  else {
  	//Update item time *NEW*
  	m_pClientList[iClientH]->m_pItemList[sItemIndex]->m_dwItemTime = GetTickCount();

  	m_pMapList[ m_pClientList[iClientH]->m_cMapIndex ]->bSetItem(m_pClientList[iClientH]->m_sX, 
    m_pClientList[iClientH]->m_sY, 
    m_pClientList[iClientH]->m_pItemList[sItemIndex]);

Code: Select all

in DelayEventProcessor() add

	if ((dwTime - dwItemCleanLastTime) > dwItemCleanDelay)	//Had time elapsed ?
  AutoClearMap();

Code: Select all

in Map.cpp add this new function

int CMap::iGetTotalItemsOnTile(short sX, short sY)
{
 class CTile * pTile;	
 class CItem * pItem;
	if ((sX < 0) || (sX >= m_sSizeX) || (sY < 0) || (sY >= m_sSizeY)) return NULL;

	pTile = (class CTile *)(m_pTile + sX + sY*m_sSizeY);
	pItem =  pTile->m_pItem[0];
	return pTile->m_cTotalItem;
}

Code: Select all

in Map.h add this function declaration

int iGetTotalItemsOnTile(short sX, short sY);

Code: Select all

add a new function void CGame::AutoClearMap()

void CGame::AutoClearMap()
{

 int i, k, j, m_y, m_x;

	for (i = 0; i < DEF_MAXMAPS; i++) { //Enum all maps
  if (m_pMapList[i] != NULL) {	//Is allocated map
  	m_x = m_pMapList[i]->m_sSizeX;
  	m_y = m_pMapList[i]->m_sSizeY;
  	for(j = 1; j < m_x; j++) {
    for(k = 1; k < m_y; k++){
    	m_pMapList[i]->CleanTile(j, k, dwItemDeleteDelay);
    }
  	}
  }
	}

	PutLogList("(!!!) AutoClearMap Executed!");

	//Update last clean time
	dwItemCleanLastTime = GetTickCount();
}

Code: Select all

in Game.h add this function declaration

void AutoClearMap();

Code: Select all

add a new function in Map.cpp

void CMap::CleanTile(short sX, short sY, DWORD dwItemDeleteDelay)
{
 class CTile * pTile;	
 class CItem * pItem[DEF_TILE_PER_ITEMS];
 register int i,j;
 DWORD dwTime;

	if ((sX < 0) || (sX >= m_sSizeX) || (sY < 0) || (sY >= m_sSizeY)) return;

	pTile = (class CTile *)(m_pTile + sX + sY*m_sSizeY);
	if (pTile->m_cTotalItem == 0) return;

	dwTime = GetTickCount();	//Get time

	ZeroMemory(pItem, sizeof(pItem));	//Zero the whole pItem structure

	for (i = 0, j = 0; i <= DEF_TILE_PER_ITEMS-2; i++){	//Enum all items on tile
  if (pTile->m_pItem[i] != NULL)
  {
  	if ((dwTime - pTile->m_pItem[i]->m_dwItemTime) > dwItemDeleteDelay)	//Item has been on ground for too long
  	{
    delete pTile->m_pItem[i];	//Delete item which has been on floor for too long
    pTile->m_pItem[i] = NULL;
  	}
  	else{	//This code only keeps live items
    pItem[j++] = pTile->m_pItem[i];	//Copy item to a temp place
  	}
  }
	}

	//Copy back data of items
	//No need to NULL out pTile as pItem has its sturcture NULLED out at the start
	for (i = 0; i <= DEF_TILE_PER_ITEMS-2; i++)
  pTile->m_pItem[i] = pItem[i];

}

Code: Select all

in Map.h add this function declaration

void CleanTile(short sX, short sY, DWORD dwItemDeleteDelay);
this piece of code should work, havent tested it cos dont have HB at work :). anyhow please test it and tell me if there is any bugs.

one bug to note tho, when the map is cleaned, items at the top which are deleted are not refreshed so player still "sees" the old items, but its not there. i'll fix that problem once i get more time :)

ps for all u wannabe HB coders, you cant code, if you could, you would be helping instead of posting useless stuff ;)
EvilHit
Loyal fan
Posts: 356
Joined: Sun Jan 16, 2005 3:20 am

Post by EvilHit »

just let me no when ur finished klks thx for doin this for me
Dshaked
&lt;3 bd long time
Posts: 747
Joined: Tue Oct 11, 2005 6:40 pm

Post by Dshaked »

LOL some abaddon drops Devastator :D ,and where it goes?:DD::D
Old Helbreath Nemesis Player<br><img src='http://img232.imageshack.us/img232/9784/dshakedqc5.jpg' border='0' alt='user posted image' /><br><img src='http://img232.imageshack.us/img232/6475 ... barqj0.jpg' border='0' alt='user posted image' /><br><a href='index.php?showtopic=7107&hl=' target='_blank'>MainServer Hexing Tutorial</a><br><a href='index.php?showtopic=7663&hl=x-mas' target='_blank'>My Files</a>
KLKS
Loyal fan
Posts: 218
Joined: Sun Feb 22, 2004 2:32 pm

Post by KLKS »

autoclean is triggered every 10 mins, cleaning all items on floor longer than 5 mins. i'm sure it dosent that u THAT long to pick up those items ? :P
unless of cos ur partially a turd or something :P
Shetar
Member
Posts: 148
Joined: Sun Nov 30, 2003 12:57 am

Post by Shetar »

I think it won't work;

for(j = 1; j < m_x; j++) {
  for(k = 1; k < m_y; k++){
   m_pMapList->CleanTile(m_x, m_y, dwItemDeleteDelay);


See for yourself..
Helbreath II Project Manager & All round Developer. <br><i>(Don't worry, we're not dead)</i>
Shetar
Member
Posts: 148
Joined: Sun Nov 30, 2003 12:57 am

Post by Shetar »

And a suggestion;

void CGame::AutoClearMap()
{

int i, k, j, m_y, m_x;
short sOwner;
char cOwnerType;

for (i = 0; i < DEF_MAXMAPS; i++) { //Enum all maps
if (m_pMapList != NULL) { //Is allocated map
m_x = m_pMapList->m_sSizeX;
m_y = m_pMapList->m_sSizeY;
for(j = 1; j < m_x; j++) {
for(k = 1; k < m_y; k++){
m_pMapList[m_pClientList[iClientH]->m_cMapIndex]->GetOwner(&sOwner, &cOwnerType, j, k);
if (sOwner == NULL || cOwnerType != DEF_OWNERTYPE_PLAYER) {

m_pMapList->CleanTile(j, k, dwItemDeleteDelay);
}
}
}
}
}

PutLogList("(!!!) AutoClearMap Executed!");

//Update last clean time
dwItemCleanLastTime = GetTickCount();
}
Helbreath II Project Manager & All round Developer. <br><i>(Don't worry, we're not dead)</i>
KLKS
Loyal fan
Posts: 218
Joined: Sun Feb 22, 2004 2:32 pm

Post by KLKS »

ahhh my bad :), tnx for correcting it. didnt have a chance of testing the code. just wrote it off the top of my head with whatever hg code i could get.

and a note
m_pMapList[m_pClientList[iClientH]->m_cMapIndex]->GetOwner(&sOwner, &cOwnerType, j, k);
if (sOwner == NULL || cOwnerType != DEF_OWNERTYPE_PLAYER)

we want to clean a map irregardless if a player is standing on an item or not. maybe an option in configs to check for this would be nice.
Shetar
Member
Posts: 148
Joined: Sun Nov 30, 2003 12:57 am

Post by Shetar »

Let's see..:
-What if I happen to give someone an item, but the guy is full and the map is being cleared at the same moment?
-What if I just wanted to grab a monster drop?
-Search for hidden items event game?
-Manufacturing succeeds, but you're full and the item drops underneath you?

Most of the time players aren't standing on items, but it's still a little bit extra security.
Helbreath II Project Manager & All round Developer. <br><i>(Don't worry, we're not dead)</i>
KLKS
Loyal fan
Posts: 218
Joined: Sun Feb 22, 2004 2:32 pm

Post by KLKS »

-What if I happen to give someone an item, but the guy is full and the map is being cleared at the same moment?

you got 5 minutes to pick the item up before it gets cleared, but the clearning code gets executed every 10 minutes once, so in an hour, it cleans the maps 6 times :P

-What if I just wanted to grab a monster drop?
you still have 5 minutes

-Search for hidden items event game?
i'm sure we can derive some code which can make an item uncleanable :P

-Manufacturing succeeds, but you're full and the item drops underneath you?

you got 5 minutes to save that item :P

one thing i think should be added. 1 minute before map clears, the server should broadcast a message to all players that map is being cleared.
Shetar
Member
Posts: 148
Joined: Sun Nov 30, 2003 12:57 am

Post by Shetar »

KLKS wrote: -What if I happen to give someone an item, but the guy is full and the map is being cleared at the same moment?

you got 5 minutes to pick the item up before it gets cleared, but the clearning code gets executed every 10 minutes once, so in an hour, it cleans the maps 6 times :P

-What if I just wanted to grab a monster drop?
you still have 5 minutes

-Search for hidden items event game?
i'm sure we can derive some code which can make an item uncleanable :P

-Manufacturing succeeds, but you're full and the item drops underneath you?

you got 5 minutes to save that item :P

one thing i think should be added. 1 minute before map clears, the server should broadcast a message to all players that map is being cleared.
My bad :o

I thought you made 2 seperate functions, which can both be used by a server depending on their wish. I only skimmed your source :)
Helbreath II Project Manager & All round Developer. <br><i>(Don't worry, we're not dead)</i>
666666
Regular
Posts: 39
Joined: Thu Nov 24, 2005 1:14 pm

Post by 666666 »

what if there was a note that said "Map clearing in X minutes", that way people will know when to drop items and when to pick them up. Just a thought.
Post Reply