fix bug in reroll shops and ugc compile issues in linux

This commit is contained in:
Ondřej Novák 2025-08-08 14:25:35 +02:00
parent bd6ca836ba
commit acec6ad268
3 changed files with 27 additions and 22 deletions

View file

@ -2797,7 +2797,7 @@ static void rebuild_shops(const void *shop_ptr)
++state_iter; ++state_iter;
} }
++shop_iter; ++shop_iter;
SEND_LOG("(SHOP) Shop found: '%s', products %d",shop_list[i]->keeper,shop_list[i]->products); SEND_LOG("(SHOP) Shop found: '%s', id=%d, products %d",shop_list[i]->keeper,shop_list[i]->shop_id, shop_list[i]->products);
} }
stringtable_free(stbl); stringtable_free(stbl);
free(shop_hacek); free(shop_hacek);
@ -3404,20 +3404,22 @@ static void reroll_shop(TSHOP *p)
} }
} }
pr=p->list; pr=p->list;
for(i=0;i<p->spec_max;i++) if (poc_spec) {
{ for(i=0;i<p->spec_max;i++)
int i=0; {
r=rnd(poc_spec)+1; int i=0;
for(j=0;i<r;j++) if (pr[j].trade_flags & SHP_SPECIAL) i++; r=rnd(poc_spec)+1;
j--; for(j=0;i<r;j++) if (pr[j].trade_flags & SHP_SPECIAL) i++;
const TPRODUCT *sel = pr+j; j--;
int maxp = sel->max_pocet; const TPRODUCT *sel = pr+j;
if (maxp) { int maxp = sel->max_pocet;
*get_product_count(pr+j)=rnd(maxp)+1; if (maxp) {
} else { *get_product_count(pr+j)=rnd(maxp)+1;
*get_product_count(pr+j) = 0; } else {
} *get_product_count(pr+j) = 0;
} }
}
}
} }
void reroll_all_shops() void reroll_all_shops()

View file

@ -427,7 +427,7 @@ THANDLE_DATA *def_handle(int handle,const char *filename,ABLOCK_DECODEPROC decom
get_file_entry(path,h->src_file,h); get_file_entry(path,h->src_file,h);
} }
SEND_LOG("(REGISTER) File/Block registred '%-.12s' handle %04X",h->src_file,handle); SEND_LOG("(REGISTER) File/Block registred '%-.12s' handle %04X",h->src_file,handle);
SEND_LOG("(REGISTER) Seekpos=%d",h->seekpos); SEND_LOG("(REGISTER) Seekpos=%d",h->offset);
h->flags=0; h->flags=0;
h->path=path; h->path=path;
if (h->status!=BK_DIRLIST) h->status=BK_NOT_LOADED; if (h->status!=BK_DIRLIST) h->status=BK_NOT_LOADED;

View file

@ -1,5 +1,8 @@
#include "ugc.h" #include "ugc.h"
#include "config.h" #include "config.h"
#include <algorithm>
#include <cstring>
#include <fstream> #include <fstream>
#include <vector> #include <vector>
#include <filesystem> #include <filesystem>
@ -147,7 +150,7 @@ size_t UGC_Fetch(UGCManager *manager) {
auto tlen = title.size()+1; auto tlen = title.size()+1;
auto alen = author.size()+1; auto alen = author.size()+1;
auto dlen = strlen(ddl)+1; auto dlen = std::strlen(ddl)+1;
r.text_data = std::make_unique<char[]>(tlen+alen+dlen); r.text_data = std::make_unique<char[]>(tlen+alen+dlen);
char *c = r.text_data.get(); char *c = r.text_data.get();