Skip to content

Commit

Permalink
linted the code, follows google c++ standards
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkite committed May 27, 2016
1 parent 033c411 commit 2009dcd
Show file tree
Hide file tree
Showing 52 changed files with 5,122 additions and 6,572 deletions.
24 changes: 24 additions & 0 deletions LICENSE
@@ -0,0 +1,24 @@
Copyright (c) 2016, Sean Kasun
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.

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 HOLDER 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.
80 changes: 0 additions & 80 deletions README

This file was deleted.

117 changes: 117 additions & 0 deletions README.md
@@ -0,0 +1,117 @@
This is the source code for Minutor 2.1
web/ contains the source code for the web-based pack builder. The live version
can be found at http://seancode.com/minutor/packs

The Makefile inside web/ will use the Closure Compiler to compile all the .js files
into a single editor.min.js. To host the pack builder on your own website, you
only need editor.min.js, index.html, main.css, and the mods/ folder.

CONVENTIONS:
------------

The coding convetion is standardized on the result of Google's cpplint.
https://github.com/google/styleguide/tree/gh-pages/cpplint

We also use clang's static analyzer. The options tested are in `check.sh`.


COMPILING:
---------

All Platforms:
Use QtCreator (Qt5 version) and open minutor.pro


How to do a static compile on Windows:
-------------------------------------

Download the qt5.5 sourcecode.

Unzip it whereever you wish, it's a large file and contains a lot of nested
subdirectories, so you'll probably want to put it in <samp>C:\Qt5\src</samp> or
something similar since you could end up running into Windows' path-length
limitations otherwise.

Now edit <samp>qtbase\mkspecs\common\msvc-desktop.conf</samp>

Find the CONFIG line and remove `embed_manifest_dll` and `embed_manifest_exe`
from that line.

Next find `QMAKE_CFLAGS_*` and change `-MD` to `-MT` and `-MDd` to `-MTd`.

Open your developer command prompt (64-bit), cd into the qtbase folder and
run:

```bat
configure -prefix %CD% -debug-and-release -opensource -confirm-license
-platform win32-msvc2013 -nomake tests -nomake examples
-opengl desktop -static
nmake
```

If nmake complains about python or perl, install ActivePerl and ActivePython and
try again. This compile will take a long time.

This should make a static Qt5 with both debug and release libraries. Now in
QtCreator, go to Tools → Options... and select Qt Versions from Build & Run.
Add a new Qt Version and locate the `qmake.exe` that is inside
<samp>qtbase\bin</samp> of the Qt5 you just compiled.
There will be a warning flag because we didn't compile qmlscene or qmlviewer
or any helpers. You can ignore that warning.

Then switch over to Kits and make a new kit that uses the Qt version you just
created. Again, there will be a warning flag for the same reasons as before,
ignore it.

Now compile Minutor using the static Kit. You should end up with a statically
linked minutor.exe which doesn't require any dlls to run.


Building for Linux:
------------------

Use qmake to generate a makefile then run make. Or use QtCreator.

If you want to make a .deb package,

```console
$ debuild
```

To make a package for another distribution:

```console
$ pbuilder-dist vivid create # called only once to generate environment
$ debuild -S -us -uc
$ cd ..
$ pbuilder-dist vivid build *.dsc
```


Building on OSX:
----------------

Make a static compile of Qt 5.5:


```console
$ git clone https://code.qt.io/qt/qt5.git
$ cd qt5
$ perl init-repository --module-subset=default,-qtwebkit,-qtwebkit-examples,-qtwebengine
(wait forever)
$ git checkout 5.5
$ ./configure -prefix $PWD -opensource -confirm-license -nomake tests -nomake
examples -release -static
$ make
(wait forever)
```

Then compile Minutor:

```console
$ cd minutor
$ ~/qt5/qtbase/bin/qmake
$ make
```

You'll end up with a minutor.app in the current directory.
130 changes: 48 additions & 82 deletions biomeidentifier.cpp
@@ -1,94 +1,60 @@
/*
Copyright (c) 2013, Sean Kasun
All rights reserved.
/** Copyright (c) 2013, Sean Kasun */

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.
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 HOLDER 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.
*/

#include "biomeidentifier.h"
#include "json.h"
#include "./biomeidentifier.h"
#include "./json.h"

static BiomeInfo unknownBiome;
BiomeIdentifier::BiomeIdentifier()
{
unknownBiome.name="Unknown";
BiomeIdentifier::BiomeIdentifier() {
unknownBiome.name = "Unknown";
}
BiomeIdentifier::~BiomeIdentifier()
{
for (int i=0;i<packs.length();i++)
{
for (int j=0;j<packs[i].length();j++)
delete packs[i][j];
}
BiomeIdentifier::~BiomeIdentifier() {
for (int i = 0; i < packs.length(); i++) {
for (int j = 0; j < packs[i].length(); j++)
delete packs[i][j];
}
}

BiomeInfo &BiomeIdentifier::getBiome(int biome)
{
QList<BiomeInfo*> &list=biomes[biome];
//search backwards for priority sorting to work
for (int i=list.length()-1;i>=0;i--)
if (list[i]->enabled)
return *list[i];
return unknownBiome;
BiomeInfo &BiomeIdentifier::getBiome(int biome) {
QList<BiomeInfo*> &list = biomes[biome];
// search backwards for priority sorting to work
for (int i = list.length() - 1; i >= 0; i--)
if (list[i]->enabled)
return *list[i];
return unknownBiome;
}

void BiomeIdentifier::enableDefinitions(int pack)
{
if (pack<0) return;
int len=packs[pack].length();
for (int i=0;i<len;i++)
packs[pack][i]->enabled=true;
void BiomeIdentifier::enableDefinitions(int pack) {
if (pack < 0) return;
int len = packs[pack].length();
for (int i = 0; i < len; i++)
packs[pack][i]->enabled = true;
}
void BiomeIdentifier::disableDefinitions(int pack)
{
if (pack<0) return;
int len=packs[pack].length();
for (int i=0;i<len;i++)
packs[pack][i]->enabled=false;
void BiomeIdentifier::disableDefinitions(int pack) {
if (pack < 0) return;
int len = packs[pack].length();
for (int i = 0; i < len; i++)
packs[pack][i]->enabled = false;
}

int BiomeIdentifier::addDefinitions(JSONArray *defs,int pack)
{
if (pack==-1)
{
pack=packs.length();
packs.append(QList<BiomeInfo *>());
}

int len=defs->length();
for (int i=0;i<len;i++)
{
JSONObject *b=dynamic_cast<JSONObject *>(defs->at(i));
int id=b->at("id")->asNumber();

BiomeInfo *biome=new BiomeInfo();
biome->enabled=true;
if (b->has("name"))
biome->name=b->at("name")->asString();
else
biome->name="Unknown";
biomes[id].append(biome);
packs[pack].append(biome);
}
return pack;
int BiomeIdentifier::addDefinitions(JSONArray *defs, int pack) {
if (pack == -1) {
pack = packs.length();
packs.append(QList<BiomeInfo *>());
}

int len = defs->length();
for (int i = 0; i < len; i++) {
JSONObject *b = dynamic_cast<JSONObject *>(defs->at(i));
int id = b->at("id")->asNumber();

BiomeInfo *biome = new BiomeInfo();
biome->enabled = true;
if (b->has("name"))
biome->name = b->at("name")->asString();
else
biome->name = "Unknown";
biomes[id].append(biome);
packs[pack].append(biome);
}
return pack;
}

0 comments on commit 2009dcd

Please sign in to comment.