Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #12 from idietmoran/dev
Browse files Browse the repository at this point in the history
0.0.5
  • Loading branch information
Stateford authored Nov 13, 2017
2 parents 4058c6e + 06b0914 commit 2a1f84f
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 208 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

.gitmodules
packages.config
*.iss
*.iscc
*.vcxproj
*.vcxproj.*
*.aps
*.rc
*.rc
17 changes: 15 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
# Changelog
All notable changes to this project will be documented in this file.

## [0.0.5]
### Added
- Attempts to bring up users page. If multiple users are found, the search page will be brought up.

## [0.0.4]
### Added
- Multithreading for workers
- Multithreading for workers

### Changed
- Reduced CPU usage by 95% (Down to 0.5% from 10%)

## [0.0.3]
### Changed
- Reduced CPU usage by 95% (Down to 0.5% from 10%)
- Removed flickering

## [0.0.2]
## Added
- Only one executable required for both dx9 and dx11.
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,8 @@ state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
FFXIV Party Logs - Reads the party list from memory and makes a http request to fflogs in the users default browser
Copyright (C) 2017 idietmoran

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
### DISCLAIMER
This program reads from process memory. Use at your own risk!

### PRE-REQ
[Microsoft C++ Redistrubutable 2015](https://www.microsoft.com/en-us/download/details.aspx?id=52685)

#### DESCRIPTION
This program reads the names of party members by memory and opens their username in a search page in your default browser.

Expand All @@ -16,17 +13,14 @@ This program reads the names of party members by memory and opens their username
[Youtube](https://youtu.be/r9TKVYfq_b0)

#### Known Issues
- Doesn't update cross-world parties
- Doesn't update cross-world parties (The memory addresses for cross-world are not static, it's going to take some digging and some patient people)
- Lists previous members in the party list until someone new overwrites their position (thank SE for this, still looking for solution)

#### TODO

=======
----------------
- Crossworld Parties
- Cross-world Parties
- Add stats directly to program
- UI


-----------------------------------------
## [DOWNLOAD](https://github.com/idietmoran/FFXIV-Party-Logs/releases)

1 change: 1 addition & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "src/menu.h"
#include <thread>


int main()
{
Menu menu;
Expand Down
1 change: 0 additions & 1 deletion src/bin/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <cpprest/http_client.h>
#include <cpprest/filestream.h>


using namespace utility;
using namespace web::http;
using namespace web::http::client;
Expand Down
5 changes: 0 additions & 5 deletions src/bin/request.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
#pragma once

#include <cpprest/http_client.h>
#include <cpprest/filestream.h>
#include <string>

using namespace utility;
using namespace web::http;
using namespace web::http::client;
using namespace concurrency::streams;

namespace Request
{
Expand Down
200 changes: 32 additions & 168 deletions src/player/player.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#include "player.h"
#include "../bin/request.h"
#include <iostream>
#include <codecvt>
#include <thread>

std::wstring Player::clientId = L"ae759d44880e5523d5fb3b59df028c64";

bool Player::characterCheck()
bool Player::getCharId()
{
// convert name_ from char to wstring
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
Expand All @@ -15,197 +13,63 @@ bool Player::characterCheck()
std::wstring tempName = wide;
std::wstring fullName = tempName.substr(0, tempName.find(L" ")) + L"%20" + tempName.substr((tempName.find(L" ") + 1), tempName.size());

int characterCount = 0;

std::wstring prevBody;
/*
* do it by each datacenter
*/
//std::thread t1([=, &prevBody, &characterCount] { naRequests(fullName, prevBody, characterCount); });
//std::thread t2([=, &prevBody, &characterCount] { euRequests(fullName, prevBody, characterCount); });
//std::thread t3([=, &prevBody, &characterCount] { jpRequests(fullName, prevBody, characterCount); });

naRequests(fullName, prevBody, characterCount);
euRequests(fullName, prevBody, characterCount);
jpRequests(fullName, prevBody, characterCount);
std::wstring body;

//t1.join();
//t2.join();
//t3.join();


// std::wcout << prevBody << std::endl;
Request::get(baseUrlW_ + fullName, body);

if(characterCount < 2 && characterCount > 0 && prevBody != L"" && !prevBody.empty())
if (!body.empty())
{
prevBody = prevBody.substr(prevBody.find(L"character_id"), prevBody.size());
prevBody = prevBody.substr(prevBody.find_first_of(L": ") + 2, prevBody.find_first_of(L","));
prevBody.erase(std::remove_if(prevBody.begin(), prevBody.end(), ::isspace), prevBody.end());
prevBody.pop_back();
//parseJson(prevBody);
characterId_ = prevBody;
return true;
}

return false;
}
std::wstring tempBody;

void Player::charRequest(std::wstring fullName, std::vector<std::wstring> dataCenter, std::wstring region, std::wstring &prevBody, int &characterCount)
{
for (auto &p : dataCenter)
{
std::wstring body;
// temp url
std::wstring apiUrl = baseApiUrl_;
//Chelsea % 20Chelsea / Hyperion / EU / ? api_key = ${ clientID }
// https://www.fflogs.com:443/v1/parses/character/Chelsea%20Chelsea/hyperion/na/?api_key=ae759d44880e5523d5fb3b59df028c64
// build url
apiUrl += fullName + L"/" + p + L"/" + region + L"/?api_key=" + clientId;
std::wcout << apiUrl << std::endl;
Request::get(apiUrl, body);

if (!body.empty() && body.size() > 15)
if (body.find(L"/character/id/") == std::string::npos)
{
std::wcout << body << std::endl;
prevBody = body;

characterCount++;
return false;
}
}
}


void Player::naRequests(std::wstring fullName, std::wstring& prevBody, int& characterCount)
{
std::vector<std::thread*> threads;
for (auto &p : naServers_)
{
std::wstring body;
// temp url
std::wstring apiUrl = baseApiUrl_;
//Chelsea % 20Chelsea / Hyperion / EU / ? api_key = ${ clientID }
// https://www.fflogs.com:443/v1/parses/character/Chelsea%20Chelsea/hyperion/na/?api_key=ae759d44880e5523d5fb3b59df028c64
// build url
apiUrl += fullName + L"/" + p + L"/na/?api_key=" + clientId;
//std::wcout << apiUrl << std::endl;

threads.push_back(new std::thread([=, &body, &prevBody, &characterCount] {
Request::get(apiUrl, body);
if (!body.empty() && body.size() > 15)
{
prevBody = body;
characterCount++;
}
}));

}

for(auto &p: threads)
{
p->join();
}
}
tempBody = body.substr(body.find(L"/character/id/"), body.size());
std::wstring tempBody2 = tempBody;
body = tempBody.substr(0, tempBody.find_first_of(L"\""));
tempBody2 = tempBody2.substr(tempBody2.find(L"</a>"), tempBody2.size());

void Player::euRequests(std::wstring fullName, std::wstring& prevBody, int& characterCount)
{
std::vector<std::thread*> threads;
for (auto &p : naServers_)
{
std::wstring body;
// temp url
std::wstring apiUrl = baseApiUrl_;
//Chelsea % 20Chelsea / Hyperion / EU / ? api_key = ${ clientID }
// https://www.fflogs.com:443/v1/parses/character/Chelsea%20Chelsea/hyperion/na/?api_key=ae759d44880e5523d5fb3b59df028c64
// build url
apiUrl += fullName + L"/" + p + L"/eu/?api_key=" + clientId;
//std::wcout << apiUrl << std::endl;

threads.push_back(new std::thread([=, &body, &prevBody, &characterCount] {
Request::get(apiUrl, body);
if (!body.empty() && body.size() > 15)
{
prevBody = body;
characterCount++;
}
}));

}

for (auto &p : threads)
{
p->join();
}
}

void Player::jpRequests(std::wstring fullName, std::wstring& prevBody, int& characterCount)
{
std::vector<std::thread*> threads;
for (auto &p : naServers_)
{
std::wstring body;
// temp url
std::wstring apiUrl = baseApiUrl_;
//Chelsea % 20Chelsea / Hyperion / EU / ? api_key = ${ clientID }
// https://www.fflogs.com:443/v1/parses/character/Chelsea%20Chelsea/hyperion/na/?api_key=ae759d44880e5523d5fb3b59df028c64
// build url
apiUrl += fullName + L"/" + p + L"/jp/?api_key=" + clientId;
//std::wcout << apiUrl << std::endl;

threads.push_back(new std::thread([=, &body, &prevBody, &characterCount] {
Request::get(apiUrl, body);
if (!body.empty() && body.size() > 15)
{
prevBody = body;
characterCount++;
}
}));

}
if (tempBody2.find(L"/character/id/") != std::wstring::npos)
{
return false;
}

for (auto &p : threads)
{
p->join();
characterId_ = body.substr(body.find_last_of(L"/") + 1, body.size());
return true;
}
return false;
}

void Player::parseJson(std::wstring *&body)
void Player::parseSearch(std::wstring &body)
{
*body = body->substr(body->find(L"character_id"), body->size());
//auto charIdBegin = body->find_first_of(L": ");
//auto charIdEnd = body->find_first_of(L",");
*body = body->substr(body->find_first_of(L": ") + 2, body->find_first_of(L","));
body->erase(std::remove_if(body->begin(), body->end(), ::isspace), body->end());
body->pop_back();
body = body;
body = body.substr(body.find(L"/character/id/", body.size()));
body = body.substr(0, body.find(L"\""));
}

void Player::openBrowser()
{
std::string fullUrl = baseUrl_;
fullUrl += name_;
std::string tempName = name_;

std::string firstName = tempName.substr(0, tempName.find(" "));
std::string lastName = tempName.substr((tempName.find(" ") + 1), tempName.size());

std::string fullName = firstName + "%20" + lastName;

//if(!getCharacterId())
//{
// ShellExecute(NULL, "open", (baseUrl_ + fullName).c_str(), NULL, NULL, SW_SHOWNORMAL);
//}

if (characterCheck())
if (getCharId())
{
std::wstring url = L"https://www.fflogs.com/character/id/";
url += characterId_;
std::wstring url = L"https://www.fflogs.com/character/id/" + characterId_;
//url += characterId_;
ShellExecuteW(NULL, L"open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);
}
else
{
std::string tempName = name_;

std::string firstName = tempName.substr(0, tempName.find(" "));
std::string lastName = tempName.substr((tempName.find(" ") + 1), tempName.size());

std::string fullName = firstName + "%20" + lastName;

ShellExecute(NULL, "open", (baseUrl_ + fullName).c_str(), NULL, NULL, SW_SHOWNORMAL);
}

}

bool Player::compare(Player* player)
Expand Down
24 changes: 3 additions & 21 deletions src/player/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,8 @@ class Player
{
protected:
static std::wstring clientId;
//std::vector<std::wstring> regions_ = {L"NA", L"EU", L"JP"};
std::vector<std::wstring> naServers_ = {L"adamantoise", L"balmung", L"cactaur", L"coeurl",
L"faerie", L"gilgamesh", L"goblin", L"jenova",
L"mateus", L"midgardsormr", L"sargatanas", L"siren",
L"zalera", L"behemoth", L"brynhildr", L"diabolos",
L"excalibur", L"exodus", L"famfrit", L"hyperion",
L"lamia", L"leviathan", L"malboro", L"ultros"};
std::vector<std::wstring> euServers_ = {L"cerberus", L"lich", L"louisoix", L"moogle",
L"odin", L"omega", L"phoenix", L"ragnarok",
L"shiva", L"zodiark"};
std::vector<std::wstring> jpServers_ = {L"anima", L"asura", L"belias", L"chocobo",
L"hades", L"ixion", L"mandragora", L"masumune",
L"pandaemonium", L"shinryu", L"titan", L"alexander",
L"bahamut", L"durandal", L"fenrir", L"ifrit",
L"ridill", L"tiamat", L"ultima", L"valefor",
L"yojimba", L"zeromus", L"aegis", L"atomos",
L"carbuncle", L"garuda", L"gungnir", L"kujata",
L"ramuh", L"tonberry", L"typhon", L"unicorn"};
std::wstring baseApiUrl_ = L"https://www.fflogs.com:443/v1/parses/character/";
std::wstring baseUrlW_ = L"https://www.fflogs.com/search/?term=";
std::string baseUrl_ = "https://www.fflogs.com/search/?term=";
std::wstring characterId_;
public:
Expand All @@ -35,10 +18,9 @@ class Player
virtual void display() = 0;
bool characterCheck();
void charRequest(std::wstring, std::vector<std::wstring>, std::wstring, std::wstring&, int&);
void naRequests(std::wstring, std::wstring&, int&);
void euRequests(std::wstring, std::wstring&, int&);
void jpRequests(std::wstring, std::wstring&, int&);
bool getCharId();
void parseJson(std::wstring*&);
void parseSearch(std::wstring&);
void openBrowser();
bool compare(Player*);
};

0 comments on commit 2a1f84f

Please sign in to comment.