| 3037 | | slot = highscore_where(old, score); |
|---|
| 3038 | | |
|---|
| 3039 | | /* Read entries from the old and write them to the new */ |
|---|
| 3040 | | for (i = 0; (i < MAX_HISCORES) && !error; i++) |
|---|
| 3041 | | { |
|---|
| 3042 | | if (!highscore_seek(old, i)) return (-1); |
|---|
| 3043 | | |
|---|
| 3044 | | /* Insert the new one at the right slot */ |
|---|
| 3045 | | if (i == slot) |
|---|
| 3046 | | { |
|---|
| 3047 | | if (!file_write(new, (const char *)score, sizeof(high_score))) |
|---|
| 3048 | | { |
|---|
| 3049 | | error = TRUE; |
|---|
| 3050 | | slot = -1; |
|---|
| 3051 | | } |
|---|
| 3052 | | } |
|---|
| 3053 | | |
|---|
| 3054 | | /* Read old one, write again */ |
|---|
| 3055 | | if (highscore_read(old, &tmpscore)) |
|---|
| 3056 | | { |
|---|
| 3057 | | if (!file_write(new, (const char *)&tmpscore, sizeof(high_score))) |
|---|
| 3058 | | { |
|---|
| 3059 | | error = TRUE; |
|---|
| 3060 | | slot = -1; |
|---|
| 3061 | | } |
|---|
| | 3039 | if (old) |
|---|
| | 3040 | { |
|---|
| | 3041 | slot = highscore_where(old, score); |
|---|
| | 3042 | |
|---|
| | 3043 | /* Read entries from the old and write them to the new */ |
|---|
| | 3044 | for (i = 0; (i < MAX_HISCORES) && !error; i++) |
|---|
| | 3045 | { |
|---|
| | 3046 | if (!highscore_seek(old, i)) return (-1); |
|---|
| | 3047 | |
|---|
| | 3048 | /* Insert the new one at the right slot */ |
|---|
| | 3049 | if (i == slot) |
|---|
| | 3050 | { |
|---|
| | 3051 | if (!file_write(new, (const char *)score, sizeof(high_score))) |
|---|
| | 3052 | { |
|---|
| | 3053 | error = TRUE; |
|---|
| | 3054 | slot = -1; |
|---|
| | 3055 | } |
|---|
| | 3056 | } |
|---|
| | 3057 | |
|---|
| | 3058 | /* Read old one, write again */ |
|---|
| | 3059 | if (highscore_read(old, &tmpscore)) |
|---|
| | 3060 | { |
|---|
| | 3061 | if (!file_write(new, (const char *)&tmpscore, sizeof(high_score))) |
|---|
| | 3062 | { |
|---|
| | 3063 | error = TRUE; |
|---|
| | 3064 | slot = -1; |
|---|
| | 3065 | } |
|---|
| | 3066 | } |
|---|
| | 3067 | } |
|---|
| | 3068 | |
|---|
| | 3069 | file_close(old); |
|---|
| | 3070 | } |
|---|
| | 3071 | else |
|---|
| | 3072 | { |
|---|
| | 3073 | slot = 0; |
|---|
| | 3074 | if (!file_write(new, (const char *)score, sizeof(high_score))) |
|---|
| | 3075 | { |
|---|
| | 3076 | error = TRUE; |
|---|
| | 3077 | slot = -1; |
|---|