Selaa lähdekoodia

Updated to enet 2.3.6

Brucey 2 vuotta sitten
vanhempi
commit
67e118af27

+ 3 - 1
enet.mod/enet.bmx

@@ -2,9 +2,11 @@ SuperStrict
 
 Module Pub.Enet
 
-ModuleInfo "Version: 1.02"
+ModuleInfo "Version: 1.03"
 ModuleInfo "Author: Lee Salzman, Vladyslav Hrytsenko, Dominik Madarasz"
 
+ModuleInfo "History: 1.03"
+ModuleInfo "History: Updated to enet 2.3.6"
 ModuleInfo "History: 1.02"
 ModuleInfo "History: Made SuperStrict"
 ModuleInfo "History: Ported to zpl-c enet : https://github.com/zpl-c/enet"

+ 2 - 0
enet.mod/enet/.gitattributes

@@ -0,0 +1,2 @@
+*.h linguist-language=C
+code/vendor/* linguist-vendored

+ 20 - 1
enet.mod/enet/.gitignore

@@ -1,3 +1,22 @@
-build/
+# Folders
+build/*
+misc/deploy/
 node_modules/
+pkg/
+
+# vs shit
+*.dir/
+x64/
+
+# Other
 .DS_store
+
+# local build scripts
+build.sh
+build.bat
+package-lock.json
+
+# gtags
+GPATH
+GRTAGS
+GTAGS

+ 0 - 25
enet.mod/enet/.travis.yml

@@ -1,25 +0,0 @@
-os:
-  - linux
-  - osx
-
-language: c
-compiler:
-  - clang
-
-script:
-  - cmake . -DCMAKE_BUILD_TYPE=Release -DENET_TEST=1 -DENET_SHARED=1
-  - cmake --build .
-  - ./enet_test
-
-before_deploy:
-  - export FILE_TO_UPLOAD=$(ls *.dylib *.so)
-
-deploy:
-  provider: releases
-  api_key:
-    - secure: "VZPCmJqX/MOBJv/k498MIrpKC7SBx+ZYqpOxo1Vp2dO3W8PzChCMePsuCdYL5ZvxLqNv9iClQ778HHQ8X976C7lIBv01p6jf/BBrvp8WguagYRIqQ+6Ehe3l1/I+6Yxx7MnzMZTTCO/EOUbVlfwF4Gql5ybvgH9Vs0CKr00jUaDPCI8pc0rV2WW97qFQ5irfFcvJx7XxuT7V48Ur27y+gkqV+L4YZthjwqN9fC5jULl2ha/WY5tRjv5gjpLpLPvBW94x3L8qET7/izP0g1MrjlPODwh6pr7o6I2SAlURREadgHdovLDm7K7N+DBVT0hZCWXlJ/Sh7Q9gs3CCAxtMyLDSoGjpWHBvRvJw702OtRxyIWriESq80kB8KUQ/piHB4DPMfDpkuWUaSNElX85NyW3fh5aXxlOvQf+CtABNACIuLC/oBshFguFgEu4kuqpFtmUG7EBssrEwnCiw2H3xpMC3G+ALEA03UKYJEZcyrmFo9PwIfaNf9ziJLzqq3haAN1/4pNyvl62MMPtNDyzXzVTWyL/Yi22tDIDgMGwCYpAyNoKHiyPpVGbOkL4561SN947g2TpIfxi6LlxzdLV6fPoPlLBsaha6LXV+YLNWsgpOJYK0zk8dxKNDzGxniSiPAaeEWhbc11UGJYgpk21ySus/lQfsQobEK/EqwOM5mpU="
-  file_glob: true
-  file: "${FILE_TO_UPLOAD}"
-  skip_cleanup: true
-  on:
-    tags: true

+ 25 - 14
enet.mod/enet/CMakeLists.txt

@@ -1,35 +1,46 @@
-cmake_minimum_required(VERSION 2.6)
+cmake_minimum_required(VERSION 3.0)
 project(enet C)
 
-if(MSVC)
-	add_definitions(-W3)
-else()
-	add_definitions(-Wno-error)
-endif()
-
-include_directories(${PROJECT_SOURCE_DIR}/include)
-
+# configure projects
 if (ENET_STATIC)
     add_library(enet_static STATIC test/library.c)
 
     if (WIN32)
-        target_link_libraries(enet_static winmm ws2_32)
+        target_link_libraries(enet_static PUBLIC winmm ws2_32)
+
+        if(MSVC)
+            target_compile_options(enet_static PRIVATE -W3)
+        endif()
+    else()
+        target_compile_options(enet_static PRIVATE -Wno-error)
     endif()
+
+    target_include_directories(enet_static PUBLIC ${PROJECT_SOURCE_DIR}/include)
 endif()
 
 if (ENET_SHARED)
-    add_definitions(-DENET_DLL)
-    add_library(enet SHARED test/library.c)
+    add_library(enet_shared SHARED test/library.c)
+    target_compile_definitions(enet_shared PUBLIC -DENET_DLL)
 
     if (WIN32)
-        target_link_libraries(enet winmm ws2_32)
+        target_link_libraries(enet_shared PUBLIC winmm ws2_32)
+
+        if(MSVC)
+            target_compile_options(enet_shared PRIVATE -W3)
+        endif()
+    else()
+        target_compile_options(enet_shared PRIVATE -Wno-error)
     endif()
+
+    target_include_directories(enet_shared PUBLIC ${PROJECT_SOURCE_DIR}/include)
 endif()
 
 if (ENET_TEST)
     add_executable(enet_test test/build.c)
+    target_include_directories(enet_test PRIVATE ${PROJECT_SOURCE_DIR}/include)
 
     if (WIN32)
-        target_link_libraries(enet_test winmm ws2_32)
+        target_link_libraries(enet_test PUBLIC winmm ws2_32)
     endif()
 endif()
+

+ 1 - 1
enet.mod/enet/LICENSE

@@ -1,7 +1,7 @@
 The MIT License (MIT)
 
 Copyright (c) 2002-2016 Lee Salzman
-Copyright (c) 2017-2018 Vladyslav Hrytsenko, Dominik Madarász
+Copyright (c) 2017-2022 Vladyslav Hrytsenko, Dominik Madarász
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal

+ 102 - 36
enet.mod/enet/README.md

@@ -1,18 +1,17 @@
 <div align="center">
-    <a href="https://github.com/zpl-c/enet"><img src="https://user-images.githubusercontent.com/2182108/33219675-6150f8a8-d14c-11e7-9081-a9be1945bfb1.png" alt="ENet" /></a>
+    <a href="https://github.com/zpl-c/enet"><img src="https://user-images.githubusercontent.com/2182108/111983468-d5593e80-8b12-11eb-9c59-8c78ecc0504e.png" alt="zpl/enet" /></a>
 </div>
 
-<br>
+<br />
 
 <div align="center">
-    <a href="https://travis-ci.org/zpl-c/enet"><img src="https://travis-ci.org/zpl-c/enet.svg" alt="Build status" /></a>
-    <a href="https://ci.appveyor.com/project/inlife/enet"><img src="https://ci.appveyor.com/api/projects/status/0mkwad2yljdlq3c6?svg=true" alt="Build status" /></a>
-    <a href="https://www.npmjs.com/package/enet.c"><img src="https://img.shields.io/npm/v/enet.c.svg?maxAge=3600" alt="NPM version" /></a>
-    <a href="https://discord.gg/2fZVEym"><img src="https://discordapp.com/api/guilds/354670964400848898/embed.png" alt="Discord server" /></a>
-    <a href="LICENSE"><img src="https://img.shields.io/github/license/zpl-c/enet.svg" alt="license" /></a>
+    <a href="https://github.com/zpl-c/enet/actions"><img src="https://img.shields.io/github/workflow/status/zpl-c/enet/tests?label=Tests&style=for-the-badge" alt="build status" /></a>
+    <img src="https://img.shields.io/github/package-json/v/zpl-c/enet?style=for-the-badge" alt="version" /></a>
+    <a href="https://discord.gg/2fZVEym"><img src="https://img.shields.io/discord/354670964400848898?color=7289DA&style=for-the-badge" alt="discord" /></a>
+    <a href="LICENSE"><img src="https://img.shields.io/github/license/zpl-c/enet?style=for-the-badge" alt="license" /></a>
 </div>
 
-<br style="line-height: 10px" />
+<br />
 
 <div align="center">
   ENet - Simple, lightweight and reliable UDP networking library written on pure C
@@ -20,17 +19,15 @@
 
 <div align="center">
   <sub>
-    Brought to you by
+    Brought to you by 
     <a href="https://github.com/lsalzman">@lsalzman</a>,
     <a href="https://github.com/inlife">@inlife</a>,
     <a href="https://github.com/zaklaus">@zaklaus</a>,
     <a href="https://github.com/nxrighthere">@nxrighthere</a>
-    and other contributors!
+    and other <a href="https://github.com/zpl-c/librg/graphs/contributors">contributors</a>
   </sub>
 </div>
 
-<hr/>
-
 ## Disclaimer
 
 This is a fork of the original library [lsalzman/enet](https://github.com/lsalzman/enet). While original repo offers a stable, time-tested wonderful library,
@@ -41,8 +38,7 @@ we are trying to change some things, things, which can't be reflected on the mai
 * applied project-wide code style change
 * cleaned up project
 * single-header style code
-* NPM package distribution
-* removed a lot of older methods
+* removed some of older/outdated methods
 * and many other various changes
 
 ## Description
@@ -55,29 +51,17 @@ ENet omits certain higher level networking features such as authentication, lobb
 server discovery, encryption, or other similar tasks that are particularly application
 specific so that the library remains flexible, portable, and easily embeddable.
 
-## Installation (via npm)
-
-Install library using (omit `--save` if you don't have npm project initilized)
-
-```sh
-$ npm install enet.c --save
-```
+## Installation
 
-Add include path to the library `node_modules/enet.c/include` to your makefile/
-
-## Installation (manually)
-
-Dowload file [include/enet.h](https://raw.githubusercontent.com/zpl-c/enet/master/include/enet.h) and just add to your project.
+Download file [releases/latest/enet.h](https://github.com/zpl-c/enet/releases/latest/download/enet.h) and just add to your project.
 
 ## Usage (Shared library)
 
 Build the shared library:
 
 ```sh
-$ mkdir build
-$ cd build
-$ cmake .. -DENET_SHARED=1 -DCMAKE_BUILD_TYPE=Release
-$ cmake --build .
+$ cmake -B build -DENET_SHARED=1 -DCMAKE_BUILD_TYPE=Release
+$ cmake --build build
 ```
 
 Use it:
@@ -103,10 +87,8 @@ int main() {
 Build the static library:
 
 ```sh
-$ mkdir build
-$ cd build
-$ cmake .. -DENET_STATIC=1 -DCMAKE_BUILD_TYPE=Release
-$ cmake --build .
+$ cmake -B build -DENET_STATIC=1 -DCMAKE_BUILD_TYPE=Release
+$ cmake --build build
 ```
 
 Use it:
@@ -126,13 +108,15 @@ int main() {
 }
 ```
 
-## Usage (Direct, Preferred)
+## Usage (Single Header, Preferred)
 
 In this case, library will be embedded to the project itself.
 
 Make sure you add a define for `ENET_IMPLEMENTATION` exactly in one source file before including the `enet.h`.
 
-Here is a simple server demo, it will wait 1 second for events, and then exit if none were found:
+Here is a simple server and client demo, it will wait 1 second for events, and then exit if none were found:
+
+Server:
 
 ```c
 #define ENET_IMPLEMENTATION
@@ -207,6 +191,88 @@ int main() {
 
 ```
 
+Client:
+
+```c
+#include <stdio.h>
+#define ENET_IMPLEMENTATION
+#include "enet.h"
+
+int main() {
+  if (enet_initialize() != 0) {
+    fprintf(stderr, "An error occurred while initializing ENet.\n");
+    return EXIT_FAILURE;
+  }
+
+  ENetHost* client = { 0 };
+  client = enet_host_create(NULL /* create a client host */,
+    1 /* only allow 1 outgoing connection */,
+    2 /* allow up 2 channels to be used, 0 and 1 */,
+    0 /* assume any amount of incoming bandwidth */,
+    0 /* assume any amount of outgoing bandwidth */);
+  if (client == NULL) {
+    fprintf(stderr,
+      "An error occurred while trying to create an ENet client host.\n");
+    exit(EXIT_FAILURE);
+  }
+
+  ENetAddress address = { 0 };
+  ENetEvent event = { 0 };
+  ENetPeer* peer = { 0 };
+  /* Connect to some.server.net:1234. */
+  enet_address_set_host(&address, "127.0.0.1");
+  address.port = 7777;
+  /* Initiate the connection, allocating the two channels 0 and 1. */
+  peer = enet_host_connect(client, &address, 2, 0);
+  if (peer == NULL) {
+    fprintf(stderr,
+      "No available peers for initiating an ENet connection.\n");
+    exit(EXIT_FAILURE);
+  }
+  /* Wait up to 5 seconds for the connection attempt to succeed. */
+  if (enet_host_service(client, &event, 5000) > 0 &&
+    event.type == ENET_EVENT_TYPE_CONNECT) {
+    puts("Connection to some.server.net:1234 succeeded.");
+  } else {
+    /* Either the 5 seconds are up or a disconnect event was */
+    /* received. Reset the peer in the event the 5 seconds   */
+    /* had run out without any significant event.            */
+    enet_peer_reset(peer);
+    puts("Connection to some.server.net:1234 failed.");
+  }
+
+  // Receive some events
+  enet_host_service(client, &event, 5000);
+
+  // Disconnect
+  enet_peer_disconnect(peer, 0);
+
+  uint8_t disconnected = false;
+  /* Allow up to 3 seconds for the disconnect to succeed
+   * and drop any packets received packets.
+   */
+  while (enet_host_service(client, &event, 3000) > 0) {
+      switch (event.type) {
+      case ENET_EVENT_TYPE_RECEIVE:
+          enet_packet_destroy(event.packet);
+          break;
+      case ENET_EVENT_TYPE_DISCONNECT:
+          puts("Disconnection succeeded.");
+          disconnected = true;
+          break;
+      }
+  }
+
+  // Drop connection, since disconnection didn't successed
+  if (!disconnected) {
+      enet_peer_reset(peer);
+  }
+
+  enet_host_destroy(client);
+  enet_deinitialize();
+}
+```
+
 ## Tutorials
 
 More information, examples and tutorials can be found at the official site: http://enet.bespin.org/

+ 0 - 30
enet.mod/enet/appveyor.yml

@@ -1,30 +0,0 @@
-image: Visual Studio 2017
-
-platform:
-  - x64
-
-configuration:
-  - Release
-
-before_build:
-  - cmake . -G "Visual Studio 15 2017 Win64" -DENET_SHARED=1 -DENET_TEST=1
-
-build:
-  project: $(APPVEYOR_BUILD_FOLDER)\$(APPVEYOR_PROJECT_NAME).sln
-
-test_script:
-  - '%APPVEYOR_BUILD_FOLDER%\%CONFIGURATION%\enet_test.exe'
-
-artifacts:
-  - path: 'Release\*.dll'
-    name: Releases
-
-deploy:
-  provider: GitHub
-  auth_token:
-    secure: "tYm5oXMHHaO3oR5xd93zvnG95eqNZWw065Z9Qo6CAN3+2G7IlWbcmbsYlsl2XDFc"
-  artifact: /.*\.dll/
-  draft: false
-  prerelease: false
-  on:
-    appveyor_repo_tag: true

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 410 - 247
enet.mod/enet/include/enet.h


+ 92 - 0
enet.mod/enet/misc/packager.js

@@ -0,0 +1,92 @@
+const fs = require('fs')
+const path = require('path')
+const {Plugin} = require('release-it')
+
+const basefile = path.join(__dirname, '..', 'include', 'enet.h')
+const workdir = path.join(__dirname, 'deploy')
+
+const versionGet = () => {
+    const data = fs.readFileSync(basefile, 'utf8')
+
+    const major = data.match(/ENET_VERSION_MAJOR\s+([0-9]+)\n/)[1]
+    const minor = data.match(/ENET_VERSION_MINOR\s+([0-9]+)\n/)[1]
+    const patch = data.match(/ENET_VERSION_PATCH\s+([0-9]+)\n/)[1]
+    const pre   = data.match(/ENET_VERSION_PRE\s+\"([\.a-z0-9]+)\"\n/)
+
+    return `${major}.${minor}.${patch}${pre ? '-' + pre[1] : ''}`
+}
+
+const versionSet = (version) => {
+    let data = fs.readFileSync(basefile, 'utf8')
+
+    let [base, pre] = version.split('-')
+    let [major, minor, patch] = base.split('.').map(a => parseInt(a))
+
+    if (!pre) pre = ''
+
+    data = data.replace(/ENET_VERSION_MAJOR\s+([0-9]+)\n/, `ENET_VERSION_MAJOR ${major}\n`)
+    data = data.replace(/ENET_VERSION_MINOR\s+([0-9]+)\n/, `ENET_VERSION_MINOR ${minor}\n`)
+    data = data.replace(/ENET_VERSION_PATCH\s+([0-9]+)\n/, `ENET_VERSION_PATCH ${patch}\n`)
+    data = data.replace(/ENET_VERSION_PRE\s+\"([\.0-9a-z]+)\"\n/, `ENET_VERSION_PRE "${pre}"\n`)
+
+    fs.writeFileSync(basefile, data)
+}
+
+const embedIncludes = (print) => {
+    if (!fs.existsSync(workdir)) fs.mkdirSync(workdir)
+
+    let data = fs.readFileSync(basefile, 'utf8')
+    let lines = data.split('\n')
+
+    // const hedley = lines.find(a => a.indexOf('enet_hedley.h') !== -1)
+    // const hedleyIndex = lines.indexOf(hedley)
+
+    // lines = lines.map((line, i) => {
+    //     if (i < hedleyIndex) return line
+    //     if (line.indexOf('#include') === -1) return line
+    //     if (line.indexOf('<') !== -1) return line
+
+    //     const parts = line.split('#include')
+    //     const spaces = parts[0]
+    //     const filename = parts[1].trim().replace(/"/g, '')
+
+    //     const content = fs
+    //         .readFileSync(path.join(__dirname, '..', 'code', filename), 'utf8')
+    //         .split('\n')
+    //         .map(l => spaces + l)
+    //         .map(l => l === spaces ? '' : l)
+    //         .join('\n')
+    //         .replace(/\s+$/g, '')
+
+    //     return content
+    // })
+
+    const code = lines.join('\n')
+    if (print) console.log(code)
+    else fs.writeFileSync(path.join(workdir, 'enet.h'), code)
+}
+
+class Bumper extends Plugin {
+    getLatestVersion() {
+        return versionGet()
+    }
+
+    bump(version) {
+        this.version = version;
+        versionSet(version)
+    }
+
+    async beforeRelease() {
+        embedIncludes()
+        console.log('done')
+    }
+
+    afterRelease() {
+        if (fs.existsSync(path.join(workdir, 'enet.h'))) {
+            fs.unlinkSync(path.join(workdir, 'enet.h'))
+        }
+    }
+}
+
+module.exports = Bumper
+module.exports.embedIncludes = embedIncludes

+ 28 - 5
enet.mod/enet/package.json

@@ -1,14 +1,11 @@
 {
   "name": "enet.c",
-  "version": "2.2.0",
+  "version": "2.3.6",
   "description": "ENet - Simple, lightweight and reliable UDP networking library written on pure C.",
   "main": "include/enet.h",
   "directories": {
     "doc": "misc/docs"
   },
-  "scripts": {
-    "test": "echo \"Error: no test specified\" && exit 1"
-  },
   "repository": {
     "type": "git",
     "url": "git+https://github.com/zpl-c/enet-c.git"
@@ -30,5 +27,31 @@
     "url": "https://github.com/zpl-c/enet-c/issues"
   },
   "homepage": "https://github.com/zpl-c/enet-c#readme",
-  "dependencies": {}
+  "scripts": {
+    "embed": "node -e 'require(\"./misc/packager\").embedIncludes()'",
+    "release": "release-it",
+    "release-patch": "release-it patch --ci",
+    "release-minor": "release-it minor --ci",
+    "release-major": "release-it major --ci",
+    "release-patch-pre": "release-it patch --preRelease=pre --ci",
+    "release-minor-pre": "release-it minor --preRelease=pre --ci",
+    "release-major-pre": "release-it major --preRelease=pre --ci"
+  },
+  "devDependencies": {
+    "release-it": "^13.6.1"
+  },
+  "release-it": {
+    "npm": {
+      "publish": true
+    },
+    "github": {
+      "release": true,
+      "assets": [
+        "misc/deploy/enet.h"
+      ]
+    },
+    "plugins": {
+      "./misc/packager.js": {}
+    }
+  }
 }

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä