The Dawn Of Time
The Official Forums for the Dawn Of Time Mud Codebase
 
Log in Register FAQ Memberlist Search The Dawn Of Time Forum Index Goto the Official Dawn Website

bounty.c porting attempt :)

 
Post new topic   Reply to topic    The Dawn Of Time Forum Index » Migration/Porting
View previous topic :: View next topic  
Author Message
Amylon



Joined: 14 Mar 2003
Posts: 25
Location: Australia

PostPosted: Mon Mar 31, 2003 9:51 pm    Post subject: bounty.c porting attempt :) Reply with quote

Anyone see why this is causing me headaches?
I ported it across but it is causing segmentation faults and causing Nasty_signal_handler to do bad things to only some characters.
I can get it all to compile and run until I actually pkill someone.
At that point if that person is bountied it segmentation faults.

struct.h

under struct pc_data
add:

Code:
int               bounty;



SAVE.CPP

Under void fwrite_char()

Code:
fprintf( fp, "Bounty %d\n",   ch->pcdata->bounty  );


I put this under the line :
fprintf( fp, "Trust %d\n", ch->trust);


Under bool load_char_obj()
I added the following line just after:
Code:
ch->pcdata->killer_until         =0;


Code:
ch->pcdata->bounty         = 0;


Under fread_char()
find case 'B':, and in there add:

Code:
KEY( "Bounty",  ch->pcdata->bounty,   fread_number( fp ) );




FIGHT.CPP

Under Pay off for killing things in bool damage()

Code:
if (!IS_NPC(ch)
&& !IS_NPC(victim)
&& victim->pcdata->bounty > 0)
{
    sprintf(buf,"You recive a %d gold bounty, for killing %s.\n\r",
    victim->pcdata->bounty, victim->name);
    ch->println(buf);
    ch->gold += victim->pcdata->bounty;
    victim->pcdata->bounty =0;
}


ACT_COMM.CPP

Code:
void do_bounty( char_data *ch, char *argument )
{
    char arg1 [MIL];
    char arg2 [MIL];
    char buf[MSL];
    char_data *victim;

    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );


   if ( arg1[0] == '\0' || arg2[0] == '\0' )
        {
        ch->printlnf( "Place a bounty on who's head?\n\rSyntax: Bounty <victim> <amount>\n\r");
             return;
        }

        if ( ( victim = get_char_world( ch, arg1 ) ) == NULL)
   {
        ch->printlnf( "They are currently not logged in!");
      return;
        }

      if (IS_NPC(victim))
      {
   ch->printlnf( "You cannot put a bounty on NPCs!");
   return;
      }

   if ( is_number( arg2 ) )
        {
   int amount;
   amount   = atoi(arg2);
        if (ch->gold < amount)
        {
      ch->printlnf( "You don't have that much gold!");
      return;
        }
   ch->gold -= amount;
   victim->pcdata->bounty +=amount;
   sprintf( buf, "You have placed a %d gold bounty on %s'g.\n\r%s now has a bounty of %d gold.",
   amount,victim->name,victim->name,victim->pcdata->bounty );
        ch->println(buf);
   return;
   }
}


Did the interp.h and .cpp file.



_________________
Amylon
Unity can only be manifested by the Binary. Unity itself and the idea of Unity are already two. -- Kabbalah
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Kalahn
Codebase Developer


Joined: 18 Jan 2003
Posts: 710
Location: New Zealand

PostPosted: Tue Apr 01, 2003 10:00 am    Post subject: Reply with quote

What platform are you running/developing on?
Try doing a "make clean", then a "make"... let us know if you still have a problem... also quote the snotes regarding the crash.

If it is on a linux machine, try using gdb to debug the core file (assuming you get a core)... this can be done by typing "gdb dawn core", followed by "bt", then "quit".

If you don't get a core dump, quote the output of "ulimit -a".

- Kal


Back to top
View user's profile Send private message Visit poster's website
Amylon



Joined: 14 Mar 2003
Posts: 25
Location: Australia

PostPosted: Tue Apr 01, 2003 2:12 pm    Post subject: Reply with quote

Very Happy Ok did a clean make and bam now it all runs perfect. Very Happy
Must have been an uncleasn issue in there somewhere. Oh well thanks.
Bounty now works fine, I can now work on actually making it cool with a ROOM_FLAG etc.

Laughing



_________________
Amylon
Unity can only be manifested by the Binary. Unity itself and the idea of Unity are already two. -- Kabbalah
Back to top
View user's profile Send private message Send e-mail MSN Messenger
patories



Joined: 15 Sep 2003
Posts: 202
Location: USA

PostPosted: Thu Oct 02, 2003 2:19 am    Post subject: Reply with quote

Ok I know I am missing something, but I cant seem to find it....

I copied everything as is, into my code, I went into my Interps and added

INTERP CPP:

{ "bs", do_backstab, POS_FIGHTING, 0, LOG_NORMAL, 0 },
{ "bounty", do_bounty, POS_RESTING 0,
LOG_NORMAL, 1 },
{ "bug", do_bug, POS_DEAD, 0, LOG_NORMAL, 1 },


INTERP H

DECLARE_DO_FUN( do_berserk );
DECLARE_DO_FUN( do_bounty );
DECLARE_DO_FUN( do_brandish );

I do a Make clean, but when I try to make a new clean I get the following errors:

fight.cpp: In function 'bool damage(char_data*, char_data*, int, int,int, bool)':
1798, 1801,1803,1804: Struct pc_data' as no member named "bounty'
1800: "buf' undeclared (first use this function)
1800 (each undeclared identifier is reported only once for each function it appears in.)

Now from my understanding of my recent attempts, the struct pc_data error is meaning that I dont have my bounty properly defined for those 4 lines. I also believe that the error on 1800 is caused by the same thing...

My question is where did I forget to assign this at??

Thanks



_________________
Patories

Imp of Shattered Illusions--Talislanta RPG
Karthos.genesismuds.com 1381

Novice Developer for KDAV Systems

"So you're saying I put down my sword and you put down your rock and we kill eachother like civilized men?"
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
ganieda



Joined: 08 Feb 2003
Posts: 297
Location: US

PostPosted: Thu Oct 02, 2003 7:28 pm    Post subject: Reply with quote

You didn't add bounty in the pc_data struct in struct.h

and you didn't declare buf properly (probably char buf[MSL];)


Back to top
View user's profile Send private message Send e-mail
patories



Joined: 15 Sep 2003
Posts: 202
Location: USA

PostPosted: Fri Oct 03, 2003 3:32 am    Post subject: Reply with quote

Bounty was added to struct.H
located right here:

int xp_penalty;
sh_int sublevel, sublevel_trains, sublevel_pracs;
int bounty;
unsigned char olc_tab;


And in ACT this is were I have it:
char arg2 [MIL];
char buf[MSL];
char_data *victim;


Now I am getting this nice headache....

act_comm.cpp: In function `void do_bounty(char_data *, char *)':
act_comm.cpp:3007: `struct pc_data' has no member named `bounty'
act_comm.cpp:3009: `struct pc_data' has no member named `bounty'
make: *** [act_comm.o] Error 1


Which that makes me think that my struct.h location is wrong but I cant seem to figure this out at all.....

Sorry to be a bother with this....



_________________
Patories

Imp of Shattered Illusions--Talislanta RPG
Karthos.genesismuds.com 1381

Novice Developer for KDAV Systems

"So you're saying I put down my sword and you put down your rock and we kill eachother like civilized men?"
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
DarkChaos



Joined: 18 Sep 2003
Posts: 43

PostPosted: Sun Oct 26, 2003 6:11 pm    Post subject: Reply with quote

Hey,

Bounty is a pretty cool feature and I have it working fine. However I would like to the give double the bounty for people in the mercenary clan. Simple enough.... I have it all coded up but I cant find anything to use as an if statement... I can get it to check if they are in a clan no prob. But I cant seem to find a way to determine if they are in a specific clan. Any Ideas?
Hans



_________________
"Chaos is the force that drives us all"
Dawn of Krynn Founder
66.93.224.150 :8000
-Nuitari
Back to top
View user's profile Send private message Send e-mail MSN Messenger
ganieda



Joined: 08 Feb 2003
Posts: 297
Location: US

PostPosted: Mon Oct 27, 2003 5:29 pm    Post subject: Reply with quote

if( !str_cmp( ch->clan->cname(), "mercenary" ) )

or whatever the clan's name is.


Back to top
View user's profile Send private message Send e-mail
Darakis



Joined: 23 Sep 2003
Posts: 23
Location: Australia

PostPosted: Mon Apr 19, 2004 12:28 am    Post subject: Reply with quote

I noticed that you said that you were going to create a room flag for this snippet?

How would one go about that?

I figure that you would put

#define ROOM_BOUNTY_OFFICE in dawn.h
but where and how do you do an if check?

Also is there a way that an object can be hardcoded to show players who has bounties on them? This is due to the fact that at present the only person that knows that there is a bounty is the person who sets it.

Thanks in Advance


Back to top
View user's profile Send private message Yahoo Messenger
ganieda



Joined: 08 Feb 2003
Posts: 297
Location: US

PostPosted: Mon Apr 19, 2004 3:27 am    Post subject: Reply with quote

Someone had a working port of this code, check the snippets section.


Back to top
View user's profile Send private message Send e-mail
Darakis



Joined: 23 Sep 2003
Posts: 23
Location: Australia

PostPosted: Mon Apr 19, 2004 4:39 am    Post subject: Reply with quote

No one has it done in snippets.

I have this running I just dont know how to do the things I listed above such as the if check and bounty list.


Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    The Dawn Of Time Forum Index » Migration/Porting All times are GMT + 13 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001-2005 phpBB Group
Theme created by Vjacheslav Trushkin