Fix multiple vault bug

Results 1 to 16 of 16
  1. #1
    Proficient Member Gangztah is offline
    MemberRank
    Aug 2006 Join Date
    CLOUD 9Location
    163Posts

    Fix multiple vault bug

    While testing the server files (996x 8-15 release)..
    found vault bug when typing /keep <negative number> (ex. /keep -999).

    With this, all can have more than the number of vault
    (ex. WareHouseNum = 3) u specified in gamserver.ini .

    Say, for WareHouseNum=3..
    Players can select vault 0 to 3 but cant access vault 4 up.
    Unfortunately, players can access vault -1 to -999 above if they type
    /keep -1 to /keep -999 above which in turn creating huge number
    of vaults for each account.

    I cross examined the extra warehouse procedures and come up with
    a simple fix below (correct me if I'm wrong or got better idea):

    Just edit the following Stored Procedures like so:

    For WHS_SELECT:
    Code:
     
    CREATE       proc WHS_SELECT 
    @op int,
    @Accountid varchar(10)
    as
    set nocount on
    declare @aid varchar(10)
     ,@cknum int
    if @op=1 begin --读取ID,检查仓库是否存在
     SELECT @aid=AccountID,@cknum=NeedExtCK FROM warehouse WHERE AccountID=@accountid
     if @cknum is null begin  --打开主仓库
      INSERT INTO warehouse (AccountID, Items, Money, EndUseDate, DbVersion) 
       VALUES (@accountid,cast(REPLICATE(char(0xff),1200) as varbinary(1200))
        ,0, getdate(), 1)
      Select @accountid AS AccountID
     end else begin
      Update warehouse Set ExtCKNum=NeedExtCK WHERE AccountID=@accountid
      if  @cknum<=0
       Select @aid AS AccountID
      else begin
       if not EXISTS (select AccountID FROM ExtWareHouse WHERE AccountID=@accountid and Number=@cknum) begin
        INSERT INTO ExtWarehouse (AccountID,Number,Items, Money, EndUseDate, DbVersion) 
         VALUES (@accountid,@cknum,cast(REPLICATE(char(0xff),1200) as varbinary(1200))
          ,0, getdate(), 1)
       end
       Select @accountid AS AccountID
      end
     end
    end else if @op=2 begin
     SELECT @cknum=ExtCKNum FROM warehouse WHERE AccountID=@accountid
            if @cknum<=0 begin
      SELECT Items from warehouse where AccountID=@accountid
           end
     else begin
      SELECT Items from ExtWareHouse WHERE AccountID=@Accountid AND Number=@cknum
                 end
    end else begin
     SELECT @cknum=ExtCKNum FROM warehouse WHERE AccountID=@accountid
     if @cknum<=0
      SELECT Money, DbVersion, pw from warehouse where AccountID=@accountid
     else
      SELECT Money, DbVersion, pw from ExtWareHouse where AccountID=@accountid AND Number=@cknum
    end
    set nocount off
    GO
    For WHS_UPD_Items:
    Code:
    CREATE    proc WHS_UPD_Items 
    @items varchar(2500),
    @Accountid varchar(10)
    as
    set nocount on
    declare @cknum int
    SELECT @cknum=ExtCKNum FROM warehouse WHERE AccountID=@accountid
    if @cknum<=0 --主仓库
     UPDATE warehouse set Items=cast(@items as varbinary(1200))
       where AccountID=@accountid
    else
     UPDATE ExtWareHouse set Items=cast(@items as varbinary(1200))
      where AccountID=@accountid AND Number=@cknum
    --waitfor delay '00:00:10'
    set nocount off
    GO
    For WHS_UPD_MnyPwDbv:
    Code:
     
    CREATE      proc WHS_UPD_MnyPwDbv
    @mny int,
    @pw int,
    @dbv int,
    @Accountid varchar(10)
    as
    set nocount on
    declare @cknum int
    SELECT @cknum=ExtCKNum FROM warehouse WHERE AccountID=@accountid
    if @cknum<=0 begin --主仓库
     if @pw=0
      UPDATE warehouse set Money=@mny,pw=@pw,DbVersion=@dbv
        where AccountID=@accountid
     else
      UPDATE warehouse set Money=@mny,pw=@pw,lastpw=@pw,DbVersion=@dbv
        where AccountID=@accountid
     UPDATE ExtWareHouse set pw=@pw where AccountID=@accountid
    end else begin
     UPDATE ExtWareHouse set Money=@mny,pw=@pw,DbVersion=@dbv
      where AccountID=@accountid AND Number=@cknum
     UPDATE ExtWareHouse set pw=@pw where AccountID=@accountid
     if @pw=0
      UPDATE WareHouse set pw=@pw where AccountID=@accountid
     else
      UPDATE WareHouse set pw=@pw,lastpw=@pw where AccountID=@accountid
    end
    --waitfor delay '00:00:10'
    set nocount off
    GO
    For WHS_UPD_Money:

    Code:
     
    CREATE    proc WHS_UPD_Money
    @mny int,
    @Accountid varchar(10)
    as
    set nocount on
    declare @cknum int
    SELECT @cknum=ExtCKNum FROM warehouse WHERE AccountID=@accountid
    if @cknum<=0 --主仓库
     UPDATE warehouse set Money=@mny
       where AccountID=@accountid
    else
     UPDATE ExtWareHouse set Money=@mny
      where AccountID=@accountid AND Number=@cknum
    --waitfor delay '00:00:10'
    set nocount off
    GO
    What the changes do?
    Whenever a player tries to type /keep <negative number>..
    He will be redirected to vault 0 (normal vault).

    NOTE: If u have better FIX please post here.

    I hope this helps. :)
    Last edited by Gangztah; 30-08-06 at 09:11 AM.


  2. #2
    urvoice.info andsnake is offline
    MemberRank
    Feb 2005 Join Date
    NicosiaLocation
    398Posts
    wow, i didnt know this. thanks :-)

  3. #3
    Proficient Member Gangztah is offline
    MemberRank
    Aug 2006 Join Date
    CLOUD 9Location
    163Posts
    Hehe tell me if it works on you :)

  4. #4
    Account Upgraded | Title Enabled! goehdtjdrnr is offline
    MemberRank
    Nov 2004 Join Date
    KoreaLocation
    420Posts
    thanks ^^ works !!!

  5. #5
    Proficient Member Gangztah is offline
    MemberRank
    Aug 2006 Join Date
    CLOUD 9Location
    163Posts
    thank u too for sharing the files mate :)

  6. #6
    Account Upgraded | Title Enabled! HELL_IN_HEAVEN is offline
    MemberRank
    Apr 2006 Join Date
    BORACAY, PHILIPPINESLocation
    530Posts
    can som1 enlighten us about this extra warehouse?

  7. #7
    Member nicksalad is offline
    MemberRank
    Jul 2005 Join Date
    PhilippinesLocation
    81Posts
    thanks m8, good work. :clap_1: i guess im not a good tester cuz i didn't noticed that :hang:

  8. #8
    Proficient Member Gangztah is offline
    MemberRank
    Aug 2006 Join Date
    CLOUD 9Location
    163Posts
    Well, nobody's perfect hehe :)
    Last edited by Gangztah; 30-08-06 at 04:01 PM.

  9. #9
    Valued Member mig1st4ck is offline
    MemberRank
    Jan 2006 Join Date
    PortugalLocation
    118Posts
    hi good work.
    I didn't tryed that.
    but there is a simple change.
    Let me tell how these new vaults work. in the procedures.

    WHS_UPD_Money This don't work. You can delete it because its not executed.
    WHS_UPD_MnyPwDbv this change the money, pass of vault and version of vault. and its only executed when you close the vault.
    WHS_UPD_Items this save the items. so when you close the vault it executes this to save the items.
    WHS_SELECT this is executed when you Open the vault. it says the Items, money, pass and version.

    And final. You only need to change this procedure to fix the bug.
    WHS_SELECT_UP
    this is executed when you type /keep
    So if you change the info when it start you correct all the bug.

    ALTER proc WHS_SELECT_UP
    @num int,
    @Name varchar(10)
    as
    set nocount on
    declare @aid varchar(10)
    declare @cknum int
    If @num>0 begin
    SELECT @aid=AccountID FROM Character WHERE Name=@Name
    SELECT @cknum=NeedExtCK FROM warehouse WHERE AccountID=@aid
    if @cknum is null begin -- Opens Vault
    INSERT INTO warehouse (AccountID, Items, Money, EndUseDate, DbVersion)
    VALUES (@aid,cast(REPLICATE(char(0xff),1200) as varbinary(1200))
    ,0, getdate(), 2)
    end
    Update warehouse Set NeedExtCK=@num WHERE AccountID=@aid
    Select @num AS NeedExtCK
    end
    I hope it help.

  10. #10
    Apprentice bossnirvana is offline
    MemberRank
    Oct 2005 Join Date
    spainLocation
    7Posts
    I did all that , and now nobody can open the vault 0, that was the main one, I have had to return to put like was because with those fix baul 0 cannot be opened, that I can do? thanks

  11. #11
    Valued Member mig1st4ck is offline
    MemberRank
    Jan 2006 Join Date
    PortugalLocation
    118Posts
    Quote Originally Posted by bossnirvana View Post
    I did all that , and now nobody can open the vault 0, that was the main one, I have had to return to put like was because with those fix baul 0 cannot be opened, that I can do? thanks
    yeah you are right. ^^

    just put it like this

    ALTER proc WHS_SELECT_UP
    @num int,
    @Name varchar(10)
    as
    set nocount on
    declare @aid varchar(10)
    declare @cknum int
    If @num>=0 begin

    SELECT @aid=AccountID FROM Character WHERE Name=@Name
    SELECT @cknum=NeedExtCK FROM warehouse WHERE AccountID=@aid
    if @cknum is null begin -- Opens Vault
    INSERT INTO warehouse (AccountID, Items, Money, EndUseDate, DbVersion)
    VALUES (@aid,cast(REPLICATE(char(0xff),1200) as varbinary(1200))
    ,0, getdate(), 2)
    end
    Update warehouse Set NeedExtCK=@num WHERE AccountID=@aid
    Select @num AS NeedExtCK
    end
    Put it > or =
    because 0 is not included in >

    thx for noticed that =)

  12. #12
    Proficient Member Gangztah is offline
    MemberRank
    Aug 2006 Join Date
    CLOUD 9Location
    163Posts
    Hi mig :)

    Nice fix but if u want flexibility & more option, my fix comes in handy when combine with urs..

    If u change the following:

    In ur fix change @num>=0 to @num>=1 ..
    In my fix change @cknum<=0 to @cknum<=1 ..

    The result will be, if u type /keep 1 = normal vault (not /keep 0), /keep 2 = 2nd vault.
    This makes it easier for the players to understand which vault they are into (minimize confusion).
    And of course, WareHouseNum = 2 in gameserver.ini would now mean TOTAL VAULTS and
    not just ADDITIONAL/EXTRA VAULTS.
    If u have existing 'Number' values (ex. Number=1) in extwarehouse table,
    just update the value to +1 (ex. Number=1 will now be Number=2 since 1 is reserved for ur normal vault)

    :smile:

    EDIT:
    Or u can just ignore the WHS_SELECT_UP fix and
    just apply my fix + mod so that /keep 0 will still redirect u to ur normal vault.
    Last edited by Gangztah; 31-08-06 at 01:29 PM.

  13. #13
    Valued Member mig1st4ck is offline
    MemberRank
    Jan 2006 Join Date
    PortugalLocation
    118Posts
    Quote Originally Posted by Gangztah View Post
    Hi mig :)

    Nice fix but if u want flexibility & more option, my fix comes in handy when combine with urs..

    If u change the following:

    In ur fix change @num>=0 to @num>=1 ..
    In my fix change @cknum<=0 to @cknum<=1 ..

    The result will be, if u type /keep 1 = normal vault (not /keep 0), /keep 2 = 2nd vault.
    This makes it easier for the players to understand which vault they are into (minimize confusion).
    And of course, WareHouseNum = 2 in gameserver.ini would now mean TOTAL VAULTS and
    not just ADDITIONAL/EXTRA VAULTS.
    If u have existing 'Number' values (ex. Number=1) in extwarehouse table,
    just update the value to +1 (ex. Number=1 will now be Number=2 since 1 is reserved for ur normal vault)

    :smile:

    EDIT:
    Or u can just ignore the WHS_SELECT_UP fix and
    just apply my fix + mod so that /keep 0 will still redirect u to ur normal vault.
    There is much ways to edit this. and configure what ever you like.
    The way you are saying maybe you come to have some problems. the new players in the server. if they open the vault before they type /keep any. the result will be.
    They will store in vault 0. them they type /keep 1. and it will open a new vault. so items in 0 will be lost.

    For me i prefere to set /keep 0 to the normal vault. them 4 adictional vaults.
    So they actualy have 5 vaults.
    Them they type /keep 5. and OMG guild vault. ^^

    Like i say you can do everything with these scripts.

  14. #14
    Proficient Member Gangztah is offline
    MemberRank
    Aug 2006 Join Date
    CLOUD 9Location
    163Posts
    Quote Originally Posted by mig1st4ck View Post
    The way you are saying maybe you come to have some problems. the new players in the server. if they open the vault before they type /keep any. the result will be.
    They will store in vault 0. them they type /keep 1. and it will open a new vault. so items in 0 will be lost.
    Hehe i dont know about u mate, but it's obvious in the script that scenario
    wont happen, and to confirm it i tested in all possible ways but what u said
    never happened.

    Anyways, thanks for comment. :)

  15. #15
    Valued Member mig1st4ck is offline
    MemberRank
    Jan 2006 Join Date
    PortugalLocation
    118Posts
    If you only change WHS_SELECT_UP.
    that will happen. but
    Quote Originally Posted by mig1st4ck View Post
    Like i say you can do everything with these scripts.
    And it will work.

  16. #16
    Proficient Member Gangztah is offline
    MemberRank
    Aug 2006 Join Date
    CLOUD 9Location
    163Posts
    Yes that's why i never said edit only WHS_SELECT_UP

    Quote Originally Posted by Gangztah View Post
    Nice fix but if u want flexibility & more option, my fix comes in handy when combine with urs..

    If u change the following:

    In ur fix change @num>=0 to @num>=1 ..
    In my fix change @cknum<=0 to @cknum<=1 ..
    Just want to make that clear :)
    Well, enough said, ur fix is cool but i just post my own in case someone
    ever need to modify the way i did.

    Cya.



Advertisement