commit
4bcd05a620
@ -0,0 +1,9 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.{c,cpp,h,hpp}]
|
||||
indent_style = tab
|
||||
charset = utf-8
|
@ -0,0 +1,170 @@
|
||||
|
||||
# Contributing to OpenTTD
|
||||
|
||||
Looking to contribute something to OpenTTD? **Here's how you can help.**
|
||||
|
||||
Please take a moment to review this document in order to make the contribution process easy and effective for everyone involved.
|
||||
|
||||
Following these guidelines helps to communicate that you respect the time of the developers managing and developing this open source project. In return, they should reciprocate that respect in addressing your issue or assessing patches and features.
|
||||
|
||||
|
||||
## Using the issue tracker
|
||||
|
||||
The [issue tracker](https://github.com/OpenTTD/OpenTTD/issues) is the preferred channel for [bug reports](#bug-reports), but please respect the following restrictions:
|
||||
|
||||
* Please **do not** use the issue tracker for help playing or using OpenTTD. Please try [irc](https://wiki.openttd.org/IRC_channel), or the [forums](https://www.tt-forums.net/)
|
||||
|
||||
* Please **do not** derail or troll issues. Keep the discussion on topic and respect the opinions of others.
|
||||
|
||||
* Please **do not** post comments consisting solely of "+1" or ":thumbsup:".
|
||||
Use [GitHub's "reactions" feature](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments) instead. We reserve the right to delete comments which violate this rule.
|
||||
|
||||
* Please **do not** open issues or pull requests regarding add-on content in NewGRF, GameScripts, AIs, etc. These are created by third-parties. Please try [irc](https://wiki.openttd.org/IRC_channel) or the [forums](https://www.tt-forums.net/) to discuss these.
|
||||
|
||||
## Bug reports
|
||||
|
||||
A bug is a _demonstrable problem_ that is caused by the code in the repository.
|
||||
Good bug reports are extremely helpful, so thanks!
|
||||
|
||||
Guidelines for bug reports:
|
||||
|
||||
0. Please don't report issues with games where you changed NewGRFs.
|
||||
|
||||
1. Please don't report issues with modified versions of OpenTTD (patchpacks and similar).
|
||||
|
||||
2. **Use the GitHub issue search** --- check if the issue has already been
|
||||
reported.
|
||||
|
||||
3. **Check if the issue has been fixed** --- try to reproduce it using the latest `nightly` build of OpenTTD, available from https://www.openttd.org
|
||||
|
||||
4. **Isolate the problem** --- ideally create reproduceable steps with an attached savegame and screenshots. Try to use few or no NewGRFs, AIs etc if possible.
|
||||
|
||||
A good bug report shouldn't leave others needing to chase you up for more information.
|
||||
Please try to be as detailed as possible in your report.
|
||||
|
||||
* What is your environment?
|
||||
* What steps will reproduce the issue?
|
||||
* Which operating system(s) experience the problem?
|
||||
* What would you expect to be the outcome?
|
||||
|
||||
All these details will help people to fix any potential bugs.
|
||||
|
||||
Example:
|
||||
|
||||
> Short and descriptive example bug report title
|
||||
>
|
||||
> A summary of the issue and the OS environment in which it occurs. If
|
||||
> suitable, include the steps required to reproduce the bug.
|
||||
>
|
||||
> 1. This is the first step
|
||||
> 2. This is the second step
|
||||
> 3. Further steps, etc.
|
||||
>
|
||||
> Attached savegame
|
||||
> Attached screenshots showing the issue
|
||||
> Crashlogs if the bug causes a crash
|
||||
>
|
||||
> Any other information you want to share that is relevant to the issue being
|
||||
> reported. This might include the lines of code that you have identified as
|
||||
> causing the bug, and potential solutions (and your opinions on their
|
||||
> merits).
|
||||
|
||||
## Feature requests
|
||||
|
||||
Before opening a feature request, please take a moment to find out whether your idea fits with the scope and aims of the project.
|
||||
|
||||
It's up to *you* to make a strong case to convince the project's developers of the merits of this feature.
|
||||
|
||||
Please provide as much detail and context as possible. This means don't request for a solution, but describe the problem you see and how/why you think it should be fixed.
|
||||
|
||||
For feature request we have a strict policy.
|
||||
|
||||
Keeping issues around with "a good idea" or "not really a bug but we should maybe fix it" turns out to have the reversed effect: nobody looks at it anymore.
|
||||
|
||||
Although we really appreciate feedback and ideas, we will close feature requests that we don't expect to fulfill in the next year.
|
||||
|
||||
Many of those ideas etc do have a place on the [forums](https://www.tt-forums.net); and if enough people like it, someone will stand up and make it.
|
||||
|
||||
It's usually best discuss in [irc](https://wiki.openttd.org/IRC_channel) before opening a feature request or working on a large feature in a fork.
|
||||
Discussion in irc can take time, but it can be productive and avoid disappointment :)
|
||||
|
||||
## Pull requests
|
||||
|
||||
Good pull requests—patches, improvements, new features—are a fantastic help.
|
||||
They should remain focused in scope and avoid containing unrelated commits.
|
||||
|
||||
**Please ask first** before embarking on any significant pull request (e.g. implementing features, refactoring code, porting to a different language), otherwise you risk spending a lot of time working on something that the project's developers might not want to merge into the project.
|
||||
|
||||
Please adhere to the [coding guidelines](#code-guidelines) used throughout the project (indentation, accurate comments, etc.) and any other requirements (such as test coverage).
|
||||
|
||||
Adhering to the following process is the best way to get your work included in the project:
|
||||
|
||||
1. [Fork](https://help.github.com/fork-a-repo/) the project, clone your fork, and configure the remotes:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/<your-username>/OpenTTD.git openttd
|
||||
git clone https://github.com/OpenTTD/OpenTTD-git-hooks.git openttd_hooks
|
||||
cd openttd
|
||||
git remote add upstream https://github.com/OpenTTD/OpenTTD.git
|
||||
cd .git/hooks
|
||||
ln -s -t . ../../../openttd_hooks/hooks/*
|
||||
```
|
||||
|
||||
2. If you cloned a while ago, get the latest changes from upstream:
|
||||
|
||||
```bash
|
||||
git fetch upstream
|
||||
```
|
||||
|
||||
3. Create a new topic branch (off the main project development branch) to
|
||||
contain your feature, change, or fix:
|
||||
|
||||
```bash
|
||||
git checkout upstream/master -b <topic-branch-name>
|
||||
```
|
||||
|
||||
4. Commit your changes in logical chunks. Please adhere to these [git commit message guidelines](https://wiki.openttd.org/Commit_style#Commit_message) or your code is unlikely to be merged into the main project.
|
||||
Use Git's [interactive rebase](https://help.github.com/articles/interactive-rebase) feature to tidy up your commits before making them public.
|
||||
|
||||
5. Locally rebase the upstream development branch into your topic branch:
|
||||
|
||||
```bash
|
||||
git fetch upstream
|
||||
git rebase upstream/master
|
||||
```
|
||||
|
||||
6. Push your topic branch up to your fork the first time:
|
||||
|
||||
```bash
|
||||
git push --set-upstream origin <topic-branch-name>
|
||||
```
|
||||
|
||||
And any time after that:
|
||||
|
||||
```bash
|
||||
git push
|
||||
```
|
||||
|
||||
7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) with a clear title and description against the `master` branch.
|
||||
|
||||
**IMPORTANT**: By submitting a patch, you agree to the [License](#license).
|
||||
|
||||
### Pull request validation
|
||||
|
||||
Continuous integration (CI) tools monitor pull requests, and help us identify build and code quality issues.
|
||||
|
||||
The results of the CI tests will show on your pull request.
|
||||
|
||||
By clicking on Details you can further zoom in; in case of a failure it will show you why it failed. In case of success it will report how awesome you were.
|
||||
|
||||
## Code guidelines
|
||||
|
||||
[Code style](https://wiki.openttd.org/Coding_style) must be adhered to for pull requests to be accepted
|
||||
|
||||
## License
|
||||
|
||||
By contributing your code, you agree to license your contribution under the [GPL v2](https://github.com/OpenTTD/OpenTTD/blob/master/COPYING).
|
||||
|
||||
### Attribution of this Contributing Guide
|
||||
|
||||
This contributing guide is adapted from [Bootstrap](https://github.com/twbs/bootstrap/blob/master/CONTRIBUTING.md) under the [Creative Commons Attribution 3.0 Unported License](https://github.com/twbs/bootstrap/blob/master/docs/LICENSE) terms for Bootstrap documentation.
|
@ -0,0 +1,75 @@
|
||||
#!/usr/bin/env groovy
|
||||
|
||||
// The stages we run one by one
|
||||
// Please don't add more than 2 items in a single stage; this hurts performance
|
||||
def ci_stages = [
|
||||
"Checkers": [
|
||||
"commit-checker": "openttd/compile-farm-ci:commit-checker",
|
||||
],
|
||||
"Compilers": [
|
||||
"linux-amd64-gcc-6": "openttd/compile-farm-ci:linux-amd64-gcc-6",
|
||||
"linux-amd64-clang-3.8": "openttd/compile-farm-ci:linux-amd64-clang-3.8",
|
||||
],
|
||||
"Archs": [
|
||||
"linux-i386-gcc-6": "openttd/compile-farm-ci:linux-i386-gcc-6",
|
||||
],
|
||||
"OS": [
|
||||
"osx-10.9": "openttd/compile-farm-ci:osx-10.9",
|
||||
],
|
||||
]
|
||||
|
||||
def generateStage(targets) {
|
||||
return targets.collectEntries{ key, target ->
|
||||
["${key}": generateCI(key, target)]
|
||||
}
|
||||
}
|
||||
|
||||
def generateCI(display_name, image_name) {
|
||||
return {
|
||||
githubNotify context: 'openttd/' + display_name, description: 'This commit is being built', status: 'PENDING'
|
||||
|
||||
try {
|
||||
dir("${display_name}") {
|
||||
unstash "source"
|
||||
|
||||
docker.image("${image_name}").pull()
|
||||
docker.image("${image_name}").withRun("--volumes-from ${hostname} --workdir " + pwd()) { c ->
|
||||
sh "docker logs --follow ${c.id}; exit `docker wait ${c.id}`"
|
||||
}
|
||||
}
|
||||
|
||||
githubNotify context: 'openttd/' + display_name, description: 'The commit looks good', status: 'SUCCESS'
|
||||
}
|
||||
catch (error) {
|
||||
githubNotify context: 'openttd/' + display_name, description: 'The commit cannot be built', status: 'FAILURE'
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
node {
|
||||
ansiColor('xterm') {
|
||||
stage("Checkout") {
|
||||
checkout scm
|
||||
|
||||
// Ensure user.email and user.name is set, otherwise rebase cannot work
|
||||
sh "git config user.email 'info@openttd.org'"
|
||||
sh "git config user.name 'OpenTTD CI'"
|
||||
|
||||
// Ensure we also have origin/master available
|
||||
sh "git fetch --no-tags origin master:refs/remotes/origin/master"
|
||||
|
||||
// Try to rebase to origin/master; if this fails, fail the CI
|
||||
sh "git rebase origin/master"
|
||||
|
||||
stash name: "source", useDefaultExcludes: false
|
||||
}
|
||||
|
||||
ci_stages.each { ci_stage ->
|
||||
stage(ci_stage.key) {
|
||||
parallel generateStage(ci_stage.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,8 @@
|
||||
/* $Id$ */
|
||||
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
Binary file not shown.
@ -0,0 +1,8 @@
|
||||
/* $Id$ */
|
||||
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
Binary file not shown.
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
@ -1,5 +1,5 @@
|
||||
!define APPBITS 32 ; Define number of bits for the architecture
|
||||
!define EXTRA_VERSION "95, 98, ME, 2000 and XP without SP3"
|
||||
!define APPARCH "win9x" ; Define the application architecture
|
||||
!define BINARY_DIR "${PATH_ROOT}bin"
|
||||
!define BINARY_DIR "${PATH_ROOT}objs\release"
|
||||
InstallDir "$PROGRAMFILES32\OpenTTD\"
|
||||
|
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" >
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!--This Id value indicates the application supports Windows Vista functionality -->
|
||||
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
|
||||
<!--This Id value indicates the application supports Windows 7 functionality-->
|
||||
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
|
||||
<!--This Id value indicates the application supports Windows 8 functionality-->
|
||||
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
|
||||
<!--This Id value indicates the application supports Windows 8.1 functionality-->
|
||||
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
|
||||
<!--This Id value indicates the application supports Windows 10 functionality-->
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
|
||||
</application>
|
||||
</compatibility>
|
||||
</assembly>
|
@ -0,0 +1,34 @@
|
||||
/* $Id$ */
|
||||
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */
|
||||
|
||||
#include "../script_client.hpp"
|
||||
#include "../template/template_client.hpp.sq"
|
||||
|
||||
|
||||
template <> const char *GetClassName<ScriptClient, ST_GS>() { return "GSClient"; }
|
||||
|
||||
void SQGSClient_Register(Squirrel *engine)
|
||||
{
|
||||
DefSQClass<ScriptClient, ST_GS> SQGSClient("GSClient");
|
||||
SQGSClient.PreRegister(engine);
|
||||
SQGSClient.AddConstructor<void (ScriptClient::*)(), 1>(engine, "x");
|
||||
|
||||
SQGSClient.DefSQConst(engine, ScriptClient::CLIENT_INVALID, "CLIENT_INVALID");
|
||||
SQGSClient.DefSQConst(engine, ScriptClient::CLIENT_SERVER, "CLIENT_SERVER");
|
||||
SQGSClient.DefSQConst(engine, ScriptClient::CLIENT_FIRST, "CLIENT_FIRST");
|
||||
|
||||
SQGSClient.DefSQStaticMethod(engine, &ScriptClient::ResolveClientID, "ResolveClientID", 2, ".i");
|
||||
SQGSClient.DefSQStaticMethod(engine, &ScriptClient::GetName, "GetName", 2, ".i");
|
||||
SQGSClient.DefSQStaticMethod(engine, &ScriptClient::GetCompany, "GetCompany", 2, ".i");
|
||||
SQGSClient.DefSQStaticMethod(engine, &ScriptClient::GetJoinDate, "GetJoinDate", 2, ".i");
|
||||
|
||||
SQGSClient.PostRegister(engine);
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/* $Id$ */
|
||||
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */
|
||||
|
||||
#include "../script_clientlist.hpp"
|
||||
#include "../template/template_clientlist.hpp.sq"
|
||||
|
||||
|
||||
template <> const char *GetClassName<ScriptClientList, ST_GS>() { return "GSClientList"; }
|
||||
|
||||
void SQGSClientList_Register(Squirrel *engine)
|
||||
{
|
||||
DefSQClass<ScriptClientList, ST_GS> SQGSClientList("GSClientList");
|
||||
SQGSClientList.PreRegister(engine, "GSList");
|
||||
SQGSClientList.AddConstructor<void (ScriptClientList::*)(), 1>(engine, "x");
|
||||
|
||||
SQGSClientList.PostRegister(engine);
|
||||
}
|
||||
|
||||
|
||||
template <> const char *GetClassName<ScriptClientList_Company, ST_GS>() { return "GSClientList_Company"; }
|
||||
|
||||
void SQGSClientList_Company_Register(Squirrel *engine)
|
||||
{
|
||||
DefSQClass<ScriptClientList_Company, ST_GS> SQGSClientList_Company("GSClientList_Company");
|
||||
SQGSClientList_Company.PreRegister(engine, "GSList");
|
||||
SQGSClientList_Company.AddConstructor<void (ScriptClientList_Company::*)(ScriptCompany::CompanyID company), 2>(engine, "xi");
|
||||
|
||||
SQGSClientList_Company.PostRegister(engine);
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
/* $Id$ */
|
||||
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @file script_client.cpp Implementation of ScriptClient. */
|
||||
|
||||
#include "../../stdafx.h"
|
||||
#include "script_client.hpp"
|
||||
#include "../../network/network.h"
|
||||
#include "../../network/network_base.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
#ifdef ENABLE_NETWORK
|
||||
/**
|
||||
* Finds NetworkClientInfo given client-identifier,
|
||||
* is used by other methods to resolve client-identifier.
|
||||
* @param client The client to get info structure for
|
||||
* @return A pointer to corresponding CI struct or NULL when not found.
|
||||
*/
|
||||
static NetworkClientInfo *FindClientInfo(ScriptClient::ClientID client)
|
||||
{
|
||||
if (client == ScriptClient::CLIENT_INVALID) return NULL;
|
||||
if (!_networking) return NULL;
|
||||
return NetworkClientInfo::GetByClientID((::ClientID)client);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* static */ ScriptClient::ClientID ScriptClient::ResolveClientID(ScriptClient::ClientID client)
|
||||
{
|
||||
#ifdef ENABLE_NETWORK
|
||||
return (FindClientInfo(client) == NULL ? ScriptClient::CLIENT_INVALID : client);
|
||||
#else
|
||||
return CLIENT_INVALID;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* static */ char *ScriptClient::GetName(ScriptClient::ClientID client)
|
||||
{
|
||||
#ifdef ENABLE_NETWORK
|
||||
NetworkClientInfo *ci = FindClientInfo(client);
|
||||
if (ci == NULL) return NULL;
|
||||
return stredup(ci->client_name);
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* static */ ScriptCompany::CompanyID ScriptClient::GetCompany(ScriptClient::ClientID client)
|
||||
{
|
||||
#ifdef ENABLE_NETWORK
|
||||
NetworkClientInfo *ci = FindClientInfo(client);
|
||||
if (ci == NULL) return ScriptCompany::COMPANY_INVALID;
|
||||
return (ScriptCompany::CompanyID)ci->client_playas;
|
||||
#else
|
||||
return ScriptCompany::COMPANY_INVALID;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* static */ ScriptDate::Date ScriptClient::GetJoinDate(ScriptClient::ClientID client)
|
||||
{
|
||||
#ifdef ENABLE_NETWORK
|
||||
NetworkClientInfo *ci = FindClientInfo(client);
|
||||
if (ci == NULL) return ScriptDate::DATE_INVALID;
|
||||
return (ScriptDate::Date)ci->join_date;
|
||||
#else
|
||||
return ScriptDate::DATE_INVALID;
|
||||
#endif
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
/* $Id$ */
|
||||
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @file script_client.hpp Everything to query a network client's information */
|
||||
|
||||
#ifndef SCRIPT_CLIENT_HPP
|
||||
#define SCRIPT_CLIENT_HPP
|
||||
|
||||
#include "script_text.hpp"
|
||||
#include "script_date.hpp"
|
||||
#include "script_company.hpp"
|
||||
#include "../../network/network_type.h"
|
||||
|
||||
/**
|
||||
* Class that handles all client related functions.
|
||||
*
|
||||
* @api game
|
||||
*/
|
||||
class ScriptClient : public ScriptObject {
|
||||
public:
|
||||
|
||||
/** Different constants related to ClientID. */
|
||||
enum ClientID {
|
||||
CLIENT_INVALID = 0, ///< Client is not part of anything
|
||||
CLIENT_SERVER = 1, ///< Servers always have this ID
|
||||
CLIENT_FIRST = 2, ///< The first client ID
|
||||
};
|
||||
|
||||
/**
|
||||
* Resolves the given client id to the correct index for the client.
|
||||
* If the client with the given id does not exist it will
|
||||
* return CLIENT_INVALID.
|
||||
* @param client The client id to resolve.
|
||||
* @return The resolved client id.
|
||||
*/
|
||||
static ClientID ResolveClientID(ClientID client);
|
||||
|
||||
/**
|
||||
* Get the name of the given client.
|
||||
* @param client The client to get the name for.
|
||||
* @pre ResolveClientID(client) != CLIENT_INVALID.
|
||||
* @return The name of the given client.
|
||||
*/
|
||||
static char *GetName(ClientID client);
|
||||
|
||||
/**
|
||||
* Get the company in which the given client is playing.
|
||||
* @param client The client to get company for.
|
||||
* @pre ResolveClientID(client) != CLIENT_INVALID.
|
||||
* @return The company in which client is playing or COMPANY_SPECTATOR.
|
||||
*/
|
||||
static ScriptCompany::CompanyID GetCompany(ClientID client);
|
||||
|
||||
/**
|
||||
* Get the game date when the given client has joined.
|
||||
* @param client The client to get joining date for.
|
||||
* @pre ResolveClientID(client) != CLIENT_INVALID.
|
||||
* @return The date when client has joined.
|
||||
*/
|
||||
static ScriptDate::Date GetJoinDate(ClientID client);
|
||||
};
|
||||
|
||||
|
||||
#endif /* SCRIPT_CLIENT_HPP */
|
@ -0,0 +1,49 @@
|
||||
/* $Id$ */
|
||||
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @file script_clientlist.cpp Implementation of ScriptClientList and friends. */
|
||||
|
||||
#include "../../stdafx.h"
|
||||
#include "script_company.hpp"
|
||||
#include "script_clientlist.hpp"
|
||||
#include "../../network/network.h"
|
||||
#include "../../network/network_base.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
ScriptClientList::ScriptClientList()
|
||||
{
|
||||
#ifdef ENABLE_NETWORK
|
||||
if (!_networking) return;
|
||||
NetworkClientInfo *ci;
|
||||
FOR_ALL_CLIENT_INFOS(ci) {
|
||||
this->AddItem(ci->client_id);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
ScriptClientList_Company::ScriptClientList_Company(ScriptCompany::CompanyID company)
|
||||
{
|
||||
#ifdef ENABLE_NETWORK
|
||||
if (!_networking) return;
|
||||
CompanyID c;
|
||||
if (company == ScriptCompany::COMPANY_SPECTATOR) {
|
||||
c = ::COMPANY_SPECTATOR;
|
||||
} else {
|
||||
company = ScriptCompany::ResolveCompanyID(company);
|
||||
if (company == ScriptCompany::COMPANY_INVALID) return;
|
||||
c = (CompanyID)company;
|
||||
}
|
||||
|
||||
NetworkClientInfo *ci;
|
||||
FOR_ALL_CLIENT_INFOS(ci) {
|
||||
if (ci->client_playas == c) this->AddItem(ci->client_id);
|
||||
}
|
||||
#endif
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/* $Id$ */
|
||||
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @file script_clientlist.hpp List all the TODO. */
|
||||
|
||||
#ifndef SCRIPT_CLIENTLIST_HPP
|
||||
#define SCRIPT_CLIENTLIST_HPP
|
||||
|
||||
#include "script_list.hpp"
|
||||
#include "script_company.hpp"
|
||||
|
||||
|
||||
/**
|
||||
* Creates a list of clients that are currently in game.
|
||||
* @api game
|
||||
* @ingroup ScriptList
|
||||
*/
|
||||
class ScriptClientList : public ScriptList {
|
||||
public:
|
||||
ScriptClientList();
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a list of clients that are playing in the company.
|
||||
* @api game
|
||||
* @ingroup ScriptList
|
||||
*/
|
||||
class ScriptClientList_Company : public ScriptList {
|
||||
public:
|
||||
/**
|
||||
* @param company_id The company to list clients for.
|
||||
*/
|
||||
ScriptClientList_Company(ScriptCompany::CompanyID company);
|
||||
};
|
||||
|
||||
#endif /* SCRIPT_CIENTLIST_HPP */
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue