Browse Source

Revert "ILuaShared interface plug"

This reverts commit ace7e2414303738b9cb828b510a79fe72981821e.

This was really bad idea.
IVogel 2 years ago
parent
commit
d197c3a514
3 changed files with 9 additions and 56 deletions
  1. 5 14
      example/src/lib.rs
  2. 0 39
      server-plugin/src/iluashared.rs
  3. 4 3
      server-plugin/src/lib.rs

+ 5 - 14
example/src/lib.rs

@@ -1,14 +1,11 @@
-use std::{
-    error::Error,
-    ffi::{c_void, CStr, CString},
-};
+use std::{ffi::{CStr, CString, c_void}, error::Error};
 
-use server_plugin::{CreateInterfaceFn, INetworkStringTableContainer, ServerPlugin};
+use server_plugin::{ServerPlugin, INetworkStringTableContainer, CreateInterfaceFn};
 use server_plugin_derive::create_interface;
 
 struct TestPlugin {
     plugin_name: CString,
-    string_tables: Option<&'static INetworkStringTableContainer>,
+    string_tables: Option<&'static INetworkStringTableContainer>
 }
 
 impl TestPlugin {
@@ -21,19 +18,13 @@ impl TestPlugin {
 }
 
 impl ServerPlugin for TestPlugin {
-    fn load(
-        &mut self,
-        sys_appfactory: CreateInterfaceFn,
-        _server_factorty: CreateInterfaceFn,
-    ) -> Result<(), Box<dyn Error>> {
+    fn load(&mut self, sys_appfactory: CreateInterfaceFn, _server_factorty: CreateInterfaceFn) -> Result<(), Box<dyn Error>> {
         self.string_tables = INetworkStringTableContainer::from_factory(sys_appfactory).ok();
         Ok(())
     }
     fn server_activate(&mut self, _edict_list: &mut [*mut c_void], _max_players: i32) {
         let string_tables = self.string_tables.unwrap();
-        for string_table in
-            (0..string_tables.get_num_tables()).map_while(|id| string_tables.get_table(id))
-        {
+        for string_table in (0..string_tables.get_num_tables()).map_while(|id| string_tables.get_table(id)) {
             dbg!(string_table);
         }
         let table = string_tables.find_table("GModGameInfo").unwrap();

+ 0 - 39
server-plugin/src/iluashared.rs

@@ -1,39 +0,0 @@
-use std::ffi::c_void;
-use std::mem;
-
-use crate::CreateInterfaceFn;
-use vtables::VTable;
-use vtables_derive::has_vtable;
-use vtables_derive::virtual_index;
-use vtables_derive::VTable;
-
-#[repr(u8)]
-pub enum LuaState {
-    Client,
-    Server,
-    Menu,
-}
-
-#[has_vtable]
-#[derive(VTable, Debug)]
-pub struct ILuaShared {}
-
-#[allow(dead_code)]
-impl ILuaShared {
-    #[virtual_index(6)]
-    pub fn get_lua_interface(&mut self, state: LuaState) -> *mut c_void {}
-
-    pub fn from_ptr(ptr: *mut c_void) -> &'static ILuaShared {
-        unsafe { mem::transmute(ptr) }
-    }
-
-    pub fn from_factory(factory: CreateInterfaceFn) -> Result<&'static ILuaShared, i32> {
-        let mut result = 0;
-        let ptr = unsafe { factory(b"LUASHARED003\0".as_ptr() as _, &mut result) };
-        if ptr.is_null() {
-            Err(result)
-        } else {
-            Ok(ILuaShared::from_ptr(ptr))
-        }
-    }
-}

+ 4 - 3
server-plugin/src/lib.rs

@@ -5,12 +5,13 @@ use std::ffi::{c_void, CStr};
 pub use platform::current::BasePlugin;
 
 mod ifilesystem;
-mod iluashared;
 mod inetworkstringtable;
 mod platform;
 
-pub use inetworkstringtable::{INetworkStringTable, INetworkStringTableContainer};
-pub use iluashared::{ILuaShared, LuaState};
+pub use inetworkstringtable::{
+    INetworkStringTable,
+    INetworkStringTableContainer
+};
 
 #[repr(i32)]
 #[derive(Debug, Clone, Copy)]