diff --git a/README.md b/README.md index 6e29dd7..abc4aa3 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@

-GitHub License GitHub Issues or Pull Requests GitHub Actions Workflow Status +GitHub License GitHub Pull Requests GitHub Issues + +

My Simulation is an **experimental** open source multiplayer game based upon The Sims Online. It attempts to mimic the original game as closely as possible while extending it with new features. diff --git a/build.zig b/build.zig index 23fc87e..c1992aa 100644 --- a/build.zig +++ b/build.zig @@ -16,7 +16,7 @@ pub fn build(b: *std.Build) void { const optimize = b.standardOptimizeOption(.{}); const exe = b.addExecutable(.{ - .name = "mysimulation", + .name = "mysim", .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, @@ -80,6 +80,7 @@ pub fn build(b: *std.Build) void { }); exe_unit_tests.linkLibC(); + exe_unit_tests.linkLibCpp(); exe_unit_tests.addIncludePath(.{ .path = "./library" }); exe_unit_tests.root_module.addImport("raylib", raylib); diff --git a/build.zig.zon b/build.zig.zon index 3704098..ed1dd74 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,8 +1,8 @@ .{ - .name = "mysimulation", + .name = "mysim", // This is a [Semantic Version](https://semver.org/). // In a future version of Zig it will be used for package deduplication. - .version = "0.1.100", + .version = "0.1.101", // This field is optional. // This is currently advisory only; Zig does not yet do anything diff --git a/library/extra/d20/d20.c b/library/extra/d20/d20.c new file mode 100644 index 0000000..80c7757 --- /dev/null +++ b/library/extra/d20/d20.c @@ -0,0 +1,120 @@ +#include + +#include +#include +#include + +#define MAX_UINT64_T 18446744073709551615ul; + +/*---------------------------------------------------------------------------*/ + +/* This is xoshiro256** 1.0, one of our all-purpose, rock-solid + generators. It has excellent (sub-ns) speed, a state (256 bits) that is + large enough for any parallel application, and it passes all tests we + are aware of. + + For generating just floating-point numbers, xoshiro256+ is even faster. + + The state must be seeded so that it is not everywhere zero. If you have + a 64-bit seed, we suggest to seed a splitmix64 generator and use its + output to fill s. */ + +static uint64_t rotl(const uint64_t x, int k) { + return (x << k) | (x >> (64 - k)); +} + +uint64_t s[4]; + +uint64_t next(void) { + const uint64_t result = rotl(s[1] * 5, 7) * 9; + + const uint64_t t = s[1] << 17; + + s[2] ^= s[0]; + s[3] ^= s[1]; + s[1] ^= s[2]; + s[0] ^= s[3]; + + s[2] ^= t; + + s[3] = rotl(s[3], 45); + + return result; +} + +/*---------------------------------------------------------------------------*/ + +int roll_from_char_array(const char *ca){ + int dice = 0; + int sides = 0; + int modifier = 0; + + int d_token = 0; + int m_token = 0; + + char *d_tok = (char *)"d"; + char *D_tok = (char *)"D"; + char *mi_tok = (char *)"-"; + char *pl_tok = (char *)"+"; + + while(*ca != '\0'){ + + if(*ca == *d_tok || *ca == *D_tok){ + d_token = 1; + } else if(*ca == *mi_tok) { + m_token = -1; + } else if (*ca == *pl_tok) { + m_token = 1; + } else { + if(d_token == 0) + { + dice = dice * 10; + dice += *ca - '0'; + } else if(m_token == 0){ + sides = sides * 10; + sides += *ca - '0'; + } else { + modifier = modifier * 10; + modifier += *ca - '0'; + } + } + ++ca; + } + + modifier = modifier * m_token; + + if(dice == 0){ + return ROLL_FROM_CHAR_ARRAY_PARSE_FAILURE_NO_NUMBER_DICE; + } else if (sides == 0){ + return ROLL_FROM_CHAR_ARRAY_PARSE_FAILURE_NO_NUMBER_OF_SIDES; + } + + return roll(dice, sides, modifier); +} + +int roll(int dice, int sides, int modifier){ + uint64_t one = rand(); + uint64_t two = rand(); + uint64_t three = rand(); + uint64_t four = rand(); + + s[0] = one; + s[1] = two; + s[2] = three; + s[3] = four; + + unsigned mask; + mask = (1 << 12) - 1; + //uint8_t i=0,parts[8]={0}; + + int a = 0; + int result = 0; + + do { + result += (int) floor(((float) (next() & mask) / (float) 4096) * (float) sides) + 1; + ++a; + } while (a < dice); + result += modifier; + + return result; +} \ No newline at end of file diff --git a/library/extra/d20/d20.h b/library/extra/d20/d20.h new file mode 100644 index 0000000..5c8b980 --- /dev/null +++ b/library/extra/d20/d20.h @@ -0,0 +1,22 @@ +/** @file d20.h + * @brief Implements Dungeons & Dragons style dice in C + * + * d20.h is a reimplementation of https://github.com/opensourcedoc/d20-c, + * but following the principles of being a single header/file library with + * a minimal API + * + * @author adamml + * @date 2022-11-07 +*/ + +#ifndef COM_GITHUB_ADAMML_D20 +#define COM_GITHUB_ADAMML_D20 + + +#define ROLL_FROM_CHAR_ARRAY_PARSE_FAILURE_NO_NUMBER_DICE -9999; /* The number of dices to roll was not correctly parsed */ +#define ROLL_FROM_CHAR_ARRAY_PARSE_FAILURE_NO_NUMBER_OF_SIDES -99999; /* The number of sides on the dice was not correctl parsed */ + +int roll_from_char_array(const char *ca); +int roll(int dice, int sides, int modifer); + +#endif \ No newline at end of file diff --git a/library/formats/core.h b/library/formats/core.h deleted file mode 100644 index 0d8ce2a..0000000 --- a/library/formats/core.h +++ /dev/null @@ -1,7 +0,0 @@ -#include "iff/iff.h" -#include "iff/iffparser.h" -#include "far/far.h" -#include "far/config.h" -#include "xa/read_xa.h" -#include "utk/read_utk.h" -#include "xa/read_xa.h" \ No newline at end of file diff --git a/library/libvitaboy/THANKS b/library/libvitaboy/THANKS index e8aa6b1..0fbdd64 100644 --- a/library/libvitaboy/THANKS +++ b/library/libvitaboy/THANKS @@ -1,10 +1 @@ - --------------------------------|---------------------------------------------------------------- -| Thanks to | for | -|--------------------------------|----------------------------------------------------------------| -| Don Hopkins | Kickstarting The Sims 1 customization, encouraging fine | -| | individuals to document the game, and most importantly, | -| | sharing with us his documentation of his VitaBoy skeletal | -| | character animation library used in The Sims 1, in the form | -| | of articles and videos. Dozens of thanks from each one of us. | -| (*) | - ------------------------------------------------------------------------------------------------- \ No newline at end of file +Thanks to Don Hopkins (https://donhopkins.medium.com/) for kickstarting The Sims 1 customization, encouraging fine individuals to document the game, and most importantly, sharing with us his documentation of his VitaBoy skeletal character animation library used in The Sims 1, in the form of articles and videos. Dozens of thanks from each one of us. \ No newline at end of file diff --git a/resources/items/dorms/8dsdormchair.iff b/resources/items/dorm/8dsdormchair.iff similarity index 100% rename from resources/items/dorms/8dsdormchair.iff rename to resources/items/dorm/8dsdormchair.iff diff --git a/resources/items/dorms/8dsdormdesk.iff b/resources/items/dorm/8dsdormdesk.iff similarity index 100% rename from resources/items/dorms/8dsdormdesk.iff rename to resources/items/dorm/8dsdormdesk.iff diff --git a/resources/items/dorms/8dsdormendtable.iff b/resources/items/dorm/8dsdormendtable.iff similarity index 100% rename from resources/items/dorms/8dsdormendtable.iff rename to resources/items/dorm/8dsdormendtable.iff diff --git a/resources/items/dorm/CREDITS.txt b/resources/items/dorm/CREDITS.txt new file mode 100755 index 0000000..13dfd50 --- /dev/null +++ b/resources/items/dorm/CREDITS.txt @@ -0,0 +1,3 @@ +Item(s) created by Judhudson@knology.net +For use with The Sims 1 and its expansions. +http://www.simprograms.com (now https://beyondsims.com) diff --git a/resources/items/dorm/Dorm Set_big.gif b/resources/items/dorm/Dorm Set_big.gif new file mode 100644 index 0000000..de95757 Binary files /dev/null and b/resources/items/dorm/Dorm Set_big.gif differ diff --git a/resources/items/dorm/chair/chair_1.png b/resources/items/dorm/chair/chair_1.png new file mode 100755 index 0000000..e8c9c2c Binary files /dev/null and b/resources/items/dorm/chair/chair_1.png differ diff --git a/resources/items/dorm/chair/chair_1_z.png b/resources/items/dorm/chair/chair_1_z.png new file mode 100755 index 0000000..17db7a7 Binary files /dev/null and b/resources/items/dorm/chair/chair_1_z.png differ diff --git a/resources/items/dorm/chair/chair_2.png b/resources/items/dorm/chair/chair_2.png new file mode 100755 index 0000000..fe98ffa Binary files /dev/null and b/resources/items/dorm/chair/chair_2.png differ diff --git a/resources/items/dorm/chair/chair_2_z.png b/resources/items/dorm/chair/chair_2_z.png new file mode 100755 index 0000000..f33f07c Binary files /dev/null and b/resources/items/dorm/chair/chair_2_z.png differ diff --git a/resources/items/dorm/table/chair.json b/resources/items/dorm/table/chair.json new file mode 100644 index 0000000..3eeca76 --- /dev/null +++ b/resources/items/dorm/table/chair.json @@ -0,0 +1,37 @@ +{ + "item": { + "name": "Dorm End Table", + "description": "Created by Judhudson@knology.net", + "version": 1, + "size": 1, + "catagory": "surfaces", + "base": "table", + "views": { + "south": { + "texture": "table_1.png", + "buffer": "table_1_z.png" + }, + "north": { + "texture": "table_2.png", + "buffer": "table_2_z.png" + } + }, + "motives": { + "room": 5, + "hunger": 0, + "social": 0, + "fun": 0, + "hygiene": 0, + "energy": 0, + "bladder": 0 + }, + "skills": { + "cooking": 5, + "mechanical": 0, + "charism": 0, + "body": 0, + "logic": 0, + "creativity": 0 + } + } +} \ No newline at end of file diff --git a/resources/items/dorm/table/table_1.png b/resources/items/dorm/table/table_1.png new file mode 100755 index 0000000..9518cb7 Binary files /dev/null and b/resources/items/dorm/table/table_1.png differ diff --git a/resources/items/dorm/table/table_1_z.png b/resources/items/dorm/table/table_1_z.png new file mode 100755 index 0000000..c06b9d2 Binary files /dev/null and b/resources/items/dorm/table/table_1_z.png differ diff --git a/resources/items/dorm/table/table_2.png b/resources/items/dorm/table/table_2.png new file mode 100755 index 0000000..59686d5 Binary files /dev/null and b/resources/items/dorm/table/table_2.png differ diff --git a/resources/items/dorm/table/table_2_z.png b/resources/items/dorm/table/table_2_z.png new file mode 100755 index 0000000..7dbd46a Binary files /dev/null and b/resources/items/dorm/table/table_2_z.png differ diff --git a/resources/items/dorms/readme.txt b/resources/items/dorms/readme.txt deleted file mode 100755 index c112adc..0000000 --- a/resources/items/dorms/readme.txt +++ /dev/null @@ -1,6 +0,0 @@ -Item(s) created by Judhudson@knology.net -For use with The Sims 1 and its expansions. - -Instructions: Unzip and extract to Maxis/The Sims/Downloads folder. Create the folder if necessary. - -http://www.simprograms.com diff --git a/resources/items/dorms/table_3.png b/resources/items/dorms/table_3.png deleted file mode 100755 index 31904c1..0000000 Binary files a/resources/items/dorms/table_3.png and /dev/null differ diff --git a/resources/items/dorms/table_4.png b/resources/items/dorms/table_4.png deleted file mode 100755 index c544ff2..0000000 Binary files a/resources/items/dorms/table_4.png and /dev/null differ diff --git a/resources/items/voting/CREDITS.txt b/resources/items/voting/CREDITS.txt new file mode 100644 index 0000000..c5d4596 --- /dev/null +++ b/resources/items/voting/CREDITS.txt @@ -0,0 +1,3 @@ +Dumbold Voting Machine, by Don Hopkins. +Special thanks to SimBabes, SimSlice, Will Wright, Ted Selker, John Gilmore, Cindy Cohen, Alan Korn, Bev Harris, Baxter the Chimpanzee, Black Box Voting, EFF, Verified Voting, CalTech-MIT/Voting Technology Project. +This Sims object is open source software, as all voting machine software should be. \ No newline at end of file diff --git a/resources/items/voting/dumbold_voting_machine.iff b/resources/items/voting/dumbold_voting_machine.iff new file mode 100644 index 0000000..7893978 Binary files /dev/null and b/resources/items/voting/dumbold_voting_machine.iff differ diff --git a/src/config.zig b/src/config.zig index 183afbc..44f493b 100644 --- a/src/config.zig +++ b/src/config.zig @@ -6,5 +6,10 @@ pub const Branding = struct { pub const Config = struct { height: i64, width: i64, + game_path: []const u8, branding: *Branding, + + pub fn init(self: Config) Config { + return self; + } }; diff --git a/src/io/iff.zig b/src/io/iff.zig deleted file mode 100644 index 4ab3b32..0000000 --- a/src/io/iff.zig +++ /dev/null @@ -1,4 +0,0 @@ -const iff = @cImport({ - @cInclude("./iff/iff.h"); - @cInclude("./iff/iffparser.h"); -}); diff --git a/src/io/oiff.zig b/src/io/oiff.zig new file mode 100644 index 0000000..f6d501e --- /dev/null +++ b/src/io/oiff.zig @@ -0,0 +1,49 @@ +const std = @import("std"); +const rl = @import("raylib"); + +pub const Texture = struct { + texture: []const u8, + buffer: []const u8, +}; + +pub const View = struct { + north: *Texture, + south: *Texture, +}; + +pub const Motives = struct { + room: i64, // Environment in later games + hunger: i64, + social: i64, + hygiene: i64, + fun: i64, + energy: i64, + bladder: i64, +}; + +pub const Skills = struct { + cooking: i64, + mechanical: i64, + charisma: i64, + body: i64, + logic: i64, + creativity: i64, +}; + +/// Open object format with similar +pub const OpenIff = struct { + name: []const u8, + description: []const u8, + version: i64, + catagory: []const u8, + /// Item to derive all logic from. + /// By defualt, this comes from the base game. + base: []const u8, + motives: *Motives, + skills: Skills, + views: *View, + + // pub fn init(file: []const u8) OpenIff { + + // } +}; diff --git a/src/main.zig b/src/main.zig index 6f62fb8..7ddaf47 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1,6 +1,7 @@ const std = @import("std"); const rl = @import("raylib"); const world = @import("world.zig"); +const nso = @import("niotso.zig"); const dbg = std.debug; @@ -56,8 +57,8 @@ pub fn main() anyerror!void { const logo = rl.Texture.init("resources/logo.png"); const splash = rl.Texture.init("resources/tsosplash.png"); - const table3 = rl.Texture.init("resources/items/dorms/table_3.png"); - const table4 = rl.Texture.init("resources/items/dorms/table_4.png"); + const table3 = rl.Texture.init("resources/items/dorm/table/table_1.png"); + const table4 = rl.Texture.init("resources/items/dorm/table/table_2.png"); const city = rl.loadImage("resources/cities/city_0100/elevation.png"); // const city_texture = rl.Texture.init("resources/cities/city_0100/vertexcolor.png"); defer rl.unloadTexture(splash); diff --git a/src/niotso.zig b/src/niotso.zig new file mode 100644 index 0000000..763f02b --- /dev/null +++ b/src/niotso.zig @@ -0,0 +1,9 @@ +pub usingnamespace @cImport({ + @cInclude("./formats/iff/iff.h"); + @cInclude("./formats/iff/iffparser.h"); + @cInclude("./formats/far/far.h"); + @cInclude("./formats/far/config.h"); + @cInclude("./formats/cur/read_cur.h"); + @cInclude("./formats/utk/read_utk.h"); + @cInclude("./formats/xa/read_xa.h"); +});