zamotivator

Untitled

Feb 4th, 2012
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.83 KB | None | 0 0
  1. Hello guys,
  2.  
  3. I investigated "save_index" and confused by several things. General questions:
  4.  
  5. 1) Which the reason create save_index file?
  6. If I right understood, only two purposes:
  7. a) decrease time of open "Load" dialog
  8. b) decrease time of render clicked save - show preview, game
  9. description, company name, etc.
  10.  
  11. Perfomance reason, other words. Please approve/disapprove my understanding.
  12.  
  13. 2) Unfortunatelly, right now "save_index" does not used by anywhere in game.
  14.  
  15. I see just single call of save_index: write_save_index() (I skipped
  16. definition of class and definition of methods):
  17.  
  18. src/savegame.hpp: /** Update the save_index */
  19. src/dialogs.cpp: config& cfg = savegame::save_index::save_summary(i->name);
  20. src/dialogs.cpp: savegame::save_index::write_save_index();
  21.  
  22. You can check this by "find ./src -exec grep save_index". From this
  23. point of view, right now save_index nobody used.
  24. I also checked it by stacktraces *(see end of letter)
  25.  
  26. In typical game usage nowhere is used :(
  27.  
  28. 3) I supposed - save_index used before, but right now code with usage
  29. removed. I investigated revision history by git bisect and can't
  30. confirm this -
  31.  
  32. commit fd497d4601f40acb0bc16c5c2ec3353767b94e92
  33. Author: Sirp <Sirp@75b3775d-3801-0410-9e12-e2e43121521d>
  34. Date: Thu Jun 10 00:35:45 2004 +0000
  35.  
  36. added new 'load' dialog. changed behavior of pressing 'space' to
  37. end a unit's turn
  38.  
  39. git-svn-id: svn+ssh://svn.gna.org/svn/wesnoth/trunk@2265
  40. 75b3775d-3801-0410-9e12-e2e43121521d
  41.  
  42. 4) Current code directly read the dir with saves and parse every file
  43. separatelly. You can see this in src/gui/dialogs/game_load.cpp:
  44. tgame_load::display_savegame
  45.  
  46. So, I want to change this situation, and full support of the
  47. "save_index" in soure code.
  48. I need this at least for:
  49. http://forums.wesnoth.org/viewtopic.php?f=10&t=36034&p=519985#p519985
  50. - for group the saves by game I should parse all saves.
  51. This is required a lot of time.
  52.  
  53. Suppose we avoid directly read the directory, and use "save_index"
  54. instead of direct read.
  55. Which problem we will meet?
  56.  
  57. 1) SHORT: missed save_index
  58. PROBLEM: User doesn't have "save_index" file, but have saves (for
  59. example, he move saves from another folder). As result "save_index"
  60. will no loaded, and user didn't see any saves.
  61. SOLUTION: rebuild save_index by directly read saves files while game is starting
  62.  
  63. 2) SHORT: save_index file too old
  64. PROBLEM: User add some new save files, not listed in save_index
  65. SOLUTION: as in (1) - rebuild save_index directly from saves files
  66. (probably read & parse just new files, not listed in save_index).
  67.  
  68. 3) SHORT: user added save file while play to game and wants open it.
  69. PROBLEM: added saves will not listed in "open" dialog without game restart.
  70.  
  71. SOLUTION (simple): on open "Load" dialog read the filename and
  72. modify_time from directory (this is right now happendessin tgame_load)
  73. and compare their with information from save_index.
  74.  
  75. SOLUTION (hard): use inotify/similar things for get updates about new
  76. files. Unreasonably complex solution.
  77.  
  78. So, right now I wants to do SOLUTION(3)(simple). I would like again
  79. repeat what I will change:
  80. 1) replay direct file read in tgame_load by information from save_index
  81. 2) implement function "update" for save_index - function list all
  82. files from save_directory, and update information in save_index file
  83. 3) call "update" function on every open of game load dialog.
  84.  
  85. How this plan for you?
  86.  
  87. Best regards, Oleg
  88.  
  89. savegame::save_index::load
  90. savegame::save_index::save_summary
  91. dialogs::load_game_dialog
  92. savegame::loadgame::show_dialog
  93. savegame::loadgame::load_game
  94. game_controller::load_game
  95. do_gameloop
  96. main
  97.  
  98. savegame::save_index::load
  99. savegame::save_index::write_save_index
  100. dialogs::load_game_dialog
  101. savegame::loadgame::show_dialog
  102. savegame::loadgame::load_game
  103. game_controller::load_game
  104. do_gameloop
  105. main
Advertisement
Add Comment
Please, Sign In to add comment