Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use_obj_on_obj from global script crashes even with set_self #214

Closed
burner1024 opened this issue Nov 9, 2018 · 8 comments
Closed

use_obj_on_obj from global script crashes even with set_self #214

burner1024 opened this issue Nov 9, 2018 · 8 comments

Comments

@burner1024
Copy link
Contributor

The following will crash the game:

procedure skill_handler begin
  variable user := get_sfall_arg;
  variable target := get_sfall_arg;
  variable skill := get_sfall_arg;
  variable skill_bonus := get_sfall_arg;
  variable skill_level := critter_skill_level(user, skill);
  variable item;
  variable skill_points := get_critter_skill_points(user, skill);
  ndebug("user is " + obj_name(user) + ", target is " + obj_name(target)
    + ", skill is " + skill + ", skill level is " + skill_level + ", bonus is " + skill_bonus
    + ", skill points is " + skill_points);
  if skill == SKILL_REPAIR then begin
    set_sfall_return(0);
    item := create_object(PID_SUPER_TOOL_KIT, 0, 0);
    add_obj_to_inven(user, item);
    set_self(user);
    ndebug("self is " + obj_name(self_obj) + ", item is " + obj_name(item));
    set_self(user);
    use_obj_on_obj(item, target);
  end
end

Apparently this a known issue, any chance it will be fixed?

@FakelsHub
Copy link
Contributor

В следующей версии (4.1.5) сделаю исправление, но нужно будет двойное применение функции set_self

    set_self(user);
    set_self(user);
    use_obj_on_obj(item, target);

@burner1024
Copy link
Contributor Author

отлично

@burner1024
Copy link
Contributor Author

А какой смысл два раза кстати? Обратная совместимость? Так вроде ничего не должно сломаться.

@FakelsHub
Copy link
Contributor

FakelsHub commented Jan 9, 2019

Потому, что под капотом в функции два раза вызывается функционал, при котором сбрасывается установка setself. Придумал сделать счетчик для сброса.

NovaRain added a commit that referenced this issue Jan 21, 2019
@NovaRain
Copy link
Collaborator

NovaRain commented Jan 21, 2019

Here's the build from the latest commit with fixes for issue 196 & 214. It also prints error when the given sfall global var name is not 8 character long:
http://www.mediafire.com/file/ypukznmi58az8rj/ddraw_20190121.rar/file

@burner1024 Could you test the build to see if the fixes/changes work for your intended scripts?
One major improvement for fs_* function is now the altered virtual files (i.e. those FRMs in your demo script) don't get saved automatically in save games, unless you specifically set the flag for them using fs_resize(fileId, -1), so there won't be large sfallfs.sav files cluttered in player's save game folders.

@burner1024
Copy link
Contributor Author

Will do

NovaRain added a commit that referenced this issue Jan 22, 2019
@burner1024
Copy link
Contributor Author

@NovaRain awesome, everything seems to be working correctly, both this issue and #196.

Maybe also add a warning to fs_* if UseFileSystemOverride is disabled?

@FakelsHub
Copy link
Contributor

Maybe also add a warning to fs_* if UseFileSystemOverride is disabled?

В скрипте это делайте.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants