Added some missing variable initializations

- The issue was caused by memcmp failing because of garbage in structs
  padding.
- Fixes bugreport:8410, special thanks (and credits for the fix) to Garr
  http://hercules.ws/board/tracker/issue-8410-autotradeat-issue/
- Also reduced scope of some variables, where appropriate.
- Thanks to Ind.

Signed-off-by: Haru <haru@dotalux.com>