stream[netchan_t::unreliabledata] buffer overflow (Player_hurt)

Please post any questions about developing your plugin here. Please use the search function before posting!
arawra
Senior Member
Posts: 190
Joined: Fri Jun 21, 2013 6:51 am

stream[netchan_t::unreliabledata] buffer overflow (Player_hurt)

Postby arawra » Sat Aug 20, 2016 2:11 pm

Syntax: Select all

@Event('player_hurt')
def player_hurt(ev):
if ev['attacker'] != ev['userid'] and ev['attacker'] != 0:
vindex = index_from_userid(ev['userid'])
aindex = index_from_userid(ev['attacker'])
victim = Player(vindex)
attacker = Player(aindex)
damage = int(ev['dmg_health'])
addPlayer(vindex)
addPlayer(aindex)
crit = random.randint(1,100)
if getClass(aindex) == 'Fighter' and getLevel(aindex) > 14:
crit += 10
if crit > 95:
dndDamage(vindex, damage, aindex)
playerMessage(aindex, 'Your attack was a critical hit!')
if victim.team != attacker.team:
if dndPlayers[vindex]['dodge']:
if random.randint(1,100) < dndPlayers[vindex]['dodge']:
playerMessage(vindex, 'You dodged %s damage!'%damage)
victim.health += damage
pass
if 'immune' in dndPlayers[vindex]:
if dndPlayers[vindex]['immune']:
victim.health += damage
playerMessage(vindex, 'A Hymn as prevented damage!')
pass
if 'curse' in dndPlayers[vindex]:
if dndPlayers[vindex]['curse']:
dndDamage(vindex, int(damage*.1), aindex)

invisColor = attacker.get_color() # Throws error on this line



def addPlayer(index):
global dndDB, dndPlayers
steamid = uniqueid_from_index(index)
if steamid not in dndDB:
dndDB[steamid] = {}
for item in ['kills', 'deaths', 'gold']:
if item not in dndDB[steamid]:
dndDB[steamid][item] = 0
for className in allClasses:
if className not in dndDB[steamid]:
dndDB[steamid][className] = {}
for item in ['xp','level']:
if item not in dndDB[steamid][className]:
dndDB[steamid][className] = {'xp':0,'level':1}
if index not in dndPlayers:
dndPlayers[index] = {}
dndPlayers[index]['className'] = 'Fighter'
dndPlayers[index]['race'] = 'Human'
dndPlayers[index]['spree'] = 0
resetPlayer(index)
if not isBot(index):
if 'last played class' in dndDB[uniqueid_from_index(index)]:
if dndDB[uniqueid_from_index(index)]['last played class']:
dndPlayers[index]['className'] = dndDB[uniqueid_from_index(index)]['last played class']
if 'last played race' in dndDB[uniqueid_from_index(index)]:
if dndDB[uniqueid_from_index(index)]['last played race']:
dndPlayers[index]['race'] = dndDB[uniqueid_from_index(index)]['last played race']


Code: Select all

SendNetMsg 192.168.56.1:27005: stream[netchan_t::unreliabledata] buffer overflow (maxsize = 4000)!

[SP] Caught an Exception:
Traceback (most recent call last):
  File '..\addons\source-python\packages\source-python\events\listener.py', line 92, in fire_game_event
    callback(game_event)
  File '..\addons\source-python\plugins\dnd\dnd.py', line 441, in player_hurt
    invisColor = invisPlayer.get_color()
  File '..\addons\source-python\packages\source-python\entities\entity.py', line 238, in get_color
    return self.render_color
  File '..\addons\source-python\packages\source-python\entities\entity.py', line 99, in __getattr__
    return getattr(make_object(server_class, self.pointer), attr)
  File '..\addons\source-python\packages\source-python\memory\manager.py', line 135, in _obj
    return cls(ptr, wrap=True)
  File '..\addons\source-python\packages\source-python\memory\manager.py', line 87, in __init__
    if self.__class__.__name__ not in self._manager:

RecursionError: maximum recursion depth exceeded while calling a Python object

User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: stream[netchan_t::unreliabledata] buffer overflow (Player_hurt)

Postby Ayuto » Sat Aug 20, 2016 5:34 pm

You are dealing damage in player_hurt. That might cause the recursion.
User avatar
iPlayer
Developer
Posts: 590
Joined: Sat Nov 14, 2015 8:37 am
Location: Moscow
Contact:

Re: stream[netchan_t::unreliabledata] buffer overflow (Player_hurt)

Postby iPlayer » Sat Aug 20, 2016 6:31 pm

You might want to use a pre-hook on Player.on_take_damage
That enables you to increase/decrease damage or completely cancel the damage.

Restoring player's health after they have been hit just in order to cancel the damage is not a good idea, as player might die from the initial damage. Pre-hook would be the way to go.
Image /id/its_iPlayer
My plugins: Map Cycle • Killstreaker • DeadChat • Infinite Jumping • TripMines • AdPurge • Bot Damage • PLRBots • Entity AntiSpam

Hail, Companion. [...] Hands to yourself, sneak thief. Image
arawra
Senior Member
Posts: 190
Joined: Fri Jun 21, 2013 6:51 am

Re: stream[netchan_t::unreliabledata] buffer overflow (Player_hurt)

Postby arawra » Sat Aug 20, 2016 7:56 pm

I was going to do PreHooking, just thought that the loop may be caused by something else.

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 37 guests