- Port server core and libraries to Linux and 32-bit ARM (armhf): * Replace FreeBSD kqueue with Linux epoll in libthecore fdwatch * Fix unaligned float and 64-bit int memory stores in utils.h str_to_number to avoid ARM VFP alignment fault (SIGBUS) * Fix getopt loop variable type in main.cpp (char -> int) to eliminate infinite loop caused by default unsigned char on ARM * Add -fsigned-char and multi-architecture flags to Makefiles (x86_64 -m32, i386, and ARM armhf) * Update libsql for modern MariaDB client library (removed reconnect field) and C++20 concept/syntax compatibility * Replace Win32 xdirent with standard POSIX dirent on Unix/Linux * Include xmd5 in libthecore on non-FreeBSD platforms - AVA2 unlock features and tools: * Material stacking up to 2000 count, refine material resolution and test suites * AVA2 ticket shop and point drop configuration updates
42 lines
3.0 KiB
Python
42 lines
3.0 KiB
Python
"""Actual refinement debit planner with explicit inventory primitives; no RNG or wallet substitutes."""
|
|
import subprocess,tempfile,unittest
|
|
from pathlib import Path
|
|
ROOT=Path(__file__).resolve().parents[2]
|
|
class Refine(unittest.TestCase):
|
|
def test_atomic_aggregate_debits_across_storage_and_invalid_sources(self):
|
|
code=r'''
|
|
#include <algorithm>
|
|
#include <map>
|
|
#include <vector>
|
|
#include <cstdint>
|
|
#include <cassert>
|
|
#define ENABLE_SPECIAL_STORAGE
|
|
using DWORD=uint32_t;using BYTE=uint8_t;
|
|
enum{INVENTORY=1,UPGRADE_INVENTORY=8,BOOK_INVENTORY,STONE_INVENTORY,CHANGE_INVENTORY,COSTUME_INVENTORY};
|
|
constexpr unsigned INVENTORY_MAX_NUM=225,SPECIAL_INVENTORY_MAX_NUM=180;
|
|
struct Material{DWORD vnum,count;};struct TRefineTable{unsigned material_count=0;Material materials[5]={};};
|
|
struct TItemPos{unsigned window,cell;TItemPos(unsigned w,unsigned c):window(w),cell(c){}};
|
|
struct Character;
|
|
struct Item{unsigned id,cell,vnum,count;Character* owner=nullptr;bool equipped=false,exchanging=false,locked=false,skip=false;
|
|
unsigned GetID(){return id;}unsigned GetCell(){return cell;}unsigned GetVnum(){return vnum;}unsigned GetCount(){return count;}
|
|
Character* GetOwner(){return owner;}bool IsEquipped(){return equipped;}bool IsExchanging(){return exchanging;}bool isLocked(){return locked;}bool GetSkipSave(){return skip;}void SetCount(unsigned n){assert(n<=count);count=n;}};
|
|
using LPITEM=Item*;struct Shop{unsigned selling=0;bool IsSellingItem(unsigned id){return id==selling;}};
|
|
struct Character{std::map<std::pair<unsigned,unsigned>,Item*> items;Shop shop;Item* GetItem(TItemPos p){auto it=items.find({p.window,p.cell});return it==items.end()?nullptr:it->second;}Shop* GetMyShop(){return &shop;}};
|
|
using LPCHARACTER=Character*;
|
|
#include "src/server/game/src/port_refine_materials.h"
|
|
int main(){Character ch;Item a{1,0,30053,2000,&ch},b{2,1,30006,1000,&ch};ch.items[{UPGRADE_INVENTORY,0}]=&a;ch.items[{INVENTORY,1}]=&b;
|
|
TRefineTable r;r.material_count=1;r.materials[0]={30053,1};assert(PortRefineTakeMaterials(&ch,&r)&&a.count==1999);
|
|
r.material_count=2;r.materials[0]={30053,1000};r.materials[1]={30053,1000};assert(!PortRefineTakeMaterials(&ch,&r)&&a.count==1999);
|
|
r.materials[1].count=999;assert(PortRefineTakeMaterials(&ch,&r)&&a.count==0);
|
|
r.material_count=1;r.materials[0]={30006,256};
|
|
for(unsigned kind=0;kind<5;++kind){b.equipped=kind==0;b.exchanging=kind==1;b.locked=kind==2;b.skip=kind==3;ch.shop.selling=kind==4?b.id:0;assert(!PortRefineTakeMaterials(&ch,&r)&&b.count==1000);}
|
|
b.equipped=b.exchanging=b.locked=b.skip=false;ch.shop.selling=0;assert(PortRefineTakeMaterials(&ch,&r)&&b.count==744);
|
|
r.material_count=2;r.materials[0]={30006,500};r.materials[1]={30053,1};assert(!PortRefineTakeMaterials(&ch,&r)&&b.count==744);
|
|
r.material_count=0;assert(PortRefineTakeMaterials(&ch,&r));
|
|
}
|
|
'''
|
|
with tempfile.TemporaryDirectory() as td:
|
|
p=Path(td)/'probe.cpp';p.write_text(code);exe=Path(td)/'probe'
|
|
subprocess.run(['c++','-std=c++17','-fsanitize=address,undefined','-I'+str(ROOT),str(p),'-o',str(exe)],check=True);subprocess.run([str(exe)],check=True)
|
|
if __name__=='__main__':unittest.main()
|