Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
59 changes: 15 additions & 44 deletions Shared/mods/deathmatch/logic/luadefs/CLuaFileDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
*****************************************************************************/

#include "StdInc.h"

#include <lua/CLuaFunctionParser.h>
#include "CLuaFileDefs.h"
#include "CScriptFile.h"
#include "CScriptArgReader.h"


#define DEFAULT_MAX_FILESIZE 52428800

void CLuaFileDefs::LoadFunctions()
Expand All @@ -21,7 +24,7 @@ void CLuaFileDefs::LoadFunctions()
{"fileOpen", fileOpen}, {"fileCreate", fileCreate}, {"fileExists", fileExists}, {"fileCopy", fileCopy},
{"fileRename", fileRename}, {"fileDelete", fileDelete},

{"fileClose", fileClose}, {"fileFlush", fileFlush}, {"fileRead", fileRead}, {"fileWrite", fileWrite},
{"fileClose", fileClose}, {"fileFlush", fileFlush}, {"fileRead", ArgumentParser<fileRead>}, {"fileWrite", fileWrite},

{"fileGetPos", fileGetPos}, {"fileGetSize", fileGetSize}, {"fileGetPath", fileGetPath}, {"fileIsEOF", fileIsEOF},

Expand Down Expand Up @@ -675,51 +678,19 @@ int CLuaFileDefs::fileFlush(lua_State* luaVM)
return 1;
}

int CLuaFileDefs::fileRead(lua_State* luaVM)
std::string CLuaFileDefs::fileRead(lua_State* L, CScriptFile* pFile, size_t count)
{
// string fileRead ( file theFile, int count )
CScriptFile* pFile;
unsigned long ulCount = 0;

CScriptArgReader argStream(luaVM);
argStream.ReadUserData(pFile);
argStream.ReadNumber(ulCount);

if (!argStream.HasErrors())
{
// Reading zero bytes from a file results in an empty string
if (ulCount == 0)
{
lua_pushstring(luaVM, "");
return 1;
}

// Allocate a buffer to read the stuff into and read some :~ into it
SString buffer;
long lBytesRead = pFile->Read(ulCount, buffer);

if (lBytesRead >= 0)
{
// Push the string onto the Lua stack. Use pushlstring so we are binary
// compatible. Normal push string takes zero terminated strings.
lua_pushlstring(luaVM, buffer.data(), lBytesRead);
return 1;
}
else if (lBytesRead == -2)
{
m_pScriptDebugging->LogWarning(luaVM, "out of memory");
}
else
{
m_pScriptDebugging->LogBadPointer(luaVM, "file", 1);
}
}
// Reading zero bytes from a file results in an empty string
if (!count)
return "";

SString buffer;
if (auto bytesRead = pFile->Read(count, buffer); bytesRead >= 0)
return buffer;
else if (bytesRead == -2)
throw std::exception("Out of memory");
else
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

// Error
lua_pushnil(luaVM);
return 1;
m_pScriptDebugging->LogBadPointer(L, "file", 1);
}

int CLuaFileDefs::fileWrite(lua_State* luaVM)
Expand Down
2 changes: 1 addition & 1 deletion Shared/mods/deathmatch/logic/luadefs/CLuaFileDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CLuaFileDefs : public CLuaDefs

LUA_DECLARE(fileClose);
LUA_DECLARE(fileFlush);
LUA_DECLARE(fileRead);
static std::string fileRead(lua_State* L, CScriptFile* pFile, size_t count);
LUA_DECLARE(fileWrite);

LUA_DECLARE(fileGetPos);
Expand Down
222 changes: 222 additions & 0 deletions vendor/cef3/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
# Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.

# OVERVIEW
#
# CMake is a cross-platform open-source build system that can generate project
# files in many different formats. It can be downloaded from
# http://www.cmake.org or installed via a platform package manager.
#
# CMake-generated project formats that have been tested with this CEF binary
# distribution include:
#
# Linux: Ninja, Unix Makefiles
# MacOS: Ninja, Xcode 8+ (x64) or Xcode 12.2+ (ARM64)
# Windows: Ninja, Visual Studio 2015+
#
# Ninja is a cross-platform open-source tool for running fast builds using
# pre-installed platform toolchains (GNU, clang, Xcode or MSVC). It can be
# downloaded from http://martine.github.io/ninja/ or installed via a platform
# package manager.
#
# CMAKE STRUCTURE
#
# This CEF binary distribution includes the following CMake files:
#
# CMakeLists.txt Bootstrap that sets up the CMake environment.
# cmake/*.cmake CEF configuration files shared by all targets.
# libcef_dll/CMakeLists.txt Defines the libcef_dll_wrapper target.
# tests/*/CMakeLists.txt Defines the test application target.
#
# See the "TODO:" comments below for guidance on how to integrate this CEF
# binary distribution into a new or existing CMake project.
#
# BUILD REQUIREMENTS
#
# The below requirements must be met to build this CEF binary distribution.
#
# - CMake version 2.8.12.1 or newer.
#
# - Linux requirements:
# Currently supported distributions include Debian Wheezy, Ubuntu Precise, and
# related. Ubuntu 18.04 64-bit is recommended. Newer versions will likely also
# work but may not have been tested.
# Required packages include:
# build-essential
# libgtk2.0-dev (required by the cefclient target only)
# libgtkglext1-dev (required by the cefclient target only)
#
# - MacOS requirements:
# Xcode 8 or newer building on MacOS 10.10 (Yosemite) or newer. Xcode 11.2
# and MacOS 10.14 are recommended. The Xcode command-line tools must also be
# installed. Only 64-bit builds are supported.
#
# - Windows requirements:
# Visual Studio 2015 Update 2 or newer building on Windows 7 or newer. Visual
# Studio 2019 and Windows 10 64-bit are recommended.
#
# BUILD EXAMPLES
#
# The below commands will generate project files and create a Debug build of all
# CEF targets using CMake and the platform toolchain.
#
# Start by creating and entering the CMake build output directory:
# > cd path/to/cef_binary_*
# > mkdir build && cd build
#
# To perform a Linux build using a 32-bit CEF binary distribution on a 32-bit
# Linux platform or a 64-bit CEF binary distribution on a 64-bit Linux platform:
# Using Unix Makefiles:
# > cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug ..
# > make -j4 cefclient cefsimple
#
# Using Ninja:
# > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug ..
# > ninja cefclient cefsimple
#
# To perform a MacOS build using a 64-bit CEF binary distribution:
# Using the Xcode IDE:
# > cmake -G "Xcode" -DPROJECT_ARCH="x86_64" ..
# Open build\cef.xcodeproj in Xcode and select Product > Build.
#
# Using Ninja:
# > cmake -G "Ninja" -DPROJECT_ARCH="x86_64" -DCMAKE_BUILD_TYPE=Debug ..
# > ninja cefclient cefsimple
#
# To perform a MacOS build using an ARM64 CEF binary distribution:
# Using the Xcode IDE:
# > cmake -G "Xcode" -DPROJECT_ARCH="arm64" ..
# Open build\cef.xcodeproj in Xcode and select Product > Build.
#
# Using Ninja:
# > cmake -G "Ninja" -DPROJECT_ARCH="arm64" -DCMAKE_BUILD_TYPE=Debug ..
# > ninja cefclient cefsimple
#
# To perform a Windows build using a 32-bit CEF binary distribution:
# Using the Visual Studio 2019 IDE:
# > cmake -G "Visual Studio 16" -A Win32 ..
# Open build\cef.sln in Visual Studio and select Build > Build Solution.
#
# Using Ninja with Visual Studio 2019 command-line tools:
# (this path may be different depending on your Visual Studio installation)
# > "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars32.bat"
# > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug ..
# > ninja cefclient cefsimple
#
# To perform a Windows build using a 64-bit CEF binary distribution:
# Using the Visual Studio 2019 IDE:
# > cmake -G "Visual Studio 16" -A x64 ..
# Open build\cef.sln in Visual Studio and select Build > Build Solution.
#
# Using Ninja with Visual Studio 2019 command-line tools:
# (this path may be different depending on your Visual Studio installation)
# > "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat"
# > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug ..
# > ninja cefclient cefsimple

#
# Global setup.
#

cmake_minimum_required(VERSION 2.8.12.1)

# Only generate Debug and Release configuration types.
set(CMAKE_CONFIGURATION_TYPES Debug Release)

# Project name.
# TODO: Change this line to match your project name when you copy this file.
project(cef)

# Use folders in the resulting project files.
set_property(GLOBAL PROPERTY OS_FOLDERS ON)


#
# CEF_ROOT setup.
# This variable must be set to locate the binary distribution.
# TODO: Choose one of the below examples and comment out the rest.
#

# Example 1: The current directory contains both the complete binary
# distribution and your project.
# A. Comment in these lines:
#
set(CEF_ROOT "${CMAKE_CURRENT_SOURCE_DIR}")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CEF_ROOT}/cmake")

# Example 2: The binary distribution is in a separate directory from your
# project. Locate the binary distribution using the CEF_ROOT CMake
# variable.
# A. Create a directory structure for your project like the following:
# myproject/
# CMakeLists.txt <= top-level CMake configuration
# mytarget/
# CMakeLists.txt <= CMake configuration for `mytarget`
# ... other `mytarget` source files
# B. Copy this file to "myproject/CMakeLists.txt" as the top-level CMake
# configuration.
# C. Create the target-specific "myproject/mytarget/CMakeLists.txt" file for
# your application. See the included cefclient and cefsimple CMakeLists.txt
# files as an example.
# D. Comment in these lines:
#
# set(CEF_ROOT "c:/path/to/cef_binary_3.2704.xxxx.gyyyyyyy_windows32")
# set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CEF_ROOT}/cmake")

# Example 3: The binary distribution is in a separate directory from your
# project. Locate the binary distribution using the CEF_ROOT
# environment variable.
# A. Create a directory structure for your project like the following:
# myproject/
# CMakeLists.txt <= top-level CMake configuration
# cmake/
# FindCEF.cmake <= CEF CMake configuration entry point
# mytarget/
# CMakeLists.txt <= CMake configuration for `mytarget`
# ... other `mytarget` source files
# B. Copy this file to "myproject/CMakeLists.txt" as the top-level CMake
# configuration.
# C. Copy the cmake/FindCEF.cmake file to "myproject/cmake/FindCEF.cmake".
# D. Create the target-specific "myproject/mytarget/CMakeLists.txt" file for
# your application. See the included cefclient and cefsimple CMakeLists.txt
# files as an example.
# E. Set the CEF_ROOT environment variable before executing CMake. For example:
# > set CEF_ROOT=c:\path\to\cef_binary_3.2704.xxxx.gyyyyyyy_windows32
# F. Comment in these lines:
#
# set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")


#
# Load the CEF configuration.
#

# Execute FindCEF.cmake which must exist in CMAKE_MODULE_PATH.
find_package(CEF REQUIRED)


#
# Define CEF-based targets.
#

# Include the libcef_dll_wrapper target.
# Comes from the libcef_dll/CMakeLists.txt file in the binary distribution
# directory.
add_subdirectory(${CEF_LIBCEF_DLL_WRAPPER_PATH} libcef_dll_wrapper)

# Include application targets.
# Comes from the <target>/CMakeLists.txt file in the current directory.
# TODO: Change these lines to match your project target when you copy this file.
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
add_subdirectory(tests/cefsimple)
add_subdirectory(tests/gtest)
add_subdirectory(tests/ceftests)
endif()

if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/cefclient")
add_subdirectory(tests/cefclient)
endif()

# Display configuration settings.
PRINT_CEF_CONFIG()
29 changes: 29 additions & 0 deletions vendor/cef3/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) 2008-2020 Marshall A. Greenblatt. Portions Copyright (c)
// 2006-2009 Google Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Loading